public final class DefaultCoderManager extends Object implements CoderManager
A simple CoderManager
implementation that associates each
registered Class
with its corresponding KeyCoder
or
ValueCoder
. See CoderManager
for more information.
This implementation builds a HashMap
to associate each
registered Class
with its KeyCoder
or
ValueCoder
. Registering a class MyClass
has no
effect on the encoding or decoding of subclasses of MyClass
.
Each subclass needs to be registered separately, even if the
ValueCoder
or KeyCoder
is the same for each
subclass. A custom CoderManager
implementation could modify this
behavior.
Constructor and Description |
---|
DefaultCoderManager(Persistit persistit)
Construct a new
DefaultCoderManager , using the
serialOverride system configuration property to determine
which classes, if any, must employ standard Java serialization. |
DefaultCoderManager(Persistit persistit,
String patterns)
Construct a new
DefaultCoderManager that uses standard Java
serialization for any class whose name conforms to the supplied
patterns string. |
Modifier and Type | Method and Description |
---|---|
CoderManager |
getParent()
Returns the parent
CoderManager . |
Map<Class<?>,KeyCoder> |
getRegisteredKeyCoders()
Create a
Map of Class es to registered
KeyCoder s. |
Map<Class<?>,ValueCoder> |
getRegisteredValueCoders()
Create a
Map of Class es to registered
ValueCoder s. |
String |
getSerialOverridePatterns()
Returns the serialization override pattern specified by the
serialOverride property. |
ValueCoder |
getValueCoder(Class<?> clazz)
Return a
ValueCoder for the supplied Class . |
boolean |
isSerialOverride(Class<?> clazz)
Tests whether the supplied class is included in the serial override set.
|
KeyCoder |
lookupKeyCoder(Class<?> clazz)
Returns the
KeyCoder registered for the supplied
Class , or null if no KeyCoder is
registered. |
ValueCoder |
lookupValueCoder(Class<?> clazz)
Return the
ValueCoder registered for the supplied
Class , or null if no ValueCoder
is registered. |
KeyCoder |
registerKeyCoder(Class<?> clazz,
KeyCoder coder)
Associates a
KeyCoder with a Class that it will
encode. |
ValueCoder |
registerValueCoder(Class<?> clazz,
ValueCoder coder)
Attempt to register the provided
ValueCoder to encode and
decode instances of supplied Class . |
KeyCoder |
unregisterKeyCoder(Class<?> clazz)
Removes any
KeyCoder registered for the supplied
Class |
int |
unregisterKeyCoder(KeyCoder coder)
Unregisters the supplied
KeyCoder from all
Class es it was previously registered to handle. |
ValueCoder |
unregisterValueCoder(Class<?> clazz)
Removes any
ValueCoder registered for the supplied
Class |
int |
unregisterValueCoder(ValueCoder coder)
Unregisters the supplied
ValueCoder from all
Class es it was previously registered to handle. |
public DefaultCoderManager(Persistit persistit)
DefaultCoderManager
, using the
serialOverride
system configuration property to determine
which classes, if any, must employ standard Java serialization.persistit
- the Persistit instanceIllegalArgumentException
- if the format of the serialOverride
property is
invalidpublic DefaultCoderManager(Persistit persistit, String patterns)
DefaultCoderManager
that uses standard Java
serialization for any class whose name conforms to the supplied
patterns
string. See getSerialOverridePatterns()
for details.persistit
- the Persistit instancepatterns
- Specifies class names of classes that always use standard Java
serialization rather a custom ValueCoder
implementation.IllegalArgumentException
- if the format of the supplied patterns
string is
invalidpublic CoderManager getParent()
CoderManager
.getParent
in interface CoderManager
public KeyCoder registerKeyCoder(Class<?> clazz, KeyCoder coder)
KeyCoder
with a Class
that it will
encode.registerKeyCoder
in interface CoderManager
clazz
- The Class
coder
- The KeyCoder
KeyCoder
formerly registered for this
Class
, or null
if there was none.public KeyCoder unregisterKeyCoder(Class<?> clazz)
KeyCoder
registered for the supplied
Class
unregisterKeyCoder
in interface CoderManager
clazz
- The Class
that will no longer have a
KeyCoder
KeyCoder
, or null
if there
was none.public int unregisterKeyCoder(KeyCoder coder)
KeyCoder
from all
Class
es it was previously registered to handle.unregisterKeyCoder
in interface CoderManager
coder
- The KeyCoder
Class
es for which this
KeyCoder
was previously registered.public Map<Class<?>,ValueCoder> getRegisteredValueCoders()
Map
of Class
es to registered
ValueCoder
s. The map is an unmodifiable, is sorted by class
name, and does not change with subsequent registrations or removals of
ValueCoder
s.getRegisteredValueCoders
in interface CoderManager
Map
of Class
es to
ValueCoder
s.public Map<Class<?>,KeyCoder> getRegisteredKeyCoders()
Map
of Class
es to registered
KeyCoder
s. The map is an unmodifiable, and is sorted by
class name, and does not change with subsequent registrations or
unregistrations of KeyCoder
s.getRegisteredKeyCoders
in interface CoderManager
Map
of Class
es to KeyCoder
s.public KeyCoder lookupKeyCoder(Class<?> clazz)
KeyCoder
registered for the supplied
Class
, or null
if no KeyCoder
is
registered.lookupKeyCoder
in interface CoderManager
clazz
- The Class
KeyCoder
or null
if there is none.public ValueCoder registerValueCoder(Class<?> clazz, ValueCoder coder)
ValueCoder
to encode and
decode instances of supplied Class
. If the class is included
in the serial override set (see getSerialOverridePatterns()
and
if the ValueCoder
is not an instance of
SerialValueCoder
, the request is ignored.registerValueCoder
in interface CoderManager
clazz
- The Class for which this ValueCoder
will provide
encoding and decoding servicescoder
- The ValueCoder to registerValueCoder
that was removed, or
null
if there was none.public ValueCoder unregisterValueCoder(Class<?> clazz)
ValueCoder
registered for the supplied
Class
unregisterValueCoder
in interface CoderManager
clazz
- The Class
that will no longer have a
ValueCoder
ValueCoder
, or null
if
there was none.public int unregisterValueCoder(ValueCoder coder)
ValueCoder
from all
Class
es it was previously registered to handle.unregisterValueCoder
in interface CoderManager
coder
- The ValueCoder
Class
es for which this
ValueCoder
was previously registered.public ValueCoder lookupValueCoder(Class<?> clazz)
ValueCoder
registered for the supplied
Class
, or null
if no ValueCoder
is registered.lookupValueCoder
in interface CoderManager
clazz
- The Class
ValueCoder
or null
if there is
none.public ValueCoder getValueCoder(Class<?> clazz)
ValueCoder
for the supplied Class
. If
there is none registered, implicitly create either a
DefaultValueCoder
or a SerialValueCoder
and register it.getValueCoder
in interface CoderManager
clazz
- The class for which a ValueCoder
is neededValueCoder
public String getSerialOverridePatterns()
Returns the serialization override pattern specified by the
serialOverride
property. The pattern specifies a collection
of names of classes that are required to be serialized by standard Java
serialization rather than by a default or custom ValueCoder
.
The result is a comma-delimited sequence of explicit class names and/or partial names that include wildcards. There are two wildcards: "**" standard for any character sequence, while "*" stands for any character sequence that having no periods. For example, the string
java.util.ArrayList,java.util.*Map,java.lang.*,javax.swing.**
includes java.util.ArrayList
,
java.util.AbstractMap
, java.util.HashMap
, etc.,
all the classes in the java.lang
package (but not
java.lang.ref
or java.lang.reflect
), and all
classes in javax.swing
and all its sub-packages.
public boolean isSerialOverride(Class<?> clazz)
serialOverride
property that are always serialized by standard Java serialization. Any
attempt to register a custom ValueCoder
or a
DefaultObjectCoder
for such a class will be ignored.clazz
- The class to testtrue
if and only if the specified class is selected
by the serialOverride
propertygetSerialOverridePatterns()
Copyright © 2025 Open Identity Platform Community. All rights reserved.