org.dynalang.mop.beans
Class ArrayMetaobjectProtocol<T>

java.lang.Object
  extended by org.dynalang.mop.beans.BeanMetaobjectProtocol<T>
      extended by org.dynalang.mop.beans.ArrayMetaobjectProtocol<T>
Type Parameters:
T - the class of the array
All Implemented Interfaces:
BaseMetaobjectProtocol, CallProtocol, MetaobjectProtocol

public class ArrayMetaobjectProtocol<T>
extends BeanMetaobjectProtocol<T>

Adds access to array elements by numeric index as well as the "length" read-only property to BeanMetaobjectProtocol.

Version:
$Id: $
Author:
Attila Szegedi

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.dynalang.mop.BaseMetaobjectProtocol
BaseMetaobjectProtocol.Result
 
Constructor Summary
ArrayMetaobjectProtocol(java.lang.Class<T> clazz, boolean methodsEnumerable)
          Constructs a new metaobject protocol for objects of a certain array class.
 
Method Summary
 java.lang.Object get(java.lang.Object target, long propertyId)
          Behaves as CallProtocol.get(Object, Object) with an integer property ID.
 java.lang.Object get(java.lang.Object target, java.lang.Object propertyId)
          Retrieves the property value from the target object.
 java.lang.Boolean has(java.lang.Object target, long propertyId)
          Behaves as BaseMetaobjectProtocol.has(Object, Object) with an integer property ID.
 java.lang.Boolean has(java.lang.Object target, java.lang.Object propertyId)
          Tells whether the target object has a particular property.
 java.util.Iterator<java.lang.Object> propertyIds(java.lang.Object target)
          Returns an iterator over the property IDs in the target object this MOP knows about (and chooses to expose - not all properties must be exposed; hidden properties are allowed).
 BaseMetaobjectProtocol.Result put(java.lang.Object target, long propertyId, java.lang.Object value, CallProtocol callProtocol)
          Behaves as BaseMetaobjectProtocol.put(Object, Object, Object,CallProtocol) with an integer property ID.
 BaseMetaobjectProtocol.Result put(java.lang.Object target, java.lang.Object propertyId, java.lang.Object value, CallProtocol callProtocol)
          Associates a value with a property in the target object.
 
Methods inherited from class org.dynalang.mop.beans.BeanMetaobjectProtocol
call, call, call, call, callStatic, delete, delete, newInstance, properties, representAs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayMetaobjectProtocol

public ArrayMetaobjectProtocol(java.lang.Class<T> clazz,
                               boolean methodsEnumerable)
                        throws java.beans.IntrospectionException
Constructs a new metaobject protocol for objects of a certain array class.

Parameters:
clazz - the class to construct a metaobject protocol for
methodsEnumerable - if true, methods are enumerable through the BeanMetaobjectProtocol.properties(Object) and propertyIds(Object).
Throws:
java.lang.IllegalArgumentException - if the passed class is not an array class.
java.beans.IntrospectionException
Method Detail

get

public java.lang.Object get(java.lang.Object target,
                            java.lang.Object propertyId)
Description copied from interface: CallProtocol
Retrieves the property value from the target object.

Specified by:
get in interface CallProtocol
Overrides:
get in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
propertyId - the ID of the property. Usually a String or an Integer, but other property ID types can also be supported.
Returns:
the property value for the target object. A null value means that the protocol authoritatively decided that the value of the property is null. If the protocol decides that the property does not exist, it will return BaseMetaobjectProtocol.Result.doesNotExist. If the protocol decides that the property exists, but is not readable, it will return BaseMetaobjectProtocol.Result.notReadable. If the protocol can not make an authoritative decision, it will return BaseMetaobjectProtocol.Result.noAuthority.

get

public java.lang.Object get(java.lang.Object target,
                            long propertyId)
Description copied from interface: MetaobjectProtocol
Behaves as CallProtocol.get(Object, Object) with an integer property ID.

Specified by:
get in interface MetaobjectProtocol
Overrides:
get in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
propertyId - the ID of the property.
Returns:
see CallProtocol.get(Object, Object).

