FileDocCategorySizeDatePackage
XPath2FilterContainer.javaAPI DocJava SE 6 API9760Tue Jun 10 00:23:04 BST 2008com.sun.org.apache.xml.internal.security.transforms.params

XPath2FilterContainer

public class XPath2FilterContainer extends ElementProxy implements TransformParam
Implements the parameters for the XPath Filter v2.0.
author
$Author: raul $
see
XPath Filter v2.0 (TR)
see
XPath Filter v2.0 (editors copy)

Fields Summary
private static final String
_ATT_FILTER
Field _ATT_FILTER
private static final String
_ATT_FILTER_VALUE_INTERSECT
Field _ATT_FILTER_VALUE_INTERSECT
private static final String
_ATT_FILTER_VALUE_SUBTRACT
Field _ATT_FILTER_VALUE_SUBTRACT
private static final String
_ATT_FILTER_VALUE_UNION
Field _ATT_FILTER_VALUE_UNION
public static final String
INTERSECT
Field INTERSECT
public static final String
SUBTRACT
Field SUBTRACT
public static final String
UNION
Field UNION
public static final String
_TAG_XPATH2
Field _TAG_XPATH2
public static final String
XPathFilter2NS
Field XPathFiler2NS
Constructors Summary
private XPath2FilterContainer()
Constructor XPath2FilterContainer


         
     

      // no instantiation
   
private XPath2FilterContainer(Document doc, String xpath2filter, String filterType)
Constructor XPath2FilterContainer

param
doc
param
xpath2filter
param
filterType


      super(doc);

      this._constructionElement
         .setAttributeNS(null, XPath2FilterContainer._ATT_FILTER, filterType);
      this._constructionElement.appendChild(doc.createTextNode(xpath2filter));
   
private XPath2FilterContainer(Element element, String BaseURI)
Constructor XPath2FilterContainer

param
element
param
BaseURI
throws
XMLSecurityException


      super(element, BaseURI);

      String filterStr = this._constructionElement.getAttributeNS(null,
                            XPath2FilterContainer._ATT_FILTER);

      if (!filterStr
              .equals(XPath2FilterContainer
              ._ATT_FILTER_VALUE_INTERSECT) &&!filterStr
                 .equals(XPath2FilterContainer
                 ._ATT_FILTER_VALUE_SUBTRACT) &&!filterStr
                    .equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION)) {
         Object exArgs[] = { XPath2FilterContainer._ATT_FILTER, filterStr,
                             XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT
                             + ", "
                             + XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT
                             + " or "
                             + XPath2FilterContainer._ATT_FILTER_VALUE_UNION };

         throw new XMLSecurityException("attributeValueIllegal", exArgs);
      }
   
Methods Summary
public final java.lang.StringgetBaseLocalName()
Method getBaseLocalName

return
the XPATH2 tag

      return XPath2FilterContainer._TAG_XPATH2;
   
public final java.lang.StringgetBaseNamespace()
Method getBaseNamespace

return
XPATH2 tag namespace

      return XPath2FilterContainer.XPathFilter2NS;
   
public java.lang.StringgetXPathFilterStr()
Returns the XPath 2 Filter String

return
the XPath 2 Filter String

      return this.getTextFromTextChild();
   
public org.w3c.dom.NodegetXPathFilterTextNode()
Returns the first Text node which contains information from the XPath 2 Filter String. We must use this stupid hook to enable the here() function to work. $todo$ I dunno whether this crashes: here()/ds:Signature[1]

return
the first Text node which contains information from the XPath 2 Filter String


      NodeList children = this._constructionElement.getChildNodes();
      int length = children.getLength();

      for (int i = 0; i < length; i++) {
         if (children.item(i).getNodeType() == Node.TEXT_NODE) {
            return children.item(i);
         }
      }

      return null;
   
public booleanisIntersect()
Returns true if the Filter attribute has value "intersect".

return
true if the Filter attribute has value "intersect".


      return this._constructionElement
         .getAttributeNS(null, XPath2FilterContainer._ATT_FILTER)
         .equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT);
   
public booleanisSubtract()
Returns true if the Filter attribute has value "subtract".

return
true if the Filter attribute has value "subtract".


      return this._constructionElement
         .getAttributeNS(null, XPath2FilterContainer._ATT_FILTER)
         .equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT);
   
public booleanisUnion()
Returns true if the Filter attribute has value "union".

return
true if the Filter attribute has value "union".


      return this._constructionElement
         .getAttributeNS(null, XPath2FilterContainer._ATT_FILTER)
         .equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION);
   
public static com.sun.org.apache.xml.internal.security.transforms.params.XPath2FilterContainernewInstance(org.w3c.dom.Element element, java.lang.String BaseURI)
Creates a XPath2FilterContainer from an existing Element; needed for verification.

param
element
param
BaseURI
return
the filter
throws
XMLSecurityException

      return new XPath2FilterContainer(element, BaseURI);
   
public static com.sun.org.apache.xml.internal.security.transforms.params.XPath2FilterContainernewInstanceIntersect(org.w3c.dom.Document doc, java.lang.String xpath2filter)
Creates a new XPath2FilterContainer with the filter type "intersect".

param
doc
param
xpath2filter
return
the filter.


      return new XPath2FilterContainer(doc, xpath2filter,
                                       XPath2FilterContainer
                                          ._ATT_FILTER_VALUE_INTERSECT);
   
public static com.sun.org.apache.xml.internal.security.transforms.params.XPath2FilterContainernewInstanceSubtract(org.w3c.dom.Document doc, java.lang.String xpath2filter)
Creates a new XPath2FilterContainer with the filter type "subtract".

param
doc
param
xpath2filter
return
the filter.


      return new XPath2FilterContainer(doc, xpath2filter,
                                       XPath2FilterContainer
                                          ._ATT_FILTER_VALUE_SUBTRACT);
   
public static com.sun.org.apache.xml.internal.security.transforms.params.XPath2FilterContainernewInstanceUnion(org.w3c.dom.Document doc, java.lang.String xpath2filter)
Creates a new XPath2FilterContainer with the filter type "union".

param
doc
param
xpath2filter
return
the filter


      return new XPath2FilterContainer(doc, xpath2filter,
                                       XPath2FilterContainer
                                          ._ATT_FILTER_VALUE_UNION);
   
public static org.w3c.dom.NodeListnewInstances(org.w3c.dom.Document doc, java.lang.String[][] params)
Method newInstances

param
doc
param
params
return
the nodelist with the data


      HelperNodeList nl = new HelperNodeList();

      nl.appendChild(doc.createTextNode("\n"));

      for (int i = 0; i < params.length; i++) {
         String type = params[i][0];
         String xpath = params[i][1];

         if (!(type.equals(XPath2FilterContainer
                 ._ATT_FILTER_VALUE_INTERSECT) || type
                    .equals(XPath2FilterContainer
                    ._ATT_FILTER_VALUE_SUBTRACT) || type
                       .equals(XPath2FilterContainer
                          ._ATT_FILTER_VALUE_UNION))) {
            throw new IllegalArgumentException("The type(" + i + ")=\"" + type
                                               + "\" is illegal");
         }

         XPath2FilterContainer c = new XPath2FilterContainer(doc, xpath, type);

         nl.appendChild(c.getElement());
         nl.appendChild(doc.createTextNode("\n"));
      }

      return nl;