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
- All Implemented Interfaces:
AnnotationProvider
- 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 classes/interfaces inherited from class org.apache.juneau.serializer.Serializer
Serializer.Null
-
Field Summary
Fields inherited from class org.apache.juneau.Context
CONTEXT_APPLY_FILTER
Fields inherited from interface org.apache.juneau.AnnotationProvider
DEFAULT, DISABLE_ANNOTATION_CACHING
-
Constructor Summary
ModifierConstructorDescriptionprotected
WriterSerializer
(WriterSerializer.Builder builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a builder from this context object.static WriterSerializer.Builder
create()
Creates a new builder for this object.Create a session builder based on the properties defined on this context.protected final Charset
File charset.protected final int
Maximum indentation.protected char
Quote character.Returns a session to use for this context.protected final Charset
Output stream charset.protected final boolean
Trim strings.final boolean
Returnstrue if this serializer subclasses fromWriterSerializer
.final WriterSerializer
Convenience method for serializing an object and sending it to STDOUT.protected JsonMap
Returns the properties on this bean as a map for debugging.protected Character
Quote character.final String
Convenience method for serializing an object to aString .final String
Methods 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, serializeToString
Methods inherited from class org.apache.juneau.BeanTraverseContext
getInitialDepth, getMaxDepth, isDetectRecursions, isIgnoreRecursions
Methods inherited from class org.apache.juneau.BeanContextable
getBeanContext
Methods inherited from class org.apache.juneau.Context
createBuilder, firstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, init, isDebug, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation, toString
-
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:Context
Creates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
- Overrides:
copy
in classSerializer
- Returns:
- A new Builder object.
-
createSession
Description copied from class:Context
Create 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:
createSession
in classSerializer
- Returns:
- A new session builder.
-
getSession
Description copied from class:Context
Returns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Overrides:
getSession
in classSerializer
- Returns:
- A new session object.
-
isWriterSerializer
Description copied from class:Serializer
Returnstrue if this serializer subclasses fromWriterSerializer
.- Overrides:
isWriterSerializer
in classSerializer
- Returns:
true if this serializer subclasses fromWriterSerializer
.
-
serialize
Convenience method for serializing an object to aString .- Overrides:
serialize
in 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 aRuntimeException
instead of aSerializeException
.This is typically good enough for debugging purposes.
- Parameters:
o
- The object to serialize.- Returns:
- The serialized object.
-
println
Convenience method for serializing an object and sending it to STDOUT.- Parameters:
o
- The object to serialize.- Returns:
- This 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:
-
quoteChar
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:Context
Returns the properties on this bean as a map for debugging.- Overrides:
properties
in classSerializer
- Returns:
- The properties on this bean as a map for debugging.
-