Author: hlship
Date: Tue Nov 28 08:17:51 2006
New Revision: 480114
URL: http://svn.apache.org/viewvc?view=rev&rev=480114
Log:
Add initial interfaces defining validation.
Delete out-of-date package folders.
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Translator.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValidationException.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Validator.java
Removed:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/pageload/
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/internal/
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/test/
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Translator.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Translator.java?view=auto&rev=480114
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Translator.java
(added)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Translator.java
Tue Nov 28 08:17:51 2006
@@ -0,0 +1,31 @@
+package org.apache.tapestry;
+
+/**
+ * Translates between client-side and server-side values. Client-side values
are always strings.
+ *
+ * @param <T>
+ */
+public interface Translator<T>
+{
+ /**
+ * Converts a server-side value to a client-side string. This allows for
formatting of the value
+ * in a way appropriate to the end user. The output client value should be
parsable by
+ * [EMAIL PROTECTED] #parseClient(String)}.
+ *
+ * @param value
+ * the server side value (which may be null)
+ * @return client-side value to present to the user
+ */
+ String toClient(T value);
+
+ /**
+ * Converts a submitted request value into an appropriate server side
value.
+ *
+ * @param clientValue
+ * (possibly null or the empty string)
+ * @return equivalent server-side value (possibly null)
+ * @throws ValidationException
+ * if the value can not be parsed
+ */
+ T parseClient(String clientValue) throws ValidationException;
+}
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValidationException.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValidationException.java?view=auto&rev=480114
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValidationException.java
(added)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValidationException.java
Tue Nov 28 08:17:51 2006
@@ -0,0 +1,14 @@
+package org.apache.tapestry;
+
+/**
+ * An exception associated with parsing client input, or validating the input
against a constraint.
+ */
+public class ValidationException extends Exception
+{
+ private static final long serialVersionUID = -6195763584437441540L;
+
+ public ValidationException(String message)
+ {
+ super(message);
+ }
+}
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Validator.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Validator.java?view=auto&rev=480114
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Validator.java
(added)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/Validator.java
Tue Nov 28 08:17:51 2006
@@ -0,0 +1,21 @@
+package org.apache.tapestry;
+
+import sun.security.validator.ValidatorException;
+
+/**
+ * Used by a [EMAIL PROTECTED] Field} to enforce a <strong>constraint</strong>
related to a form submission.
+ */
+public interface Validator<T>
+{
+ /**
+ * Invoked after the client-submitted value has been [EMAIL PROTECTED]
Translator translated} to check that
+ * the value conforms to expectations (often, in terms of minimum or
maximum value). If and only
+ * if the value is approved by all Validators is the value applied by the
field.
+ *
+ * @param field
+ * the field for which a client submitted value is being
validated
+ * @param value
+ * @throws ValidatorException
+ */
+ void check(Field field, T value) throws ValidatorException;
+}