Top Description Inners Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime.reflect

public abstract Class Accessor<BeanT, ValueT>

extends Object
implements Receiver
Class Inheritance
All Implemented Interfaces
org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Receiver
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection, org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection, org.glassfish.jaxb.runtime.v2.runtime.reflect.AdaptedAccessor, org.glassfish.jaxb.runtime.v2.runtime.reflect.NullSafeAccessor, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Character, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Boolean, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Byte, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Character, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Double, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Float, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Integer, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Long, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Ref, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.FieldAccessor_Short, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Boolean, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Byte, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Double, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Float, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Integer, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Long, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Ref, org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.MethodAccessor_Short
Imports
com.sun.istack.Nullable, org.glassfish.jaxb.runtime.api.AccessorException, .JAXBRIContext, org.glassfish.jaxb.core.v2.model.core.Adapter, org.glassfish.jaxb.runtime.v2.model.impl.RuntimeModelBuilder, org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl, org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Loader, .Receiver, .UnmarshallingContext, jakarta.xml.bind.JAXBElement, jakarta.xml.bind.annotation.adapters.XmlAdapter, org.xml.sax.SAXException, java.lang.reflect.*, java.util.Arrays, .HashMap, .List, .Map, java.util.logging.Level, .Logger

Accesses a particular property of a bean.

This interface encapsulates the access to the actual data store. The intention is to generate implementations for a particular bean and a property to improve the performance.

Accessor can be used as a receiver. Upon receiving an object it sets that to the field.

Author
Kohsuke Kawaguchi ([email protected])
See Also
Accessor.FieldReflection, TransducedAccessor

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Accessor.FieldReflection<BeanT, ValueT>

Accessor that uses Java reflection to access a field.

public static class
Accessor.GetterOnlyReflection<BeanT, ValueT>

A version of GetterSetterReflection that doesn't have any setter.

public static class
Accessor.GetterSetterReflection<BeanT, ValueT>

Accessor that uses Java reflection to access a getter and a setter.

public static class
Accessor.ReadOnlyFieldReflection<BeanT, ValueT>

Read-only access to Field.

public static class
Accessor.SetterOnlyReflection<BeanT, ValueT>

A version of GetterSetterReflection thaat doesn't have any getter.

Field Summary

Modifier and TypeField and Description
private static boolean
accessWarned

Flag that will be set to true after issueing a warning about the lack of permission to access non-public fields.

private static final Accessor<BeanT, ValueT>
public static final Accessor<JAXBElement<T>, Object>
private static List<Class<T>>
private static final Map<Class<?>, Object>
uninitializedValues

Uninitialized map keyed by their classes.

public final Class<ValueT>

Constructor Summary

AccessConstructor and Description
protected
Accessor(Class<ValueT> valueType)

Method Summary

Modifier and TypeMethod and Description
public final <T> Accessor<BeanT, T>
adapt(Class<T> targetType, final Class<? extends XmlAdapter<T, ValueT>> adapter)

Wraps this into another and performs the type adaption as necessary.

public final <T> Accessor<BeanT, T>
adapt(Adapter<Type, Class<T>> adapter)

public abstract ValueT
get(BeanT
must not be null.
bean
)

Gets the value of the property of the given bean object.

public static <A, B> Accessor<A, B>
getErrorInstance()

Gets the special used to recover from errors.

public Object
getUnadapted(BeanT bean)

Sets the value without adapting the value.

public Class<ValueT>
public boolean

Returns:

true if it is NOT builtin class
isAbstractable
(Class<T>
to be checked
clazz
)

Checks if it is not builtin jaxb class

public boolean
isAdapted()

Returns true if this accessor wraps an adapter.

public boolean
public Accessor<BeanT, ValueT>

Returns:

