|
||||||||||
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.discovery.utils.CapsdKnownAddressParser
The CapsdKnownAddressParser is designed to parse node addresses that are sent by the capabilities daemon to the discovery process. Capsd will only send the addresses of nodes which have been added to the database. The SOAP document that is exchanged can be decomposed into the new addresses.
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 |
CAPSD_IPV4ADDR
The BlueBird Capsd IPv4Address address. |
private String |
CAPSD_KNOWNADDR
The BlueBird Capsd known address tag. |
private String |
CAPSD_NS
The BlueBird Capabilities Daemon namespace uri. |
private StringBuffer |
m_addrBuf
A temporary string buffer to store character data when the m_isIPv4Addr is true. |
private List |
m_addresses
A list of IPv4Address objects extracted from the document. |
private int |
m_error
Set if a tag is in error. |
private boolean |
m_isIPv4Addr
Set to true if the IPv4Address tag has been parsed. |
private boolean |
m_isKnownAddr
Set to true if the OpenNMS NewAddress tag was processed successfully. |
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 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. |
Constructor Summary | |
CapsdKnownAddressParser()
The class constructor creates a new instance of the CapsdKnownAddressParser. |
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 |
getAddresses()
Returns the list of address 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_addresses
A list of IPv4Address objects extracted from the document.
private StringBuffer m_addrBuf
A temporary string buffer to store character data when the m_isIPv4Addr 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_isKnownAddr
Set to true if the OpenNMS NewAddress tag was processed successfully.
private boolean m_isIPv4Addr
Set to true if the IPv4Address tag has been parsed.
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 CAPSD_KNOWNADDR
The BlueBird Capsd known address tag.
private final String CAPSD_IPV4ADDR
The BlueBird Capsd IPv4Address address.
private final String CAPSD_NS
The BlueBird Capabilities Daemon namespace uri.
Constructor Detail |
public CapsdKnownAddressParser()
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 getAddresses()
Returns the list of address 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 |