public class ContentFilter extends AbstractFilter<Content>
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.
| Modifier and Type | Field and Description |
|---|---|
static int |
CDATA
Mask for JDOM
CDATA objects |
static int |
COMMENT
Mask for JDOM
Comment objects |
static int |
DOCTYPE
Mask for JDOM
DocType object |
static int |
DOCUMENT
Mask for JDOM
Document object |
static int |
ELEMENT
Mask for JDOM
Element objects |
static int |
ENTITYREF
Mask for JDOM
EntityRef objects |
static int |
PI
Mask for JDOM
ProcessingInstruction objects |
static int |
TEXT
Mask for JDOM
Text objects |
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Returns whether the two filters are equivalent (i.e. the
matching mask values are identical).
|
Content |
filter(java.lang.Object obj)
Check to see if the object matches according to the filter mask.
|
int |
getFilterMask()
Return current filtering mask.
|
int |
hashCode() |
void |
setCDATAVisible(boolean visible)
Set visibility of
CDATA objects. |
void |
setCommentVisible(boolean visible)
Set visibility of
Comment objects. |
void |
setDefaultMask()
Set this filter to allow all legal JDOM objects.
|
void |
setDocTypeVisible(boolean visible)
Set visibility 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 visibility of
Element objects. |
void |
setEntityRefVisible(boolean visible)
Set visibility of
EntityRef objects. |
void |
setFilterMask(int mask)
Set filtering mask.
|
void |
setPIVisible(boolean visible)
Set visibility of
ProcessingInstruction objects. |
void |
setTextVisible(boolean visible)
Set visibility of
Text objects. |
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 objectpublic static final int DOCTYPE
DocType objectpublic ContentFilter()
public ContentFilter(boolean allVisible)
allVisible - true all JDOM objects are visible,
false all JDOM objects are hidden.public ContentFilter(int mask)
mask - Mask of JDOM objects to allow.public int getFilterMask()
public void setFilterMask(int mask)
mask - the new filtering maskpublic void setDefaultMask()
public void setDocumentContent()
public void setElementContent()
public void setElementVisible(boolean visible)
Element objects.visible - whether Elements are visible, true
if yes, false if notpublic void setCDATAVisible(boolean visible)
CDATA objects.visible - whether CDATA nodes are visible, true
if yes, false if notpublic void setTextVisible(boolean visible)
Text objects.visible - whether Text nodes are visible, true
if yes, false if notpublic void setCommentVisible(boolean visible)
Comment objects.visible - whether Comments are visible, true
if yes, false if notpublic void setPIVisible(boolean visible)
ProcessingInstruction objects.visible - whether ProcessingInstructions are visible,
true if yes, false if notpublic void setEntityRefVisible(boolean visible)
EntityRef objects.visible - whether EntityRefs are visible, true
if yes, false if notpublic void setDocTypeVisible(boolean visible)
DocType objects.visible - whether the DocType is visible, true
if yes, false if notpublic Content filter(java.lang.Object obj)
obj - The object to verify.true if the objected matched a predfined
set of rules.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to compare againstpublic int hashCode()
hashCode in class java.lang.ObjectCopyright © 2021 Jason Hunter, Brett McLaughlin. All Rights Reserved.