|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.common.utils.BBParser
BBParser provides basic XML parsing functionality to parse XML from a file or an input stream BBParser creates a DOMParser which creates a DOM tree of the XML being parsed. BBParser provides the error handling routines for the DOM parser and provides some methods to traverse the elements of the DOM tree created as a result of the parse. The DOMParser created throws an IOException if the xml file is not found or if the xml does not conform to its DTD. In addition to this, BBParser and its sub-classes can set their own exception messages and throw exceptions if the values read are not what is expected. Sub-classes will need to override the 'processElement()' method and implement their own storage and data getter methods specific to the XML that is being processed
Inner Class Summary | |
private class |
BBParser.BBErrorHandler
Class BBErrorHandler implements the org.xml.sax.ErrorHandler interface - this is then set as the error handler for the DOMParser to track errors |
Field Summary | |
protected int |
ATTRIB_VALUE_PAIR_ERR
Error number set when a typical |
protected String |
ATTRIB_VALUE_PAIR_ERR_STR
Error message set when the ATTRIB_VALUE_PAIR error occurs |
protected int |
EXCEPTION
Error number set by default when there is an exception |
protected StringBuffer |
m_curElement
Element currently being processed - will need to be set as the sub-class goes through the DOM tree |
protected int |
m_errNum
The error number set when an error is encountered |
protected String |
m_exceptionMsg
The error message set when an error is encountered |
protected org.xml.sax.InputSource |
m_inpSource
Input Stream being parsed |
protected org.apache.xerces.parsers.DOMParser |
m_parser
DOM parser that builds the DOM tree |
protected int |
NULL_VALUE_ERR
Error number set when the value read is null |
protected String |
NULL_VALUE_ERR_STR
Error message set when the value read is null |
Constructor Summary | |
BBParser()
Default constructor - creates the DOMParser |
Method Summary | |
String |
getErrorMessage()
Returns the error message for the parse |
int |
getErrorNumber()
Returns the error number for the parse |
void |
parse()
Parse the already set 'm_inpSource' |
void |
parse(org.xml.sax.InputSource inpSource)
Parses the input stream passed |
void |
parse(InputStream inpStream)
Parses the input stream passed |
void |
parse(String fileName)
Parse the fileName passed |
protected boolean |
processDocument(org.w3c.dom.Document doc)
Process the 'Document' object or the root of the DOM tree |
protected boolean |
processElement(org.w3c.dom.Element el,
boolean isRoot)
This is the method to be overridden by sub-classes to branch off and go through the DOM tree to handle elements specific to the XML they are parsing - does nothing here |
protected boolean |
processNode(org.w3c.dom.Node node)
Processes a 'Node' object of the DOM tree depending upon the node type |
protected String |
processParmValue(org.w3c.dom.Node parmValueNode)
Returns the value from a " |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected final int ATTRIB_VALUE_PAIR_ERR
protected final int NULL_VALUE_ERR
protected final int EXCEPTION
protected final String ATTRIB_VALUE_PAIR_ERR_STR
protected final String NULL_VALUE_ERR_STR
protected StringBuffer m_curElement
protected String m_exceptionMsg
protected int m_errNum
protected org.apache.xerces.parsers.DOMParser m_parser
protected org.xml.sax.InputSource m_inpSource
Constructor Detail |
public BBParser()
Method Detail |
protected boolean processDocument(org.w3c.dom.Document doc)
protected boolean processNode(org.w3c.dom.Node node)
protected boolean processElement(org.w3c.dom.Element el, boolean isRoot)
protected String processParmValue(org.w3c.dom.Node parmValueNode)
public void parse() throws IOException
throws
- java.io.IOException if parse fails for any reasonpublic void parse(String fileName) throws IOException
fileName
- file to be parsedthrows
- java.io.IOException if parse fails for any reasonpublic void parse(InputStream inpStream) throws IOException
inpStream
- the java.io.InputStream that contains the XML to be parsedthrows
- java.io.IOException if parse fails for any reasonpublic void parse(org.xml.sax.InputSource inpSource) throws IOException
inpStream
- the org.xml.sax.InputSource that contains the XML to be parsedthrows
- java.io.IOException if parse fails for any reasonpublic int getErrorNumber()
public String getErrorMessage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |