Package org.ametys.runtime.util
Class MapHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.ametys.runtime.util.MapHandler
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
public class MapHandler extends DefaultHandler
This class is intended to be use as a simple helper to construct Maps from SAX events.
The incoming SAX document must follow this structure :
<root>
<Name1>value1</Name1>
<Name2>value2</Name2>
...
</root>
Each pair Name/Value will be put (as Strings) in the constructed Map
-
-
Field Summary
Fields Modifier and Type Field Description private StringBuffer
_currentString
private int
_level
private Map<String,String>
_map
-
Constructor Summary
Constructors Constructor Description MapHandler(Map<String,String> map)
Create a map handler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
void
endElement(String uri, String localName, String qName)
void
startElement(String uri, String localName, String qName, Attributes attributes)
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
_level
private int _level
-
_currentString
private StringBuffer _currentString
-
-
Constructor Detail
-
MapHandler
public MapHandler(Map<String,String> map)
Create a map handler- Parameters:
map
- Map to fill
-
-
Method Detail
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
-