ninja.validation
Class ValidationImpl

java.lang.Object
  extended by ninja.validation.ValidationImpl
All Implemented Interfaces:
Validation

public class ValidationImpl
extends Object
implements Validation

Validation object

Author:
James Roper

Constructor Summary
ValidationImpl(Lang lang)
           
 
Method Summary
 void addFieldViolation(String field, ConstraintViolation constraintViolation)
          Add a violation to the given field
 void addViolation(ConstraintViolation constraintViolation)
          Add a general violation
 ConstraintViolation getFieldViolation(String field)
          Get the voilation for the given field
 String getFieldViolationMessage(String field)
          Get the formatted violation message for the given field
 String getFieldViolationMessage(String field, Locale locale)
          Get the formatted violation message for the given field
 boolean hasFieldViolation(String field)
          Whether the validation context has a violation for the given field
 boolean hasViolations()
          Whether the validation context has violations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationImpl

@Inject
public ValidationImpl(Lang lang)
Method Detail

hasViolations

public boolean hasViolations()
Description copied from interface: Validation
Whether the validation context has violations

Specified by:
hasViolations in interface Validation
Returns:
True if it does

hasFieldViolation

public boolean hasFieldViolation(String field)
Description copied from interface: Validation
Whether the validation context has a violation for the given field

Specified by:
hasFieldViolation in interface Validation
Returns:
True if it does

addFieldViolation

public void addFieldViolation(String field,
                              ConstraintViolation constraintViolation)
Description copied from interface: Validation
Add a violation to the given field

Specified by:
addFieldViolation in interface Validation
Parameters:
field - The field to add the violation to
constraintViolation - The constraint violation

addViolation

public void addViolation(ConstraintViolation constraintViolation)
Description copied from interface: Validation
Add a general violation

Specified by:
addViolation in interface Validation
Parameters:
constraintViolation - The constraint violation

getFieldViolation

public ConstraintViolation getFieldViolation(String field)
Description copied from interface: Validation
Get the voilation for the given field

Specified by:
getFieldViolation in interface Validation
Parameters:
field - The field
Returns:
The constraint violation, or null if no constraint violation was found

getFieldViolationMessage

public String getFieldViolationMessage(String field)
Description copied from interface: Validation
Get the formatted violation message for the given field

Specified by:
getFieldViolationMessage in interface Validation
Parameters:
field - The field
Returns:
The message, or null if there was no violation

getFieldViolationMessage

public String getFieldViolationMessage(String field,
                                       Locale locale)
Description copied from interface: Validation
Get the formatted violation message for the given field

Specified by:
getFieldViolationMessage in interface Validation
Parameters:
field - The field
locale - The locale
Returns:
The message, or null if there was no violation


Copyright © 2012. All Rights Reserved.