|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BaseMetaobjectProtocol
The base metaobject protocol interface that provides essential functionality for implementing a metaobject protocol. Some notes on the design:
UndeclaredThrowableException
first.BaseMetaobjectProtocol.Results
enum where methods return
Object
. The rationale for this is that the protocols are designed
with chaining in mind, namely more than one protocol can be invoked for
an operation on an object, and certain protocols can declare that they
can't handle that particular object (in our self-chosen terminology,
they don't have authority over it) so the next protocol gets tried.
Using exceptions for such expected flow control seemed like a bad
practice. Also, a language implementation using multiple protocols can
choose to signal an error on its own if all protocols are exhausted
without success for a particular operation, and it is at liberty to use
whatever is its natural error signaling method, which is not necessarily
equivalent or best implemented using Java structured exception handling.
Nested Class Summary | |
---|---|
static class |
BaseMetaobjectProtocol.Results
Defines special operation results that are used as return values from many metaobject protocol methods to indicate success or failure. |
Method Summary | |
---|---|
BaseMetaobjectProtocol.Results |
delete(java.lang.Object target,
java.lang.Object propertyId)
Deletes an association of a value with a property in the target object. |
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.util.Map.Entry> |
properties(java.lang.Object target)
Returns an iterator over the property ID-value pairs 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,
java.lang.Object propertyId,
java.lang.Object value,
CallProtocol callProtocol)
Associates a value with a property in the target object. |
Methods inherited from interface org.dynalang.mop.CallProtocol |
---|
call, call, get, representAs |
Method Detail |
---|
BaseMetaobjectProtocol.Results delete(java.lang.Object target, java.lang.Object propertyId)
target
- the target objectpropertyId
- the ID of the property. Usually a String or an
Integer, but other property ID types can also be supported.
BaseMetaobjectProtocol.Results.doesNotExist
. If the protocol authoritatively decides
that the property can not be deleted, it will return
BaseMetaobjectProtocol.Results.notDeleteable
. If the protocol doesn't have the
authority to delete the property, it will leave the object unchanged,
and return BaseMetaobjectProtocol.Results.noAuthority
. If the operation succeeds,
BaseMetaobjectProtocol.Results.ok
is returned.java.lang.Boolean has(java.lang.Object target, java.lang.Object propertyId)
target
- the target objectpropertyId
- the ID of the property. Usually a String or an
Integer, but other property ID types can also be supported.
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.java.util.Iterator<java.util.Map.Entry> properties(java.lang.Object target)
target
- the target object
BaseMetaobjectProtocol.Results put(java.lang.Object target, java.lang.Object propertyId, java.lang.Object value, CallProtocol callProtocol)
target
- the target objectpropertyId
- 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 propertycallProtocol
- 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.
BaseMetaobjectProtocol.Results.doesNotExist
. If the protocol
authoritatively decides that the property is read-only, it will return
BaseMetaobjectProtocol.Results.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.Results.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.Results.noAuthority
. If the operation succeeds,
BaseMetaobjectProtocol.Results.ok
is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |