Module com.sun.xml.bind
Class Accessor<BeanT,ValueT>
- java.lang.Object
-
- org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor<BeanT,ValueT>
-
- All Implemented Interfaces:
Receiver
- Direct Known Subclasses:
Accessor.FieldReflection,Accessor.GetterSetterReflection,FieldAccessor_Boolean,FieldAccessor_Byte,FieldAccessor_Character,FieldAccessor_Double,FieldAccessor_Float,FieldAccessor_Integer,FieldAccessor_Long,FieldAccessor_Ref,FieldAccessor_Short,MethodAccessor_Boolean,MethodAccessor_Byte,MethodAccessor_Character,MethodAccessor_Double,MethodAccessor_Float,MethodAccessor_Integer,MethodAccessor_Long,MethodAccessor_Ref,MethodAccessor_Short,NullSafeAccessor
public abstract class Accessor<BeanT,ValueT> extends Object implements Receiver
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 (kk@kohsuke.org)
- See Also:
Accessor.FieldReflection,TransducedAccessor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAccessor.FieldReflection<BeanT,ValueT>Accessorthat uses Java reflection to access a field.static classAccessor.GetterOnlyReflection<BeanT,ValueT>A version ofAccessor.GetterSetterReflectionthat doesn't have any setter.static classAccessor.GetterSetterReflection<BeanT,ValueT>Accessorthat uses Java reflection to access a getter and a setter.static classAccessor.ReadOnlyFieldReflection<BeanT,ValueT>Read-only access toField.static classAccessor.SetterOnlyReflection<BeanT,ValueT>A version ofAccessor.GetterSetterReflectionthaat doesn't have any getter.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> Accessor<BeanT,T>adapt(Class<T> targetType, Class<? extends jakarta.xml.bind.annotation.adapters.XmlAdapter<T,ValueT>> adapter)<T> Accessor<BeanT,T>adapt(Adapter<Type,Class> adapter)abstract ValueTget(BeanT bean)Gets the value of the property of the given bean object.static <A,B>
Accessor<A,B>getErrorInstance()Gets the specialAccessorused to recover from errors.ObjectgetUnadapted(BeanT bean)Sets the value without adapting the value.Class<ValueT>getValueType()booleanisAbstractable(Class clazz)Checks if it is not builtin jaxb classbooleanisAdapted()Returns true if this accessor wraps an adapter.booleanisValueTypeAbstractable()Accessor<BeanT,ValueT>optimize(JAXBContextImpl context)Returns the optimized version of the same accessor.voidreceive(UnmarshallingContext.State state, Object o)Called when the child loader is deactivated.abstract voidset(BeanT bean, ValueT value)Sets the value of the property of the given bean object.voidsetUnadapted(BeanT bean, Object value)Sets the value without adapting the value.
-
-
-
Method Detail
-
optimize
public Accessor<BeanT,ValueT> optimize(@Nullable JAXBContextImpl context)
Returns the optimized version of the same accessor.- Parameters:
context- TheJAXBContextImplthat owns the whole thing. (SeeRuntimeModelBuilder.context.)- Returns:
- At least the implementation can return
this.
-
get
public abstract ValueT get(BeanT bean) throws AccessorException
Gets the value of the property of the given bean object.- Parameters:
bean- must not be null.- Throws:
AccessorException- if failed to set a value. For example, the getter method may throw an exception.- Since:
- 2.0 EA1
-
set
public abstract void set(BeanT bean, ValueT value) throws AccessorException
Sets the value of the property of the given bean object.- Parameters:
bean- must not be null.value- the value to be set. Setting value to null means resetting to the VM default value (even for primitive properties.)- Throws:
AccessorException- if failed to set a value. For example, the setter method may throw an exception.- Since:
- 2.0 EA1
-
getUnadapted
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(java.lang.Class<B>, java.lang.String, java.lang.String)- Throws:
AccessorException
-
isAdapted
public boolean isAdapted()
Returns true if this accessor wraps an adapter.This method needs to be used with care, but it helps some optimization.
-
setUnadapted
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(java.lang.Class<B>, java.lang.String, java.lang.String)- Throws:
AccessorException
-
receive
public void receive(UnmarshallingContext.State state, Object o) throws SAXException
Description copied from interface:ReceiverCalled when the child loader is deactivated.- Specified by:
receivein interfaceReceiver- Parameters:
state- points to the parent's current state.o- object that was loaded. may be null.- Throws:
SAXException
-
isValueTypeAbstractable
public boolean isValueTypeAbstractable()
-
isAbstractable
public boolean isAbstractable(Class clazz)
Checks if it is not builtin jaxb class- Parameters:
clazz- to be checked- Returns:
- true if it is NOT builtin class
-
adapt
public final <T> Accessor<BeanT,T> adapt(Class<T> targetType, Class<? extends jakarta.xml.bind.annotation.adapters.XmlAdapter<T,ValueT>> adapter)
-
-