core
Class XMLBurger

java.lang.Object
  extended by core.XMLBurger

public class XMLBurger
extends java.lang.Object

Library for efficient parsing of odd XML files. Particularly useful while dealing with odd XML document, where the mapping to Java Object is difficult.

Version:
1.0
Author:
Samuel Croset

Field Summary
private  int eventType
           
private  java.io.FileInputStream fileInputStream
           
private  org.codehaus.stax2.XMLStreamReader2 reader
           
 
Constructor Summary
XMLBurger(java.lang.String pathOfXML)
          Create an XMLBurger object from an XML file.
 
Method Summary
 int getEventType()
           
 java.io.FileInputStream getFileInputStream()
           
 org.codehaus.stax2.XMLStreamReader2 getReader()
           
 java.lang.String getTagAttribute(java.lang.String attribute)
          Return the value associated with the current tag attribute.
 java.lang.String getTagText()
          Return the text associated with the current tag.
 boolean inTag(java.lang.String tag)
          Stay inside the tag passed as parameter.
Usage:
while(burger.inTag("NameOfYourTag")){
//Do something while staying inside the loop, usually looking for over tags via the tag() method.
}
 boolean isNotOver()
          Main loop, over the content of the entire XML.
while(burger.isNotOver()){
//Do things and check for tags
}
 void setEventType(int eventType)
           
 void setFileInputStream(java.io.FileInputStream fileInputStream)
           
 void setReader(org.codehaus.stax2.XMLStreamReader2 reader)
           
 boolean tag(java.lang.String tag)
          Check if the tag passed as parameter is encountered.
Usage:
if(burger.tag("NameOfYourTag")){
//Do something, like instantiating of of your object or looping over the tag using the inTag("") method
}
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileInputStream

private java.io.FileInputStream fileInputStream

reader

private org.codehaus.stax2.XMLStreamReader2 reader

eventType

private int eventType
Constructor Detail

XMLBurger

public XMLBurger(java.lang.String pathOfXML)
Create an XMLBurger object from an XML file.

Parameters:
pathOfXML -
Method Detail

setEventType

public void setEventType(int eventType)

getEventType

public int getEventType()

setReader

public void setReader(org.codehaus.stax2.XMLStreamReader2 reader)

getReader

public org.codehaus.stax2.XMLStreamReader2 getReader()

setFileInputStream

public void setFileInputStream(java.io.FileInputStream fileInputStream)

getFileInputStream

public java.io.FileInputStream getFileInputStream()

isNotOver

public boolean isNotOver()
Main loop, over the content of the entire XML.
while(burger.isNotOver()){
//Do things and check for tags
}

Returns:
whether the XML document is over or not.
Throws:
javax.xml.stream.XMLStreamException

tag

public boolean tag(java.lang.String tag)
Check if the tag passed as parameter is encountered.
Usage:
if(burger.tag("NameOfYourTag")){
//Do something, like instantiating of of your object or looping over the tag using the inTag("") method
}

Parameters:
tag -
Returns:
whether or not the current parsed tag is the tag entered as input

inTag

public boolean inTag(java.lang.String tag)
Stay inside the tag passed as parameter.
Usage:
while(burger.inTag("NameOfYourTag")){
//Do something while staying inside the loop, usually looking for over tags via the tag() method.
}

Parameters:
tag -
Returns:
whether or not the cursor is still in the tag entered in input.
Throws:
javax.xml.stream.XMLStreamException

getTagText

public java.lang.String getTagText()
Return the text associated with the current tag. The construct has to be like this: [yourTag]the text[/yourTag]
Usage:
if(burger.tag("NameOfYourTag")){
//Do something, for example instantiate one of your object.
//Retrieve the text inside the tag "NameOfYourTag".
String text = burger.getTagText();
//You can do something with this value, for example setting a property of an object.
}

Returns:
the text contained by the tag.

getTagAttribute

public java.lang.String getTagAttribute(java.lang.String attribute)
Return the value associated with the current tag attribute. The construct has to be like this: [yourTag attribute="value"]the text[/yourTag]
Usage:
if(burger.tag("NameOfYourTag")){
//Do something, for example instantiate one of your object.
//Retrieve the value of the specified attribute.
String value = burger.getTagAttribute("attribute");
//You can do something with this value, for example setting a property of an object.
}

Parameters:
attribute -
Returns:
the value of the attribute.