@Typed(value={}) public class BasicBinder extends Object implements Binder, RegisterableBinder
java.util.ServiceLoader
.
Default construction of this class registers bindings for core
JDK classes, as well as any bindings specified using bindings.xml
You can also register additional bindings programmatically.Binding is used to define a binding
Constructor and Description |
---|
BasicBinder()
Creates a new instance, initialised with standard, and registered bindings
|
BasicBinder(boolean includeBuiltInBindings)
Creates a new instance
|
Modifier and Type | Method and Description |
---|---|
<T> T |
convertFromString(Class<T> output,
String object)
*
String Binder *
*
|
<T> T |
convertFromString(Class<T> output,
String object,
Class<? extends Annotation> qualifier)
Convert a String to the given target class
|
<S,T> T |
convertTo(Class<S> input,
Class<T> output,
Object object)
Convert an object which is an instance of source class to the given target class
|
<S,T> T |
convertTo(Class<S> input,
Class<T> output,
Object object,
Class<? extends Annotation> qualifier)
Convert an object which is an instance of source class to the given target class
|
<S,T> T |
convertTo(Class<T> output,
Object object)
Convert an object to the given target class
This method infers the source type for the conversion from the runtime type of object.
|
<S,T> T |
convertTo(Class<T> output,
Object object,
Class<? extends Annotation> qualifier)
Convert an object to the given target class
This method infers the source type for the conversion from the runtime type of object.
|
<S,T> T |
convertTo(ConverterKey<S,T> key,
Object object)
Convert an object which is an instance of source class to the given target class
|
<S> String |
convertToString(Class<S> input,
Object object)
Convert an object which is an instance of source class to String
|
<S> String |
convertToString(Class<S> input,
Object object,
Class<? extends Annotation> qualifier)
Convert an object which is an instance of source class to String
|
String |
convertToString(Object object)
Convert an object to String
This method infers the source type for the conversion from the runtime type of object.
|
String |
convertToString(Object object,
Class<? extends Annotation> qualifier)
Convert an object to String
This method infers the source type for the conversion from the runtime type of object.
|
<S,T> Binding<S,T> |
findBinding(Class<S> source,
Class<T> target)
Resolve a Binding with the given source and target class.
|
<S,T> Binding<S,T> |
findBinding(Class<S> source,
Class<T> target,
Class<? extends Annotation> qualifier)
Resolve a Binding with the given source and target class.
|
<S,T> Binding<S,T> |
findBinding(ConverterKey<S,T> key)
Resolve a Binding with the given source and target class.
|
<S,T> Converter<S,T> |
findConverter(Class<S> input,
Class<T> output)
Resolve a Converter with the given input and output classes.
|
<S,T> Converter<S,T> |
findConverter(Class<S> source,
Class<T> target,
Class<? extends Annotation> qualifier)
Resolve a Converter with the given input and output classes.
|
<S,T> Converter<S,T> |
findConverter(ConverterKey<S,T> key)
Resolve a Converter with the given input and output classes.
|
<S,T> ToMarshaller<S,T> |
findMarshaller(Class<S> source,
Class<T> target)
Resolve a Marshaller with the given source and target class.
|
<S,T> ToMarshaller<S,T> |
findMarshaller(Class<S> source,
Class<T> target,
Class<? extends Annotation> qualifier)
Resolve a Marshaller with the given source and target class.
|
<S,T> ToMarshaller<S,T> |
findMarshaller(ConverterKey<S,T> key)
Resolve a Marshaller with the given source and target class.
|
<S,T> FromUnmarshaller<S,T> |
findUnmarshaller(Class<S> source,
Class<T> target)
Resolve an UnMarshaller with the given source and target class.
|
<S,T> FromUnmarshaller<S,T> |
findUnmarshaller(Class<S> source,
Class<T> target,
Class<? extends Annotation> qualifier)
Resolve an UnMarshaller with the given source and target class.
|
<S,T> FromUnmarshaller<S,T> |
findUnmarshaller(ConverterKey<S,T> key)
Resolve an UnMarshaller with the given source and target class.
|
Iterable<ConverterKey<?,?>> |
getConverterEntries()
Return an iterable collection of ConverterKeys, one for each currently registered conversion
|
protected <I> I |
getExtendedBinder(Class<I> cls)
Retrieves an extended binder
|
void |
registerAnnotatedClasses(Class<?>... classesToInspect)
Inspect each of the supplied classes, processing any of the annotated methods found
|
<S,T> void |
registerBinding(Class<S> source,
Class<T> target,
Binding<S,T> converter)
Register a Binding with the given source and target class.
|
<S,T> void |
registerBinding(Class<S> source,
Class<T> target,
Binding<S,T> converter,
Class<? extends Annotation> qualifier)
Register a Binding with the given source and target class.
|
<S,T> void |
registerBinding(ConverterKey<S,T> key,
Binding<S,T> converter)
Register a Binding with the given source and target class.
|
protected void |
registerBindingConfigurationEntries(Iterable<BindingConfigurationEntry> bindings)
Registers a list of binding configuration entries.
|
protected <S,T> void |
registerBindingConfigurationEntry(BindingConfigurationEntry theBinding)
Register a particular binding configuration entry.
|
void |
registerConfiguration(URL nextLocation)
Register the configuration file (bindings.xml) at the given URL
|
protected <X> void |
registerConfigurations(Enumeration<URL> bindingsConfiguration)
Registers a set of configurations for the given list of URLs.
|
<S,T> void |
registerConverter(Class<S> input,
Class<T> output,
Converter<S,T> converter)
Register a Converter with the given input and output classes.
|
<S,T> void |
registerConverter(Class<S> input,
Class<T> output,
Converter<S,T> converter,
Class<? extends Annotation> qualifier)
Register a Converter with the given input and output classes.
|
<S,T> void |
registerConverter(ConverterKey<S,T> key,
Converter<S,T> converter)
Register a Converter with the given input and output classes.
|
void |
registerConverterProvider(ConverterProvider provider)
Register a single converter provider
|
void |
registerConverterProviders(ConverterProvider... providers)
Method used to register one or more converter providers.
|
protected <I,T extends I> |
registerExtendedBinder(Class<I> iface,
T provider)
Register a custom, typesafe binder implementation which can be retrieved later
|
<S,T> void |
registerMarshaller(Class<S> source,
Class<T> target,
ToMarshaller<S,T> converter)
Register a Marshaller with the given source and target class.
|
<S,T> void |
registerMarshaller(Class<S> source,
Class<T> target,
ToMarshaller<S,T> converter,
Class<? extends Annotation> qualifier)
Register a Marshaller with the given source and target class.
|
<S,T> void |
registerMarshaller(ConverterKey<S,T> key,
ToMarshaller<S,T> converter)
Register a Marshaller with the given source and target class.
|
<S,T> void |
registerUnmarshaller(Class<S> source,
Class<T> target,
FromUnmarshaller<S,T> converter)
Register an UnMarshaller with the given source and target class.
|
<S,T> void |
registerUnmarshaller(Class<S> source,
Class<T> target,
FromUnmarshaller<S,T> converter,
Class<? extends Annotation> qualifier)
Register an UnMarshaller with the given source and target class.
|
<S,T> void |
registerUnmarshaller(ConverterKey<S,T> key,
FromUnmarshaller<S,T> converter)
Register an UnMarshaller with the given source and target class.
|
public BasicBinder()
public BasicBinder(boolean includeBuiltInBindings)
includeBuiltInBindings
- If true, initialise with standard, and registered bindingsprotected <X> void registerConfigurations(Enumeration<URL> bindingsConfiguration)
X
- Internally used type argumentbindingsConfiguration
- An enumeration of the URLs to processpublic final void registerConfiguration(URL nextLocation)
registerConfiguration
in interface RegisterableBinder
nextLocation
- The URL to registerpublic void registerConverterProviders(ConverterProvider... providers)
providers
- A collection of providerspublic void registerConverterProvider(ConverterProvider provider)
provider
- The provider.protected void registerBindingConfigurationEntries(Iterable<BindingConfigurationEntry> bindings)
bindings
- The entries to registerprotected <S,T> void registerBindingConfigurationEntry(BindingConfigurationEntry theBinding)
S
- The Source type for the bindingT
- The Target type for the bindingtheBinding
- The entry to be registeredpublic void registerAnnotatedClasses(Class<?>... classesToInspect)
registerAnnotatedClasses
in interface RegisterableBinder
classesToInspect
- The classes to inspect for annotationsprotected <I,T extends I> void registerExtendedBinder(Class<I> iface, T provider)
I
- The class to be registeredT
- Implementation of the binder type, I.iface
- The interface for the provider to be registered.provider
- The implementation.protected <I> I getExtendedBinder(Class<I> cls)
I
- Interface type for the extended bindercls
- The implementation.public final <S,T> void registerBinding(Class<S> source, Class<T> target, Binding<S,T> converter)
registerBinding
in interface RegisterableBinder
S
- Source typeT
- Target typesource
- The source (owning) classtarget
- The target (foreign) classconverter
- The binding to be registeredpublic final <S,T> void registerUnmarshaller(Class<S> source, Class<T> target, FromUnmarshaller<S,T> converter)
registerUnmarshaller
in interface RegisterableBinder
S
- Source typeT
- Target typesource
- The source (input) classtarget
- The target (output) classconverter
- The FromUnmarshaller to be registeredpublic final <S,T> void registerMarshaller(Class<S> source, Class<T> target, ToMarshaller<S,T> converter)
registerMarshaller
in interface RegisterableBinder
S
- Source typeT
- Target typesource
- The source (input) classtarget
- The target (output) classconverter
- The ToMarshaller to be registeredpublic final <S,T> void registerConverter(Class<S> input, Class<T> output, Converter<S,T> converter)
registerConverter
in interface RegisterableBinder
S
- Source typeT
- Target typeinput
- The input classoutput
- The output classconverter
- The Converter to be registeredpublic final <S,T> void registerBinding(Class<S> source, Class<T> target, Binding<S,T> converter, Class<? extends Annotation> qualifier)
registerBinding
in interface RegisterableBinder
S
- Source typeT
- Target typesource
- The source (owning) classtarget
- The target (foreign) classconverter
- The binding to be registeredqualifier
- The qualifier for which the binding must be registeredpublic final <S,T> void registerBinding(ConverterKey<S,T> key, Binding<S,T> converter)
registerBinding
in interface RegisterableBinder
S
- Source typeT
- Target typekey
- Converter Key to useconverter
- The binding to be registeredpublic final <S,T> void registerUnmarshaller(Class<S> source, Class<T> target, FromUnmarshaller<S,T> converter, Class<? extends Annotation> qualifier)
registerUnmarshaller
in interface RegisterableBinder
S
- Source typeT
- Target typesource
- The source (input) classtarget
- The target (output) classconverter
- The FromUnmarshaller to be registeredqualifier
- The qualifier for which the unmarshaller must be registeredpublic final <S,T> void registerUnmarshaller(ConverterKey<S,T> key, FromUnmarshaller<S,T> converter)
registerUnmarshaller
in interface RegisterableBinder
S
- Source typeT
- Target typekey
- Converter Key to useconverter
- The FromUnmarshaller to be registeredpublic final <S,T> void registerMarshaller(Class<S> source, Class<T> target, ToMarshaller<S,T> converter, Class<? extends Annotation> qualifier)
registerMarshaller
in interface RegisterableBinder
S
- Source typeT
- Target typesource
- The source (input) classtarget
- The target (output) classconverter
- The ToMarshaller to be registeredqualifier
- The qualifier for which the marshaller must be registeredpublic final <S,T> void registerMarshaller(ConverterKey<S,T> key, ToMarshaller<S,T> converter)
registerMarshaller
in interface RegisterableBinder
S
- Source typeT
- Target typekey
- Converter Key to useconverter
- The ToMarshaller to be registeredpublic final <S,T> void registerConverter(Class<S> input, Class<T> output, Converter<S,T> converter, Class<? extends Annotation> qualifier)
registerConverter
in interface RegisterableBinder
S
- Source typeT
- Target typeinput
- The input classoutput
- The output classconverter
- The Converter to be registeredqualifier
- The qualifier for which the converter must be registeredpublic final <S,T> void registerConverter(ConverterKey<S,T> key, Converter<S,T> converter)
registerConverter
in interface RegisterableBinder
S
- Source typeT
- Target typekey
- Converter Key to useconverter
- The Converter to be registeredpublic <S,T> T convertTo(Class<T> output, Object object)
convertTo
in interface ConversionBinder
S
- The Source typeT
- The Target typeoutput
- The target class to convert the object toobject
- The object to be convertedpublic <S,T> T convertTo(Class<T> output, Object object, Class<? extends Annotation> qualifier)
convertTo
in interface ConversionBinder
S
- The Source typeT
- The Target typeoutput
- The target class to convert the object toobject
- The object to be convertedqualifier
- The qualifier for which the binding must be registeredpublic <S,T> T convertTo(Class<S> input, Class<T> output, Object object)
convertTo
in interface ConversionBinder
S
- The Source typeT
- The Target typeinput
- The class of the object to be convertedoutput
- The target class to convert the object toobject
- The object to be convertedpublic <S,T> T convertTo(Class<S> input, Class<T> output, Object object, Class<? extends Annotation> qualifier)
convertTo
in interface ConversionBinder
S
- The Source typeT
- The Target typeinput
- The class of the object to be convertedoutput
- The target class to convert the object toobject
- The object to be convertedqualifier
- Match the converter with the given qualifierpublic <S,T> T convertTo(ConverterKey<S,T> key, Object object)
convertTo
in interface ConversionBinder
S
- The Source typeT
- The Target typekey
- The converter key to useobject
- The object to be convertedpublic <S,T> Binding<S,T> findBinding(Class<S> source, Class<T> target)
findBinding
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source (owning) classtarget
- The target (foreign) classpublic <S,T> ToMarshaller<S,T> findMarshaller(Class<S> source, Class<T> target)
findMarshaller
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source (input) classtarget
- The target (output) classpublic <S,T> Converter<S,T> findConverter(Class<S> input, Class<T> output)
findConverter
in interface SearchableBinder
S
- The Source typeT
- The Target typeinput
- The input classoutput
- The output classpublic <S,T> FromUnmarshaller<S,T> findUnmarshaller(Class<S> source, Class<T> target)
findUnmarshaller
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source (input) classtarget
- The target (output) classpublic <S,T> Binding<S,T> findBinding(Class<S> source, Class<T> target, Class<? extends Annotation> qualifier)
findBinding
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source (owning) classtarget
- The target (foreign) classqualifier
- The qualifier for which the binding must be registeredpublic <S,T> Binding<S,T> findBinding(ConverterKey<S,T> key)
findBinding
in interface SearchableBinder
S
- The Source typeT
- The Target typekey
- The key to look uppublic <S,T> ToMarshaller<S,T> findMarshaller(Class<S> source, Class<T> target, Class<? extends Annotation> qualifier)
findMarshaller
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source (input) classtarget
- The target (output) classqualifier
- The qualifier for which the marshaller must be registeredpublic <S,T> ToMarshaller<S,T> findMarshaller(ConverterKey<S,T> key)
findMarshaller
in interface SearchableBinder
S
- The Source typeT
- The Target typekey
- The key to look uppublic <S,T> Converter<S,T> findConverter(Class<S> source, Class<T> target, Class<? extends Annotation> qualifier)
findConverter
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source classtarget
- The target classqualifier
- The qualifier for which the marshaller must be registeredpublic <S,T> Converter<S,T> findConverter(ConverterKey<S,T> key)
findConverter
in interface SearchableBinder
S
- The Source typeT
- The Target typekey
- The key to look uppublic <S,T> FromUnmarshaller<S,T> findUnmarshaller(Class<S> source, Class<T> target, Class<? extends Annotation> qualifier)
findUnmarshaller
in interface SearchableBinder
S
- The Source typeT
- The Target typesource
- The source (input) classtarget
- The target (output) classqualifier
- The qualifier for which the unmarshaller must be registeredpublic <S,T> FromUnmarshaller<S,T> findUnmarshaller(ConverterKey<S,T> key)
findUnmarshaller
in interface SearchableBinder
S
- The Source typeT
- The Target typekey
- The key to look uppublic Iterable<ConverterKey<?,?>> getConverterEntries()
getConverterEntries
in interface RegisterableBinder
public <T> T convertFromString(Class<T> output, String object)
convertFromString
in interface StringBinder
T
- The type of the target classoutput
- The target class to convert the object toobject
- The String to be convertedpublic <T> T convertFromString(Class<T> output, String object, Class<? extends Annotation> qualifier)
StringBinder
convertFromString
in interface StringBinder
T
- The type of the target classoutput
- The target class to convert the object toobject
- The String to be convertedqualifier
- The qualifier for which the binding must be registeredpublic String convertToString(Object object)
StringBinder
convertToString
in interface StringBinder
object
- The object to be convertedpublic String convertToString(Object object, Class<? extends Annotation> qualifier)
StringBinder
convertToString
in interface StringBinder
object
- The object to be convertedqualifier
- The qualifier for which the binding must be registeredpublic <S> String convertToString(Class<S> input, Object object)
StringBinder
convertToString
in interface StringBinder
S
- The type of the input classinput
- The class of the object to be convertedobject
- The object to be convertedpublic <S> String convertToString(Class<S> input, Object object, Class<? extends Annotation> qualifier)
StringBinder
convertToString
in interface StringBinder
S
- The type of the input classinput
- The class of the object to be convertedobject
- The object to be convertedqualifier
- Match the converter with the given qualifierCopyright © 2010–2018 Jadira Systems. All rights reserved.