Last update: 2011-06-23

org.proteios.io
Class XMLReaderUtil

java.lang.Object
  extended by org.proteios.io.XMLReaderUtil

public class XMLReaderUtil
extends Object

Use this class to simplify lookup and positioning of an XMLStreamReader

Author:
gregory

Constructor Summary
XMLReaderUtil()
           
 
Method Summary
 boolean gotoTag(javax.xml.stream.XMLStreamReader parser, String tagName)
          Positions the parser to the tag named tagName.
 boolean gotoTag(javax.xml.stream.XMLStreamReader parser, String tagName, Integer attrIndex, String attrValue)
          If attrIndex and attrValue are both null only the tagName will be searched for
 boolean gotoTag(javax.xml.stream.XMLStreamReader parser, String tagName, String attrName, String attrValue)
           
 boolean gotoTag(javax.xml.stream.XMLStreamReader parser, XMLTag template)
          Positions the parser to start tag matching the given template.
 XMLTag parse(javax.xml.stream.XMLStreamReader parser, TagFactory factory, XMLTag template, XMLTag parent)
          Find the next element matching template tag and adds it as a child to the parent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLReaderUtil

public XMLReaderUtil()
Method Detail

parse

public XMLTag parse(javax.xml.stream.XMLStreamReader parser,
                    TagFactory factory,
                    XMLTag template,
                    XMLTag parent)
             throws javax.xml.stream.XMLStreamException
Find the next element matching template tag and adds it as a child to the parent.

Parameters:
parser - XMLStreamReader
factory - used to create tags
template - XMLTag to match
parent - optional parent tag
Returns:
a new tag matching the template or null if none is found
Throws:
javax.xml.stream.XMLStreamException

gotoTag

public boolean gotoTag(javax.xml.stream.XMLStreamReader parser,
                       XMLTag template)
Positions the parser to start tag matching the given template. Starts by looking at the current position. Note that the parser will be moved to the end of the stream if no matching tag is found.

Parameters:
parser - to position
template - XMLTag to match
Returns:
true if one is found, false otherwise

gotoTag

public boolean gotoTag(javax.xml.stream.XMLStreamReader parser,
                       String tagName)
Positions the parser to the tag named tagName.

Parameters:
parser - to position
tagName - in UPPERCASE
Returns:
true if one is found, false otherwise

gotoTag

public boolean gotoTag(javax.xml.stream.XMLStreamReader parser,
                       String tagName,
                       Integer attrIndex,
                       String attrValue)
If attrIndex and attrValue are both null only the tagName will be searched for

Parameters:
parser - xml reader to position
tagName - in UPPERCASE
attrIndex - attribute index to match
attrValue - value of attribute to match
Returns:
true if one is found, false otherwise

gotoTag

public boolean gotoTag(javax.xml.stream.XMLStreamReader parser,
                       String tagName,
                       String attrName,
                       String attrValue)
Parameters:
parser -
tagName - in UPPERCASE
attrName - attribute name to match
attrValue - value of attribute to match
Returns:
true if one is found, false otherwise

Last update: 2011-06-23