Public: Fix gwt compile errors in javax.validation.
I changed InputStreams to Strings and Local to GwtLocale.
For the Validation class, I completely gutted it,
bootstraping validation in GWT will not use this class.
Review at http://gwt-code-reviews.appspot.com/764801
Review by: rjrjr@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8536 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/build.xml b/user/build.xml
index 346b233..b9ab352 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -109,7 +109,7 @@
<pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
<pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
<pathelement location="${gwt.tools}/redist/json/r2_20080312/json-1.5.jar" />
- <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar" />
+ <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar" />
<path refid="test.extraclasspath" />
</classpath>
</gwt.javac>
@@ -132,7 +132,11 @@
<gwt.checkstyle>
<fileset dir="src" >
<exclude name="javax/validation/super/javax/validation/constraints/Pattern.java"/>
- </fileset>
+ <exclude name="javax/validation/super/javax/validation/spi/ConfigurationState.java"/>
+ <exclude name="javax/validation/super/javax/validation/MessageInterpolator.java"/>
+ <exclude name="javax/validation/super/javax/validation/Configuration.java"/>
+ <exclude name="javax/validation/super/javax/validation/Validation.java"/>
+ </fileset>
<fileset dir="super/com/google/gwt/emul" />
<fileset dir="super/com/google/gwt/junit/translatable" />
</gwt.checkstyle>
diff --git a/user/src/javax/validation/super/javax/validation/Configuration.java b/user/src/javax/validation/super/javax/validation/Configuration.java
new file mode 100644
index 0000000..7a792a4
--- /dev/null
+++ b/user/src/javax/validation/super/javax/validation/Configuration.java
@@ -0,0 +1,203 @@
+// $Id: Configuration.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.
+*/
+// Changed by Google
+package javax.validation;
+
+
+/**
+ * Receives configuration information, selects the appropriate
+ * Bean Validation provider and builds the appropriate <code>ValidatorFactory</code>.
+ * <p/>
+ * Usage:
+ * <pre>
+ * {@code
+ * Configuration<?> configuration = //provided by one of the Validation bootstrap methods
+ * ValidatorFactory = configuration
+ * .messageInterpolator( new CustomMessageInterpolator() )
+ * .buildValidatorFactory();}
+ * </pre>
+ * <p/>
+ * By default, the configuration information is retrieved from
+ * <i>META-INF/validation.xml</i>.
+ * It is possible to override the configuration retrieved from the XML file
+ * by using one or more of the <code>Configuration</code> methods.
+ * <p/>
+ * The {@link ValidationProviderResolver} is specified at configuration time
+ * (see {@link javax.validation.spi.ValidationProvider}).
+ * If none is explicitly requested, the default <code>ValidationProviderResolver</code> is used.
+ * <p/>
+ * The provider is selected in the following way:
+ * <ul>
+ * <li>if a specific provider is requested programmatically using
+ * <code>Validation.byProvider(Class)</code>, find the first provider implementing
+ * the provider class requested and use it</li>
+ * <li>if a specific provider is requested in <i>META-INF/validation.xml</i>,
+ * find the first provider implementing the provider class requested and use it</li>
+ * <li>otherwise, use the first provider returned by the <code>ValidationProviderResolver<code></li>
+ * </ul>
+ * <p/>
+ * Implementations are not meant to be thread-safe.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface Configuration<T extends Configuration<T>> {
+
+ /**
+ * Ignore data from the <i>META-INF/validation.xml</i> file if this
+ * method is called.
+ * This method is typically useful for containers that parse
+ * <i>META-INF/validation.xml</i> themselves and pass the information
+ * via the <code>Configuration</code> methods.
+ *
+ * @return <code>this</code> following the chaining method pattern.
+ */
+ T ignoreXmlConfiguration();
+
+ /**
+ * Defines the message interpolator used. Has priority over the configuration
+ * based message interpolator.
+ * If <code>null</code> is passed, the default message interpolator is used
+ * (defined in XML or the specification default).
+ *
+ * @param interpolator message interpolator implementation.
+ *
+ * @return <code>this</code> following the chaining method pattern.
+ */
+ T messageInterpolator(MessageInterpolator interpolator);
+
+ /**
+ * Defines the traversable resolver used. Has priority over the configuration
+ * based traversable resolver.
+ * If <code>null</code> is passed, the default traversable resolver is used
+ * (defined in XML or the specification default).
+ *
+ * @param resolver traversable resolver implementation.
+ *
+ * @return <code>this</code> following the chaining method pattern.
+ */
+ T traversableResolver(TraversableResolver resolver);
+
+ /**
+ * Defines the constraint validator factory. Has priority over the configuration
+ * based constraint factory.
+ * If null is passed, the default constraint validator factory is used
+ * (defined in XML or the specification default).
+ *
+ * @param constraintValidatorFactory constraint factory inmplementation.
+ *
+ * @return <code>this</code> following the chaining method pattern.
+ */
+ T constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory);
+
+ /**
+ * Add a stream describing constraint mapping in the Bean Validation
+ * XML format.
+ * <p/>
+ * The stream should be closed by the client API after the
+ * <code>ValidatorFactory</code> has been built. The Bean Validation provider
+ * must not close the stream.
+ *
+ * @param stream XML mapping stream.
+ *
+ * @return <code>this</code> following the chaining method pattern.
+ * @throws IllegalArgumentException if <code>stream</code> is null
+ */
+ T addMapping(String stream);
+
+ /**
+ * Add a provider specific property. This property is equivalent to
+ * XML configuration properties.
+ * If the underlying provider does not know how to handle the property,
+ * it must silently ignore it.
+ * <p/>
+ * Note: Using this non type-safe method is generally not recommended.
+ * <p/>
+ * It is more appropriate to use, if available, the type-safe equivalent provided
+ * by a specific provider via its <code>Configuration<code> subclass.
+ * <code>ValidatorFactory factory = Validation.byProvider(ACMEPrivoder.class)
+ * .configure()
+ * .providerSpecificProperty(ACMEState.FAST)
+ * .buildValidatorFactory();
+ * </code>
+ * This method is typically used by containers parsing <i>META-INF/validation.xml</i>
+ * themselves and injecting the state to the Configuration object.
+ * <p/>
+ * If a property with a given name is defined both via this method and in the
+ * XML configuration, the value set programmatically has priority.
+ *
+ * If null is passed as a value, the value defined in XML is used. If no value
+ * is defined in XML, the property is considered unset.
+ *
+ * @param name property name.
+ * @param value property value.
+ * @return <code>this</code> following the chaining method pattern.
+ *
+ * @throws IllegalArgumentException if <code>name</code> is null
+ */
+ T addProperty(String name, String value);
+
+ /**
+ * Return an implementation of the <code>MessageInterpolator</code> interface
+ * following the default <code>MessageInterpolator</code> defined in the
+ * specification:
+ * <ul>
+ * <li>use the ValidationMessages resource bundle to load keys</li>
+ * <li>use Locale.getDefault()</li>
+ * </ul>
+ *
+ * @return default MessageInterpolator implementation compliant with the specification
+ */
+ MessageInterpolator getDefaultMessageInterpolator();
+
+ /**
+ * Return an implementation of the <code>TraversableResolver</code> interface
+ * following the default <code>TraversableResolver</code> defined in the
+ * specification:
+ * <ul>
+ * <li>if Java Persistence is available in the runtime environment,
+ * a property is considered reachable if Java Persistence considers
+ * the property as loaded</li>
+ * <li>if Java Persistence is not available in the runtime environment,
+ * all properties are considered reachable</li>
+ * <li>all properties are considered cascadable.</li>
+ * </ul>
+ *
+ * @return default TraversableResolver implementation compliant with the specification
+ */
+ TraversableResolver getDefaultTraversableResolver();
+
+ /**
+ * Return an implementation of the <code>ConstraintValidatorFactory</code> interface
+ * following the default <code>ConstraintValidatorFactory</code> defined in the
+ * specification:
+ * <ul>
+ * <li>uses the public no-arg constructor of the <code>ConstraintValidator</code></li>
+ * </ul>
+ *
+ * @return default ConstraintValidatorFactory implementation compliant with the specification
+ */
+ ConstraintValidatorFactory getDefaultConstraintValidatorFactory();
+
+ /**
+ * Build a <code>ValidatorFactory</code> implementation.
+ *
+ * @return ValidatorFactory
+ * @throws ValidationException if the ValidatorFactory cannot be built
+ */
+ ValidatorFactory buildValidatorFactory();
+}
diff --git a/user/src/javax/validation/super/javax/validation/MessageInterpolator.java b/user/src/javax/validation/super/javax/validation/MessageInterpolator.java
new file mode 100644
index 0000000..7507ad5
--- /dev/null
+++ b/user/src/javax/validation/super/javax/validation/MessageInterpolator.java
@@ -0,0 +1,73 @@
+// $Id: MessageInterpolator.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.
+*/
+//Changed by Google
+package javax.validation;
+
+import javax.validation.metadata.ConstraintDescriptor;
+
+import com.google.gwt.i18n.shared.GwtLocale;
+
+/**
+ * Interpolate a given constraint violation message.
+ * Implementations should be as tolerant as possible on syntax errors.
+ *<p>
+ * Modified to use {@link GwtLocale} instead of {@link java.util.Locale}.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public interface MessageInterpolator {
+ /**
+ * Interpolate the message template based on the contraint validation context.
+ * The locale is defaulted according to the <code>MessageInterpolator</code>
+ * implementation. See the implementation documentation for more detail.
+ *
+ * @param messageTemplate The message to interpolate.
+ * @param context contextual information related to the interpolation
+ *
+ * @return Interpolated error message.
+ */
+ String interpolate(String messageTemplate, Context context);
+
+ /**
+ * Interpolate the message template based on the contraint validation context.
+ * The <code>Locale</code> used is provided as a parameter.
+ *
+ * @param messageTemplate The message to interpolate.
+ * @param context contextual information related to the interpolation
+ * @param locale the locale targeted for the message
+ *
+ * @return Interpolated error message.
+ */
+ String interpolate(String messageTemplate, Context context, GwtLocale locale);
+
+ /**
+ * Information related to the interpolation context
+ */
+ interface Context {
+ /**
+ * @return ConstraintDescriptor corresponding to the constraint being validated
+ */
+ ConstraintDescriptor<?> getConstraintDescriptor();
+
+ /**
+ * @return value being validated
+ */
+ Object getValidatedValue();
+ }
+}
diff --git a/user/src/javax/validation/super/javax/validation/Validation.java b/user/src/javax/validation/super/javax/validation/Validation.java
new file mode 100644
index 0000000..3c7e8bb
--- /dev/null
+++ b/user/src/javax/validation/super/javax/validation/Validation.java
@@ -0,0 +1,28 @@
+// $Id: Validation.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.
+*/
+// Changed by Google
+package javax.validation;
+
+
+
+/**
+ * Skip.
+ * This is not the right way to bootstrap validation in GWT.
+ */
+public class Validation {
+}
diff --git a/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java b/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java
new file mode 100644
index 0000000..3037ddb
--- /dev/null
+++ b/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java
@@ -0,0 +1,123 @@
+// $Id: ConfigurationState.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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 javax.validation.spi;
+
+import java.util.Map;
+import java.util.Set;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
+
+/**
+ * Contract between a <code>Configuration</code> and a
+ * </code>ValidatorProvider</code> to create a <code>ValidatorFactory</code>.
+ * The configuration artifacts defined in the XML configuration and provided to the
+ * <code>Configuration</code> are merged and passed along via
+ * <code>ConfigurationState</code>.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public interface ConfigurationState {
+
+ /**
+ * Returns true if Configuration.ignoreXMLConfiguration() has been called
+ * In this case, the ValidatorFactory must ignore META-INF/validation.xml
+ *
+ * @return {@code true} if META-INF/validation.xml should be ignored
+ */
+ boolean isIgnoreXmlConfiguration();
+
+ /**
+ * Returns the message interpolator of this configuration.
+ * Message interpolator is defined in the following decreasing priority:
+ * <ul>
+ * <li>set via the <code>Configuration</code> programmatic API</li>
+ * <li>defined in META-INF/validation.xml provided that ignoreXmlConfiguration
+ * is false. In this case the instance is created via its no-arg constructor.</li>
+ * <li>{@code null} if undefined.</li>
+ * </ul>
+ *
+ * @return message provider instance or null if not defined
+ */
+ MessageInterpolator getMessageInterpolator();
+
+ /**
+ * Returns a set of configuration streams.
+ * The streams are defined by:
+ * <ul>
+ * <li>mapping XML streams passed programmatically in <code>Configuration</code></li>
+ * <li>mapping XML stream located in the resources defined in</li>
+ * META-INF/validation.xml (constraint-mapping element)
+ * </ul>
+ * Streams represented in the XML configuration and opened by the
+ * <code>Configuration</code> implementation must be closed by the
+ * <code>Configuration</code> implementation after the <code>ValidatorFactory</code>
+ * creation (or if an exception occurs).
+ *
+ * <p/>
+ * GWT change: Rerturn a set of Strings intest of a InputStream.
+ *
+ * @return set of Strings (was input stream)
+ */
+ Set<String> getMappingStreams();
+
+ /**
+ * Returns the constraint validator factory of this configuration.
+ * The {@code ConstraintValidatorFactory} implementation is defined in the following
+ * decreasing priority:
+ * <ul>
+ * <li>set via the <code>Configuration</code> programmatic API</li>
+ * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration
+ * is false. In this case the instance is created via its no-arg constructor.</li>
+ * <li>{@code null} if undefined.</li>
+ * </ul>
+ *
+ * @return factory instance or {@code null} if not defined
+ */
+ ConstraintValidatorFactory getConstraintValidatorFactory();
+
+ /**
+ * Returns the traversable resolver for this configuration.
+ * <code>TraversableResolver</code> is defined in the following decreasing priority:
+ * <ul>
+ * <li>set via the <code>Configuration</code> programmatic API</li>
+ * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration
+ * is false. In this case the instance is created via its no-arg constructor.</li>
+ * <li>{@code null} if undefined.</li>
+ * </ul>
+ *
+ * @return traversable provider instance or {@code null} if not defined
+ */
+ TraversableResolver getTraversableResolver();
+
+ /**
+ * Returns a map of non type-safe custom properties.
+ * Properties defined via:
+ * <ul>
+ * <li>Configuration.addProperty(String, String)</li>
+ * <li>META-INF/validation.xml provided that ignoredXmlConfiguration</li>
+ * is false.
+ * </ul>
+ * If a property is defined both programmatically and in XML,
+ * the value defined programmatically has priority
+ *
+ * @return Map whose key is the property key and the value the property value
+ */
+ Map<String, String> getProperties();
+}