1 17 package com.sun.org.apache.xml.internal.security.transforms.params; 18 19 20 21 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 22 import com.sun.org.apache.xml.internal.security.transforms.TransformParam; 23 import com.sun.org.apache.xml.internal.security.utils.ElementProxy; 24 import org.w3c.dom.Document ; 25 import org.w3c.dom.Element ; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.NodeList ; 28 29 30 38 public class XPath2FilterContainer04 extends ElementProxy 39 implements TransformParam { 40 41 42 private static final String _ATT_FILTER = "Filter"; 43 44 45 private static final String _ATT_FILTER_VALUE_INTERSECT = "intersect"; 46 47 48 private static final String _ATT_FILTER_VALUE_SUBTRACT = "subtract"; 49 50 51 private static final String _ATT_FILTER_VALUE_UNION = "union"; 52 53 54 public static final String _TAG_XPATH2 = "XPath"; 55 56 57 public static final String XPathFilter2NS = 58 "http://www.w3.org/2002/04/xmldsig-filter2"; 59 60 64 private XPath2FilterContainer04() { 65 66 } 68 69 76 private XPath2FilterContainer04(Document doc, String xpath2filter, 77 String filterType) { 78 79 super(doc); 80 81 this._constructionElement.setAttributeNS(null, XPath2FilterContainer04._ATT_FILTER, 82 filterType); 83 84 if ((xpath2filter.length() > 2) 85 && (!Character.isWhitespace(xpath2filter.charAt(0)))) { 86 this._constructionElement.appendChild(doc.createTextNode("\n" 87 + xpath2filter + "\n")); 88 } else { 89 this._constructionElement 90 .appendChild(doc.createTextNode(xpath2filter)); 91 } 92 } 93 94 101 private XPath2FilterContainer04(Element element, String BaseURI) 102 throws XMLSecurityException { 103 104 super(element, BaseURI); 105 106 String filterStr = 107 this._constructionElement 108 .getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER); 109 110 if (!filterStr 111 .equals(XPath2FilterContainer04 112 ._ATT_FILTER_VALUE_INTERSECT) &&!filterStr 113 .equals(XPath2FilterContainer04 114 ._ATT_FILTER_VALUE_SUBTRACT) &&!filterStr 115 .equals(XPath2FilterContainer04._ATT_FILTER_VALUE_UNION)) { 116 Object exArgs[] = { XPath2FilterContainer04._ATT_FILTER, filterStr, 117 XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT 118 + ", " 119 + XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT 120 + " or " 121 + XPath2FilterContainer04._ATT_FILTER_VALUE_UNION }; 122 123 throw new XMLSecurityException("attributeValueIllegal", exArgs); 124 } 125 } 126 127 134 public static XPath2FilterContainer04 newInstanceIntersect(Document doc, 135 String xpath2filter) { 136 137 return new XPath2FilterContainer04(doc, xpath2filter, 138 XPath2FilterContainer04 139 ._ATT_FILTER_VALUE_INTERSECT); 140 } 141 142 149 public static XPath2FilterContainer04 newInstanceSubtract(Document doc, 150 String xpath2filter) { 151 152 return new XPath2FilterContainer04(doc, xpath2filter, 153 XPath2FilterContainer04 154 ._ATT_FILTER_VALUE_SUBTRACT); 155 } 156 157 164 public static XPath2FilterContainer04 newInstanceUnion(Document doc, 165 String xpath2filter) { 166 167 return new XPath2FilterContainer04(doc, xpath2filter, 168 XPath2FilterContainer04 169 ._ATT_FILTER_VALUE_UNION); 170 } 171 172 181 public static XPath2FilterContainer04 newInstance( 182 Element element, String BaseURI) throws XMLSecurityException { 183 return new XPath2FilterContainer04(element, BaseURI); 184 } 185 186 191 public boolean isIntersect() { 192 193 return this._constructionElement 194 .getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER) 195 .equals(XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT); 196 } 197 198 203 public boolean isSubtract() { 204 205 return this._constructionElement 206 .getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER) 207 .equals(XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT); 208 } 209 210 215 public boolean isUnion() { 216 217 return this._constructionElement 218 .getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER) 219 .equals(XPath2FilterContainer04._ATT_FILTER_VALUE_UNION); 220 } 221 222 227 public String getXPathFilterStr() { 228 return this.getTextFromTextChild(); 229 } 230 231 239 public Node getXPathFilterTextNode() { 240 NodeList children = this._constructionElement.getChildNodes(); 241 int length = children.getLength(); 242 243 for (int i = 0; i < length; i++) { 244 if (children.item(i).getNodeType() == Node.TEXT_NODE) { 245 return children.item(i); 246 } 247 } 248 249 return null; 250 } 251 252 253 public final String getBaseLocalName() { 254 return XPath2FilterContainer04._TAG_XPATH2; 255 } 256 257 258 public final String getBaseNamespace() { 259 return XPath2FilterContainer04.XPathFilter2NS; 260 } 261 } 262 | Popular Tags |