Class UonSerializer
- All Implemented Interfaces:
HttpPartSerializer,UonMetaProvider
- Direct Known Subclasses:
OpenApiSerializer,UonSerializer.Encoding,UonSerializer.Readable,UrlEncodingSerializer
Media types
Handles
Produces
Description
This serializer provides several serialization options. Typically, one of the predefined DEFAULT serializers will be sufficient. However, custom serializers can be constructed to fine-tune behavior.
The following shows a sample object defined in Javascript:
{
id: 1,
name:
Using the "strict" syntax defined in this document, the equivalent UON notation would be as follows:
(
Example:
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class.static classEquivalent toUonSerializer..create ().encoding().build();static classEquivalent toUonSerializer..create ().ws().build();Nested classes/interfaces inherited from class org.apache.juneau.serializer.Serializer
Serializer.NullNested classes/interfaces inherited from interface org.apache.juneau.httppart.HttpPartSerializer
HttpPartSerializer.Creator, HttpPartSerializer.Void -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanstatic final UonSerializerReusable instance ofUonSerializer, all default settings.static final UonSerializerReusable instance ofUonSerializer.Encoding.static final UonSerializerReusable instance ofUonSerializer.Readable.protected final booleanprotected final ParamFormatprotected final CharacterFields inherited from class org.apache.juneau.serializer.WriterSerializer
maxIndent, quoteCharOverride, useWhitespaceFields inherited from class org.apache.juneau.serializer.Serializer
accept, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static UonSerializer.Buildercreate()Creates a new builder for this object.Create a session builder based on the properties defined on this context.protected final ParamFormatFormat to use for query/form-data/header values.Creates a new serializer session.protected final charQuote character.Returns a session to use for this context.Returns the language-specific metadata on the specified bean property.getUonClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected final booleanAdd"_type" properties when needed.protected final booleanEncode non-valid URI characters.Returns the properties on this bean as a map for debugging.serialize(HttpPartType partType, HttpPartSchema schema, Object value) Converts the specified value to a string that can be used as an HTTP header value, query parameter value, form-data parameter, or URI path variable.Methods inherited from class org.apache.juneau.serializer.WriterSerializer
getFileCharset, getMaxIndent, getStreamCharset, isUseWhitespace, isWriterSerializer, println, quoteChar, serialize, toStringMethods inherited from class org.apache.juneau.serializer.Serializer
createSerializerBuilder, 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.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
-
DEFAULT
Reusable instance ofUonSerializer, all default settings. -
DEFAULT_READABLE
Reusable instance ofUonSerializer.Readable. -
DEFAULT_ENCODING
Reusable instance ofUonSerializer.Encoding. -
addBeanTypesUon
-
encoding
-
quoteCharUon
-
paramFormat
-
-
Constructor Details
-
UonSerializer
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 classWriterSerializer- 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 classWriterSerializer- Returns:
- A new session builder.
-
getPartSession
Description copied from interface:HttpPartSerializerCreates a new serializer session.- Specified by:
getPartSessionin interfaceHttpPartSerializer- Returns:
- A new serializer session.
-
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 classWriterSerializer- Returns:
- A new session object.
-
getUonBeanPropertyMeta
Description copied from interface:UonMetaProviderReturns the language-specific metadata on the specified bean property.- Specified by:
getUonBeanPropertyMetain interfaceUonMetaProvider- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getUonClassMeta
Description copied from interface:UonMetaProviderReturns the language-specific metadata on the specified class.- Specified by:
getUonClassMetain interfaceUonMetaProvider- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
serialize
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException Converts the specified value to a string that can be used as an HTTP header value, query parameter value, form-data parameter, or URI path variable.Returned values should NOT be URL-encoded.
- Parameters:
partType- The category of value being serialized.schema- Schema information about the part.
May benull .
Not all part serializers use the schema information.value- The value being serialized.- Returns:
- The serialized value.
- Throws:
SerializeException- If a problem occurred while trying to parse the input.SchemaValidationException- If the output fails schema validation.
-
getParamFormat
Format to use for query/form-data/header values.- Returns:
- Specifies the format to use for URL GET parameter keys and values.
- See Also:
-
getQuoteChar
Quote character.- Overrides:
getQuoteCharin classWriterSerializer- Returns:
- The character used for quoting attributes and values.
- See Also:
-
isAddBeanTypes
Add"_type" properties when needed.- Overrides:
isAddBeanTypesin classSerializer- Returns:
true if"_type" properties will be added to beans if their type cannot be inferred through reflection.- See Also:
-
isEncoding
Encode non-valid URI characters.- Returns:
true if non-valid URI characters should be encoded with"%xx" constructs.- See Also:
-
properties
Description copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classWriterSerializer- Returns:
- The properties on this bean as a map for debugging.
-