|
|||||||||
| Home >> All >> org >> jdom >> [ filter overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jdom.filter
Class ContentFilter

java.lang.Objectorg.jdom.filter.AbstractFilter
org.jdom.filter.ContentFilter
- All Implemented Interfaces:
- Filter, java.io.Serializable
- public class ContentFilter
- extends AbstractFilter
A general purpose Filter able to represent all legal JDOM objects or a specific subset. Filtering is accomplished by way of a filtering mask in which each bit represents whether a JDOM object is visible or not. For example to view all Text and CDATA nodes in the content of element x.
Filter filter = new ContentFilter(ContentFilter.TEXT |
ContentFilter.CDATA);
List content = x.getContent(filter);
For those who don't like bit-masking, set methods are provided as an alternative. For example to allow everything except Comment nodes.
Filter filter = new ContentFilter();
filter.setCommentVisible(false);
List content = x.getContent(filter);
The default is to allow all valid JDOM objects.
- Version:
- $Revision: 1.14 $, $Date: 2004/08/31 04:56:07 $
| Field Summary | |
static int |
CDATA
Mask for JDOM org.jdom.CDATA objects |
static int |
COMMENT
Mask for JDOM org.jdom.Comment objects |
private static java.lang.String |
CVS_ID
|
static int |
DOCTYPE
Mask for JDOM org.jdom.DocType object |
static int |
DOCUMENT
Mask for JDOM org.jdom.Document object |
static int |
ELEMENT
Mask for JDOM org.jdom.Element objects |
static int |
ENTITYREF
Mask for JDOM org.jdom.EntityRef objects |
private int |
filterMask
The JDOM object mask |
static int |
PI
Mask for JDOM org.jdom.ProcessingInstruction objects |
static int |
TEXT
Mask for JDOM org.jdom.Text objects |
| Constructor Summary | |
ContentFilter()
Default constructor that allows any legal JDOM objects. |
|
ContentFilter(boolean allVisible)
Set whether all JDOM objects are visible or not. |
|
ContentFilter(int mask)
Filter out JDOM objects according to a filtering mask. |
|
| Method Summary | |
boolean |
equals(java.lang.Object obj)
Returns whether the two filters are equivalent (i.e. the matching mask values are identical). |
int |
getFilterMask()
Return current filtering mask. |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
boolean |
matches(java.lang.Object obj)
Check to see if the object matches according to the filter mask. |
void |
setCDATAVisible(boolean visible)
Set visiblity of CDATA objects. |
void |
setCommentVisible(boolean visible)
Set visiblity of Comment objects. |
void |
setDefaultMask()
Set this filter to allow all legal JDOM objects. |
void |
setDocTypeVisible(boolean visible)
Set visiblity of DocType objects. |
void |
setDocumentContent()
Set filter to match only JDOM objects that are legal document content. |
void |
setElementContent()
Set filter to match only JDOM objects that are legal element content. |
void |
setElementVisible(boolean visible)
Set visiblity of Element objects. |
void |
setEntityRefVisible(boolean visible)
Set visiblity of EntityRef objects. |
void |
setFilterMask(int mask)
Set filtering mask. |
void |
setPIVisible(boolean visible)
Set visiblity of ProcessingInstruction objects. |
void |
setTextVisible(boolean visible)
Set visiblity of Text objects. |
| Methods inherited from class org.jdom.filter.AbstractFilter |
and, negate, or |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
CVS_ID
private static final java.lang.String CVS_ID
- See Also:
- Constant Field Values
ELEMENT
public static final int ELEMENT
- Mask for JDOM org.jdom.Element objects
- See Also:
- Constant Field Values
CDATA
public static final int CDATA
- Mask for JDOM org.jdom.CDATA objects
- See Also:
- Constant Field Values
TEXT
public static final int TEXT
- Mask for JDOM org.jdom.Text objects
- See Also:
- Constant Field Values
COMMENT
public static final int COMMENT
- Mask for JDOM org.jdom.Comment objects
- See Also:
- Constant Field Values
PI
public static final int PI
- Mask for JDOM org.jdom.ProcessingInstruction objects
- See Also:
- Constant Field Values
ENTITYREF
public static final int ENTITYREF
- Mask for JDOM org.jdom.EntityRef objects
- See Also:
- Constant Field Values
DOCUMENT
public static final int DOCUMENT
- Mask for JDOM org.jdom.Document object
- See Also:
- Constant Field Values
DOCTYPE
public static final int DOCTYPE
- Mask for JDOM org.jdom.DocType object
- See Also:
- Constant Field Values
filterMask
private int filterMask
- The JDOM object mask
| Constructor Detail |
ContentFilter
public ContentFilter()
- Default constructor that allows any legal JDOM objects.
ContentFilter
public ContentFilter(boolean allVisible)
- Set whether all JDOM objects are visible or not.
ContentFilter
public ContentFilter(int mask)
- Filter out JDOM objects according to a filtering mask.
| Method Detail |
getFilterMask
public int getFilterMask()
- Return current filtering mask.
setFilterMask
public void setFilterMask(int mask)
- Set filtering mask.
setDefaultMask
public void setDefaultMask()
- Set this filter to allow all legal JDOM objects.
setDocumentContent
public void setDocumentContent()
- Set filter to match only JDOM objects that are legal
document content.
setElementContent
public void setElementContent()
- Set filter to match only JDOM objects that are legal
element content.
setElementVisible
public void setElementVisible(boolean visible)
- Set visiblity of
Elementobjects.
setCDATAVisible
public void setCDATAVisible(boolean visible)
- Set visiblity of
CDATAobjects.
setTextVisible
public void setTextVisible(boolean visible)
- Set visiblity of
Textobjects.
setCommentVisible
public void setCommentVisible(boolean visible)
- Set visiblity of
Commentobjects.
setPIVisible
public void setPIVisible(boolean visible)
- Set visiblity of
ProcessingInstructionobjects.
setEntityRefVisible
public void setEntityRefVisible(boolean visible)
- Set visiblity of
EntityRefobjects.
setDocTypeVisible
public void setDocTypeVisible(boolean visible)
- Set visiblity of
DocTypeobjects.
matches
public boolean matches(java.lang.Object obj)
- Check to see if the object matches according to the filter mask.
equals
public boolean equals(java.lang.Object obj)
- Returns whether the two filters are equivalent (i.e. the
matching mask values are identical).
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
|
|||||||||
| Home >> All >> org >> jdom >> [ filter overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC