Package ejava.projects.esales.xml
Class ESalesParser
- java.lang.Object
-
- ejava.projects.esales.xml.ESalesParser
-
public class ESalesParser extends Object
This class will read in Java objects from a specified XML file. These objects can be used to create ingest data for projects.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
log
static String
SAMPLE_FILE
protected javax.xml.bind.Unmarshaller
um
protected XMLInputFactory
xmlif
protected XMLStreamReader
xmlr
-
Constructor Summary
Constructors Constructor Description ESalesParser(Class<?> rootType, InputStream is)
Pass in the JAXB class that represents the root node of the document and an InputStream for the document to parse.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
contains(String[] elements, String localName)
Object
getObject(String... elements)
This method will return either the object or null if we hit the end of stream before getting another instance.static InputStream
getSampleData()
void
setSchema(InputStream schema)
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
xmlif
protected XMLInputFactory xmlif
-
um
protected javax.xml.bind.Unmarshaller um
-
xmlr
protected XMLStreamReader xmlr
-
SAMPLE_FILE
public static final String SAMPLE_FILE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ESalesParser
public ESalesParser(Class<?> rootType, InputStream is) throws javax.xml.bind.JAXBException, XMLStreamException
Pass in the JAXB class that represents the root node of the document and an InputStream for the document to parse.- Parameters:
rootType
- - the class of the root typeis
- - am input stream with document to parse- Throws:
javax.xml.bind.JAXBException
XMLStreamException
-
-
Method Detail
-
setSchema
public void setSchema(InputStream schema) throws SAXException
- Throws:
SAXException
-
getObject
public Object getObject(String... elements) throws XMLStreamException, javax.xml.bind.JAXBException
This method will return either the object or null if we hit the end of stream before getting another instance. Note that only the local-name is being used. That won't work to great when two namespaces declare a common local-name. Should be easily fixable when needed.- Parameters:
element
-- Returns:
- Throws:
XMLStreamException
javax.xml.bind.JAXBException
-
getSampleData
public static InputStream getSampleData()
-
-