|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dynalang.mop.impl.MetaobjectProtocolBase org.dynalang.mop.collections.MapMetaobjectProtocol
public class MapMetaobjectProtocol
A metaobject protocol that knows how to manipulate Java maps. Operates on
all keys present in the map, and returns BaseMetaobjectProtocol.Results#noAuthority
for
keys not present (thus allowing fallback to other navigators below it).
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.dynalang.mop.BaseMetaobjectProtocol |
---|
BaseMetaobjectProtocol.Results |
Constructor Summary | |
---|---|
MapMetaobjectProtocol()
|
Method Summary | |
---|---|
java.lang.Object |
call(java.lang.Object callable,
CallProtocol callProtocol,
java.util.Map args)
Calls a callable object with named arguments. |
java.lang.Object |
call(java.lang.Object callable,
CallProtocol callProtocol,
java.lang.Object... args)
Calls a callable object with positional arguments. |
BaseMetaobjectProtocol.Results |
delete(java.lang.Object target,
java.lang.Object propertyId)
Removes a key-value mapping from the map. |
java.lang.Object |
get(java.lang.Object target,
java.lang.Object propertyId)
Retrieves a value from the map. |
java.lang.Boolean |
has(java.lang.Object target,
java.lang.Object propertyId)
Determines whether a key is present in the map. |
boolean |
isAuthoritativeForClass(java.lang.Class clazz)
Returns whether this metaobject protocol has authority over objects of the specified class. |
java.util.Iterator<java.util.Map.Entry> |
properties(java.lang.Object target)
Retrieves the mappings in the map. |
BaseMetaobjectProtocol.Results |
put(java.lang.Object target,
java.lang.Object propertyId,
java.lang.Object value,
CallProtocol callProtocol)
Binds a key-value pair into the map. |
java.lang.Object |
representAs(java.lang.Object object,
java.lang.Class targetClass)
Returns a representation of the specified target object as an object of the specified target class. |
Methods inherited from class org.dynalang.mop.impl.MetaobjectProtocolBase |
---|
call, call, delete, get, has, propertyIds, put |
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.MetaobjectProtocol |
---|
call, call, delete, get, has, propertyIds, put |
Constructor Detail |
---|
public MapMetaobjectProtocol()
Method Detail |
---|
public boolean isAuthoritativeForClass(java.lang.Class clazz)
ClassBasedMetaobjectProtocol
BaseMetaobjectProtocol.Results.noAuthority
for certain objects.
In that case - when used in CompositeClassBasedMetaobjectProtocol
- the other participating MOPs will also be given the chance to handle
the object after this MOP was given the chance first.
isAuthoritativeForClass
in interface ClassBasedMetaobjectProtocol
clazz
- the class of the handled object
public java.lang.Object call(java.lang.Object callable, CallProtocol callProtocol, java.util.Map args)
CallProtocol
call
in interface CallProtocol
callable
- the callable objectcallProtocol
- 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 named arguments for the callable object. null must
be treated as empty map. Usually, the map keys are strings, but it is
possible that some protocols support non-string keys.
BaseMetaobjectProtocol.Results#noAuthority
as this MOP
has no concept of callablespublic java.lang.Object call(java.lang.Object callable, CallProtocol callProtocol, java.lang.Object... args)
CallProtocol
call
in interface CallProtocol
callable
- the callable objectcallProtocol
- 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 positional arguments for the callable object. null must
be treated as empty array.
BaseMetaobjectProtocol.Results#noAuthority
as this MOP
has no concept of callablespublic BaseMetaobjectProtocol.Results delete(java.lang.Object target, java.lang.Object propertyId)
delete
in interface BaseMetaobjectProtocol
target
- the map to remove element frompropertyId
- the map key
BaseMetaobjectProtocol.Results#ok
if the removal was successful. If the map is
read-only (throws a UnsupportedOperationException
on removal
attempt), BaseMetaobjectProtocol.Results#notDeleteable
is returned. If the map does not
contain the key, or it throws a NullPointerException
for a null
key, or the target is not a map, BaseMetaobjectProtocol.Results#noAuthority
is
returned.public java.lang.Object get(java.lang.Object target, java.lang.Object propertyId)
get
in interface CallProtocol
target
- the map to retrieve frompropertyId
- the key for retrieval
NullPointerException
for a null key, or the target is not a map,
BaseMetaobjectProtocol.Results#noAuthority
is returned.public java.lang.Boolean has(java.lang.Object target, java.lang.Object propertyId)
has
in interface BaseMetaobjectProtocol
target
- the map to testpropertyId
- the key to test for
Boolean.TRUE
. If
the map does not contain the key, or it throws a
NullPointerException
for a null key, or the target is not a map,
BaseMetaobjectProtocol.Results#noAuthority
is returned.public java.util.Iterator<java.util.Map.Entry> properties(java.lang.Object target)
properties
in interface BaseMetaobjectProtocol
target
- the map whose mappings are retrieved
public BaseMetaobjectProtocol.Results put(java.lang.Object target, java.lang.Object propertyId, java.lang.Object value, CallProtocol callProtocol)
put
in interface BaseMetaobjectProtocol
target
- the map where to bind the new mappingpropertyId
- the mapping keyvalue
- the mapped valuecallProtocol
- not used
BaseMetaobjectProtocol.Results#ok
if the binding was successful. If the map is
read-only (throws a UnsupportedOperationException
on put
attempt), BaseMetaobjectProtocol.Results#notWritable
is returned. If the map does not
contain the key, or it throws a NullPointerException
for a null
key or null value, or the target is not a map,
BaseMetaobjectProtocol.Results#noAuthority
is returned. If the map throws
ClassCastException
(because it is limited in types of values it
can accept), BaseMetaobjectProtocol.Results#noRepresentation
is returned.public java.lang.Object representAs(java.lang.Object object, java.lang.Class targetClass)
CallProtocol
representAs
in interface CallProtocol
object
- the object to representtargetClass
- the target class for representation.
BaseMetaobjectProtocol.Results#noAuthority
as this MOP has no concept of type
conversion
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |