net.dpml.lang
Class Construct

java.lang.Object
  extended bynet.dpml.lang.Construct
All Implemented Interfaces:
Serializable, Value
Direct Known Subclasses:
ValueDirective

public class Construct
extends Object
implements Value, Serializable

A object resolvable from primitive arguments.

Version:
1.0.1
Author:
Digital Product Meta Library
See Also:
Serialized Form

Constructor Summary
Construct(String value)
          Create a new construct using the default java.lang.String class as the base type.
Construct(String target, String value)
          Create a new construct using a supplied target defintion.
Construct(String target, String method, String value)
          Create a new construct using a supplied target defintion.
Construct(String target, String method, Value[] args)
          Create a new construct using a supplied target defintion.
Construct(String target, Value[] args)
          Create a new construct using a supplied target defintion.
Construct(ValueDirective directive)
          Creation of a new construct using a value directive.
 
Method Summary
 boolean equals(Object other)
          Compare this instance with a supplied object for equality.
static Object[] getArgs(Map map, Value[] params, Object[] args)
          Utility operation that consolidates an array of values and supplimentary arguments to an array of objects.
 String getBaseValue()
          Return the classname of the resolved value.
 String getMethodName()
          Return the method name to be applied to the target object.
 String getTargetExpression()
          Return the classname of the resolved value.
 Value[] getValues()
          Return the set of nested values within this value.
 int hashCode()
          Compute the instance hashcode value.
 boolean isCompound()
          Return TRUE if this construct is a compund construct else FALSE.
 Object resolve()
          Resolve an instance from the value using the context classloader.
 Object resolve(boolean isolate)
          Resolve an instance from the value using a supplied isolation policy.
 Object resolve(Map map)
          Resolve an instance from the value using a supplied map.
 Object resolve(Map map, boolean isolate)
          Resolve an instance from the value using a supplied context map.
 Object resolve(String classname, Map map, boolean isolate)
          Resolve an instance from the value using a supplied context map.
 String toString()
          Return a string representation of the construct.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Construct

public Construct(String value)
Create a new construct using the default java.lang.String class as the base type.

Parameters:
value - the construct value

Construct

public Construct(String target,
                 String value)
Create a new construct using a supplied target defintion. The target argument may be either a classname or a symbolic reference in the form ${[key]}. If the argument is symbolic it resolved relative to a context map supplied by the application resolving construct values.

Parameters:
target - a classname or symbolic reference
value - the construct value

Construct

public Construct(String target,
                 String method,
                 String value)
Create a new construct using a supplied target defintion. The target argument may be either a classname or a symbolic reference in the form ${[key]}. If the argument is symbolic it is resolved relative to a context map supplied by the application resolving construct values. If the construct value is symbolic the implementation will attempt to expand the reference relative to a context map (if supplied) otherwise the implementation will attempt to expand the value using system properties.

Parameters:
target - a classname or symbolic reference
method - the method to invoke on the target
value - the construct value

Construct

public Construct(String target,
                 Value[] args)
Create a new construct using a supplied target defintion. The target argument may be either a classname or a symbolic reference in the form ${[key]}. If the argument is symbolic it is resolved relative to a context map supplied by the application resolving construct values. Instance values resolved from the supplied Value[] will be used as constructor arguments when resolving the target.

Parameters:
target - the construct classname
args - an array of unresolved parameter values

Construct

public Construct(String target,
                 String method,
                 Value[] args)
Create a new construct using a supplied target defintion. The target argument may be either a classname or a symbolic reference in the form ${[key]}. If the argument is symbolic it is resolved relative to a context map supplied by the application resolving construct values. Instance values resolved from the supplied Value[] will be used as method arguments when resolving the target.

Parameters:
target - the construct classname
method - the method to invoke on the target
args - an array of unresolved parameter values

Construct

public Construct(ValueDirective directive)
Creation of a new construct using a value directive.

Parameters:
directive - the value directive
Method Detail

getArgs

public static Object[] getArgs(Map map,
                               Value[] params,
                               Object[] args)
                        throws Exception
Utility operation that consolidates an array of values and supplimentary arguments to an array of objects.

Parameters:
map - a map of keys and values used in symbolic target resolution
params - the value array
args - supplimentary arguments
Returns:
the consolidated argument array
Throws:
Exception - if an error occurs in argument resolution

isCompound

public boolean isCompound()
Return TRUE if this construct is a compund construct else FALSE.

Returns:
TRUE if this ia a compound construct

getMethodName

public String getMethodName()
Return the method name to be applied to the target object.

Returns:
the method name

getValues

public Value[] getValues()
Return the set of nested values within this value.

Returns:
the nested values array

getBaseValue

public String getBaseValue()
Return the classname of the resolved value.

Returns:
the classname

getTargetExpression

public String getTargetExpression()
Return the classname of the resolved value.

Returns:
the classname

resolve

public Object resolve()
               throws Exception
Resolve an instance from the value using the context classloader.

Specified by:
resolve in interface Value
Returns:
the resolved instance
Throws:
Exception - if an error occurs during value resolution

resolve

public Object resolve(Map map)
               throws Exception
Resolve an instance from the value using a supplied map.

Specified by:
resolve in interface Value
Parameters:
map - the context map
Returns:
the resolved instance
Throws:
Exception - if an error occurs during value resolution

resolve

public Object resolve(boolean isolate)
               throws Exception
Resolve an instance from the value using a supplied isolation policy.

Specified by:
resolve in interface Value
Parameters:
isolate - the isolation policy
Returns:
the resolved instance
Throws:
Exception - if an error occurs during value resolution

resolve

public Object resolve(Map map,
                      boolean isolate)
               throws Exception
Resolve an instance from the value using a supplied context map. If any target expressions in immediate or nested values contain a symbolic expression the value will be resolved using the supplied map.

Specified by:
resolve in interface Value
Parameters:
map - the context map
isolate - the isolation policy
Returns:
the resolved instance
Throws:
Exception - if error occurs during instance resolution

resolve

public Object resolve(String classname,
                      Map map,
                      boolean isolate)
               throws Exception
Resolve an instance from the value using a supplied context map. If any target expressions in immediate or nested values contain a symbolic expression the value will be resolved using the supplied map.

Specified by:
resolve in interface Value
Parameters:
classname - the default classname
map - the context map
isolate - the isolation policy
Returns:
the resolved instance
Throws:
Exception - if error occurs during instance resolution

toString

public String toString()
Return a string representation of the construct.

Returns:
the string value

equals

public boolean equals(Object other)
Compare this instance with a supplied object for equality.

Parameters:
other - the other object
Returns:
true if the supplied instance is equal to this instance

hashCode

public int hashCode()
Compute the instance hashcode value.

Returns:
the hashcode