Class XmlSerializer
- All Implemented Interfaces:
- AnnotationProvider,- XmlMetaProvider
- Direct Known Subclasses:
- HtmlSerializer,- SoapXmlSerializer,- XmlDocSerializer,- XmlSerializer.Ns,- XmlSerializer.NsSq,- XmlSerializer.NsSqReadable,- XmlSerializer.Sq,- XmlSerializer.SqReadable
Media types
 Handles 
 Produces 
Description
 See the JsonSerializer class for details on how Java models map to JSON.
 
For example, the following JSON...
   {
      name:
...maps to the following XML using the default serializer...
   
An additional "add-json-properties" mode is also provided to prevent loss of JSON data types...
   
 This serializer provides several serialization options.
 Typically, one of the predefined 
 If an attribute name contains any non-valid XML element characters, they will be escaped using standard
 _x####_ notation.
 
Behavior-specific subclasses
The following direct subclasses are provided for convenience:
- XmlSerializer.Sq- Default serializer, single quotes.
- XmlSerializer.SqReadable- Default serializer, single quotes, whitespace added.
Notes:
- This class is thread safe and reusable.
See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classBuilder class.static classDefault serializer without namespaces.static classDefault serializer without namespaces, single quotes.static classDefault serializer without namespaces, single quotes, with whitespace.static classDefault serializer, single quotes.static classDefault serializer, single quotes, whitespace added.Nested classes/interfaces inherited from class org.apache.juneau.serializer.SerializerSerializer.Null
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final XmlSerializerDefault serializer without namespaces.protected static final Namespacestatic final XmlSerializerDefault serializer, all default settings.static final XmlSerializerDefault serializer, single quotes.static final XmlSerializerDefault serializer, single quotes, whitespace added.static final XmlSerializerDefault serializer without namespaces, with single quotes.static final XmlSerializerDefault serializer without namespaces, with single quotes, whitespace added.protected static final NamespaceFields inherited from class org.apache.juneau.ContextCONTEXT_APPLY_FILTERFields inherited from interface org.apache.juneau.AnnotationProviderDISABLE_ANNOTATION_CACHING
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static XmlSerializer.Buildercreate()Creates a new builder for this object.Create a session builder based on the properties defined on this context.protected final NamespaceDefault namespace.protected final Namespace[]Default namespaces.Returns a session to use for this context.getXmlBeanMeta(BeanMeta<?> bm) Returns the language-specific metadata on the specified bean.Returns the language-specific metadata on the specified bean property.getXmlClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected booleanAdd"_type" properties when needed.protected final booleanAdd namespace URLs to the root element.protected final booleanAuto-detect namespace usage.protected final booleanEnable support for XML namespaces.protected JsonMapReturns the properties on this bean as a map for debugging.Methods inherited from class org.apache.juneau.serializer.WriterSerializergetFileCharset, getMaxIndent, getQuoteChar, getStreamCharset, isUseWhitespace, isWriterSerializer, println, quoteChar, serialize, toStringMethods inherited from class org.apache.juneau.serializer.SerializercreateSerializerBuilder, doSerialize, forEachAcceptMediaType, getListener, getMediaTypeRanges, getPrimaryMediaType, getResponseContentType, getResponseHeaders, getUriContext, getUriRelativity, getUriResolution, isAddRootType, isKeepNullProperties, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, serialize, serializeToStringMethods inherited from class org.apache.juneau.BeanTraverseContextgetInitialDepth, getMaxDepth, isDetectRecursions, isIgnoreRecursionsMethods inherited from class org.apache.juneau.BeanContextablegetBeanContextMethods inherited from class org.apache.juneau.ContextcreateBuilder, firstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, init, isDebug, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.juneau.AnnotationProviderfirstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation
- 
Field Details- 
DEFAULTDefault serializer without namespaces.
- 
DEFAULT_SQDefault serializer without namespaces, with single quotes.
- 
DEFAULT_SQ_READABLEDefault serializer without namespaces, with single quotes, whitespace added.
- 
DEFAULT_NSDefault serializer, all default settings.
- 
DEFAULT_NS_SQDefault serializer, single quotes.
- 
DEFAULT_NS_SQ_READABLEDefault serializer, single quotes, whitespace added.
- 
DEFAULT_JUNEAU_NAMESPACE
- 
DEFAULT_XS_NAMESPACE
 
- 
- 
Constructor Details- 
XmlSerializerConstructor.- Parameters:
- builder- The builder for this object.
 
 
- 
- 
Method Details- 
createCreates a new builder for this object.- Returns:
- A new builder.
 
- 
copyDescription copied from class:ContextCreates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations. - Overrides:
- copyin class- WriterSerializer
- Returns:
- A new Builder object.
 
- 
createSessionDescription copied from class:ContextCreate a session builder based on the properties defined on this context.Use this method for creating sessions where you want to override basic settings. Otherwise, use Context.getSession()directly.- Overrides:
- createSessionin class- WriterSerializer
- Returns:
- A new session builder.
 
- 
getSessionDescription copied from class:ContextReturns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session. - Overrides:
- getSessionin class- WriterSerializer
- Returns:
- A new session object.
 
- 
getXmlClassMetaDescription copied from interface:XmlMetaProviderReturns the language-specific metadata on the specified class.- Specified by:
- getXmlClassMetain interface- XmlMetaProvider
- Parameters:
- cm- The class to return the metadata on.
- Returns:
- The metadata.
 
- 
getXmlBeanMetaDescription copied from interface:XmlMetaProviderReturns the language-specific metadata on the specified bean.- Specified by:
- getXmlBeanMetain interface- XmlMetaProvider
- Parameters:
- bm- The bean to return the metadata on.
- Returns:
- The metadata.
 
- 
getXmlBeanPropertyMetaDescription copied from interface:XmlMetaProviderReturns the language-specific metadata on the specified bean property.- Specified by:
- getXmlBeanPropertyMetain interface- XmlMetaProvider
- Parameters:
- bpm- The bean property to return the metadata on.
- Returns:
- The metadata.
 
- 
isAddBeanTypesAdd"_type" properties when needed.- Overrides:
- isAddBeanTypesin class- Serializer
- Returns:
- true if- "_type" properties will be added to beans if their type cannot be inferred through reflection.
- See Also:
 
- 
isAddNamespaceUrlsToRootAdd namespace URLs to the root element.- Returns:
- true if- xmlns:xattributes are added to the root element for the default and all mapped namespaces.
- See Also:
 
- 
isAutoDetectNamespacesAuto-detect namespace usage.- Returns:
- true if namespace usage is detected before serialization.
- See Also:
 
- 
getDefaultNamespaceDefault namespace.- Returns:
- The default namespace URI for this document.
- See Also:
 
- 
isEnableNamespacesEnable support for XML namespaces.- Returns:
- false if XML output will not contain any namespaces regardless of any other settings.
- See Also:
 
- 
getNamespacesDefault namespaces.- Returns:
- The default list of namespaces associated with this serializer.
- See Also:
 
- 
propertiesDescription copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
- propertiesin class- WriterSerializer
- Returns:
- The properties on this bean as a map for debugging.
 
 
-