erland.util
Class ParameterStorageParameterString

java.lang.Object
  extended by erland.util.ParameterStorageParameterString
All Implemented Interfaces:
ParameterValueStorageExInterface, ParameterValueStorageInterface

public class ParameterStorageParameterString
extends Object
implements ParameterValueStorageExInterface

Get, set or delete parameters stored in a parameter string

Author:
Erland Isaksson

Constructor Summary
ParameterStorageParameterString(StorageInterface primaryStorage, StorageInterface secondaryStorage, char parameterDelimiter)
          Createa a storage object
ParameterStorageParameterString(StorageInterface primaryStorage, StorageInterface secondaryStorage, char parameterDelimiter, String primaryStorageParameters, String secondaryStorageParameters)
          Createa a storage object
 
Method Summary
 void delParameter(String name)
          Delete a parameter
protected  void delSpecialParameterInData(StringBuffer data, String name)
          Delets a parameter in the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true
 String getParameter(String name)
          Get a parameter value
 StorageInterface getParameterAsStorage(String name)
          Retreives the parameter as a StorageInterface object instead of a value Observe that this is a new StorageInterface object and will not be related to any of your other StorageInterface objects
protected  StorageInterface getSpecialParameterAsStorageInData(StringBuffer data, String name)
          Gets a storage object for a parameter from the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true
protected  String getSpecialParameterInData(StringBuffer data, String name)
          Gets the parameter value for a parameter from the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true
protected  void init(StorageInterface primaryStorage, StorageInterface secondaryStorage, char parameterDelimiter, String primaryStorageParameters, String secondaryStorageParameters)
          Initialize this object
protected  boolean isSpecialHandled(String name)
          Check if this parameter should be special handled, will be autmatically called when a parameter is accessed.
 void setParameter(String name, String value)
          Set a parameter value
 void setParameterAsStorage(String name, StorageInterface value)
          Sets the parameter as a StorageInterface object instead of a value Observe that this is a new StorageInterface object must have been retreived with the ParameterValueStorageExInterface.getParameterAsStorage(String) method
protected  void setSpecialParameterAsStorageInData(StringBuffer data, String name, StorageInterface value)
          Sets the parameter value for a parameter in the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true The value is specified as a StorageInterface object
protected  void setSpecialParameterInData(StringBuffer data, String name, String value)
          Sets the parameter value for a parameter in the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParameterStorageParameterString

public ParameterStorageParameterString(StorageInterface primaryStorage,
                                       StorageInterface secondaryStorage,
                                       char parameterDelimiter)
Createa a storage object

Parameters:
primaryStorage - The storage object which the parameters should be read/write from/to
secondaryStorage - The storage object which the parameters should be read from if they don't exist in the primaryStorage
parameterDelimiter - The character that separates two parameters

ParameterStorageParameterString

public ParameterStorageParameterString(StorageInterface primaryStorage,
                                       StorageInterface secondaryStorage,
                                       char parameterDelimiter,
                                       String primaryStorageParameters,
                                       String secondaryStorageParameters)
Createa a storage object

Parameters:
primaryStorage - The storage object which the parameters should be read/write from/to
secondaryStorage - The storage object which the parameters should be read from if they don't exist in the primaryStorage
parameterDelimiter - The character that separates two parameters
primaryStorageParameters - A comma separated list with parameters allowed in primaryStorage, null means that all parameters are allowed
secondaryStorageParameters - comma separated list with parameters allowed in secondaryStorage, null means that all parameters are allowed
Method Detail

init

protected void init(StorageInterface primaryStorage,
                    StorageInterface secondaryStorage,
                    char parameterDelimiter,
                    String primaryStorageParameters,
                    String secondaryStorageParameters)
Initialize this object

Parameters:
primaryStorage - The storage object which the parameters should be read/write from/to
secondaryStorage - The storage object which the parameters should be read from if they don't exist in the primaryStorage
parameterDelimiter - The character that separates two parameters
primaryStorageParameters - A comma separated list with parameters allowed in primaryStorage, null means that all parameters are allowed
secondaryStorageParameters - comma separated list with parameters allowed in secondaryStorage, null means that all parameters are allowed

