[jdom-interest] improved proposal for new ElementFilter implementation

tshitshi kia ntoni tkiantoni at yahoo.co.uk
Tue Jul 27 11:37:13 PDT 2004


Skipped content of type multipart/alternative-------------- next part --------------
/*
 * Created on 21 juil. 2004
 * Tshitshi Kia Ntoni
 * 
 Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:

 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions, and the following disclaimer.

 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions, and the disclaimer that follows
    these conditions in the documentation and/or other materials
    provided with the distribution.

 3. The name "JDOM" must not be used to endorse or promote products
    derived from this software without prior written permission.  For
    written permission, please contact <request_AT_jdom_DOT_org>.

 4. Products derived from this software may not be called "JDOM", nor
    may "JDOM" appear in their name, without prior written permission
    from the JDOM Project Management <request_AT_jdom_DOT_org>.

 In addition, we request (but do not require) that you include in the
 end-user documentation provided with the redistribution and/or in the
 software itself an acknowledgement equivalent to the following:
     "This product includes software developed by the
      JDOM Project (http://www.jdom.org/)."
 Alternatively, the acknowledgment may be graphical using the logos
 available at http://www.jdom.org/images/logos.

 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED.  IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.

 This software consists of voluntary contributions made by many
 individuals on behalf of the JDOM Project and was originally
 created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
 Brett McLaughlin <brett_AT_jdom_DOT_org>.  For more information
 on the JDOM Project, please see <http://www.jdom.org/>.

 */
package genie.core.util;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Iterator;

import org.jdom.Attribute;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.filter.AbstractFilter;

/**
 * A Filter that only matches {@link org.jdom.Element} objects
 * that feet the supplied, if so, element name, element namespace, attribute name,
 * attribute namespace,  attribute value and attribute type.
 * The attribute type is passed through a filtermask.
 * With the implementation it is easy to look up an element according to 
 * its id value as to any attribue value. 
 * <code>Document document ....;</code>
 * <code>ElementFilter2 filter = new ElementFilter2();</code>
 * <code>filter.setFilterMask(ElementFilter2.ID)</code>
 * <code>filter.setAttributeValue(aIdValue)</code>
 * No need of implementing specific 
 * Document and Element classes as done in org.jdom.contrib.ids package.
 * Null elementName, elementNamespace, attributeName, attributeNamespace or attributeValue
 * mean any elementName, elementNamespace, attributeName, attributeNamespace or attributeValue
 * may be selected, except other retriction according to other rules.
 * The default filter mask permits to select any attribute type.
 * Importance of criteria :
 * ----------------------
 * elementNamespace > elementName > attributeNamespace (considered only if elementNamespace == null ) 
 * > attributeName > attributeValue > attributeType
 * 
 * @version 1, $Date: 2004/06/21  $
 * @author  Tshitshi Kia Ntoni
 */
public class ElementFilter2 extends AbstractFilter {

    /**
     * Attribute type: the attribute value is a string.
     *
     * @see #getAttributeType
     */
    public final static int CDATA = 2;

    /**
     * <p>
     * Attribute type: the attribute value is a list of entity names.
     * </p>
     *
     * @see #getAttributeType
     */
    public final static int ENTITIES = 64;

    /**
     * Attribute type: the attribute value is the elementName of an entity.
     *
     * @see #getAttributeType
     */
    public final static int ENTITY = 32;

    /**
     * Attribute type: the attribute value is a elementName token from an
     * enumeration.
     *
     * @see #getAttributeType
     */
    public final static int ENUMERATED = 1016;

    /**
     * Attribute type: the attribute value is a unique identifier.
     *
     * @see #getAttributeType
     */
    public final static int ID = 4;

    /**
     * Attribute type: the attribute value is a reference to a
     * unique identifier.
     *
     * @see #getAttributeType
     */
    public final static int IDREF = 8;

    /**
     * Attribute type: the attribute value is a list of references to
     * unique identifiers.
     *
     * @see #getAttributeType
     */
    public final static int IDREFS = 16;

    /**
     * Attribute type: the attribute value is a elementName token.
     * <p>
     * According to SAX 2.0 specification, attributes of enumerated
     * types should be reported as "NMTOKEN" by SAX parsers.  But the
     * major parsers (Xerces and Crimson) provide specific values
     * that permit to recognize them as {@link #ENUMERATED}.
     *
     * @see #getAttributeType
     */
    public final static int NMTOKEN = 128;

    /**
     * Attribute type: the attribute value is a list of elementName tokens.
     *
     * @see #getAttributeType
     */
    public final static int NMTOKENS = 254;

    /**
     * Attribute type: the attribute value is the elementName of a notation.
     *
     * @see #getAttributeType
     */
    public final static int NOTATION = 508;
    /** Mask for JDOM {@link Element} objects  with  an {@link Attribute}
     *  whose type is {@link Attribute.UNDECLARED_TYPE}
     */
    public final static int UNDECLARED = 1;
    
    /** The attribute name */
    private String attributeName;
    // considered only if elementNamespace == null
    /** The attribute namespace */
    private transient Namespace attributeNamespace;
    /** The attribute value */
    private String attributeValue;
    
    /** The element name */
    private String elementName;    
    /** The element namespace */
    private transient Namespace elementNamespace;
    /** The JDOM object mask */
    private int filterMask;

    /**
     * Select only the Elements with any name in any Namespace.
     * 
     */
    public ElementFilter2() {
        setDefaultMask();
    }

    /**
     * Select only the Elements with any name in any Namespace 
     * and an attribute whose type matches the mask.
     * 
     * @param mask
     */
    public ElementFilter2(boolean allVisible) {
        if (allVisible) {
            setDefaultMask();
        }
        else {
            filterMask &= ~filterMask;
        }
    }

    /**
     * Select only the Elements with any name in any Namespace 
     * and an attribute whose type matches the mask.
     * 
     * @param mask
     */
    public ElementFilter2(int mask) {
        setFilterMask(mask);
    }

    /**
     * Returns whether the two filters are equivalent (i.e. the matching names
     * and namespace are equivalent).
     *
     * @param  obj                   the object to compare against
     * @return                     whether the two filters are equal
     */
    public boolean equals(Object obj) {        
        if (this == obj) return true;
        if (!(obj instanceof ElementFilter2)) return false;
    
        final ElementFilter2 filter = (ElementFilter2) obj;
        
        if (elementName != null ? !elementName.equals(filter.elementName) : filter.elementName != null){
            return false;
        }
        if (elementNamespace != null ? !elementNamespace.equals(filter.elementNamespace) : filter.elementNamespace != null){
            return false;
        }
        if (attributeName != null ? !attributeName.equals(filter.attributeName) : filter.attributeName != null){
            return false;
        }
        if (attributeNamespace != null ? !attributeNamespace.equals(filter.attributeNamespace) : filter.attributeNamespace != null){
            return false;
        }
        if (filterMask != filter.filterMask){
            return false;
        }
    
        return true;
    }

    /**
     * @return Returns the attributeName.
     */
    public String getAttributeName() {
        return attributeName;
    }
    /**
     * @return Returns the attributeNamespace.
     */
    public Namespace getAttributeNamespace() {
        return attributeNamespace;
    }
    /**
     * @return Returns the attributeValue.
     */
    public String getAttributeValue() {
        return attributeValue;
    }
    
    /**
     * get the filter to allow all legal JDOM Element.
     */
    public int getDefaultMask() {
        return  CDATA | ENTITIES | ENTITY |
        		ENUMERATED | ID | IDREF | 
        		IDREFS | NMTOKEN | NMTOKENS | 
        		NOTATION | UNDECLARED;
    }
    /**
     * @return Returns the elementName.
     */
    public String getElementName() {
        return elementName;
    }
    /**
     * @return Returns the elementNamespace.
     */
    public Namespace getElementNamespace() {
        return elementNamespace;
    }
    /**
     * Return current filtering mask.
     */
    public int getFilterMask() {
        return filterMask;
    }

