|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--com.ls.util.xml.XMLHandler
Creates XML documents from a Map or to parse a XML document into a Map
| Field Summary | |
protected StringBuffer |
elementValue
the value of an element |
| Constructor Summary | |
XMLHandler()
creates a Parser instance and sets its handler to this object |
|
| Method Summary | |
String |
buildString(String documentType,
Map xmlHash)
creates a XML document from a map |
void |
characters(char[] ch,
int start,
int length)
Any character within an element node will be interpreted as the value of this element node. |
protected Map |
createElementHash()
Creates a map. |
com.sun.xml.tree.XmlDocument |
createXMLdocument(String documentType,
Map xmlHash)
creates a XML document from a map |
void |
endDocument()
If the document is finished there should be only one map left in the list. |
void |
endElement(String elementName)
If the Parser receives the end tag of an element, he will remove it from the list of stuff to parse. |
ReferenceIdentityHashtable |
getAttributes()
returns the list of attributes (which was generated while parsing) |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
empty implementation: method is not needed for the parsing of XML streams but belongs to the interface DocumentHandler |
Map |
parse(org.xml.sax.InputSource xmlSource)
Parses a XML structure as read from the given InputSource and
returns a map view on it. |
Map |
parse(Reader reader)
Parses a XML structure as read from the given Reader and
returns a map view on it. |
Map |
parse(String xmlString)
Parses a XML structure as read from the given String and returns a map view on it. |
void |
processingInstruction(String target,
String data)
empty implementation: method is not needed for the parsing of XML streams but belongs to the interface DocumentHandler |
void |
setDocumentLocator(org.xml.sax.Locator locator)
empty implementation: method is not needed for the parsing of XML streams but belongs to the interface DocumentHandler |
void |
startDocument()
receives notification of the beginning of a document and creates a new list to store the element nodes |
void |
startElement(String elementName,
org.xml.sax.AttributeList attributeList)
If the Parser receives the start tag of an element, a new map will be added to the list, containing the attributes of this element node. |
void |
write(Writer writer,
String documentType,
Map xmlHash)
creates a XML document from a map and writes it to the specified Writer |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected StringBuffer elementValue
| Constructor Detail |
public XMLHandler()
| Method Detail |
public ReferenceIdentityHashtable getAttributes()
protected Map createElementHash()
HashMap in this implementation)
public com.sun.xml.tree.XmlDocument createXMLdocument(String documentType,
Map xmlHash)
documentType - specifies the document type (for example: MESSAGE or CONFIG)xmlHash - XML data stored in a map
public String buildString(String documentType,
Map xmlHash)
throws XMLException
xmlHash - XML data stored in a hash (keys will become tag names, values the tag values)documentType - specifies the document type (for example: "MESSAGE" or "CONTENT")XMLException - If the conversion to XML fails
public void write(Writer writer,
String documentType,
Map xmlHash)
throws XMLException
writer - Writer to wich the built XML string should be writtendocumentType - specifies the document type (message type)xmlHash - XML data stored in a hashXMLException - If the XML string was not successfully written to the writer
public Map parse(org.xml.sax.InputSource xmlSource)
throws XMLException,
IllegalArgumentException,
ProgrammingException
InputSource and
returns a map view on it.parse in interface IXMLHandlerxmlSource - the source from where to get the XML structureMapXMLException - If the parsing process failsIllegalArgumentException - If the given XML input source is nullProgrammingException - If this.xmlParser is null
public Map parse(Reader reader)
throws XMLException,
IllegalArgumentException,
ProgrammingException
Reader and
returns a map view on it.parse in interface IXMLHandlerreader - the source from where to get the XML structureMapXMLException - If the parsing process failsIllegalArgumentException - If the given reader is nullProgrammingException - If this.xmlParser is null
public Map parse(String xmlString)
throws XMLException,
IllegalArgumentException,
ProgrammingException
parse in interface IXMLHandlerxmlString - the source from where to get the XML structureMapXMLException - If the parsing process failsIllegalArgumentException - If the given XML string is nullProgrammingException - If this.xmlParser is null
public void startElement(String elementName,
org.xml.sax.AttributeList attributeList)
throws ProgrammingException
startElement in interface org.xml.sax.DocumentHandlerelementName - element type nameattributeList - NOT USED (according to interface: attributes attached to the element, if any)ProgrammingException - If this.xmlList is null
public void characters(char[] ch,
int start,
int length)
characters in interface org.xml.sax.DocumentHandlerch - characters from the XML documentstart - start position in the arraylength - number of characters to read from the arraypublic void endElement(String elementName)
endElement in interface org.xml.sax.DocumentHandlerelementName - element type namepublic void startDocument()
startDocument in interface org.xml.sax.DocumentHandlerpublic void endDocument()
endDocument in interface org.xml.sax.DocumentHandler
public void ignorableWhitespace(char[] ch,
int start,
int length)
ignorableWhitespace in interface org.xml.sax.DocumentHandlerch - char[] containing the whitespace charactersstart - starting point of the array from where to identify whitespace characterslength - number of characters specifying the whitespace
public void processingInstruction(String target,
String data)
processingInstruction in interface org.xml.sax.DocumentHandlertarget - the target for calling a processing instructiondata - a string representing the datapublic void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator in interface org.xml.sax.DocumentHandlerlocator - object that can return the location of any SAX document event
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||