Package org.bitlet.weupnp
Class NameValueHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.bitlet.weupnp.NameValueHandler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
public class NameValueHandler extends org.xml.sax.helpers.DefaultHandlerA simple SAX handler that is used to parse XML name value pairs in the form <name>value</name>- See Also:
DefaultHandler
-
-
Constructor Summary
Constructors Constructor Description NameValueHandler(java.util.Map<java.lang.String,java.lang.String> nameValue)Creates a new instance of a NameValueHandler, storing values in the supplied map
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Receive notification of character data inside an element.voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)Receive notification of the end of an element.voidstartElement(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.
-
-
-
Method Detail
-
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.SAXExceptionReceive notification of the start of an element. Caches the element ascurrentElement, so that it will be stored as a map key when the corresponding value will be read.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.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.SAXExceptionReceive notification of the end of an element. It is used to reset currentElement when the XML node is closed. Note: this works only when the data we are interested in does not contain child nodes. Based on a patch provided by christophercyll and attached to issue #4: http://code.google.com/p/weupnp/issues/detail?id=4- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.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.
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionReceive notification of character data inside an element. Stores the characters as value, usingcurrentElementas a key- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.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)
-
-