|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.dp.events.XMLEventsParser
The XMLEventsParser is a SAX based parser used to decompose an event stream into the corresponding event classes. The class provides realitivly strong structure checking, but does not require and/or parse an DTD that may proceed the data. This allows the parser to be used with a SAX based SOAP parser, since SOAP prohibits the used of DTDs.
Field Summary | |
private org.xml.sax.Attributes |
m_attributes
The last attributes elements passed to the startElement() method. |
private StringBuffer |
m_data
The buffer where subsequent textual information from the character() method are appendedd. |
private int |
m_depth
The current depth of the elements in the document and the TOS for the m_save member. |
private Event |
m_event
The event being currently processes |
private List |
m_events
The list of events from the stream |
private EventHeader |
m_header
The header recovered from the event stream |
private EventParameter |
m_parm
An event parameter, valid between <parm>...</parm> |
private int[] |
m_save
The save buffer stack. |
private EventSnmpInfo |
m_snmpInfo
An snmp information block. |
private static int |
SAVE_AUTOACTION
|
private static int |
SAVE_DESCR
|
private static int |
SAVE_EVENT
|
private static int |
SAVE_EVENTS
|
private static int |
SAVE_FORWARD
|
private static int |
SAVE_HDR_CREATED
|
private static int |
SAVE_HDR_DPNAME
|
private static int |
SAVE_HDR_MSTATION
|
private static int |
SAVE_HDR_VERSION
|
private static int |
SAVE_HEADER
|
private static int |
SAVE_HOST
|
private static int |
SAVE_IGNORE
|
private static int |
SAVE_INTERFACE
|
private static int |
SAVE_LOG
|
private static int |
SAVE_LOGGROUP
|
private static int |
SAVE_LOGMSG
|
private static int |
SAVE_MOUSEOVERTEXT
|
private static int |
SAVE_NODEID
|
private static int |
SAVE_NOTIFICATION
|
private static int |
SAVE_OPERACTION
|
private static int |
SAVE_OPERINSTRUCT
|
private static int |
SAVE_PARM
|
private static int |
SAVE_PARM_NAME
|
private static int |
SAVE_PARM_VALUE
|
private static int |
SAVE_PARMS
|
private static int |
SAVE_SERVICE
|
private static int |
SAVE_SEVERITY
|
private static int |
SAVE_SNMP
|
private static int |
SAVE_SNMP_EID
|
private static int |
SAVE_SNMP_EIDTEXT
|
private static int |
SAVE_SNMP_GENERIC
|
private static int |
SAVE_SNMP_SPECIFIC
|
private static int |
SAVE_SNMPHOST
|
private static int |
SAVE_SOURCE
|
private static int |
SAVE_TIME
|
private static int |
SAVE_TTICKET
|
private static int |
SAVE_UEI
|
(package private) static String |
TAG_AUTOACTION
|
(package private) static String |
TAG_CREATED
|
(package private) static String |
TAG_DESCR
|
(package private) static String |
TAG_DPNAME
|
(package private) static String |
TAG_EID
|
(package private) static String |
TAG_EIDTEXT
|
(package private) static String |
TAG_ENCODING
|
(package private) static String |
TAG_ENCODING_ATTR_BASE64
|
(package private) static String |
TAG_ENCODING_ATTR_TEXT
|
(package private) static String |
TAG_EVENT
|
(package private) static String |
TAG_EVENTS
|
(package private) static String |
TAG_FORWARD
|
(package private) static String |
TAG_GENERIC
|
(package private) static String |
TAG_HEADER
|
(package private) static String |
TAG_HOST
|
(package private) static String |
TAG_INTERFACE
|
(package private) static String |
TAG_LOG
|
(package private) static String |
TAG_LOGGROUP
|
(package private) static String |
TAG_LOGMSG
|
(package private) static String |
TAG_LOGMSGDEST
|
(package private) static String |
TAG_LOGMSGDEST_ATTR_LOGNDISPLAY
|
(package private) static String |
TAG_LOGMSGDEST_ATTR_LOGONLY
|
(package private) static String |
TAG_LOGMSGDEST_ATTR_SUPPRESS
|
(package private) static String |
TAG_MECHANISM
|
(package private) static String |
TAG_MECHANISM_ATTR_SNMPTCP
|
(package private) static String |
TAG_MECHANISM_ATTR_SNMPUDP
|
(package private) static String |
TAG_MECHANISM_ATTR_XMLTCP
|
(package private) static String |
TAG_MECHANISM_ATTR_XMLUDP
|
(package private) static String |
TAG_MOUSEOVERTEXT
|
(package private) static String |
TAG_MSTATION
|
(package private) static String |
TAG_NODEID
|
(package private) static String |
TAG_NOTIFICATION
|
(package private) static String |
TAG_OPERACTION
|
(package private) static String |
TAG_OPERACTIONMENU
|
(package private) static String |
TAG_OPERINSTR
|
(package private) static String |
TAG_PARM
|
(package private) static String |
TAG_PARM_NAME
|
(package private) static String |
TAG_PARM_VALUE
|
(package private) static String |
TAG_PARMS
|
(package private) static String |
TAG_SERVICE
|
(package private) static String |
TAG_SEVERITY
|
(package private) static String |
TAG_SNMP
|
(package private) static String |
TAG_SNMPHOST
|
(package private) static String |
TAG_SOURCE
|
(package private) static String |
TAG_SPECIFIC
|
(package private) static String |
TAG_STATE
|
(package private) static String |
TAG_STATE_ATTR_OFF
|
(package private) static String |
TAG_STATE_ATTR_ON
|
(package private) static String |
TAG_TIME
|
(package private) static String |
TAG_TIME_ATTR_DAY
|
(package private) static String |
TAG_TIME_ATTR_HOUR
|
(package private) static String |
TAG_TIME_ATTR_MIN
|
(package private) static String |
TAG_TIME_ATTR_MONTH
|
(package private) static String |
TAG_TIME_ATTR_SEC
|
(package private) static String |
TAG_TIME_ATTR_YEAR
|
(package private) static String |
TAG_TTICKET
|
(package private) static String |
TAG_TYPE
|
(package private) static String |
TAG_TYPE_ATTR_INT
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_COUNTER32
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_COUNTER64
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_GAUGE32
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_INT32
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_IPADDR
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_NULL
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_OBJECTID
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_OCTETSTR
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_OPAQUE
|
(package private) static String |
TAG_TYPE_ATTR_SNMP_TIMETICKS
|
(package private) static String |
TAG_TYPE_ATTR_STRING
|
(package private) static String |
TAG_UEI
|
(package private) static String |
TAG_VER
|
Constructor Summary | |
XMLEventsParser()
Constructs a new default instance of the parser that can be registered with a SAXParser. |
Method Summary | |
void |
characters(char[] data,
int offset,
int length)
Store the characters of the current element in the current element value buffer |
(package private) static void |
dataElement(PrintStream ps,
String tag,
org.xml.sax.Attributes attrs,
String value)
Prints out a data element into the print stream. |
private int |
depthOf(int token)
Returns the depth of a particular SAVE_??? tag. |
void |
endDocument()
Called when the end of the document is reached. |
(package private) static void |
endElement(PrintStream ps,
String tag)
Prints out the closing element. |
void |
endElement(String uri,
String localName,
String qName)
At the end of the element store the current element buffer value to the appropriate buffer. |
void |
endPrefixMapping(String prefix)
Ends a prefix to URI mapping. |
void |
error(org.xml.sax.SAXParseException ex)
Throw an exception if there is an error during parse |
void |
fatalError(org.xml.sax.SAXParseException ex)
Throw an exception if there is a fatal error during parse |
List |
getEvents()
Return the events in the stream |
EventHeader |
getHeader()
Returns the header from the event stream |
void |
ignorableWhitespace(char[] data,
int offset,
int length)
Ignore the whitespaces |
static void |
main(String[] args)
used for debugging |
void |
processingInstruction(String target,
String data)
Receives processing instructions |
static void |
serializeToXML(OutputStream out,
EventHeader hdr,
List events)
Generates a document confomant to this parser from the passed events. |
static void |
serializeToXML(OutputStream out,
List events)
Generates a document confomant to this parser from the passed events. |
static void |
serializeToXML(PrintStream out,
EventHeader hdr,
List events)
Generates a document confomant to this parser from the passed events. |
static void |
serializeToXML(PrintStream out,
List events)
Generates a document confomant to this parser from the passed events. |
void |
setDocumentLocator(org.xml.sax.Locator loc)
Sets the document locator. |
void |
skippedEntity(String name)
Recieves notification of a skipped entity. |
void |
startDocument()
Called when the document parsing is beginning. |
(package private) static void |
startElement(PrintStream ps,
String tag,
org.xml.sax.Attributes attrs)
Prints out a start xml tag with the passed attributes |
void |
startElement(String uri,
String localName,
String qName,
org.xml.sax.Attributes attrs)
Called when a new element is encountered in the document. |
void |
startPrefixMapping(String prefix,
String uri)
Starts a prefix to URI mapping. |
protected boolean |
validate(Event e)
Used to validate the event before it is placed onto the actual list of events. |
void |
warning(org.xml.sax.SAXParseException ex)
Throw an exception if there is a warning during parse |
Methods inherited from class java.lang.Object |
|
Field Detail |
static final String TAG_LOG
static final String TAG_HEADER
static final String TAG_VER
static final String TAG_DPNAME
static final String TAG_CREATED
static final String TAG_MSTATION
static final String TAG_EVENTS
static final String TAG_EVENT
static final String TAG_UEI
static final String TAG_SOURCE
static final String TAG_TIME
static final String TAG_TIME_ATTR_YEAR
static final String TAG_TIME_ATTR_MONTH
static final String TAG_TIME_ATTR_DAY
static final String TAG_TIME_ATTR_HOUR
static final String TAG_TIME_ATTR_MIN
static final String TAG_TIME_ATTR_SEC
static final String TAG_TYPE
static final String TAG_TYPE_ATTR_INT
static final String TAG_TYPE_ATTR_STRING
static final String TAG_TYPE_ATTR_SNMP_INT32
static final String TAG_TYPE_ATTR_SNMP_OCTETSTR
static final String TAG_TYPE_ATTR_SNMP_NULL
static final String TAG_TYPE_ATTR_SNMP_OBJECTID
static final String TAG_TYPE_ATTR_SNMP_IPADDR
static final String TAG_TYPE_ATTR_SNMP_COUNTER32
static final String TAG_TYPE_ATTR_SNMP_GAUGE32
static final String TAG_TYPE_ATTR_SNMP_TIMETICKS
static final String TAG_TYPE_ATTR_SNMP_OPAQUE
static final String TAG_TYPE_ATTR_SNMP_COUNTER64
static final String TAG_HOST
static final String TAG_SNMPHOST
static final String TAG_NODEID
static final String TAG_SERVICE
static final String TAG_INTERFACE
static final String TAG_SNMP
static final String TAG_EID
static final String TAG_EIDTEXT
static final String TAG_SPECIFIC
static final String TAG_GENERIC
static final String TAG_PARMS
static final String TAG_PARM
static final String TAG_PARM_NAME
static final String TAG_PARM_VALUE
static final String TAG_ENCODING
static final String TAG_ENCODING_ATTR_TEXT
static final String TAG_ENCODING_ATTR_BASE64
static final String TAG_DESCR
static final String TAG_LOGMSG
static final String TAG_LOGMSGDEST
static final String TAG_LOGMSGDEST_ATTR_SUPPRESS
static final String TAG_LOGMSGDEST_ATTR_LOGONLY
static final String TAG_LOGMSGDEST_ATTR_LOGNDISPLAY
static final String TAG_SEVERITY
static final String TAG_OPERINSTR
static final String TAG_AUTOACTION
static final String TAG_OPERACTION
static final String TAG_OPERACTIONMENU
static final String TAG_LOGGROUP
static final String TAG_NOTIFICATION
static final String TAG_TTICKET
static final String TAG_STATE
static final String TAG_STATE_ATTR_ON
static final String TAG_STATE_ATTR_OFF
static final String TAG_FORWARD
static final String TAG_MECHANISM
static final String TAG_MECHANISM_ATTR_SNMPUDP
static final String TAG_MECHANISM_ATTR_SNMPTCP
static final String TAG_MECHANISM_ATTR_XMLUDP
static final String TAG_MECHANISM_ATTR_XMLTCP
static final String TAG_MOUSEOVERTEXT
private static final int SAVE_IGNORE
private static final int SAVE_LOG
private static final int SAVE_HEADER
private static final int SAVE_HDR_VERSION
private static final int SAVE_HDR_DPNAME
private static final int SAVE_HDR_CREATED
private static final int SAVE_HDR_MSTATION
private static final int SAVE_EVENTS
private static final int SAVE_EVENT
private static final int SAVE_UEI
private static final int SAVE_SOURCE
private static final int SAVE_TIME
private static final int SAVE_HOST
private static final int SAVE_SNMPHOST
private static final int SAVE_SNMP
private static final int SAVE_SNMP_EID
private static final int SAVE_SNMP_EIDTEXT
private static final int SAVE_SNMP_SPECIFIC
private static final int SAVE_SNMP_GENERIC
private static final int SAVE_PARMS
private static final int SAVE_PARM
private static final int SAVE_PARM_NAME
private static final int SAVE_PARM_VALUE
private static final int SAVE_DESCR
private static final int SAVE_LOGMSG
private static final int SAVE_SEVERITY
private static final int SAVE_OPERINSTRUCT
private static final int SAVE_AUTOACTION
private static final int SAVE_OPERACTION
private static final int SAVE_LOGGROUP
private static final int SAVE_NOTIFICATION
private static final int SAVE_TTICKET
private static final int SAVE_FORWARD
private static final int SAVE_MOUSEOVERTEXT
private static final int SAVE_NODEID
private static final int SAVE_SERVICE
private static final int SAVE_INTERFACE
private StringBuffer m_data
private int[] m_save
private int m_depth
private EventHeader m_header
private List m_events
private Event m_event
private EventParameter m_parm
private EventSnmpInfo m_snmpInfo
private org.xml.sax.Attributes m_attributes
Constructor Detail |
public XMLEventsParser()
Method Detail |
private int depthOf(int token)
token
- The tag to return depth information from.protected boolean validate(Event e)
Used to validate the event before it is placed onto the actual list of events. If the method returns true then the event is added to the list. If the method returns false then it is not added to the list.
Additionally, the method is able to modify the values contained in the event if necessary, prior to the event being added to the list of events. Care should be used by all derived classes that implement this behavior.
e
- The event to validatestatic void startElement(PrintStream ps, String tag, org.xml.sax.Attributes attrs)
ps
- The output streamtag
- The start tag.attrs
- The attributes, if any.static void endElement(PrintStream ps, String tag)
ps
- The output streamtag
- The closing tag.static void dataElement(PrintStream ps, String tag, org.xml.sax.Attributes attrs, String value)
ps
- The output streamtag
- The start tag.attrs
- The attributes, if any.value
- The value string.public void setDocumentLocator(org.xml.sax.Locator loc)
setDocumentLocator
in interface org.xml.sax.ContentHandler
loc
- The document locator.public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Thrown if an error occurs
processing the start of the document.public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Thrown if an error occurs
validating the document semantics.public void startElement(String uri, String localName, String qName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
uri
- The namespace of the element.localName
- The unqualified name of the element.qName
- The qualified name of the element.attrs
- The attributes for the element.org.xml.sax.SAXException
- Thrown if an error occurs processing
the element.public void endElement(String uri, String localName, String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Thrown if there is an error during parsepublic void characters(char[] data, int offset, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- if there is an error during parsepublic void ignorableWhitespace(char[] data, int offset, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- if there is an error during parsepublic void processingInstruction(String target, String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
target
- The target of the processing instruction.data
- The processing data.org.xml.sax.SAXException
- Thrown if an an error occurs
during processingpublic void skippedEntity(String name) throws org.xml.sax.SAXException
skippedEntity
in interface org.xml.sax.ContentHandler
name
- The name of the skipped entity.org.xml.sax.SAXException
- Thrown if an an error occurs
during processingpublic void startPrefixMapping(String prefix, String uri) throws org.xml.sax.SAXException
startPrefixMapping
in interface org.xml.sax.ContentHandler
prefix
- The prefix.uri
- The namespace mapping.org.xml.sax.SAXException
- Thrown if an an error occurs
during processingpublic void endPrefixMapping(String prefix) throws org.xml.sax.SAXException
endPrefixMapping
in interface org.xml.sax.ContentHandler
prefix
- The prefix that is endingorg.xml.sax.SAXException
- Thrown if an an error occurs
during processingpublic void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
org.xml.sax.SAXException
- if there is an error during parsepublic void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
org.xml.sax.SAXException
- if there is an error during parsepublic void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
org.xml.sax.SAXException
- if there is an error during parsepublic EventHeader getHeader()
public List getEvents()
public static void serializeToXML(OutputStream out, EventHeader hdr, List events)
out
- The output streamhdr
- The header for this documentevents
- The list of events to be written.public static void serializeToXML(PrintStream out, EventHeader hdr, List events)
out
- The output streamhdr
- The header for the documentevents
- The list of events to be written.public static void serializeToXML(OutputStream out, List events)
out
- The output streamevents
- The list of events to be written.public static void serializeToXML(PrintStream out, List events)
out
- The output streamevents
- The list of events to be written.public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |