Top Description Inners Fields Constructors Methods
org.osgi.util.converter

pack-priv Class CustomConverterImpl

extends Object
implements InternalConverter
Class Inheritance
All Implemented Interfaces
org.osgi.util.converter.InternalConverter, org.osgi.util.converter.Converter
Imports
java.lang.reflect.InvocationHandler, .Method, .Proxy, .Type, java.util.ArrayList, .Collections, .List, .Map

A custom converter wraps another converter by adding rules and/or error handlers.
Author
$Id: 74ee937304bad6209dc924fc8b0d943754910961 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
pack-priv final List<ConverterFunction>
pack-priv final InternalConverter
pack-priv final List<ConverterFunction>
pack-priv final Map<Type, List<ConverterFunction>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public InternalConverting
convert(Object
The object that should be converted.
obj
)

Implements org.osgi.util.converter.InternalConverter.convert.

Start a conversion for the given object.

public Functioning
function()

Implements org.osgi.util.converter.Converter.function.

Start defining a function that can perform given conversions.

public ConverterBuilder
newConverterBuilder()

Implements org.osgi.util.converter.Converter.newConverterBuilder.

Obtain a builder to create a modified converter based on this converter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allRulesback to summary
pack-priv final List<ConverterFunction> allRules
delegateback to summary
pack-priv final InternalConverter delegate
errorHandlersback to summary
pack-priv final List<ConverterFunction> errorHandlers
typeRulesback to summary
pack-priv final Map<Type, List<ConverterFunction>> typeRules

Constructor Detail

CustomConverterImplback to summary
pack-priv CustomConverterImpl(InternalConverter converter, Map<Type, List<ConverterFunction>> rules, List<ConverterFunction> catchAllRules, List<ConverterFunction> errHandlers)

Method Detail

convertback to summary
public InternalConverting convert(Object obj)

Implements org.osgi.util.converter.InternalConverter.convert.

Doc from org.osgi.util.converter.Converter.convert.

Start a conversion for the given object.

Parameters
obj:Object

The object that should be converted.

Returns:InternalConverting

A Converting object to complete the conversion.

Annotations
@Override
functionback to summary
public Functioning function()

Implements org.osgi.util.converter.Converter.function.

Doc from org.osgi.util.converter.Converter.function.

Start defining a function that can perform given conversions.

Returns:Functioning

A Functioning object to complete the definition.

Annotations
@Override
newConverterBuilderback to summary
public ConverterBuilder newConverterBuilder()

Implements org.osgi.util.converter.Converter.newConverterBuilder.

Doc from org.osgi.util.converter.Converter.newConverterBuilder.

Obtain a builder to create a modified converter based on this converter. For more details see the ConverterBuilder interface.

Returns:ConverterBuilder

A new Converter Builder.

Annotations
@Override
org.osgi.util.converter back to summary

private Class CustomConverterImpl.ConvertingWrapper

extends Object
implements InternalConverting
Class Inheritance
  • java.lang.Object
  • org.osgi.util.converter.CustomConverterImpl.ConvertingWrapper
All Implemented Interfaces
org.osgi.util.converter.InternalConverting, org.osgi.util.converter.Converting, org.osgi.util.converter.Specifying

Field Summary

Modifier and TypeField and Description
private volatile Object
private final InternalConverting
private volatile boolean
private final InternalConverter
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Converting
defaultValue(Object
The default value.
defVal
)

Implements org.osgi.util.converter.Specifying.defaultValue.

The default value to use when the object cannot be converted or in case of conversion from a null value.

pack-priv List<ConverterFunction>
public Converting
keysIgnoreCase()

Implements org.osgi.util.converter.Specifying.keysIgnoreCase.

When converting between map-like types use case-insensitive mapping of keys.

public Converting
sourceAs(Class<?>
The class to treat the object as.
type
)

Implements org.osgi.util.converter.Specifying.sourceAs.

Treat the source object as the specified class.

public Converting
sourceAsBean()

Implements org.osgi.util.converter.Specifying.sourceAsBean.

Treat the source object as a JavaBean.

public Converting
sourceAsDTO()

Implements org.osgi.util.converter.Specifying.sourceAsDTO.

Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.

public Converting
targetAs(Class<?>
The class to treat the object as.
cls
)

Implements org.osgi.util.converter.Specifying.targetAs.

Treat the target object as the specified class.

public Converting
targetAsBean()

Implements org.osgi.util.converter.Specifying.targetAsBean.

Treat the target object as a JavaBean.

public Converting
targetAsDTO()

Implements org.osgi.util.converter.Specifying.targetAsDTO.

Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.

public <T> T
to(Class<T>
The class to convert to.
cls
)

Implements org.osgi.util.converter.Converting.to.

Specify the target object type for the conversion as a class object.

public <T> T
to(TypeReference<T>
A type reference to the object being converted to.
ref
)

Implements org.osgi.util.converter.Converting.to.

Specify the target object type as a TypeReference.

public <T> T
to(Type
A Type object to represent the target type to be converted to.
type
)

Implements org.osgi.util.converter.Converting.to.

Specify the target object type as a Java Reflection Type object.

public <T> T
to(Type
A Type object to represent the target type to be converted to.
type
,
InternalConverter
Internal converter
converter
)

Implements org.osgi.util.converter.InternalConverting.to.

Invoke the conversion while passing the top-level converter.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Converting
view()

Implements org.osgi.util.converter.Specifying.view.

Return a live view over the backing object that reflects any changes to the original object.

private Object
wrapErrorHandling(final Object wrapped, final InternalConverter converter)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

