Top Fields Constructors Methods
org.osgi.util.converter

pack-priv Class ConvertingImpl

extends AbstractSpecifying<Converting>
implements Converting, InternalConverting
Class Inheritance
All Implemented Interfaces
org.osgi.util.converter.InternalConverting, org.osgi.util.converter.Converting, org.osgi.util.converter.Specifying
Imports
java.lang.annotation.Annotation, java.lang.invoke.MethodHandles, .MethodHandles.Lookup, .MethodType, java.lang.reflect.Array, .Constructor, .Field, .GenericArrayType, .InvocationHandler, .Method, .Modifier, .ParameterizedType, .Proxy, .Type, .TypeVariable, .WildcardType, java.util.ArrayList, .Arrays, .Collection, .Collections, .Deque, .Dictionary, .HashMap, .HashSet, .Hashtable, .Iterator, .LinkedHashMap, .LinkedHashSet, .LinkedList, .List, .Map, .Map.Entry, .NavigableMap, .NavigableSet, .Queue, .Set, .SortedMap, .SortedSet, .TreeMap, .TreeSet, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, .ConcurrentNavigableMap, .ConcurrentSkipListMap

Author
$Id: 4a493f8aa24f752c5dae3e191cb63cbafc439ff0 $

Field Summary

Modifier and TypeField and Description
private final InternalConverter
private static final Map<Class<?>, Class<?>>
private static final Collection<Class<?>>
private volatile Object
private volatile Class<?>
private volatile Class<?>
private volatile Type
private volatile Type[]
Inherited from org.osgi.util.converter.AbstractSpecifying:
defaultValuehasDefaultkeysIgnoreCaseliveViewsourceAsClasssourceAsDTOsourceAsJavaBeantargetAsClasstargetAsDTOtargetAsJavaBean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static void
private static Object
private Collection<?>
private Collection<?>
private Object
private Object
pack-priv Object
private Object
convertMapElement(Object element, int typeIdx, InternalConverter converter)

private Object
pack-priv Object
private Object
pack-priv Object
private <T> T
convertToArray(Class<?> componentClz, Type componentType, InternalConverter converter)

private <T> T
private Collection<?>
private <T> T
private Object
private <T> T
convertToDTO(Class<?> sourceCls, Class<?> targetAsCls, InternalConverter converter)

private Object
convertToInterface(Class<?> sourceCls, final Class<?> targetCls, InternalConverter converter)

private Object
convertToJavaBean(Class<?> sourceCls, Class<?> targetCls, InternalConverter converter)

private Map<K, V>
private Map<K, V>
private Object
private static Map<K, V>
private Map<K, V>
private static Map<K, V>
private static Object
createMapOrCollection(Class<?> cls, int initialSize)

private Object
createProxy(final Class<?> cls, final Map<?, ?> data, final InternalConverter converter)

private static Class<?>
private static Set<Class<?>>
private static Set<Class<?>>
private List<String>
getNames(Class<?> cls)

private Map<?, ?>
private static Set<Method>
getSetters(Class<?> cls)

private static void
handleBeanMethod(Object obj, Method md, Set<String> invokedMethods, Map<K, V> res)

private void
handleDTOField(Object obj, Field field, Set<String> handledFields, Map<K, V> result, InternalConverter converter)

private static void
handleInterfaceMethod(Object obj, Class<?> intf, Method md, Set<String> invokedMethods, Map<K, V> res)

private Object
handleNull(Class<?> cls, InternalConverter converter)

private boolean
private static boolean
private static boolean
isMapType(Class<?> cls, boolean asJavaBean, boolean asDTO)

private static boolean
private static boolean
private Map<?, ?>
mapView(Object obj, Class<?> sourceCls, InternalConverter converter)

pack-priv static Type
reifyType(Type typeToReify, Class<?> ownerClass, Type[] typeArgs)

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.

private Object
private <T> T
Inherited from org.osgi.util.converter.AbstractSpecifying:
defaultValuekeysIgnoreCasesourceAssourceAsBeansourceAsDTOtargetAstargetAsBeantargetAsDTOview

Field Detail

initialConverterback to summary
private final InternalConverter initialConverter
INTERFACE_IMPLSback to summary
private static final Map<Class<?>, Class<?>> INTERFACE_IMPLS
NO_MAP_VIEW_TYPESback to summary
private static final Collection<Class<?>> NO_MAP_VIEW_TYPES
objectback to summary
private volatile Object object
sourceClassback to summary
private volatile Class<?> sourceClass
targetClassback to summary
private volatile Class<?> targetClass
targetTypeback to summary
private volatile Type targetType
typeArgumentsback to summary
private volatile Type[] typeArguments

Constructor Detail

ConvertingImplback to summary
pack-priv ConvertingImpl(InternalConverter converter, Object obj)

Method Detail

