Platform SDK Java 8.5 API Reference

com.genesyslab.platform.configuration.protocol.xml
Class ConfDataSaxHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.genesyslab.platform.configuration.protocol.xml.ConfDataSaxHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ConfDataSaxHandler
extends org.xml.sax.helpers.DefaultHandler

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

ConfDataSaxHandler

public ConfDataSaxHandler(CfgMetadata metadata)
Constructor of the handler instance.

Parameters:
metadata - actual configuration MetaData description.
Throws:
java.lang.NullPointerException - if given configuration metadata is null
Method Detail

getParsedData

public java.util.Collection<ConfObjectBase> getParsedData()

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Receive notification of the beginning of the document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Receive notification of the end of the document.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endDocument()

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Receive notification of the start of a Namespace mapping.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI mapped to the prefix.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Receive notification of the end of a Namespace mapping.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Parameters:
prefix - The Namespace prefix being declared.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endPrefixMapping(java.lang.String)

startElement

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
Receive notification of the start of an element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
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.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Receive notification of the end of an element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
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.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data inside an element.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.characters(char[], int, int)

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.