DBWeb
Class ErrorRecord

java.lang.Object
  |
  +--DBWeb.ErrorRecord

public class ErrorRecord
extends java.lang.Object

A utility class that represents errors accumulated in checking a user's input form. In addition, it also stores warnings, separately.


Constructor Summary
ErrorRecord()
           
 
Method Summary
 void add(java.lang.String field, java.lang.String msg)
          Adds the msg to messages associated with field.
 void addWarning(java.lang.String field, java.lang.String msg)
          Adds (as warning) the msg to messages associated with field.
 java.lang.String checkDate(java.lang.String field, java.lang.String s)
          Checks that s is parsable as a date in one of the formats known to Entity.
 java.lang.String checkDate(java.lang.String field, java.lang.String s, java.text.DateFormat df)
          checkDate() checks to make sure that the given data is in the form required.
 void checkString(java.lang.String field, java.lang.String s)
           
 void checkString(java.lang.String field, java.lang.String encodedString, int maxlength)
          checkString() adds an error if the input string is longer than the specified maximum number of characters (default 255) after being expanded by HTMLEncode()
 void checkStrings(Entity b, java.lang.String fields)
          As a convenience, we provide a method that iterates over all the field names in fields, extracts the corresponding field from the Entity argument b, and checks that the string is not too long to store (>255 chars) after HTML encoding.
 boolean isEmpty()
          isEmpty() says whether there are no errors accumulated.
 java.lang.String toHtml()
          toHtml() produces the appropriate HTML to display any error messages accumulated in ErrorRecord.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorRecord

public ErrorRecord()
Method Detail

isEmpty

public boolean isEmpty()
isEmpty() says whether there are no errors accumulated. Note: Warnings do not count as errors.


add

public void add(java.lang.String field,
                java.lang.String msg)
Adds the msg to messages associated with field. If there is already an entry for field, we simply expand it. Otherwise, create one.


addWarning

public void addWarning(java.lang.String field,
                       java.lang.String msg)
Adds (as warning) the msg to messages associated with field. If there is already an entry for field, we simply expand it. Otherwise, create one.


checkString

public void checkString(java.lang.String field,
                        java.lang.String encodedString,
                        int maxlength)
checkString() adds an error if the input string is longer than the specified maximum number of characters (default 255) after being expanded by HTMLEncode()


checkString

public void checkString(java.lang.String field,
                        java.lang.String s)

checkStrings

public void checkStrings(Entity b,
                         java.lang.String fields)
As a convenience, we provide a method that iterates over all the field names in fields, extracts the corresponding field from the Entity argument b, and checks that the string is not too long to store (>255 chars) after HTML encoding.


checkDate

public java.lang.String checkDate(java.lang.String field,
                                  java.lang.String s,
                                  java.text.DateFormat df)
checkDate() checks to make sure that the given data is in the form required. An empty date ("") is also considered OK.


checkDate

public java.lang.String checkDate(java.lang.String field,
                                  java.lang.String s)
Checks that s is parsable as a date in one of the formats known to Entity. Returns date in format appropriate for storage into a SQL database.


toHtml

public java.lang.String toHtml()
toHtml() produces the appropriate HTML to display any error messages accumulated in ErrorRecord. The HTML produced creates a single-cell table that colors its background light red and produces a definition list