All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.jdom.filter.ContentFilter

java.lang.Object
   |
   +----org.jdom.filter.ContentFilter

public class ContentFilter
extends Object
implements Filter

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.

Version:
$Revision: 1.1 $, $Date: 2002/03/12 07:00:50 $
Author:
Bradley S. Huffman

Variable Index

 o CDATA
Mask for JDOM CDATA objects
 o COMMENT
Mask for JDOM Comment objects
 o DOCUMENT
Mask for JDOM Document object
 o ELEMENT
Mask for JDOM Element objects
 o ENTITYREF
Mask for JDOM EnitityRef objects
 o filterMask
The JDOM object mask
 o PI
Mask for JDOM ProcessingInstruction objects
 o TEXT
Mask for JDOM Text objects

Constructor Index

 o ContentFilter()

Default constructor that allows any legal JDOM objects.

 o ContentFilter(boolean)

Set whether all JDOM objects are visible or not.

 o ContentFilter(int)

Filter out JDOM objects according to a filtering mask.

Method Index

 o canAdd(Object)

Check to see if the object can be added to the list.

 o canRemove(Object)

Check to see if the object can be removed from the list.

 o equals(Object)

Returns true if object is instance of ContentFilter and has the same filtering mask as this one.

 o getFilterMask()

Return current filtering mask.

 o matches(Object)

Check to see if the object matches according to the filter mask.

 o setCDATAVisible(boolean)

Set visiblity of CDATA objects.

 o setCommentVisible(boolean)

Set visiblity of Comment objects.

 o setDefaultMask()

Set this filter to allow all legal JDOM objects.

 o setDocumentContent()

Set filter to match only JDOM objects that are legal document content.

 o setElementContent()

Set filter to match only JDOM objects that are legal element content.

 o setElementVisible(boolean)

Set visiblity of Element objects.

 o setEntityRefVisible(boolean)

Set visiblity of EntityRef objects.

 o setFilterMask(int)

Set filtering mask.

 o setPIVisible(boolean)

Set visiblity of ProcessingInstruction objects.

 o setTextVisible(boolean)

Set visiblity of Text objects.

Variables

 o ELEMENT
 public static final int ELEMENT
Mask for JDOM Element objects

 o CDATA
 public static final int CDATA
Mask for JDOM CDATA objects

 o TEXT
 public static final int TEXT
Mask for JDOM Text objects

 o COMMENT
 public static final int COMMENT
Mask for JDOM Comment objects

 o PI
 public static final int PI
Mask for JDOM ProcessingInstruction objects

 o ENTITYREF
 public static final int ENTITYREF
Mask for JDOM EnitityRef objects

 o DOCUMENT
 public static final int DOCUMENT
Mask for JDOM Document object

 o filterMask
 protected int filterMask
The JDOM object mask

Constructors

 o ContentFilter
 public ContentFilter()

Default constructor that allows any legal JDOM objects.

 o ContentFilter
 public ContentFilter(boolean allVisible)

Set whether all JDOM objects are visible or not.

Parameters:
allVisible - true all JDOM objects are visible, false all JDOM objects are hidden.
 o ContentFilter
 public ContentFilter(int mask)

Filter out JDOM objects according to a filtering mask.

Parameters:
mask - Mask of JDOM objects to allow.

Methods

 o getFilterMask
 public int getFilterMask()

Return current filtering mask.

 o setFilterMask
 public void setFilterMask(int mask)

Set filtering mask.

 o setDefaultMask
 public void setDefaultMask()

Set this filter to allow all legal JDOM objects.

 o setDocumentContent
 public void setDocumentContent()

Set filter to match only JDOM objects that are legal document content.

 o setElementContent
 public void setElementContent()

Set filter to match only JDOM objects that are legal element content.

 o setElementVisible
 public void setElementVisible(boolean visible)

Set visiblity of Element objects.

Parameters:
visible - whether Elements are visible, true if yes, false if not
 o setCDATAVisible
 public void setCDATAVisible(boolean visible)

Set visiblity of CDATA objects.

Parameters:
visible - whether CDATA nodes are visible, true if yes, false if not
 o setTextVisible
 public void setTextVisible(boolean visible)

Set visiblity of Text objects.

Parameters:
visible - whether Text nodes are visible, true if yes, false if not
 o setCommentVisible
 public void setCommentVisible(boolean visible)

Set visiblity of Comment objects.

Parameters:
visible - whether Comments are visible, true if yes, false if not
 o setPIVisible
 public void setPIVisible(boolean visible)

Set visiblity of ProcessingInstruction objects.

Parameters:
visible - whether ProcessingInstructions are visible, true if yes, false if not
 o setEntityRefVisible
 public void setEntityRefVisible(boolean visible)

Set visiblity of EntityRef objects.

Parameters:
visible - whether EntityRefs are visible, true if yes, false if not
 o canAdd
 public boolean canAdd(Object obj)

Check to see if the object can be added to the list.

Parameters:
obj - The object to verify.
Returns:
true if the object can be added.
 o canRemove
 public boolean canRemove(Object obj)

Check to see if the object can be removed from the list.

Parameters:
obj - The object to verify.
Returns:
true if the object can be removed.
 o matches
 public boolean matches(Object obj)

Check to see if the object matches according to the filter mask.

Parameters:
obj - The object to verify.
Returns:
true if the objected matched a predfined set of rules.
 o equals
 public boolean equals(Object obj)

Returns true if object is instance of ContentFilter and has the same filtering mask as this one.

Returns:
true if the Filters are equal
Overrides:
equals in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index