|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jdom.filter.ContentFilter
ContentFilter
is a general purpose Filter
representing all legal JDOM objects and allows the ability to set
and unset the visiblity of these objects. 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.
Field Summary | |
static int |
CDATA
Mask for JDOM CDATA objects |
static int |
COMMENT
Mask for JDOM Comment objects |
static int |
DOCUMENT
Mask for JDOM Document object |
static int |
ELEMENT
Mask for JDOM Element objects |
static int |
ENTITYREF
Mask for JDOM EntityRef objects |
protected int |
filterMask
The JDOM object mask |
static int |
PI
Mask for JDOM ProcessingInstruction objects |
static int |
TEXT
Mask for 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 |
canAdd(java.lang.Object obj)
Check to see if the object can be added to the list. |
boolean |
canRemove(java.lang.Object obj)
Check to see if the object can be removed from the list. |
boolean |
equals(java.lang.Object obj)
Returns true if object is instance of ContentFilter and has the same filtering mask as this one. |
int |
getFilterMask()
Return current filtering mask. |
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 |
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 java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ELEMENT
Element
objectspublic static final int CDATA
CDATA
objectspublic static final int TEXT
Text
objectspublic static final int COMMENT
Comment
objectspublic static final int PI
ProcessingInstruction
objectspublic static final int ENTITYREF
EntityRef
objectspublic static final int DOCUMENT
Document
objectprotected int filterMask
Constructor Detail |
public ContentFilter()
Default constructor that allows any legal JDOM objects.
public ContentFilter(boolean allVisible)
Set whether all JDOM objects are visible or not.
allVisible
- true
all JDOM objects are visible,
false
all JDOM objects are hidden.public ContentFilter(int mask)
Filter out JDOM objects according to a filtering mask.
mask
- Mask of JDOM objects to allow.Method Detail |
public int getFilterMask()
Return current filtering mask.
public void setFilterMask(int mask)
Set filtering mask.
public void setDefaultMask()
Set this filter to allow all legal JDOM objects.
public void setDocumentContent()
Set filter to match only JDOM objects that are legal document content.
public void setElementContent()
Set filter to match only JDOM objects that are legal element content.
public void setElementVisible(boolean visible)
Set visiblity of Element
objects.
visible
- whether Elements are visible, true
if yes, false
if notpublic void setCDATAVisible(boolean visible)
Set visiblity of CDATA
objects.
visible
- whether CDATA nodes are visible, true
if yes, false
if notpublic void setTextVisible(boolean visible)
Set visiblity of Text
objects.
visible
- whether Text nodes are visible, true
if yes, false
if notpublic void setCommentVisible(boolean visible)
Set visiblity of Comment
objects.
visible
- whether Comments are visible, true
if yes, false
if notpublic void setPIVisible(boolean visible)
Set visiblity of ProcessingInstruction
objects.
visible
- whether ProcessingInstructions are visible,
true
if yes, false
if notpublic void setEntityRefVisible(boolean visible)
Set visiblity of EntityRef
objects.
visible
- whether EntityRefs are visible, true
if yes, false
if notpublic boolean canAdd(java.lang.Object obj)
Check to see if the object can be added to the list.
canAdd
in interface Filter
obj
- The object to verify.true
if the object can be added.public boolean canRemove(java.lang.Object obj)
Check to see if the object can be removed from the list.
canRemove
in interface Filter
obj
- The object to verify.true
if the object can be removed.public boolean matches(java.lang.Object obj)
Check to see if the object matches according to the filter mask.
matches
in interface Filter
obj
- The object to verify.true
if the objected matched a predfined
set of rules.public boolean equals(java.lang.Object obj)
Returns true if object is instance of ContentFilter and has the same filtering mask as this one.
equals
in class java.lang.Object
true
if the Filters are equal
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |