Top Description Methods
org.jdom2.input.stax

public Interface StAXFilter

Known Direct Implementers
org.jdom2.input.stax.DefaultStAXFilter
Imports
org.jdom2.Namespace

In StAX Processing it is possible to read fragments of XML. JDOM supports reading JDOM Content from StAX Readers in fragments. JDOM users can influence the content that is processed by the return values in this interface.

Using the StAXStreamBuilder or StAXEventBuilder you can parse a List of JDOM content by filtering that content with an instance of this filter.

There are two significant states in which methods in this interface will be called:

Author
Rolf Lear

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

null if you want to exclude this CDATA, or a non-null value which will become the new CDATA text value.
includeCDATA
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The CDATA text value
text
)

The current event is a CDATA event.

public String

Returns:

null if you want to exclude this comment, or a non-null value which will become the new comment value.
includeComment
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The Comment value
comment
)

The current event is a Comment event.

public boolean

Returns:

true if the DocType should become a JDOM Fragment.
includeDocType
()

The current event is a DocType event.

public boolean

Returns:

true if the Element should become a JDOM Fragment.
includeElement
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The XML tag name of this Element
name
,
Namespace
The Namespace of this Element
ns
)

The current event is an Element event.

public boolean

Returns:

true if you want to include this EntityRef.
includeEntityRef
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The EntityRef name
name
)

The current event is an EntityRef event.

public boolean

Returns:

true if you want to include this ProcessingInstruction.
includeProcessingInstruction
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The ProcessingInstruction Target value
target
)

The current event is a ProcessingInstruction event.

public String

Returns:

null if you want to exclude this Text, or a non-null value which will become the new Text value.
includeText
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The Text value
text
)

The current event is a TEXT event.

public String

Returns:

null if you want to exclude this CDATA, or a non-null value which will become the new CDATA text value.
pruneCDATA
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The CDATA text value
text
)

An Element is being included, and this is a child CDATA event of the included parent Element.

public String

Returns:

null if you want to exclude this Comment, or a non-null value which will become the new Comment value.
pruneComment
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The Comment value
comment
)

An Element is being included, and this is a child Comment event of the included parent Element.

public boolean

Returns:

true if the child Element should be excluded.
pruneElement
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The XML tag name of this child Element
name
,
Namespace
The Namespace of this child Element
ns
)

An Element is being included, and this is a child Element event of the included parent Element.

public boolean

Returns:

true if you want to exclude this EntityRef.
pruneEntityRef
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The EntityRef name
name
)

An Element is being included, and this is a child EntityRef event of the included parent Element.

public boolean

Returns:

true if you want to exclude this ProcessingInstruction.
pruneProcessingInstruction
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The ProcessingInstruction Target value
target
)

An Element is being included, and this is a child ProcessingInstruction event of the included parent Element.

public String

Returns:

null if you want to exclude this Text, or a non-null value which will become the new Text value.
pruneText
(int
The depth of this content from the document root (the root Element is at depth 0)
depth
,
String
The Text value
text
)

An Element is being included, and this is a child Text event of the included parent Element.

Method Detail

includeCDATAback to summary
public String includeCDATA(int depth, String text)

The 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;
}
Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

text:String

The CDATA text value

Returns:String

null if you want to exclude this CDATA, or a non-null value which will become the new CDATA text value.

includeCommentback to summary
public String includeComment(int depth, String comment)

The 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;
}
Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

comment:String

The Comment value

Returns:String

null if you want to exclude this comment, or a non-null value which will become the new comment value.

includeDocTypeback to summary
public boolean includeDocType()

The current event is a DocType event.

Returns:boolean

true if the DocType should become a JDOM Fragment.

includeElementback to summary
public boolean includeElement(int depth, String name, Namespace ns)

The 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.

Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

name:String

The XML tag name of this Element

ns:Namespace

The Namespace of this Element

Returns:boolean

true if the Element should become a JDOM Fragment.

includeEntityRefback to summary
public boolean includeEntityRef(int depth, String name)

The current event is an EntityRef event.

Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

name:String

The EntityRef name

Returns:boolean

true if you want to include this EntityRef.

includeProcessingInstructionback to summary
public boolean includeProcessingInstruction(int depth, String target)

The current event is a ProcessingInstruction event.

Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

target:String

The ProcessingInstruction Target value

Returns:boolean

true if you want to include this ProcessingInstruction.

includeTextback to summary
public String includeText(int depth, String text)

The 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;
}
Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

text:String

The Text value

Returns:String

null if you want to exclude this Text, or a non-null value which will become the new Text value.

pruneCDATAback to summary
public String pruneCDATA(int depth, String text)

An 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;
}
Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

text:String

The CDATA text value

Returns:String

null if you want to exclude this CDATA, or a non-null value which will become the new CDATA text value.

pruneCommentback to summary
public String pruneComment(int depth, String comment)

An 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;
}
Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

comment:String

The Comment value

Returns:String

null if you want to exclude this Comment, or a non-null value which will become the new Comment value.

pruneElementback to summary
public boolean pruneElement(int depth, String name, Namespace ns)

An 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?

Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

name:String

The XML tag name of this child Element

ns:Namespace

The Namespace of this child Element

Returns:boolean

true if the child Element should be excluded.

pruneEntityRefback to summary
public boolean pruneEntityRef(int depth, String name)

An 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?

Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

name:String

The EntityRef name

Returns:boolean

true if you want to exclude this EntityRef.

pruneProcessingInstructionback to summary
public boolean pruneProcessingInstruction(int depth, String target)

An 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?

Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

target:String

The ProcessingInstruction Target value

Returns:boolean

true if you want to exclude this ProcessingInstruction.

pruneTextback to summary
public String pruneText(int depth, String text)

An 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;
}
Parameters
depth:int

The depth of this content from the document root (the root Element is at depth 0)

text:String

The Text value

Returns:String

null if you want to exclude this Text, or a non-null value which will become the new Text value.