addClassIfAvailableback to summary
private static void addClassIfAvailable(String cls, Collection<Class<?>> collection)
asBoxedArrayback to summary
private static Object asBoxedArray(Object obj)
asCollectionback to summary
private Collection<?> asCollection(InternalConverter converter)
collectionViewback to summary
private Collection<?> collectionView(InternalConverter converter)
convertArrayToSingleValueback to summary
private Object convertArrayToSingleValue(Class<?> cls, InternalConverter converter)
convertCollectionToSingleValueback to summary
private Object convertCollectionToSingleValue(Class<?> cls, InternalConverter converter)
convertCollectionValueback to summary
pack-priv Object convertCollectionValue(Object element, InternalConverter converter)
convertMapElementback to summary
private Object convertMapElement(Object element, int typeIdx, InternalConverter converter)
convertMapEntryToSingleValueback to summary
private Object convertMapEntryToSingleValue(Class<?> cls, InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes
convertMapKeyback to summary
pack-priv Object convertMapKey(Object key, InternalConverter converter)
convertMapToSingleValueback to summary
private Object convertMapToSingleValue(Class<?> cls, InternalConverter converter)
convertMapValueback to summary
pack-priv Object convertMapValue(Object value, InternalConverter converter)
convertToArrayback to summary
private <T> T convertToArray(Class<?> componentClz, Type componentType, InternalConverter converter)
Annotations
@SuppressWarnings:unchecked
convertToCollectionback to summary
private <T> T convertToCollection(InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes, unchecked
convertToCollectionDelegateback to summary
private Collection<?> convertToCollectionDelegate(InternalConverter converter)
convertToCollectionTypeback to summary
private <T> T convertToCollectionType(InternalConverter converter)
Annotations
@SuppressWarnings:unchecked
convertToDictionaryback to summary
private Object convertToDictionary(InternalConverter converter)
Annotations
@SuppressWarnings:unchecked, rawtypes
convertToDTOback to summary
private <T> T convertToDTO(Class<?> sourceCls, Class<?> targetAsCls, InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes, unchecked
convertToInterfaceback to summary
private Object convertToInterface(Class<?> sourceCls, final Class<?> targetCls, InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes
convertToJavaBeanback to summary
private Object convertToJavaBean(Class<?> sourceCls, Class<?> targetCls, InternalConverter converter)
convertToMapback to summary
private Map<K, V> convertToMap(InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes, unchecked
convertToMapDelegateback to summary
private Map<K, V> convertToMapDelegate(InternalConverter converter)
Annotations
@SuppressWarnings:unchecked, rawtypes
convertToMapTypeback to summary
private Object convertToMapType(InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes
createMapFromBeanAccessorsback to summary
private static Map<K, V> createMapFromBeanAccessors(Object obj, Class<?> sourceCls)
Annotations
@SuppressWarnings:rawtypes
createMapFromDTOback to summary
private Map<K, V> createMapFromDTO(Object obj, InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes
createMapFromInterfaceback to summary
private static Map<K, V> createMapFromInterface(Object obj, Class<?> srcCls)
Annotations
@SuppressWarnings:unchecked, rawtypes
createMapOrCollectionback to summary
private static Object createMapOrCollection(Class<?> cls, int initialSize)
createProxyback to summary
private Object createProxy(final Class<?> cls, final Map<?, ?> data, final InternalConverter converter)
getConstructableTypeback to summary
private static Class<?> getConstructableType(Class<?> targetCls)
getInterfacesback to summary
private static Set<Class<?>> getInterfaces(Class<?> cls)
getInterfaces0back to summary
private static Set<Class<?>> getInterfaces0(Class<?> cls)
getNamesback to summary
private List<String> getNames(Class<?> cls)
getPropertiesDelegateback to summary
private Map<?, ?> getPropertiesDelegate(Object obj, Class<?> cls, InternalConverter converter)
getSettersback to summary
private static Set<Method> getSetters(Class<?> cls)
handleBeanMethodback to summary
private static void handleBeanMethod(Object obj, Method md, Set<String> invokedMethods, Map<K, V> res)
Annotations
@SuppressWarnings:rawtypes, unchecked
handleDTOFieldback to summary
private void handleDTOField(Object obj, Field field, Set<String> handledFields, Map<K, V> result, InternalConverter converter)
Annotations
@SuppressWarnings:rawtypes, unchecked
handleInterfaceMethodback to summary
private static void handleInterfaceMethod(Object obj, Class<?> intf, Method md, Set<String> invokedMethods, Map<K, V> res)
Annotations
@SuppressWarnings:rawtypes, unchecked
handleNullback to summary
private Object handleNull(Class<?> cls, InternalConverter converter)
hasGetPropertiesback to summary
private boolean hasGetProperties(Class<?> cls)
isCopyRequiredTypeback to summary
private static boolean isCopyRequiredType(Class<?> cls)
isMapTypeback to summary
private static boolean isMapType(Class<?> cls, boolean asJavaBean, boolean asDTO)
isMarkerAnnotationback to summary
private static boolean isMarkerAnnotation(Class<?> annClass)
isWriteableJavaBeanback to summary
private static boolean isWriteableJavaBean(Class<?> cls)
mapViewback to summary
private Map<?, ?> mapView(Object obj, Class<?> sourceCls, InternalConverter converter)
reifyTypeback to summary
pack-priv static Type reifyType(Type typeToReify, Class<?> ownerClass, Type[] typeArgs)
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
trySpecialCasesback to summary
private Object trySpecialCases(InternalConverter converter)
tryStandardMethodsback to summary
private <T> T tryStandardMethods()
Annotations
@SuppressWarnings:unchecked