public class ConfDataSaxHandler
extends org.xml.sax.helpers.DefaultHandler
String strXml = getSampleAppXmlString();
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
ConfDataSaxHandler handler = new ConfDataSaxHandler(metadata);
saxParser.parse(new ByteArrayInputStream(strXml.getBytes()), handler);
ConfDataCollection<?> objects = (ConfDataCollection<?>) handler.getParsedData();
System.out.println("OBJECTS: " + objects.toString(false, false));
Or using Transformer:
Document doc = <get-ConfData-doc-somewhere>;
ConfDataSaxHandler handler = new ConfDataSaxHandler(metadata);
XmlFactories.newTransformer().transform(new DOMSource(doc), new SAXResult(handler));
ConfDataCollection<?> objects = (ConfDataCollection<?>) handler.getParsedData();
System.out.println("OBJECT: " + objects.toString(false, false));
Modifier and Type | Class | Description |
---|---|---|
protected class |
ConfDataSaxHandler.ElementHandler |
Base class for custom internal handlers of specific configuration data structures.
|
protected class |
ConfDataSaxHandler.ElementHandlerClass |
|
protected class |
ConfDataSaxHandler.ElementHandlerIntegerList |
|
protected class |
ConfDataSaxHandler.ElementHandlerKVList |
|
protected class |
ConfDataSaxHandler.ElementHandlerObjCollection |
|
protected class |
ConfDataSaxHandler.ElementHandlerStringList |
|
protected class |
ConfDataSaxHandler.ElementHandlerStructCollection |
Constructor | Description |
---|---|
ConfDataSaxHandler(CfgMetadata metadata) |
Constructor of the handler instance.
|
Modifier and Type | Method | Description |
---|---|---|
void |
characters(char[] ch,
int start,
int length) |
Receive notification of character data inside an element.
|
void |
endDocument() |
Receive notification of the end of the document.
|
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName) |
Receive notification of the end of an element.
|
void |
endPrefixMapping(java.lang.String prefix) |
Receive notification of the end of a Namespace mapping.
|
java.util.Collection<ConfObjectBase> |
getParsedData() |
|
void |
startDocument() |
Receive notification of the beginning of the document.
|
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes) |
Receive notification of the start of an element.
|
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri) |
Receive notification of the start of a Namespace mapping.
|
public ConfDataSaxHandler(CfgMetadata metadata)
metadata
- actual configuration MetaData description.java.lang.NullPointerException
- if given configuration metadata is nullpublic java.util.Collection<ConfObjectBase> getParsedData()
public void startDocument() throws org.xml.sax.SAXException
startDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startDocument()
public void endDocument() throws org.xml.sax.SAXException
endDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endDocument()
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
startPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
prefix
- The Namespace prefix being declared.uri
- The Namespace URI mapped to the prefix.org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
endPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
prefix
- The Namespace prefix being declared.org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endPrefixMapping(java.lang.String)
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
startElement
in class org.xml.sax.helpers.DefaultHandler
uri
- The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed.localName
- The local name (without prefix), or the
empty string if Namespace processing is not being
performed.qName
- The qualified name (with prefix), or the
empty string if qualified names are not available.attributes
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in class org.xml.sax.helpers.DefaultHandler
uri
- The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed.localName
- The local name (without prefix), or the
empty string if Namespace processing is not being
performed.qName
- The qualified name (with prefix), or the
empty string if qualified names are not available.org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in class org.xml.sax.helpers.DefaultHandler
ch
- The characters.start
- The start position in the character array.length
- The number of characters to use from the
character array.org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.characters(char[], int, int)
Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 9.0.006.00
Copyright © 2006–2019 Genesys Telecommunications Laboratories, Inc. All rights reserved.