org.eclipse.actf.validation.core
Class Parameter

java.lang.Object
  extended by org.eclipse.actf.validation.core.Parameter

public class Parameter
extends Object

A Parameter object represents any attribute value or argument that is to be passed to a constructor or method as it appears in the XML document. Such objects include (but are certainly not limited to):

Thus, this class embodies most of the special syntax used by the RGB engine in reading the description of a GUI in an XML document.

Author:
Mike Squillace

Field Summary
static String EMPTY_VALUE
          empty parameter
static int LITERAL_PRIMITIVE
          literal primitive
static int METHOD_ALIAS
          method alias (not currently used)
static int REFERENCE_ID
          reference id
static int SCRIPT_CODE
          script code
static int UNKNOWN
          unknown parameter type
static String UNRESOLVED
          unresolved parameter
 
Constructor Summary
Parameter(Object obj)
          wraps the given Object as a resolved Parameter
Parameter(String param, ICodeProcessor codeProcessor)
          create a Parameter object for later resolution.
Parameter(String param, int type, ICodeProcessor codeProcessor)
          create a Parameter object for later resolution.
 
Method Summary
 ICodeProcessor getCodeProcessor()
          returns the code processor being used by this parameter.
 String getFieldName()
          gets the fully-qualified name of the field named by this parameter
 int getParameterType()
          returns the parameter type of this unresolved parameter
 Object getResolvedValue()
          returns the resolved parameter value.
 String getUnresolvedValue()
          get the unresolved value for this parameter.
 boolean isMethodAlias()
          returns true if this parameter is a method alias
 boolean isPublicFieldName()
          returns whether or not this parameter as an unresolved String names a public field in some class.
 boolean isReferenceId()
          returns true if this parameter is a reference id
 boolean isResolved()
          returns true if this Parameter has been resolved via invoking one of the resolve(...)
 boolean isScriptCode()
          returns true if this parameter is code to be evaluated by this Parameter's ICodeProcessor
 Object resolve(Class cls)
          attempts to resolve this unresolved Parameter.
 Object[] resolve(Class[] paramTypes)
          force this Parameter to be treated as a series of statements in the scripting language of this Parameter's ICodeProcessor and return the array of objects that is the result of the evaluation of these statements.
 Object resolve(Class cls, Object parent)
           
 void setCodeProcessor(ICodeProcessor cp)
          set the code processor for this parameter
 void setParameterType(int type)
          set the parameter type of this parameter.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
unknown parameter type

See Also:
Constant Field Values

REFERENCE_ID

public static final int REFERENCE_ID
reference id

See Also:
Constant Field Values

METHOD_ALIAS

public static final int METHOD_ALIAS
method alias (not currently used)

See Also:
Constant Field Values

SCRIPT_CODE

public static final int SCRIPT_CODE
script code

See Also:
Constant Field Values

LITERAL_PRIMITIVE

public static final int LITERAL_PRIMITIVE
literal primitive

See Also:
Constant Field Values

UNRESOLVED

public static final String UNRESOLVED
unresolved parameter

See Also:
Constant Field Values

EMPTY_VALUE

public static final String EMPTY_VALUE
empty parameter

See Also:
Constant Field Values
Constructor Detail

Parameter

public Parameter(String param,
                 ICodeProcessor codeProcessor)
create a Parameter object for later resolution. The given String argument is the parameter as it is read from the XML source. The type of this parameter object is determined by its literal form or by symbols prefixed to it. If a literal is given, a best-guess is made about the type of object to which ultimate resolution will lead.

Parameters:
param - -- string representation of parameter as read from XML document
codeProcessor - -- ICodeProcessor for evaluation of expressions and ids

Parameter

public Parameter(String param,
                 int type,
                 ICodeProcessor codeProcessor)
create a Parameter object for later resolution. Supplying a type to this ctor overrides any default determination based upon syntax of the literal supplied

Parameters:
param - -- representation of the parameter to be resolved
type - -- type of this parameter; one of the public static fields of this class
codeProcessor - -- code processor for evaluation, which may be null if the type is not SCRIPT_CODE
See Also:
Parameter(String, ICodeProcessor)

Parameter

public Parameter(Object obj)
wraps the given Object as a resolved Parameter

Parameters:
obj - -- an Object that will be passed to a method or constructor
Method Detail

setCodeProcessor

public void setCodeProcessor(ICodeProcessor cp)
set the code processor for this parameter

Parameters:
cp - -- code processor

getCodeProcessor

public ICodeProcessor getCodeProcessor()
returns the code processor being used by this parameter.

Returns:
code processor

getResolvedValue

public Object getResolvedValue()
returns the resolved parameter value. The resolved value of a parameter is an object of the given type that best reflects the information provided to this Parameter object. This value may be null if one of the resolve(...) methods has not been invoked

Returns:
resolved parameter value
See Also:
resolve(Class)

getUnresolvedValue

public String getUnresolvedValue()
get the unresolved value for this parameter. This will be the text of the origianal text content or attribute value of the element without special syntax of ACTF.

Returns:
text of original text content or attribute of element

setParameterType

public void setParameterType(int type)
set the parameter type of this parameter. The valid parameter types are given as public static fields of this class. This method is used to override default setting based upon syntax of literal

Parameters:
type - -- one of the public static fields of this class

getParameterType

public int getParameterType()
returns the parameter type of this unresolved parameter

Returns:
parameter type (one of the public static fields of this class)

resolve

public Object resolve(Class cls)
attempts to resolve this unresolved Parameter. The algorithm for resolution is as follows:

Parameters:
cls - -- desired class of which resolution is to produce an instance
Returns:
instance of desired class or null if resolution could not take place

resolve

public Object resolve(Class cls,
                      Object parent)
Parameters:
cls - - desired class of which resolution is to produce an instance
parent - - parent object (e.g. for resolving constraints or other layout information)
Returns:
instance of desired class or null if resolution could not take place
See Also:
resolve(Class)

resolve

public Object[] resolve(Class[] paramTypes)
force this Parameter to be treated as a series of statements in the scripting language of this Parameter's ICodeProcessor and return the array of objects that is the result of the evaluation of these statements. Statements are delimited via the expression delimiter, which is model-dependent or which can be set via the 'exprdelim' property in the raven.properties file.

Parameters:
paramTypes - -- array of types of desired parameters
Returns:
array of results of resolution or null if code could not be evaluated
See Also:
"resources/raven.properties"

isResolved

public boolean isResolved()
returns true if this Parameter has been resolved via invoking one of the resolve(...) methods

Returns:
true if this Parameter has been resolved, false otherwise
See Also:
resolve(Class)

isScriptCode

public boolean isScriptCode()
returns true if this parameter is code to be evaluated by this Parameter's ICodeProcessor

Returns:
true if parameter is script code, false otherwise

isMethodAlias

public boolean isMethodAlias()
returns true if this parameter is a method alias

Returns:
true if parameter is a method alias, false otherwise

isReferenceId

public boolean isReferenceId()
returns true if this parameter is a reference id

Returns:
true if parameter is a reference id, false otherwise

isPublicFieldName

public boolean isPublicFieldName()
returns whether or not this parameter as an unresolved String names a public field in some class.

Returns:
true if the String names a public field in some class, false otherwise

getFieldName

public String getFieldName()
gets the fully-qualified name of the field named by this parameter

Returns:
name of field named by this parameter or null if parameter does not name a public field

toString

public String toString()

Overrides:
toString in class Object