Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* 
   * Copyright (C) 2012 FoxLabs
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.foxlabs.validation;
 
 
 
This context holds current validation state.

Parameters:
<T> The type of validated entity
Author(s):
Fox Mulder
 
 public interface ValidationContext<T> {
    
    
Returns validator used for entity validation.

Returns:
Validator used for entity validation.
 
     Validator<T> getValidator();
     
     // State
     
    
Returns type of the entity we are validating.

Returns:
Type of the entity we are validating.
 
     Class<T> getEntityType();
    
    
Returns metadata of the current entity we are validating.

Returns:
Metadata of the current entity we are validating.
 
     EntityMetaData<T> getEntityMetaData();
    
    
Returns type of the element defined on the entity we are validating.

Returns:
Type of the element defined on the entity we are validating.
 
     Class<?> getElementType();
    
    
Returns name of the element defined on the entity we are validating.

Returns:
Name of the element defined on the entity we are validating.
 
     String getElementName();
    
    
Returns metadata of the current element we are validating.

Returns:
Metadata of the current element we are validating.
 
     <V> ElementMetaData<T, V> getElementMetaData();
    
    
Returns root entity being validated.

Returns:
Root entity being validated.
 
     Object getRootEntity();
    
    
Returns current entity we are validating.

Returns:
Current entity we are validating.
 
     T getCurrentEntity();
    
    
Returns current validation target we are validating.

Returns:
Current validation target we are validating.
 
     ValidationTarget getCurrentTarget();
    
    
Sets current validation target we are validating.

Parameters:
target Current validation target we are validating.
    void setCurrentTarget(ValidationTarget target);
    
    
Returns current item index (or map key) we are validating.

Returns:
Current item index (or map key) we are validating.
    Object getCurrentIndex();
    
    
Sets current item index (or map key) we are validating.

Parameters:
index Current item index (or map key) we are validating.
    void setCurrentIndex(Object index);
    
    // Parameters
    
    
Returns locale to be used for error messages and formatting numbers, dates, etc.

Returns:
Locale to be used for error messages and formatting numbers, dates, etc.
    Locale getMessageLocale();
    
    
Returns filter to be used for property filtering.

Returns:
Filter to be used for property filtering.
    PropertyFilter getPropertyFilter();
    
    
Returns array of constraint groups to be validated.

Returns:
Array of constraint groups to be validated.
    String[] getValidatingGroups();
    
    
Determines if converters should take locale into account.

Returns:
true if converters should take locale into account; false otherwise.
    boolean isLocalizedConvert();
    
    
Determines if validation should fail on the first violation.

Returns:
true if validation should fail on the first violation; false otherwise.
    boolean isFailFast();
    
    
Returns default format of integer numbers for locale returned by the method getMessageLocale(). The format returned is based on the pattern that was configured by the validator factory. If default pattern is not configured then integer number format supported by JRE will be returned.

Returns:
Default format of integer numbers.
    NumberFormat getIntegerFormat();
    
    
Returns format of integer numbers for the specified pattern and locale returned by the method getMessageLocale(). If the specified pattern is null then default format will be returned.

Parameters:
pattern Integer number pattern.
Returns:
Format of integer numbers for the specified pattern.
See also:
getIntegerFormat()
    NumberFormat getIntegerFormat(String pattern);
    
    
Returns default format of decimal numbers for locale returned by the method getMessageLocale(). The format returned is based on the pattern that was configured by the validator factory. If default pattern is not configured then decimal number format supported by JRE will be returned.

Returns:
Default format of decimal numbers.
    NumberFormat getDecimalFormat();
    
    
Returns format of decimal numbers for the specified pattern and locale returned by the method getMessageLocale(). If the specified pattern is null then default format will be returned.

Parameters:
pattern Decimal number pattern.
Returns:
Format of decimal numbers for the specified pattern.
See also:
getDecimalFormat()
    NumberFormat getDecimalFormat(String pattern);
    
    
Returns default format of dates for locale returned by the method getMessageLocale(). The format returned is based on the pattern if it was configured by the validator factory. If default pattern is not configured then date format based on date and time styles will be returned.

Returns:
Default format of dates.
    DateFormat getDateFormat();
    
    
Returns format of dates for the specified pattern and locale returned by the method getMessageLocale(). If the specified pattern is null then default format will be returned.

Parameters:
pattern Date pattern.
Returns:
Format of dates for the specified pattern.
See also:
getDateFormat()
    DateFormat getDateFormat(String pattern);
    
    
Returns format of dates for the specified date and time styles and locale returned by the method getMessageLocale(). If both of the specified styles are negative values then default format will be returned.

Parameters:
dateStyle Date style.
timeStyle Time style.
Returns:
Format of dates for the specified date and time styles.
See also:
getDateFormat()
    DateFormat getDateFormat(int dateStyleint timeStyle);
    
    // Message
    
    
Returns localized message for the specified key and locale returned by the method getMessageLocale().

Returns:
Localized message for the specified key.
    String resolveMessage(String key);
    
    
Builds localized error message for the specified validation component and locale returned by the method getMessageLocale().

Parameters:
component Validation component.
Returns:
Localized error message for the specified validation component.
    String buildMessage(Validation<?> component);
    
New to GrepCode? Check out our FAQ X