Class RegistryMatcher
- java.lang.Object
-
- org.simpleframework.xml.transform.RegistryMatcher
-
- All Implemented Interfaces:
Matcher
public class RegistryMatcher extends java.lang.Object implements Matcher
TheRegistryMatcher
provides a simple matcher backed by a registry. Registration can be done to match a type to aTransform
class or instance. If a transform class is registered an instance of it is created when requested using the default no argument constructor of the type, it is then cached so it can be reused on future requests.- See Also:
Persister
-
-
Field Summary
Fields Modifier and Type Field Description private Cache<Transform>
transforms
This is used to fetch transform instances by type.private Cache<java.lang.Class>
types
This is used to determine the transform for a type.
-
Constructor Summary
Constructors Constructor Description RegistryMatcher()
Constructor for theRegistryMatcher
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(java.lang.Class type, java.lang.Class transform)
This is used to bind aTransform
type.void
bind(java.lang.Class type, Transform transform)
This is used to bind aTransform
instance to the specified type.private Transform
create(java.lang.Class type)
This is used to create aTransform
using the type specified.private Transform
create(java.lang.Class type, java.lang.Class factory)
This is used to create aTransform
using the type specified.Transform
match(java.lang.Class type)
This is used to match aTransform
using the type specified.
-
-
-
Method Detail
-
bind
public void bind(java.lang.Class type, java.lang.Class transform)
This is used to bind aTransform
type. The first time a transform is requested for the specified type a new instance of thisTransform
will be instantiated.- Parameters:
type
- this is the type to resolve the transform fortransform
- this is the transform type to instantiate
-
bind
public void bind(java.lang.Class type, Transform transform)
This is used to bind aTransform
instance to the specified type. Each time a transform is requested for this type the provided instance will be returned.- Parameters:
type
- this is the type to resolve the transform fortransform
- this transform instance to be used
-
match
public Transform match(java.lang.Class type) throws java.lang.Exception
This is used to match aTransform
using the type specified. If no transform can be acquired then this returns a null value indicating that no transform could be found.
-
create
private Transform create(java.lang.Class type) throws java.lang.Exception
This is used to create aTransform
using the type specified. If no transform can be acquired then this returns a null value indicating that no transform could be found.- Parameters:
type
- this is the type to acquire the transform for- Returns:
- returns a transform for processing the type given
- Throws:
java.lang.Exception
-
create
private Transform create(java.lang.Class type, java.lang.Class factory) throws java.lang.Exception
This is used to create aTransform
using the type specified. If the transform can not be instantiated then this will throw an exception. If it can then it is cached.- Parameters:
type
- this is the type to acquire the transform forfactory
- the class for instantiating the transform- Returns:
- returns a transform for processing the type given
- Throws:
java.lang.Exception
-
-