defaultValueback to summary
private volatile Object defaultValue
delback to summary
private final InternalConverting del
hasDefaultback to summary
private volatile boolean hasDefault
initialConverterback to summary
private final InternalConverter initialConverter
objectback to summary
private final Object object

Constructor Detail

ConvertingWrapperback to summary
pack-priv ConvertingWrapper(Object obj, InternalConverting delegate, InternalConverter converter)

Method Detail

defaultValueback to summary
public Converting defaultValue(Object defVal)

Implements org.osgi.util.converter.Specifying.defaultValue.

Doc from org.osgi.util.converter.Specifying.defaultValue.

The default value to use when the object cannot be converted or in case of conversion from a null value.

Parameters
defVal:Object

The default value.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
getErrorHandlersback to summary
pack-priv List<ConverterFunction> getErrorHandlers(Converter converter)
keysIgnoreCaseback to summary
public Converting keysIgnoreCase()

Implements org.osgi.util.converter.Specifying.keysIgnoreCase.

Doc from org.osgi.util.converter.Specifying.keysIgnoreCase.

When converting between map-like types use case-insensitive mapping of keys.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
sourceAsback to summary
public Converting sourceAs(Class<?> type)

Implements org.osgi.util.converter.Specifying.sourceAs.

Doc from org.osgi.util.converter.Specifying.sourceAs.

Treat the source object as the specified class. This can be used to disambiguate a type if it implements multiple interfaces or extends multiple classes.

Parameters
type:Class<?>

The class to treat the object as.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
sourceAsBeanback to summary
public Converting sourceAsBean()

Implements org.osgi.util.converter.Specifying.sourceAsBean.

Doc from org.osgi.util.converter.Specifying.sourceAsBean.

Treat the source object as a JavaBean. By default objects will not be treated as JavaBeans, this has to be specified using this method.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
sourceAsDTOback to summary
public Converting sourceAsDTO()

Implements org.osgi.util.converter.Specifying.sourceAsDTO.

Doc from org.osgi.util.converter.Specifying.sourceAsDTO.

Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
targetAsback to summary
public Converting targetAs(Class<?> cls)

Implements org.osgi.util.converter.Specifying.targetAs.

Doc from org.osgi.util.converter.Specifying.targetAs.

Treat the target object as the specified class. This can be used to disambiguate a type if it implements multiple interfaces or extends multiple classes.

Parameters
cls:Class<?>

The class to treat the object as.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
targetAsBeanback to summary
public Converting targetAsBean()

Implements org.osgi.util.converter.Specifying.targetAsBean.

Doc from org.osgi.util.converter.Specifying.targetAsBean.

Treat the target object as a JavaBean. By default objects will not be treated as JavaBeans, this has to be specified using this method.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
targetAsDTOback to summary
public Converting targetAsDTO()

Implements org.osgi.util.converter.Specifying.targetAsDTO.

Doc from org.osgi.util.converter.Specifying.targetAsDTO.

Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
toback to summary
public <T> T to(Class<T> cls)

Implements org.osgi.util.converter.Converting.to.

Doc from org.osgi.util.converter.Converting.to.

Specify the target object type for the conversion as a class object.

Parameters
<T>
The type to convert to.
cls:Class<T>

The class to convert to.

Returns:T

The converted object.

Annotations
@Override
toback to summary
public <T> T to(TypeReference<T> ref)

Implements org.osgi.util.converter.Converting.to.

Doc from org.osgi.util.converter.Converting.to.

Specify the target object type as a TypeReference. If the target class carries generics information a TypeReference should be used as this preserves the generic information whereas a Class object has this information erased. Example use:

List<String> result = converter.convert(Arrays.asList(1, 2, 3))
		.to(new TypeReference<List<String>>() {
		});
Parameters
<T>
The type to convert to.
ref:TypeReference<T>

A type reference to the object being converted to.

Returns:T

The converted object.

Annotations
@Override
toback to summary
public <T> T to(Type type)

Implements org.osgi.util.converter.Converting.to.

Doc from org.osgi.util.converter.Converting.to.

Specify the target object type as a Java Reflection Type object.

Parameters
<T>
The type to convert to.
type:Type

A Type object to represent the target type to be converted to.

Returns:T

The converted object.

Annotations
@Override
toback to summary
public <T> T to(Type type, InternalConverter converter)

Implements org.osgi.util.converter.InternalConverting.to.

Doc from org.osgi.util.converter.InternalConverting.to.

Invoke the conversion while passing the top-level converter. The top-level converter is needed when performing embedded conversions such as in map elements. When using a custom converter, the top converter must be used for this.

Parameters
<T>
The type to convert to.
type:Type

A Type object to represent the target type to be converted to.

converter:InternalConverter

Internal converter

Returns:T

The converted object.

Annotations
@SuppressWarnings:unchecked
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
viewback to summary
public Converting view()

Implements org.osgi.util.converter.Specifying.view.

Doc from org.osgi.util.converter.Specifying.view.

Return a live view over the backing object that reflects any changes to the original object. This is only possible with conversions to java.util.Map, java.util.Collection, java.util.List and java.util.Set. The live view object will cease to be live as soon as modifications are made to it. Note that conversions to an interface or annotation will always produce a live view that cannot be modified. This modifier has no effect with conversions to other types.

Returns:Converting

The current Converting object so that additional calls can be chained.

Annotations
@Override
wrapErrorHandlingback to summary
private Object wrapErrorHandling(final Object wrapped, final InternalConverter converter)