1 6 7 package javax.emb; 8 9 import java.io.Serializable; 10 import java.util.Collection; 11 import java.util.Collections; 12 import java.util.HashMap; 13 import java.util.Map; 14 15 51 public final class ProtocolConstraints implements Serializable 52 { 53 public final static String CLIENT_TYPE = "CLIENT_TYPE"; 54 public final static String SERVER_TYPE = "SERVER_TYPE"; 55 56 private final Map constraints = Collections.synchronizedMap(new HashMap()); 57 58 66 public Object getConstraint(String type) 67 { 68 if (type == null) 69 { 70 throw new NullPointerException(); 71 } 72 73 return constraints.get(type); 74 } 75 76 89 public void setConstraint(String type, Object value) 90 { 91 if (type == null) 92 { 93 throw new NullPointerException(); 94 } 95 96 if ((type.equals(CLIENT_TYPE) || type.equals(SERVER_TYPE)) 97 && !(value instanceof String[])) 98 { 99 throw new IllegalArgumentException(); 100 } 101 102 constraints.put(type, value); 103 } 104 105 110 public String[] getConstraintTypes() 111 { 112 Collection keySet = constraints.keySet(); 113 return (String[]) keySet.toArray(new String[keySet.size()]); 114 } 115 } | Popular Tags |