    public int hashCode() {        
        int result;
        result = (elementName != null ? elementName.hashCode() : 0);
        result += (elementNamespace != null ? elementNamespace.hashCode() : 0);
        result += (attributeName != null ? attributeName.hashCode() : 0);
        result +=  (attributeNamespace != null ? attributeNamespace.hashCode() : 0);
        result += filterMask;
        return result;
    }
    /**
     * called if attribute value unspecified
     * 
     * @param attribute
     * @param attributeType
     * @return
     */
    private boolean matchedAttributeType(Attribute attribute, int attributeType) {
        if (attribute == null) {
            return false;
        }        
        return attribute.getAttributeType() == attributeType;
    }
    /**
     * called if attribute value specified
     * 
     * @param attribute
     * @param attributeType
     * @return
     */
    private boolean matchedAttributeValueAndType(Attribute attribute, int attributeType) {
        if (attribute == null) {
            return false;
        }
        return attributeValue.equals(attribute.getValue()) && attribute.getAttributeType() == attributeType;
    }
    /**
     * 
     * @param element
     * @param attributeType
     * @return
     */
    private boolean matchedElement(Element element, int attributeType) {
        // if elementnamespace not null, it must equal the element.getNamespace()
        if (elementNamespace != null && element.getNamespace() == null) {
            return false;
        }
        if (elementNamespace != null && element.getNamespace() != null && 
                ! elementNamespace.equals(element.getNamespace())) {
            return false;
        }
        if (elementName != null) {
           return matchedSpecifiedElement(element, attributeType);
        } else {
            return matchedUnspecifiedElement(element, attributeType);
        }
    }
    /**
     * called if attribute name specified
     * 
     * @param attribute
     * @param attributeType
     * @return
     */ 
    private boolean matchedSpecifiedAttribute(Attribute attribute, int attributeType) {
        // TODO test the namespaces equality
        if (attribute == null) {
            return false;
        }
        // if elementNamespace null and the attributeNamespace not null, 
        //the attributeNamespace must equal the attribute.getNamespace()
        if (elementNamespace == null) {
            System.out.println("elementNamespace == null");
            if (attributeNamespace != null && attribute.getNamespace() == null) {
                return false;
            }
            if (attributeNamespace != null && attribute.getNamespace() != null && 
                    ! attributeNamespace.equals(attribute.getNamespace())) {
                return false;
            }            
        }        
        if (attributeName.equals(attribute.getName()) && attributeValue != null){
           return matchedAttributeValueAndType(attribute, attributeType); 
        }
        if (attributeName.equals(attribute.getName()) && attributeValue == null){
           return matchedAttributeType(attribute, attributeType); 
        }
        return false;
    }
    /**
     * called if element name specified
     * 
     * @param element
     * @param attributeType
     * @return
     */
    private boolean matchedSpecifiedElement(Element element, int attributeType) {
        // TODO test the namespaces equality
        if (this.elementName.equals(element.getName()) && attributeName != null ) {
            return matchedSpecifiedAttribute(element.getAttribute(attributeName), attributeType);
        } 
        if (this.elementName.equals(element.getName()) && attributeName == null ){
            Iterator attributes = element.getAttributes().iterator();
            while (attributes.hasNext()) {
                Attribute attribute = (Attribute) attributes.next();
                if (matchedUnspecifiedAttribute(attribute, attributeType)) {
                    return true;
                }
            }            
        }        
        return false;
    }
    /**
     * called if attribute name unspecified
     * 
     * @param attribute
     * @param attributeType
     * @return
     */
    private boolean matchedUnspecifiedAttribute(Attribute attribute, int attributeType) {
        // TODO test the namespaces equality
        if (attribute == null) {
            return false;
        }
        // if elementNamespace null and the attributeNamespace not null, 
        //the attributeNamespace must equal the attribute.getNamespace()
        if (elementNamespace == null) {
            if (attributeNamespace != null && attribute.getNamespace() == null) {
                return false;
            }
            if (attributeNamespace != null && attribute.getNamespace() != null && 
                    ! attributeNamespace.equals(attribute.getNamespace())) {
                return false;
            }            
        }
        if (attributeValue != null){
            return matchedAttributeValueAndType(attribute, attributeType); 
         } else {
            return matchedAttributeType(attribute, attributeType); 
         }         
    }
    /**
     * called if element name unspecified
     * 
     * @param element
     * @param attributeType
     * @return
     */
    private boolean matchedUnspecifiedElement(Element element, int attributeType) {
        // TODO test the namespaces equality
        if (this.elementName == null && attributeName != null) {
            return matchedSpecifiedAttribute(element.getAttribute(attributeName), attributeType);
        } 
        if (this.elementName == null && attributeName == null){
            Iterator attributes = element.getAttributes().iterator();
            while (attributes.hasNext()) {
                Attribute attribute = (Attribute) attributes.next();
                if (attributeValue != null && matchedAttributeValueAndType(attribute, attributeType)) {
                    return true;
                }
                if (attributeValue == null && matchedAttributeType(attribute, attributeType)) {
                    return true;
                }
            }
            
        }        
        return false;
    }
    /* (non-Javadoc)
     * @see org.jdom.filter.Filter#matches(java.lang.Object)
     */
    public boolean matches(Object arg0) {         
        if (arg0 instanceof Element) {
            Element el = (Element) arg0;            
            if (filterMask - getDefaultMask() == 0) {
                if (elementName == null && attributeName == null && attributeValue == null 
                        && elementNamespace == null && attributeNamespace == null) {
                    // return as ContentFilter filter... filter.setFilterMask(ContentFilter.ELEMENT)
                    return true;
                }
                return matchedElement(el, Attribute.UNDECLARED_TYPE) |
                matchedElement(el, Attribute.CDATA_TYPE) |
                matchedElement(el, Attribute.ID_TYPE) |
                matchedElement(el, Attribute.IDREF_TYPE) |
                matchedElement(el, Attribute.IDREFS_TYPE) | 
                matchedElement(el, Attribute.ENTITY_TYPE) |
                matchedElement(el, Attribute.ENTITIES_TYPE) |
                matchedElement(el, Attribute.ENUMERATED_TYPE) | 
                matchedElement(el, Attribute.NMTOKEN_TYPE) | 
                matchedElement(el, Attribute.NMTOKENS_TYPE) |
                matchedElement(el, Attribute.NOTATION_TYPE);
            } else if ((filterMask & UNDECLARED) != 0) {               
                return matchedElement(el, Attribute.UNDECLARED_TYPE);                
            } else if ((filterMask & CDATA) != 0) {
                return matchedElement(el, Attribute.CDATA_TYPE);                
            }  else if ((filterMask & ID) != 0) {
                return matchedElement(el, Attribute.ID_TYPE);                
            }  else if ((filterMask & IDREF) != 0) {
                return matchedElement(el, Attribute.IDREF_TYPE);                
            }  else if ((filterMask & IDREFS) != 0) {
                return matchedElement(el, Attribute.IDREFS_TYPE);                
            }  else if ((filterMask & ENTITY) != 0) {
                return matchedElement(el, Attribute.ENTITY_TYPE);                
            }  else if ((filterMask & ENTITIES) != 0) {
                return matchedElement(el, Attribute.ENTITIES_TYPE);                
            }  else if ((filterMask & ENUMERATED) != 0) {
                return matchedElement(el, Attribute.ENUMERATED_TYPE);                
            }  else if ((filterMask & NMTOKEN) != 0) {
                return matchedElement(el, Attribute.NMTOKEN_TYPE);                
            }  else if ((filterMask & NMTOKENS) != 0) {
                return matchedElement(el, Attribute.NMTOKENS_TYPE);                
            }  else if ((filterMask & NOTATION) != 0) {
                return matchedElement(el, Attribute.NOTATION_TYPE);                
            }
        }
        return false;
    }

