Class XmlSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>
- Direct Known Subclasses:
HtmlSerializer.Builder,SoapXmlSerializer.Builder,XmlSerializer.DefaultBuilder
- Enclosing class:
- XmlSerializer
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()Constructor, default settings.protectedBuilder(XmlSerializer copyFrom) Copy constructor.protectedBuilder(XmlSerializer.Builder<?> copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionAdd"_type" properties when needed.addBeanTypesXml(boolean value) Same asaddBeanTypesXml()but allows you to explicitly specify the value.Add namespace URLs to the root element.addNamespaceUrisToRoot(boolean value) Same asaddNamespaceUrisToRoot()but allows you to explicitly specify the value.build()Build the object.abstract SELFcopy()Copy creator.defaultNamespace(Namespace value) Default namespace.Don't auto-detect namespace usage.disableAutoDetectNamespaces(boolean value) Same asdisableAutoDetectNamespaces()but allows you to explicitly specify the value.XmlSerializer configuration property: Disable use of JSON type identifier tags.disableJsonTags(boolean value) Same asdisableJsonTags()but allows you to explicitly specify the value.Enable support for XML namespaces.enableNamespaces(boolean value) Same asenableNamespaces()but allows you to explicitly specify the value.hashKey()Returns the hashkey of this builder.namespaces(Namespace... values) Default namespaces.ns()Enable support for XML namespaces.textNodeDelimiter(String value) Text node delimiter.Methods inherited from class org.apache.juneau.marshall.serializer.WriterSerializer.Builder
maxIndent, quoteChar, quoteCharOverride, sq, streamCharset, useWhitespace, useWhitespace, wsMethods inherited from class org.apache.juneau.marshall.serializer.Serializer.Builder
accept, addBeanTypes, addBeanTypes, addRootType, addRootType, getAccept, getProduces, keepNullProperties, keepNullProperties, listener, nonDefault, nonDefault, produces, sortCollections, sortCollections, sortMaps, sortMaps, trimEmptyCollections, trimEmptyCollections, trimEmptyMaps, trimEmptyMaps, trimStrings, trimStrings, uriContext, uriRelativity, uriResolutionMethods inherited from class org.apache.juneau.marshall.MarshallingTraverseContext.Builder
detectRecursions, detectRecursions, ignoreRecursions, ignoreRecursions, initialDepth, maxDepthMethods inherited from class org.apache.juneau.marshall.MarshallingContextable.Builder
activeView, annotations, beanClassVisibility, beanConstructorVisibility, beanDictionary, beanFieldVisibility, beanInterceptor, beanMapPutReturnsOldValue, beanMethodVisibility, beanProperties, beanProperties, beanProperties, beanPropertiesExcludes, beanPropertiesExcludes, beanPropertiesExcludes, beanPropertiesReadOnly, beanPropertiesReadOnly, beanPropertiesReadOnly, beanPropertiesWriteOnly, beanPropertiesWriteOnly, beanPropertiesWriteOnly, beansRequireDefaultConstructor, beansRequireSerializable, beansRequireSettersForGetters, bigNumberFormat, binaryFormat, bitSetFormat, booleanFormat, calendarFormat, classFormat, classLoader, currencyFormat, dateFormat, debug, dictionaryOn, disableBeansRequireSomeProperties, disableDefaultViewInclusion, disableIgnoreMissingSetters, disableIgnoreTransientFields, disableIgnoreUnknownNullBeanProperties, disableInterfaceProxies, durationFormat, enumFormat, example, example, findFluentSetters, findFluentSetters, floatFormat, ignoreInvocationExceptionsOnGetters, ignoreInvocationExceptionsOnSetters, ignoreUnknownBeanProperties, ignoreUnknownEnumValues, implClass, implClasses, interfaceClass, interfaces, locale, localeFormat, marshallingContext, marshallingContext, marshallingContext, marshallingContext, mediaType, notBeanClasses, notBeanPackages, periodFormat, propertyNamer, propertyNamer, recordComponentOrder, stopClass, swap, swap, swaps, swaps, temporalFormat, timeZone, timeZoneFormat, typeName, typePropertyName, typePropertyName, unsortedProperties, unsortedProperties, useJavaBeanIntrospector, uuidFormat, validateSchema, validateSchemaMethods inherited from class org.apache.juneau.marshall.Context.Builder
annotations, apply, applyAnnotations, applyAnnotations, asSubtype, build, cache, canApply, copyOrNull, debug, getApplied, getType, impl, isDebug, registerBuilders, self, type
-
Constructor Details
-
Builder
protected Builder()Constructor, default settings. -
Builder
Copy constructor.- Parameters:
copyFrom- The builder to copy from.
Cannot benull .
-
Builder
Copy constructor.- Parameters:
copyFrom- The bean to copy from.
Cannot benull .
-
-
Method Details
-
addBeanTypesXml
Add"_type" properties when needed.If
true , then"_type" properties will be added to beans if their type cannot be inferred through reflection.When present, this value overrides the
Serializer.Builder#addBeanTypes()setting and is provided to customize the behavior of specific serializers in aSerializerSet.- Returns:
- This object.
-
addBeanTypesXml
Same asaddBeanTypesXml()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
addNamespaceUrisToRoot
Add namespace URLs to the root element.Use this setting to add
xmlns:xattributes to the root element for the default and all mapped namespaces.This setting is ignored if
enableNamespaces()is not enabled.See Also:
- Returns:
- This object.
-
addNamespaceUrisToRoot
Same asaddNamespaceUrisToRoot()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
build
Description copied from class:Context.BuilderBuild the object.- Overrides:
buildin classWriterSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>- Returns:
- The built object.
-
copy
Description copied from class:Context.BuilderCopy creator.- Specified by:
copyin classWriterSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>- Returns:
- A new mutable copy of this builder.
-
defaultNamespace
- Parameters:
value- The new value for this property.
The default is"juneau: http://www.apache.org/2013/Juneau" .
Can benull to specify no namespace.- Returns:
- This object.
-
disableAutoDetectNamespaces
Don't auto-detect namespace usage.Don't detect namespace usage before serialization.
Used in conjunction with
addNamespaceUrisToRoot()to reduce the list of namespace URLs appended to the root element to only those that will be used in the resulting document.If disabled, then the data structure will first be crawled looking for namespaces that will be encountered before the root element is serialized.
This setting is ignored if
enableNamespaces()is not enabled.Notes:
-
Auto-detection of namespaces can be costly performance-wise.
In high-performance environments, it's recommended that namespace detection be disabled, and that namespaces be manually defined through thenamespaces(Namespace...)property.
See Also:
- Returns:
- This object.
-
Auto-detection of namespaces can be costly performance-wise.
-
disableAutoDetectNamespaces
Same asdisableAutoDetectNamespaces()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
disableJsonTags
XmlSerializer configuration property: Disable use of JSON type identifier tags.When enabled, JSON type tags (e.g.
"<string>" ) tags and attributes will not be added to the output. Note that JSON type tags are used to ensure parsers are able to recreate the original data types passed into the serializer. Disabling JSON tags can cause different data to be parsed (e.g. strings instead of numbers).- Returns:
- This object.
-
disableJsonTags
Same asdisableJsonTags()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
enableNamespaces
Enable support for XML namespaces.If not enabled, XML output will not contain any namespaces regardless of any other settings.
See Also:
- Returns:
- This object.
-
enableNamespaces
Same asenableNamespaces()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
hashKey
Description copied from class:Context.BuilderReturns the hashkey of this builder.Used to return previously instantiated context beans that have matching hashkeys. The
HashKeyobject is suitable for use as a hashmap key of a map of context beans. A context bean is considered equivalent if theHashKey.equals(Object)method is the same.- Overrides:
hashKeyin classWriterSerializer.Builder<SELF extends XmlSerializer.Builder<SELF>>- Returns:
- The hashkey of this builder.
-
namespaces
Default namespaces.The default list of namespaces associated with this serializer.
- Parameters:
values- The new value for this property.
Cannot containnull values.- Returns:
- This object.
-
ns
Enable support for XML namespaces.Shortcut for calling
enableNamespaces(.true )- Returns:
- This object.
-
textNodeDelimiter
Text node delimiter.Specifies the delimiter string to insert between consecutive text nodes. This is useful for adding spacing between text elements to improve readability.
The default value is an empty string (no delimiter).
Example:
XmlSerializer.
create () .textNodeDelimiter(" " ) .build();With this setting, serializing:
new Audio().children("a" ,"b" ,new Strong("c" ));Will produce:
<audio>a b<strong>c</strong></audio>
Instead of:<audio>ab<strong>c</strong></audio>- Parameters:
value- The delimiter string.
Can benull (interpreted as empty string).- Returns:
- This object.
-