Top Description Inners Fields Constructors Methods
com.thoughtworks.xstream.converters.reflection

public Class PureJavaReflectionProvider

extends Object
implements ReflectionProvider
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.converters.reflection.ReflectionProvider
Known Direct Subclasses
com.thoughtworks.xstream.converters.reflection.SunLimitedUnsafeReflectionProvider
Imports
com.thoughtworks.xstream.converters.ConversionException, .ErrorWritingException, .ConversionException, .ErrorWritingException, com.thoughtworks.xstream.core.JVM, com.thoughtworks.xstream.core.util.Fields, .Fields, java.io.ByteArrayInputStream, .ByteArrayOutputStream, .DataOutputStream, .IOException, .ObjectInputStream, .ObjectStreamClass, .ObjectStreamConstants, .Serializable, java.lang.reflect.Constructor, .Field, .InvocationTargetException, .Method, .Modifier, java.util.Iterator, .Map, .WeakHashMap

Pure Java ObjectFactory that instantiates objects using standard Java reflection, however the types of objects that can be constructed are limited.

Can newInstance: classes with public visibility, outer classes, static inner classes, classes with default constructors and any class that implements java.io.Serializable.

Cannot newInstance: classes without public visibility, non-static inner classes, classes without default constructors. Note that any code in the constructor of a class will be executed when the ObjectFactory instantiates the object.

Author
Joe Walnes

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
protected FieldDictionary
private transient Map<K, V>
private transient Map<K, V>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
protected boolean
public Field
getField(Class<T>
class where the field was defined
definedIn
,
String
field name
fieldName
)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getField.

Returns a field defined in some class.
public Field
getFieldOrNull(Class<T>
class where the field was defined
definedIn
,
String
field name
fieldName
)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getFieldOrNull.

Returns a field defined in some class.
public Class<T>
protected void
init()

private Object
public Object
newInstance(Class<T>
the type to instantiate
type
)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.newInstance.

Creates a new instance of the specified type.
private Object
public void
protected void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fieldDictionaryback to summary
protected FieldDictionary fieldDictionary
objectStreamClassCacheback to summary
private transient Map<K, V> objectStreamClassCache
serializedDataCacheback to summary
private transient Map<K, V> serializedDataCache

Constructor Detail

PureJavaReflectionProviderback to summary
public PureJavaReflectionProvider()
PureJavaReflectionProviderback to summary
public PureJavaReflectionProvider(FieldDictionary fieldDictionary)

Method Detail

fieldDefinedInClassback to summary
public boolean fieldDefinedInClass(String fieldName, Class<T> type)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.fieldDefinedInClass.

Deprecated

As of 1.4.5, use getFieldOrNull(Class, String) instead

fieldModifiersSupportedback to summary
protected boolean fieldModifiersSupported(Field field)
getFieldback to summary
public Field getField(Class<T> definedIn, String fieldName)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getField.

Doc from com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getField.

Returns a field defined in some class.

Parameters
definedIn:Class<T>

class where the field was defined

fieldName:String

field name

Returns:Field

the field itself

getFieldOrNullback to summary
public Field getFieldOrNull(Class<T> definedIn, String fieldName)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getFieldOrNull.

Doc from com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getFieldOrNull.

Returns a field defined in some class.

Parameters
definedIn:Class<T>

class where the field was defined

fieldName:String

field name

Returns:Field

the field itself or null

getFieldTypeback to summary
public Class<T> getFieldType(Object object, String fieldName, Class<T> definedIn)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.getFieldType.

initback to summary
protected void init()
instantiateUsingSerializationback to summary
private Object instantiateUsingSerialization(final Class<T> type)
newInstanceback to summary
public Object newInstance(Class<T> type)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.newInstance.

Doc from com.thoughtworks.xstream.converters.reflection.ReflectionProvider.newInstance.

Creates a new instance of the specified type. It is in the responsibility of the implementation how such an instance is created.

Parameters
type:Class<T>

the type to instantiate

Returns:Object

a new instance of this type

readResolveback to summary
private Object readResolve()
setFieldDictionaryback to summary
public void setFieldDictionary(FieldDictionary dictionary)
validateFieldAccessback to summary
protected void validateFieldAccess(Field field)
visitSerializableFieldsback to summary
public void visitSerializableFields(Object object, ReflectionProvider.Visitor visitor)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.visitSerializableFields.

writeFieldback to summary
public void writeField(Object object, String fieldName, Object value, Class<T> definedIn)

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.writeField.

com.thoughtworks.xstream.converters.reflection back to summary

private Class PureJavaReflectionProvider.Reflections

extends Object
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.Reflections

Field Summary

Modifier and TypeField and Description
private static final Method

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

newInstanceback to summary
private static final Method newInstance

Constructor Detail

Reflectionsback to summary
private Reflections()