You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2011/12/02 17:33:45 UTC

svn commit: r1209569 [34/50] - in /struts/struts2/branches/STRUTS_3_X: apps/blank/src/main/java/example/ apps/blank/src/test/java/example/ apps/jboss-blank/src/main/java/example/ apps/jboss-blank/src/test/java/example/ apps/mailreader/src/main/java/mai...

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/Validations.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/Validations.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/Validations.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/Validations.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <!-- START SNIPPET: description -->
+ * <p>If you want to use several annotations of the same type, these annotations must be nested within the @Validations() annotation.</p>
+ * <!-- END SNIPPET: description -->
+ *
+ * <p/> <u>Annotation usage:</u>
+ *
+ * <!-- START SNIPPET: usage -->
+ * <p/>Used at METHOD level.
+ * <!-- END SNIPPET: usage -->
+ *
+ * <p/> <u>Annotation parameters:</u>
+ *
+ * <!-- START SNIPPET: parameters -->
+ * <table class='confluenceTable'>
+ *
+ * <tr>
+ * <th class='confluenceTh'> Parameter </th>
+ * <th class='confluenceTh'> Required </th>
+ * <th class='confluenceTh'> Notes </th>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> requiredFields </td>
+ * <td class='confluenceTd'> no </td>
+ *
+ * <td class='confluenceTd'> Add list of RequiredFieldValidators  </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> customValidators </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of CustomValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> conversionErrorFields </td>
+ *
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of ConversionErrorFieldValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> dateRangeFields </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of DateRangeFieldValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> emails </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of EmailValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> fieldExpressions </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of FieldExpressionValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> intRangeFields </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of IntRangeFieldValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> requiredStrings </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of RequiredStringValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> stringLengthFields </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of StringLengthFieldValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> urls </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of UrlValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> visitorFields </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of VisitorFieldValidators </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> regexFields </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of RegexFieldValidator </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> expressions </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> Add list of ExpressionValidator </td>
+ * </tr>
+ * </table>
+ * <!-- END SNIPPET: parameters -->
+ *
+ * <p/> <u>Example code:</u>
+ *
+ * <pre>
+ * <!-- START SNIPPET: example -->
+ * &#64;Validations(
+ *           requiredFields =
+ *                   {&#64;RequiredFieldValidator(type = ValidatorType.SIMPLE, fieldName = "customfield", message = "You must enter a value for field.")},
+ *           requiredStrings =
+ *                   {&#64;RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "stringisrequired", message = "You must enter a value for string.")},
+ *           emails =
+ *                   { &#64;EmailValidator(type = ValidatorType.SIMPLE, fieldName = "emailaddress", message = "You must enter a value for email.")},
+ *           urls =
+ *                   { &#64;UrlValidator(type = ValidatorType.SIMPLE, fieldName = "hreflocation", message = "You must enter a value for email.")},
+ *           stringLengthFields =
+ *                   {&#64;StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, minLength="10" , maxLength = "12", fieldName = "needstringlength", message = "You must enter a stringlength.")},
+ *           intRangeFields =
+ *                   { &#64;IntRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "intfield", min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")},
+ *           dateRangeFields =
+ *                   {&#64;DateRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "datefield", min = "-1", max = "99", message = "bar must be between ${min} and ${max}, current value is ${bar}.")},
+ *           expressions = {
+ *               &#64;ExpressionValidator(expression = "foo &gt; 1", message = "Foo must be greater than Bar 1. Foo = ${foo}, Bar = ${bar}."),
+ *               &#64;ExpressionValidator(expression = "foo &gt; 2", message = "Foo must be greater than Bar 2. Foo = ${foo}, Bar = ${bar}."),
+ *               &#64;ExpressionValidator(expression = "foo &gt; 3", message = "Foo must be greater than Bar 3. Foo = ${foo}, Bar = ${bar}."),
+ *               &#64;ExpressionValidator(expression = "foo &gt; 4", message = "Foo must be greater than Bar 4. Foo = ${foo}, Bar = ${bar}."),
+ *               &#64;ExpressionValidator(expression = "foo &gt; 5", message = "Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.")
+ *   }
+ *   )
+ *   public String execute() throws Exception {
+ *       return SUCCESS;
+ *   }
+ * <!-- END SNIPPET: example -->
+ * </pre>
+ *
+ * @author jepjep
+ * @author Rainer Hermanns
+ * @version $Id: Validations.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+@Target( { ElementType.METHOD, ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Validations {
+
+    /**
+     * Custom Validation rules.
+     */
+    public CustomValidator[] customValidators() default {};
+
+    public ConversionErrorFieldValidator[] conversionErrorFields() default {};
+
+    public DateRangeFieldValidator[] dateRangeFields() default {};
+
+    public EmailValidator[] emails() default {};
+
+    public FieldExpressionValidator[] fieldExpressions() default {};
+
+    public IntRangeFieldValidator[] intRangeFields() default {};
+
+    public RequiredFieldValidator[] requiredFields() default {};
+
+    public RequiredStringValidator[] requiredStrings() default {};
+
+    public StringLengthFieldValidator[] stringLengthFields() default {};
+
+    public UrlValidator[] urls() default {};
+    
+    public ConditionalVisitorFieldValidator[] conditionalVisitorFields() default {};
+
+    public VisitorFieldValidator[] visitorFields() default {};
+
+    public RegexFieldValidator[] regexFields() default {};
+
+    public ExpressionValidator[] expressions() default {};
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/ValidatorType.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/ValidatorType.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/ValidatorType.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/ValidatorType.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.annotations;
+
+/**
+ * <code>ValidatorType</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: ValidatorType.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public enum ValidatorType {
+
+    FIELD, SIMPLE;
+
+    @Override
+    public String toString() {
+        return super.toString().toUpperCase();
+    }
+    
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/VisitorFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/VisitorFieldValidator.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/VisitorFieldValidator.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/VisitorFieldValidator.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <!-- START SNIPPET: description -->
+ * The validator allows you to forward validator to object properties of your action
+ * using the objects own validator files. This allows you to use the ModelDriven development
+ * pattern and manage your validations for your models in one place, where they belong, next to
+ * your model classes.
+ *
+ * The VisitorFieldValidator can handle either simple Object properties, Collections of Objects, or Arrays.
+ * The error message for the VisitorFieldValidator will be appended in front of validator messages added
+ * by the validations for the Object message.
+ * <!-- END SNIPPET: description -->
+ *
+ * <p/> <u>Annotation usage:</u>
+ *
+ * <!-- START SNIPPET: usage -->
+ * <p/>The annotation must be applied at method level.
+ * <!-- END SNIPPET: usage -->
+ *
+ * <p/> <u>Annotation parameters:</u>
+ *
+ * <!-- START SNIPPET: parameters -->
+ * <table class='confluenceTable'>
+ * <tr>
+ * <th class='confluenceTh'> Parameter </th>
+ * <th class='confluenceTh'> Required </th>
+ * <th class='confluenceTh'> Default </th>
+ * <th class='confluenceTh'> Notes </th>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'>message</td>
+ * <td class='confluenceTd'>yes</td>
+ * <td class='confluenceTd'>&nbsp;</td>
+ * <td class='confluenceTd'>field error message</td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'>key</td>
+ * <td class='confluenceTd'>no</td>
+ * <td class='confluenceTd'>&nbsp;</td>
+ * <td class='confluenceTd'>i18n key from language specific properties file.</td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'>fieldName</td>
+ * <td class='confluenceTd'>no</td>
+ * <td class='confluenceTd'>&nbsp;</td>
+ * <td class='confluenceTd'>&nbsp;</td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'>shortCircuit</td>
+ * <td class='confluenceTd'>no</td>
+ * <td class='confluenceTd'>false</td>
+ * <td class='confluenceTd'>If this validator should be used as shortCircuit.</td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> context </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> action alias </td>
+ * <td class='confluenceTd'> Determines the context to use for validating the Object property. If not defined, the context of the Action validation is propogated to the Object property validation.  In the case of Action validation, this context is the Action alias.  </td>
+ * </tr>
+ * <tr>
+ * <td class='confluenceTd'> appendPrefix </td>
+ * <td class='confluenceTd'> no </td>
+ * <td class='confluenceTd'> true </td>
+ * <td class='confluenceTd'> Determines whether the field name of this field validator should be prepended to the field name of the visited field to determine the full field name when an error occurs.  For example, suppose that the bean being validated has a "name" property.  If <em>appendPrefix</em> is true, then the field error will be stored under the field "bean.name".  If <em>appendPrefix</em> is false, then the field error will be stored under the field "name".  <br clear="all" /> <img class="emoticon" src="/images/icons/emoticons/warning.gif" height="16" width="16" align="absmiddle" alt="" border="0"/> If you are using the VisitorFieldValidator to validate the model from a ModelDriven Action, you should set <em>appendPrefix</em> to false unless you are using "model.name" to reference the properties on your model. </td>
+ * </tr>
+ * </table>
+ * <!-- END SNIPPET: parameters -->
+ *
+ * <p/> <u>Example code:</u>
+ *
+ * <pre>
+ * <!-- START SNIPPET: example -->
+ * &#64;VisitorFieldValidator(message = "Default message", key = "i18n.key", shortCircuit = true, context = "action alias", appendPrefix = true)
+ * <!-- END SNIPPET: example -->
+ * </pre>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: VisitorFieldValidator.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface VisitorFieldValidator {
+
+    /**
+     * Determines the context to use for validating the Object property.
+     * If not defined, the context of the Action validator is propogated to the Object property validator.
+     * In the case of Action validator, this context is the Action alias.
+     */
+    String context() default "";
+
+    /**
+     * Determines whether the field name of this field validator should be prepended to the field name of
+     * the visited field to determine the full field name when an error occurs. For example, suppose that
+     * the bean being validated has a "name" property.
+     *
+     * If appendPrefix is true, then the field error will be stored under the field "bean.name".
+     * If appendPrefix is false, then the field error will be stored under the field "name".
+     *
+     * If you are using the VisitorFieldValidator to validate the model from a ModelDriven Action,
+     * you should set appendPrefix to false unless you are using "model.name" to reference the properties
+     * on your model.
+     */
+    boolean appendPrefix() default true;
+
+    /**
+     * The default error message for this validator.
+     * NOTE: It is required to set a message, if you are not using the message key for 18n lookup!
+     */
+    String message() default "";
+
+    /**
+     * The message key to lookup for i18n.
+     */
+    String key() default "";
+
+    /**
+     * The optional fieldName for SIMPLE validator types.
+     */
+    String fieldName() default "";
+
+    /**
+     * If this is activated, the validator will be used as short-circuit.
+     *
+     * Adds the short-circuit="true" attribute value if <tt>true</tt>.
+     *
+     */
+    boolean shortCircuit() default false;
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/package.html
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/package.html?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/package.html (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/annotations/package.html Fri Dec  2 16:33:03 2011
@@ -0,0 +1 @@
+<body>Validator annotations.</body>

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/AbstractFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/AbstractFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/AbstractFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/AbstractFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import org.apache.struts2.xwork2.util.logging.Logger;
+import org.apache.struts2.xwork2.util.logging.LoggerFactory;
+
+/**
+ * <code>AbstractFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: AbstractFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public abstract class AbstractFieldValidatorDescription implements ValidatorDescription {
+
+    /**
+     * Jakarta commons-logging reference.
+     */
+    protected static Logger log = null;
+
+    public String fieldName;
+    public String key;
+    public String message;
+    public boolean shortCircuit;
+    public boolean simpleValidator;
+
+
+    public AbstractFieldValidatorDescription() {
+        log = LoggerFactory.getLogger(this.getClass());
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public AbstractFieldValidatorDescription(String fieldName) {
+        this.fieldName = fieldName;
+        log = LoggerFactory.getLogger(this.getClass());
+    }
+
+    /**
+     * Sets the field name for this validator rule.
+     *
+     * @return fieldName the field name for this validator rule
+     */
+    public String getFieldName() {
+        return fieldName;
+    }
+
+    /**
+     * Sets the field name for this validator rule.
+     *
+     * @param fieldName the field name for this validator rule
+     */
+    public void setFieldName(String fieldName) {
+        this.fieldName = fieldName;
+    }
+
+    /**
+     * Sets the I18N message key.
+     * @param key the I18N message key
+     */
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    /**
+     * Sets the default validator failure message.
+     *
+     * @param message the default validator failure message
+     */
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    /**
+     * Set the shortCircuit flag.
+     *
+     * @param shortCircuit the shortCircuit flag.
+     */
+    public void setShortCircuit(boolean shortCircuit) {
+        this.shortCircuit = shortCircuit;
+    }
+
+    public void setSimpleValidator(boolean simpleValidator) {
+        this.simpleValidator = simpleValidator;
+    }
+
+    public boolean isSimpleValidator() {
+        return simpleValidator;
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    public String asXml() {
+        if ( simpleValidator) {
+            return asSimpleXml();
+        }
+        return asFieldXml();
+    }
+
+    /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    public abstract String asFieldXml();
+
+     /**
+      * Returns the validator XML definition.
+      *
+      * @return the validator XML definition.
+      */
+     public abstract String asSimpleXml();
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ConversionErrorFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ConversionErrorFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ConversionErrorFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ConversionErrorFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>ConversionErrorFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: ConversionErrorFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class ConversionErrorFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public ConversionErrorFieldValidatorDescription() {
+        super();
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public ConversionErrorFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+
+    /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if (shortCircuit) {
+                writer.println("\t\t<field-validator type=\"conversion\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"conversion\" short-circuit=\"true\">");
+            }
+
+            if (!"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if (shortCircuit) {
+                writer.println("\t<validator type=\"conversion\">");
+            } else {
+                writer.println("\t<validator type=\"conversion\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName + "</param>");
+
+            if (!"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DateRangeFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DateRangeFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DateRangeFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DateRangeFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>DateRangeFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: DateRangeFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class DateRangeFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public String min;
+    public String max;
+
+    public DateRangeFieldValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public DateRangeFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setMin(String min) {
+        this.min = min;
+    }
+
+    public void setMax(String max) {
+        this.max = max;
+    }
+
+ /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"date\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"date\" short-circuit=\"true\">");
+            }
+            if ( min != null && min.length() > 0) {
+                writer.println("\t\t\t<param name=\"min\">" + min + "</param>");
+            }
+            if ( max != null && max.length() > 0) {
+                writer.println("\t\t\t<param name=\"max\">" + max + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"date\">");
+            } else {
+                writer.println("\t<validator type=\"date\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+
+            if ( min != null && min.length() > 0) {
+                writer.println("\t\t<param name=\"min\">" + min + "</param>");
+            }
+            if ( max != null && max.length() > 0) {
+                writer.println("\t\t<param name=\"max\">" + max + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DoubleRangeFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DoubleRangeFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DoubleRangeFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/DoubleRangeFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>DoubleRangeFieldValidatorDescription</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id: DoubleRangeFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class DoubleRangeFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public String min;
+    public String max;
+
+    public DoubleRangeFieldValidatorDescription() {
+    }
+
+    /**
+     * Creates an DoubleRangeFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public DoubleRangeFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setMin(String min) {
+        this.min = min;
+    }
+
+    public void setMax(String max) {
+        this.max = max;
+    }
+
+    /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"double\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"double\" short-circuit=\"true\">");
+            }
+            if ( min != null && min.length() > 0) {
+                writer.println("\t\t\t<param name=\"min\">" + min + "</param>");
+            }
+            if ( max != null && max.length() > 0) {
+                writer.println("\t\t\t<param name=\"max\">" + max + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"double\">");
+            } else {
+                writer.println("\t<validator type=\"double\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+
+            if ( min != null && min.length() > 0) {
+                writer.println("\t\t<param name=\"min\">" + min + "</param>");
+            }
+            if ( max != null && max.length() > 0) {
+                writer.println("\t\t<param name=\"max\">" + max + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/EmailValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/EmailValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/EmailValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/EmailValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>EmailValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: EmailValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class EmailValidatorDescription extends AbstractFieldValidatorDescription {
+
+
+    public EmailValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public EmailValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    /**
+      * Returns the field validator XML definition.
+      *
+      * @return the field validator XML definition.
+      */
+     @Override
+     public String asFieldXml() {
+         StringWriter sw = new StringWriter();
+         PrintWriter writer = null;
+
+         try {
+             writer = new PrintWriter(sw);
+
+             if ( shortCircuit) {
+                 writer.println("\t\t<field-validator type=\"email\">");
+             } else {
+                 writer.println("\t\t<field-validator type=\"email\" short-circuit=\"true\">");
+             }
+
+             if ( !"".equals(key)) {
+                 writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+             } else {
+                 writer.println("\t\t\t<message>" + message + "</message>");
+             }
+
+             writer.println("\t\t</field-validator>");
+
+         } finally {
+             if (writer != null) {
+                 writer.flush();
+                 writer.close();
+             }
+         }
+         return sw.toString();
+
+     }
+
+     /**
+      * Returns the validator XML definition.
+      *
+      * @return the validator XML definition.
+      */
+     @Override
+     public String asSimpleXml() {
+         StringWriter sw = new StringWriter();
+         PrintWriter writer = null;
+
+         try {
+             writer = new PrintWriter(sw);
+
+             if ( shortCircuit) {
+                 writer.println("\t<validator type=\"email\">");
+             } else {
+                 writer.println("\t<validator type=\"email\" short-circuit=\"true\">");
+             }
+
+             writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+             if ( !"".equals(key)) {
+                 writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+             } else {
+                 writer.println("\t\t<message>" + message + "</message>");
+             }
+
+             writer.println("\t</validator>");
+
+         } finally {
+             if (writer != null) {
+                 writer.flush();
+                 writer.close();
+             }
+         }
+         return sw.toString();
+     }
+
+
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ExpressionValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ExpressionValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ExpressionValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ExpressionValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>ExpressionValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: ExpressionValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class ExpressionValidatorDescription implements ValidatorDescription {
+
+    public String expression;
+    public String key;
+    public String message;
+    public boolean shortCircuit;
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public void setShortCircuit(boolean shortCircuit) {
+        this.shortCircuit = shortCircuit;
+    }
+
+    /**
+     * Returns the field name to create the validation rule for.
+     *
+     * @return The field name to create the validation rule for
+     */
+    public String getFieldName() {
+        throw new UnsupportedOperationException("ExpressionValidator annotations cannot be applied to fields...");
+    }
+
+    public String asXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"expression\">");
+            } else {
+                writer.println("\t<validator type=\"expression\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"expression\">" + expression+ "</param>");
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+    public boolean isSimpleValidator() {
+        return false;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/FieldExpressionValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/FieldExpressionValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/FieldExpressionValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/FieldExpressionValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>FieldExpressionValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: FieldExpressionValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class FieldExpressionValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public String expression;
+    public String key;
+    public String message;
+    public boolean shortCircuit;
+
+    public FieldExpressionValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public FieldExpressionValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+
+    @Override
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    @Override
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    @Override
+    public void setShortCircuit(boolean shortCircuit) {
+        this.shortCircuit = shortCircuit;
+    }
+
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"fieldexpression\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"fieldexpression\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t\t<param name=\"expression\">" + expression+ "</param>");
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        throw new UnsupportedOperationException(getClass().getName() + " cannot be used for simple validators...");
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/IntRangeFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/IntRangeFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/IntRangeFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/IntRangeFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>IntRangeFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: IntRangeFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class IntRangeFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public String min;
+    public String max;
+
+    public IntRangeFieldValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public IntRangeFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setMin(String min) {
+        this.min = min;
+    }
+
+    public void setMax(String max) {
+        this.max = max;
+    }
+
+    /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"int\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"int\" short-circuit=\"true\">");
+            }
+            if ( min != null && min.length() > 0) {
+                writer.println("\t\t\t<param name=\"min\">" + min + "</param>");
+            }
+            if ( max != null && max.length() > 0) {
+                writer.println("\t\t\t<param name=\"max\">" + max + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"int\">");
+            } else {
+                writer.println("\t<validator type=\"int\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+
+            if ( min != null && min.length() > 0) {
+                writer.println("\t\t<param name=\"min\">" + min + "</param>");
+            }
+            if ( max != null && max.length() > 0) {
+                writer.println("\t\t<param name=\"max\">" + max + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+
+
+
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>RequiredFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: RequiredFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class RequiredFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public RequiredFieldValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public RequiredFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+     /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"required\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"required\" short-circuit=\"true\">");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"required\">");
+            } else {
+                writer.println("\t<validator type=\"required\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredStringValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredStringValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredStringValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/RequiredStringValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>RequiredStringValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: RequiredStringValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class RequiredStringValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public boolean trim = true;
+
+    public RequiredStringValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public RequiredStringValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setTrim(boolean trim) {
+        this.trim = trim;
+    }
+
+    /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"requiredstring\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"requiredstring\" short-circuit=\"true\">");
+            }
+            if ( !trim) {
+                writer.println("\t\t\t<param name=\"trim\">" + trim + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"requiredstring\">");
+            } else {
+                writer.println("\t<validator type=\"requiredstring\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+            if ( !trim) {
+                writer.println("\t\t<param name=\"trim\">" + trim + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/StringLengthFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/StringLengthFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/StringLengthFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/StringLengthFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>StringLengthFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: StringLengthFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class StringLengthFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public boolean trim = true;
+    public String minLength;
+    public String maxLength;
+
+    public StringLengthFieldValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public StringLengthFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setTrim(boolean trim) {
+        this.trim = trim;
+    }
+
+    public void setMinLength(String minLength) {
+        this.minLength = minLength;
+    }
+
+    public void setMaxLength(String maxLength) {
+        this.maxLength = maxLength;
+    }
+
+   /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"stringlength\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"stringlength\" short-circuit=\"true\">");
+            }
+            if ( !trim) {
+                writer.println("\t\t\t<param name=\"trim\">" + trim + "</param>");
+            }
+            if ( minLength != null && minLength.length() > 0) {
+                writer.println("\t\t\t<param name=\"minLength\">" + minLength + "</param>");
+            }
+            if ( maxLength != null && maxLength.length() > 0) {
+                writer.println("\t\t\t<param name=\"maxLength\">" + maxLength + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"stringlength\">");
+            } else {
+                writer.println("\t<validator type=\"stringlength\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+            if ( !trim) {
+                writer.println("\t\t<param name=\"trim\">" + trim + "</param>");
+            }
+
+            if ( minLength != null && minLength.length() > 0) {
+                writer.println("\t\t<param name=\"minLength\">" + minLength + "</param>");
+            }
+            if ( maxLength != null && maxLength.length() > 0) {
+                writer.println("\t\t<param name=\"maxLength\">" + maxLength + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/URLValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/URLValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/URLValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/URLValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>URLValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: URLValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class URLValidatorDescription extends AbstractFieldValidatorDescription {
+
+
+    public URLValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified aliasNames.
+     *
+     * @param fieldName
+     */
+    public URLValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+
+   /**
+     * Returns the field validator XML definition.
+     *
+     * @return the field validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"url\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"url\" short-circuit=\"true\">");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t<validator type=\"url\">");
+            } else {
+                writer.println("\t<validator type=\"url\" short-circuit=\"true\">");
+            }
+
+            writer.println("\t\t<param name=\"fieldName\">" + fieldName+ "</param>");
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t</validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/ValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+/**
+ * <code>ValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: ValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public interface ValidatorDescription {
+
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    String asXml();
+
+    /**
+     * Returns the field name to create the validation rule for.
+     *
+     * @return The field name to create the validation rule for
+     */
+    String getFieldName();
+
+    /**
+     * Sets the I18N message key.
+     * @param key the I18N message key
+     */
+    void setKey(String key);
+
+    /**
+     * Sets the default validator failure message.
+     *
+     * @param message the default validator failure message
+     */
+    void setMessage(String message);
+
+    /**
+     * Set the shortCircuit flag.
+     *
+     * @param shortCircuit the shortCircuit flag.
+     */
+    void setShortCircuit(boolean shortCircuit);
+
+    boolean isSimpleValidator();
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/VisitorFieldValidatorDescription.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/VisitorFieldValidatorDescription.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/VisitorFieldValidatorDescription.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/VisitorFieldValidatorDescription.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.metadata;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <code>VisitorFieldValidatorDescription</code>
+ *
+ * @author Rainer Hermanns
+ * @version $Id: VisitorFieldValidatorDescription.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class VisitorFieldValidatorDescription extends AbstractFieldValidatorDescription {
+
+    public String context;
+    public boolean appendPrefix = true;
+
+    public VisitorFieldValidatorDescription() {
+    }
+
+    /**
+     * Creates an AbstractFieldValidatorDescription with the specified field name.
+     *
+     * @param fieldName
+     */
+    public VisitorFieldValidatorDescription(String fieldName) {
+        super(fieldName);
+    }
+
+    public void setContext(String context) {
+        this.context = context;
+    }
+
+    public void setAppendPrefix(boolean appendPrefix) {
+        this.appendPrefix = appendPrefix;
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asFieldXml() {
+        StringWriter sw = new StringWriter();
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(sw);
+
+            if ( shortCircuit) {
+                writer.println("\t\t<field-validator type=\"visitor\">");
+            } else {
+                writer.println("\t\t<field-validator type=\"visitor\" short-circuit=\"true\">");
+            }
+
+            if ( context != null && context.length() > 0) {
+                writer.println("\t\t\t<param name=\"context\">" + context + "</param>");
+            }
+
+            if ( !appendPrefix) {
+                writer.println("\t\t\t<param name=\"appendPrefix\">" + appendPrefix + "</param>");
+            }
+
+            if ( !"".equals(key)) {
+                writer.println("\t\t\t<message key=\"" + key + "\">" + message + "</message>");
+            } else {
+                writer.println("\t\t\t<message>" + message + "</message>");
+            }
+
+            writer.println("\t\t</field-validator>");
+
+        } finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+        return sw.toString();
+    }
+
+    /**
+     * Returns the validator XML definition.
+     *
+     * @return the validator XML definition.
+     */
+    @Override
+    public String asSimpleXml() {
+        throw new UnsupportedOperationException(getClass().getName() + " cannot be used for simple validators...");
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/package.html
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/package.html?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/package.html (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/metadata/package.html Fri Dec  2 16:33:03 2011
@@ -0,0 +1 @@
+<body>Validator meta data classes.</body>

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/package.html
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/package.html?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/package.html (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/package.html Fri Dec  2 16:33:03 2011
@@ -0,0 +1 @@
+<body>XWork validation subsystem.</body>
\ No newline at end of file

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/AbstractRangeValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/AbstractRangeValidator.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/AbstractRangeValidator.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/AbstractRangeValidator.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * 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.apache.struts2.xwork2.validator.validators;
+
+import org.apache.struts2.xwork2.validator.ValidationException;
+
+
+/**
+ * Base class for range based validators.
+ *
+ * @author Jason Carreira
+ * @author Cameron Braid
+ */
+public abstract class AbstractRangeValidator extends FieldValidatorSupport {
+
+    public void validate(Object object) throws ValidationException {
+        Object obj = getFieldValue(getFieldName(), object);
+        Comparable value = (Comparable) obj;
+
+        // if there is no value - don't do comparison
+        // if a value is required, a required validator should be added to the field
+        if (value == null) {
+            return;
+        }
+
+        // only check for a minimum value if the min parameter is set
+        if ((getMinComparatorValue() != null) && (value.compareTo(getMinComparatorValue()) < 0)) {
+            addFieldError(getFieldName(), object);
+        }
+
+        // only check for a maximum value if the max parameter is set
+        if ((getMaxComparatorValue() != null) && (value.compareTo(getMaxComparatorValue()) > 0)) {
+            addFieldError(getFieldName(), object);
+        }
+    }
+
+    protected abstract Comparable getMaxComparatorValue();
+
+    protected abstract Comparable getMinComparatorValue();
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/ConditionalVisitorFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/ConditionalVisitorFieldValidator.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/ConditionalVisitorFieldValidator.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/main/java/org/apache/struts2/xwork2/validator/validators/ConditionalVisitorFieldValidator.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,77 @@
+package org.apache.struts2.xwork2.validator.validators;
+
+import org.apache.struts2.xwork2.validator.ValidationException;
+
+/**
+ * <code>ConditionalVisitorFieldValidator</code>
+ *
+ *
+ * &lt;field name="colleaguePosition"&gt;
+ *   &lt;field-validator type="fieldexpression" short-circuit="true"&gt;
+ *     reason == 'colleague' and colleaguePositionID == '_CHOOSE_'
+ *     &lt;message&gt;You must choose a position where you worked with this person,
+ * or choose "Other..."&lt;/message&gt;
+ *   &lt;/field-validator&gt;
+ *   &lt;field-validator type="conditionalvisitor"&gt;
+ *     reason == 'colleague' and colleaguePositionID == 'OTHER'
+ *     &lt;message/&gt;
+ *   &lt;/field-validator&gt;
+ * &lt;/field&gt;
+ *
+ * @author Matt Raible
+ */
+public class ConditionalVisitorFieldValidator extends VisitorFieldValidator {
+    private String expression;
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+
+    public String getExpression() {
+        return expression;
+    }
+
+    /**
+     * If expression evaluates to true, invoke visitor validation.
+     *
+     * @param object the object being validated
+     * @throws ValidationException
+     */
+    @Override
+    public void validate(Object object) throws ValidationException {
+        if (validateExpression(object)) {
+            super.validate(object);
+        }
+    }
+
+    /**
+     * Validate the expression contained in the "expression" paramter.
+     *
+     * @param object the object you're validating
+     * @return true if expression evaluates to true (implying a validation
+     *         failure)
+     * @throws ValidationException if anything goes wrong
+     */
+    public boolean validateExpression(Object object) throws ValidationException {
+        Boolean answer = Boolean.FALSE;
+        Object obj = null;
+
+        try {
+            obj = getFieldValue(expression, object);
+        }
+        catch (ValidationException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            // let this pass, but it will be logged right below
+        }
+
+        if ((obj != null) && (obj instanceof Boolean)) {
+            answer = (Boolean) obj;
+        } else {
+            log.warn("Got result of " + obj + " when trying to get Boolean.");
+        }
+
+        return answer;
+    }
+} 
\ No newline at end of file