Class DefaultStAXFilter
- java.lang.Object
-
- org.jdom2.input.stax.DefaultStAXFilter
-
- All Implemented Interfaces:
StAXFilter
public class DefaultStAXFilter extends java.lang.Object implements StAXFilter
This DefaultStAXFilter includes all content and prunes nothing.Override this class to make adjustments to get the results you need.
- Author:
- Rolf Lear
- See Also:
StAXFilter
-
-
Constructor Summary
Constructors Constructor Description DefaultStAXFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringincludeCDATA(int depth, java.lang.String text)The current event is a CDATA event.java.lang.StringincludeComment(int depth, java.lang.String comment)The current event is a Comment event.booleanincludeDocType()The current event is a DocType event.booleanincludeElement(int depth, java.lang.String name, Namespace ns)The current event is an Element event.booleanincludeEntityRef(int depth, java.lang.String name)The current event is an EntityRef event.booleanincludeProcessingInstruction(int depth, java.lang.String target)The current event is a ProcessingInstruction event.java.lang.StringincludeText(int depth, java.lang.String text)The current event is a TEXT event.java.lang.StringpruneCDATA(int depth, java.lang.String text)An Element is being included, and this is a child CDATA event of the included parent Element.java.lang.StringpruneComment(int depth, java.lang.String comment)An Element is being included, and this is a child Comment event of the included parent Element.booleanpruneElement(int depth, java.lang.String name, Namespace ns)An Element is being included, and this is a child Element event of the included parent Element.booleanpruneEntityRef(int depth, java.lang.String name)An Element is being included, and this is a child EntityRef event of the included parent Element.booleanpruneProcessingInstruction(int depth, java.lang.String target)An Element is being included, and this is a child ProcessingInstruction event of the included parent Element.java.lang.StringpruneText(int depth, java.lang.String text)An Element is being included, and this is a child Text event of the included parent Element.
-
-
-
Method Detail
-
includeDocType
public boolean includeDocType()
Description copied from interface:StAXFilterThe current event is a DocType event.- Specified by:
includeDocTypein interfaceStAXFilter- Returns:
- true if the DocType should become a JDOM Fragment.
-
includeElement
public boolean includeElement(int depth, java.lang.String name, Namespace ns)Description copied from interface:StAXFilterThe current event is an Element event.If the return value of this call is true, then this Element will be processed as a JDOM fragment. You may then get calls to the prune* methods to determine whether child content of this Element should be pruned.
- Specified by:
includeElementin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)name- The XML tag name of this Elementns- The Namespace of this Element- Returns:
- true if the Element should become a JDOM Fragment.
-
includeComment
public java.lang.String includeComment(int depth, java.lang.String comment)Description copied from interface:StAXFilterThe current event is a Comment event.A null return value will cause the Comment to be ignored, and a non-null return value will become the Comment's text.
To include the comment as-is, do:
public String includeComment(int depth, String comment) { return comment; }- Specified by:
includeCommentin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)comment- The Comment value- Returns:
- null if you want to exclude this comment, or a non-null value which will become the new comment value.
-
includeEntityRef
public boolean includeEntityRef(int depth, java.lang.String name)Description copied from interface:StAXFilterThe current event is an EntityRef event.- Specified by:
includeEntityRefin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)name- The EntityRef name- Returns:
- true if you want to include this EntityRef.
-
includeCDATA
public java.lang.String includeCDATA(int depth, java.lang.String text)Description copied from interface:StAXFilterThe current event is a CDATA event.A null return value will cause the Comment to be ignored, and a non-null return value will become the CDATA's text.
To include the CDATA as-is, do:
public String includeCDATA(int depth, String text) { return text; }- Specified by:
includeCDATAin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)text- The CDATA text value- Returns:
- null if you want to exclude this CDATA, or a non-null value which will become the new CDATA text value.
-
includeText
public java.lang.String includeText(int depth, java.lang.String text)Description copied from interface:StAXFilterThe current event is a TEXT event.A null return value will cause the Comment to be ignored, and a non-null return value will become the Text's text.
To include the Text as-is, do:
public String includeText(int depth, String text) { return text; }- Specified by:
includeTextin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)text- The Text value- Returns:
- null if you want to exclude this Text, or a non-null value which will become the new Text value.
-
includeProcessingInstruction
public boolean includeProcessingInstruction(int depth, java.lang.String target)Description copied from interface:StAXFilterThe current event is a ProcessingInstruction event.- Specified by:
includeProcessingInstructionin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)target- The ProcessingInstruction Target value- Returns:
- true if you want to include this ProcessingInstruction.
-
pruneElement
public boolean pruneElement(int depth, java.lang.String name, Namespace ns)Description copied from interface:StAXFilterAn Element is being included, and this is a child Element event of the included parent Element. Should this Child Element be pruned from the parent fragment?- Specified by:
pruneElementin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)name- The XML tag name of this child Elementns- The Namespace of this child Element- Returns:
- true if the child Element should be excluded.
-
pruneComment
public java.lang.String pruneComment(int depth, java.lang.String comment)Description copied from interface:StAXFilterAn Element is being included, and this is a child Comment event of the included parent Element. Should this child Comment be pruned from the parent fragment?A non-null return value will become the Comment value. Return null to skip the Comment.
To include the Comment as-is, do:
public String pruneComment(int depth, String comment) { return comment; }- Specified by:
pruneCommentin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)comment- The Comment value- Returns:
- null if you want to exclude this Comment, or a non-null value which will become the new Comment value.
-
pruneEntityRef
public boolean pruneEntityRef(int depth, java.lang.String name)Description copied from interface:StAXFilterAn Element is being included, and this is a child EntityRef event of the included parent Element. Should this child EntityRef be pruned from the parent fragment?- Specified by:
pruneEntityRefin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)name- The EntityRef name- Returns:
- true if you want to exclude this EntityRef.
-
pruneCDATA
public java.lang.String pruneCDATA(int depth, java.lang.String text)Description copied from interface:StAXFilterAn Element is being included, and this is a child CDATA event of the included parent Element. Should this child CDATA be pruned from the parent fragment?A non-null return value will become the CDATA text. Return null to skip the CDATA.
To include the CDATA as-is, do:
public String pruneCDATA(int depth, String text) { return text; }- Specified by:
pruneCDATAin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)text- The CDATA text value- Returns:
- null if you want to exclude this CDATA, or a non-null value which will become the new CDATA text value.
-
pruneText
public java.lang.String pruneText(int depth, java.lang.String text)Description copied from interface:StAXFilterAn Element is being included, and this is a child Text event of the included parent Element. Should this child Text be pruned from the parent fragment?A non-null return value will become the Text. Return null to skip the Text.
To include the Text as-is, do:
public String pruneText(int depth, String text) { return text; }- Specified by:
pruneTextin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)text- The Text value- Returns:
- null if you want to exclude this Text, or a non-null value which will become the new Text value.
-
pruneProcessingInstruction
public boolean pruneProcessingInstruction(int depth, java.lang.String target)Description copied from interface:StAXFilterAn Element is being included, and this is a child ProcessingInstruction event of the included parent Element. Should this ProcessingInstruction be pruned from the parent fragment?- Specified by:
pruneProcessingInstructionin interfaceStAXFilter- Parameters:
depth- The depth of this content from the document root (the root Element is at depth 0)target- The ProcessingInstruction Target value- Returns:
- true if you want to exclude this ProcessingInstruction.
-
-