net.sf.yavtags.rules
Class YavRule

java.lang.Object
  extended by net.sf.yavtags.rules.YavRule
Direct Known Subclasses:
Alnumhyphen, Alnumhyphenat, Alphabetic, Alphanumeric, Alphaspace, And, AndOrOperator, Custom, Date, DateLe, DateLt, Double, Email, Empty, Equal, Implies, Integer, KeyPress, Mask, MaxLength, MinLength, NotEqual, Numeric, NumRange, Or, PostCondition, PreCondition, Regexp, Required

public abstract class YavRule
extends java.lang.Object

Encapsulates a YAV validation rule.


Field Summary
protected  java.lang.String[] i18nKeys
          List of yav i18n keys used for this rule
protected  java.util.Map<java.lang.String,java.lang.String[]> parameterMap
          Map of request parameter values, as in ServletRequest interface.
protected  java.util.List<YavRule> previousRules
          Previous parsed rules, for compound rules like 'implies'
protected  YavConfig yavConfig
          Yav configuration
 
Constructor Summary
protected YavRule(java.lang.String rule, java.util.List<YavRule> previousRules, YavConfig yavConfig)
          Avoid external instantation.
 
Method Summary
 YavError checkError()
           
protected abstract  YavError checkError(java.lang.String value)
           
static boolean existsIndependentRuleForFieldName(java.util.List<YavRule> yavRules, java.lang.String fieldName)
           
 java.lang.String getDependantRule()
          If this is a dependant rule, get the first part of the rule.
 java.lang.String getFieldLabel()
           
 java.lang.String getFieldName()
           
 java.lang.String[] getI18nKeys()
           
protected  java.lang.String getMetanameLabel()
          Returns description label for metaname in rule suffix, the most common case.
protected  java.lang.String getMetanameLabel(java.lang.String metaname)
          Returns description label for metaname, i.e, the text after ':' in metanames like 'passwd:Password'.
protected  java.lang.String getProcessedValue()
          Returns value for metaname in rule suffix, the most common case.
protected  java.lang.String getProcessedValue(java.lang.String metaname)
          If 'metaname' starts with '$', returns the value of request parameter.
 java.lang.String getRule()
           
protected  java.lang.String getRuleSuffix()
           
 java.lang.String getRuleType()
           
 boolean hasFieldLabel()
           
static YavRule parseRule(java.lang.String rule, java.util.List<YavRule> previousRules, java.util.Map<java.lang.String,YavMask> yavMasks, YavConfig yavConfig)
           
 void setLocalizedFieldLabel(java.lang.String localizedFieldLabel)
           
 void setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> parameterMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

previousRules

protected java.util.List<YavRule> previousRules
Previous parsed rules, for compound rules like 'implies'


parameterMap

protected java.util.Map<java.lang.String,java.lang.String[]> parameterMap
Map of request parameter values, as in ServletRequest interface. See: http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/ServletRequest.html#getParameterMap%28%29


yavConfig

protected YavConfig yavConfig
Yav configuration


i18nKeys

protected java.lang.String[] i18nKeys
List of yav i18n keys used for this rule

Constructor Detail

YavRule

protected YavRule(java.lang.String rule,
                  java.util.List<YavRule> previousRules,
                  YavConfig yavConfig)
           throws java.text.ParseException
Avoid external instantation. Use static factory method 'parse' instead

Throws:
java.text.ParseException
Method Detail

parseRule

public static YavRule parseRule(java.lang.String rule,
                                java.util.List<YavRule> previousRules,
                                java.util.Map<java.lang.String,YavMask> yavMasks,
                                YavConfig yavConfig)
                         throws java.text.ParseException
Throws:
java.text.ParseException

getRule

public java.lang.String getRule()

getDependantRule

public java.lang.String getDependantRule()
If this is a dependant rule, get the first part of the rule.


hasFieldLabel

public boolean hasFieldLabel()

getFieldName

public java.lang.String getFieldName()

getFieldLabel

public java.lang.String getFieldLabel()

setLocalizedFieldLabel

public void setLocalizedFieldLabel(java.lang.String localizedFieldLabel)

getRuleType

public java.lang.String getRuleType()

getRuleSuffix

protected java.lang.String getRuleSuffix()

existsIndependentRuleForFieldName

public static boolean existsIndependentRuleForFieldName(java.util.List<YavRule> yavRules,
                                                        java.lang.String fieldName)

checkError

public YavError checkError()

checkError

protected abstract YavError checkError(java.lang.String value)

getI18nKeys

public java.lang.String[] getI18nKeys()

setParameterMap

public void setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> parameterMap)

getProcessedValue

protected java.lang.String getProcessedValue(java.lang.String metaname)
If 'metaname' starts with '$', returns the value of request parameter. Whatelse, returns 'metaname'. 'metaname' can contain a name to be displayed with the ':' separator. Examples of 'metaname': 5000 $passwd $passwd:Password


getProcessedValue

protected java.lang.String getProcessedValue()
Returns value for metaname in rule suffix, the most common case.


getMetanameLabel

protected java.lang.String getMetanameLabel(java.lang.String metaname)
Returns description label for metaname, i.e, the text after ':' in metanames like 'passwd:Password'.


getMetanameLabel

protected java.lang.String getMetanameLabel()
Returns description label for metaname in rule suffix, the most common case.