has

public java.lang.Boolean has(java.lang.Object target,
                             java.lang.Object propertyId)
Description copied from interface: BaseMetaobjectProtocol
Tells whether the target object has a particular property.

Specified by:
has in interface BaseMetaobjectProtocol
Overrides:
has in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
propertyId - the ID of the property. Usually a String or an Integer, but other property ID types can also be supported.
Returns:
Boolean.TRUE or Boolean.FALSE if the protocol can authoritatively decide whether the target has or has not the property, or null if it does not have the authority to decide.

has

public java.lang.Boolean has(java.lang.Object target,
                             long propertyId)
Description copied from interface: MetaobjectProtocol
Behaves as BaseMetaobjectProtocol.has(Object, Object) with an integer property ID.

Specified by:
has in interface MetaobjectProtocol
Overrides:
has in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
propertyId - the ID of the property.
Returns:
see BaseMetaobjectProtocol.has(Object, Object).

propertyIds

public java.util.Iterator<java.lang.Object> propertyIds(java.lang.Object target)
Description copied from interface: MetaobjectProtocol
Returns an iterator over the property IDs in the target object this MOP knows about (and chooses to expose - not all properties must be exposed; hidden properties are allowed).

Specified by:
propertyIds in interface MetaobjectProtocol
Overrides:
propertyIds in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
Returns:
an iterator over the property IDs.

put

public BaseMetaobjectProtocol.Result put(java.lang.Object target,
                                         java.lang.Object propertyId,
                                         java.lang.Object value,
                                         CallProtocol callProtocol)
Description copied from interface: BaseMetaobjectProtocol
Associates a value with a property in the target object.

Specified by:
put in interface BaseMetaobjectProtocol
Overrides:
put in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
propertyId - the ID of the property. Usually a String or an Integer, but other property ID types can also be supported.
value - the new value for the property
callProtocol - a marshaller that is used to convert the value in case the property can only accept values of certain types, and the metaobject protocol allows automatic coercing to those types.
Returns:
a value indicating the outcome of the operation. If the protocol decides that the property does not exist, and can not be created, it will return BaseMetaobjectProtocol.Result.doesNotExist. If the protocol authoritatively decides that the property is read-only, it will return BaseMetaobjectProtocol.Result.notWritable. If the property has a limitation on types it can take as values, and the supplied marshaller is not able to provide a suitable representation, then the value of the property is not changed, and BaseMetaobjectProtocol.Result.noRepresentation is returned. Finally, if the protocol doesn't have the authority to put the new property value, it will leave the property value unchanged, and return BaseMetaobjectProtocol.Result.noAuthority. If the operation succeeds, BaseMetaobjectProtocol.Result.ok is returned.

put

public BaseMetaobjectProtocol.Result put(java.lang.Object target,
                                         long propertyId,
                                         java.lang.Object value,
                                         CallProtocol callProtocol)
Description copied from interface: MetaobjectProtocol
Behaves as BaseMetaobjectProtocol.put(Object, Object, Object,CallProtocol) with an integer property ID. Associates a value with a property in the target object.

Specified by:
put in interface MetaobjectProtocol
Overrides:
put in class BeanMetaobjectProtocol<T>
Parameters:
target - the target object
propertyId - the ID of the property. Usually a String or an Integer, but other property ID types can also be supported.
value - the new value for the property
callProtocol - a marshaller that is used to convert the value in case the property can only accept values of certain types, and the metaobject protocol allows automatic coercing to those types.
Returns:
the previous value of the property, or a special value. A null value means that the protocol authoritatively decided that the previous value of the property is null. If the protocol decides that the property does not exist, and can not be created, it will return BaseMetaobjectProtocol.Result.doesNotExist. If the protocol can not set the new value, it will return BaseMetaobjectProtocol.Result.notWritable. If the protocol doesn't have the authority to put the new property value, it will leave the object unchanged, and return BaseMetaobjectProtocol.Result.noAuthority. If the operation succeeds, BaseMetaobjectProtocol.Result.ok is returned.