Package net.sf.basedb.core
Class StringParameterType
- java.lang.Object
-
- net.sf.basedb.core.ParameterType<String>
-
- net.sf.basedb.core.StringParameterType
-
- Direct Known Subclasses:
PasswordParameterType
public class StringParameterType extends ParameterType<String>
This class represent a parameter type that is a string. This type defines amax length
for the text.- Version:
- 2.0
- Author:
- Samuel, Nicklas
- Last modified
- $Date: 2015-04-21 09:59:42 +0200 (ti, 21 apr 2015) $
-
-
Constructor Summary
Constructors Constructor Description 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, List<String> items)
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, Enumeration<String,String> items, boolean checkValues)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Integer
getMaxLength()
Get the max length of the parameter.(package private) ParameterValueData<String>
newParameterValueData()
Create a newTextParameterValueData
object.String
toString()
private static Type
typeFromLength(Integer maxLength)
(package private) void
validateValue(String name, String value)
Checks if the value is aString
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, isMasked, validate, validate
-
-
-
-
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 possibledefaultValue
- The default value of this parameternotNull
- 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)
-
StringParameterType
public StringParameterType(Integer maxLength, String defaultValue, boolean notNull, int multiplicity, int width, int height, Enumeration<String,String> items, boolean checkValues)
-
-
Method Detail
-
validateValue
void validateValue(String name, String value) throws InvalidDataException
Checks if the value is aString
object and shorter than the maximum length.- Specified by:
validateValue
in classParameterType<String>
- Parameters:
value
- The value to testname
- 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 newTextParameterValueData
object.- Specified by:
newParameterValueData
in classParameterType<String>
-
getMaxLength
public Integer getMaxLength()
Get the max length of the parameter.- Returns:
- Max length or null if none is set.
-
-