Remove validation packagse from the GWT 2.1 branch. Patch by: bobv Review by: rjrjr git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/2.1@8953 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/build.xml b/samples/build.xml index 6b78224..9db9033 100644 --- a/samples/build.xml +++ b/samples/build.xml
@@ -38,10 +38,6 @@ <gwt.ant dir="showcase" /> </target> - <target name="validation" description="Build validation"> - <gwt.ant dir="validation" /> - </target> - <target name="-do" description="Run all subprojects" > <antcall target="dynatable" /> <antcall target="dynatablerf" /> @@ -51,7 +47,6 @@ <antcall target="logexample" /> <antcall target="mail" /> <antcall target="showcase" /> - <antcall target="validation" /> </target> <target name="build" description="Builds GWT">
diff --git a/samples/validation/build.xml b/samples/validation/build.xml deleted file mode 100755 index 0c75492..0000000 --- a/samples/validation/build.xml +++ /dev/null
@@ -1,6 +0,0 @@ -<project name="validation" default="build" basedir="."> - <property name="sample.root" value="validation" /> - <property name="sample.module" value="Validation" /> - <property name="sample.path" value="src" /> - <import file="../common.ant.xml" /> -</project>
diff --git a/samples/validation/src/com/google/gwt/sample/validation/COPYING b/samples/validation/src/com/google/gwt/sample/validation/COPYING deleted file mode 100644 index d9a10c0..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/COPYING +++ /dev/null
@@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS
diff --git a/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml b/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml deleted file mode 100644 index 8b74b57..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml +++ /dev/null
@@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright 2010 Google Inc. --> -<!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> -<!-- may not use this file except in compliance with the License. You may --> -<!-- 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. License for the specific language governing permissions and --> -<!-- limitations under the License. --> - -<module rename-to='validation'> - <inherits name='com.google.gwt.rpc.RPC'/> - <inherits name='com.google.gwt.user.User'/> - <inherits name='com.google.gwt.user.theme.standard.Standard'/> - <inherits name='com.google.gwt.validation.Validation'/> - - <entry-point class='com.google.gwt.sample.validation.client.Validation'/> - - <source path='client'/> - <source path='shared'/> -</module>
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java b/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java deleted file mode 100644 index 41f61f4..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.client; - -import com.google.gwt.rpc.client.RpcService; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; - -/** - * The client side stub for the RPC service. - */ -@RemoteServiceRelativePath("greet") -public interface GreetingService extends RpcService { - String greetServer(Person name) throws IllegalArgumentException; -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java b/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java deleted file mode 100644 index cbc3b97..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.client; - -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.user.client.rpc.AsyncCallback; - -/** - * The async counterpart of <code>GreetingService</code>. - */ -public interface GreetingServiceAsync { - void greetServer(Person person, AsyncCallback<String> callback) - throws IllegalArgumentException; -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidator.java b/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidator.java deleted file mode 100644 index 14f8bb5..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidator.java +++ /dev/null
@@ -1,29 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.client; - -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.validation.client.GwtValidation; - -import javax.validation.Validator; - -/** - * Validator marker for the Valiation Sample project. Only the classes listed in - * the {@link GwtValidation} annotation can be validated. - */ -@GwtValidation(Person.class) -public interface SampleValidator extends Validator { -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/Validation.java b/samples/validation/src/com/google/gwt/sample/validation/client/Validation.java deleted file mode 100644 index 6a33243..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/Validation.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.user.client.ui.RootPanel; - -/** - * Entry point classes define <code>onModuleLoad()</code>. - */ -public class Validation implements EntryPoint { - - /** - * Create a remote service proxy to talk to the server-side Greeting service. - */ - private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class); - - - /** - * This is the entry point method. - */ - public void onModuleLoad() { - - Person person = new Person(); - ValidationView view = new ValidationView(person, greetingService); - RootPanel.get("view").add(view); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java b/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java deleted file mode 100644 index 21a90f7..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java +++ /dev/null
@@ -1,162 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.resources.client.CssResource; -import com.google.gwt.sample.validation.shared.Person; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validator; - -/** - * Display the Validation sample. - */ -public class ValidationView extends Composite { - interface MyStyle extends CssResource { - String error(); - } - - interface ValidationViewUiBinder extends UiBinder<Widget, ValidationView> { - } - - /** - * The message displayed to the user when the server cannot be reached or - * returns an error. - */ - private static final String SERVER_ERROR = "An error occurred while " - + "attempting to contact the server. Please check your network " - + "connection and try again."; - - private static ValidationViewUiBinder uiBinder = GWT.create(ValidationViewUiBinder.class); - - @UiField - Button closeButton; - - @UiField - DialogBox dialogBox; - - @UiField - Label errorLabel; - - @UiField - TextBox nameField; - - @UiField - Button sendButton; - - @UiField - HTML serverResponse; - - @UiField - MyStyle style; - - @UiField - Label textToServer; - - private final GreetingServiceAsync greetingService; - - private final Person person; - - public ValidationView(Person person, GreetingServiceAsync greetingService) { - - this.person = person; - - this.greetingService = greetingService; - initWidget(uiBinder.createAndBindUi(this)); - - nameField.setText(person.getName()); - } - - @UiHandler("closeButton") - public void doClick(ClickEvent e) { - dialogBox.hide(); - sendButton.setEnabled(true); - sendButton.setFocus(true); - } - - @UiHandler("sendButton") - void onClick(ClickEvent e) { - sendPersonToServer(); - } - - @UiHandler("sendButton") - void onKeyPress(KeyUpEvent e) { - if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - sendPersonToServer(); - } - } - - /** - * Send the person from the nameField to the server and wait for a response. - */ - private void sendPersonToServer() { - errorLabel.setText(""); - person.setName(nameField.getText()); - - Validator validator = GWT.create(SampleValidator.class); - - Set<ConstraintViolation<Person>> violations = validator.validate(person); - if (!violations.isEmpty()) { - StringBuffer errorMessage = new StringBuffer(); - for (ConstraintViolation<Person> constraintViolation : violations) { - if (errorMessage.length() == 0) { - errorMessage.append('\n'); - } - errorMessage.append(constraintViolation.getMessage()); - } - errorLabel.setText(errorMessage.toString()); - return; - } - sendButton.setEnabled(false); - textToServer.setText(person.getName()); - serverResponse.setText(""); - greetingService.greetServer(person, new AsyncCallback<String>() { - public void onFailure(Throwable caught) { - // Show the RPC error message to the user - dialogBox.setText("Remote Procedure Call - Failure"); - serverResponse.addStyleName(style.error()); - serverResponse.setHTML(SERVER_ERROR); - dialogBox.center(); - closeButton.setFocus(true); - } - - public void onSuccess(String result) { - dialogBox.setText("Remote Procedure Call"); - serverResponse.removeStyleName(style.error()); - serverResponse.setHTML(result); - dialogBox.center(); - closeButton.setFocus(true); - } - }); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.ui.xml b/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.ui.xml deleted file mode 100644 index dc7c5a6..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.ui.xml +++ /dev/null
@@ -1,52 +0,0 @@ -<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> -<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" - xmlns:g="urn:import:com.google.gwt.user.client.ui"> - <ui:style type ="com.google.gwt.sample.validation.client.ValidationView.MyStyle"> - @external .gwt-DialogBox; - .gwt-DialogBox { - width: 400px; - } - .panel { - align: center; - } - .send { - display: block; - font-size: 16pt; - } - .error { - color: red; - } - .dialogPanel { - margin: 5px; - } - .close { - margin: 15px 6px 6px; - } - </ui:style> - <g:VerticalPanel styleName="{style.panel}"> - <g:FlowPanel> - <g:Label>Please enter your name:</g:Label> - <g:TextBox ui:field="nameField">GWT User</g:TextBox> - </g:FlowPanel> - <g:Button styleName="{style.send}" ui:field="sendButton">Send</g:Button> - <g:Label styleName="{style.error}" ui:field="errorLabel" /> - <g:DialogBox ui:field="dialogBox" - animationEnabled="true" - text="Remote Procedure Call" - visible="false" - width="400"> - <g:VerticalPanel styleName="dialogPanel"> - <g:HTML> - <b>Sending name to the server:</b> - </g:HTML> - <g:Label ui:field="textToServer" /> - <g:HTML> - <br /> - <b>Server replies:</b> - </g:HTML> - <g:HTML ui:field="serverResponse" /> - <g:Button styleName="{style.close}" ui:field="closeButton">Close</g:Button> - </g:VerticalPanel> - </g:DialogBox> - </g:VerticalPanel> -</ui:UiBinder> \ No newline at end of file
diff --git a/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java b/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java deleted file mode 100644 index 00a2bd8..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java +++ /dev/null
@@ -1,60 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.server; - -import com.google.gwt.rpc.server.RpcServlet; -import com.google.gwt.sample.validation.client.GreetingService; -import com.google.gwt.sample.validation.shared.Person; - -/** - * The server side implementation of the RPC service. - */ -@SuppressWarnings("serial") -public class GreetingServiceImpl extends RpcServlet implements - GreetingService { - - public String greetServer(Person person) throws IllegalArgumentException { - // Verify that the input is valid. - - // TODO(nchalko) validate - - String serverInfo = getServletContext().getServerInfo(); - String userAgent = getThreadLocalRequest().getHeader("User-Agent"); - - // Escape data from the client to avoid cross-site script vulnerabilities. - String value = escapeHtml(person.getName()); - userAgent = escapeHtml(userAgent); - - return "Hello, " + value + "!<br><br>I am running " + serverInfo - + ".<br><br>It looks like you are using:<br>" + userAgent; - } - - /** - * Escape an html string. Escaping data received from the client helps to - * prevent cross-site script vulnerabilities. - * - * @param html the html string to escape - * @return the escaped string - */ - private String escapeHtml(String html) { - // TODO(nchalko) use SafeHtml after it's integrated. - if (html == null) { - return null; - } - return html.replaceAll("&", "&").replaceAll("<", "<").replaceAll( - ">", ">"); - } -}
diff --git a/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java b/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java deleted file mode 100644 index 27d196b..0000000 --- a/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.sample.validation.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -/** - * A sample bean to show validation on. - */ -public class Person implements IsSerializable { - - @NotNull - @Size(min = 4) - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -}
diff --git a/samples/validation/war/Validation.css b/samples/validation/war/Validation.css deleted file mode 100644 index ebf683e..0000000 --- a/samples/validation/war/Validation.css +++ /dev/null
@@ -1,15 +0,0 @@ -/** Add css rules here for your application. */ - - -/** Example rules used by the template application (remove for your app) */ -h1 { - font-size: 2em; - font-weight: bold; - color: #777777; - margin: 40px 0px 70px; - text-align: center; -} - -.serverResponseLabelError { - color: red; -}
diff --git a/samples/validation/war/Validation.html b/samples/validation/war/Validation.html deleted file mode 100644 index 32654de..0000000 --- a/samples/validation/war/Validation.html +++ /dev/null
@@ -1,58 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- --> -<!-- Copyright 2010 Google Inc. --> -<!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> -<!-- may not use this file except in compliance with the License. You may --> -<!-- 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. License for the specific language governing permissions and --> -<!-- limitations under the License. --> -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - - <!-- --> - <!-- Consider inlining CSS to reduce the number of requested files --> - <!-- --> - <link type="text/css" rel="stylesheet" href="Validation.css"> - - <!-- --> - <!-- Any title is fine --> - <!-- --> - <title>javax.validation Starter Project</title> - - <!-- --> - <!-- This script loads your compiled module. --> - <!-- If you add any GWT meta tags, they must --> - <!-- be added before this line. --> - <!-- --> - <script type="text/javascript" language="javascript" src="validation/validation.nocache.js"></script> - </head> - - <!-- --> - <!-- The body can have arbitrary html, or --> - <!-- you can leave the body empty if you want --> - <!-- to create a completely dynamic UI. --> - <!-- --> - <body> - - <!-- OPTIONAL: include this if you want history support --> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - - <!-- RECOMMENDED if your web app will not function without JavaScript enabled --> - <noscript> - <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> - Your web browser must have JavaScript enabled - in order for this application to display correctly. - </div> - </noscript> - - <h1>javax.validation Starter Project</h1> - <div id="view" /> - </body> -</html>
diff --git a/samples/validation/war/WEB-INF/classes/marker b/samples/validation/war/WEB-INF/classes/marker deleted file mode 100644 index e69de29..0000000 --- a/samples/validation/war/WEB-INF/classes/marker +++ /dev/null
diff --git a/samples/validation/war/WEB-INF/web.xml b/samples/validation/war/WEB-INF/web.xml deleted file mode 100644 index 9f79f03..0000000 --- a/samples/validation/war/WEB-INF/web.xml +++ /dev/null
@@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<web-app> - - <!-- Servlets --> - <servlet> - <servlet-name>greetServlet</servlet-name> - <servlet-class>com.google.gwt.sample.validation.server.GreetingServiceImpl</servlet-class> - </servlet> - - <servlet-mapping> - <servlet-name>greetServlet</servlet-name> - <url-pattern>/validation/greet</url-pattern> - </servlet-mapping> - - <!-- Default page to serve --> - <welcome-file-list> - <welcome-file>Validation.html</welcome-file> - </welcome-file-list> - -</web-app>
diff --git a/samples/validation/war/favicon.ico b/samples/validation/war/favicon.ico deleted file mode 100644 index 25c8d88..0000000 --- a/samples/validation/war/favicon.ico +++ /dev/null Binary files differ
diff --git a/user/build.xml b/user/build.xml index 88b61c6..c674c04 100755 --- a/user/build.xml +++ b/user/build.xml
@@ -136,13 +136,7 @@ <target name="checkstyle" description="Static analysis of source"> <gwt.checkstyle> - <fileset dir="src" > - <exclude name="javax/validation/super/javax/validation/constraints/Pattern.java"/> - <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="src" /> <fileset dir="super/com/google/gwt/emul" /> <fileset dir="super/com/google/gwt/junit/translatable" /> </gwt.checkstyle>
diff --git a/user/src/com/google/gwt/validation/Validation.gwt.xml b/user/src/com/google/gwt/validation/Validation.gwt.xml deleted file mode 100644 index ce2ab6d..0000000 --- a/user/src/com/google/gwt/validation/Validation.gwt.xml +++ /dev/null
@@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - 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. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.regexp.RegExp" /> - <inherits name="javax.validation.Validation" /> - <source path="client" /> - - <!-- Generators --> - <generate-with class="com.google.gwt.validation.rebind.ValidatorGenerator"> - <when-type-assignable class="javax.validation.Validator" /> - </generate-with> - <generate-with - class="com.google.gwt.validation.rebind.GwtSpecificValidatorGenerator"> - <when-type-assignable - class="com.google.gwt.validation.client.impl.GwtSpecificValidator" /> - </generate-with> -</module>
diff --git a/user/src/com/google/gwt/validation/client/GwtValidation.java b/user/src/com/google/gwt/validation/client/GwtValidation.java deleted file mode 100644 index d9520f9..0000000 --- a/user/src/com/google/gwt/validation/client/GwtValidation.java +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Annotates a {@link javax.validation.Validator} explicitly listing the classes - * that can be validated in GWT. - * <p> - * Define the Validator you want explicitly listing the class you want to - * validate. - * - * <pre> - * @GwtValidation(MyBean.class, MyOther.class) - * public interface MyValidator extends javax.validation.Validator { - * } - * </pre> - * Create and use the validator. - * - * <pre> - * MyValidator validator = GWT.create(MyValidator.class); - * MyBean bean = new MyBean(); - * ... - * Set<ConstraintViolation<MyBean>> violations = validator.validate(bean); - * </pre> - * - */ -@Documented -@Target(TYPE) -@Retention(RUNTIME) -public @interface GwtValidation { - - /** - * The list of Classes which can be validated by the annotated - * {@link GwtValidator}. - */ - Class<?>[] value(); - - /** - * The list of Groups which can be processed by the annotated - * {@link GwtValidator}, empty means all groups. - */ - Class<?>[] groups() default {}; -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMaxValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMaxValidator.java deleted file mode 100644 index 7f3d269..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMaxValidator.java +++ /dev/null
@@ -1,50 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.DecimalMax; - -/** - * Abstract {@link DecimalMax} constraint validator implementation for a - * <code>T</code>. - * - * @param <T> the type of object to validate - */ -public abstract class AbstractDecimalMaxValidator<T> implements - ConstraintValidator<DecimalMax, T> { - - private BigDecimal max; - - public AbstractDecimalMaxValidator() { - super(); - } - - public final void initialize(DecimalMax constraintAnnotation) { - try { - max = new BigDecimal(constraintAnnotation.value()); - } catch (NumberFormatException e) { - throw new IllegalArgumentException(constraintAnnotation.value() - + " does not represent a valid BigDecimal format", e); - } - } - - protected final boolean isValid(BigDecimal bigValue) { - return max.compareTo(bigValue) >= 0; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMinValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMinValidator.java deleted file mode 100644 index c0c6748..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractDecimalMinValidator.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.DecimalMin; - -/** - * Abstract {@link DecimalMin} constraint validator implementation for a - * <code>T</code>. - * - * @param <T> the type of object to validate - */ -public abstract class AbstractDecimalMinValidator<T> implements - ConstraintValidator<DecimalMin, T> { - - private BigDecimal min; - - public final void initialize(DecimalMin constraintAnnotation) { - try { - min = new BigDecimal(constraintAnnotation.value()); - } catch (NumberFormatException e) { - throw new IllegalArgumentException(constraintAnnotation.value() - + " does not represent a valid BigDecimal format", e); - } - } - - protected final boolean isValid(BigDecimal bigValue) { - return min.compareTo(bigValue) <= 0; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractDigitsValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractDigitsValidator.java deleted file mode 100644 index 3b21514..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractDigitsValidator.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Digits; - -/** - * Abstract {@link Digits} constraint validator implementation for a - * <code>T</code>. - * - * @param <T> the type of object to validate - */ -public abstract class AbstractDigitsValidator<T> implements - ConstraintValidator<Digits, T> { - - private int fraction; - private int integer; - - public final void initialize(Digits constraintAnnotation) { - if (!(constraintAnnotation.fraction() >= 0)) { - throw new IllegalArgumentException( - "@Digits.fraction must be a nonnegative nubmer"); - } - if (!(constraintAnnotation.integer() >= 0)) { - throw new IllegalArgumentException( - "@Digits.integer must be a nonnegative nubmer"); - } - fraction = constraintAnnotation.fraction(); - integer = constraintAnnotation.integer(); - } - - protected final boolean isValid(BigDecimal bigValue) { - int integerLength = bigValue.precision() - bigValue.scale(); - if (integerLength > integer) { - return false; - } - int fractionalLength = bigValue.scale() < 0 ? 0 : bigValue.scale(); - return fractionalLength <= fraction; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractMaxValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractMaxValidator.java deleted file mode 100644 index 5465269..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractMaxValidator.java +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Max; - -/** - * - * @param <T> the type of object to validate - */ -public abstract class AbstractMaxValidator<T> implements - ConstraintValidator<Max, T> { - - private long max; - - public final void initialize(Max constraintAnnotation) { - max = constraintAnnotation.value(); - } - - protected final boolean isValid(Number value) { - if (value instanceof BigDecimal) { - return ((BigDecimal) value).compareTo(BigDecimal.valueOf(max)) <= 0; - } else if (value instanceof BigInteger) { - return ((BigInteger) value).compareTo(BigInteger.valueOf(max)) <= 0; - } else { - return value.longValue() <= max; - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractMinValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractMinValidator.java deleted file mode 100644 index 0fab154..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractMinValidator.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Min; - -/** - * Abstract {@link Min} constraint validator implementation for a <code>T</code> - * . - * - * @param <T> the type of object to validate - */ -public abstract class AbstractMinValidator<T> implements - ConstraintValidator<Min, T> { - - private long min; - - public final void initialize(Min constraintAnnotation) { - min = constraintAnnotation.value(); - } - - protected final boolean isValid(Number value) { - if (value instanceof BigDecimal) { - return ((BigDecimal) value).compareTo(BigDecimal.valueOf(min)) >= 0; - } else if (value instanceof BigInteger) { - return ((BigInteger) value).compareTo(BigInteger.valueOf(min)) >= 0; - } else { - return value.longValue() >= min; - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AbstractSizeValidator.java b/user/src/com/google/gwt/validation/client/constraints/AbstractSizeValidator.java deleted file mode 100644 index 43d38b5..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AbstractSizeValidator.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.Size; - -/** - * Abstract {@link Size} constraint validator implementation. - * - * @param <T> - */ -public abstract class AbstractSizeValidator<T> implements - ConstraintValidator<Size, T> { - - private int min; - private int max; - - public AbstractSizeValidator() { - super(); - } - - public final void initialize(Size annotation) { - if (!(annotation.min() >= 0)) { - throw new IllegalArgumentException( - "@Size.min must be a nonnegative nubmer"); - } - if (!(annotation.max() >= 0)) { - throw new IllegalArgumentException( - "@Size.max must be a nonnegative nubmer"); - } - if (!(annotation.min() <= annotation.max())) { - throw new IllegalArgumentException( - "@Size.min must be less than or equal to @Size.max"); - } - min = annotation.min(); - max = annotation.max(); - } - - protected final boolean isLengthValid(int length) { - return min <= length && length <= max; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/constraints/AssertFalseValidator.java b/user/src/com/google/gwt/validation/client/constraints/AssertFalseValidator.java deleted file mode 100644 index ee44197..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AssertFalseValidator.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.AssertFalse; - -/** - * {@link AssertFalse} constraint validator implementation. - */ -public class AssertFalseValidator implements - ConstraintValidator<AssertFalse, Boolean> { - - public void initialize(AssertFalse constraintAnnotation) { - } - - public boolean isValid(Boolean value, ConstraintValidatorContext context) { - return value == null || !value.booleanValue(); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/AssertTrueValidator.java b/user/src/com/google/gwt/validation/client/constraints/AssertTrueValidator.java deleted file mode 100644 index dfd5827..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/AssertTrueValidator.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.AssertTrue; - -/** - * {@link AssertTrue} constraint validator implementation. - */ -public class AssertTrueValidator implements - ConstraintValidator<AssertTrue, Boolean> { - - public void initialize(AssertTrue constraintAnnotation) { - } - - public boolean isValid(Boolean value, ConstraintValidatorContext context) { - return value == null || value.booleanValue(); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumber.java deleted file mode 100644 index 668b3d5..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumber.java +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMax} constraint validator - * implementation for a {@link Number}. - */ -public class DecimalMaxValidatorForNumber extends - AbstractDecimalMaxValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - if (value instanceof BigDecimal) { - return isValid((BigDecimal) value); - } - if (value instanceof BigInteger) { - return isValid(new BigDecimal((BigInteger) value)); - } - return isValid(BigDecimal.valueOf(value.doubleValue())); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForString.java deleted file mode 100644 index 16e378f..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMax} constraint validator - * implementation for a {@link String}. - */ -public class DecimalMaxValidatorForString extends - AbstractDecimalMaxValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumber.java deleted file mode 100644 index eaf5169..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumber.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMin} constraint validator - * implementation for a {@link Number}. - */ -public class DecimalMinValidatorForNumber extends - AbstractDecimalMinValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } else if (value instanceof BigDecimal) { - BigDecimal bigValue = (BigDecimal) value; - return isValid(bigValue); - } else if (value instanceof BigInteger) { - return isValid(new BigDecimal((BigInteger) value)); - } else { - return isValid(BigDecimal.valueOf(value.doubleValue())); - } - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForString.java deleted file mode 100644 index eca67de..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DecimalMinValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.DecimalMax} constraint validator - * implementation for a {@link String}. - */ -public class DecimalMinValidatorForString extends - AbstractDecimalMinValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForNumber.java deleted file mode 100644 index 8e10b66..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForNumber.java +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Digits} constraint validator - * implementation for a {@link Number}. - */ -public class DigitsValidatorForNumber extends AbstractDigitsValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } else if (value instanceof BigDecimal) { - BigDecimal bigValue = (BigDecimal) value; - return isValid(bigValue); - } else if (value instanceof BigInteger) { - return isValid(new BigDecimal((BigInteger) value)); - } else { - return isValid(BigDecimal.valueOf(value.doubleValue())); - } - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForString.java deleted file mode 100644 index 227453d..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/DigitsValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Digits} constraint validator - * implementation for a {@link String}. - */ -public class DigitsValidatorForString extends AbstractDigitsValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/FutureValidatorForDate.java b/user/src/com/google/gwt/validation/client/constraints/FutureValidatorForDate.java deleted file mode 100644 index f007213..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/FutureValidatorForDate.java +++ /dev/null
@@ -1,40 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Future; - -/** - * {@link Future} constraint validator implementation for a - * {@link java.util.Date}. - */ -public class FutureValidatorForDate implements - ConstraintValidator<Future, Date> { - - public void initialize(Future constraintAnnotation) { - } - - public boolean isValid(Date value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return value.after(new Date()); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForNumber.java deleted file mode 100644 index e5adf31..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForNumber.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Max} constraint validator implementation - * for a {@link Number}. - */ -public class MaxValidatorForNumber extends AbstractMaxValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isValid(value); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForString.java deleted file mode 100644 index e3fc8c0..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MaxValidatorForString.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Max} constraint validator implementation - * for a {@link String}. - */ -public class MaxValidatorForString extends AbstractMaxValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForNumber.java b/user/src/com/google/gwt/validation/client/constraints/MinValidatorForNumber.java deleted file mode 100644 index 16865dd..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForNumber.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Min} constraint validator implementation - * for a {@link Number}. - */ -public class MinValidatorForNumber extends AbstractMinValidator<Number> { - - public boolean isValid(Number value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isValid(value); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/MinValidatorForString.java deleted file mode 100644 index 7c713af..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/MinValidatorForString.java +++ /dev/null
@@ -1,40 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Min} constraint validator implementation - * for a {@link String}. - */ -public class MinValidatorForString extends AbstractMinValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - BigDecimal bigValue; - try { - bigValue = new BigDecimal(value); // TODO(nchalko) deal with i18n - } catch (NumberFormatException e) { - return false; - } - return isValid(bigValue); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/NotNullValidator.java b/user/src/com/google/gwt/validation/client/constraints/NotNullValidator.java deleted file mode 100644 index 95aec12..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/NotNullValidator.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.NotNull; - -/** - * {@link NotNull} constraint validator implementation. - */ -public class NotNullValidator implements ConstraintValidator<NotNull, Object> { - - public void initialize(NotNull constraintAnnotation) { - } - - public boolean isValid(Object value, ConstraintValidatorContext context) { - return value != null; - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/NullValidator.java b/user/src/com/google/gwt/validation/client/constraints/NullValidator.java deleted file mode 100644 index ed46cd6..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/NullValidator.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Null; - -/** - * {@link Null} constraint validator implementation. - */ -public class NullValidator implements ConstraintValidator<Null, Object> { - - public void initialize(Null constraintAnnotation) { - } - - public boolean isValid(Object value, ConstraintValidatorContext context) { - return value == null; - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/PastValidatorForDate.java b/user/src/com/google/gwt/validation/client/constraints/PastValidatorForDate.java deleted file mode 100644 index 4a7f0c8..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/PastValidatorForDate.java +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Past; - -/** - * {@link Past} constraint validator implementation for a {@link java.util.Date}. - */ -public class PastValidatorForDate implements ConstraintValidator<Past, Date> { - - public void initialize(Past constraintAnnotation) { - } - - public boolean isValid(Date value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return value.before(new Date()); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java b/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java deleted file mode 100644 index 59ec77a..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import com.google.gwt.regexp.shared.RegExp; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Pattern.Flag; - -/** - * {@link Pattern} constraint validator implementation. - * <p> - * Note this implementation uses {@link RegExp} which differs from - * {@link java.util.regex.Pattern}. - */ -public class PatternValidator implements ConstraintValidator<Pattern, String> { - private RegExp pattern; - - public void initialize(Pattern annotation) { - Pattern.Flag flags[] = annotation.flags(); - String flagString = ""; - for (Pattern.Flag flag : flags) { - flagString += toString(flag); - } - pattern = RegExp.compile(annotation.regexp(), flagString); - } - - public boolean isValid(String value, ConstraintValidatorContext context) { - return value == null || pattern.exec(value) != null; - } - - private String toString(Flag flag) { - String value; - switch (flag) { - case CASE_INSENSITIVE: - case UNICODE_CASE: - value = "i"; - break; - case MULTILINE: - value = "m"; - break; - default: - throw new IllegalArgumentException(flag - + " is not a suppoted gwt Pattern (RegExp) flag"); - } - return value; - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBoolean.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBoolean.java deleted file mode 100644 index 4fccc09..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBoolean.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link boolean}s. - */ -public class SizeValidatorForArrayOfBoolean extends - AbstractSizeValidator<boolean[]> { - - public boolean isValid(boolean[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByte.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByte.java deleted file mode 100644 index 071d54c..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByte.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link byte}s. - */ -public class SizeValidatorForArrayOfByte extends AbstractSizeValidator<byte[]> { - - public boolean isValid(byte[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfChar.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfChar.java deleted file mode 100644 index 4303890..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfChar.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link char}s. - */ -public class SizeValidatorForArrayOfChar extends AbstractSizeValidator<char[]> { - - public boolean isValid(char[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDouble.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDouble.java deleted file mode 100644 index ebb2019..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDouble.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link double}s. - */ -public class SizeValidatorForArrayOfDouble extends - AbstractSizeValidator<double[]> { - - public boolean isValid(double[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloat.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloat.java deleted file mode 100644 index 4b149dd..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloat.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link float}s. - */ -public class SizeValidatorForArrayOfFloat extends - AbstractSizeValidator<float[]> { - - public boolean isValid(float[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfInt.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfInt.java deleted file mode 100644 index 3211dbf..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfInt.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link int}s. - */ -public class SizeValidatorForArrayOfInt extends AbstractSizeValidator<int[]> { - - public boolean isValid(int[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLong.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLong.java deleted file mode 100644 index a67f5b1..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLong.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link long}s. - */ -public class SizeValidatorForArrayOfLong extends AbstractSizeValidator<long[]> { - - public boolean isValid(long[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObject.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObject.java deleted file mode 100644 index 3264f43..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObject.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link Object}s. - */ -public class SizeValidatorForArrayOfObject extends - AbstractSizeValidator<Object[]> { - - public boolean isValid(Object[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShort.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShort.java deleted file mode 100644 index 4dc9c17..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShort.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a array of {@link short}s. - */ -public class SizeValidatorForArrayOfShort extends - AbstractSizeValidator<short[]> { - - public boolean isValid(short[] value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length); - } -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForCollection.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForCollection.java deleted file mode 100644 index 7f5b4ef..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForCollection.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Collection; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a {@link Collection}. - */ -public class SizeValidatorForCollection extends - AbstractSizeValidator<Collection<?>> { - - public boolean isValid(Collection<?> value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.size()); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForMap.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForMap.java deleted file mode 100644 index d820181..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForMap.java +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Map; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a {@link Map}. - */ -public class SizeValidatorForMap extends AbstractSizeValidator<Map<?, ?>> { - - public boolean isValid(Map<?, ?> value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.size()); - } - -}
diff --git a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForString.java b/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForString.java deleted file mode 100644 index c25fcac..0000000 --- a/user/src/com/google/gwt/validation/client/constraints/SizeValidatorForString.java +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidatorContext; - -/** - * {@link javax.validation.constraints.Size} constraint validator implementation - * for a {@link String}. - */ -public class SizeValidatorForString extends AbstractSizeValidator<String> { - - public boolean isValid(String value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - return isLengthValid(value.length()); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/AbstractBeanDescriptor.java b/user/src/com/google/gwt/validation/client/impl/AbstractBeanDescriptor.java deleted file mode 100644 index 9f42398..0000000 --- a/user/src/com/google/gwt/validation/client/impl/AbstractBeanDescriptor.java +++ /dev/null
@@ -1,88 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.validation.metadata.ConstraintDescriptor; -import javax.validation.metadata.PropertyDescriptor; - -/** - * Abstract BeanDescriptor for use by generated {@link GwtBeanDescriptor}. - * <p> - * Subclasses are expected to call setDescriptorMap from the constructor. - * - * @param <T> the bean Type - */ -public abstract class AbstractBeanDescriptor<T> implements GwtBeanDescriptor<T> { - - private final Class<T> clazz; - - private final Set<ConstraintDescriptor<?>> constraints = new HashSet<ConstraintDescriptor<?>>(); - private final Map<String, PropertyDescriptor> descriptor = new HashMap<String, PropertyDescriptor>(); - - /** - * @param clazz - */ - public AbstractBeanDescriptor(Class<T> clazz) { - super(); - this.clazz = clazz; - } - - public ConstraintFinder findConstraints() { - // TODO(nchalko) implement - return null; - } - - public Set<PropertyDescriptor> getConstrainedProperties() { - return new HashSet<PropertyDescriptor>(descriptor.values()); - } - - public Set<ConstraintDescriptor<?>> getConstraintDescriptors() { - // Copy for safety - return new HashSet<ConstraintDescriptor<?>>(constraints); - } - - public PropertyDescriptor getConstraintsForProperty(String propertyName) { - return descriptor.get(propertyName); - } - - public Class<?> getElementClass() { - return clazz; - } - - public boolean hasConstraints() { - return !constraints.isEmpty(); - } - - public boolean isBeanConstrained() { - return true; - } - - protected void setDescriptorMap(Map<String, PropertyDescriptor> map) { - descriptor.clear(); - descriptor.putAll(map); - constraints.clear(); - for (PropertyDescriptor p : descriptor.values()) { - if (p.hasConstraints()) { - constraints.addAll(p.getConstraintDescriptors()); - } - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java b/user/src/com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java deleted file mode 100644 index 3894f33..0000000 --- a/user/src/com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java +++ /dev/null
@@ -1,97 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; -import java.util.Set; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintViolation; - -/** - * Base methods for implementing a {@link GwtSpecificValidator}. - * <p> - * All methods that do not need to be generated go here. - * - * @param <G> the type object to validate - */ -public abstract class AbstractGwtSpecificValidator<G> implements - GwtSpecificValidator<G> { - - /** - * @param <A> - * @param <T> - * @param <V> - * @param context - * @param violations - * @param object - * @param value - * @param validator - * @param constraintDescriptor - * @param groups - */ - protected <A extends Annotation, T, V> void validate( - GwtValidationContext<T> context, Set<ConstraintViolation<T>> violations, - G object, V value, ConstraintValidator<A, V> validator, - ConstraintDescriptorImpl<A> constraintDescriptor, Class<?>[] groups) { - validator.initialize(constraintDescriptor.getAnnotation()); - ConstraintValidatorContextImpl<A, V> constraintValidatorContext = - context.createConstraintValidatorContext(constraintDescriptor); - if (!validator.isValid(value, constraintValidatorContext)) { - addViolations(// - context, // - violations, // - object, // - value, // - constraintDescriptor, // - constraintValidatorContext); - } - } - - private <V, T, A extends Annotation> void addViolations( - GwtValidationContext<T> context, Set<ConstraintViolation<T>> violations, - G object, V value, ConstraintDescriptorImpl<A> constraintDescriptor, - ConstraintValidatorContextImpl<A, V> constraintValidatorContext) { - Set<MessageAndPath> mps = constraintValidatorContext.getMessageAndPaths(); - for (MessageAndPath messageAndPath : mps) { - ConstraintViolation<T> violation = createConstraintViolation(// - context, // - object, // - value, // - constraintDescriptor, // - messageAndPath); - violations.add(violation); - } - } - - private <T, V, A extends Annotation> ConstraintViolation<T> createConstraintViolation( - GwtValidationContext<T> context, G object, V value, - ConstraintDescriptorImpl<A> constraintDescriptor, - MessageAndPath messageAndPath) { - // TODO(nchalko) interpolate - ConstraintViolation<T> violation = ConstraintViolationImpl.<T> builder() // - .setConstraintDescriptor(constraintDescriptor) // - .setInvalidValue(value) // - .setLeafBean(object) // - .setMessage(messageAndPath.getMessage()) // - .setMessageTemplate(messageAndPath.getMessage()) // - .setPropertyPath(messageAndPath.getPath()) // - .setRootBean(context.getRootBean()) // - .setRootBeanClass(context.getRootBeanClass()) // - .build(); - return violation; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/AbstractGwtValidator.java b/user/src/com/google/gwt/validation/client/impl/AbstractGwtValidator.java deleted file mode 100644 index e5b7487..0000000 --- a/user/src/com/google/gwt/validation/client/impl/AbstractGwtValidator.java +++ /dev/null
@@ -1,31 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import javax.validation.ValidationException; -import javax.validation.Validator; - -/** - * Base methods for implementing {@link Validator} in GWT. - * <p> - * All methods that do not need to be generated go here. - */ -public abstract class AbstractGwtValidator implements Validator { - - public <T> T unwrap(Class<T> type) { - throw new ValidationException(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java deleted file mode 100644 index 5ef4804..0000000 --- a/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java +++ /dev/null
@@ -1,155 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.validation.ConstraintValidator; -import javax.validation.Payload; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * A immutable GWT implementation of {@link ConstraintDescriptor}. - * - * @param <T> the constraint annotation to describe. - */ -public class ConstraintDescriptorImpl<T extends Annotation> implements - ConstraintDescriptor<T> { - - /** - * Builder for {@link ConstraintDescriptorImpl}. - * - * @param <T> the constraint annotation to describe. - */ - public static class Builder<T extends Annotation> { - private T annotation; - private Set<Class<?>> groups; - private Set<Class<? extends Payload>> payload; - private List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses; - private Map<String, Object> attributes; - private Set<ConstraintDescriptor<?>> composingConstraints; - private boolean reportAsSingleViolation; - - public ConstraintDescriptorImpl<T> build() { - return new ConstraintDescriptorImpl<T>( - annotation, // - groups, // - payload, // - constraintValidatorClasses, // - attributes, // - composingConstraints, // - reportAsSingleViolation); - } - - public Builder<T> setAnnotation(T annotation) { - this.annotation = annotation; - return this; - } - - public Builder<T> setAttributes(Map<String, Object> attributes) { - this.attributes = attributes; - return this; - } - - public Builder<T> setComposingConstraints( - Set<ConstraintDescriptor<?>> composingConstraints) { - this.composingConstraints = composingConstraints; - return this; - } - - public Builder<T> setConstraintValidatorClasses( - List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses) { - this.constraintValidatorClasses = constraintValidatorClasses; - return this; - } - - public Builder<T> setGroups(Set<Class<?>> groups) { - this.groups = groups; - return this; - } - - public Builder<T> setPayload(Set<Class<? extends Payload>> payload) { - this.payload = payload; - return this; - } - - public Builder<T> setReportAsSingleViolation(boolean reportAsSingleViolation) { - this.reportAsSingleViolation = reportAsSingleViolation; - return this; - } - } - - public static <T extends Annotation> Builder<T> builder() { - return new Builder<T>(); - } - - private final T annotation; - private final Set<Class<?>> groups; - private final Set<Class<? extends Payload>> payload; - private final List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses; - private final Map<String, Object> attributes; - private final Set<ConstraintDescriptor<?>> composingConstraints; - private final boolean reportAsSingleViolation; - - private ConstraintDescriptorImpl( - T annotation, - Set<Class<?>> groups, - Set<Class<? extends Payload>> payload, - List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses, - Map<String, Object> attributes, - Set<ConstraintDescriptor<?>> composingConstraints, - boolean reportAsSingleViolation) { - super(); - this.annotation = annotation; - this.groups = groups; - this.payload = payload; - this.constraintValidatorClasses = constraintValidatorClasses; - this.attributes = attributes; - this.composingConstraints = composingConstraints; - this.reportAsSingleViolation = reportAsSingleViolation; - } - - public T getAnnotation() { - return annotation; - } - - public Map<String, Object> getAttributes() { - return attributes; - } - - public Set<ConstraintDescriptor<?>> getComposingConstraints() { - return composingConstraints; - } - - public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() { - return constraintValidatorClasses; - } - - public Set<Class<?>> getGroups() { - return groups; - } - - public Set<Class<? extends Payload>> getPayload() { - return payload; - } - - public boolean isReportAsSingleViolation() { - return reportAsSingleViolation; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintValidatorContextImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintValidatorContextImpl.java deleted file mode 100644 index 1705c4a..0000000 --- a/user/src/com/google/gwt/validation/client/impl/ConstraintValidatorContextImpl.java +++ /dev/null
@@ -1,218 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; -import java.util.HashSet; -import java.util.Set; - -import javax.validation.ConstraintValidatorContext; -import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext; -import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext; -import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder; -import javax.validation.ConstraintViolation; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * GWT safe immutable implementation of {@link ConstraintValidatorContext} - * <p> - * These objects are very short lived. - * - * @param <A> the constraint being validated - * @param <T> the type of object being validated - */ -public class ConstraintValidatorContextImpl<A extends Annotation, T> implements - ConstraintValidatorContext { - - /** - * Builder for {@link ConstraintValidatorContextImpl}. - */ - public final class ConstraintViolationBuilderImpl implements - ConstraintViolationBuilder { - - private ConstraintValidatorContextImpl<A, T> context; - private String messageTemplate; - - /** - * @param constraintValidatorContextImpl - * @param messageTemplate - */ - public ConstraintViolationBuilderImpl( - ConstraintValidatorContextImpl<A, T> constraintValidatorContextImpl, - String messageTemplate) { - this.context = constraintValidatorContextImpl; - this.messageTemplate = messageTemplate; - } - - public ConstraintValidatorContext addConstraintViolation() { - return context; - } - - public NodeBuilderDefinedContext addNode(String name) { - return new NodeBuilderDefinedContextImpl(this, messageTemplate, - basePath.append(name)); - } - } - - /** - * Immutable GWT safe {@link NodeBuilderCustomizableContext}. - */ - public final class NodeBuilderCustomizableContextImpl implements - NodeBuilderCustomizableContext { - private final String messageTemplate; - private final ConstraintViolationBuilderImpl parent; - private final PathImpl path; - - /** - * @param parent - * @param messageTemplate - * @param append - */ - public NodeBuilderCustomizableContextImpl( - ConstraintViolationBuilderImpl parent, String messageTemplate, - PathImpl path) { - this.parent = parent; - this.messageTemplate = messageTemplate; - this.path = path; - } - - public ConstraintValidatorContext addConstraintViolation() { - return null; - } - - public NodeBuilderCustomizableContext addNode(String name) { - return this; - } - - public NodeContextBuilder inIterable() { - return new NodeContextBuilderImpl(path, messageTemplate, parent); - } - } - - /** - * Immutable GWT safe {@link NodeBuilderDefinedContext}. - */ - public final class NodeBuilderDefinedContextImpl implements - NodeBuilderDefinedContext { - - private final String messageTemplate; - private final ConstraintViolationBuilderImpl parent; - private final PathImpl path; - - /** - * @param constraintViolationBuilderImpl - * @param messageTemplate - * @param append - */ - public NodeBuilderDefinedContextImpl(ConstraintViolationBuilderImpl parent, - String messageTemplate, PathImpl path) { - this.parent = parent; - this.messageTemplate = messageTemplate; - this.path = path; - } - - public ConstraintValidatorContext addConstraintViolation() { - ConstraintViolation<T> violation = ConstraintViolationImpl.<T> builder().setPropertyPath( - path).setMessageTemplate(messageTemplate).build(); - - parent.context.violations.add(violation); - return parent.context; - } - - public NodeBuilderCustomizableContext addNode(String name) { - return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, - path.append(name)); - } - } - - /** - * Immutable GWT safe {@link NodeContextBuilder}. - */ - public final class NodeContextBuilderImpl implements NodeContextBuilder { - - private final String messageTemplate; - - private final ConstraintViolationBuilderImpl parent; - private final PathImpl path; - - public NodeContextBuilderImpl(PathImpl path, String messageTemplate, - ConstraintViolationBuilderImpl parent) { - super(); - this.path = path; - this.messageTemplate = messageTemplate; - this.parent = parent; - } - - public ConstraintValidatorContext addConstraintViolation() { - return null; - } - - public NodeBuilderCustomizableContext addNode(String name) { - return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, - path.append(name)); - } - - public NodeBuilderDefinedContext atIndex(Integer index) { - return new NodeBuilderDefinedContextImpl(parent, messageTemplate, - path.appendIndex(null, index.intValue())); - } - - public NodeBuilderDefinedContext atKey(Object key) { - return new NodeBuilderDefinedContextImpl(parent, messageTemplate, - path.appendKey(null, key)); - } - } - - private final PathImpl basePath; - private final ConstraintDescriptor<A> descriptor; - - private boolean disableDefault; - private Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>(); - - public ConstraintValidatorContextImpl(PathImpl path, - ConstraintDescriptor<A> descriptor) { - super(); - this.basePath = path; - this.descriptor = descriptor; - } - - public ConstraintViolationBuilder buildConstraintViolationWithTemplate( - String messageTemplate) { - ConstraintViolationBuilderImpl builder = new ConstraintViolationBuilderImpl( - this, messageTemplate); - return builder; - } - - public void disableDefaultConstraintViolation() { - disableDefault = true; - } - - public String getDefaultConstraintMessageTemplate() { - return (String) descriptor.getAttributes().get("message"); - } - - public Set<MessageAndPath> getMessageAndPaths() { - // TODO handle custom. - HashSet<MessageAndPath> messages = new HashSet<MessageAndPath>(); - messages.add(new MessageAndPath(this.basePath, - this.getDefaultConstraintMessageTemplate())); - return messages; - } - - public Set<ConstraintViolation<T>> getViolations() { - return violations; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java deleted file mode 100644 index 2c5ead9..0000000 --- a/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java +++ /dev/null
@@ -1,165 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.io.Serializable; - -import javax.validation.ConstraintViolation; -import javax.validation.Path; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * An implementation of {@link ConstraintViolation}. - * - * @param <T> the type of bean validated. - */ -public class ConstraintViolationImpl<T> implements ConstraintViolation<T>, - Serializable { - - /** - * Builder for ConstraintViolations. - * - * @param <T> the type of bean validated. - */ - public static class Builder<T> { - private String message; - private String messageTemplate; - private T rootBean; - private Class<T> rootBeanClass; - private Object leafBean; - private Path propertyPath; - private Object invalidValue; - private ConstraintDescriptor<?> constraintDescriptor; - - public ConstraintViolationImpl<T> build() { - return new ConstraintViolationImpl<T>(message, messageTemplate, rootBean, - rootBeanClass, leafBean, propertyPath, invalidValue, - constraintDescriptor); - } - - public Builder<T> setConstraintDescriptor( - ConstraintDescriptor<?> constraintDescriptor) { - this.constraintDescriptor = constraintDescriptor; - return this; - } - - public Builder<T> setInvalidValue(Object invalidValue) { - this.invalidValue = invalidValue; - return this; - } - - public Builder<T> setLeafBean(Object leafBean) { - this.leafBean = leafBean; - return this; - } - - public Builder<T> setMessage(String message) { - this.message = message; - return this; - } - - public Builder<T> setMessageTemplate(String messageTemplate) { - this.messageTemplate = messageTemplate; - return this; - } - - public Builder<T> setPropertyPath(Path propertyPath) { - this.propertyPath = propertyPath; - return this; - } - - public Builder<T> setRootBean(T rootBean) { - this.rootBean = rootBean; - return this; - } - - public Builder<T> setRootBeanClass(Class<T> rootBeanClass) { - this.rootBeanClass = rootBeanClass; - return this; - } - } - - private static final long serialVersionUID = 1L; - - public static <T> Builder<T> builder() { - return new Builder<T>(); - } - - private final String message; - private final String messageTemplate; - private final T rootBean; - private final Class<T> rootBeanClass; - private final Object leafBean; - private final Path propertyPath; - private final Object invalidValue; - private final ConstraintDescriptor<?> constraintDescriptor; - - /** - * @param message - * @param messageTemplate - * @param rootBean - * @param rootBeanClass - * @param leafBean - * @param propertyPath - * @param invalidValue - * @param constraintDescriptor - */ - private ConstraintViolationImpl(String message, String messageTemplate, - T rootBean, Class<T> rootBeanClass, Object leafBean, Path propertyPath, - Object invalidValue, ConstraintDescriptor<?> constraintDescriptor) { - super(); - this.message = message; - this.messageTemplate = messageTemplate; - this.rootBean = rootBean; - this.rootBeanClass = rootBeanClass; - this.leafBean = leafBean; - this.propertyPath = propertyPath; - this.invalidValue = invalidValue; - this.constraintDescriptor = constraintDescriptor; - } - - public ConstraintDescriptor<?> getConstraintDescriptor() { - return constraintDescriptor; - } - - public Object getInvalidValue() { - return invalidValue; - } - - public Object getLeafBean() { - return leafBean; - } - - public String getMessage() { - return message; - } - - public String getMessageTemplate() { - return messageTemplate; - } - - public Path getPropertyPath() { - return propertyPath; - } - - public T getRootBean() { - return rootBean; - } - - public Class<T> getRootBeanClass() { - return rootBeanClass; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptor.java b/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptor.java deleted file mode 100644 index 700cf7a..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtBeanDescriptor.java +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import javax.validation.metadata.BeanDescriptor; - -/** - * Marker interface used by GWT to generate a {@link BeanDescriptor} for a - * specific class T. - * - * @param <T> - */ -public interface GwtBeanDescriptor<T> extends BeanDescriptor { -}
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtSpecificValidator.java b/user/src/com/google/gwt/validation/client/impl/GwtSpecificValidator.java deleted file mode 100644 index 2391c8f..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtSpecificValidator.java +++ /dev/null
@@ -1,115 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.ValidationException; - -/** - * Defines GWT version of {@link javax.validation.Validator}. This used by - * generate a specific Validator for a given class G. - * - * @param <G> the type of bean for this validator - */ -public interface GwtSpecificValidator<G> { - - /** - * Return the descriptor object describing bean constraints. The returned - * object (and associated objects including - * <code>ConstraintDescriptor<code>s) are immutable. - * - * - * @return the bean descriptor for the class associated with this validator. - * - * @throws IllegalArgumentException if clazz is null - * @throws ValidationException if a non recoverable error happens during the - * metadata discovery or if some constraints are invalid. - */ - GwtBeanDescriptor<G> getConstraints() throws ValidationException; - - /** - * Validates all constraints on <code>object</code>. - * - * @param<T> the type of the RootBean for this validation context - * @param context The gwt validation context - * @param object object to validate - * @param groups group or list of groups targeted for validation (default to - * {@link javax.validation.groups.Default}) - * - * @return constraint violations or an empty Set if none - * - * @throws IllegalArgumentException if object is null or if null is passed to - * the varargs groups - * @throws ValidationException if a non recoverable error happens during the - * validation process - */ - <T> Set<ConstraintViolation<T>> validate(GwtValidationContext<T> context, - G object, Class<?>... groups) throws ValidationException; - - /** - * Validates all constraints placed on the property of <code>object</code> - * named <code>propertyName</code>. - * - * @param<T> the type of the RootBean for this validation context - * @param context The gwt validation context - * @param object object to validate - * @param propertyName property to validate (ie field and getter constraints) - * @param groups group or list of groups targeted for validation (default to - * {@link javax.validation.groups.Default}) - * - * @return constraint violations or an empty Set if none - * - * @throws IllegalArgumentException if <code>object</code> is null, if - * <code>propertyName</code> null, empty or not a valid object - * property or if null is passed to the varargs groups - * @throws ValidationException if a non recoverable error happens during the - * validation process - */ - <T> Set<ConstraintViolation<T>> validateProperty( - GwtValidationContext<T> context, G object, String propertyName, - Class<?>... groups) throws ValidationException; - - /** - * Validates all constraints placed on the property named - * <code>propertyName</code> of the class <code>beanType</code> where the - * property value is <code>value</code>. - * <p/> - * <code>ConstraintViolation</code> objects return null for - * {@link ConstraintViolation#getRootBean()} and - * {@link ConstraintViolation#getLeafBean()} - * - * @param<T> the type of the RootBean for this validation context - * @param context The gwt validation context - * @param beanType the bean type - * @param propertyName property to validate - * @param value property value to validate - * @param groups group or list of groups targeted for validation (default to - * {@link javax.validation.groups.Default}) - * - * @return constraint violations or an empty Set if none - * - * @throws IllegalArgumentException if <code>beanType</code> is null, if - * <code>propertyName</code> null, empty or not a valid object - * property or if null is passed to the varargs groups - * @throws ValidationException if a non recoverable error happens during the - * validation process - */ - <T> Set<ConstraintViolation<T>> validateValue( - GwtValidationContext<T> context, Class<G> beanType, String propertyName, - Object value, Class<?>... groups) throws ValidationException; -}
diff --git a/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java b/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java deleted file mode 100644 index c78140e..0000000 --- a/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.lang.annotation.Annotation; - -import javax.validation.metadata.BeanDescriptor; -import javax.validation.metadata.ConstraintDescriptor; - -/** - * Context for a {@link com.google.gwt.validation.client.GwtValidation}. - * - * @param <T> the type of the root bean. - */ -public class GwtValidationContext<T> { - - private final BeanDescriptor beanDescriptor; - private PathImpl path = new PathImpl(); - private final T rootBean; - - /** - * - */ - public GwtValidationContext(T rootBean, BeanDescriptor beanDescriptor) { - this.rootBean = rootBean; - this.beanDescriptor = beanDescriptor; - } - - /** - * Append a node named name to the path.. - * - * @param name - * @return the new GwtValidationContext. - */ - public GwtValidationContext<T> append(String name) { - GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean, - beanDescriptor); - temp.path = temp.path.append(name); - return temp; - } - - public <A extends Annotation, V> ConstraintValidatorContextImpl<A, V> createConstraintValidatorContext( - ConstraintDescriptor<A> descriptor) { - return new ConstraintValidatorContextImpl<A, V>(path, descriptor); - } - - public T getRootBean() { - return rootBean; - } - - @SuppressWarnings("unchecked") - public Class<T> getRootBeanClass() { - return (Class<T>) rootBean.getClass(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/MessageAndPath.java b/user/src/com/google/gwt/validation/client/impl/MessageAndPath.java deleted file mode 100644 index f40cc15..0000000 --- a/user/src/com/google/gwt/validation/client/impl/MessageAndPath.java +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import javax.validation.Path; - -/** - * Holds as Message and a Path. - * <p> - * Used to build a {@link javax.validation.ConstraintViolation} - */ -public class MessageAndPath { - - private final String message; - private final Path path; - - public MessageAndPath(Path path, String message) { - super(); - this.path = path; - this.message = message; - } - - public String getMessage() { - return message; - } - - public Path getPath() { - return path; - } - - /** - * For debugging use only. - */ - @Override - public String toString() { - return path + "=" + message; - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/NodeImpl.java b/user/src/com/google/gwt/validation/client/impl/NodeImpl.java deleted file mode 100644 index 0482ee0..0000000 --- a/user/src/com/google/gwt/validation/client/impl/NodeImpl.java +++ /dev/null
@@ -1,132 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.io.Serializable; - -import javax.validation.Path.Node; - -/** - * An immutable GWT safe implementation of {@link Node}. - */ -class NodeImpl implements Node, Serializable { - - private static final long serialVersionUID = 1L; - public static final Node ROOT_NODE = new NodeImpl(null); - - private final String name; - private final Integer index; - private final Object key; - - /** - * Create a non iterable node. - * - * @param name the possibly <code>null</code> name. - */ - public NodeImpl(String name) { - this.name = name; - this.index = null; - this.key = null; - } - - /** - * Create an iterable node with an index. - * - * @param name the possibly <code>null</code> name. - * @param index the zero based index. - */ - public NodeImpl(String name, int index) { - if (index < 0) { - throw new IllegalArgumentException("Index can not be negative."); - } - this.name = name; - this.index = Integer.valueOf(index); - this.key = null; - } - - /** - * Create an iterable node with a key. - * - * @param name the possibly <code>null</code> name. - * @param key the lookup key for this node. - */ - public NodeImpl(String name, Object key) { - if (key == null) { - throw new NullPointerException(); - } - this.name = name; - this.index = null; - this.key = key; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof NodeImpl)) { - return false; - } - NodeImpl that = (NodeImpl) obj; - return (this.name == null ? that.name == null : this.name == that.name) - && (this.index == null ? that.index == null : this.index == that.index) - && (this.key == null ? that.key == null : this.key == that.key); - } - - public Integer getIndex() { - return index; - } - - public Object getKey() { - return key; - } - - public String getName() { - return name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((index == null) ? 0 : index.hashCode()); - result = prime * result + ((key == null) ? 0 : key.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - public boolean isInIterable() { - return index != null || key != null; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - if (name != null) { - sb.append(name); - } - if (isInIterable()) { - sb.append('['); - if (key != null) { - sb.append(key); - } else { - sb.append(index); - } - sb.append(']'); - } - return sb.toString(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/PathImpl.java b/user/src/com/google/gwt/validation/client/impl/PathImpl.java deleted file mode 100644 index 8591073..0000000 --- a/user/src/com/google/gwt/validation/client/impl/PathImpl.java +++ /dev/null
@@ -1,114 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.validation.Path; - -/** - * An immutable GWT safe implementation of {@link Path}. - */ -public class PathImpl implements Path, Serializable { - - private static final long serialVersionUID = 1L; - - private final List<Node> nodes = new ArrayList<Node>(); - - /** - * Creates a new path containing only the root (<code>null</code>) - * {@link Node}. - */ - public PathImpl() { - nodes.add(NodeImpl.ROOT_NODE); - } - - private PathImpl(PathImpl originalPath, Node node) { - nodes.addAll(originalPath.nodes); - nodes.add(node); - } - - /** - * Create a new path with a node named <code>name</code> appended to the - * existing path. - * - * @param name - * @return The new path with appended node. - */ - public PathImpl append(String name) { - return new PathImpl(this, new NodeImpl(name)); - } - - /** - * Create a new path with a indexed node named <code>name</code> appended to - * the existing path. - * - * @param name - * @param key - * @return The new path with appended node. - */ - public PathImpl appendIndex(String name, int index) { - return new PathImpl(this, new NodeImpl(name, index)); - } - - /** - * Create a new path with a keyed node named <code>name</code> appended to the - * existing path. - * - * @param name - * @param key - * @return The new path with appended node. - */ - public PathImpl appendKey(String name, Object key) { - return new PathImpl(this, new NodeImpl(name, key)); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof PathImpl)) { - return false; - } - PathImpl that = (PathImpl) obj; - return this.nodes.equals(that.nodes); - } - - @Override - public int hashCode() { - return nodes.hashCode(); - } - - public Iterator<Node> iterator() { - return nodes.iterator(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (Node n : nodes) { - if (sb.length() > 0) { - sb.append('.'); - } - sb.append(n); - } - return sb.toString(); - } -}
diff --git a/user/src/com/google/gwt/validation/client/impl/PropertyDescriptorImpl.java b/user/src/com/google/gwt/validation/client/impl/PropertyDescriptorImpl.java deleted file mode 100644 index 67c95b4..0000000 --- a/user/src/com/google/gwt/validation/client/impl/PropertyDescriptorImpl.java +++ /dev/null
@@ -1,76 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.validation.metadata.ConstraintDescriptor; -import javax.validation.metadata.PropertyDescriptor; - -/** - * - */ -public class PropertyDescriptorImpl implements PropertyDescriptor { - - private boolean cascaded; - private Set<ConstraintDescriptor<?>> descriptors = new HashSet<ConstraintDescriptor<?>>(); - private Class<?> elementClass; - private String name; - - /** - * @param name - * @param elementClass - * @param cascaded - * @param descriptors - */ - public PropertyDescriptorImpl(String name, Class<?> elementClass, - boolean cascaded, ConstraintDescriptor<?>... descriptors) { - super(); - - this.elementClass = elementClass; - this.cascaded = cascaded; - this.name = name; - this.descriptors = new HashSet<ConstraintDescriptor<?>>( - Arrays.asList(descriptors)); - } - - public ConstraintFinder findConstraints() { - return null; - } - - public Set<ConstraintDescriptor<?>> getConstraintDescriptors() { - return Collections.unmodifiableSet(descriptors); - } - - public Class<?> getElementClass() { - return elementClass; - } - - public String getPropertyName() { - return name; - } - - public boolean hasConstraints() { - return !descriptors.isEmpty(); - } - - public boolean isCascaded() { - return cascaded; - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/AbstractCreator.java b/user/src/com/google/gwt/validation/rebind/AbstractCreator.java deleted file mode 100644 index 24c1111..0000000 --- a/user/src/com/google/gwt/validation/rebind/AbstractCreator.java +++ /dev/null
@@ -1,93 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JPackage; -import com.google.gwt.user.rebind.AbstractSourceCreator; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; - -import java.io.PrintWriter; - -/** - * Abstract Class for Creating source files. - * <p> - * This class is not thread safe. - */ -public abstract class AbstractCreator extends AbstractSourceCreator { - - protected final GeneratorContext context; - - protected final TreeLogger logger; - - protected final JClassType validatorType; - - public AbstractCreator(GeneratorContext context, TreeLogger logger, - JClassType validatorType) { - super(); - this.context = context; - this.logger = branch(logger, "Creating " + validatorType); - this.validatorType = validatorType; - } - - public final String create() { - SourceWriter sourceWriter = getSourceWriter(logger, context); - if (sourceWriter != null) { - writeClassBody(sourceWriter); - sourceWriter.commit(logger); - } - return getQualifiedName(); - } - - protected abstract void compose(ClassSourceFileComposerFactory composerFactory); - - protected final String getPackage() { - JPackage serviceIntfPkg = validatorType.getPackage(); - String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName(); - return packageName; - } - - protected abstract void writeClassBody(SourceWriter sourceWriter); - - private String getQualifiedName() { - String packageName = getPackage(); - return (packageName == "" ? "" : packageName + ".") + getSimpleName(); - } - - private String getSimpleName() { - return validatorType.getSimpleSourceName() + "Impl"; - } - - private SourceWriter getSourceWriter(TreeLogger logger, - GeneratorContext ctx) { - String packageName = getPackage(); - String simpleName = getSimpleName(); - PrintWriter printWriter = ctx.tryCreate(logger, packageName, simpleName); - if (printWriter == null) { - return null; - } - - ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory( - packageName, simpleName); - compose(composerFactory); - SourceWriter sourceWriter = composerFactory.createSourceWriter(ctx, - printWriter); - return sourceWriter; - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/rebind/BeanHelper.java b/user/src/com/google/gwt/validation/rebind/BeanHelper.java deleted file mode 100644 index 97e52ea..0000000 --- a/user/src/com/google/gwt/validation/rebind/BeanHelper.java +++ /dev/null
@@ -1,54 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.typeinfo.JClassType; - -/** - * A simple struct for the various values associated with a Bean that can be - * validated. - */ -final class BeanHelper { - - private final JClassType jClass; - - public BeanHelper(JClassType jClass) { - super(); - this.jClass = jClass; - } - - public String getDescriptorName() { - - return jClass.getName() + "Descriptor"; - } - - public String getTypeCanonicalName() { - return jClass.getQualifiedSourceName(); - } - - public String getValidatorInstanceName() { - return jClass.getName().toLowerCase() + "Validator"; - } - - public String getValidatorName() { - return jClass.getName() + "Validator"; - } - - @Override - public String toString() { - return getTypeCanonicalName(); - } -} \ No newline at end of file
diff --git a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java deleted file mode 100644 index be6098a..0000000 --- a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java +++ /dev/null
@@ -1,192 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.rebind; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.google.gwt.validation.client.impl.AbstractGwtSpecificValidator; -import com.google.gwt.validation.client.impl.GwtBeanDescriptor; -import com.google.gwt.validation.client.impl.GwtValidationContext; - -import java.util.HashSet; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.metadata.BeanDescriptor; - -/** - * Creates a {@link com.google.gwt.validation.client.GwtSpecificValidator}. - * <p> - * This class is not thread safe. - */ - -public class GwtSpecificValidatorCreator extends AbstractCreator { - - final JClassType beanType; - private BeanHelper beanHelper; - private final TypeOracle oracle; - - public GwtSpecificValidatorCreator(JClassType validatorType, - JClassType beanType, BeanHelper beanHelper, TreeLogger logger, - GeneratorContext context) { - super(context, logger, validatorType); - this.oracle = context.getTypeOracle(); - this.beanType = beanType; - this.beanHelper = beanHelper; - } - - @Override - protected void compose(ClassSourceFileComposerFactory composerFactory) { - Class<?>[] imports = new Class<?>[]{ - GWT.class, - GwtBeanDescriptor.class, - GwtValidationContext.class, - Set.class, - HashSet.class, - ConstraintViolation.class, - BeanDescriptor.class, - }; - for (Class<?> imp : imports) { - composerFactory.addImport(imp.getCanonicalName()); - } - - composerFactory.setSuperclass(AbstractGwtSpecificValidator.class.getCanonicalName() - + "<" + beanType.getQualifiedSourceName() + ">"); - - composerFactory.addImplementedInterface(validatorType.getName()); - } - - @Override - protected void writeClassBody(SourceWriter sw) { - writeFields(sw); - sw.println(); - writeValidate(sw); - sw.println(); - writeValidateProperty(sw); - sw.println(); - writeValidateValue(sw); - sw.println(); - writeGetDescriptor(sw); - } - - protected void writeNewViolations(SourceWriter sw) { - // Set<ConstraintViolation<T>> violations = new - // HashSet<ConstraintViolation<T>>(); - sw.println("Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();"); - } - - /** - * @param sourceWriter - */ - private void writeFields(SourceWriter sw) { - // MyBeanDescriptor beanDescriptor = GWT.create(MyBeanDescriptor); - sw.println(GwtBeanDescriptor.class.getCanonicalName()); - sw.println(" beanDescriptor = null; // GWT.create"); - } - - private void writeGetDescriptor(SourceWriter sw) { - // public GwtBeanDescriptor<beanType> getConstraints() { - sw.print("public "); - sw.print("GwtBeanDescriptor<" + beanHelper.getTypeCanonicalName() + "> "); - sw.println("getConstraints() {"); - sw.indent(); - - // return beanDescriptor; - sw.println("return beanDescriptor;"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidate(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate( - sw.println("public <T> Set<ConstraintViolation<T>> validate("); - - // GwtValidationContext<T> context, BeanType object, Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println(beanHelper.getTypeCanonicalName() + " object,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - writeNewViolations(sw); - - // TODO(nchalko) loop over all constraints - - // return violations; - sw.println("return violations;"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidateProperty(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate( - sw.println("public <T> Set<ConstraintViolation<T>> validateProperty("); - - // GwtValidationContext<T> context, BeanType object, String propertyName, - // Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println(beanHelper.getTypeCanonicalName() + " object,"); - sw.println("String propertyName,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - writeNewViolations(sw); - - // TODO(nchalko) case statement for propertyName - - // return violations; - sw.println("return violations;"); - - sw.outdent(); - sw.println("}"); - } - - private void writeValidateValue(SourceWriter sw) { - // public <T> Set<ConstraintViolation<T>> validate( - sw.println("public <T> Set<ConstraintViolation<T>> validateValue("); - - // GwtValidationContext<T> context, Class<Author> beanType, - // String propertyName, Object value, Class<?>... groups) { - sw.indent(); - sw.indent(); - sw.println("GwtValidationContext<T> context,"); - sw.println("Class<" + beanHelper.getTypeCanonicalName() + "> beanType,"); - sw.println("String propertyName,"); - sw.println("Object value,"); - sw.println("Class<?>... groups) {"); - sw.outdent(); - - writeNewViolations(sw); - - // TODO(nchalko) case statement for propertyName - - // return violations; - sw.println("return violations;"); - - sw.outdent(); - sw.println("}"); - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorGenerator.java b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorGenerator.java deleted file mode 100644 index 71cee0f..0000000 --- a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorGenerator.java +++ /dev/null
@@ -1,91 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JParameterizedType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.validation.client.impl.GwtSpecificValidator; - -/** - * Generates a {@link com.google.gwt.validation.client.GwtSpecificValidator}. - * <p> - * This class is thread safe. - */ -public class GwtSpecificValidatorGenerator extends Generator { - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - JClassType validatorType = context.getTypeOracle().findType(typeName); - TypeOracle typeOracle = context.getTypeOracle(); - assert (typeOracle != null); - - JClassType validator = typeOracle.findType(typeName); - if (validator == null) { - logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" - + typeName + "'", null); - throw new UnableToCompleteException(); - } - - JClassType gwtSpecificInterface = getGwtSpecificValidator(logger, validator); - JClassType beanType = getBeanType(logger, validator, gwtSpecificInterface); - - BeanHelper beanHelper = ValidatorCreator.getBeanHelper(beanType); - - if (beanHelper == null) { - logger.log(TreeLogger.ERROR, "Unable to find BeanHelper for " + beanType - + " " + GwtSpecificValidator.class.getSimpleName() - + " should only be referenced from a class created by " - + ValidatorGenerator.class.getCanonicalName(), null); - throw new UnableToCompleteException(); - } - - AbstractCreator creator = new GwtSpecificValidatorCreator(validatorType, - beanType, beanHelper, logger, context); - return creator.create(); - } - - private JClassType getBeanType(TreeLogger logger, JClassType validator, - JClassType gwtSpecificInterface) throws UnableToCompleteException { - if (gwtSpecificInterface instanceof JParameterizedType) { - JParameterizedType paramType = (JParameterizedType) gwtSpecificInterface; - return paramType.getTypeArgs()[0]; - } - logger.log(TreeLogger.ERROR, validator.getQualifiedSourceName() - + " must implement " + GwtSpecificValidator.class.getCanonicalName() - + " with a one generic parameter.", null); - throw new UnableToCompleteException(); - } - - private JClassType getGwtSpecificValidator(TreeLogger logger, - JClassType validator) throws UnableToCompleteException { - for (JClassType interfaceType : validator.getImplementedInterfaces()) { - if (interfaceType.getQualifiedSourceName().endsWith( - GwtSpecificValidator.class.getCanonicalName())) { - return interfaceType; - } - } - logger.log(TreeLogger.ERROR, validator.getQualifiedSourceName() - + " must implement " + GwtSpecificValidator.class.getCanonicalName(), - null); - throw new UnableToCompleteException(); - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java b/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java deleted file mode 100644 index e64949c..0000000 --- a/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java +++ /dev/null
@@ -1,259 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.rebind; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JPackage; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.google.gwt.validation.client.GwtValidation; -import com.google.gwt.validation.client.impl.AbstractGwtValidator; -import com.google.gwt.validation.client.impl.GwtBeanDescriptor; -import com.google.gwt.validation.client.impl.GwtSpecificValidator; -import com.google.gwt.validation.client.impl.GwtValidationContext; - -import java.io.PrintWriter; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.metadata.BeanDescriptor; - -/** - * Class that creates the validator for the given input class. - */ -public class ValidatorCreator { - - // stash the map in a ThreadLocal, since each GWT module lives in its own - // thread in DevMode - private static final ThreadLocal<Map<JClassType, BeanHelper>> threadLocalHelperMap = new ThreadLocal<Map<JClassType, BeanHelper>>() { - @Override - protected synchronized Map<JClassType, BeanHelper> initialValue() { - return new HashMap<JClassType, BeanHelper>(); - } - }; - - public static BeanHelper getBeanHelper(JClassType beanType) { - return getBeanHelpers().get(beanType); - } - - public static Map<JClassType, BeanHelper> getBeanHelpers() { - return Collections.unmodifiableMap(threadLocalHelperMap.get()); - } - - private final Map<JClassType, BeanHelper> beansToValidate = new HashMap<JClassType, BeanHelper>(); - private final GeneratorContext context; - private final TreeLogger logger; - private final JClassType validatorType; - - public ValidatorCreator(JClassType validatorType, - GwtValidation gwtValidation, TreeLogger logger, - GeneratorContext context) { - this.validatorType = validatorType; - this.logger = logger; - this.context = context; - TypeOracle oracle = context.getTypeOracle(); - - for (Class<?> clazz : gwtValidation.value()) { - JClassType jClass = oracle.findType(clazz.getCanonicalName()); - BeanHelper helper = new BeanHelper(jClass); - beansToValidate.put(jClass, helper); - } - threadLocalHelperMap.get().putAll(beansToValidate); - } - - public String create() { - SourceWriter sourceWriter = getSourceWriter(logger, context); - if (sourceWriter != null) { - writeTypeSupport(sourceWriter); - writeValidate(sourceWriter); - writeValidateProperty(sourceWriter); - writeValidateValue(sourceWriter); - writeGetConstraintsForClass(sourceWriter); - - sourceWriter.commit(logger); - } - return getQaulifiedName(); - } - - protected void writeContext(SourceWriter sourceWriter, BeanHelper bean, - String objectName) { - sourceWriter.print(GwtValidationContext.class.getCanonicalName() - + "<T> context = new " + GwtValidationContext.class.getCanonicalName() - + "<T>(" + objectName + ","); - sourceWriter.println(bean.getValidatorInstanceName() - + ".getConstraints());"); - } - - protected void writeGetConstraintsForClass(SourceWriter sourceWriter) { - sourceWriter.println("public BeanDescriptor getConstraintsForClass(Class<?> clazz) {"); - sourceWriter.indent(); - sourceWriter.println("return null;"); - sourceWriter.outdent(); - sourceWriter.println("}"); - sourceWriter.println(); - } - - protected void writeIfEqulsBeanType(SourceWriter sourceWriter, BeanHelper bean) { - sourceWriter.println("if (object.getClass().equals(" - + bean.getTypeCanonicalName() + ".class)) {"); - } - - protected void writeThrowIllegalArgumnet(SourceWriter sourceWriter) { - sourceWriter.print("throw new IllegalArgumentException(\"" - + this.validatorType.getName() + " can only validate "); - sourceWriter.print(beansToValidate.toString()); - sourceWriter.println("\");"); - } - - protected void writeTypeSupport(SourceWriter sw) { - // TODO (nchalko) write these as top level interfaces. - // As top level interfaces other generated Validators can use them. - // Without it a gwt application can only have ONE validator. - for (BeanHelper bean : beansToValidate.values()) { - sw.println("public interface " + bean.getValidatorName() - + " extends GwtSpecificValidator<" + bean.getTypeCanonicalName() - + "> {"); - sw.println("}"); - - sw.println("public interface " + bean.getDescriptorName() - + " extends GwtBeanDescriptor<" - + bean.getTypeCanonicalName() + "> {"); - sw.println("}"); - - sw.print("private final " + bean.getValidatorName() + " "); - sw.print(bean.getValidatorInstanceName()); - sw.print(" = GWT.create(" + bean.getValidatorName() + ".class);"); - sw.println(); - } - } - - protected void writeValidate(SourceWriter sw) { - sw.println("public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups) {"); - sw.indent(); - for (BeanHelper bean : beansToValidate.values()) { - writeValidate(sw, bean); - } - writeThrowIllegalArgumnet(sw); - sw.outdent(); // class - sw.println("}"); - sw.println(); - } - - protected void writeValidate(SourceWriter sw, BeanHelper bean) { - writeIfEqulsBeanType(sw, bean); - sw.indent(); - writeContext(sw, bean, "object"); - sw.print("return " + bean.getValidatorInstanceName() - + ".validate(context, (" + bean.getTypeCanonicalName() + ") object, "); - sw.println("groups);"); - sw.outdent(); // if - sw.println("}"); - } - - protected void writeValidateProperty(SourceWriter sw) { - sw.println("public <T> Set<ConstraintViolation<T>> validateProperty(T object,String propertyName, Class<?>... groups) {"); - sw.indent(); - for (BeanHelper bean : beansToValidate.values()) { - writeValidateProperty(sw, bean); - } - writeThrowIllegalArgumnet(sw); - sw.outdent(); - sw.println("}"); - sw.println(); - } - - protected void writeValidateProperty(SourceWriter sw, BeanHelper bean) { - writeIfEqulsBeanType(sw, bean); - sw.indent(); - writeContext(sw, bean, "object"); - sw.print("return " + bean.getValidatorInstanceName() - + ".validateProperty(context, (" + bean.getTypeCanonicalName() - + ") object, propertyName, "); - sw.println("groups);"); - sw.outdent(); // if - sw.println("}"); - } - - protected void writeValidateValue(SourceWriter sw) { - sw.println("public <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups) {"); - sw.indent(); - for (BeanHelper bean : beansToValidate.values()) { - writeValidateValue(sw, bean); - } - writeThrowIllegalArgumnet(sw); - sw.outdent(); - sw.println("}"); - sw.println(); - } - - protected void writeValidateValue(SourceWriter sw, BeanHelper bean) { - sw.println("if (beanType.getClass().equals(" + bean.getTypeCanonicalName() - + ".class)) {"); - sw.indent(); - writeContext(sw, bean, "null"); - sw.println("return " + bean.getValidatorInstanceName() - + ".validateValue(context, (Class<" + bean.getTypeCanonicalName() - + ">)beanType, propertyName, value, groups);"); - sw.outdent(); // if - sw.println("}"); - } - - private String getQaulifiedName() { - return validatorType.getQualifiedSourceName() + "Impl"; - } - - private String getSimpleName() { - return validatorType.getSimpleSourceName() + "Impl"; - } - - private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx) { - JPackage serviceIntfPkg = validatorType.getPackage(); - String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName(); - String simpleName = getSimpleName(); - PrintWriter printWriter = ctx.tryCreate(logger, packageName, simpleName); - if (printWriter == null) { - return null; - } - - ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory( - packageName, simpleName); - - String[] imports = new String[]{ - GWT.class.getCanonicalName(), - GwtBeanDescriptor.class.getCanonicalName(), - GwtSpecificValidator.class.getCanonicalName(), - GwtValidationContext.class.getCanonicalName(), - Set.class.getCanonicalName(), - ConstraintViolation.class.getCanonicalName(), - BeanDescriptor.class.getCanonicalName()}; - for (String imp : imports) { - composerFactory.addImport(imp); - } - - composerFactory.setSuperclass(AbstractGwtValidator.class.getCanonicalName()); - SourceWriter sourceWriter = composerFactory.createSourceWriter(ctx, - printWriter); - - return sourceWriter; - } -}
diff --git a/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java b/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java deleted file mode 100644 index d64290b..0000000 --- a/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java +++ /dev/null
@@ -1,72 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.rebind; - -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.validation.client.GwtValidation; - -/** - * Generates the generic {@link javax.validation.Validator}. The generic - * validator only handles the classes listed in the - * {@link com.google.gwt.validation.client.GwtValidation} annotaiton. See - * {@link com.google.gwt.validation.client.GwtValidation} for usage. - */ -public class ValidatorGenerator extends Generator { - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - JClassType validatorType = context.getTypeOracle().findType(typeName); - TypeOracle typeOracle = context.getTypeOracle(); - assert (typeOracle != null); - - JClassType validator = typeOracle.findType(typeName); - if (validator == null) { - logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" - + typeName + "'", null); - throw new UnableToCompleteException(); - } - - GwtValidation gwtValidation = validatorType.findAnnotationInTypeHierarchy(GwtValidation.class); - - if (gwtValidation == null) { - logger.log(TreeLogger.ERROR, typeName + "Must be anntotated with " - + GwtValidation.class.getCanonicalName(), null); - throw new UnableToCompleteException(); - } - - if (gwtValidation.value().length == 0) { - logger.log(TreeLogger.ERROR, - "The @" + GwtValidation.class.getSimpleName() + " of " + typeName - + "must specify at least one bean type to validate.", null); - throw new UnableToCompleteException(); - } - - TreeLogger validatorLogger = logger.branch(TreeLogger.DEBUG, - "Generating Validator for '" + validator.getQualifiedSourceName() - + "'", null); - ValidatorCreator creator = new ValidatorCreator(validatorType, - gwtValidation, - validatorLogger, - context); - return creator.create(); - } -}
diff --git a/user/src/javax/validation/Validation.gwt.xml b/user/src/javax/validation/Validation.gwt.xml deleted file mode 100644 index 9eec257..0000000 --- a/user/src/javax/validation/Validation.gwt.xml +++ /dev/null
@@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - 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. ---> -<!-- Includes the javax.validation classes from the source jar --> -<module> - <source path=""> - <exclude name="super/"/> - </source> - <super-source path="super"/> -</module> \ No newline at end of file
diff --git a/user/src/javax/validation/super/javax/validation/Configuration.java b/user/src/javax/validation/super/javax/validation/Configuration.java deleted file mode 100644 index 7a792a4..0000000 --- a/user/src/javax/validation/super/javax/validation/Configuration.java +++ /dev/null
@@ -1,203 +0,0 @@ -// $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 deleted file mode 100644 index 7507ad5..0000000 --- a/user/src/javax/validation/super/javax/validation/MessageInterpolator.java +++ /dev/null
@@ -1,73 +0,0 @@ -// $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 deleted file mode 100644 index 3c7e8bb..0000000 --- a/user/src/javax/validation/super/javax/validation/Validation.java +++ /dev/null
@@ -1,28 +0,0 @@ -// $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/constraints/Pattern.java b/user/src/javax/validation/super/javax/validation/constraints/Pattern.java deleted file mode 100644 index 017edfe..0000000 --- a/user/src/javax/validation/super/javax/validation/constraints/Pattern.java +++ /dev/null
@@ -1,159 +0,0 @@ -// $Id: Pattern.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. - */ -// Modified by Google. -package javax.validation.constraints; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.Payload; - -/** - * The annotated String must match the following regular expression. The regular - * expression follows the Java regular expression conventions see - * {@link java.util.regex.Pattern}. - * - * <p> - * Accepts String. <code>null</code> elements are considered valid. - * - * <p> - * GWT Modification: Reference to java.util.regex.Pattern are inlined - * - * @author Emmanuel Bernard - */ -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) -@Retention(RUNTIME) -@Documented -@Constraint(validatedBy = {}) -public @interface Pattern { - /** - * @return The regular expression to match. - */ - String regexp(); - - /** - * @return Array of <code>Flag</code>s considered when resolving the regular - * expression. - */ - Flag[] flags() default {}; - - /** - * @return The error message template. - */ - String message() default "{javax.validation.constraints.Pattern.message}"; - - /** - * @return The groups the constraint belongs to. - */ - Class<?>[] groups() default {}; - - /** - * @return The payload associated to the constraint - */ - Class<? extends Payload>[] payload() default {}; - - /** - * Possible Regexp flags - */ - public static enum Flag { - - /** - * Enables Unix lines mode - * - * @see java.util.regex.Pattern#UNIX_LINES - */ - UNIX_LINES(1), - - /** - * Enables case-insensitive matching - * - * @see java.util.regex.Pattern#CASE_INSENSITIVE - */ - CASE_INSENSITIVE(2), - - /** - * Permits whitespace and comments in pattern - * - * @see java.util.regex.Pattern#COMMENTS - */ - COMMENTS(4), - - /** - * Enables multiline mode - * - * @see java.util.regex.Pattern#MULTILINE - */ - MULTILINE(8), - - /** - * Enables dotall mode - * - * @see java.util.regex.Pattern#DOTALL - */ - DOTALL(32), - - /** - * Enables Unicode-aware case folding - * - * @see java.util.regex.Pattern#UNICODE_CASE - */ - UNICODE_CASE(64), - - /** - * Enables canonical equivalence - * - * @see java.util.regex.Pattern#CANON_EQ - */ - CANON_EQ(128); - - // JDK flag value - private final int value; - - private Flag(int value) { - this.value = value; - } - - /** - * @return flag value as defined in {@link java.util.regex.Pattern} - */ - public int getValue() { - return value; - } - } - - /** - * Defines several <code>@Pattern</code> annotations on the same element - * - * @see Pattern - * - * @author Emmanuel Bernard - */ - @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) - @Retention(RUNTIME) - @Documented - @interface List { - Pattern[] value(); - } -}
diff --git a/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java b/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java deleted file mode 100644 index 3037ddb..0000000 --- a/user/src/javax/validation/super/javax/validation/spi/ConfigurationState.java +++ /dev/null
@@ -1,123 +0,0 @@ -// $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(); -}
diff --git a/user/test/com/google/gwt/validation/client/SimpleSample.java b/user/test/com/google/gwt/validation/client/SimpleSample.java deleted file mode 100644 index 86083d8..0000000 --- a/user/test/com/google/gwt/validation/client/SimpleSample.java +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client; - -import javax.validation.constraints.NotNull; - -/** - * A simple sample class to test javax.validation. - */ -public class SimpleSample { - @NotNull - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -}
diff --git a/user/test/com/google/gwt/validation/client/SimpleSampleTest.java b/user/test/com/google/gwt/validation/client/SimpleSampleTest.java deleted file mode 100644 index 37d3661..0000000 --- a/user/test/com/google/gwt/validation/client/SimpleSampleTest.java +++ /dev/null
@@ -1,53 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client; - -import com.google.gwt.junit.client.GWTTestCase; -import com.google.gwt.validation.client.impl.ConstraintViolationImpl; - -import javax.validation.ConstraintViolation; -import javax.validation.constraints.NotNull; - -/** - * Tests for {@link SimpleSample}. - */ -public class SimpleSampleTest extends GWTTestCase { - SimpleSample sample; - - @Override - protected void gwtSetUp() { - sample = new SimpleSample(); - } - - public void testAnnotatedClassCompiles() throws Exception { - // Only tests that validation annotated class compile - assertEquals(null, sample.getName()); - } - - public void testConstraintViolation_compiles() throws Exception { - // Only tests that Violation Compiles which will also compile Path, Node - // and ConstraintDescriptor - ConstraintViolation<NotNull> violation = ConstraintViolationImpl.<NotNull> builder(). - setLeafBean(sample). - build(); - assertEquals(sample, violation.getLeafBean()); - } - - @Override - public String getModuleName() { - return "com.google.gwt.validation.Validation"; - } -}
diff --git a/user/test/com/google/gwt/validation/client/ValidationClientGwtSuite.java b/user/test/com/google/gwt/validation/client/ValidationClientGwtSuite.java deleted file mode 100644 index 03e87ad..0000000 --- a/user/test/com/google/gwt/validation/client/ValidationClientGwtSuite.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client; - -import com.google.gwt.junit.tools.GWTTestSuite; - -import junit.framework.Test; - -/** - * All validation client GWT tests. - */ -public class ValidationClientGwtSuite { - - public static Test suite() { - GWTTestSuite suite = new GWTTestSuite( - "Test suite for all validation code."); - suite.addTestSuite(SimpleSampleTest.class); - return suite; - } -}
diff --git a/user/test/com/google/gwt/validation/client/ValidationClientJreSuite.java b/user/test/com/google/gwt/validation/client/ValidationClientJreSuite.java deleted file mode 100644 index ec75ece..0000000 --- a/user/test/com/google/gwt/validation/client/ValidationClientJreSuite.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client; - -import com.google.gwt.validation.client.impl.NodeImplTest; -import com.google.gwt.validation.client.impl.PathImplTest; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * All validation client non GWT tests. - */ -public class ValidationClientJreSuite { - - public static Test suite() { - TestSuite suite = new TestSuite( - "Test suite for validation client code that does not require GWT."); - suite.addTestSuite(PathImplTest.class); - suite.addTestSuite(NodeImplTest.class); - return suite; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/AssertFalseValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/AssertFalseValidatorTest.java deleted file mode 100644 index 771247a..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/AssertFalseValidatorTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.AssertFalse; - -/** - * Tests for {@link AssertFalseValidator}. - */ -public class AssertFalseValidatorTest extends - ConstraintValidatorTestCase<AssertFalse, Boolean> { - - @SuppressWarnings("unused") - @AssertFalse - private Boolean defaultField; - - protected AssertFalseValidator createValidator() { - return new AssertFalseValidator(); - } - - public void testIsValid_false() { - Boolean value = Boolean.FALSE; - boolean expected = true; - assertConstraintValidator(value, expected); - } - - public void testIsValid_true() { - assertConstraintValidator(Boolean.TRUE, false); - } - - @Override - protected Class<AssertFalse> getAnnotationClass() { - return AssertFalse.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/AssertTrueValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/AssertTrueValidatorTest.java deleted file mode 100644 index 5ff0379..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/AssertTrueValidatorTest.java +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.AssertTrue; - -/** - * Tests for {@link AssertFalseValidator}. - */ -public class AssertTrueValidatorTest extends - ConstraintValidatorTestCase<AssertTrue, Boolean> { - - @SuppressWarnings("unused") - @AssertTrue - private Boolean defaultField; - - @Override - protected AssertTrueValidator createValidator() { - return new AssertTrueValidator(); - } - - public void testIsValid_false() { - assertConstraintValidator(Boolean.FALSE, false); - } - - public void testIsValid_true() { - assertConstraintValidator(Boolean.TRUE, true); - } - - @Override - protected Class<AssertTrue> getAnnotationClass() { - return AssertTrue.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/ConstraintValidatorTestCase.java b/user/test/com/google/gwt/validation/client/constraints/ConstraintValidatorTestCase.java deleted file mode 100644 index d267949..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/ConstraintValidatorTestCase.java +++ /dev/null
@@ -1,137 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import junit.framework.TestCase; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -/** - * TestCase for {@link javax.validation.ConstraintValidator}s. - * <p> - * Subclasses must : - * <ul> - * <li>implement {@link #getAnnotationClass()}</li> - * <li>implement {@link #createValidator()}.</li> - * <li>define a field called <code>defaultField</code> and annotate it with the - * constraint Annotation under test</li> - * </ul> - * - * <p> - * If additional instances of the annotation need to be tested you can get there - * value with {@link #getAnnotation(Class, Class, String)} - * - * @param <A> The constraint Annotation of the ConstraintValidator under test - * @param <T> The bean type of the ConstraintValidator under test - */ -public abstract class ConstraintValidatorTestCase<A extends Annotation, T> - extends TestCase { - - public final static String DEFAULT_ANNOTATED_FIELD_NAME = "defaultField"; - - // Validators are reusable but not thread safe - protected final ConstraintValidator<A, T> validator = createValidator(); - - // private ConstraintValidatorContext context; - - public ConstraintValidatorTestCase() { - super(); - } - - /** - * All constraints except {@link NotNull} should return true for a null value. - */ - public final void testIsValid_null() { - ConstraintValidatorTestCase.assertConstraintValidator(validator, - getDefaultAnnotation(), null, null, isNullValid()); - } - - /** - * Override this if a null value should not be valid. This is called by - * {@link #testIsValid_null()} - */ - protected boolean isNullValid() { - return true; - } - - /** - * Get the annotation of type {@link #getAnnotationClass()} on the field named - * <code>defaultField</code>. - */ - protected final A getDefaultAnnotation() { - return getAnnotation(getAnnotationClass(), this.getClass(), - DEFAULT_ANNOTATED_FIELD_NAME); - } - - protected abstract Class<A> getAnnotationClass(); - - protected A getAnnotation(Class<A> annotationClass, Class<?> objectClass, - String fieldName) { - - for (Field field : objectClass.getDeclaredFields()) { - if (field.getName().equals(fieldName)) { - A annotation = field.getAnnotation(annotationClass); - if (annotation == null) { - throw new IllegalArgumentException(objectClass + "." + fieldName - + " is not annotated with " + annotationClass); - } - return annotation; - } - } - throw new IllegalArgumentException(objectClass - + " does not have a field called " + fieldName); - } - - protected abstract ConstraintValidator<A, T> createValidator(); - - /** - * Assert result of validating <code>value</code> with <code>validator</code> - * initialized with the annotation of the <code>defaultField</code>. - * - * @param value the Value to validate - * @param expected the expected result of a calling <code>isValid</code> - */ - protected void assertConstraintValidator(T value, boolean expected) { - assertConstraintValidator(validator, getDefaultAnnotation(), null, value, - expected); - } - - /** - * Asserts the validity of a value using the given validator, annotation, and - * context. - * - * @param <T> object type - * @param <A> the constraint annotation type - * @param validator the {@link ConstraintValidator} to test - * @param annotation the constraint annotation to initialize the validator. - * @param context The context for the validator - * @param value the value to validate. - * @param expected the expected result - */ - public static <T, A extends Annotation> void assertConstraintValidator( - ConstraintValidator<A, T> validator, A annotation, - ConstraintValidatorContext context, T value, boolean expected) { - validator.initialize(annotation); - String message = validator.getClass().getName() + "(" + annotation - + ").isValid(" + value + ", " + context + ")"; - assertEquals(message, expected, validator.isValid(value, context)); - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/ConstraintsGwtSuite.java b/user/test/com/google/gwt/validation/client/constraints/ConstraintsGwtSuite.java deleted file mode 100644 index 45ca523..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/ConstraintsGwtSuite.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import com.google.gwt.junit.tools.GWTTestSuite; - -import junit.framework.Test; - -/** - * All Constraints tests that GWTTestCase. - */ -public class ConstraintsGwtSuite { - public static Test suite() { - GWTTestSuite suite = new GWTTestSuite( - "Validation Constraint tests that require GWT"); - suite.addTestSuite(GwtCompileTest.class); - return suite; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/ConstraintsJreSuite.java b/user/test/com/google/gwt/validation/client/constraints/ConstraintsJreSuite.java deleted file mode 100644 index 98f1a38..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/ConstraintsJreSuite.java +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * All Constraints tests that don't need GWTTestCase. - */ -public class ConstraintsJreSuite { - public static Test suite() { - TestSuite suite = new TestSuite( - "Validation Constraint tests that require the JRE"); - suite.addTestSuite(AssertFalseValidatorTest.class); - suite.addTestSuite(AssertTrueValidatorTest.class); - suite.addTestSuite(DecimalMaxValidatorForNumberTest.class); - suite.addTestSuite(DecimalMaxValidatorForStringTest.class); - suite.addTestSuite(DecimalMinValidatorForNumberTest.class); - suite.addTestSuite(DecimalMinValidatorForStringTest.class); - suite.addTestSuite(DigitsValidatorForNumberTest.class); - suite.addTestSuite(DigitsValidatorForStringTest.class); - suite.addTestSuite(FutureValidatorForDateTest.class); - suite.addTestSuite(MaxValidatorForNumberTest.class); - suite.addTestSuite(MaxValidatorForStringTest.class); - suite.addTestSuite(MinValidatorForNumberTest.class); - suite.addTestSuite(MinValidatorForStringTest.class); - suite.addTestSuite(NotNullValidatorTest.class); - suite.addTestSuite(NullValidatorTest.class); - suite.addTestSuite(PastValidatorForDateTest.class); - suite.addTestSuite(PatternValidatorTest.class); - suite.addTestSuite(SizeValidatorForArrayOfBooleanTest.class); - suite.addTestSuite(SizeValidatorForArrayOfByteTest.class); - suite.addTestSuite(SizeValidatorForArrayOfCharTest.class); - suite.addTestSuite(SizeValidatorForArrayOfDoubleTest.class); - suite.addTestSuite(SizeValidatorForArrayOfFloatTest.class); - suite.addTestSuite(SizeValidatorForArrayOfIntTest.class); - suite.addTestSuite(SizeValidatorForArrayOfLongTest.class); - suite.addTestSuite(SizeValidatorForArrayOfObjectTest.class); - suite.addTestSuite(SizeValidatorForArrayOfShortTest.class); - suite.addTestSuite(SizeValidatorForCollectionTest.class); - suite.addTestSuite(SizeValidatorForMapTest.class); - suite.addTestSuite(SizeValidatorForCollectionTest.class); - suite.addTestSuite(SizeValidatorForMapTest.class); - suite.addTestSuite(SizeValidatorForStringTest.class); - return suite; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumberTest.java deleted file mode 100644 index c91bb52..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForNumberTest.java +++ /dev/null
@@ -1,53 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMax; - -/** - * Tests for {@link DecimalMaxValidatorForNumber}. - */ -public class DecimalMaxValidatorForNumberTest extends - ConstraintValidatorTestCase<DecimalMax, Number> { - private static Double BELOW = Double.valueOf(922392239223.08); - private static Double SAME = Double.valueOf(922392239223.09); - private static Double ABOVE = Double.valueOf(922392239223.10); - - @SuppressWarnings("unused") - @DecimalMax("922392239223.09") - private double defaultField; - - protected DecimalMaxValidatorForNumber createValidator() { - return new DecimalMaxValidatorForNumber(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, true); - } - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, false); - } - - @Override - protected Class<DecimalMax> getAnnotationClass() { - return DecimalMax.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForStringTest.java deleted file mode 100644 index cc73112..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMaxValidatorForStringTest.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMax; - -/** - * Tests for {@link DecimalMaxValidatorForString}. - */ -public class DecimalMaxValidatorForStringTest extends - ConstraintValidatorTestCase<DecimalMax, String> { - private static String BELOW = "922392239223.08"; - private static String SAME = "922392239223.09"; - private static String ABOVE = "922392239223.10"; - - @SuppressWarnings("unused") - @DecimalMax("922392239223.09") - private String defaultField; - - protected DecimalMaxValidatorForString createValidator() { - return new DecimalMaxValidatorForString(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, true); - } - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, false); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected Class<DecimalMax> getAnnotationClass() { - return DecimalMax.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumberTest.java deleted file mode 100644 index 8b72c9f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForNumberTest.java +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMin; - -/** - * Tests for {@link DecimalMinValidatorForNumber}. - */ -public class DecimalMinValidatorForNumberTest extends - ConstraintValidatorTestCase<DecimalMin, Number> { - private static Double BELOW = Double.valueOf(922392239223.08); - private static Double ABOVE = Double.valueOf(922392239223.10); - - @SuppressWarnings("unused") - @DecimalMin("922392239223.09") - private double defaultField; - - protected DecimalMinValidatorForNumber createValidator() { - return new DecimalMinValidatorForNumber(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, false); - } - - // Because of rounding error we can't actually test for the exact vale - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, true); - } - - @Override - protected Class<DecimalMin> getAnnotationClass() { - return DecimalMin.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForStringTest.java deleted file mode 100644 index 1fa77bd..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DecimalMinValidatorForStringTest.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.DecimalMin; - -/** - * Tests for {@link DecimalMinValidatorForString}. - */ -public class DecimalMinValidatorForStringTest extends - ConstraintValidatorTestCase<DecimalMin, String> { - private static String BELOW = "922392239223.08"; - private static String SAME = "922392239223.09"; - private static String ABOVE = "922392239223.10"; - - @SuppressWarnings("unused") - @DecimalMin("922392239223.09") - private double defaultField; - - protected DecimalMinValidatorForString createValidator() { - return new DecimalMinValidatorForString(); - } - - public void testIsValid_below() { - assertConstraintValidator(BELOW, false); - } - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_above() { - assertConstraintValidator(ABOVE, true); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected Class<DecimalMin> getAnnotationClass() { - return DecimalMin.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForNumberTest.java deleted file mode 100644 index 8131a06..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForNumberTest.java +++ /dev/null
@@ -1,66 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.math.BigDecimal; - -import javax.validation.constraints.Digits; - -/** - * Tests for {@link DigitsValidatorForNumber}. - */ -public class DigitsValidatorForNumberTest extends - ConstraintValidatorTestCase<Digits, Number> { - - private static BigDecimal GOOD = new BigDecimal("1234.12"); - private static BigDecimal INT_TO_BIG = new BigDecimal("12345.12"); - private static BigDecimal INT_SMALL = new BigDecimal("123.12"); - private static BigDecimal DECIMAL_TO_BIG = new BigDecimal("1234.123"); - private static BigDecimal DECIMAL_SMALL = new BigDecimal("1234.1"); - - @SuppressWarnings("unused") - @Digits(integer = 4, fraction = 2) - private double defaultField; - - protected DigitsValidatorForNumber createValidator() { - return new DigitsValidatorForNumber(); - } - - public void testIsValid_decimalToBig() { - assertConstraintValidator(DECIMAL_SMALL, true); - } - - public void testIsValid_decimalToSmall() { - assertConstraintValidator(DECIMAL_TO_BIG, false); - } - - public void testIsValid_good() { - assertConstraintValidator(GOOD, true); - } - - public void testIsValid_intToBig() { - assertConstraintValidator(INT_TO_BIG, false); - } - - public void testIsValid_intToSmall() { - assertConstraintValidator(INT_SMALL, true); - } - - @Override - protected Class<Digits> getAnnotationClass() { - return Digits.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForStringTest.java deleted file mode 100644 index 9b60d6d..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/DigitsValidatorForStringTest.java +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Digits; - -/** - * Tests for {@link DigitsValidatorForString}. - */ -public class DigitsValidatorForStringTest extends - ConstraintValidatorTestCase<Digits, String> { - - private static String GOOD = "1234.12"; - private static String INT_TO_BIG = "12345.12"; - private static String INT_SMALL = "123.12"; - private static String DECIMAL_TO_BIG = "1234.123"; - private static String DECIMAL_SMALL = "1234.1"; - - @SuppressWarnings("unused") - @Digits(integer = 4, fraction = 2) - private double defaultField; - - protected DigitsValidatorForString createValidator() { - return new DigitsValidatorForString(); - } - - public void testIsValid_decimalToBig() { - assertConstraintValidator(DECIMAL_SMALL, true); - } - - public void testIsValid_decimalToSmall() { - assertConstraintValidator(DECIMAL_TO_BIG, false); - } - - public void testIsValid_good() { - assertConstraintValidator(GOOD, true); - } - - public void testIsValid_intToBig() { - assertConstraintValidator(INT_TO_BIG, false); - } - - public void testIsValid_intToSmall() { - assertConstraintValidator(INT_SMALL, true); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected Class<Digits> getAnnotationClass() { - return Digits.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/FutureValidatorForDateTest.java b/user/test/com/google/gwt/validation/client/constraints/FutureValidatorForDateTest.java deleted file mode 100644 index bc3a609..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/FutureValidatorForDateTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Future; - -/** - * Tests for {@link FutureValidatorForDate}. - */ -public class FutureValidatorForDateTest extends - ConstraintValidatorTestCase<Future, Date> { - - @SuppressWarnings("unused") - @Future - private Date defaultField; - - protected FutureValidatorForDate createValidator() { - return new FutureValidatorForDate(); - } - - public void testAssertIsValid_nowMinus1000() { - assertConstraintValidator(new Date(new Date().getTime() - 1000), false); - } - - public void testAssertIsValid_nowPlus1000() { - assertConstraintValidator(new Date(new Date().getTime() + 1000), true); - } - - @Override - protected Class<Future> getAnnotationClass() { - return Future.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/GwtCompileTest.java b/user/test/com/google/gwt/validation/client/constraints/GwtCompileTest.java deleted file mode 100644 index b031395..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/GwtCompileTest.java +++ /dev/null
@@ -1,70 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import com.google.gwt.junit.client.GWTTestCase; - -import java.util.ArrayList; -import java.util.List; - -/** - * A GWT test to force the compilation of all default standard - * {@link javax.validation.ConstraintValidator}s. - */ -public class GwtCompileTest extends GWTTestCase { - - @Override - public String getModuleName() { - return "com.google.gwt.validation.Validation"; - } - - public void testDefaultConstraints() { - List<Class<?>> temp = new ArrayList<Class<?>>(); - temp.add(AssertFalseValidator.class); - temp.add(AssertTrueValidator.class); - temp.add(DecimalMaxValidatorForNumber.class); - temp.add(DecimalMaxValidatorForString.class); - temp.add(DecimalMinValidatorForNumber.class); - temp.add(DecimalMinValidatorForString.class); - temp.add(DigitsValidatorForNumber.class); - temp.add(DigitsValidatorForString.class); - // FutureValidatorForCalendar GWT does not support java.util.Calendar - temp.add(FutureValidatorForDate.class); - temp.add(MaxValidatorForNumber.class); - temp.add(MaxValidatorForString.class); - temp.add(MinValidatorForNumber.class); - temp.add(MinValidatorForString.class); - temp.add(NotNullValidator.class); - temp.add(NullValidator.class); - // PastValidatorForCalendar GWT does not support java.util.Calendar - temp.add(PastValidatorForDate.class); - temp.add(PatternValidator.class); - temp.add(SizeValidatorForArrayOfBoolean.class); - temp.add(SizeValidatorForArrayOfByte.class); - temp.add(SizeValidatorForArrayOfChar.class); - temp.add(SizeValidatorForArrayOfDouble.class); - temp.add(SizeValidatorForArrayOfFloat.class); - temp.add(SizeValidatorForArrayOfInt.class); - temp.add(SizeValidatorForArrayOfLong.class); - temp.add(SizeValidatorForArrayOfObject.class); - temp.add(SizeValidatorForArrayOfShort.class); - temp.add(SizeValidatorForCollection.class); - temp.add(SizeValidatorForMap.class); - temp.add(SizeValidatorForString.class); - - assertEquals(29, temp.size()); - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForNumberTest.java deleted file mode 100644 index f18b5df..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForNumberTest.java +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Max; - -/** - * Tests for {@link MaxValidatorForNumber}. - */ -public class MaxValidatorForNumberTest extends - ConstraintValidatorTestCase<Max, Number> { - private static long SAME = 123456789L; - private static long SMALLER = SAME - 1L; - private static long BIGGER = SAME + 1L; - - @Max(123456789L) - public long defaultField; - - public void testIsValid_same() { - assertConstraintValidator(Long.valueOf(SAME), true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(Long.valueOf(SMALLER), true); - } - - public void testIsValid_bigger() { - assertConstraintValidator(Long.valueOf(BIGGER), false); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE), true); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE), false); - } - - @Override - protected MaxValidatorForNumber createValidator() { - return new MaxValidatorForNumber(); - } - - @Override - protected Class<Max> getAnnotationClass() { - return Max.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForStringTest.java deleted file mode 100644 index b5cb1b7..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MaxValidatorForStringTest.java +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Max; - -/** - * Tests for {@link MinValidatorForString}. - */ -public class MaxValidatorForStringTest extends - ConstraintValidatorTestCase<Max, String> { - private static String SAME = "123456789"; - private static String SMALLER = "123456788"; - private static String BIGGER = "123456790"; - - @Max(123456789) - public String defaultField; - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(SMALLER, true); - } - - public void testIsValid_bigger() { - assertConstraintValidator(BIGGER, false); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE).toString(), true); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE).toString(), false); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected MaxValidatorForString createValidator() { - return new MaxValidatorForString(); - } - - @Override - protected Class<Max> getAnnotationClass() { - return Max.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForNumberTest.java b/user/test/com/google/gwt/validation/client/constraints/MinValidatorForNumberTest.java deleted file mode 100644 index bbb8a44..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForNumberTest.java +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Min; - -/** - * Tests for {@link MinValidatorForNumber}. - */ -public class MinValidatorForNumberTest extends - ConstraintValidatorTestCase<Min, Number> { - private static long SAME = 123456789L; - private static long SMALLER = SAME - 1L; - private static long BIGGER = SAME + 1L; - - @Min(123456789L) - public long defaultField; - - public void testIsValid_same() { - assertConstraintValidator(Long.valueOf(SAME), true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(Long.valueOf(SMALLER), false); - } - - public void testIsValid_bigger() { - assertConstraintValidator(Long.valueOf(BIGGER), true); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE), false); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE), true); - } - - @Override - protected MinValidatorForNumber createValidator() { - return new MinValidatorForNumber(); - } - - @Override - protected Class<Min> getAnnotationClass() { - return Min.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/MinValidatorForStringTest.java deleted file mode 100644 index 5c1d526..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/MinValidatorForStringTest.java +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Max; - -/** - * Tests for {@link MinValidatorForString}. - */ -public class MinValidatorForStringTest extends - ConstraintValidatorTestCase<Max, String> { - private static String SAME = "123456789"; - private static String SMALLER = "123456788"; - private static String BIGGER = "123456790"; - - @Max(123456789) - public String defaultField; - - public void testIsValid_same() { - assertConstraintValidator(SAME, true); - } - - public void testIsValid_smaller() { - assertConstraintValidator(SMALLER, true); - } - - public void testIsValid_bigger() { - assertConstraintValidator(BIGGER, false); - } - - public void testIsValid_minValue() { - assertConstraintValidator(Long.valueOf(Long.MIN_VALUE).toString(), true); - } - - public void testIsValid_maxValue() { - assertConstraintValidator(Long.valueOf(Long.MAX_VALUE).toString(), false); - } - - public void testIsValid_invalid() { - assertConstraintValidator("invalid", false); - } - - @Override - protected MaxValidatorForString createValidator() { - return new MaxValidatorForString(); - } - - @Override - protected Class<Max> getAnnotationClass() { - return Max.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/NotNullValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/NotNullValidatorTest.java deleted file mode 100644 index bf4dc31..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/NotNullValidatorTest.java +++ /dev/null
@@ -1,50 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.ConstraintValidator; -import javax.validation.constraints.NotNull; - -/** - * Tests for {@link NotNullValidator}. - */ -public class NotNullValidatorTest extends - ConstraintValidatorTestCase<NotNull, Object> { - - @SuppressWarnings("unused") - @NotNull - private String defaultField; - - public void testIsValid_notNull() { - ConstraintValidatorTestCase.assertConstraintValidator(validator, - getDefaultAnnotation(), null, new Object(), true); - } - - @Override - protected boolean isNullValid() { - return false; - } - - @Override - protected Class<NotNull> getAnnotationClass() { - return NotNull.class; - } - - @Override - protected ConstraintValidator<NotNull, Object> createValidator() { - return new NotNullValidator(); - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/NullValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/NullValidatorTest.java deleted file mode 100644 index 7197064..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/NullValidatorTest.java +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import javax.validation.constraints.Null; - -/** - * Tests for {@link NullValidator}. - */ -public class NullValidatorTest extends - ConstraintValidatorTestCase<Null, Object> { - - @SuppressWarnings("unused") - @Null - private Object defaultField; - - protected NullValidator createValidator() { - return new NullValidator(); - } - - public void testIsValid_notNull() { - assertConstraintValidator("this is not null", false); - } - - @Override - protected Class<Null> getAnnotationClass() { - return Null.class; - } - -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/PastValidatorForDateTest.java b/user/test/com/google/gwt/validation/client/constraints/PastValidatorForDateTest.java deleted file mode 100644 index 7c3d37a..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/PastValidatorForDateTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Past; - -/** - * Tests for {@link PastValidatorForDate}. - */ -public class PastValidatorForDateTest extends - ConstraintValidatorTestCase<Past, Date> { - - @SuppressWarnings("unused") - @Past - private Date defaultField; - - protected PastValidatorForDate createValidator() { - return new PastValidatorForDate(); - } - - public void testAssertIsValid_nowMinus1000() { - assertConstraintValidator(new Date(new Date().getTime() - 1000), true); - } - - public void testAssertIsValid_nowPlus1000() { - assertConstraintValidator(new Date(new Date().getTime() + 1000), false); - } - - @Override - protected Class<Past> getAnnotationClass() { - return Past.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/PatternValidatorTest.java b/user/test/com/google/gwt/validation/client/constraints/PatternValidatorTest.java deleted file mode 100644 index 60f3fea..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/PatternValidatorTest.java +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Pattern; - -/** - * Tests for {@link PastValidatorForDate}. - */ -public class PatternValidatorTest extends - ConstraintValidatorTestCase<Pattern, String> { - - @SuppressWarnings("unused") - @Pattern(regexp = "good") - private Date defaultField; - - protected PatternValidator createValidator() { - return new PatternValidator(); - } - - public void testAssertIsValid_good() { - assertConstraintValidator("this is good", true); - } - - public void testAssertIsValid_bad() { - assertConstraintValidator("this is bad", false); - } - - @Override - protected Class<Pattern> getAnnotationClass() { - return Pattern.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBooleanTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBooleanTest.java deleted file mode 100644 index 3c70fbd..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfBooleanTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfBoolean}. - */ -public class SizeValidatorForArrayOfBooleanTest extends - ConstraintValidatorTestCase<Size, boolean[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfBoolean createValidator() { - return new SizeValidatorForArrayOfBoolean(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private boolean[] createArray(int size) { - boolean[] array = new boolean[size]; - for (int i = 0; i < size; i++) { - array[i] = (i % 2 == 0); - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByteTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByteTest.java deleted file mode 100644 index 4efd56f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfByteTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfByte}. - */ -public class SizeValidatorForArrayOfByteTest extends - ConstraintValidatorTestCase<Size, byte[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfByte createValidator() { - return new SizeValidatorForArrayOfByte(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private byte[] createArray(int size) { - byte[] array = new byte[size]; - for (int i = 0; i < size; i++) { - array[i] = (byte) i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfCharTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfCharTest.java deleted file mode 100644 index c831e8f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfCharTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfChar}. - */ -public class SizeValidatorForArrayOfCharTest extends - ConstraintValidatorTestCase<Size, char[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfChar createValidator() { - return new SizeValidatorForArrayOfChar(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private char[] createArray(int size) { - char[] array = new char[size]; - for (int i = 0; i < size; i++) { - array[i] = (char) i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDoubleTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDoubleTest.java deleted file mode 100644 index 7be25ae..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfDoubleTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfDouble}. - */ -public class SizeValidatorForArrayOfDoubleTest extends - ConstraintValidatorTestCase<Size, double[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfDouble createValidator() { - return new SizeValidatorForArrayOfDouble(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private double[] createArray(int size) { - double[] array = new double[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloatTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloatTest.java deleted file mode 100644 index f265b45..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfFloatTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfFloat}. - */ -public class SizeValidatorForArrayOfFloatTest extends - ConstraintValidatorTestCase<Size, float[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfFloat createValidator() { - return new SizeValidatorForArrayOfFloat(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private float[] createArray(int size) { - float[] array = new float[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfIntTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfIntTest.java deleted file mode 100644 index 0e37693..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfIntTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfInt}. - */ -public class SizeValidatorForArrayOfIntTest extends - ConstraintValidatorTestCase<Size, int[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfInt createValidator() { - return new SizeValidatorForArrayOfInt(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private int[] createArray(int size) { - int[] array = new int[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLongTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLongTest.java deleted file mode 100644 index c8b3b41..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfLongTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfLong}. - */ -public class SizeValidatorForArrayOfLongTest extends - ConstraintValidatorTestCase<Size, long[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfLong createValidator() { - return new SizeValidatorForArrayOfLong(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private long[] createArray(int size) { - long[] array = new long[size]; - for (int i = 0; i < size; i++) { - array[i] = i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObjectTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObjectTest.java deleted file mode 100644 index 34da630..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfObjectTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfObject}. - */ -public class SizeValidatorForArrayOfObjectTest extends - ConstraintValidatorTestCase<Size, Object[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfObject createValidator() { - return new SizeValidatorForArrayOfObject(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private Object[] createArray(int size) { - Object[] array = new Object[size]; - for (int i = 0; i < size; i++) { - array[i] = Integer.valueOf(i); - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShortTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShortTest.java deleted file mode 100644 index bfab23f..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForArrayOfShortTest.java +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForArrayOfShort}. - */ -public class SizeValidatorForArrayOfShortTest extends - ConstraintValidatorTestCase<Size, short[]> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForArrayOfShort createValidator() { - return new SizeValidatorForArrayOfShort(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createArray(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createArray(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createArray(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createArray(6), false); - } - - private short[] createArray(int size) { - short[] array = new short[size]; - for (int i = 0; i < size; i++) { - array[i] = (short) i; - } - return array; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForCollectionTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForCollectionTest.java deleted file mode 100644 index 6a44d53..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForCollectionTest.java +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForCollection}. - */ -public class SizeValidatorForCollectionTest extends - ConstraintValidatorTestCase<Size, Collection<?>> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForCollection createValidator() { - return new SizeValidatorForCollection(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createList(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createList(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createList(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createList(6), false); - } - - private Collection<Integer> createList(int size) { - List<Integer> list = new ArrayList<Integer>(size); - for (int i = 1; i <= size; i++) { - Integer key = Integer.valueOf(i); - list.add(key); - } - return list; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForMapTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForMapTest.java deleted file mode 100644 index 67eb163..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForMapTest.java +++ /dev/null
@@ -1,67 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForMap}. - */ -public class SizeValidatorForMapTest extends - ConstraintValidatorTestCase<Size, Map<?, ?>> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForMap createValidator() { - return new SizeValidatorForMap(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator(createMap(1), false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator(createMap(2), true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator(createMap(5), true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator(createMap(6), false); - } - - private Map<Integer, String> createMap(int size) { - Map<Integer, String> map = new HashMap<Integer, String>(size); - for (int i = 1; i <= size; i++) { - Integer key = Integer.valueOf(i); - map.put(key, key.toString()); - } - return map; - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForStringTest.java b/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForStringTest.java deleted file mode 100644 index 26c0198..0000000 --- a/user/test/com/google/gwt/validation/client/constraints/SizeValidatorForStringTest.java +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.constraints; - -import java.util.Date; - -import javax.validation.constraints.Size; - -/** - * Tests for {@link SizeValidatorForString}. - */ -public class SizeValidatorForStringTest extends - ConstraintValidatorTestCase<Size, String> { - - @SuppressWarnings("unused") - @Size(min = 2, max = 5) - private Date defaultField; - - protected SizeValidatorForString createValidator() { - return new SizeValidatorForString(); - } - - public void testAssertIsValid_short() { - assertConstraintValidator("1", false); - } - - public void testAssertIsValid_min() { - assertConstraintValidator("12", true); - } - - public void testAssertIsValid_max() { - assertConstraintValidator("12345", true); - } - - public void testAssertIsValid_long() { - assertConstraintValidator("123456", false); - } - - @Override - protected Class<Size> getAnnotationClass() { - return Size.class; - } -}
diff --git a/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java b/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java deleted file mode 100644 index ca9b74c..0000000 --- a/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import junit.framework.TestCase; - -import javax.validation.Path.Node; - -/** - * Tests for {@link NodeImpl}. - */ -public class NodeImplTest extends TestCase { - - public void testRoot() throws Exception { - assertNode(NodeImpl.ROOT_NODE, null, false, null, null); - } - - public void testFoo() throws Exception { - assertNode(new NodeImpl("foo"), "foo", false, null, null); - } - - public void testFoo1() throws Exception { - assertNode(new NodeImpl("foo", 1), "foo", true, null, - Integer.valueOf(1)); - } - - public void testFooBar() throws Exception { - assertNode(new NodeImpl("foo", "bar"), "foo", true, "bar", null); - } - - protected void assertNode(Node node, String expectedName, - boolean expectedInIterator, Object expectedKey, Integer expectedIndex) { - assertEquals(node + " name", expectedName, node.getName()); - assertEquals(node + " isInIterator", expectedInIterator, - node.isInIterable()); - assertEquals(node + " key", expectedKey, node.getKey()); - assertEquals(node + " index", expectedIndex, node.getIndex()); - } -}
diff --git a/user/test/com/google/gwt/validation/client/impl/PathImplTest.java b/user/test/com/google/gwt/validation/client/impl/PathImplTest.java deleted file mode 100644 index e8a1fd7..0000000 --- a/user/test/com/google/gwt/validation/client/impl/PathImplTest.java +++ /dev/null
@@ -1,77 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.client.impl; - -import junit.framework.TestCase; - -/** - * Tests for {@link PathImpl}. - */ -public class PathImplTest extends TestCase { - - public void testEquals_root() { - PathImpl root = new PathImpl(); - PathImpl rootCopy = new PathImpl(); - assertEqualsAndHash(root, rootCopy); - } - - public void testEquals_foo() { - PathImpl foo = new PathImpl().append("foo"); - PathImpl fooCopy = new PathImpl().append("foo"); - assertEqualsAndHash(foo, fooCopy); - } - - public void testEqual_fooBarKey() { - PathImpl fooBarKey = new PathImpl().append("foo").appendKey("bar", "key"); - PathImpl fooBarKeyCopy = new PathImpl().append("foo").appendKey("bar", - "key"); - assertEqualsAndHash(fooBarKey, fooBarKeyCopy); - } - - public void testEquals_fooBar1() { - PathImpl fooBar1 = new PathImpl().append("foo").appendIndex("bar", 1); - PathImpl fooBar1Copy = new PathImpl().append("foo").appendIndex("bar", 1); - assertEqualsAndHash(fooBar1, fooBar1Copy); - } - - public void testEquals_not() { - PathImpl root = new PathImpl(); - PathImpl foo = new PathImpl().append("foo"); - assertNotEqual(root, foo); - - PathImpl fooBarKey = new PathImpl().append("foo").appendKey("bar", "key"); - PathImpl fooBarNote = new PathImpl().append("foo").appendKey("bar", "note"); - assertNotEqual(root, fooBarKey); - assertNotEqual(foo, fooBarKey); - assertNotEqual(fooBarNote, fooBarKey); - - PathImpl fooBar1 = new PathImpl().append("foo").appendIndex("bar", 1); - PathImpl fooBar2 = new PathImpl().append("foo").appendIndex("bar", 2); - assertNotEqual(root, fooBar1); - assertNotEqual(foo, fooBar1); - assertNotEqual(fooBarKey, fooBar1); - assertNotEqual(fooBar2, fooBar1); - } - - protected void assertNotEqual(Object lhs, Object rhs) { - assertFalse(lhs + "should not equal " + rhs, lhs.equals(rhs)); - } - - protected void assertEqualsAndHash(Object lhs, Object rhs) { - assertEquals(lhs, rhs); - assertEquals("hashCode", lhs.hashCode(), rhs.hashCode()); - } -}
diff --git a/user/test/com/google/gwt/validation/example/ValidationExample.gwt.xml b/user/test/com/google/gwt/validation/example/ValidationExample.gwt.xml deleted file mode 100644 index 0dddb0f..0000000 --- a/user/test/com/google/gwt/validation/example/ValidationExample.gwt.xml +++ /dev/null
@@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd"> -<!-- - Copyright 2010 Google Inc. - - 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. ---> -<module> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.validation.Validation" /> - <source path="client" /> -</module> \ No newline at end of file
diff --git a/user/test/com/google/gwt/validation/example/client/Author.java b/user/test/com/google/gwt/validation/example/client/Author.java deleted file mode 100644 index eadf824..0000000 --- a/user/test/com/google/gwt/validation/example/client/Author.java +++ /dev/null
@@ -1,54 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -import javax.validation.constraints.Size; - -/** - * From the jsr spec. - */ -public class Author { - - private String firstName; - @NotEmpty(message = "lastname must not be null") - private String lastName; - @Size(max = 30) - private String company; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public String getCompany() { - return company; - } - - public void setCompany(String company) { - this.company = company; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/AuthorTest.java b/user/test/com/google/gwt/validation/example/client/AuthorTest.java deleted file mode 100644 index 2be400a..0000000 --- a/user/test/com/google/gwt/validation/example/client/AuthorTest.java +++ /dev/null
@@ -1,102 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.junit.client.GWTTestCase; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validator; - -/** - * Tests for {@link Author}. - */ -public class AuthorTest extends GWTTestCase { - - private Author author; - - private Validator validator; - - @Override - public String getModuleName() { - return "com.google.gwt.validation.example.ValidationExample"; - } - - public void testValidate_string() { - try { - validator.validate("some string"); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException expected) { - } - } - - public void testValidate_valid() { - author.setFirstName("John"); - author.setLastName("Smith"); - author.setCompany("Google"); - Set<ConstraintViolation<Author>> violations = validator.validate(author); - assertContentsAnyOrder("valid author", violations); - } - - public void testValidateProperty_object() { - try { - validator.validateProperty(new Object(), "foo"); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException expected) { - } - } - - public void testValidateValue_string() { - try { - validator.validateValue(String.class, "notValid", "value"); - fail("Expected a " + IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - // expected - } - } - - protected Validator createValidator() { - return GWT.create(ExampleGwtValidator.class); - } - - @Override - protected final void gwtSetUp() throws Exception { - super.gwtSetUp(); - author = new Author(); - validator = createValidator(); - } - - private <T> void assertContentsAnyOrder(String message, - Iterable<T> actual, T... expected) { - - List<T> expectedList = Arrays.asList(expected); - message += "Expected to find " + expectedList + " but found " + actual; - for (T a : actual) { - if (expectedList.contains(a)) { - expectedList.remove(a); - } else { - fail(message); - } - } - if (!expectedList.isEmpty()) { - fail(message); - } - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/Book.java b/user/test/com/google/gwt/validation/example/client/Book.java deleted file mode 100644 index 4267176..0000000 --- a/user/test/com/google/gwt/validation/example/client/Book.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import javax.validation.groups.Default; - -/** - * From the JSR 303 spec. - */ -public class Book { - private String title; - private String description; - @Valid - @NotNull - private Author author; - - @NotEmpty(groups = {FirstLevelCheck.class, Default.class}) - @Size(max = 30) - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Author getAuthor() { - return author; - } - - public void setAuthor(Author author) { - this.author = author; - } - - public String getDescription() { - return description; - } - - public void setAuthor(String description) { - this.description = description; - } -}
diff --git a/user/test/com/google/gwt/validation/example/client/ExampleGwtValidator.java b/user/test/com/google/gwt/validation/example/client/ExampleGwtValidator.java deleted file mode 100644 index 46a6922..0000000 --- a/user/test/com/google/gwt/validation/example/client/ExampleGwtValidator.java +++ /dev/null
@@ -1,29 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -import com.google.gwt.validation.client.GwtValidation; - -import javax.validation.Validator; - -/** - * Example top level class to create a {@link Validator}. - * - * GWT.create instances of this class - */ -@GwtValidation(Author.class) -public interface ExampleGwtValidator extends Validator { -}
diff --git a/user/test/com/google/gwt/validation/example/client/ExampleValidationClientGwtSuite.java b/user/test/com/google/gwt/validation/example/client/ExampleValidationClientGwtSuite.java deleted file mode 100644 index e9a711a..0000000 --- a/user/test/com/google/gwt/validation/example/client/ExampleValidationClientGwtSuite.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -import com.google.gwt.junit.tools.GWTTestSuite; - -import junit.framework.Test; - -/** - * All Constraints tests that GWTTestCase. - */ -public class ExampleValidationClientGwtSuite { - public static Test suite() { - GWTTestSuite suite = new GWTTestSuite( - "Validation Example tests that require GWT"); - suite.addTestSuite(AuthorTest.class); - return suite; - } - -}
diff --git a/user/test/com/google/gwt/validation/example/client/FirstLevelCheck.java b/user/test/com/google/gwt/validation/example/client/FirstLevelCheck.java deleted file mode 100644 index e560fee..0000000 --- a/user/test/com/google/gwt/validation/example/client/FirstLevelCheck.java +++ /dev/null
@@ -1,23 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -/** - * A example group for validation. - */ -public interface FirstLevelCheck { - -}
diff --git a/user/test/com/google/gwt/validation/example/client/NotEmpty.java b/user/test/com/google/gwt/validation/example/client/NotEmpty.java deleted file mode 100644 index f88465c..0000000 --- a/user/test/com/google/gwt/validation/example/client/NotEmpty.java +++ /dev/null
@@ -1,72 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * 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 com.google.gwt.validation.example.client; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.validation.Constraint; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import javax.validation.ReportAsSingleViolation; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -/** - * The annotated element size must at least 1 and cannot be null. From the JSR - * 303 spec. - */ -@Documented -@NotNull -@Size(min = 1) -@ReportAsSingleViolation -@Constraint(validatedBy = NotEmpty.NotEmptyValidator.class) -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) -@Retention(RUNTIME) -public @interface NotEmpty { - String message() default "{com.google.gwt.validation.example.client.NotEmpty.message}"; - - Class<?>[] groups() default {}; - - /** - * From the JSR 303 spec. - */ - @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) - @Retention(RUNTIME) - @Documented - @interface List { - NotEmpty[] value(); - } - /** - * Sample composite validator. - */ - class NotEmptyValidator implements ConstraintValidator<NotEmpty, String> { - public void initialize(NotEmpty constraintAnnotation) { - } - - public boolean isValid(String value, ConstraintValidatorContext context) { - return true; - } - } -}