org.ucmtwine.parameter
Class Parameter

java.lang.Object
  extended by org.ucmtwine.parameter.Parameter
All Implemented Interfaces:
IParameter
Direct Known Subclasses:
BooleanParameter, DateParameter, DoubleParameter, FloatParameter, InjectedParameter, IntegerParameter, LongParameter, ProviderParameter, ResultSetParameter, StringParameter

public abstract class Parameter
extends Object
implements IParameter

Encapsulates a binder parameter, taking the legwork out of enforcing type and mandatory requirements.

Author:
tim

Field Summary
static int GRAMMAR_ELEMENT_UNSPECIFIED
           
protected  String name
           
protected  boolean required
           
protected  Class<?> type
          The actual type (may be primitive, non nullable etc)
 
Constructor Summary
protected Parameter()
           
protected Parameter(Class<?> type)
           
protected Parameter(String name, Class<?> type)
          Initialise a basic named binder variable.
 
Method Summary
static Parameter create(Class<?> type)
          Create an un-named, required, parameter.
static Parameter create(String name)
          Shortcut to make a named String parameter.
static Parameter create(String name, Class<?> type, boolean required)
          Factory method to create the concrete variable type.
 Object getArgumentValue(Object object, intradoc.server.Service service)
          Get the value from another object, casting if needed.
abstract  Object getBinderValue(intradoc.server.Service service)
          Get the value from the binder, checking for type compatibility and mandatory requirements.
 String getName()
          Get variable name.
 String getStringValue(intradoc.data.DataBinder binder)
          Get the string value from binder.
 Class<?> getType()
          Returns the actual type given a type string.
 boolean isRequired()
           
static boolean parseRequiredString(String requiredString)
          Based on an input string, determines if the required flag is true.
 void setName(String name)
          Set variable name.
 void setRequired(boolean optional)
           
 String toActionString()
          Gets a parameter definition string for use in service actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ucmtwine.parameter.IParameter
getGrammarElementType
 

Field Detail

GRAMMAR_ELEMENT_UNSPECIFIED

public static final int GRAMMAR_ELEMENT_UNSPECIFIED
See Also:
Constant Field Values

name

protected String name

required

protected boolean required

type

protected Class<?> type
The actual type (may be primitive, non nullable etc)

Constructor Detail

Parameter

protected Parameter()

Parameter

protected Parameter(Class<?> type)

Parameter

protected Parameter(String name,
                    Class<?> type)
Initialise a basic named binder variable.

Parameters:
name -
Method Detail

create

public static Parameter create(String name)
Shortcut to make a named String parameter.

Parameters:
name -
Returns:

create

public static Parameter create(Class<?> type)
Create an un-named, required, parameter.

Parameters:
type -
Returns:

create

public static Parameter create(String name,
                               Class<?> type,
                               boolean required)
                        throws IllegalArgumentException
Factory method to create the concrete variable type.

Parameters:
name - The name in the binder of the variable.
Returns:
Throws:
IllegalArgumentException

getName

public String getName()
Get variable name.

Specified by:
getName in interface IParameter
Returns:

setName

public void setName(String name)
Set variable name.

Parameters:
name -

isRequired

public boolean isRequired()
Specified by:
isRequired in interface IParameter

setRequired

public void setRequired(boolean optional)

getStringValue

public String getStringValue(intradoc.data.DataBinder binder)
Get the string value from binder.


getBinderValue

public abstract Object getBinderValue(intradoc.server.Service service)
                               throws IllegalAccessException
Get the value from the binder, checking for type compatibility and mandatory requirements.

Specified by:
getBinderValue in interface IParameter
Parameters:
service - The execution context.
Returns:
A type cast value or null
Throws:
IllegalAccessException

getArgumentValue

public Object getArgumentValue(Object object,
                               intradoc.server.Service service)
                        throws ClassCastException
Get the value from another object, casting if needed.

Specified by:
getArgumentValue in interface IParameter
Returns:
Throws:
ClassCastException

toActionString

public String toActionString()
Gets a parameter definition string for use in service actions.

Specified by:
toActionString in interface IParameter
Returns:

parseRequiredString

public static boolean parseRequiredString(String requiredString)
Based on an input string, determines if the required flag is true.

Parameters:
requiredString - A string containing a boolean value or "required".
Returns:
A boolean representing the mandatory state of the binder variable

getType

public Class<?> getType()
Returns the actual type given a type string.

Specified by:
getType in interface IParameter
Returns:
A java type, if valid


Copyright © 2012. All Rights Reserved.