com.highdeal.udr.hci
Class ConstraintObject

java.lang.Object
  extended by com.highdeal.udr.hci.ConstraintObject
Direct Known Subclasses:
EnumeratedListConstraint, FormatConstraint, RangeConstraint

public abstract class ConstraintObject
extends java.lang.Object

This Java class represents the constraint as used by an entity to be constrained; A constraint can be an enumerated list, a range, or a format.

A constraint has a constraint type (enumerated list, range, format) and a compatible subtype corresponding to the type of the value to be constrained (boolean, integer, decimal, string, date, duration).

A constraint is represented by a String. See the createConstraintFromString(String) method for more information about the String format.


Nested Class Summary
static class ConstraintObject.MetaChar
          This enumeration lists the meta characters: escape, multiple, single, slash.
 
Field Summary
static boolean[][] compatibilityTable
          The compatibility table: constrained object type/constraint object type.
static int NO_SUBTYPE
          The no subtype.
static java.lang.String separator
          The separator character as a string
static char separatorChar
          The separator character: '/'
static java.lang.String STRING_TYPE_BIG_INTEGER
           
static java.lang.String STRING_TYPE_BOOLEAN
           
static java.lang.String STRING_TYPE_DATE
           
static java.lang.String STRING_TYPE_DECIMAL
           
static java.lang.String STRING_TYPE_ENUMERATED_LIST
           
static java.lang.String STRING_TYPE_FORMAT
           
static java.lang.String STRING_TYPE_INTEGER
           
static java.lang.String STRING_TYPE_LONG
           
static java.lang.String STRING_TYPE_RANGE
           
static java.lang.String STRING_TYPE_STRING
           
static int TYPE_BIG_INTEGER
          the big integer subtype.
static int TYPE_BOOLEAN
          the date subtype.
static int TYPE_DATE
          the date subtype.
static int TYPE_DECIMAL
          the decimal subtype.
static int TYPE_ENUMERATED_LIST
          The enumerated list type.
static int TYPE_FORMAT
          The format constraint type.
static int TYPE_INTEGER
          the integer subtype.
static int TYPE_LONG
          the long subtype.
static int TYPE_RANGE
          The range constraint type.
static int TYPE_STRING
          the string subtype.
 
Constructor Summary
ConstraintObject()
           
 
Method Summary
static ConstraintObject createConstraintFromString(java.lang.String str)
          Builds a constraint from a string representation.
static java.lang.String escapeMetaChar(java.lang.String value)
          This method adds an escape char before each metachar from the input string.
static int[] getAllowedConstraintTypes(int valueType)
          According to the value type (NUMBER, STRING, DATE, BOOLEAN, DURATION) to be constrained returns the allowed constraint types.
 int getConstraintSubType()
          Gets the subtype of the constraint that depends on the type of the constrained value.
abstract  int getConstraintType()
          Returns the constraint type of this constraint.
abstract  java.lang.String getInitializationString()
          Returns the initialization string of the constraint.
abstract  boolean isBigIntegerConstraint()
          Returns big integer status of the constraint.
abstract  boolean isBooleanConstraint()
          Returns boolean status of the constraint.
abstract  boolean isDateConstraint()
          Returns date status of the constraint.
abstract  boolean isDecimalConstraint()
          Returns decimal status of the constraint.
abstract  boolean isIntegerConstraint()
          Returns integer status of the constraint.
abstract  boolean isLongConstraint()
          Returns long status of the constraint.
abstract  boolean isStringConstraint()
          Returns string status of the constraint.
abstract  boolean isValidValue(java.lang.Object value)
          Tests if the value checks the constraint.
static int parseConstraintSubType(java.lang.String subType)
           
abstract  java.lang.String toString()
          Returns true the string that represents the constraint.
static java.lang.String unescapeMetaChar(java.lang.String value)
           
static java.lang.String unescapeSeparatorChar(java.lang.String s)
          Unescapes the separator character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_ENUMERATED_LIST

public static final int TYPE_ENUMERATED_LIST
The enumerated list type.

See Also:
Constant Field Values

STRING_TYPE_ENUMERATED_LIST

public static final java.lang.String STRING_TYPE_ENUMERATED_LIST
See Also:
Constant Field Values

TYPE_RANGE

public static final int TYPE_RANGE
The range constraint type.

See Also:
Constant Field Values

STRING_TYPE_RANGE

public static final java.lang.String STRING_TYPE_RANGE
See Also:
Constant Field Values

TYPE_FORMAT

public static final int TYPE_FORMAT
The format constraint type.

See Also:
Constant Field Values

STRING_TYPE_FORMAT

public static final java.lang.String STRING_TYPE_FORMAT
See Also:
Constant Field Values

TYPE_INTEGER

public static final int TYPE_INTEGER
the integer subtype.

See Also:
Constant Field Values

STRING_TYPE_INTEGER

public static final java.lang.String STRING_TYPE_INTEGER
See Also:
Constant Field Values

TYPE_DECIMAL

public static final int TYPE_DECIMAL
the decimal subtype.

See Also:
Constant Field Values

STRING_TYPE_DECIMAL

public static final java.lang.String STRING_TYPE_DECIMAL
See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
the string subtype.

See Also:
Constant Field Values

STRING_TYPE_STRING

public static final java.lang.String STRING_TYPE_STRING
See Also:
Constant Field Values

TYPE_DATE

public static final int TYPE_DATE
the date subtype.

See Also:
Constant Field Values

STRING_TYPE_DATE

public static final java.lang.String STRING_TYPE_DATE
See Also:
Constant Field Values

TYPE_BOOLEAN

public static final int TYPE_BOOLEAN
the date subtype.

See Also:
Constant Field Values

STRING_TYPE_BOOLEAN

public static final java.lang.String STRING_TYPE_BOOLEAN
See Also:
Constant Field Values

NO_SUBTYPE

public static final int NO_SUBTYPE
The no subtype.

See Also:
Constant Field Values

TYPE_LONG

public static final int TYPE_LONG
the long subtype.

See Also:
Constant Field Values

STRING_TYPE_LONG

public static final java.lang.String STRING_TYPE_LONG
See Also:
Constant Field Values

TYPE_BIG_INTEGER

public static final int TYPE_BIG_INTEGER
the big integer subtype.

See Also:
Constant Field Values

STRING_TYPE_BIG_INTEGER

public static final java.lang.String STRING_TYPE_BIG_INTEGER
See Also:
Constant Field Values

compatibilityTable

public static final boolean[][] compatibilityTable
The compatibility table: constrained object type/constraint object type.


separatorChar

public static final char separatorChar
The separator character: '/'

See Also:
Constant Field Values

separator

public static final java.lang.String separator
The separator character as a string

Constructor Detail

ConstraintObject

public ConstraintObject()
Method Detail

createConstraintFromString

public static ConstraintObject createConstraintFromString(java.lang.String str)
Builds a constraint from a string representation.

Three types of constraints can be defined: enumerated list constraint, range constraint, and format constraint.

Enumerated List Constraint

This type of constraint is decribed by a string that respects the following format:
/E/compatible_subtype/item1/.../itemN/

Where:

An Object is compatible with an enumerated list constraint if and only if it's instance of the given compatible subtype and equals one of the given items.

Range Constraint

This type of constraint is decribed by a string that respects the following format:
/R/compatible_subtype/min/min_type/max/max_type/

Where:

An Object is compatible with an range constraint if and only if it's instance of the given compatible subtype and belongs to the range defined by min and max bounds, and the related bound types.

Format Constraint

This type of constraint is decribed by a string that respects the following format:
/F/pattern/

Where:

An Object is compatible with a format constraint if and only if it's a String matching the given pattern.


isValidValue

public abstract boolean isValidValue(java.lang.Object value)
Tests if the value checks the constraint.

Returns:
true if the value checks the constraint, false otherwise

getConstraintType

public abstract int getConstraintType()
Returns the constraint type of this constraint.

Returns:
The constraint type
See Also:
TYPE_ENUMERATED_LIST, TYPE_RANGE, TYPE_FORMAT

getConstraintSubType

public int getConstraintSubType()
Gets the subtype of the constraint that depends on the type of the constrained value.

Returns:
The subtype of the constraint
See Also:
TYPE_BOOLEAN, TYPE_INTEGER, TYPE_LONG, TYPE_BIG_INTEGER, TYPE_DECIMAL, TYPE_STRING, TYPE_DATE, NO_SUBTYPE

isBooleanConstraint

public abstract boolean isBooleanConstraint()
Returns boolean status of the constraint.

Returns:
true if the constrained value is boolean, false otherwise

isIntegerConstraint

public abstract boolean isIntegerConstraint()
Returns integer status of the constraint.

Returns:
true if the constrained value is integer, false otherwise

isLongConstraint

public abstract boolean isLongConstraint()
Returns long status of the constraint.

Returns:
true if the constrained value is long, false otherwise

isDecimalConstraint

public abstract boolean isDecimalConstraint()
Returns decimal status of the constraint.

Returns:
true if the constrained value is big decimal, false otherwise

isBigIntegerConstraint

public abstract boolean isBigIntegerConstraint()
Returns big integer status of the constraint.

Returns:
true if the constrained value is a BigInteger, false otherwise

isDateConstraint

public abstract boolean isDateConstraint()
Returns date status of the constraint.

Returns:
true if the constrained value is date, false otherwise

isStringConstraint

public abstract boolean isStringConstraint()
Returns string status of the constraint.

Returns:
true if the constrained value is string, false otherwise

getInitializationString

public abstract java.lang.String getInitializationString()
Returns the initialization string of the constraint.

Returns:
The initialization string of the constraint

toString

public abstract java.lang.String toString()
Returns true the string that represents the constraint.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the constraint

getAllowedConstraintTypes

public static int[] getAllowedConstraintTypes(int valueType)
According to the value type (NUMBER, STRING, DATE, BOOLEAN, DURATION) to be constrained returns the allowed constraint types.

Returns:
The allowed constraint types can be
See Also:
TYPE_ENUMERATED_LIST, TYPE_RANGE, TYPE_FORMAT

parseConstraintSubType

public static int parseConstraintSubType(java.lang.String subType)

escapeMetaChar

public static java.lang.String escapeMetaChar(java.lang.String value)
This method adds an escape char before each metachar from the input string.

Parameters:
value - The string to scan
Returns:
The string with the metachar escaped

unescapeMetaChar

public static java.lang.String unescapeMetaChar(java.lang.String value)

unescapeSeparatorChar

public static java.lang.String unescapeSeparatorChar(java.lang.String s)
Unescapes the separator character.

Returns:
The unescaped string

Document Published: October 2015 (SAP CC 4.0 SP10 and Later)