At least the implementation can return this.
optimize
(JAXBContextImpl
The JAXBContextImpl that owns the whole thing. (See RuntimeModelBuilder#context.)
context
)

Returns the optimized version of the same accessor.

public void
receive(UnmarshallingContext.State state, Object o)

Implements org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Receiver.receive.

Called when the child loader is deactivated.

public abstract void
set(BeanT
must not be null.
bean
,
ValueT
the value to be set. Setting value to null means resetting to the VM default value (even for primitive properties.)
value
)

Sets the value of the property of the given bean object.

public void
setUnadapted(BeanT bean, Object value)

Sets the value without adapting the value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessWarnedback to summary
private static boolean accessWarned

Flag that will be set to true after issueing a warning about the lack of permission to access non-public fields.

ERRORback to summary
private static final Accessor<BeanT, ValueT> ERROR
JAXB_ELEMENT_VALUEback to summary
public static final Accessor<JAXBElement<T>, Object> JAXB_ELEMENT_VALUE

Accessor for JAXBElement#getValue().

nonAbstractableClassesback to summary
private static List<Class<T>> nonAbstractableClasses
uninitializedValuesback to summary
private static final Map<Class<?>, Object> uninitializedValues

Uninitialized map keyed by their classes.

valueTypeback to summary
public final Class<ValueT> valueType

Constructor Detail

Accessorback to summary
protected Accessor(Class<ValueT> valueType)

Method Detail

adaptback to summary
public final <T> Accessor<BeanT, T> adapt(Class<T> targetType, final Class<? extends XmlAdapter<T, ValueT>> adapter)

Wraps this into another and performs the type adaption as necessary.

adaptback to summary
public final <T> Accessor<BeanT, T> adapt(Adapter<Type, Class<T>> adapter)
Annotations
@SuppressWarnings:unchecked
getback to summary
public abstract ValueT get(BeanT bean) throws AccessorException

Gets the value of the property of the given bean object.

Parameters
bean:BeanT

must not be null.

Exceptions
AccessorException:
if failed to set a value. For example, the getter method may throw an exception.
Since
2.0 EA1
getErrorInstanceback to summary
public static <A, B> Accessor<A, B> getErrorInstance()

Gets the special used to recover from errors.

Annotations
@SuppressWarnings:unchecked
getUnadaptedback to summary
public Object getUnadapted(BeanT bean) throws AccessorException

Sets the value without adapting the value.

This ugly entry point is only used by JAX-WS. See JAXBRIContext#getElementPropertyAccessor

getValueTypeback to summary
public Class<ValueT> getValueType()
isAbstractableback to summary
public boolean isAbstractable(Class<T> clazz)

Checks if it is not builtin jaxb class

Parameters
clazz:Class<T>

to be checked

Returns:boolean

true if it is NOT builtin class

isAdaptedback to summary
public boolean isAdapted()

Returns true if this accessor wraps an adapter.

This method needs to be used with care, but it helps some optimization.

isValueTypeAbstractableback to summary
public boolean isValueTypeAbstractable()
optimizeback to summary
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context)

Returns the optimized version of the same accessor.

Parameters
context:JAXBContextImpl

