com.ibm.dse.automaton.html
Class HtmlProcessorXValidate

java.lang.Object
  |
  +--com.ibm.dse.automaton.html.HtmlProcessorXValidate

public abstract class HtmlProcessorXValidate
extends java.lang.Object
implements ProcessorXValidate

This class implements a error management framework for validators. The base validator class imposes on the user to manage a string array of error messages that may change in size dynamically as validation is carried out. To alleviate this, this class manages a collection of error messages that can be accessed using the methods addMessage(String) and deleteMessage(String). At the end of validation, these error messages are composed into a string array and returned automatically. The main caveat of using this class is that subclasses must implement their validation logic in the doXValidate(...) method instead of the xValidate(...) method.


Constructor Summary
HtmlProcessorXValidate()
          HtmlProcessorXValidate constructor.
 
Method Summary
 void addMessage(java.lang.String message)
          Adds a message to the collection of error messages for this validator.
 void deleteMessage(java.lang.String message)
          Removes a message from the collection of messages for this validator.
abstract  void doXValidate(Context context, java.lang.String transitionName)
          This method should be overriden by subclasses to do the actual work of cross-validation.
 boolean isEmpty(java.lang.String value)
          This is equivalent to calling isEmpty(String, true)
 boolean isEmpty(java.lang.String value, boolean trim)
          This method returns true if the string passed to it as argument is either null, or if it contains no data.
 java.lang.String[] xValidate(Context ctx)
          Performs the operation "cross-validation" service
 java.lang.String[] xValidate(Context context, java.lang.String transitionName)
          This method relegates the actual work of cross validation to subclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlProcessorXValidate

public HtmlProcessorXValidate()
HtmlProcessorXValidate constructor.
Method Detail

addMessage

public void addMessage(java.lang.String message)
Adds a message to the collection of error messages for this validator.
Parameters:
message - java.lang.String

deleteMessage

public void deleteMessage(java.lang.String message)
Removes a message from the collection of messages for this validator.
Parameters:
message - java.lang.String

doXValidate

public abstract void doXValidate(Context context,
                                 java.lang.String transitionName)
                          throws java.lang.Exception
This method should be overriden by subclasses to do the actual work of cross-validation. This method should contain the logic that would normally have been placed in the xValidate(Context, String) method of a class that subclasses from com.ibm.dse.automaton.html.ProcessorXValidate. Users of this method can utilize addMessage(String) and deleteMessage(String) to manage error messages. They also do not have to worry about creating and resizing string arrays to hold their error messages. All this is handled by this class.
Parameters:
context - com.ibm.dse.base.Context
transitionName - java.lang.String
Throws:
java.lang.Exception -  

isEmpty

public boolean isEmpty(java.lang.String value)
This is equivalent to calling isEmpty(String, true)
Parameters:
value - java.lang.String
Returns:
boolean

isEmpty

public boolean isEmpty(java.lang.String value,
                       boolean trim)
This method returns true if the string passed to it as argument is either null, or if it contains no data. If the boolean trim argument is true, then the string argument is trimmed before it is checked.
Parameters:
value - java.lang.String
Returns:
boolean

xValidate

public java.lang.String[] xValidate(Context ctx)
Description copied from interface: OperationXValidate
Performs the operation "cross-validation" service
Tags copied from interface: OperationXValidate
Returns:
String[] - The validation error string list.

xValidate

public java.lang.String[] xValidate(Context context,
                                    java.lang.String transitionName)
                             throws java.lang.Exception
This method relegates the actual work of cross validation to subclasses. It then collects and error messages generated and returns them as an array of strings, as required by the framework
Specified by:
xValidate in interface ProcessorXValidate
Parameters:
context - com.ibm.dse.base.Context
transitionName - java.lang.String
Returns:
java.lang.String[]
Throws:
java.lang.Exception -