|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.xolite.impl.BaseXMLSerializer
public abstract class BaseXMLSerializer
Base for XMLSerializer implementations. This class hold all the complex state of XML serialization (like mapped prefixes, elements currently started, ...). It verify the coherence of the state (like checking that the ended element is the element currently started) and generate simpler serialization events (the abstract methods). Those new events will be implemented by concrete sub-classes.
Field Summary | |
---|---|
protected static int |
STATE_ELEMENT_CLOSED
|
protected static int |
STATE_ELEMENT_START_CLOSED
|
protected static int |
STATE_ELEMENT_START_OPENED
|
protected static int |
STATE_FINISHED
|
protected static int |
STATE_INIT
|
protected static int |
STATE_TEXT
|
protected static int |
STATE_TEXT_MULTI_LINE
|
Constructor Summary | |
---|---|
protected |
BaseXMLSerializer()
|
Method Summary | |
---|---|
void |
attribute(String name,
String value)
Add an attribute to the element that was just started. |
void |
attribute(String uri,
String name,
String value)
Add an attribute to the element that was just started. |
protected abstract void |
attributeImpl(String uri,
String prefix,
String name,
String value,
int index)
|
void |
characters(String text)
Add character content of an element. |
protected abstract void |
charactersImpl(String text,
boolean multilineContent)
|
void |
charactersMultiLine(String text)
Same as characters but the text (supposed to be multi-line) is formatted to be an indented text block. |
protected abstract void |
closeElementStartImpl(boolean complexContent)
|
protected void |
definePrefixMapping(String prefix,
String uri)
|
protected abstract void |
endComplexElementImpl(String uri,
String prefix,
String tag)
|
void |
endDocument()
End the current XML document. |
protected abstract void |
endDocumentImpl()
|
void |
endElement(String uri,
String tag)
End an XML element. |
protected abstract void |
endInlineElementImpl(String uri,
String prefix,
String tag)
|
protected abstract void |
endTextElementImpl(String uri,
String prefix,
String tag,
boolean multilineContent)
|
Object |
getCustomObject(Object key)
Get back any custom object that was put in with the putCustomObject(key, value) method. |
protected int |
getLastElementLength()
Get the tag length (prefix+name) of the last opened level. |
protected String |
getLastElementName()
Get the element name of the last opened level (to be used for debug output only). |
protected int |
getLevel()
|
void |
putCustomObject(Object key,
Object value)
Put a custom object in an internal Map. |
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. |
protected abstract void |
startDocumentImpl()
|
void |
startElement(String uri,
String tag)
Start an XML element. |
protected abstract void |
startElementImpl(String uri,
String prefix,
String tag)
|
void |
startPrefixMapping(String prefix,
String namespaceUri)
Define a prefix mapping. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int STATE_INIT
protected static final int STATE_ELEMENT_START_OPENED
protected static final int STATE_ELEMENT_START_CLOSED
protected static final int STATE_TEXT
protected static final int STATE_TEXT_MULTI_LINE
protected static final int STATE_ELEMENT_CLOSED
protected static final int STATE_FINISHED
Constructor Detail |
---|
protected BaseXMLSerializer()
Method Detail |
---|
protected int getLevel()
public void startDocument() throws XMLSerializeException
XMLSerializer
startDocument
in interface XMLSerializer
XMLSerializeException
public void endDocument() throws XMLSerializeException
XMLSerializer
endDocument
in interface XMLSerializer
XMLSerializeException
protected String getLastElementName()
protected int getLastElementLength()
public void startPrefixMapping(String prefix, String namespaceUri) throws XMLSerializeException
XMLSerializer
This 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 XMLSerializer
prefix
- 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 void startElement(String uri, String tag) throws XMLSerializeException
XMLSerializer
startElement
in interface XMLSerializer
uri
- The element namespace URI (can be null if namespace are not used)tag
- The element local name (a.k.a. NCName)
XMLSerializeException
- if required action cannot be done (implementation dependent).public void attribute(String name, String value) throws XMLSerializeException
XMLSerializer
startElement
call. attribute. This attribute use no namespace.
attribute
in interface XMLSerializer
name
- 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 uri, String name, String value) throws XMLSerializeException
XMLSerializer
startElement
call. attribute
attribute
in interface XMLSerializer
uri
- The attribute namespace URI. This URI is usually null because most of the time, attributes don't use a
namespace.name
- 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
XMLSerializer
startElement
(possibly followed by
attribute
) and endElement
. If this method is called several times for the same element, the
texts are concatenated.
characters
in interface XMLSerializer
text
- 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 XMLSerializer
text
- the text to serialize in XML
XMLSerializeException
ElementText.getMultilineText(String, XMLEventParser)
public void endElement(String uri, String tag) throws XMLSerializeException
XMLSerializer
endElement
in interface XMLSerializer
uri
- The element namespace URI (can be null if namespace are not used)tag
- The element local name (a.k.a. NCName)
XMLSerializeException
- if required action cannot be done (implementation dependent).public void simpleElement(String namespaceUri, String localName, String text) throws XMLSerializeException
XMLSerializer
startElement(namespaceUri, localName); characters(text); endElement(namespaceUri, localName);
simpleElement
in interface XMLSerializer
namespaceUri
- 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
protected abstract void startDocumentImpl() throws Exception
Exception
protected abstract void endDocumentImpl() throws Exception
Exception
protected abstract void startElementImpl(String uri, String prefix, String tag) throws Exception
Exception
protected abstract void attributeImpl(String uri, String prefix, String name, String value, int index) throws Exception
Exception
protected abstract void closeElementStartImpl(boolean complexContent) throws Exception
Exception
protected abstract void charactersImpl(String text, boolean multilineContent) throws Exception
Exception
protected abstract void endInlineElementImpl(String uri, String prefix, String tag) throws Exception
Exception
protected abstract void endTextElementImpl(String uri, String prefix, String tag, boolean multilineContent) throws Exception
Exception
protected abstract void endComplexElementImpl(String uri, String prefix, String tag) throws Exception
Exception
protected void definePrefixMapping(String prefix, String uri) throws Exception
Exception
public Object getCustomObject(Object key)
XMLSerializer
putCustomObject(key, value)
method.
getCustomObject
in interface XMLSerializer
key
- key of the custom object.
public void putCustomObject(Object key, Object value)
XMLSerializer
getCustomObject(key)
method.
putCustomObject
in interface XMLSerializer
key
- key of the custom object.value
- custom object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |