Package org.apache.juneau.serializer
Class WriterSerializer
java.lang.Object
org.apache.juneau.Context
org.apache.juneau.BeanContextable
org.apache.juneau.BeanTraverseContext
org.apache.juneau.serializer.Serializer
org.apache.juneau.serializer.WriterSerializer
- Direct Known Subclasses:
CsvSerializer,JsonSerializer,PlainTextSerializer,UonSerializer,XmlSerializer
Subclass of
Serializer for character-based serializers.
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.serializer.Serializer
Serializer.Null -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final Characterprotected final Characterprotected final booleanFields inherited from class org.apache.juneau.serializer.Serializer
accept, addBeanTypes, addRootType, keepNullProperties, listener, produces, sortCollections, sortMaps, trimEmptyCollections, trimEmptyMaps, trimStringsFields inherited from class org.apache.juneau.BeanContextable
beanContextFields inherited from class org.apache.juneau.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWriterSerializer(WriterSerializer.Builder builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static WriterSerializer.Buildercreate()Creates a new builder for this object.Create a session builder based on the properties defined on this context.protected final CharsetFile charset.protected final intMaximum indentation.protected charQuote character.Returns a session to use for this context.protected final CharsetOutput stream charset.protected final booleanTrim strings.final booleanReturnstrue if this serializer subclasses fromWriterSerializer.final WriterSerializerConvenience method for serializing an object and sending it to STDOUT.Returns the properties on this bean as a map for debugging.protected CharacterQuote character.final StringConvenience method for serializing an object to aString .final StringMethods inherited from class org.apache.juneau.serializer.Serializer
createSerializerBuilder, doSerialize, forEachAcceptMediaType, getListener, getMediaTypeRanges, getPrimaryMediaType, getResponseContentType, getResponseHeaders, getUriContext, getUriRelativity, getUriResolution, isAddBeanTypes, isAddRootType, isKeepNullProperties, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, serialize, serializeToStringMethods inherited from class org.apache.juneau.BeanTraverseContext
getDetectRecursions, getIgnoreRecursions, getInitialDepth, getMaxDepth, isDetectRecursions, isIgnoreRecursionsMethods inherited from class org.apache.juneau.BeanContextable
getBeanContextMethods inherited from class org.apache.juneau.Context
createBuilder, getAnnotationProvider, init, isDebug, toString
-
Field Details
-
useWhitespace
-
quoteChar
-
quoteCharOverride
-
maxIndent
-
-
Constructor Details
-
WriterSerializer
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Returns:
- A new builder.
-
copy
Description 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 classSerializer- Returns:
- A new Builder object.
-
createSession
Description 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 classSerializer- Returns:
- A new session builder.
-
getSession
Description 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 classSerializer- Returns:
- A new session object.
-
isWriterSerializer
Description copied from class:SerializerReturnstrue if this serializer subclasses fromWriterSerializer.- Overrides:
isWriterSerializerin classSerializer- Returns:
true if this serializer subclasses fromWriterSerializer.
-
println
Convenience method for serializing an object and sending it to STDOUT.- Parameters:
o- The object to serialize.- Returns:
- This object.
-
serialize
Convenience method for serializing an object to aString .- Overrides:
serializein classSerializer- Parameters:
o- The object to serialize.- Returns:
- The output serialized to a string.
- Throws:
SerializeException- If a problem occurred trying to convert the output.
-
toString
Identical toserialize(Object)except throws aRuntimeExceptioninstead of aSerializeException.This is typically good enough for debugging purposes.
- Parameters:
o- The object to serialize.- Returns:
- The serialized object.
-
getFileCharset
File charset.- Returns:
- The character set to use when writing to
Files on the file system. - See Also:
-
getMaxIndent
Maximum indentation.- Returns:
- The maximum indentation level in the serialized document.
- See Also:
-
getQuoteChar
Quote character.- Returns:
- The character used for quoting attributes and values.
- See Also:
-
getStreamCharset
Output stream charset.- Returns:
- The character set to use when writing to
OutputStreams and byte arrays. - See Also:
-
isUseWhitespace
Trim strings.- Returns:
- When enabled, whitespace is added to the output to improve readability.
- See Also:
-
properties
Description copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classSerializer- Returns:
- The properties on this bean as a map for debugging.
-
quoteChar
Quote character.- Returns:
- The character used for quoting attributes and values.
- See Also:
-