2.17.2: 2011-06-17

net.sf.basedb.core
Class StringParameterType

java.lang.Object
  extended by net.sf.basedb.core.ParameterType<String>
      extended by net.sf.basedb.core.StringParameterType

public class StringParameterType
extends ParameterType<String>

This class represent a parameter type that is a string. This type defines a max length for the text.

Version:
2.0
Author:
Samuel, Nicklas
Last modified
$Date: 2010-10-01 13:51:57 +0200 (Fri, 01 Oct 2010) $

Field Summary
private  Integer maxLength
           
 
Constructor Summary
StringParameterType()
          Create a new string parameter type, setting the max length to 255 and nulls are allowed.
StringParameterType(Integer maxLength, String defaultValue, boolean notNull)
          Create a new string parameter type.
StringParameterType(Integer maxLength, String defaultValue, boolean notNull, int multiplicity, int width, int height)
           
StringParameterType(Integer maxLength, String defaultValue, boolean notNull, int multiplicity, int width, int height, Enumeration<String,String> items)
           
StringParameterType(Integer maxLength, String defaultValue, boolean notNull, int multiplicity, int width, int height, List<String> items)
           
 
Method Summary
 Integer getMaxLength()
          Get the max length of the parameter.
(package private)  ParameterValueData<String> newParameterValueData()
          Create a new TextParameterValueData object.
 String toString()
           
private static Type typeFromLength(Integer maxLength)
           
(package private)  void validateValue(String name, String value)
          Checks if the value is a String object and shorter than the maximum length.
 
Methods inherited from class net.sf.basedb.core.ParameterType
getDefaultValue, getEnumeration, getHeight, getItems, getMultiplicity, getNotNull, getParameterClass, getValueType, getWidth, isEnumeration, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxLength

private final Integer maxLength
Constructor Detail

StringParameterType

public StringParameterType()
Create a new string parameter type, setting the max length to 255 and nulls are allowed.


StringParameterType

public StringParameterType(Integer maxLength,
                           String defaultValue,
                           boolean notNull)
Create a new string parameter type.

Parameters:
maxLength - The maximum length of the string that is allowed or null to allow as long as possible
defaultValue - The default value of this parameter
notNull - FALSE if nulls values are allowed, TRUE otherwise

StringParameterType

public StringParameterType(Integer maxLength,
                           String defaultValue,
                           boolean notNull,
                           int multiplicity,
                           int width,
                           int height)

StringParameterType

public StringParameterType(Integer maxLength,
                           String defaultValue,
                           boolean notNull,
                           int multiplicity,
                           int width,
                           int height,
                           List<String> items)

StringParameterType

public StringParameterType(Integer maxLength,
                           String defaultValue,
                           boolean notNull,
                           int multiplicity,
                           int width,
                           int height,
                           Enumeration<String,String> items)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

validateValue

void validateValue(String name,
                   String value)
             throws InvalidDataException
Checks if the value is a String object and shorter than the maximum length.

Specified by:
validateValue in class ParameterType<String>
Parameters:
value - The value to test
name - The name of the parameter, use the name if there is need to throw an exception
Throws:
InvalidDataException - If the value is not a string or too long

newParameterValueData

ParameterValueData<String> newParameterValueData()
Create a new TextParameterValueData object.

Specified by:
newParameterValueData in class ParameterType<String>

getMaxLength

public Integer getMaxLength()
Get the max length of the parameter.

Returns:
Max length or null if none is set.

typeFromLength

private static Type typeFromLength(Integer maxLength)

2.17.2: 2011-06-17