com.arsdigita.util.parameter
Class AbstractParameterContext

java.lang.Object
  extended bycom.arsdigita.util.parameter.AbstractParameterContext
All Implemented Interfaces:
ParameterContext
Direct Known Subclasses:
AbstractConfig, AbstractScript, ParameterRecord

public abstract class AbstractParameterContext
extends Object
implements ParameterContext

Subject to change. A base implementation of the ParameterContext interface.

Version:
$Id: //core-platform/dev/src/com/arsdigita/util/parameter/AbstractParameterContext.java#8 $
Author:
Justin Ross <jross@redhat.com>
See Also:
ParameterContext

Field Summary
static String versionId
           
 
Constructor Summary
AbstractParameterContext()
          Constructs a parameter context.
 
Method Summary
 Object get(Parameter param)
          Gets the unmarshaled value of param.
 Object get(Parameter param, Object dephault)
          Gets the unmarshaled value of param, returning dephalt if param's value is null.
 Parameter[] getParameters()
          Returns all the parameters registered on the parameter context.
 ErrorList load(ParameterReader reader)
          Reads and unmarshals all values associated with the registered parameters from reader.
 void load(ParameterReader reader, ErrorList errors)
          Reads and unmarshals all values associated with the registered parameters from reader.
protected  void loadInfo()
          Loads source data for ParameterInfo objects from the file YourClass_parameter.properties next to YourClass.class.
 void register(Parameter param)
          Registers param to the context.
 void save(ParameterWriter writer)
          Marshals and writes all values associated with the registered parameters to writer.
 void set(Parameter param, Object value)
          Sets the value of param to value.
 ErrorList validate()
          Validates all values associated with the registered parameters.
 void validate(ErrorList errors)
          Validates all values associated with the registered parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

AbstractParameterContext

public AbstractParameterContext()
Constructs a parameter context.

Method Detail

register

public final void register(Parameter param)
Registers param to the context.

Parameters:
param - The Parameter being registered; it cannot be null

getParameters

public final Parameter[] getParameters()
Description copied from interface: ParameterContext
Returns all the parameters registered on the parameter context.

Specified by:
getParameters in interface ParameterContext
Returns:
A Parameter[] of all the parameters; it cannot be null
See Also:
ParameterContext.getParameters()

get

public Object get(Parameter param)
Description copied from interface: ParameterContext
Gets the unmarshaled value of param. If the loaded value is null, param.getDefaultValue() is returned.

Specified by:
get in interface ParameterContext
Parameters:
param - The named Parameter whose value to retrieve; it cannot be null
Returns:
The unmarshaled Java object value of param
See Also:
ParameterContext.get(Parameter)

get

public Object get(Parameter param,
                  Object dephault)
Description copied from interface: ParameterContext
Gets the unmarshaled value of param, returning dephalt if param's value is null.

Specified by:
get in interface ParameterContext
Parameters:
param - The Parameter whose value to retrieve; it cannot be null
dephault - The fallback default value; it may be null
Returns:
The unmarshaled Java object value of param or dephalt if the former is null
See Also:
ParameterContext.get(Parameter,Object)

set

public void set(Parameter param,
                Object value)
Description copied from interface: ParameterContext
Sets the value of param to value.

Specified by:
set in interface ParameterContext
Parameters:
param - The Parameter whose value to set; it cannot be null
value - The new value of param; it may be null
See Also:
ParameterContext.get(Parameter,Object)

load

public final ErrorList load(ParameterReader reader)
Reads and unmarshals all values associated with the registered parameters from reader. Any errors are returned.

Parameters:
reader - The ParameterReader from which to fetch the values; it cannot be null
Returns:
An ErrorList containing any errors encountered while loading; it cannot be null

load

public final void load(ParameterReader reader,
                       ErrorList errors)
Description copied from interface: ParameterContext
Reads and unmarshals all values associated with the registered parameters from reader. If any errors are encountered, they are added to errors.

Specified by:
load in interface ParameterContext
Parameters:
reader - The ParameterReader from which to fetch the values; it cannot be null
errors - The ErrorList that captures any errors while loading; it cannot be null
See Also:
ParameterContext.load(ParameterReader,ErrorList)

validate

public final ErrorList validate()
Validates all values associated with the registered parameters. Any errors encountered are returned.

Returns:
An ErrorList containing validation errors; it cannot be null

validate

public final void validate(ErrorList errors)
Description copied from interface: ParameterContext
Validates all values associated with the registered parameters. Any errors encountered are added to errors.

Specified by:
validate in interface ParameterContext
Parameters:
errors - The ErrorList that captures validation errors; it cannot be null
See Also:
ParameterContext.validate(ErrorList)

save

public final void save(ParameterWriter writer)
Description copied from interface: ParameterContext
Marshals and writes all values associated with the registered parameters to writer.

Specified by:
save in interface ParameterContext
Parameters:
writer - The ParameterWriter to which values are written; it cannot be null
See Also:
ParameterContext.save(ParameterWriter)

loadInfo

protected final void loadInfo()
Loads source data for ParameterInfo objects from the file YourClass_parameter.properties next to YourClass.class. YourClass_parameter.properties:
 yourforum.notification_enabled.title=Flag to enable forum notifications
 yourforum.notification_enabled.purpose=Enables or disables forum notifications
 yourforum.notification_enabled.example=true
 yourforum.notifiaction_enabled.format=true|false
 

See Also:
ParameterInfo


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC