|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.metadata.AbstractType
de.mguennewig.pobjects.metadata.ScalarType
de.mguennewig.pobjects.metadata.StringType
public class StringType
Basic string type with an upper limit to its length.
| Field Summary | |
|---|---|
static int |
RESTRICT_TO_ALPHANUM
The allowed strings (and also the map) will be restricted to alpha-numeric characters ( [a-zA-Z_0-9]). |
static int |
RESTRICT_TO_ANYTHING
The allowed strings won't be restricted expect for a possible present map. |
static int |
RESTRICT_TO_CHARSET
The allowed strings (and also the map) will be restricted to the characters which are given in the pattern. |
static int |
RESTRICT_TO_NUMERIC
The allowed strings (and also the map) will be restricted to only digits ( [0-9]). |
static int |
RESTRICT_TO_REGEXP
The allowed strings (and also the map) will be restricted to ones that are fully matched by the regular expression in pattern. |
| Fields inherited from interface de.mguennewig.pobjects.metadata.Type |
|---|
CLASS_NAME, TYPE_NAME |
| Constructor Summary | |
|---|---|
StringType(int size)
Creates a new string type of a maximum size of size. |
|
StringType(int size,
int restrictTo)
Creates a new string type with restriction to alpha-numeric or numeric characters. |
|
StringType(int size,
int restrictTo,
java.lang.String pattern)
Creates a new string type. |
|
StringType(int size,
int restrictTo,
java.lang.String pattern,
int minimumLength)
Creates a new string type. |
|
StringType(int size,
int restrictTo,
java.lang.String pattern,
int minimumLength,
java.lang.String errorMsgKey)
Creates a new string type. |
|
| Method Summary | |
|---|---|
void |
checkConstraints(Record rec,
Column column)
Checks all constraints imposed on values of this type. |
void |
checkSyntax(java.lang.String value)
|
java.lang.String |
getErrorMsgKey()
Returns error resource key used if restriction does not match or null if the default messages are used. |
java.lang.Class<java.lang.String> |
getJavaClass()
Returns the Java class instance that is being used for the values of this type. |
int |
getMaxFieldSize()
Returns the maximum field size required to enter a value of this type. |
int |
getMinimumLength()
Returns the minimum number of characters required. |
java.lang.String |
getPattern()
Returns a pattern which will be interpreted depending on the restrictTo value. |
int |
getRestrictTo()
Returns which restriction will be applied to the strings. |
int |
getSize()
Returns the maximum number of characters allowed. |
java.lang.Object |
parseNative(java.lang.String value)
Parse value according to the `native' string representation
of this type. |
void |
setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
Sets the parameter(s) starting at startPos. |
| Methods inherited from class de.mguennewig.pobjects.metadata.ScalarType |
|---|
addMap, expand, getMap, getResult, getResultInc, isScalar, labelToValue, valueToLabel |
| Methods inherited from class de.mguennewig.pobjects.metadata.AbstractType |
|---|
format, formatNative, getDescription, getTypeClass, name, parse, setDescription, setTypeClass |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int RESTRICT_TO_ANYTHING
public static final int RESTRICT_TO_ALPHANUM
[a-zA-Z_0-9]).
public static final int RESTRICT_TO_NUMERIC
[0-9]).
public static final int RESTRICT_TO_CHARSET
pattern.
public static final int RESTRICT_TO_REGEXP
pattern.
Pattern,
Constant Field Values| Constructor Detail |
|---|
public StringType(int size)
size.
size - The maximum number of characters allowed.
public StringType(int size,
int restrictTo)
size - The maximum number of characters allowed.restrictTo - One of RESTRICT_TO_ALPHANUM and
RESTRICT_TO_NUMERIC.
public StringType(int size,
int restrictTo,
java.lang.String pattern)
size - The maximum number of characters allowed.restrictTo - Any of the RESTRICT_TO_* constants.pattern - Depends on restrictTo
java.util.regex.PatternSyntaxException - if
restrictTo == RESTRICT_TO_REGEXP and pattern
contains a syntax error.StringType(int,int,String,int,String)
public StringType(int size,
int restrictTo,
java.lang.String pattern,
int minimumLength)
size - The maximum number of characters allowed.restrictTo - Any of the RESTRICT_TO_* constants.pattern - Depends on restrictTo
restrictTo value |
pattern value |
||||||||
|---|---|---|---|---|---|---|---|---|---|
| RESTRICT_TO_ANYTHING | null |
RESTRICT_TO_ALPHANUM | null |
RESTRICT_TO_NUMERIC | null |
RESTRICT_TO_CHARSET | A string of allowed characters | RESTRICT_TO_REGEXP | A regular expression |
minimumLength - The minimum number of characters required.
java.util.regex.PatternSyntaxException - if
restrictTo == RESTRICT_TO_REGEXP and pattern
contains a syntax error.
public StringType(int size,
int restrictTo,
java.lang.String pattern,
int minimumLength,
java.lang.String errorMsgKey)
size - The maximum number of characters allowed.restrictTo - Any of the RESTRICT_TO_* constants.pattern - Depends on restrictTo
restrictTo value |
pattern value |
||||||||
|---|---|---|---|---|---|---|---|---|---|
| RESTRICT_TO_ANYTHING | null |
RESTRICT_TO_ALPHANUM | null |
RESTRICT_TO_NUMERIC | null |
RESTRICT_TO_CHARSET | A string of allowed characters | RESTRICT_TO_REGEXP | A regular expression |
minimumLength - The minimum number of characters required.errorMsgKey - Optional error message resource key used if
restriction does not match.
java.util.regex.PatternSyntaxException - if
restrictTo == RESTRICT_TO_REGEXP and pattern
contains a syntax error.| Method Detail |
|---|
public final java.lang.String getErrorMsgKey()
null if the default messages are used.
checkSyntax(String)public final int getMinimumLength()
public final java.lang.String getPattern()
restrictTo value.
RESTRICT_TO_CHARSET, the
regular expression for RESTRICT_TO_REGEXP, else
null.public final int getRestrictTo()
RESTRICT_TO_* constants for details."public final int getSize()
public final java.lang.Class<java.lang.String> getJavaClass()
public final int getMaxFieldSize()
This is the maximum number of characters required to enter a string representation of all valid values of this type. The typical size of an input field may be much smaller.
getMaxFieldSize in interface TypegetMaxFieldSize in class ScalarType
public void checkConstraints(Record rec,
Column column)
throws PObjConstraintException
checkConstraints in interface TypecheckConstraints in class ScalarTyperec - The record which contains column.column - The column of rec which has this type.
PObjConstraintException - when any constraint imposed on values of
this type is not fulfilled.public final java.lang.Object parseNative(java.lang.String value)
value according to the `native' string representation
of this type.
This representation is a one-to-one mapping of the type's value set to
strings, without any translation based on MapItems associated with
the type.
For example, an integer type's implementation would accept a value like `"1"' and translate it to an integer object, but would reject a label like `"Yes"' that may be associated with the value `1'.
Type.addMap(MapItem),
Type.parse(String)
public void checkSyntax(java.lang.String value)
throws PObjSyntaxException
checkSyntax in interface TypecheckSyntax in class ScalarTypePObjSyntaxException
public void setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
throws java.sql.SQLException
startPos.
This method is the counterpart to
Type.getResult(JdbcContainer,ResultSet,int) and
Type.getResultInc().
java.sql.SQLException - if any database error occurs.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||