org.dynalang.mop.impl
Class MetaobjectProtocolBase

java.lang.Object
  extended by org.dynalang.mop.impl.MetaobjectProtocolBase
All Implemented Interfaces:
BaseMetaobjectProtocol, CallProtocol, MetaobjectProtocol
Direct Known Subclasses:
BottomMetaobjectProtocol, MapMetaobjectProtocol

public abstract class MetaobjectProtocolBase
extends java.lang.Object
implements MetaobjectProtocol

A convenient base class for implementing a MetaobjectProtocol that requires you to only implement MetaobjectProtocolBase methods on it.

Version:
$Id: $
Author:
Attila Szegedi

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.dynalang.mop.BaseMetaobjectProtocol
BaseMetaobjectProtocol.Results
 
Constructor Summary
MetaobjectProtocolBase()
           
 
Method Summary
 java.lang.Object call(java.lang.Object target, java.lang.Object callableId, CallProtocol callProtocol, java.util.Map args)
          Calls a method on the target object with supplied named arguments.
 java.lang.Object call(java.lang.Object target, java.lang.Object callableId, CallProtocol callProtocol, java.lang.Object... args)
          Calls a method on the target object with supplied positional arguments.
 BaseMetaobjectProtocol.Results delete(java.lang.Object target, long propertyId)
          Behaves as BaseMetaobjectProtocol.delete(Object, Object) with an integer property ID.
 java.lang.Object get(java.lang.Object target, long propertyId)
          Behaves as CallProtocol.get(Object, Object) with an integer property ID.
 java.lang.Boolean has(java.lang.Object target, long propertyId)
          Behaves as BaseMetaobjectProtocol.has(Object, Object) with an integer property ID.
 java.util.Iterator<? extends 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.Results 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.dynalang.mop.BaseMetaobjectProtocol
delete, has, properties, put
 
Methods inherited from interface org.dynalang.mop.CallProtocol
call, call, get, representAs
 

Constructor Detail

MetaobjectProtocolBase

public MetaobjectProtocolBase()
Method Detail

call

public java.lang.Object call(java.lang.Object target,
                             java.lang.Object callableId,
                             CallProtocol callProtocol,
                             java.util.Map args)
Description copied from interface: MetaobjectProtocol
Calls a method on the target object with supplied named arguments. Must behave identically to:
 Object callable = get(target, callableId);
 if(callable instanceof Results) {
     return callable;
 }
 return call(callable, args);
 

Specified by:
call in interface MetaobjectProtocol
Parameters:
target - the target object
callableId - the ID of the method to call
callProtocol - a marshaller that should be used by this metaobject protocol to convert the arguments to conform to expected argument types for the call.
args - the arguments of the call
Returns:
the result of the invocation, or a special result. Can return any return value that CallProtocol.get(Object, Object) would return while looking up the callable. Can also return any return value that CallProtocol.call(Object, CallProtocol, Map) would return while calling.

call

public java.lang.Object call(java.lang.Object target,
                             java.lang.Object callableId,
                             CallProtocol callProtocol,
                             java.lang.Object... args)
Description copied from interface: MetaobjectProtocol
Calls a method on the target object with supplied positional arguments. Must behave identically to:
 Object callable = get(target, callableId);
 if(callable instanceof Results) {
     return callable;
 }
 return call(callable, args);
 

Specified by:
call in interface MetaobjectProtocol
Parameters:
target - the target object
callableId - the ID of the method to call
callProtocol - a marshaller that should be used by this metaobject protocol to convert the arguments to conform to expected argument types for the call.
args - the arguments of the call
Returns:
the result of the invocation, or a special result. Can return any return value that CallProtocol.get(Object, Object) would return while looking up the callable. Can also return any return value that CallProtocol.call(Object, CallProtocol, Object[]) would return while calling.

delete

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

Specified by:
delete in interface MetaobjectProtocol
Parameters:
target - the target object
propertyId - the ID of the property.
Returns:
see BaseMetaobjectProtocol.delete(Object, Object).

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
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,
                             long propertyId)
Description copied from interface: MetaobjectProtocol
Behaves as BaseMetaobjectProtocol.has(Object, Object) with an integer property ID.

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

propertyIds

public java.util.Iterator<? extends 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
Parameters:
target - the target object
Returns:
an iterator over the property IDs.

put

public BaseMetaobjectProtocol.Results 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
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.Results.doesNotExist. If the protocol can not set the new value, it will return BaseMetaobjectProtocol.Results.notWritable. If the protocol doesn't have the authority to put the new property value, it will leave the object unchanged, and return BaseMetaobjectProtocol.Results.noAuthority. If the operation succeeds, BaseMetaobjectProtocol.Results.ok is returned.