The JAXBContextImpl that owns the whole thing. (See RuntimeModelBuilder#context.)

Returns:Accessor<BeanT, ValueT>

At least the implementation can return this.

receiveback to summary
public void receive(UnmarshallingContext.State state, Object o) throws SAXException

Implements org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Receiver.receive.

Doc from org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Receiver.receive.

Called when the child loader is deactivated.

Annotations
@Override
@SuppressWarnings:unchecked
setback to summary
public abstract void set(BeanT bean, ValueT value) throws AccessorException

Sets the value of the property of the given bean object.

Parameters
bean:BeanT

must not be null.

value:ValueT

the value to be set. Setting value to null means resetting to the VM default value (even for primitive properties.)

Exceptions
AccessorException:
if failed to set a value. For example, the setter method may throw an exception.
Since
2.0 EA1
setUnadaptedback to summary
public void setUnadapted(BeanT bean, Object value) throws AccessorException

Sets the value without adapting the value.

This ugly entry point is only used by JAX-WS. See JAXBRIContext#getElementPropertyAccessor

Annotations
@SuppressWarnings:unchecked
org.glassfish.jaxb.runtime.v2.runtime.reflect back to summary

public Class Accessor.FieldReflection<BeanT, ValueT>

extends Accessor<BeanT, ValueT>
Class Inheritance
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.ReadOnlyFieldReflection

Accessor that uses Java reflection to access a field.

Field Summary

Modifier and TypeField and Description
public final Field
f

private static final Logger
Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor:
JAXB_ELEMENT_VALUEvalueType

Constructor Summary

AccessConstructor and Description
public
public
FieldReflection(Field f, boolean supressAccessorWarnings)

Method Summary

Modifier and TypeMethod and Description
public ValueT
get(BeanT bean)

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Gets the value of the property of the given bean object.

public Accessor<BeanT, ValueT>
optimize(JAXBContextImpl context)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Returns the optimized version of the same accessor.

public void
set(BeanT bean, ValueT value)

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Sets the value of the property of the given bean object.

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor:
adaptadaptgetErrorInstancegetUnadaptedgetValueTypeisAbstractableisAdaptedisValueTypeAbstractablereceivesetUnadapted

Field Detail

fback to summary
public final Field f
loggerback to summary
private static final Logger logger

Constructor Detail

FieldReflectionback to summary
public FieldReflection(Field f)
FieldReflectionback to summary
public FieldReflection(Field f, boolean supressAccessorWarnings)
Annotations
@SuppressWarnings:unchecked

Method Detail

getback to summary
public ValueT get(BeanT bean)

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Gets the value of the property of the given bean object.

Annotations
@Override
@SuppressWarnings:unchecked
optimizeback to summary
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Returns the optimized version of the same accessor.

Annotations
@Override
setback to summary
public void set(BeanT bean, ValueT value)

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Sets the value of the property of the given bean object.

Annotations
@Override
@SuppressWarnings:unchecked
org.glassfish.jaxb.runtime.v2.runtime.reflect back to summary

public Class Accessor.GetterOnlyReflection<BeanT, ValueT>

extends Accessor.GetterSetterReflection<BeanT, ValueT>
Class Inheritance

A version of GetterSetterReflection that doesn't have any setter.

This provides a user-friendly error message.

Field Summary

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection:
gettersetter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
set(BeanT bean, ValueT value)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection.set.

Sets the value of the property of the given bean object.

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection:
getoptimize

Constructor Detail

GetterOnlyReflectionback to summary
public GetterOnlyReflection(Method getter)

Method Detail

setback to summary
public void set(BeanT bean, ValueT value) throws AccessorException

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection.set.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Sets the value of the property of the given bean object.

Annotations
@Override
Exceptions
AccessorException:
if failed to set a value. For example, the setter method may throw an exception.
org.glassfish.jaxb.runtime.v2.runtime.reflect back to summary

public Class Accessor.GetterSetterReflection<BeanT, ValueT>

extends Accessor<BeanT, ValueT>
Class Inheritance
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterOnlyReflection, org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.SetterOnlyReflection

Accessor that uses Java reflection to access a getter and a setter.

Field Summary

Modifier and TypeField and Description
public final Method
private static final Logger
public final Method
Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor:
JAXB_ELEMENT_VALUEvalueType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ValueT
get(BeanT bean)

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Gets the value of the property of the given bean object.

private AccessorException
private void
public Accessor<BeanT, ValueT>
optimize(JAXBContextImpl context)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Returns the optimized version of the same accessor.

public void
set(BeanT bean, ValueT value)

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Sets the value of the property of the given bean object.

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor:
adaptadaptgetErrorInstancegetUnadaptedgetValueTypeisAbstractableisAdaptedisValueTypeAbstractablereceivesetUnadapted

Field Detail

getterback to summary
public final Method getter
loggerback to summary
private static final Logger logger
setterback to summary
public final Method setter

Constructor Detail

GetterSetterReflectionback to summary
public GetterSetterReflection(Method getter, Method setter)
Annotations
@SuppressWarnings:unchecked

Method Detail

getback to summary
public ValueT get(BeanT bean) throws AccessorException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Gets the value of the property of the given bean object.

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
AccessorException:
if failed to set a value. For example, the getter method may throw an exception.
handleInvocationTargetExceptionback to summary
private AccessorException handleInvocationTargetException(InvocationTargetException e)
makeAccessibleback to summary
private void makeAccessible(Method m)
optimizeback to summary
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Returns the optimized version of the same accessor.

Annotations
@Override
setback to summary
public void set(BeanT bean, ValueT value) throws AccessorException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Sets the value of the property of the given bean object.

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
AccessorException:
if failed to set a value. For example, the setter method may throw an exception.
org.glassfish.jaxb.runtime.v2.runtime.reflect back to summary

public final Class Accessor.ReadOnlyFieldReflection<BeanT, ValueT>

extends Accessor.FieldReflection<BeanT, ValueT>
Class Inheritance

Read-only access to Field. Used to handle a static field.

Field Summary

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection:
f

Constructor Summary

AccessConstructor and Description
public
ReadOnlyFieldReflection(Field f, boolean supressAccessorWarnings)

public

Method Summary

Modifier and TypeMethod and Description
public Accessor<BeanT, ValueT>
optimize(JAXBContextImpl context)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection.optimize.

Returns the optimized version of the same accessor.

public void
set(BeanT bean, ValueT value)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection.set.

Sets the value of the property of the given bean object.

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection:
get

Constructor Detail

ReadOnlyFieldReflectionback to summary
public ReadOnlyFieldReflection(Field f, boolean supressAccessorWarnings)
ReadOnlyFieldReflectionback to summary
public ReadOnlyFieldReflection(Field f)

Method Detail

optimizeback to summary
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection.optimize.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.optimize.

Returns the optimized version of the same accessor.

Annotations
@Override
setback to summary
public void set(BeanT bean, ValueT value)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.FieldReflection.set.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.set.

Sets the value of the property of the given bean object.

Annotations
@Override
org.glassfish.jaxb.runtime.v2.runtime.reflect back to summary

public Class Accessor.SetterOnlyReflection<BeanT, ValueT>

extends Accessor.GetterSetterReflection<BeanT, ValueT>
Class Inheritance

A version of GetterSetterReflection thaat doesn't have any getter.

This provides a user-friendly error message.

Field Summary

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection:
gettersetter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ValueT
get(BeanT bean)

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection.get.

Gets the value of the property of the given bean object.

Inherited from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection:
optimizeset

Constructor Detail

SetterOnlyReflectionback to summary
public SetterOnlyReflection(Method setter)

Method Detail

getback to summary
public ValueT get(BeanT bean) throws AccessorException

Overrides org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.GetterSetterReflection.get.

Doc from org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor.get.

Gets the value of the property of the given bean object.

Annotations
@Override
Exceptions
AccessorException:
if failed to set a value. For example, the getter method may throw an exception.