Public Member Functions | Protected Member Functions | Protected Attributes

de.mfuchs.xmlstorage.XMLPos Class Reference

XMLPos is the iterator for XML trees in XMLStorage. More...

Collaboration diagram for de.mfuchs.xmlstorage.XMLPos:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 XMLPos (XMLNode root)
 Construct an XMLPos, which points to the given XMLNode.
 XMLPos (final XMLPos other)
 Construct an XMLPos as copy of another.
 XMLPos (final XMLPos other, final String nodeName)
 Create XML tree iterator positioned at subnode node_name of current other position.
 XMLPos (final XMLPos other, final String nodeName, final String attrName, final String attrValue)
 Create XML tree iterator positioned at subnode node_name with attribute attrName and attribute value attrValue.
XMLNode cur ()
 Return the current node.
String get (final String attrName)
 Return the value of an attribute in the current node or "".
String get (final String attrName, final String def)
 Return the value of an attribute in the current node or a default value.
void put (final String attrName, final String value)
 Set an attribute value.
void addDown (XMLNode child)
 Insert children when building tree.
boolean back ()
 Go back to previous position.
boolean goDown ()
 Go down to first child.
boolean goDown (final String name)
 Search for child and go down.
boolean go (String path)
 Move X-Path like to position in XML tree.
boolean go (XPath xpath)
 Move X-Path like to position in XML tree.
void create (final String name)
 Create node and move to it.
void smartCreate (final String name)
 Create node if not already existing and move to it.
void smartCreate (final String name, final String attrName, final String attrValue)
 Search matching child node identified by key name and an attribute value.
String getContent ()
void setContent (final String s)
void setContent (final String s, boolean cdata)
String toString ()
 Return the name oif the current node.
void putSubattrib (final String nodeName, final String attrName, final String value)
 Set an attribute in a subnode.

Protected Member Functions

void goTo (XMLNode child)
 Go to the specified node.

Protected Attributes

XMLNode _root
XMLNode _cur
Stack< XMLNode_stack = new Stack<XMLNode>()

Detailed Description

XMLPos is the iterator for XML trees in XMLStorage.

Author:
Martin Fuchs

Definition at line 48 of file XMLPos.java.


Constructor & Destructor Documentation

de.mfuchs.xmlstorage.XMLPos.XMLPos ( XMLNode  root )

Construct an XMLPos, which points to the given XMLNode.

Parameters:
rootroot node

Definition at line 54 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLPos._root.

    {
        _root = root;
        _cur = root;
    }
de.mfuchs.xmlstorage.XMLPos.XMLPos ( final XMLPos  other )

Construct an XMLPos as copy of another.

Parameters:
otherXMLPos original

Definition at line 64 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLPos._root.

    {
        _root = other._root;
        _cur = other._cur;
        // don't copy _stack
    }
de.mfuchs.xmlstorage.XMLPos.XMLPos ( final XMLPos  other,
final String  nodeName 
)

Create XML tree iterator positioned at subnode node_name of current other position.

Parameters:
otherposition to be copied
nodeNamenew node name

Definition at line 76 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLPos._root, and de.mfuchs.xmlstorage.XMLPos.smartCreate().

    {
        _root = other._root;
        _cur = other._cur;
        // don't copy _stack
        smartCreate(nodeName);
    }

Here is the call graph for this function:

de.mfuchs.xmlstorage.XMLPos.XMLPos ( final XMLPos  other,
final String  nodeName,
final String  attrName,
final String  attrValue 
)

Create XML tree iterator positioned at subnode node_name with attribute attrName and attribute value attrValue.

See also:
XMLPos.smart_create
Parameters:
otherposition to be copied
nodeNamenew node name
attrNameattribute name
attrValueattribute value

Definition at line 93 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLPos._root, and de.mfuchs.xmlstorage.XMLPos.smartCreate().

    {
        _root = other._root;
        _cur = other._cur;
        // don't copy _stack
        smartCreate(nodeName, attrName, attrValue);
    }

