Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.providers.datadefinition.makumba.validation
Class BasicValidationRule

    java.lang.Object
      org.makumba.providers.datadefinition.makumba.validation.BasicValidationRule

All Implemented Interfaces:
  Serializable, Comparable<ValidationRule>, ValidationRule

Direct Known Subclasses:
  ComparisonValidationRule, SingleFieldValidationRule

    public abstract class BasicValidationRule

extends Object
implements ValidationRule, Serializable

This class provides basic support for validation rules. New rules should extend this class, or `SingleFieldValidationRule` if they are operating on one field only.

Version:
  $Id: BasicValidationRule.java,v 1.1 Sep 17, 2007 12:26:09 AM rudi Exp $
Author:
  Rudolf Mayer
See Also:
  Serialized Form

Field Summary
`protected int[]` | `allowedTypes` Stores what types of fields are allowed (int, char.. see `FieldDefinition` .
`protected String` | `errorMessage`
`protected FieldDefinition` | `fd` The field definition this rule applies to.
`protected static String` | `fieldDef`
`protected static String` | `fieldFunction`
`protected String` | `fieldName` The name of the field (not always the same as fd.getName() for compound forms).
`protected static String` | `lowerFunction`
`static int[]` | `NUMBER_TYPES` Number types, int and real.
`(package private) static ArrayList<String>` | `operators`
`protected static String` | `rangeDef`
`protected static String` | `rangeValue`
`protected String` | `ruleName`
`protected String` | `ruleSyntax`
`static int[]` | `STRING_TYPES` String types, char and text
`protected static String` | `upperFunction`

Constructor Summary
`protected` | `BasicValidationRule()`
`` | `BasicValidationRule(FieldDefinition fd, String fieldName, String errorMessage, String ruleName, int[] allowedTypes)`

Method Summary
`protected Object` | `applyFunction(Object o1, String functionName)` Apply a function to the fields value.
`int` | `compareTo(ValidationRule o)` We order the rules such that comparison rules come last.
`static String` | `extractFunctionArgument(String statement)` Extract the function argument from the rule definition statement.
`static String` | `extractFunctionNameFromStatement(String statement)` Extract the function name from the rule definition statement.
`protected String` | `getAllowedTypes()` Return a string represenation of the allowed types.
`String` | `getErrorMessage()` Gets the error message that should be shown for this rule.
`FieldDefinition` | `getFieldDefinition()` Gets the `FieldDefinition` this rule applies to.
`String` | `getFieldName()` return the (first) field name the rule operates on.
`String` | `getRuleName()` Gets the name of this rule.
`static ArrayList<String>` | `getValidationRuleOperators()`
`static boolean` | `isFunctionCall(String statement)` Checks if the given statement contains a syntactically correct function call.
`static boolean` | `isValidFunctionCall(String s)` Checks if the given statement contains a syntactically correct and known function call.
`static void` | `main(String[] args)` Main class for testing purposes.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.makumba.ValidationRule
`validate`

Field Detail

### operators

    static ArrayList<String> operators

### rangeValue

    protected static final String rangeValue

See Also:
  Constant Field Values

### rangeDef

    protected static final String rangeDef

See Also:
  Constant Field Values

### fieldDef

    protected static final String fieldDef

See Also:
  Constant Field Values

### lowerFunction

    protected static final String lowerFunction

See Also:
  Constant Field Values

### upperFunction

    protected static final String upperFunction

See Also:
  Constant Field Values

### fieldFunction

    protected static final String fieldFunction

### fd

    protected FieldDefinition fd

  The field definition this rule applies to.

### fieldName

    protected String fieldName

  The name of the field (not always the same as fd.getName() for compound forms).

### allowedTypes

    protected int[] allowedTypes

  Stores what types of fields are allowed (int, char.. see `FieldDefinition` .

### ruleSyntax

    protected String ruleSyntax

### errorMessage

    protected String errorMessage

### ruleName

    protected String ruleName

### NUMBER_TYPES

    public static int[] NUMBER_TYPES

  Number types, int and real.

### STRING_TYPES

    public static int[] STRING_TYPES

  String types, char and text

Constructor Detail

### BasicValidationRule

    public BasicValidationRule(FieldDefinition fd,
                               String fieldName,
                               String errorMessage,
                               String ruleName,
                               int[] allowedTypes)

### BasicValidationRule

    protected BasicValidationRule()

Method Detail

### getRuleName

    public String getRuleName()

  Description copied from interface: `ValidationRule`
  Gets the name of this rule.

  Specified by:
    `getRuleName` in interface `ValidationRule`

### getErrorMessage

    public String getErrorMessage()

  Description copied from interface: `ValidationRule`
  Gets the error message that should be shown for this rule.

  Specified by:
    `getErrorMessage` in interface `ValidationRule`

### getFieldDefinition

    public FieldDefinition getFieldDefinition()

  Description copied from interface: `ValidationRule`
  Gets the `FieldDefinition` this rule applies to.

  Specified by:
    `getFieldDefinition` in interface `ValidationRule`

### getAllowedTypes

    protected String getAllowedTypes()

  Return a string represenation of the allowed types.

### applyFunction

    protected Object applyFunction(Object o1,
                                   String functionName)

  Apply a function to the fields value.

### getFieldName

    public String getFieldName()

  return the (first) field name the rule operates on.

### extractFunctionArgument

    public static String extractFunctionArgument(String statement)

  Extract the function argument from the rule definition statement. I.e. for 'lower(name)', 'name' will be returned.

  Returns:
    the function argument, or null if this statement does not contain a function.

### isFunctionCall

    public static boolean isFunctionCall(String statement)

  Checks if the given statement contains a syntactically correct function call.

### isValidFunctionCall

    public static boolean isValidFunctionCall(String s)

  Checks if the given statement contains a syntactically correct and known function call.

### extractFunctionNameFromStatement

    public static String extractFunctionNameFromStatement(String statement)

  Extract the function name from the rule definition statement. I.e. for 'lower(name)', 'lower' will be returned.

  Returns:
    the function name, or null if this statement does not contain a function.

### main

    public static void main(String[] args)

  Main class for testing purposes.

### compareTo

    public int compareTo(ValidationRule o)

  We order the rules such that comparison rules come last. This is important for live validation, where first the validity of each field by itself should be checked.

  Specified by:
    `compareTo` in interface `Comparable<ValidationRule>`

### getValidationRuleOperators

    public static ArrayList<String> getValidationRuleOperators()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20