planetj.dataengine.parameter
Class AbstractParameter

java.lang.Object
  extended byplanetj.dataengine.parameter.AbstractParameter
All Implemented Interfaces:
java.lang.Cloneable, IParameter, java.io.Serializable
Direct Known Subclasses:
AbstractNamedParameter, ContextParameterParameter, DataEngineServletParameter, ExecutingContextParameter, FieldOrUsageIdParameter, ParameterParameter, RuntimeParameter, ShadowParameter

public abstract class AbstractParameter
extends java.lang.Object
implements IParameter

A general implementation of the IParameter interface

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface planetj.dataengine.parameter.IParameter
CONTEXT_SPECIFIC_ID_END, CONTEXT_SPECIFIC_ID_START, DEFAULT_DATA_TYPE, ID_START, PARAMETER_INDEX_PREFIX, PARAMETER_VALUE_ACTUAL, PARAMETER_VALUE_DISPLAY, PARAMETER_VALUE_UNKNOWN
 
Constructor Summary
AbstractParameter()
           
 
Method Summary
 java.lang.Object clearValue()
          Clears this parameter's value, returning the current value after it has been cleared.
 java.lang.Object clone()
          Clones this parameter
 IParameter cloneParameter()
          Clones this parameter
 boolean equals(java.lang.Object o)
          Tests if the context index, token, and value of the passed IParameter object equal those of this object
 java.lang.String getCodeReplacementString()
          Gets the String which represents this parameter's value in a String of code.
 IContext getContext()
          Gets the parameter's context
 int getContextIndex()
          Gets the (0-based) index of this parameter within its context
 java.lang.String getContextSpecificId()
          Gets the context specific ID of this parameter.
 int getDataType()
          Gets the SQL data type of the parameter
 java.lang.String getDefaultValueAsString()
          Gets this parameter's default value as a String
 java.lang.String getId()
          Returns an ID which uniquely identifies this parameter.
 IParameterSource getSource()
          Gets the object from which this parameter was generated.
 FieldDescriptorRow getTargetFieldDescriptor()
          Gets a field descriptor describing this parameter's target (i.e.
 java.lang.String getToken()
          Gets the literal token that was used to denote this parameter in code
 java.lang.Object getValue()
          Gets the value of the parameter
 boolean hasAssignedValue()
          Tests if this parameter has been assigned a value.
 int hashCode()
          Gets a hashCode based on the context index, token, and value of this parameter
 boolean isSQLParameter()
          Tests if this parameter should be sent as a parameter to the DB if it is included in a SQL statement.
 boolean isValueLoaded()
          Tests if the parameter has loaded a value.
 java.lang.Object loadValueFromSource(java.lang.Object source)
          Loads this parameter's value from a source.
 java.lang.Object loadValueFromSource(java.lang.Object o, int valueType)
          Loads this parameter's value from a source.
 void setContext(IContext context)
          Sets the parameter's context
protected  void setContextIndex(int newContextIndex)
          Sets the (0-based) index of this parameter within its context
protected  void setContextInternal(IContext context)
          Sets the parameter's context
 void setDataType(int newDataType)
          Sets the SQL data type of the parameter
 void setDefaultValueAsString(java.lang.String value)
          Sets this parameter's default value as a String
 void setSource(IParameterSource newSource)
          Sets the object from which this parameter was generated.
 void setSQLParameter(boolean sqlp)
          Sets if this parameter should be sent as a parameter to the DB if it is included in a SQL statement.
 void setToken(java.lang.String token)
          Sets the literal token that was used to denote this parameter in code.
protected  void setTokenInternal(java.lang.String token)
          Sets the literal token that was used to denote this parameter in code.
 void setValue(java.lang.Object value)
          Sets the value of the parameter
protected  void setValueInternal(java.lang.Object value)
          Sets the value of the parameter
 java.lang.String toString()
          Returns a String representation of this object
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractParameter

public AbstractParameter()
Method Detail

clearValue

public java.lang.Object clearValue()
                            throws CMException
Clears this parameter's value, returning the current value after it has been cleared.

Specified by:
clearValue in interface IParameter
Throws:
CMException

clone

public final java.lang.Object clone()
Clones this parameter

Specified by:
clone in interface IParameter

cloneParameter

public IParameter cloneParameter()
Clones this parameter

Specified by:
cloneParameter in interface IParameter

equals

public boolean equals(java.lang.Object o)
Tests if the context index, token, and value of the passed IParameter object equal those of this object


getCodeReplacementString

public java.lang.String getCodeReplacementString()
Gets the String which represents this parameter's value in a String of code. For SQL parameters, this will be a question mark. For most other parameters, this will be a String representation of the parameter value

Specified by:
getCodeReplacementString in interface IParameter

getContext

public IContext getContext()
Gets the parameter's context

Specified by:
getContext in interface IParameter

getContextIndex

public int getContextIndex()
Gets the (0-based) index of this parameter within its context

Specified by:
getContextIndex in interface IParameter

getContextSpecificId

public java.lang.String getContextSpecificId()
Gets the context specific ID of this parameter. This is just the context index, with the ID_START char tacked onto the beginning of it and the CONTEXT_SPECIFIC_ID_END char tacked onto the end. Two parameters in different contexts may have the same context specific ID

Specified by:
getContextSpecificId in interface IParameter

getDataType

public int getDataType()
Gets the SQL data type of the parameter

Specified by:
getDataType in interface IParameter

getDefaultValueAsString

public java.lang.String getDefaultValueAsString()
Gets this parameter's default value as a String


getId

public java.lang.String getId()
Returns an ID which uniquely identifies this parameter. (Although if two contexts contain exactly the same code, their parameters may have the same ID).


getSource

public IParameterSource getSource()
Gets the object from which this parameter was generated. This value may be null

Specified by:
getSource in interface IParameter

getTargetFieldDescriptor

public FieldDescriptorRow getTargetFieldDescriptor()
                                            throws CMException
Gets a field descriptor describing this parameter's target (i.e. where this parameter's value is being set). Not all parameters will have a target field descriptor.

Specified by:
getTargetFieldDescriptor in interface IParameter
Throws:
CMException

getToken

public java.lang.String getToken()
Gets the literal token that was used to denote this parameter in code

Specified by:
getToken in interface IParameter

getValue

public java.lang.Object getValue()
Gets the value of the parameter

Specified by:
getValue in interface IParameter

hashCode

public int hashCode()
Gets a hashCode based on the context index, token, and value of this parameter


hasAssignedValue

public boolean hasAssignedValue()
Tests if this parameter has been assigned a value. When this method returns false then this parameter's value is either null or is the default value.

Specified by:
hasAssignedValue in interface IParameter

isSQLParameter

public boolean isSQLParameter()
Tests if this parameter should be sent as a parameter to the DB if it is included in a SQL statement. The DB can handle fewer type of parameters than the DataEngine, so not all DataEngine parameters can be sent as parameters to the DB. (For example, table names cannot be sent as DB parameters.) If this parameter is not part of an SQL statement then it does not matter what this method returns.


isValueLoaded

public boolean isValueLoaded()
Tests if the parameter has loaded a value. If a parameter has never had a value set, (not counting the default value) then this method will return false. If this parameter has ever loaded a value, this method will return true, even if the value which was loaded was exactly the same as its default value.


loadValueFromSource

public final java.lang.Object loadValueFromSource(java.lang.Object source)
                                           throws CMException
Description copied from interface: IParameter
Loads this parameter's value from a source. The object passed in may be ignored if the parameter already knows the source from which its value should be extracted.

Specified by:
loadValueFromSource in interface IParameter
Parameters:
source - source Object to use to extract the parameters value
Throws:
CMException

loadValueFromSource

public java.lang.Object loadValueFromSource(java.lang.Object o,
                                            int valueType)
                                     throws CMException
Description copied from interface: IParameter
Loads this parameter's value from a source. The object passed in may be ignored if the parameter already knows the source from which its value should be extracted.

Specified by:
loadValueFromSource in interface IParameter
Parameters:
o - source Object to use to extract the parameters value
valueType - the type of value to extract. (e.g. actual value or a display value)
Throws:
CMException

setContext

public void setContext(IContext context)
Sets the parameter's context

Specified by:
setContext in interface IParameter

setContextIndex

protected void setContextIndex(int newContextIndex)
Sets the (0-based) index of this parameter within its context


setContextInternal

protected final void setContextInternal(IContext context)
Sets the parameter's context


setDataType

public void setDataType(int newDataType)
Sets the SQL data type of the parameter

Specified by:
setDataType in interface IParameter

setDefaultValueAsString

public void setDefaultValueAsString(java.lang.String value)
Sets this parameter's default value as a String


setSource

public void setSource(IParameterSource newSource)
Sets the object from which this parameter was generated. This value may be null

Specified by:
setSource in interface IParameter

setSQLParameter

public void setSQLParameter(boolean sqlp)
Sets if this parameter should be sent as a parameter to the DB if it is included in a SQL statement. The DB can handle fewer type of parameters than the DataEngine, so not all DataEngine parameters can be sent as parameters to the DB. (For example, table names cannot be sent as DB parameters.)


setToken

public void setToken(java.lang.String token)
              throws CMException
Sets the literal token that was used to denote this parameter in code. Subclasses may override this method if they need to do additional processing on the token as long as they invoke the setTokenInternal() method to actually set the token

Specified by:
setToken in interface IParameter
Throws:
CMException

setTokenInternal

protected final void setTokenInternal(java.lang.String token)
Sets the literal token that was used to denote this parameter in code.


setValue

public void setValue(java.lang.Object value)
              throws CMException
Sets the value of the parameter

Specified by:
setValue in interface IParameter
Throws:
CMException

setValueInternal

protected final void setValueInternal(java.lang.Object value)
Sets the value of the parameter


toString

public java.lang.String toString()
Returns a String representation of this object