public class SerializationContext extends Object implements SerializationContext
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log |
protected boolean |
startOfDocument
The flag whether the XML decl should be written
|
Constructor and Description |
---|
SerializationContext(Writer writer)
Construct SerializationContext with associated writer
|
SerializationContext(Writer writer,
MessageContext msgContext)
Construct SerializationContext with associated writer and MessageContext
|
Modifier and Type | Method and Description |
---|---|
String |
attributeQName2String(QName qName)
Convert attribute QName to a string of the form
|
void |
endElement()
Writes the end element tag for the open element.
|
Message |
getCurrentMessage()
Return the current message
|
QName |
getCurrentXMLType()
Get the currently prefered xmlType
|
boolean |
getDoMultiRefs()
Are we doing multirefs?
|
XMLEncoder |
getEncoder() |
String |
getEncoding()
get the encoding for the serialization
|
String |
getEncodingStyle()
Returns this context's encoding style.
|
QName |
getItemQName() |
QName |
getItemType() |
MessageContext |
getMessageContext()
Get the MessageContext we're operating with
|
String |
getPrefixForURI(String uri)
Get a prefix for a namespace URI.
|
String |
getPrefixForURI(String uri,
String defaultPrefix)
Get a prefix for the given namespace URI.
|
String |
getPrefixForURI(String uri,
String defaultPrefix,
boolean attribute)
Get a prefix for the given namespace URI.
|
boolean |
getPretty()
Get whether the serialization should be pretty printed.
|
QName |
getQNameForClass(Class cls)
Get the QName associated with the specified class.
|
Serializer |
getSerializerForJavaType(Class javaType)
Convenience method to get the Serializer for a specific
java type
|
TypeMapping |
getTypeMapping()
Get the TypeMapping we're using.
|
TypeMappingRegistry |
getTypeMappingRegistry()
Get the TypeMappingRegistry we're using.
|
String |
getValueAsString(Object value,
QName xmlType,
Class javaClass) |
boolean |
isEncoded()
Returns whether this context should be encoded or not.
|
boolean |
isPrimitive(Object value)
Indicates whether the object should be interpretted as a primitive
for the purposes of multi-ref processing.
|
void |
outputMultiRefs()
The serialize method uses hrefs to reference all non-primitive
values.
|
String |
qName2String(QName qName) |
String |
qName2String(QName qName,
boolean writeNS)
Convert QName to a string of the form
|
void |
registerPrefixForURI(String prefix,
String uri)
Register prefix for the indicated uri
|
void |
serialize(QName elemQName,
Attributes attributes,
Object value)
Serialize the indicated value as an element with the name
indicated by elemQName.
|
void |
serialize(QName elemQName,
Attributes attributes,
Object value,
QName xmlType)
Deprecated.
use serialize(QName, Attributes, Object, QName, Class) instead
|
void |
serialize(QName elemQName,
Attributes attributes,
Object value,
QName xmlType,
boolean sendNull,
Boolean sendType)
Deprecated.
use serialize(QName, Attributes, Object, QName,
Boolean, Boolean) instead.
|
void |
serialize(QName elemQName,
Attributes attributes,
Object value,
QName xmlType,
Boolean sendNull,
Boolean sendType)
Serialize the indicated value as an element with the name
indicated by elemQName.
|
void |
serialize(QName elemQName,
Attributes attributes,
Object value,
QName xmlType,
Class javaType)
Serialize the indicated value as an element with the name
indicated by elemQName.
|
void |
serialize(QName elemQName,
Attributes attributes,
Object value,
QName xmlType,
Class javaClass,
Boolean sendNull,
Boolean sendType)
Serialize the indicated value as an element with the name
indicated by elemQName.
|
void |
setDoMultiRefs(boolean shouldDo)
Set whether we are doing multirefs
|
void |
setEncoding(String encoding)
set the encoding for the serialization
|
void |
setItemQName(QName itemQName) |
void |
setItemType(QName itemType) |
void |
setPretty(boolean pretty)
Indicate whether the serialization should be pretty printed.
|
void |
setSendDecl(boolean sendDecl)
Set whether or not we should write XML declarations.
|
Attributes |
setTypeAttribute(Attributes attributes,
QName type)
Obtains the type attribute that should be serialized and returns the new list of Attributes
|
void |
setWriteXMLType(QName type) |
boolean |
shouldSendXSIType()
Get whether or not to write xsi:type attributes.
|
void |
startElement(QName qName,
Attributes attributes)
Writes (using the Writer) the start tag for element QName along with the
indicated attributes and namespace mappings.
|
void |
writeChars(char[] p1,
int p2,
int p3)
Convenience operation to write out (to Writer) the characters
in p1 starting at index p2 for length p3.
|
void |
writeDOMElement(Element el)
Output a DOM representation to a SerializationContext
|
void |
writeSafeString(String string)
Convenience operation to write out (to Writer) the String
properly encoded with xml entities (like &)
|
void |
writeString(String string)
Convenience operation to write out (to Writer) the String
|
void |
writeXMLDeclaration() |
protected static org.apache.commons.logging.Log log
protected boolean startOfDocument
public SerializationContext(Writer writer)
writer
- java.io.Writerpublic SerializationContext(Writer writer, MessageContext msgContext)
writer
- java.io.WritermsgContext
- is the MessageContextpublic boolean getPretty()
public void setPretty(boolean pretty)
pretty
- true/falsepublic boolean getDoMultiRefs()
public void setDoMultiRefs(boolean shouldDo)
public void setSendDecl(boolean sendDecl)
sendDecl
- true/falsepublic boolean shouldSendXSIType()
public TypeMapping getTypeMapping()
public TypeMappingRegistry getTypeMappingRegistry()
public String getPrefixForURI(String uri)
uri
- is the namespace uripublic String getPrefixForURI(String uri, String defaultPrefix)
public String getPrefixForURI(String uri, String defaultPrefix, boolean attribute)
public void registerPrefixForURI(String prefix, String uri)
prefix
- uri
- is the namespace uripublic Message getCurrentMessage()
public MessageContext getMessageContext()
public String getEncodingStyle()
String
valuepublic boolean isEncoded()
boolean
valuepublic String qName2String(QName qName, boolean writeNS)
qName
- public String attributeQName2String(QName qName)
qName
- QNamepublic QName getQNameForClass(Class cls)
cls
- Class of an object requiring serialization.public boolean isPrimitive(Object value)
value
- to be serializedpublic void serialize(QName elemQName, Attributes attributes, Object value) throws IOException
elemQName
- is the QName of the elementattributes
- are additional attributesvalue
- is the object to serializeIOException
public void serialize(QName elemQName, Attributes attributes, Object value, QName xmlType) throws IOException
elemQName
- is the QName of the elementattributes
- are additional attributesvalue
- is the object to serializexmlType
- is the qname of the type or null.IOException
public void serialize(QName elemQName, Attributes attributes, Object value, QName xmlType, Class javaType) throws IOException
elemQName
- is the QName of the elementattributes
- are additional attributesvalue
- is the object to serializexmlType
- is the qname of the type or null.javaType
- is the java type of the valueIOException
public void serialize(QName elemQName, Attributes attributes, Object value, QName xmlType, boolean sendNull, Boolean sendType) throws IOException
elemQName
- is the QName of the elementattributes
- are additional attributesvalue
- is the object to serializexmlType
- is the qname of the type or null.sendNull
- determines whether to send null values.sendType
- determines whether to set xsi:type attribute.IOException
public void serialize(QName elemQName, Attributes attributes, Object value, QName xmlType, Boolean sendNull, Boolean sendType) throws IOException
elemQName
- is the QName of the elementattributes
- are additional attributesvalue
- is the object to serializexmlType
- is the qname of the type or null.sendNull
- determines whether to send null values.sendType
- determines whether to set xsi:type attribute.IOException
public void serialize(QName elemQName, Attributes attributes, Object value, QName xmlType, Class javaClass, Boolean sendNull, Boolean sendType) throws IOException
elemQName
- is the QName of the elementattributes
- are additional attributesvalue
- is the object to serializexmlType
- is the qname of the type or null.javaType
- is the java type of the valuesendNull
- determines whether to send null values.sendType
- determines whether to set xsi:type attribute.IOException
public void outputMultiRefs() throws IOException
IOException
public void writeXMLDeclaration() throws IOException
IOException
public void startElement(QName qName, Attributes attributes) throws IOException
qName
- is the name of the elementattributes
- are the attributes to writeIOException
public void endElement() throws IOException
IOException
public void writeChars(char[] p1, int p2, int p3) throws IOException
p1
- character array to writep2
- starting index in arrayp3
- length to writeIOException
public void writeString(String string) throws IOException
string
- is the String to write.IOException
public void writeSafeString(String string) throws IOException
string
- is the String to write.IOException
public void writeDOMElement(Element el) throws IOException
el
- is a DOM ElementIOException
public final Serializer getSerializerForJavaType(Class javaType)
javaType
- is Class for a type to serializepublic Attributes setTypeAttribute(Attributes attributes, QName type)
attributes
- of the qnametype
- is the qname of the typepublic QName getCurrentXMLType()
public String getValueAsString(Object value, QName xmlType, Class javaClass) throws IOException
IOException
public void setWriteXMLType(QName type)
public XMLEncoder getEncoder()
public String getEncoding()
public void setEncoding(String encoding)
public QName getItemQName()
public void setItemQName(QName itemQName)
public QName getItemType()
public void setItemType(QName itemType)
Copyright © The Apache Software Foundation. All Rights Reserved.