org.vladnput
Class VladError

java.lang.Object
  extended by org.vladnput.VladError

public class VladError
extends java.lang.Object

Class representing a single validation error. It contains information about the requesting IP address, URL, and parameter (if applicable) that failed to validate, as well as a generic message and a list of detailed messages about the error. There is also a maximum number of times that this URL and parameter name combination should be logged and whether this error should be enforced or not. Errors that are not enforced will be logged. It the responsibility of the web application to reject requests that produce enforced errors. Detailed messages are helpful for the cases where a single type can validate multiple aspects. For instance, a string type might check that the string matches a regular expression as well as minimum and maximum length checks. If a value violates both the regular expression and the maximum length, then the detail messages can indicate that both constraints were violated while the generic message can indicate that there was a problem with the parameter without giving that level of detail. A user interface can present these two levels of detail or choose to ignore one or the other as deemed appropriate. This class is not thread-safe.

Author:
Patrick Higgins

Constructor Summary
VladError(java.lang.String url, java.lang.String paramName, java.lang.String paramValue, java.lang.String message, java.lang.String remoteAddr, java.lang.Integer maxLog, boolean enforce)
          Constructs a new error.
 
Method Summary
 void addDetail(java.lang.String msg)
          Adds a detailed error message.
 java.util.List<java.lang.String> getDetails()
          Gets the detailed messages.
 boolean getEnforce()
          Returns true if the error should be enforced (causing the request to be rejected), false otherwise.
 java.lang.Integer getMaxLog()
          Returns the maximum number of times this url and parameter name combination should be logged.
 java.lang.String getMessage()
          Returns the generic error message
 java.lang.String getParamName()
          Returns the name of the invalid parameter
 java.lang.String getParamValue()
          Returns the value of the invalid parameter
 java.lang.String getRemoteAddr()
          Returns the IP address of client that issued the invalid request
 java.lang.String getUrl()
          Returns the URL of the invalid request
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VladError

public VladError(java.lang.String url,
                 java.lang.String paramName,
                 java.lang.String paramValue,
                 java.lang.String message,
                 java.lang.String remoteAddr,
                 java.lang.Integer maxLog,
                 boolean enforce)
Constructs a new error.

Parameters:
url - The URL of the invalid request
paramName - The invalid parameter name, or null if the URL itself was the problem
paramValue - The invalid parameter value, or null if the URL itself was the problem
message - Generic message about the error
remoteAddr - The client IP address which issued the request
maxLog - The maximum number of times this url and parameter name combination should be logged, or null for no limit
enforce - Whether or not this error should be enforced
Method Detail

getUrl

public java.lang.String getUrl()
Returns the URL of the invalid request

Returns:
The URL

getParamName

public java.lang.String getParamName()
Returns the name of the invalid parameter

Returns:
Parameter name

getParamValue

public java.lang.String getParamValue()
Returns the value of the invalid parameter

Returns:
Parameter value

getMessage

public java.lang.String getMessage()
Returns the generic error message

Returns:
Error message

getRemoteAddr

public java.lang.String getRemoteAddr()
Returns the IP address of client that issued the invalid request

Returns:
Client IP address

getMaxLog

public java.lang.Integer getMaxLog()
Returns the maximum number of times this url and parameter name combination should be logged.

Returns:
Maximum number of log entries, or null if there is no limit

getEnforce

public boolean getEnforce()
Returns true if the error should be enforced (causing the request to be rejected), false otherwise.

Returns:
The enforcement value

addDetail

public void addDetail(java.lang.String msg)
Adds a detailed error message.

Parameters:
msg - The message

getDetails

public java.util.List<java.lang.String> getDetails()
Gets the detailed messages.

Returns:
List of String messages, or null if there are none.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009 Patrick Higgins. All Rights Reserved.