|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.genesyslab.platform.configuration.protocol.xml.ConfDataSaxHandler
public class ConfDataSaxHandler
SAX event handler for Configuration Data XML transformations.
It parses incoming stream of SAX events and builds collection of configuration objects. Usage sample is following:
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));
Nested Class Summary | |
---|---|
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 Summary | |
---|---|
ConfDataSaxHandler(CfgMetadata metadata)
Constructor of the handler instance. |
Method Summary | |
---|---|
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. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConfDataSaxHandler(CfgMetadata metadata)
metadata
- actual configuration MetaData description.
java.lang.NullPointerException
- if given configuration metadata is nullMethod Detail |
---|
public java.util.Collection<ConfObjectBase> getParsedData()
public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
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 interface org.xml.sax.ContentHandler
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 interface org.xml.sax.ContentHandler
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 interface org.xml.sax.ContentHandler
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 interface org.xml.sax.ContentHandler
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 interface org.xml.sax.ContentHandler
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 interface org.xml.sax.ContentHandler
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)
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |