1 4 7 package javax.xml.crypto.dsig.spec; 8 9 import java.util.Collections ; 10 import java.util.Iterator ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 49 public class XPathType { 50 51 54 public static class Filter { 55 private final String operation; 56 57 private Filter(String operation) { 58 this.operation = operation; 59 } 60 61 66 public String toString() { 67 return operation; 68 } 69 70 73 public static final Filter INTERSECT = new Filter("intersect"); 74 75 78 public static final Filter SUBTRACT = new Filter("subtract"); 79 80 83 public static final Filter UNION = new Filter("union"); 84 } 85 86 private final String expression; 87 private final Filter filter; 88 private Map nsMap; 89 90 100 public XPathType(String expression, Filter filter) { 101 if (expression == null) { 102 throw new NullPointerException ("expression cannot be null"); 103 } 104 if (filter == null) { 105 throw new NullPointerException ("filter cannot be null"); 106 } 107 this.expression = expression; 108 this.filter = filter; 109 this.nsMap = Collections.EMPTY_MAP; 110 } 111 112 129 public XPathType(String expression, Filter filter, Map namespaceMap) { 130 this(expression, filter); 131 if (namespaceMap == null) { 132 throw new NullPointerException ("namespaceMap cannot be null"); 133 } 134 nsMap = new HashMap (namespaceMap); 135 Iterator entries = nsMap.entrySet().iterator(); 136 while (entries.hasNext()) { 137 Map.Entry me = (Map.Entry ) entries.next(); 138 if (!(me.getKey() instanceof String ) || 139 !(me.getValue() instanceof String )) { 140 throw new ClassCastException ("not a String"); 141 } 142 } 143 nsMap = Collections.unmodifiableMap(nsMap); 144 } 145 146 151 public String getExpression() { 152 return expression; 153 } 154 155 160 public Filter getFilter() { 161 return filter; 162 } 163 164 175 public Map getNamespaceMap() { 176 return nsMap; 177 } 178 } 179 | Popular Tags |