|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.xom.NodeFactory
nu.xom.samples.MinimalNodeFactory
nu.xom.samples.RSSHeadlines
public class RSSHeadlines
Print just the headlines from an RSS feed
Constructor Summary | |
---|---|
RSSHeadlines()
|
Method Summary | |
---|---|
nu.xom.Nodes |
finishMakingElement(nu.xom.Element element)
Signals the end of an element. |
static void |
main(java.lang.String[] args)
|
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.samples.MinimalNodeFactory |
---|
makeAttribute, makeComment, makeDocType, makeProcessingInstruction, makeRootElement |
Methods inherited from class nu.xom.NodeFactory |
---|
finishMakingDocument, startMakingDocument |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RSSHeadlines()
Method Detail |
---|
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 MinimalNodeFactory
name
- the qualified name of the elementnamespace
- the namespace URI of the element
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 MinimalNodeFactory
data
- the complete text content of the node
public nu.xom.Nodes finishMakingElement(nu.xom.Element element)
nu.xom.NodeFactory
Signals the end of an element. This method should return
the Nodes
to be added to the tree.
They need not contain the Element
that
was passed to this method, though most often they will.
By default the Nodes
returned contain
only the built element. However, subclasses may return
a list containing any number of nodes, all of which will be
added to the tree at the current position in the order given by
the list (subject to the usual well-formedness constraints, of
course. For instance, the list should not contain a
DocType
object unless the element is the root
element, and the document does not already have a
DocType
). All of the nodes returned must be
parentless. If this method returns an empty list,
then the element (including all its contents) is not included
in the finished document.
To process an element at a time, override this method in a
subclass so that it functions as a callback. When you're done
processing the Element
, return an empty list so
that it will be removed from the tree and garbage collected.
Be careful not to return an empty list for the root element
though. That is, when the element passed to this method is the
root element, the list returned must contain exactly one
Element
object. The simplest way to check this
is testing if element.getParent() instanceof
Document
.
Do not detach element
or any of its ancestors
while inside this method. Doing so can royally muck up the
build.
finishMakingElement
in class nu.xom.NodeFactory
element
- the finished Element
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |