Public Member Functions | |
boolean | resolvable () |
Referable | get () |
ResolvableReference (String id, Resolver resolver) | |
ResolvableReference (Referable referent) |
Implements a reference to an object that will be resolved at a later time using some resolver mechanism. A resolvable reference can be created in both resolved and unresolved states. Resolvable references are immutable by definition.
A resolverable reference has two states: resolved and unresolved. When in the resolved state, the reference will always return the same resolved object. When in the unresolved state, the first time the object is requested, it will be resolved and returned. At that point the reference becomes resolved and the same object is returned in subsequent requests.
The following example creates a resolved and unresolved objects and then resolved the two:
ResolvableReference resolved, unresolved;
resolved = new ResolvableReference( myObject ); unresolved = new ResolvableReference( "id", resolver ); if ( resolved.get() == myObject ) ; // This will always be true if ( unresolved.get() == resolver.resolve( "id" ) ) ; // This will always be true
org.exolab.castor.xml.schema.ResolvableReference.ResolvableReference | ( | String | id, | |
Resolver | resolver | |||
) |
Constructs a resolvable reference for the named object. This reference will be resolved on demand by calling the resolver with the specified identifier. The object need not be resolvable until the get method is called.
id | The object's identifier | |
resolver | The resolve to use |
org.exolab.castor.xml.schema.ResolvableReference.ResolvableReference | ( | Referable | referent | ) |
Constructs a resolvable reference for the given object. This reference will always resolve to the specified referent.
referent | The object to resolve to |
Referable org.exolab.castor.xml.schema.ResolvableReference.get | ( | ) |
Called to resolve the object and return it. The returned object must be cast to the proper class. If a referent was specified in the constructor, that referent will be returned. If an identifier was specified, the resolved will be called to resolve the object. The resolver will be called only the first time this method is called. Subsequent calls will return the same object.
Null is returned if the object was resolved to null.
References org.exolab.castor.xml.schema.Resolver.resolve().
boolean org.exolab.castor.xml.schema.ResolvableReference.resolvable | ( | ) |
Determines whether or not the reference can be resolved at the time this method is called. A call to this method does not guarantee a null value will not be returned by a call to the get() method.
References org.exolab.castor.xml.schema.Resolver.resolve().