com.atlassian.bamboo.utils.error
Class SimpleErrorCollection

java.lang.Object
  extended by com.atlassian.bamboo.utils.error.SimpleErrorCollection
All Implemented Interfaces:
ErrorCollection, java.io.Serializable

public class SimpleErrorCollection
extends java.lang.Object
implements ErrorCollection

See Also:
Serialized Form

Constructor Summary
SimpleErrorCollection()
           
SimpleErrorCollection(java.lang.String... errors)
           
 
Method Summary
 void addError(java.lang.String field, java.lang.String message)
          Add a field-specific error message.
 void addError(java.lang.String prefix, java.lang.String field, java.lang.String message)
          Adds a new form validation error with a given prefix.
 void addErrorCollection(ErrorCollection errors)
          Populate this ErrorCollection with general and field-specific errors.
 void addErrorMessage(java.lang.String message)
          Add error message relating to system state (not field-specific).
 java.lang.String addErrorMessage(java.lang.String message, java.lang.Exception e)
           
 void addErrorMessages(java.util.Collection<java.lang.String> incomingMessages)
          Append new error messages to those already collected.
 void addErrors(java.util.Map<java.lang.String,?> incomingErrors)
          Append new field-specific errors to those already collected.
 java.util.Collection<java.lang.String> getErrorMessages()
          Get all non field-specific error messages.
 java.util.Map<java.lang.String,java.lang.String> getErrors()
          Get all field-specific errors.
 java.util.Map<java.lang.String,java.lang.String> getFieldErrors()
           
 java.util.Collection<java.lang.String> getFlushedErrorMessages()
          Get error messages, then get rid of them.
 int getTotalErrors()
           
 boolean hasAnyErrors()
          Whether any errors (of any type - field-specific or otherwise) have been collected.
 void setErrorMessages(java.util.Collection<java.lang.String> errorMessages)
          Populate this ErrorCollection with a new set of messages (existing errors are lost).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleErrorCollection

public SimpleErrorCollection()

SimpleErrorCollection

public SimpleErrorCollection(java.lang.String... errors)
Method Detail

addError

public void addError(java.lang.String field,
                     java.lang.String message)
Description copied from interface: ErrorCollection
Add a field-specific error message.

Specified by:
addError in interface ErrorCollection
Parameters:
field - Field name, eg. "assignee"
message - Error message.

addErrorMessage

public void addErrorMessage(java.lang.String message)
Description copied from interface: ErrorCollection
Add error message relating to system state (not field-specific).

Specified by:
addErrorMessage in interface ErrorCollection
Parameters:
message - Error message.

getErrorMessages

public java.util.Collection<java.lang.String> getErrorMessages()
Description copied from interface: ErrorCollection
Get all non field-specific error messages.

Specified by:
getErrorMessages in interface ErrorCollection
Returns:
Collection of error Strings.

setErrorMessages

public void setErrorMessages(java.util.Collection<java.lang.String> errorMessages)
Description copied from interface: ErrorCollection
Populate this ErrorCollection with a new set of messages (existing errors are lost).

Specified by:
setErrorMessages in interface ErrorCollection
Parameters:
errorMessages - List of error message Strings.

getFlushedErrorMessages

public java.util.Collection<java.lang.String> getFlushedErrorMessages()
Description copied from interface: ErrorCollection
Get error messages, then get rid of them.

Specified by:
getFlushedErrorMessages in interface ErrorCollection
Returns:
The (now cleared) error messages.

getErrors

public java.util.Map<java.lang.String,java.lang.String> getErrors()
Description copied from interface: ErrorCollection
Get all field-specific errors.

Specified by:
getErrors in interface ErrorCollection
Returns:
Map of String: String pairs, eg. {"assignee": "Assignee is required"}

addErrorCollection

public void addErrorCollection(@NotNull
                               ErrorCollection errors)
Description copied from interface: ErrorCollection
Populate this ErrorCollection with general and field-specific errors.

Specified by:
addErrorCollection in interface ErrorCollection
Parameters:
errors - ErrorCollection whose errors/messages we obtain.

addErrorMessages

public void addErrorMessages(java.util.Collection<java.lang.String> incomingMessages)
Description copied from interface: ErrorCollection
Append new error messages to those already collected.

Specified by:
addErrorMessages in interface ErrorCollection
Parameters:
incomingMessages - Collection of error strings.

addErrorMessage

public java.lang.String addErrorMessage(java.lang.String message,
                                        java.lang.Exception e)
Specified by:
addErrorMessage in interface ErrorCollection

addErrors

public void addErrors(java.util.Map<java.lang.String,?> incomingErrors)
Description copied from interface: ErrorCollection
Append new field-specific errors to those already collected.

Specified by:
addErrors in interface ErrorCollection
Parameters:
incomingErrors - A Map from String field names, to String error messages, or Collections of String error messages.

hasAnyErrors

public boolean hasAnyErrors()
Description copied from interface: ErrorCollection
Whether any errors (of any type - field-specific or otherwise) have been collected.

Specified by:
hasAnyErrors in interface ErrorCollection
Returns:
true if there are errors; false otherwise.

getFieldErrors

public java.util.Map<java.lang.String,java.lang.String> getFieldErrors()
Specified by:
getFieldErrors in interface ErrorCollection

getTotalErrors

public int getTotalErrors()
Specified by:
getTotalErrors in interface ErrorCollection

toString

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

addError

public void addError(java.lang.String prefix,
                     java.lang.String field,
                     java.lang.String message)
Description copied from interface: ErrorCollection
Adds a new form validation error with a given prefix. ie. prefix of "builder.ant" and field "target" will result in a key of "builder.ant.target"

Specified by:
addError in interface ErrorCollection
Parameters:
prefix - The prefix of the field in . form
field - The id of the form element in error
message - The error message to display to the user


Copyright © 2011 Atlassian. All Rights Reserved.