    private void readObject(ObjectInputStream in)
            throws IOException, ClassNotFoundException {
    
        in.defaultReadObject();
    
        elementNamespace = Namespace.getNamespace(
                (String) in.readObject(), (String) in.readObject());
        attributeNamespace = Namespace.getNamespace(
                (String) in.readObject(), (String) in.readObject());
    }
    /**
     * @param attributeName The attributeName to set.
     */
    public void setAttributeName(String attributeName) {
        this.attributeName = attributeName;
    }
    /**
     * @param attributeNamespace The attributeNamespace to set.
     */
    public void setAttributeNamespace(Namespace attributeNamespace) {
        this.attributeNamespace = attributeNamespace;
    }
    /**
     * @param attributeValue The attributeValue to set.
     */
    public void setAttributeValue(String attributeValue) {
        this.attributeValue = attributeValue;
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Cdata</code> type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setCdataVisible(boolean visible) {
        if (visible) {
            filterMask |= CDATA;
        }
        else {
            filterMask &= ~CDATA;
        }
    }

    /**
     * Set this filter to allow all legal JDOM Element.
     */
    public void setDefaultMask() {
        filterMask = CDATA | ENTITIES | ENTITY |
        			 ENUMERATED | ID | IDREF | 
        			 IDREFS | NMTOKEN | NMTOKENS | 
        			 NOTATION | UNDECLARED;        
    }
    /**
     * @param elementName The elementName to set.
     */
    public void setElementName(String elementName) {
        this.elementName = elementName;
    }
    /**
     * @param elementNamespace The elementNamespace to set.
     */
    public void setElementNamespace(Namespace elementNamespace) {
        this.elementNamespace = elementNamespace;
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Entity</code> list type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setEntitiesVisible(boolean visible) {
        if (visible) {
            filterMask |= ENTITIES;
        }
        else {
            filterMask &= ~ENTITIES;
        }
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Entity</code> type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setEntityVisible(boolean visible) {
        if (visible) {
            filterMask |= ENTITY;
        }
        else {
            filterMask &= ~ENTITY;
        }
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>enumerated</code> type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setEnumeratedVisible(boolean visible) {
        if (visible) {
            filterMask |= ENUMERATED;
        }
        else {
            filterMask &= ~ENUMERATED;
        }
    }

    /**
     * Set filtering mask.
     * @param mask
     */
    public void setFilterMask(int mask) {
        setDefaultMask();
        filterMask &= mask;
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Idref</code> list type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setIdRefsVisible(boolean visible) {
        if (visible) {
            filterMask |= IDREFS;
        }
        else {
            filterMask &= ~IDREFS;
        }
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Idref</code> type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setIdRefVisible(boolean visible) {
        if (visible) {
            filterMask |= IDREF;
        }
        else {
            filterMask &= ~IDREF;
        }
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Id</code> type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setIdVisible(boolean visible) {
        if (visible) {
            filterMask |= ID;
        }
        else {
            filterMask &= ~ID;
        }
    }

    /**
     * Set visiblity of <code>Element</code> objects.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setNmTokensVisible(boolean visible) {
        if (visible) {
            filterMask |= NMTOKENS;
        }
        else {
            filterMask &= ~NMTOKENS;
        }
    }

    /**
     * Set visiblity of <code>Element</code> objects.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setNmTokenVisible(boolean visible) {
        if (visible) {
            filterMask |= NMTOKEN;
        }
        else {
            filterMask &= ~NMTOKEN;
        }
    }

    /**
     * Set visiblity of <code>Element</code> objects.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setNotationVisible(boolean visible) {
        if (visible) {
            filterMask |= NOTATION;
        }
        else {
            filterMask &= ~NOTATION;
        }
    }

    /**
     * Set visiblity of <code>Elements</code> with <code>Undeclared</code> type <code>Attribute</code>.
     *
     * @param visible whether Elements are visible, <code>true</code>
     *        if yes, <code>false</code> if not
     */
    public void setUndeclaredVisible(boolean visible) {
        if (visible) {
            filterMask |= UNDECLARED;
        }
        else {
            filterMask &= ~UNDECLARED;
        }
    }

    // Support a custom Namespace serialization so no two namespace
    // object instances may exist for the same prefix/uri pair
    private void writeObject(ObjectOutputStream out) throws IOException {
    
        out.defaultWriteObject();
    
        // We use writeObject() and not writeUTF() to minimize space
        // This allows for writing pointers to already written strings
        out.writeObject(elementNamespace.getPrefix());
        out.writeObject(elementNamespace.getURI());
        out.writeObject(attributeNamespace.getPrefix());
        out.writeObject(attributeNamespace.getURI());
    }

    /**
     * Set filter to match only element content with <code>Cdata</code> attribute.
     */
    public void setCdata() {
        filterMask = CDATA;
    }

    /**
     * Set filter to match only element content with <code>entity</code> attribute.
     */
    public void setEntity() {
        filterMask = ENTITY;
    }

    /**
     * Set filter to match only element content with <code>entity</code> list attribute.
     */
    public void setEntities() {
        filterMask = ENTITIES;
    }

    /**
     * Set filter to match only element content with <code>enumerated</code> attribute.
     */
    public void setEnumerated() {
        filterMask = ENUMERATED;
    }

    /**
     * Set filter to match only element content with <code>id</code> attribute.
     */
    public void setId() {
        filterMask = ID;
    }

    /**
     * Set filter to match only element content with <code>idref</code> attribute.
     */
    public void setIdRef() {
        filterMask = IDREF;
    }

    /**
     * Set filter to match only element content with <code>idref</code> list attribute.
     */
    public void setIdRefs() {
        filterMask = IDREFS;
    }

    /**
     * Set filter to match only element content with <code>nmtoken</code> attribute.
     */
    public void setNmToken() {
        filterMask = NMTOKEN;
    }

    /**
     * Set filter to match only element content with <code>nmtoken</code> list attribute.
     */
    public void setNmTokens() {
        filterMask = NMTOKENS;
    }

    /**
     * Set filter to match only element content with <code>notation</code> attribute.
     */
    public void setNotation() {
        filterMask = NOTATION;
    }

    /**
     * Set filter to match only element content with <code>undeclared</code> attribute.
     */
    public void setUndeclared() {
        filterMask = UNDECLARED;
    }
}


More information about the jdom-interest mailing list