|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.xolite.sax.SaxXMLSerializer
public class SaxXMLSerializer
XMLSerializer passing all the serialization events to a SAX ContentHandler.
| Constructor Summary | |
|---|---|
SaxXMLSerializer()
|
|
SaxXMLSerializer(ContentHandler theHandler)
|
|
| Method Summary | |
|---|---|
void |
attribute(String localName,
String value)
Add an attribute to the element that was just started. |
void |
attribute(String namespaceUri,
String localName,
String value)
Add an attribute to the element that was just started. |
void |
characters(String text)
Add character content of an element. |
void |
charactersMultiLine(String text)
Same as characters but the text (supposed to be multi-line) is formatted to be an indented text block. |
void |
endDocument()
End the current XML document. |
void |
endElement(String namespaceUri,
String localName)
End an XML element. |
ContentHandler |
getContentHandler()
|
Object |
getCustomObject(Object key)
Get back any custom object that was put in with the putCustomObject(key, value) method. |
void |
putCustomObject(Object key,
Object value)
Put a custom object in an internal Map. |
void |
serialize(XMLSerializable root)
|
void |
setContentHandler(ContentHandler theHandler)
|
void |
simpleElement(String namespaceUri,
String localName,
String text)
This is a helper method useful to add a simpleType element in one call. |
void |
startDocument()
Start an XML document. |
void |
startElement(String namespaceUri,
String localName)
Start an XML element. |
void |
startPrefixMapping(String prefix,
String namespaceUri)
Define a prefix mapping. |
static boolean |
stringEquals(Object obj1,
Object obj2)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SaxXMLSerializer()
public SaxXMLSerializer(ContentHandler theHandler)
| Method Detail |
|---|
public void setContentHandler(ContentHandler theHandler)
public ContentHandler getContentHandler()
public void serialize(XMLSerializable root)
throws XMLSerializeException
XMLSerializeException
public void startDocument()
throws XMLSerializeException
XMLSerializer
startDocument in interface XMLSerializerXMLSerializeException
public void startElement(String namespaceUri,
String localName)
throws XMLSerializeException
XMLSerializer
startElement in interface XMLSerializernamespaceUri - The element namespace URI (can be null if namespace are not used)localName - The element local name (a.k.a. NCName)
XMLSerializeException - if required action cannot be done (implementation dependent).
public void attribute(String localName,
String value)
throws XMLSerializeException
XMLSerializerstartElement call. attribute. This attribute use no namespace.
attribute in interface XMLSerializerlocalName - The attribute local name (a.k.a. NCName)value - the attribute value (null is treated as empty string).
XMLSerializeException - if you don't call this method just after startElement or if required action cannot be done
(implementation dependent).
public void attribute(String namespaceUri,
String localName,
String value)
throws XMLSerializeException
XMLSerializerstartElement call. attribute
attribute in interface XMLSerializernamespaceUri - The attribute namespace URI. This URI is usually null because most of the time, attributes don't use a
namespace.localName - The attribute local name (a.k.a. NCName)value - the attribute value (null is treated as empty string).
XMLSerializeException - if you don't call this method just after startElement or if required action cannot be done
(implementation dependent).
public void characters(String text)
throws XMLSerializeException
XMLSerializerstartElement (possibly followed by
attribute) and endElement. If this method is called several times for the same element, the
texts are concatenated.
characters in interface XMLSerializertext - text of the currently started element.
XMLSerializeException - if you don't call this method just beteween startElement and endElement or if
required action cannot be done (implementation dependent).
public void charactersMultiLine(String text)
throws XMLSerializeException
XMLSerializer
<tag>
some text
spanning multiple
lines.
</tag>
While usual output would have given:
<tag>some text
spanning multiple
lines.</tag>
The original text can be retrieved (when parsing) with the ElementText.getMultilineText(..) method. This
method will automatically remove the added space.
charactersMultiLine in interface XMLSerializertext - the text to serialize in XML
XMLSerializeExceptionElementText.getMultilineText(String, XMLEventParser)
public void endElement(String namespaceUri,
String localName)
throws XMLSerializeException
XMLSerializer
endElement in interface XMLSerializernamespaceUri - The element namespace URI (can be null if namespace are not used)localName - The element local name (a.k.a. NCName)
XMLSerializeException - if required action cannot be done (implementation dependent).
public void endDocument()
throws XMLSerializeException
XMLSerializer
endDocument in interface XMLSerializerXMLSerializeExceptionpublic Object getCustomObject(Object key)
XMLSerializerputCustomObject(key, value) method.
getCustomObject in interface XMLSerializerkey - key of the custom object.
public void putCustomObject(Object key,
Object value)
XMLSerializergetCustomObject(key) method.
putCustomObject in interface XMLSerializerkey - key of the custom object.value - custom object.
public void simpleElement(String namespaceUri,
String localName,
String text)
throws XMLSerializeException
XMLSerializerstartElement(namespaceUri, localName); characters(text); endElement(namespaceUri, localName);
simpleElement in interface XMLSerializernamespaceUri - The element namespace URI (can be null if namespace are not used)localName - The element local name (a.k.a. NCName)text - text of the element.
XMLSerializeException
public void startPrefixMapping(String prefix,
String namespaceUri)
throws XMLSerializeException
XMLSerializerThis method should be called for each namespace URI before the first time they are used.
If the given namespace is already associated to another prefix (or the same prefix), this method call is ignored (i.e. first association wins).
If the given prefix is already associated to an other namespace, a new prefix is generated and mapped at the place of the given one.
startPrefixMapping in interface XMLSerializerprefix - a prefix (can be "" for default prefix mapping)namespaceUri - a namespace URI
XMLSerializeException - if prefix or namespaceUri is null or if required action cannot be done (implementation dependent).
public static boolean stringEquals(Object obj1,
Object obj2)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||