isSpecialHandled

protected boolean isSpecialHandled(String name)
Check if this parameter should be special handled, will be autmatically called when a parameter is accessed. Implement this in your sub class if you want to handle some parameters in a special way.

Parameters:
name - The parameter name
Returns:
Always false
true - This parameter should be special handled,then one of 
         getSpecialParameterInData(StringBuffer,String), setSpecialParameterInData(StringBuffer,String,String), delSpecialParameterInData(StringBuffer,String),
         will be called to access the parameter
false - This parameter is handled in the normal way, one of
         getParameter(String), setParameter(String,String), delParameter(String), 
         will be called to access the parameter

getSpecialParameterInData

protected String getSpecialParameterInData(StringBuffer data,
                                           String name)
Gets the parameter value for a parameter from the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true

Parameters:
data - The StringBuffer to search for the parameter in
name - The parameter name of the parameter
Returns:
The value of the parameter

getSpecialParameterAsStorageInData

protected StorageInterface getSpecialParameterAsStorageInData(StringBuffer data,
                                                              String name)
Gets a storage object for a parameter from the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true

Parameters:
data - The StringBuffer to search for the parameter in
name - The parameter name of the parameter
Returns:
The storage object for the parameter

getParameter

public String getParameter(String name)
Description copied from interface: ParameterValueStorageInterface
Get a parameter value

Specified by:
getParameter in interface ParameterValueStorageInterface
Parameters:
name - The name of the parameter
Returns:
The value of the parameter, will be an empty string if the parameter does not exist

setSpecialParameterInData

protected void setSpecialParameterInData(StringBuffer data,
                                         String name,
                                         String value)
Sets the parameter value for a parameter in the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true

Parameters:
data - The StringBuffer to set the parameter in
name - The parameter name of the parameter
value - The parameter value of the parameter

setSpecialParameterAsStorageInData

protected void setSpecialParameterAsStorageInData(StringBuffer data,
                                                  String name,
                                                  StorageInterface value)
Sets the parameter value for a parameter in the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true The value is specified as a StorageInterface object

Parameters:
data - The StringBuffer to set the parameter in
name - The parameter name of the parameter
value - The parameter value of the parameter

setParameter

public void setParameter(String name,
                         String value)
Description copied from interface: ParameterValueStorageInterface
Set a parameter value

Specified by:
setParameter in interface ParameterValueStorageInterface
Parameters:
name - The name of the parameter
value - The value of the parameter

delSpecialParameterInData

protected void delSpecialParameterInData(StringBuffer data,
                                         String name)
Delets a parameter in the StringBuffer specified, this method is only called if isSpecialHandled(String) returns true

Parameters:
data - The StringBuffer to set the parameter in
name - The parameter name of the parameter

delParameter

public void delParameter(String name)
Description copied from interface: ParameterValueStorageInterface
Delete a parameter

Specified by:
delParameter in interface ParameterValueStorageInterface
Parameters:
name - The name of the parameter

toString

public String toString()
Overrides:
toString in class Object

getParameterAsStorage

public StorageInterface getParameterAsStorage(String name)
Description copied from interface: ParameterValueStorageExInterface
Retreives the parameter as a StorageInterface object instead of a value Observe that this is a new StorageInterface object and will not be related to any of your other StorageInterface objects

Specified by:
getParameterAsStorage in interface ParameterValueStorageExInterface
Parameters:
name - The name of the parameter to retreive
Returns:
A StorageInterface object containing the value of the parameter

setParameterAsStorage

public void setParameterAsStorage(String name,
                                  StorageInterface value)
Description copied from interface: ParameterValueStorageExInterface
Sets the parameter as a StorageInterface object instead of a value Observe that this is a new StorageInterface object must have been retreived with the ParameterValueStorageExInterface.getParameterAsStorage(String) method

Specified by:
setParameterAsStorage in interface ParameterValueStorageExInterface
Parameters:
name - The name of the parameter to set
value - The value as a StorageInterface object


Copyright © 2003-2005 Erland Isaksson. All Rights Reserved.