|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xml.sax.helpers.DefaultHandler | +--org.opennms.bb.dp.poller.parsers.MonitorResponseParser
The MonitorResponseParser is designed to parse ICMP monitor responses from discovery. The SOAP document that is exchanged can be decomposed into an ICMP poll reply including (but not limited to) IPv4 address, number of retries and timeout (ms).
In order to use the class, first create an instance of an XML parser using the Xerces SAXPaser class. Then set an instance of this class as the ErrorHandler and the ContentHandler. After seting up the parser just call the parse method. If the parser fails then the list of address returned will be null.
SAXParser
,
ContentHandler
,
ErrorHandler
,
DefaultHandler
Field Summary | |
private String |
DISCOVERY_NS
The BlueBird Discovery namespace uri. |
private String |
IPV4ADDR
|
private StringBuffer |
m_addrBuf
A temporary string buffer to store character data when the m_isIPv4Addr is true. |
private int |
m_error
Set if a tag is in error. |
private boolean |
m_isIPv4Addr
|
private boolean |
m_isMonitorResponse
Set to true if the corresponding tag was processed successfully. |
private boolean |
m_isResponse
|
private boolean |
m_isSoapCompliantBody
Set to true if the SOAP body tag was processed successfully |
private boolean |
m_isSoapCompliantEnv
Set to true if the SOAP envlope was processed successfully. |
private boolean |
m_isStatus
|
private List |
m_responses
A list of response objects extracted from the document. |
private StringBuffer |
m_statusBuf
A temporary string buffer to store character data when the m_isStatus is true. |
private String |
MONITOR_RESPONSE
|
private String |
RESPONSE
|
private String |
SOAP_BODY
The SOAP Body tag |
private String |
SOAP_ENV
The SOAP Envelope tag |
private String |
SOAP_NS
The SOAP envelope namespace that is required for SOAP conformance. |
private String |
STATUS
|
Constructor Summary | |
MonitorResponseParser()
The class constructor creates a new instance of the MonitorResponseParser. |
Method Summary | |
void |
characters(char[] data,
int offset,
int length)
This method is used to receive event notifiaction of character data. |
void |
endElement(String uri,
String localName,
String qName)
Called to process the end of an element for the document. |
void |
error(org.xml.sax.SAXParseException ex)
The error handler is invoked by the parser when a recoverable error occurs parsing the document. |
void |
fatalError(org.xml.sax.SAXParseException ex)
The fatal error handler is invoked by the parser when a non-recoverable error occurs parsing the document. |
List |
getResponses()
Returns the list of responses recovered by the parser. |
static void |
main(String[] args)
A sample test program. |
void |
startDocument()
The startDocument method is called by the xerces parser when a new document is started. |
void |
startElement(String uri,
String localName,
String qName,
org.xml.sax.Attributes attributes)
Called to process the start of a new element for the document. |
void |
warning(org.xml.sax.SAXParseException ex)
The warning handler is invoked by the parser when a recoverable error occurs parsing the document. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
|
Field Detail |
private List m_responses
A list of response objects extracted from the document.
private StringBuffer m_addrBuf
A temporary string buffer to store character data when the m_isIPv4Addr is true.
private StringBuffer m_statusBuf
A temporary string buffer to store character data when the m_isStatus is true.
private boolean m_isSoapCompliantEnv
Set to true if the SOAP envlope was processed successfully.
private boolean m_isSoapCompliantBody
Set to true if the SOAP body tag was processed successfully
private boolean m_isMonitorResponse
Set to true if the corresponding tag was processed successfully.
private boolean m_isResponse
private boolean m_isIPv4Addr
private boolean m_isStatus
private int m_error
Set if a tag is in error. Each call to start element will increment the tag, if non-zero. Each call to end element will decrement the tag, if non-zero. This keeps tags from being processed when an error occurs until the corresponding end tag is caught.
private final String SOAP_ENV
The SOAP Envelope tag
private final String SOAP_BODY
The SOAP Body tag
private final String SOAP_NS
The SOAP envelope namespace that is required for SOAP conformance.
private final String MONITOR_RESPONSE
private final String RESPONSE
private final String IPV4ADDR
private final String STATUS
private final String DISCOVERY_NS
The BlueBird Discovery namespace uri.
Constructor Detail |
public MonitorResponseParser()
Method Detail |
public void startDocument() throws org.xml.sax.SAXException
The startDocument method is called by the xerces parser when a new document is started. If the instance previously contained any data, then it is lost since the class is reset to its initial state. This allows for an instance to be reused to parse new document and avoid creating new instances.
startDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
- Thrown if an error
occurs parsing the start of the document.public void startElement(String uri, String localName, String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Called to process the start of a new element for the document. If namespaces are enabled, then the uri will be a valid namesapce. See the base class for more information.
startElement
in class org.xml.sax.helpers.DefaultHandler
uri
- The XML namespace.localName
- The local name with the namespace prefix.qName
- The qualified name (includs namepace prefix).attributes
- The attributes associated with the element.org.xml.sax.SAXException
- Thrown if a processing
error occurs.public void endElement(String uri, String localName, String qName) throws org.xml.sax.SAXException
Called to process the end of an element for the document. If namespaces are enabled, then the uri will be a valid namesapce. See the base class for more information.
endElement
in class org.xml.sax.helpers.DefaultHandler
uri
- The XML namespace.localName
- The local name with the namespace prefix.qName
- The qualified name (includs namepace prefix).org.xml.sax.SAXException
- Thrown if a processing
error occurs.public void characters(char[] data, int offset, int length) throws org.xml.sax.SAXException
This method is used to receive event notifiaction of character data. The character data is attached to the last tag that was processed by the startElement method.
The character data in this method is ignored unless an address tag is being processed. No validation is performed to ensure that non-data elements have no data.
characters
in class org.xml.sax.helpers.DefaultHandler
data
- The character data from the parser.offset
- The offset in the data buffer that is valid.length
- The length of valid data from the offset.org.xml.sax.SAXException
- Thrown if a processing error
occurs.public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
The warning handler is invoked by the parser when a recoverable error occurs parsing the document.
warning
in class org.xml.sax.helpers.DefaultHandler
ex
- The exception that occured.org.xml.sax.SAXException
- Thrown if an error
occurs processing the exception.public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
The error handler is invoked by the parser when a recoverable error occurs parsing the document.
error
in class org.xml.sax.helpers.DefaultHandler
ex
- The exception that occured.org.xml.sax.SAXException
- Thrown if an error
occurs processing the exception.public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
The fatal error handler is invoked by the parser when a non-recoverable error occurs parsing the document.
fatalError
in class org.xml.sax.helpers.DefaultHandler
ex
- The exception that occured.org.xml.sax.SAXException
- Thrown if an error
occurs processing the exception.public List getResponses()
Returns the list of responses recovered by the parser.
public static void main(String[] args)
A sample test program. Creates an instance of the parser and parses each file passed on the command line. Once the each file is parse, the address(es) in the file are printed to the commmand line.
This is used solely for debugging and development testing.
args
- The arguments to main.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |