|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.xom.NodeFactory
nu.xom.samples.StreamingTextExtractor
public class StreamingTextExtractor
Demonstrates filtered streaming via a NodeFactory
subclass.
Constructor Summary | |
---|---|
StreamingTextExtractor()
|
|
StreamingTextExtractor(java.io.Writer out)
|
Method Summary | |
---|---|
void |
finishMakingDocument(nu.xom.Document doc)
Signals the end of a document. |
static void |
main(java.lang.String[] args)
|
nu.xom.Nodes |
makeAttribute(java.lang.String name,
java.lang.String namespace,
java.lang.String value,
nu.xom.Attribute.Type type)
Returns a new Nodes object containing an
attribute in the specified namespace
with the specified name and type. |
nu.xom.Nodes |
makeComment(java.lang.String data)
Returns a new Nodes object containing a
comment with the specified text. |
nu.xom.Nodes |
makeDocType(java.lang.String rootElementName,
java.lang.String publicID,
java.lang.String systemID)
Returns a new Nodes object containing a
DocType object with the specified root element
name, system ID, and public ID. |
nu.xom.Nodes |
makeProcessingInstruction(java.lang.String target,
java.lang.String data)
Returns a new Nodes object containing a
new ProcessingInstruction object with
the specified target and data. |
nu.xom.Element |
makeRootElement(java.lang.String name,
java.lang.String namespace)
Creates a new element in the specified namespace with the specified name. |
nu.xom.Nodes |
makeText(java.lang.String data)
Returns a new Nodes object containing a
text node with the specified content. |
nu.xom.Element |
startMakingElement(java.lang.String name,
java.lang.String namespace)
Creates a new Element in the specified namespace
with the specified name. |
Methods inherited from class nu.xom.NodeFactory |
---|
finishMakingElement, startMakingDocument |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StreamingTextExtractor(java.io.Writer out)
public StreamingTextExtractor()
Method Detail |
---|
public nu.xom.Nodes makeComment(java.lang.String data)
nu.xom.NodeFactory
Returns a new Nodes
object containing a
comment with the specified text.
Subclasses may change the content or other
characteristics of the comment returned.
Subclasses may change the nodes returned from this method.
They may return a Nodes
object containing any
number of children and attributes which are appended and
added to the current parent element. This Nodes
object should not contain any Document
objects.
All of the nodes returned must be parentless.
Subclasses may return an empty Nodes
to indicate
the comment should not be included in the
finished document.
makeComment
in class nu.xom.NodeFactory
data
- the complete text content of the comment
public nu.xom.Nodes makeText(java.lang.String data)
nu.xom.NodeFactory
Returns a new Nodes
object containing a
text node with the specified content.
Subclasses may change the content or other characteristics of
the text returned. Subclasses may also change the nodes
returned from this method. They may return a Nodes
object containing any number of nodes which are added or
appended to the current parent node. This Nodes
object must not contain any Document
nodes. All of
the nodes returned must be parentless. Subclasses may return an
empty Nodes
to indicate the text should not be
included in the finished document.
makeText
in class nu.xom.NodeFactory
data
- the complete text content of the node
public nu.xom.Element makeRootElement(java.lang.String name, java.lang.String namespace)
nu.xom.NodeFactory
Creates a new element in the specified namespace with the specified name. The builder calls this method to make the root element of the document.
Subclasses may change the name, namespace, content, or other
characteristics of the element returned.
The default implementation merely calls
startMakingElement
. However, when subclassing, it
is often useful to be able to easily distinguish between the
root element and a non-root element because the root element
cannot be detached. Therefore, subclasses must not return null
from this method. Doing so will cause a
NullPointerException
.
makeRootElement
in class nu.xom.NodeFactory
name
- the qualified name of the elementnamespace
- the namespace URI of the element
public nu.xom.Element startMakingElement(java.lang.String name, java.lang.String namespace)
nu.xom.NodeFactory
Creates a new Element
in the specified namespace
with the specified name.
Subclasses may change the name, namespace, content, or other
characteristics of the Element
returned.
Subclasses may return null to indicate the
Element
should not be created.
However, doing so will only remove the element's start-tag and
end-tag from the result tree. Any content inside the element
will be attached to the element's parent by default, unless it
too is filtered. To remove an entire element, return an empty
Nodes
object from the
finishMakingElement()
method.
startMakingElement
in class nu.xom.NodeFactory
name
- the qualified name of the elementnamespace
- the namespace URI of the element
public nu.xom.Nodes makeAttribute(java.lang.String name, java.lang.String namespace, java.lang.String value, nu.xom.Attribute.Type type)
nu.xom.NodeFactory
Returns a new Nodes
object containing an
attribute in the specified namespace
with the specified name and type.
Subclasses may change the nodes returned from this method.
They may return a Nodes
object containing any
number of children and attributes which are appended and
added to the current parent element. This Nodes
object may not contain any Document
objects.
All of the nodes returned must be parentless.
Subclasses may return an empty Nodes
to indicate
the attribute should not be created.
makeAttribute
in class nu.xom.NodeFactory
name
- the prefixed name of the attributenamespace
- the namespace URIvalue
- the attribute valuetype
- the attribute type
public nu.xom.Nodes makeDocType(java.lang.String rootElementName, java.lang.String publicID, java.lang.String systemID)
nu.xom.NodeFactory
Returns a new Nodes
object containing a
DocType
object with the specified root element
name, system ID, and public ID.
Subclasses may change the root element name, public ID,
system ID, or other characteristics of the DocType
returned. Subclasses may change the nodes returned from this
method. They may return a Nodes
object containing
any number of comments and processing instructions which are
appended to the current parent node. This Nodes
object may not contain any Document
,
Element
, Attribute
, or
Text
objects. All of the nodes returned must be
parentless. Subclasses may return an empty Nodes
to
indicate the DocType
should not be included in the
finished document.
makeDocType
in class nu.xom.NodeFactory
rootElementName
- the declared, qualified name
for the root elementpublicID
- the public ID of the external DTD subsetsystemID
- the URL of the external DTD subset
public nu.xom.Nodes makeProcessingInstruction(java.lang.String target, java.lang.String data)
nu.xom.NodeFactory
Returns a new Nodes
object containing a
new ProcessingInstruction
object with
the specified target and data.
Subclasses may change the target, data, or other
characteristics of the ProcessingInstruction
returned. Subclasses may change the nodes returned from this
method. They may return a Nodes
object containing
any number of nodes which are added or
appended to the current parent node. This Nodes
object must not contain any Document
nodes.
If the processing instruction appears in the prolog or epilog
of the document, then it must also not contain any
Element
, Attribute
, or
Text
objects.
All of the nodes returned must be parentless. Subclasses
may return an empty Nodes
to indicate the
processing instruction should not be included in the
finished document.
makeProcessingInstruction
in class nu.xom.NodeFactory
target
- the target of the processing instructiondata
- the data of the processing instruction
public void finishMakingDocument(nu.xom.Document doc)
nu.xom.NodeFactory
Signals the end of a document. The default implementation of this method does nothing. The builder does not call this method if an exception is thrown while building a document.
finishMakingDocument
in class nu.xom.NodeFactory
doc
- the completed Document
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |