org.norther.tammi.spray.template.form
Class DefaultFormContext

java.lang.Object
  extended by org.norther.tammi.spray.template.form.DefaultFormContext
All Implemented Interfaces:
Serializable, FormContext

public class DefaultFormContext
extends Object
implements FormContext, Serializable

A default implementation of FormContext.

Version:
$Id: DefaultFormContext.java,v 1.16 2010-06-24 08:44:21 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.spray.template.form.FormContext
FORM_INDEX_SEPARATOR, FORM_NAME_SEPARATOR, FORM_NAME_SPLITTER, FORM_PREFIX_SEPARATOR, PARAMETER_ELEMENT_SEPARATOR
 
Constructor Summary
DefaultFormContext()
          Constructs a new context.
DefaultFormContext(FormContext parent)
          Constructs a new context with a parent.
 
Method Summary
 void clearContext()
          Clears the context.
 boolean contains(String name)
          Checks whether the current form variable contains the named attribute.
 int getElement()
          Gets the array index of the current form attribute element.
 int getFormIndex()
          Gets the index of the current form variable, if any.
 String getFormName()
          Gets the name of the current form, if any.
 String getFormPrefix()
          Gets the prefix of the current form variable and form, if any.
 String getFormPrefix(int index)
          Gets the prefix of the indexed form variable and the current form.
protected  String getFormPrefix(String form, int index)
          Gets the form prefix for the specified name and index.
 MBeanAttributeInfo getInfo()
          Gets the attribute info of the current form attribute.
 MBeanAttributeInfo getInfo(boolean unlocked)
          Gets the optionally unlocked attribute info of the current form attribute.
 VariableAttributeInfo getInfo(String name)
          Gets the named attribute info of the current form variable.
 VariableAttributeInfo getInfo(String name, boolean unlocked)
          Gets the named and optionally unlocked attribute info of the current form variable.
 List<VariableAttributeInfo> getInfos()
          Gets the attribute info list of the current form variable.
 List<VariableAttributeInfo> getInfos(boolean unlocked)
          Gets the optionally unlocked attribute info list of the current form variable.
 String getNestedPrefix()
          Gets the nested form prefix.
 FormContext getParentContext()
          Gets the parent context, if any.
 FormContext getRootContext()
          Gets the root context.
 Variable getVariable()
          Gets the current form variable.
 boolean isReadOnly()
          Checks whether the current form is read-only.
 void setElement(int index)
          Sets the array index of the current form attribute element.
 void setFormName(String form)
          Sets the name of the current form and resets its variable index.
 void setInfo(MBeanAttributeInfo attribute)
          Sets the attribute info of the current form attribute.
 void setInfo(String name)
          Sets the named attribute info of the current form attribute.
 void setReadOnly(boolean readonly)
          Sets whether the current form is read-only.
 void setVariable(Variable variable, boolean readonly, int... index)
          Sets the current form variable with a read-only option.
 void setVariable(Variable variable, int... index)
          Sets the current form variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFormContext

public DefaultFormContext()
Constructs a new context.


DefaultFormContext

public DefaultFormContext(FormContext parent)
Constructs a new context with a parent.

Parameters:
parent - the parent context.
Method Detail

getFormName

public String getFormName()
Description copied from interface: FormContext
Gets the name of the current form, if any.

Specified by:
getFormName in interface FormContext
Returns:
the form name or null.

setFormName

public void setFormName(String form)
Description copied from interface: FormContext
Sets the name of the current form and resets its variable index.

Specified by:
setFormName in interface FormContext
Parameters:
form - the form name.

getFormIndex

public int getFormIndex()
Description copied from interface: FormContext
Gets the index of the current form variable, if any.

Specified by:
getFormIndex in interface FormContext
Returns:
the form variable index or -1.

getFormPrefix

public String getFormPrefix()
Description copied from interface: FormContext
Gets the prefix of the current form variable and form, if any.

Specified by:
getFormPrefix in interface FormContext
Returns:
the form prefix or null.

getFormPrefix

public String getFormPrefix(int index)
Description copied from interface: FormContext
Gets the prefix of the indexed form variable and the current form.

Specified by:
getFormPrefix in interface FormContext
Parameters:
index - the index.
Returns:
the form prefix or null.

getNestedPrefix

public String getNestedPrefix()
Description copied from interface: FormContext
Gets the nested form prefix.

Specified by:
getNestedPrefix in interface FormContext
Returns:
the nested prefix or null.

isReadOnly

public boolean isReadOnly()
Description copied from interface: FormContext
Checks whether the current form is read-only.

Specified by:
isReadOnly in interface FormContext
Returns:
true if read-only, false otherwise.

setReadOnly

public void setReadOnly(boolean readonly)
Description copied from interface: FormContext
Sets whether the current form is read-only.

Specified by:
setReadOnly in interface FormContext
Parameters:
readonly - true if read-only, false otherwise.

getVariable

public Variable getVariable()
Description copied from interface: FormContext
Gets the current form variable.

Specified by:
getVariable in interface FormContext
Returns:
the form variable or null.

setVariable

public void setVariable(Variable variable,
                        int... index)
Description copied from interface: FormContext
Sets the current form variable.

Specified by:
setVariable in interface FormContext
Parameters:
variable - the form variable.
index - the form index.

setVariable

public void setVariable(Variable variable,
                        boolean readonly,
                        int... index)
Description copied from interface: FormContext
Sets the current form variable with a read-only option.

Specified by:
setVariable in interface FormContext
Parameters:
variable - the form variable.
readonly - a forced read-only option.
index - the form index.

getInfo

public MBeanAttributeInfo getInfo()
Description copied from interface: FormContext
Gets the attribute info of the current form attribute.

Specified by:
getInfo in interface FormContext
Returns:
the attribute or null.

getInfo

public MBeanAttributeInfo getInfo(boolean unlocked)
Description copied from interface: FormContext
Gets the optionally unlocked attribute info of the current form attribute.

Specified by:
getInfo in interface FormContext
Parameters:
unlocked - true if unlocked, false otherwise.
Returns:
the attribute or null.

getInfo

public VariableAttributeInfo getInfo(String name)
Description copied from interface: FormContext
Gets the named attribute info of the current form variable.

Specified by:
getInfo in interface FormContext
Parameters:
name - the attribute name.
Returns:
the named attribute or null.

getInfo

public VariableAttributeInfo getInfo(String name,
                                     boolean unlocked)
Description copied from interface: FormContext
Gets the named and optionally unlocked attribute info of the current form variable.

Specified by:
getInfo in interface FormContext
Parameters:
name - the attribute name.
unlocked - true if unlocked, false otherwise.
Returns:
the named attribute or null.

setInfo

public void setInfo(String name)
Description copied from interface: FormContext
Sets the named attribute info of the current form attribute.

Specified by:
setInfo in interface FormContext
Parameters:
name - the attribute name.

setInfo

public void setInfo(MBeanAttributeInfo attribute)
Description copied from interface: FormContext
Sets the attribute info of the current form attribute.

Specified by:
setInfo in interface FormContext
Parameters:
attribute - the form attribute.

getInfos

public List<VariableAttributeInfo> getInfos()
Description copied from interface: FormContext
Gets the attribute info list of the current form variable.

Specified by:
getInfos in interface FormContext
Returns:
a list of form attributes or null.

getInfos

public List<VariableAttributeInfo> getInfos(boolean unlocked)
Description copied from interface: FormContext
Gets the optionally unlocked attribute info list of the current form variable.

Specified by:
getInfos in interface FormContext
Parameters:
unlocked - true if unlocked, false otherwise.
Returns:
a list of form attributes or null.

contains

public boolean contains(String name)
Description copied from interface: FormContext
Checks whether the current form variable contains the named attribute.

Specified by:
contains in interface FormContext
Parameters:
name - the attribute name.
Returns:
true if contained, false otherwise.

getElement

public int getElement()
Description copied from interface: FormContext
Gets the array index of the current form attribute element.

Specified by:
getElement in interface FormContext
Returns:
the element index or -1.

setElement

public void setElement(int index)
Description copied from interface: FormContext
Sets the array index of the current form attribute element.

Specified by:
setElement in interface FormContext
Parameters:
index - the element index.

getParentContext

public FormContext getParentContext()
Description copied from interface: FormContext
Gets the parent context, if any.

Specified by:
getParentContext in interface FormContext
Returns:
the parent context or null.

getRootContext

public FormContext getRootContext()
Description copied from interface: FormContext
Gets the root context.

Specified by:
getRootContext in interface FormContext
Returns:
the root context.

clearContext

public void clearContext()
Description copied from interface: FormContext
Clears the context.

Specified by:
clearContext in interface FormContext

getFormPrefix

protected String getFormPrefix(String form,
                               int index)
Gets the form prefix for the specified name and index.

Parameters:
form - the form name.
index - the variable index.
Returns:
the local prefix or null.


Copyright © 2004 The Norther Organization. All rights reserved.