Here is the call graph for this function:


Member Function Documentation

void de.mfuchs.xmlstorage.XMLPos.addDown ( XMLNode  child )

Insert children when building tree.

Parameters:
childnew child

Definition at line 145 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLNode.addChild(), and de.mfuchs.xmlstorage.XMLPos.goTo().

Referenced by de.mfuchs.xmlstorage.XMLPos.create(), de.mfuchs.xmlstorage.XMLPos.smartCreate(), and de.mfuchs.xmlstorage.XMLDocReader.startElement().

    {
        _cur.addChild(child);
        goTo(child);
    }

Here is the call graph for this function:

boolean de.mfuchs.xmlstorage.XMLPos.back (  )
void de.mfuchs.xmlstorage.XMLPos.create ( final String  name )

Create node and move to it.

Parameters:
namename of the new node

Definition at line 227 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos.addDown().

Referenced by de.mfuchs.XMLTest.test2Write(), de.mfuchs.XMLTest.test3Write(), de.mfuchs.Example3.testWrite(), de.mfuchs.Example2.testWrite(), de.mfuchs.Example1.testWrite(), and de.mfuchs.xmlstorage.XMLMessage.XMLMessage().

    {
        addDown(new XMLNode(name));
    }

Here is the call graph for this function:

XMLNode de.mfuchs.xmlstorage.XMLPos.cur (  )
String de.mfuchs.xmlstorage.XMLPos.get ( final String  attrName )

Return the value of an attribute in the current node or "".

Parameters:
attrNameattribute name
Returns:
attribute value

Definition at line 115 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.get().

Referenced by de.mfuchs.Example3.testRead(), and de.mfuchs.Example2.testRead().

    {
        return _cur.get(attrName);
    }

Here is the call graph for this function:

String de.mfuchs.xmlstorage.XMLPos.get ( final String  attrName,
final String  def 
)

Return the value of an attribute in the current node or a default value.

Parameters:
attrNameattribute name
defdefault value
Returns:
value

Definition at line 126 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.get().

    {
        return _cur.get(attrName, def);
    }

Here is the call graph for this function:

String de.mfuchs.xmlstorage.XMLPos.getContent (  )
Returns:
content string

Definition at line 269 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.getContent().

Referenced by de.mfuchs.XMLTest.test2Read(), and de.mfuchs.Example1.testRead().

    {
        return _cur.getContent();
    }

Here is the call graph for this function:

boolean de.mfuchs.xmlstorage.XMLPos.go ( String  path )

Move X-Path like to position in XML tree.

Parameters:
pathXPath expression
Returns:
true if successfull

Definition at line 200 of file XMLPos.java.

Referenced by de.mfuchs.XMLTest.test1(), de.mfuchs.XMLTest.test2Read(), de.mfuchs.Example3.testRead(), de.mfuchs.Example2.testRead(), and de.mfuchs.Example1.testRead().

    {
        return go(new XPath(path));
    }
boolean de.mfuchs.xmlstorage.XMLPos.go ( XPath  xpath )

Move X-Path like to position in XML tree.

Parameters:
xpathXPath object
Returns:
true if successfull

Definition at line 210 of file XMLPos.java.

References de.mfuchs.xmlstorage.XPath._absolute, de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLPos._root, de.mfuchs.xmlstorage.XMLNode.findRelative(), and de.mfuchs.xmlstorage.XMLPos.goTo().

    {
        XMLNode node = xpath._absolute? _root: _cur;

        node = node.findRelative(xpath);

        if (node != null) {
            goTo(node);
            return true;
        } else
            return false;
    }

Here is the call graph for this function:

boolean de.mfuchs.xmlstorage.XMLPos.goDown ( final String  name )

Search for child and go down.

Parameters:
namenode name
Returns:
true if successfull

Definition at line 184 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLNode.find(), and de.mfuchs.xmlstorage.XMLPos.goTo().

    {
        XMLNode node = _cur.find(name);

        if (node != null) {
            goTo(node);
            return true;
        } else
            return false;
    }

Here is the call graph for this function:

boolean de.mfuchs.xmlstorage.XMLPos.goDown (  )

Go down to first child.

Returns:
true if successfull

Definition at line 168 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLNode.getFirstChild(), and de.mfuchs.xmlstorage.XMLPos.goTo().

Referenced by de.mfuchs.XMLTest.test1(), de.mfuchs.XMLTest.test2Read(), and de.mfuchs.Example1.testRead().

    {
        XMLNode node = _cur.getFirstChild();

        if (node != null) {
            goTo(node);
            return true;
        } else
            return false;
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLPos.goTo ( XMLNode  child ) [protected]
void de.mfuchs.xmlstorage.XMLPos.put ( final String  attrName,
final String  value 
)

Set an attribute value.

Parameters:
attrNameattribute name
valuenew attribute value

Definition at line 136 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.put().

Referenced by de.mfuchs.XMLTest.test3Write(), de.mfuchs.Example3.testWrite(), and de.mfuchs.Example2.testWrite().

    {
        _cur.put(attrName, value);
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLPos.putSubattrib ( final String  nodeName,
final String  attrName,
final String  value 
)

Set an attribute in a subnode.

Parameters:
nodeNamenode name
attrNameattribute name
valueattribute value

Definition at line 319 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.putSubattrib().

    {
        _cur.putSubattrib(nodeName, attrName, value);
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLPos.setContent ( final String  s,
boolean  cdata 
)
Parameters:
snew content string
cdatawrite in CDATA format if true

Definition at line 286 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.setContent().

    {
        _cur.setContent(s, cdata);
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLPos.setContent ( final String  s )
Parameters:
snew content string

Definition at line 277 of file XMLPos.java.

Referenced by de.mfuchs.XMLTest.test2Write(), de.mfuchs.XMLTest.test3Write(), and de.mfuchs.Example1.testWrite().

    {
        setContent(s, false);
    }
void de.mfuchs.xmlstorage.XMLPos.smartCreate ( final String  name )

Create node if not already existing and move to it.

Parameters:
namename of the new node

Definition at line 236 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLPos.addDown(), de.mfuchs.xmlstorage.XMLNode.find(), and de.mfuchs.xmlstorage.XMLPos.goTo().

Referenced by de.mfuchs.xmlstorage.XMLPos.XMLPos().

    {
        XMLNode node = _cur.find(name);

        if (node != null)
            goTo(node);
        else
            addDown(new XMLNode(name));
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLPos.smartCreate ( final String  name,
final String  attrName,
final String  attrValue 
)

Search matching child node identified by key name and an attribute value.

It it doesn't exist, create it.

Parameters:
namename of the new node
attrNameattribute name
attrValueattribute value

Definition at line 253 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, de.mfuchs.xmlstorage.XMLPos.addDown(), de.mfuchs.xmlstorage.XMLNode.find(), de.mfuchs.xmlstorage.XMLPos.goTo(), and de.mfuchs.xmlstorage.XMLNode.put().

    {
        XMLNode node = _cur.find(name, attrName, attrValue);

        if (node != null)
            goTo(node);
        else {
            node = new XMLNode(name);
            addDown(node);
            node.put(attrName, attrValue);
        }
    }

Here is the call graph for this function:

String de.mfuchs.xmlstorage.XMLPos.toString (  )

Return the name oif the current node.

Definition at line 294 of file XMLPos.java.

References de.mfuchs.xmlstorage.XMLPos._cur, and de.mfuchs.xmlstorage.XMLNode.toString().

    {
        return _cur.toString();
    }

Here is the call graph for this function:


Member Data Documentation

Stack<XMLNode> de.mfuchs.xmlstorage.XMLPos._stack = new Stack<XMLNode>() [protected]

The documentation for this class was generated from the following file: