|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.xml.bind.v2.runtime.Coordinator
com.sun.xml.bind.v2.runtime.XMLSerializer
public final class XMLSerializer
Receives XML serialization event and writes to XmlOutput
.
This object coordinates the overall marshalling efforts across different content-tree objects and different target formats.
The following CFG gives the proper sequence of method invocation.
MARSHALLING := ELEMENT ELEMENT := "startElement" NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODY "endElement" NSDECL := "declareNamespace" ATTRIBUTE := "attribute" ATTVALUES := "text"* BODY := ( "text" | ELEMENT )*
A marshalling of one element consists of two stages. The first stage is for marshalling attributes and collecting namespace declarations. The second stage is for marshalling characters/child elements of that element.
Observe that multiple invocation of "text" is allowed.
Also observe that the namespace declarations are allowed only between "startElement" and "endAttributes".
IOException
, SAXException
, and XMLStreamException
are thrown from XmlOutput
. They are always considered fatal, and
therefore caught only by MarshallerImpl
.
AccessorException
can be thrown when an access to a property/field
fails, and this is considered as a recoverable error, so it's caught everywhere.
Field Summary | |
---|---|
AttachmentMarshaller |
attachmentMarshaller
|
JAXBContextImpl |
grammar
|
int[] |
knownUri2prefixIndexMap
|
NameList |
nameList
|
Fields inherited from class com.sun.xml.bind.v2.runtime.Coordinator |
---|
debugTableNPE, guyWhoSetTheTableToNull |
Method Summary | ||
---|---|---|
void |
addInscopeBinding(String nsUri,
String prefix)
This method can be called after startDocument(com.sun.xml.bind.v2.runtime.output.XmlOutput, boolean, java.lang.String, java.lang.String) is called
but before the marshalling begins, to set the currently in-scope namespace
bindings. |
|
void |
attribute(Name name,
CharSequence value)
|
|
void |
attribute(String uri,
String local,
String value)
|
|
void |
attWildcardAsAttributes(Map<QName,String> attributes,
String fieldName)
|
|
void |
attWildcardAsURIs(Map<QName,String> attributes,
String fieldName)
|
|
void |
childAsRoot(Object obj)
|
|
void |
childAsSoleContent(Object child,
String fieldName)
The equivalent of: |
|
void |
childAsXsiType(Object child,
String fieldName,
JaxBeanInfo expected,
boolean nillable)
This method is called when a type child object is found. |
|
void |
clearCurrentProperty()
Takes care of cleaning the currentProperty. |
|
void |
close()
|
|
void |
endAttributes()
Switches to the "marshal child texts/elements" mode. |
|
void |
endDocument()
|
|
void |
endElement()
Ends marshalling of an element. |
|
void |
endNamespaceDecls(Object innerPeer)
|
|
void |
errorMissingId(Object obj)
Called when a referenced object doesn't have an ID. |
|
Base64Data |
getCachedBase64DataInstance()
Deprecated. Base64Data is no longer cached, so that
XMLStreamWriterEx impl can retain the data, like JAX-WS does. |
|
ValidationEventLocator |
getCurrentLocation(String fieldName)
|
|
Property |
getCurrentProperty()
May return null when the property hasn't been set. |
|
Transformer |
getIdentityTransformer()
|
|
boolean |
getInlineBinaryFlag()
|
|
static XMLSerializer |
getInstance()
When called from within the realm of the marshaller, this method returns the current XMLSerializer in charge. |
|
protected ValidationEventLocator |
getLocation()
Gets the current location. |
|
NamespaceContext2 |
getNamespaceContext()
|
|
boolean |
getObjectIdentityCycleDetection()
|
|
QName |
getSchemaType()
|
|
String |
getXMIMEContentType()
Gets the MIME type with which the binary content shall be printed. |
|
boolean |
handleError(Exception e)
|
|
boolean |
handleError(Exception e,
Object source,
String fieldName)
|
|
boolean |
handleEvent(ValidationEvent event)
|
|
void |
leafElement(Name tagName,
int data,
String fieldName)
|
|
void |
leafElement(Name tagName,
Pcdata data,
String fieldName)
|
|
void |
leafElement(Name tagName,
String data,
String fieldName)
|
|
String |
onID(Object owner,
String value)
|
|
String |
onIDREF(Object obj)
|
|
void |
reportError(String fieldName,
Throwable t)
Report an error found as an exception. |
|
void |
reportError(ValidationEvent ve)
|
|
javax.activation.MimeType |
setExpectedMimeType(javax.activation.MimeType expectedMimeType)
This method is used by MimeTypedTransducer to set the expected MIME type
for the encapsulated Transducer . |
|
boolean |
setInlineBinaryFlag(boolean value)
|
|
void |
setObjectIdentityCycleDetection(boolean val)
|
|
void |
setPrefixMapper(NamespacePrefixMapper prefixMapper)
|
|
QName |
setSchemaType(QName st)
|
|
void |
startDocument(XmlOutput out,
boolean fragment,
String schemaLocation,
String noNsSchemaLocation)
Reset this object to write to the specified output. |
|
void |
startElement(Name tagName,
Object outerPeer)
|
|
void |
startElement(String nsUri,
String localName,
String preferredPrefix,
Object outerPeer)
|
|
void |
startElementForce(String nsUri,
String localName,
String forcedPrefix,
Object outerPeer)
Variation of startElement(String, String, String, Object) that forces
a specific prefix. |
|
void |
text(Pcdata text,
String fieldName)
The text(String, String) method that takes Pcdata . |
|
void |
text(String text,
String fieldName)
Marshalls text. |
|
|
writeDom(E element,
DomHandler<E,?> domHandler,
Object parentBean,
String fieldName)
|
|
void |
writeXsiNilTrue()
Short for the following call sequence: |
Methods inherited from class com.sun.xml.bind.v2.runtime.Coordinator |
---|
_getInstance, containsAdapter, error, fatalError, getAdapter, popCoordinator, pushCoordinator, putAdapter, resetThreadAffinity, setThreadAffinity, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final JAXBContextImpl grammar
public final NameList nameList
public final int[] knownUri2prefixIndexMap
public AttachmentMarshaller attachmentMarshaller
Method Detail |
---|
public Base64Data getCachedBase64DataInstance()
Base64Data
is no longer cached, so that
XMLStreamWriterEx impl can retain the data, like JAX-WS does.
Base64Data
.
public void reportError(ValidationEvent ve) throws SAXException
SAXException
public final void reportError(String fieldName, Throwable t) throws SAXException
fieldName
- the name of the property being processed when an error is found.
SAXException
public void startElement(Name tagName, Object outerPeer)
public void startElement(String nsUri, String localName, String preferredPrefix, Object outerPeer)
public void startElementForce(String nsUri, String localName, String forcedPrefix, Object outerPeer)
startElement(String, String, String, Object)
that forces
a specific prefix. Needed to preserve the prefix when marshalling DOM.
public void endNamespaceDecls(Object innerPeer) throws IOException, javax.xml.stream.XMLStreamException
IOException
javax.xml.stream.XMLStreamException
public void endAttributes() throws SAXException, IOException, javax.xml.stream.XMLStreamException
SAXException
IOException
javax.xml.stream.XMLStreamException
public void endElement() throws SAXException, IOException, javax.xml.stream.XMLStreamException
SAXException
IOException
javax.xml.stream.XMLStreamException
public void leafElement(Name tagName, String data, String fieldName) throws SAXException, IOException, javax.xml.stream.XMLStreamException
SAXException
IOException
javax.xml.stream.XMLStreamException
public void leafElement(Name tagName, Pcdata data, String fieldName) throws SAXException, IOException, javax.xml.stream.XMLStreamException
SAXException
IOException
javax.xml.stream.XMLStreamException
public void leafElement(Name tagName, int data, String fieldName) throws SAXException, IOException, javax.xml.stream.XMLStreamException
SAXException
IOException
javax.xml.stream.XMLStreamException
public void text(String text, String fieldName) throws SAXException, IOException, javax.xml.stream.XMLStreamException
This method can be called after the endAttributes()
method to marshal texts inside elements.
If the method is called more than once, those texts are considered
as separated by whitespaces. For example,
c.startElement("","foo"); c.endAttributes(); c.text("abc"); c.text("def"); c.startElement("","bar"); c.endAttributes(); c.endElement(); c.text("ghi"); c.endElement();will generate
<foo>abc def<bar/>ghi</foo>
.
SAXException
IOException
javax.xml.stream.XMLStreamException
public void text(Pcdata text, String fieldName) throws SAXException, IOException, javax.xml.stream.XMLStreamException
text(String, String)
method that takes Pcdata
.
SAXException
IOException
javax.xml.stream.XMLStreamException
public void attribute(String uri, String local, String value) throws SAXException
SAXException
public void attribute(Name name, CharSequence value) throws IOException, javax.xml.stream.XMLStreamException
IOException
javax.xml.stream.XMLStreamException
public NamespaceContext2 getNamespaceContext()
public String onID(Object owner, String value)
public String onIDREF(Object obj) throws SAXException
SAXException
public void childAsRoot(Object obj) throws JAXBException, IOException, SAXException, javax.xml.stream.XMLStreamException
JAXBException
IOException
SAXException
javax.xml.stream.XMLStreamException
public final void childAsSoleContent(Object child, String fieldName) throws SAXException, IOException, javax.xml.stream.XMLStreamException
childAsURIs(child, fieldName); endNamespaceDecls(); childAsAttributes(child, fieldName); endAttributes(); childAsBody(child, fieldName);This produces the given child object as the sole content of an element. Used to reduce the code size in the generated marshaller.
SAXException
IOException
javax.xml.stream.XMLStreamException
public final void childAsXsiType(Object child, String fieldName, JaxBeanInfo expected, boolean nillable) throws SAXException, IOException, javax.xml.stream.XMLStreamException
This method produces events of the following form:
NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODYoptionally including @xsi:type if necessary.
child
- Object to be marshalled. The JaxBeanInfo
for
this object must return a type name.expected
- Expected type of the object.fieldName
- property name of the parent objeect from which 'o' comes.
Used as a part of the error message in case anything goes wrong
with 'o'.
SAXException
IOException
javax.xml.stream.XMLStreamException
public void attWildcardAsURIs(Map<QName,String> attributes, String fieldName)
public void attWildcardAsAttributes(Map<QName,String> attributes, String fieldName) throws SAXException
SAXException
public final void writeXsiNilTrue() throws SAXException, IOException, javax.xml.stream.XMLStreamException
getNamespaceContext().declareNamespace(WellKnownNamespace.XML_SCHEMA_INSTANCE,"xsi",true); endNamespaceDecls(); attribute(WellKnownNamespace.XML_SCHEMA_INSTANCE,"nil","true"); endAttributes();
SAXException
IOException
javax.xml.stream.XMLStreamException
public <E> void writeDom(E element, DomHandler<E,?> domHandler, Object parentBean, String fieldName) throws SAXException
SAXException
public Transformer getIdentityTransformer()
public void setPrefixMapper(NamespacePrefixMapper prefixMapper)
public void startDocument(XmlOutput out, boolean fragment, String schemaLocation, String noNsSchemaLocation) throws IOException, SAXException, javax.xml.stream.XMLStreamException
schemaLocation
- if non-null, this value is printed on the root element as xsi:schemaLocationnoNsSchemaLocation
- Similar to 'schemaLocation' but this one works for xsi:noNamespaceSchemaLocation
IOException
SAXException
javax.xml.stream.XMLStreamException
public void endDocument() throws IOException, SAXException, javax.xml.stream.XMLStreamException
IOException
SAXException
javax.xml.stream.XMLStreamException
public void close()
public void addInscopeBinding(String nsUri, String prefix)
startDocument(com.sun.xml.bind.v2.runtime.output.XmlOutput, boolean, java.lang.String, java.lang.String)
is called
but before the marshalling begins, to set the currently in-scope namespace
bindings.
This method is useful to avoid redundant namespace declarations when the marshalling is producing a sub-document.
public String getXMIMEContentType()
This method shall be used from those RuntimeBuiltinLeafInfo
that are
bound to base64Binary.
JAXBContextImpl.getXMIMEContentType(Object)
public javax.activation.MimeType setExpectedMimeType(javax.activation.MimeType expectedMimeType)
MimeTypedTransducer
to set the expected MIME type
for the encapsulated Transducer
.
public boolean setInlineBinaryFlag(boolean value)
public boolean getInlineBinaryFlag()
public QName setSchemaType(QName st)
public QName getSchemaType()
public void setObjectIdentityCycleDetection(boolean val)
public boolean getObjectIdentityCycleDetection()
public boolean handleError(Exception e)
public boolean handleError(Exception e, Object source, String fieldName)
public boolean handleEvent(ValidationEvent event)
public void errorMissingId(Object obj) throws SAXException
SAXException
public ValidationEventLocator getCurrentLocation(String fieldName)
protected ValidationEventLocator getLocation()
Coordinator
getLocation
in class Coordinator
public Property getCurrentProperty()
public void clearCurrentProperty()
public static XMLSerializer getInstance()
XMLSerializer
in charge.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |