public final class SerializerGroup extends BeanContext
Serializers
that can be looked up by media type.
Accept
header values.
Accept
strings in the order they exist in this group.
Adding new entries will cause the entries to be prepended to the group. This allows for previous serializers to be overridden through subsequent calls.
For example, calling g.append(S1.
will result in the order S3, S4, S1, S2
.
BEAN_beanClassVisibility, BEAN_beanConstructorVisibility, BEAN_beanDictionary, BEAN_beanDictionary_add, BEAN_beanDictionary_remove, BEAN_beanFieldVisibility, BEAN_beanFilters, BEAN_beanFilters_add, BEAN_beanFilters_remove, BEAN_beanMapPutReturnsOldValue, BEAN_beanMethodVisibility, BEAN_beansRequireDefaultConstructor, BEAN_beansRequireSerializable, BEAN_beansRequireSettersForGetters, BEAN_beansRequireSomeProperties, BEAN_beanTypePropertyName, BEAN_debug, BEAN_excludeProperties, BEAN_ignoreInvocationExceptionsOnGetters, BEAN_ignoreInvocationExceptionsOnSetters, BEAN_ignorePropertiesWithoutSetters, BEAN_ignoreUnknownBeanProperties, BEAN_ignoreUnknownNullBeanProperties, BEAN_implClasses, BEAN_includeProperties, BEAN_locale, BEAN_mediaType, BEAN_notBeanClasses, BEAN_notBeanClasses_add, BEAN_notBeanClasses_remove, BEAN_notBeanPackages, BEAN_notBeanPackages_add, BEAN_notBeanPackages_remove, BEAN_pojoSwaps, BEAN_pojoSwaps_add, BEAN_pojoSwaps_remove, BEAN_propertyNamer, BEAN_sortProperties, BEAN_timeZone, BEAN_useInterfaceProxies, BEAN_useJavaBeanIntrospector, DEFAULT, DEFAULT_SORTED
Constructor and Description |
---|
SerializerGroup(PropertyStore ps,
Serializer[] serializers)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
SerializerGroupBuilder |
builder()
Returns a builder that's a copy of the settings on this serializer group.
|
static SerializerGroupBuilder |
create()
Instantiates a new clean-slate
SerializerGroupBuilder object. |
Serializer |
getSerializer(MediaType mediaType)
Same as
getSerializerMatch(MediaType) but returns just the matched serializer. |
Serializer |
getSerializer(String acceptHeader)
Same as
getSerializerMatch(String) but returns just the matched serializer. |
SerializerMatch |
getSerializerMatch(MediaType mediaType)
Same as
getSerializerMatch(String) but matches using a MediaType instance. |
SerializerMatch |
getSerializerMatch(String acceptHeader)
Searches the group for a serializer that can handle the specified
Accept value. |
List<Serializer> |
getSerializers()
Returns a copy of the serializers in this group.
|
OutputStreamSerializer |
getStreamSerializer(MediaType mediaType)
Same as
getSerializer(MediaType) , but casts it to a OutputStreamSerializer . |
OutputStreamSerializer |
getStreamSerializer(String acceptHeader)
Same as
getSerializer(String) , but casts it to an OutputStreamSerializer . |
List<MediaType> |
getSupportedMediaTypes()
Returns the media types that all serializers in this group can handle.
|
WriterSerializer |
getWriterSerializer(MediaType mediaType)
Same as
getSerializer(MediaType) , but casts it to a WriterSerializer . |
WriterSerializer |
getWriterSerializer(String acceptHeader)
Same as
getSerializer(String) , but casts it to a WriterSerializer . |
_class, asMap, createBeanSession, createBeanSession, createDefaultBeanSessionArgs, createDefaultSessionArgs, createSession, createSession, createSession, dumpCacheStats, getBeanMeta, getBeanRegistry, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getExcludeProperties, getImplClassConstructor, getIncludeProperties, hasSameCache, isBean, isNotABean, newInstance, newInstance, newInstanceFromOuter, object, resolveClassMeta, string
equals, getArrayProperty, getArrayProperty, getBooleanProperty, getClassArrayProperty, getClassArrayProperty, getClassArrayProperty, getClassListProperty, getClassListProperty, getClassMapProperty, getClassMapProperty, getClassProperty, getClassSetProperty, getClassSetProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceProperty, getInstanceProperty, getInstanceProperty, getIntegerProperty, getListProperty, getListProperty, getLongProperty, getMapProperty, getProperty, getProperty, getPropertyKeys, getPropertyStore, getSetProperty, getSetProperty, getStringProperty, hashCode, toString
public SerializerGroup(PropertyStore ps, Serializer[] serializers)
ps
- The modifiable properties that were used to initialize the serializers.
A snapshot of these will be made so that we can clone and modify this group.serializers
- The serializers defined in this group.
The order is important because they will be tried in reverse order (e.g.newer first) in which they will be tried
to match against media types.public static SerializerGroupBuilder create()
SerializerGroupBuilder
object.
This is equivalent to simply calling
.
SerializerGroupBuilder
object.public SerializerGroupBuilder builder()
builder
in class BeanContext
SerializerGroupBuilder
initialized to this group.public SerializerMatch getSerializerMatch(String acceptHeader)
Accept
value.
The accept
value complies with the syntax described in RFC2616, Section 14.1, as described below:
Accept = "Accept" ":" #( media-range [ accept-params ] ) media-range = ( "*\/*" | ( type "/" "*" ) | ( type "/" subtype ) ) *( ";" parameter ) accept-params = ";" "q" "=" qvalue *( accept-extension ) accept-extension = ";" token [ "=" ( token | quoted-string ) ]
The returned object includes both the serializer and media type that matched.
acceptHeader
- The HTTP public SerializerMatch getSerializerMatch(MediaType mediaType)
getSerializerMatch(String)
but matches using a MediaType
instance.mediaType
- The HTTP media type.public Serializer getSerializer(String acceptHeader)
getSerializerMatch(String)
but returns just the matched serializer.acceptHeader
- The HTTP public Serializer getSerializer(MediaType mediaType)
getSerializerMatch(MediaType)
but returns just the matched serializer.mediaType
- The HTTP media type.public WriterSerializer getWriterSerializer(String acceptHeader)
getSerializer(String)
, but casts it to a WriterSerializer
.acceptHeader
- The HTTP public WriterSerializer getWriterSerializer(MediaType mediaType)
getSerializer(MediaType)
, but casts it to a WriterSerializer
.mediaType
- The HTTP media type.public OutputStreamSerializer getStreamSerializer(String acceptHeader)
getSerializer(String)
, but casts it to an OutputStreamSerializer
.acceptHeader
- The HTTP public OutputStreamSerializer getStreamSerializer(MediaType mediaType)
getSerializer(MediaType)
, but casts it to a OutputStreamSerializer
.mediaType
- The HTTP media type.public List<MediaType> getSupportedMediaTypes()
Entries are ordered in the same order as the serializers in the group.
public List<Serializer> getSerializers()
Copyright © 2018 Apache. All rights reserved.