Class WriterSerializer.Builder<SELF extends WriterSerializer.Builder<SELF>>
- Direct Known Subclasses:
CsvSerializer.Builder,HjsonSerializer.Builder,HoconSerializer.Builder,IniSerializer.Builder,JsonSerializer.Builder,MarkdownSerializer.Builder,PlainTextSerializer.Builder,RdfSerializer.Builder,SseSerializer.Builder,TomlSerializer.Builder,UonSerializer.Builder,WriterSerializer.DefaultBuilder,XmlSerializer.Builder,YamlSerializer.Builder
- Enclosing class:
- WriterSerializer
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()Constructor, default settings.protectedBuilder(WriterSerializer copyFrom) Copy constructor.protectedBuilder(WriterSerializer.Builder<?> copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the object.abstract SELFcopy()Copy creator.hashKey()Returns the hashkey of this builder.maxIndent(int value) Maximum indentation.quoteChar(char value) Quote character.quoteCharOverride(char value) Quote character override.sq()Quote character.streamCharset(Charset value) Output stream charset.Use whitespace.useWhitespace(boolean value) Same asuseWhitespace()but allows you to explicitly specify the value.ws()Use whitespace.Methods 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
-
build
Description copied from class:Context.BuilderBuild the object.- Overrides:
buildin classSerializer.Builder<SELF extends WriterSerializer.Builder<SELF>>- Returns:
- The built object.
-
copy
Description copied from class:Context.BuilderCopy creator.- Specified by:
copyin classSerializer.Builder<SELF extends WriterSerializer.Builder<SELF>>- Returns:
- A new mutable copy of this builder.
-
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 classSerializer.Builder<SELF extends WriterSerializer.Builder<SELF>>- Returns:
- The hashkey of this builder.
-
maxIndent
Maximum indentation.Specifies the maximum indentation level in the serialized document.
Notes:
- This setting does not apply to the RDF serializers.
Example:
// Create a serializer that indents a maximum of 20 tabs. WriterSerializerserializer = JsonSerializer .create () .ws()// Enable whitespace .maxIndent(20) .build();- Parameters:
value- The new value for this property.
The default is100 .- Returns:
- This object.
-
quoteChar
Quote character.Specifies the character to use for quoting attributes and values.
Notes:
- This setting does not apply to the RDF serializers.
Example:
// Create a serializer that uses single quotes. WriterSerializerserializer = JsonSerializer .create () .quoteChar('\'' ) .build();// A bean with a single property public class MyBean {public Stringfoo ="bar" ; }// Produces {'foo':'bar'} Stringjson =serializer .toString(new MyBean());- Parameters:
value- The new value for this property.
The default is'"' .- Returns:
- This object.
-
quoteCharOverride
Quote character override.Similar to
quoteChar(char)but takes precedence over that setting.Allows you to override the quote character even if it's set by a subclass such as
Json5Serializer.- Parameters:
value- The new value for this property.
The default isnull .- Returns:
- This object.
-
sq
Quote character.Specifies to use single quotes for quoting attributes and values.
Notes:
- This setting does not apply to the RDF serializers.
Example:
// Create a serializer that uses single quotes. WriterSerializerserializer = JsonSerializer .create () .sq() .build();// A bean with a single property public class MyBean {public Stringfoo ="bar" ; }// Produces {'foo':'bar'} Stringjson =serializer .toString(new MyBean());- Returns:
- This object.
-
streamCharset
Output stream charset.The character set to use when writing to
OutputStreams .Used when passing in output streams and byte arrays to
Serializer.write(Object, Object).Example:
// Create a serializer that writes UTF-8 files. WriterSerializerserializer = JsonSerializer .create () .streamCharset(Charset.forName ("UTF-8" )) .build();// Use it to write to a UTF-8 encoded output stream. serializer .serializer(new FileOutputStreamStream("MyBean.txt" ),myBean );- Parameters:
value- The new value for this property.
The default is the system JVM setting.
Can benull (defaults to UTF-8).- Returns:
- This object.
-
useWhitespace
Use whitespace.When enabled, whitespace is added to the output to improve readability.
Example:
// Create a serializer with whitespace enabled. WriterSerializerserializer = JsonSerializer .create () .useWhitespace() .build();// A bean with a single property public class MyBean {public Stringfoo ="bar" ; }// Produces "\{\n\t"foo": "bar"\n\}\n" Stringjson =serializer .write(new MyBean());- Returns:
- This object.
-
useWhitespace
Same asuseWhitespace()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
ws
Use whitespace.When enabled, whitespace is added to the output to improve readability.
Example:
// Create a serializer with whitespace enabled. WriterSerializerserializer = JsonSerializer .create () .ws() .build();// A bean with a single property public class MyBean {public Stringfoo ="bar" ; }// Produces "\{\n\t"foo": "bar"\n\}\n" Stringjson =serializer .write(new MyBean());- Returns:
- This object.
-