You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by si...@apache.org on 2010/03/28 14:28:32 UTC
svn commit: r928387 [5/15] - in /incubator/bval/trunk: ./ agimatec-jsr303/
agimatec-validation/ bval-core/ bval-core/.externalToolBuilders/
bval-core/.settings/ bval-core/src/ bval-core/src/main/
bval-core/src/main/java/ bval-core/src/main/java/org/ bv...
Added: incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml (added)
+++ incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml Sun Mar 28 12:28:25 2010
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<beanInfos>
+ <validator id="standard" java="org.apache.bval.routines.NOPValidation"
+ jsFunction="noop"/>
+ <validator id="email" java="org.apache.bval.routines.EMailValidation"/>
+ <bean id="org.apache.bval.example.BusinessObject"
+ impl="org.apache.bval.example.BusinessObject">
+ <feature key="mainKey">
+ <value class="string">userId</value>
+ </feature>
+ <feature key="DOMAIN">
+ <value class="string">TestObjects</value>
+ </feature>
+ <feature key="WIDGET">
+ <value class="string">entry</value>
+ </feature>
+ <property name="userId" mandatory="true"/>
+ <property name="firstName" mandatory="true" maxLength="100"/>
+ <property name="lastName" mandatory="true" maxLength="100"/>
+ <property name="title" mandatory="false" maxLength="10"/>
+ <property timeLag="PAST" name="dateBirth" mandatory="false"/>
+ <property timeLag="FUTURE" name="validTo" mandatory="false"/>
+ <property name="email">
+ <feature key="WIDGET">
+ <value class="string">entry</value>
+ </feature>
+ <feature key="TABLE_COLUMN">
+ <value class="boolean">true</value>
+ </feature>
+ <feature key="ajax-formatter">
+ <value class="map">
+ <entry>
+ <string>locale</string>
+ <string>DE</string>
+ </entry>
+ <entry>
+ <string>style</string>
+ <string>info</string>
+ </entry>
+ </value>
+ </feature>
+ <validator refId="email"/>
+ <validator refId="standard"/>
+ </property>
+ <relationship beanId="org.apache.bval.example.Address" name="address" mandatory="false"
+ displayName="UserAddress"/>
+ <relationship beanId="org.apache.bval.example.Address" name="addresses" maxLength="3"/>
+ </bean>
+ <bean id="org.apache.bval.example.Address"
+ impl="org.apache.bval.example.BusinessObjectAddress">
+ <feature key="DOMAIN">
+ <value class="string">TestObjects</value>
+ </feature>
+ <property name="city"/>
+ <property name="country" mandatory="true" maxLength="10"/>
+ <relationship name="owner" beanId="org.apache.bval.example.BusinessObject"
+ mandatory="true"/>
+ </bean>
+</beanInfos>
\ No newline at end of file
Propchange: incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/bval/trunk/bval-core/src/test/resources/org/apache/bval/example/test-beanInfos.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Propchange: incubator/bval/trunk/bval-jsr303/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Mar 28 12:28:25 2010
@@ -0,0 +1 @@
+target
Added: incubator/bval/trunk/bval-jsr303/LICENSE.txt
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/LICENSE.txt?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/LICENSE.txt (added)
+++ incubator/bval/trunk/bval-jsr303/LICENSE.txt Sun Mar 28 12:28:25 2010
@@ -0,0 +1,203 @@
+
+ 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
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
Propchange: incubator/bval/trunk/bval-jsr303/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/LICENSE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/bval/trunk/bval-jsr303/LICENSE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/NOTICE.txt?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/NOTICE.txt (added)
+++ incubator/bval/trunk/bval-jsr303/NOTICE.txt Sun Mar 28 12:28:25 2010
@@ -0,0 +1,16 @@
+
+Apache Incubator - Bean Validation project
+Copyright 2010 The Apache Software Foundation.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache and the Apache feather logo are trademarks of The Apache Software Foundation.
+
+
+The following copyright notice(s) were affixed to portions of this code
+with which this file is now or was at one time distributed.
+
+This product includes software developed by agimatec GmbH.
+Copyright 2007-2010 Agimatec GmbH. All rights reserved.
+
Propchange: incubator/bval/trunk/bval-jsr303/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/bval/trunk/bval-jsr303/NOTICE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/agimatec-jsr303.iml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/agimatec-jsr303.iml?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/agimatec-jsr303.iml (added)
+++ incubator/bval/trunk/bval-jsr303/agimatec-jsr303.iml Sun Mar 28 12:28:25 2010
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/xsd" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/com" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/jaxb" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target/agimatec-validation-dist-0.9.6-SNAPSHOT" />
+ <excludeFolder url="file://$MODULE_DIR$/target/classes" />
+ <excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
+ <excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" />
+ <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="agimatec-validation" exported="" />
+ <orderEntry type="library" exported="" name="Maven: commons-lang:commons-lang:2.4" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-beanutils:commons-beanutils:1.8.2" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
+ <orderEntry type="library" name="Maven: junit:junit:3.8.2" level="project" />
+ <orderEntry type="library" name="Maven: log4j:log4j:1.2.14" level="project" />
+ <orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.3.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0" level="project" />
+ <orderEntry type="library" name="Maven: javax.validation:validation-api:1.0.0.GA" level="project" />
+ </component>
+</module>
+
Added: incubator/bval/trunk/bval-jsr303/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/pom.xml?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/pom.xml (added)
+++ incubator/bval/trunk/bval-jsr303/pom.xml Sun Mar 28 12:28:25 2010
@@ -0,0 +1,351 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<!--
+ Maven release plugin requires the project tag to be on a single line.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.bval</groupId>
+ <artifactId>bval-parent</artifactId>
+ <version>0.9.6</version>
+ </parent>
+
+ <artifactId>bval-jsr303</artifactId>
+ <name>bval-jsr303 :: Bean Validation 1.0 Implementation</name>
+ <packaging>jar</packaging>
+
+ <description>
+ This is an implementation of JSR 303 (Bean Validation), a specification
+ of the Java API for Javabean validation in Java EE and Java SE.
+ The technical objective is to provide a class level constraint declaration
+ and validation facility for the Java application developer, as well as a
+ constraint metadata repository and query API.
+ This implementation is based on the validation framework of agimatec GmbH,
+ that is in production since 2007 and offers additional features, like
+ XML-based extensible metadata, code generation (JSON for AJAX applications),
+ and optionally, JSR303 annotation support.
+ </description>
+
+ <!-- Sonatype repo doesn't allow this for release artifacts
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Repository</name>
+ <url>http://snapshots.jboss.org/maven2</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ -->
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <show>package</show>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc</report>
+ <report>test-javadoc</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jdepend-maven-plugin</artifactId>
+ <version>2.0-beta-2</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <profiles>
+ <profile>
+ <id>jaxb</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.3</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <!--
+ geronimo profile using geronimo-validation_1.0_spec.jar
+ active when property "agimatec-on-geronimo" is present.
+ (invoke maven with -Dagimatec-on-geronimo)
+ -->
+ <profile>
+ <id>geronimo</id>
+ <activation>
+ <property>
+ <name>agimatec-on-geronimo</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-validation_1.0_spec</artifactId>
+ <!-- allow users to choose an API provider -->
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <!--
+ default profile using javax.validation/validation-api.jar
+ automatically active when property "agimatec-on-geronimo" not present.
+ -->
+ <profile>
+ <id>ri</id>
+ <activation>
+ <property>
+ <name>!agimatec-on-geronimo</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <!-- allow users to choose an API provider -->
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.bval</groupId>
+ <artifactId>bval-core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- optional dependencies -->
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <!-- allow users to choose an API provider -->
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/main/xsd</directory>
+ <targetPath>META-INF</targetPath>
+ </resource>
+ <!-- also include license and notice files -->
+ <resource>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ <include>DISCLAIMER.txt</include>
+ </includes>
+ <targetPath>META-INF</targetPath>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ <include>DISCLAIMER.txt</include>
+ </includes>
+ <targetPath>META-INF</targetPath>
+ </testResource>
+ </testResources>
+
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ </extension>
+ </extensions>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xjc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <packageName>org.apache.bval.jsr303.xml</packageName>
+ <outputDirectory>${basedir}/target/generated-sources</outputDirectory>
+ <extension>true</extension>
+ </configuration>
+ </plugin>
+
+ <!--
+ create a directory unter test/agimatec-validation-dist/**
+ with all artifacts, sources and dependencies
+ for download from the project website
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${dist-dir}/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <includeScope>compile</includeScope>
+ </configuration>
+ </execution>
+ <execution>
+ <id>src-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <classifier>sources</classifier>
+ <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
+ <outputDirectory>${dist-dir}/src</outputDirectory>
+ <excludeTransitive>true</excludeTransitive>
+ <includeScope>compile</includeScope>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-installed</id>
+ <phase>install</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <version>${project.version}</version>
+ <type>${project.packaging}</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${dist-dir}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-sources</id>
+ <phase>install</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <version>${project.version}</version>
+ <type>${project.packaging}</type>
+ <classifier>sources</classifier>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <version>${project.version}</version>
+ <type>${project.packaging}</type>
+ <classifier>test-sources</classifier>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${dist-dir}/src</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <dist-dir>${project.build.directory}/agimatec-validation-dist-${project.version}</dist-dir>
+ </properties>
+</project>
Propchange: incubator/bval/trunk/bval-jsr303/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/bval/trunk/bval-jsr303/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/bval/trunk/bval-jsr303/readme.txt
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/readme.txt?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/readme.txt (added)
+++ incubator/bval/trunk/bval-jsr303/readme.txt Sun Mar 28 12:28:25 2010
@@ -0,0 +1,100 @@
+agimatec-jsr303
+===============
+
+JSR 303: bean-validation by agimatec GmbH
+==========================================
+This is an implementation of JSR 303 (Bean Validation), a specification of the Java
+API for Javabean validation in Java EE and Java SE.
+The technical objective is to provide a class level constraint declaration and validation
+facility for the Java application developer, as well as a constraint metadata repository
+and query API.
+This implementation is based on the validation framework of agimatec GmbH,
+that is in production since 2007 and offers additional features,
+like XML-based extensible metadata, code generation (JSON for AJAX applications),
+JSR303 annotation support.
+
+How to compile the project
+==========================
+Requirements:
+0. Sources require java1.5 or higher. (Tested with JDK 1.5.0_12 and 1.6.0_07)
+1. The project is built with maven2 (2.0.9).
+ You need to download and install maven2 from: http://maven.apache.org/
+2. Invoke maven2 from within the directory of the pom.xml file
+
+When building the project from source, you need the compatible version validation-api.jar:
+
+Check out the reference implementation and build it first:
+svn checkout http://anonsvn.jboss.org/repos/hibernate/beanvalidation/trunk/validation-api validation-api
+cd validation-api
+mvn clean install
+
+[As long as there is no public maven repository to get the artifact of validation-api from.]
+
+compile agimatec-jsr303 project:
+------------------------------------
+mvn install
+(artifacts are generated into the target directory)
+
+compile with alternative dependencies (geronimo):
+-------------------------------------------------
+compile agimatec-jsr303 using geronimo artifacts for validation-api
+instead of reference implementation of validation-api:
+
+mvn install -Dagimatec-on-geronimo
+
+(optional) generate site, javadoc:
+-----------------------
+mvn site
+
+(optional) generate source-jars:
+---------------------
+mvn source:jar
+mvn source:test-jar
+
+(optional) generate an IntelliJ project:
+-----------------------------
+mvn idea:idea
+
+(optional) deploy maven-site and javadoc:
+------------------------------
+[ Note:
+ You must set the properties ${agimatec-site-id} and ${agimatec-site-url} to
+ adequate values. You can do that by adding them to your maven settings.xml. This is the place
+ where the server credenticals for uploads are kept. ]
+
+mvn site-deploy
+
+Getting started
+---------------
+Refer to the project page and WIKI at:
+http://code.google.com/p/agimatec-validation
+
+You can checkout latest sources and releases from there.
+You can also refer to the test cases in src/test/java/** for examples.
+
+Project status
+==============
+* The agimatec-validation framework is older than the JSR 303 specification, but the similarities
+ were striking so that the adaption to the standard was possible withing a short time.
+ There are still things to be done...
+
+* The specification is in beta state and subject to change.
+
+* Please verify that the version of validation-api.jar you are using
+ is compatible with agimatec-validation.jar
+
+* You can use the framework with the JSR303 interfaces if you want to strictly use the standard.
+ Refer to classes in packages javax.validation and com.agimatec.validation.jsr303
+
+ or you can access the propriatary APIs of agimatec-validation for additional features.
+ Refer to classes MetaBeanManagerFactory and BeanValidator.
+
+Feedback, questions, contribution
+=================================
+** Your feedback is welcome! **
+
+http://code.google.com/p/agimatec-validation
+http://www.agimatec.de
+
+Roman Stumm, agimatec GmbH, 2008, 2009, 2010
+email: roman.stumm@agimatec.de
Propchange: incubator/bval/trunk/bval-jsr303/readme.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/readme.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/bval/trunk/bval-jsr303/readme.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.AssertFalse;
+
+/**
+ * Description: assert that value is false<br/>
+ * User: roman <br/>
+ * Date: 03.02.2009 <br/>
+ * Time: 12:48:05 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class AssertFalseValidator implements ConstraintValidator<AssertFalse, Boolean> {
+
+ public void initialize(AssertFalse annotation) {
+ }
+
+ public boolean isValid(Boolean value, ConstraintValidatorContext context) {
+ return value == null || !value;
+ }
+
+}
\ No newline at end of file
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.AssertTrue;
+
+/**
+ * Description: assert that value is true<br/>
+ * User: roman <br/>
+ * Date: 03.02.2009 <br/>
+ * Time: 12:48:21 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class AssertTrueValidator implements ConstraintValidator<AssertTrue, Boolean> {
+
+ public void initialize(AssertTrue annotation) {
+ }
+
+ public boolean isValid(Boolean value, ConstraintValidatorContext context) {
+ return value == null || value;
+ }
+
+}
\ No newline at end of file
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.DecimalMax;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/** Description: validate that number-value of passed object is <= maxvalue<br/> */
+public class DecimalMaxValidatorForNumber
+ implements ConstraintValidator<DecimalMax, Number> {
+
+ private BigDecimal maxValue;
+
+ public void initialize(DecimalMax annotation) {
+ try {
+ this.maxValue = new BigDecimal(annotation.value());
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(
+ annotation.value() + " does not represent a valid BigDecimal format");
+ }
+ }
+
+ public boolean isValid(Number value, ConstraintValidatorContext context) {
+ if (value == null) {
+ return true;
+ } else if (value instanceof BigDecimal) {
+ return ((BigDecimal) value).compareTo(maxValue) != 1;
+ } else if (value instanceof BigInteger) {
+ return (new BigDecimal((BigInteger) value)).compareTo(maxValue) != 1;
+ } else {
+ return (new BigDecimal(value.doubleValue()).compareTo(maxValue)) != 1;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForNumber.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.DecimalMax;
+import java.math.BigDecimal;
+
+/**
+ * Check that the String being validated represents a number, and has a value
+ * <= maxvalue
+ */
+public class DecimalMaxValidatorForString
+ implements ConstraintValidator<DecimalMax, String> {
+
+ private BigDecimal maxValue;
+
+ public void initialize(DecimalMax annotation) {
+ try {
+ this.maxValue = new BigDecimal(annotation.value());
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(
+ annotation.value() + " does not represent a valid BigDecimal format");
+ }
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext context) {
+ if (value == null) {
+ return true;
+ }
+ try {
+ return new BigDecimal(value).compareTo(maxValue) != 1;
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMaxValidatorForString.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.DecimalMin;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/** Description: validate that number-value of passed object is >= minvalue<br/> */
+public class DecimalMinValidatorForNumber
+ implements ConstraintValidator<DecimalMin, Number> {
+
+ private BigDecimal minValue;
+
+ public void initialize(DecimalMin annotation) {
+ try {
+ this.minValue = new BigDecimal(annotation.value());
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(
+ annotation.value() + " does not represent a valid BigDecimal format");
+ }
+ }
+
+ public boolean isValid(Number value, ConstraintValidatorContext context) {
+ if (value == null) {
+ return true;
+ } else if (value instanceof BigDecimal) {
+ return ((BigDecimal) value).compareTo(minValue) != -1;
+ } else if (value instanceof BigInteger) {
+ return (new BigDecimal((BigInteger) value)).compareTo(minValue) != -1;
+ } else {
+ return (new BigDecimal(value.doubleValue()).compareTo(minValue)) != -1;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForNumber.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.DecimalMin;
+import java.math.BigDecimal;
+
+/**
+ * Description:
+ * Check that the String being validated represents a number, and has a value
+ * >= minvalue
+ */
+public class DecimalMinValidatorForString
+ implements ConstraintValidator<DecimalMin, String> {
+
+ private BigDecimal minValue;
+
+ public void initialize(DecimalMin annotation) {
+ try {
+ this.minValue = new BigDecimal(annotation.value());
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(
+ annotation.value() + " does not represent a valid BigDecimal format");
+ }
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext context) {
+ //null values are valid
+ if (value == null) {
+ return true;
+ }
+ try {
+ return new BigDecimal(value).compareTo(minValue) != -1;
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DecimalMinValidatorForString.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+
+/**
+ * Validates that the <code>Number</code> being validates matches the pattern
+ * defined in the constraint.
+ */
+public class DigitsValidatorForNumber implements ConstraintValidator<Digits, Number> {
+
+ private int integral;
+ private int fractional;
+
+ public int getIntegral() {
+ return integral;
+ }
+
+ public void setIntegral(int integral) {
+ this.integral = integral;
+ }
+
+ public int getFractional() {
+ return fractional;
+ }
+
+ public void setFractional(int fractional) {
+ this.fractional = fractional;
+ }
+
+ public void initialize(Digits annotation) {
+ this.integral = annotation.integer();
+ this.fractional = annotation.fraction();
+ if (integral < 0) {
+ throw new IllegalArgumentException(
+ "The length of the integer part cannot be negative.");
+ }
+ if (fractional < 0) {
+ throw new IllegalArgumentException(
+ "The length of the fraction part cannot be negative.");
+ }
+ }
+
+ public boolean isValid(Number num, ConstraintValidatorContext context) {
+ if (num == null) {
+ return true;
+ }
+
+ BigDecimal bigDecimal;
+ if (num instanceof BigDecimal) {
+ bigDecimal = (BigDecimal) num;
+ } else {
+ bigDecimal = new BigDecimal(num.toString()).stripTrailingZeros();
+ }
+
+ int intLength = bigDecimal.precision() - bigDecimal.scale();
+ if (integral >= intLength) {
+ int factionLength = bigDecimal.scale() < 0 ? 0 : bigDecimal.scale();
+ return fractional >= factionLength;
+ } else {
+ return false;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+
+/**
+ * Validates that the <code>String</code> being validated consists of digits,
+ * and matches the pattern defined in the constraint.
+ */
+public class DigitsValidatorForString implements ConstraintValidator<Digits, String> {
+
+ private int integral;
+ private int fractional;
+
+ public int getIntegral() {
+ return integral;
+ }
+
+ public void setIntegral(int integral) {
+ this.integral = integral;
+ }
+
+ public int getFractional() {
+ return fractional;
+ }
+
+ public void setFractional(int fractional) {
+ this.fractional = fractional;
+ }
+
+ public void initialize(Digits annotation) {
+ this.integral = annotation.integer();
+ this.fractional = annotation.fraction();
+ if (integral < 0) {
+ throw new IllegalArgumentException(
+ "The length of the integer part cannot be negative.");
+ }
+ if (fractional < 0) {
+ throw new IllegalArgumentException(
+ "The length of the fraction part cannot be negative.");
+ }
+ }
+
+ public boolean isValid(String str, ConstraintValidatorContext context) {
+ //null values are valid
+ if (str == null) {
+ return true;
+ }
+
+ BigDecimal bigDecimal = getBigDecimalValue(str);
+ if (bigDecimal == null) {
+ return false;
+ }
+
+ int intLength = bigDecimal.precision() - bigDecimal.scale();
+ if (integral >= intLength) {
+ int factionLength = bigDecimal.scale() < 0 ? 0 : bigDecimal.scale();
+ return fractional >= factionLength;
+ } else {
+ return false;
+ }
+ }
+
+ private BigDecimal getBigDecimalValue(String str) {
+ BigDecimal bd;
+ try {
+ bd = new BigDecimal(str);
+ } catch (NumberFormatException nfe) {
+ return null;
+ }
+ return bd;
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.*;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * <p>
+ * --
+ * This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate an email address (by pattern)<br/>
+ * User: roman.stumm <br/>
+ * Date: 14.10.2008 <br/>
+ * Time: 12:38:10 <br/>
+ * Copyright: Agimatec GmbH
+ */
+@Documented
+@Constraint(validatedBy = EmailValidator.class)
+@Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER})
+@Retention(RUNTIME)
+public @interface Email {
+ Class<?>[] groups() default {};
+
+ String message() default "{org.apache.bval.constraints.Email.message}";
+
+ Class<? extends Payload>[] payload() default {};
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/Email.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.apache.bval.routines.EMailValidation;
+
+/**
+ * Description: pattern for validation taken from hibernate.<br/>
+ * User: roman.stumm <br/>
+ * Date: 14.10.2008 <br/>
+ * Time: 12:38:37 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class EmailValidator implements ConstraintValidator<Email, String> {
+ protected final EMailValidation validation = new EMailValidation();
+
+ public boolean isValid(String value, ConstraintValidatorContext context) {
+ return validation.isValid(value);
+ }
+
+ public void initialize(Email parameters) {
+ // do nothing (as long as Email has no properties)
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Future;
+import java.util.Calendar;
+
+/**
+ * Description: validate a date or calendar representing a date in the future <br/>
+ * User: roman <br/>
+ * Date: 03.02.2009 <br/>
+ * Time: 12:48:43 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class FutureValidatorForCalendar implements ConstraintValidator<Future, Calendar> {
+
+ public void initialize(Future annotation) {
+ }
+
+ public boolean isValid(Calendar cal, ConstraintValidatorContext context) {
+ return cal == null || cal.after(now());
+ }
+
+
+ /**
+ * overwrite when you need a different algorithm for 'now'.
+ *
+ * @return current date/time
+ */
+ protected Calendar now() {
+ return Calendar.getInstance();
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForCalendar.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Future;
+import java.util.Date;
+
+/**
+ * Description: validate a date or calendar representing a date in the future <br/>
+ * User: roman <br/>
+ * Date: 03.02.2009 <br/>
+ * Time: 12:48:43 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class FutureValidatorForDate implements ConstraintValidator<Future, Date> {
+
+ public void initialize(Future annotation) {
+ }
+
+ public boolean isValid(Date date, ConstraintValidatorContext context) {
+ return date == null || date.after(now());
+ }
+
+ /**
+ * overwrite when you need a different algorithm for 'now'.
+ *
+ * @return current date/time
+ */
+ protected Date now() {
+ return new Date();
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/FutureValidatorForDate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Max;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * Check that the number being validated is less than or equal to the maximum
+ * value specified.
+ */
+public class MaxValidatorForNumber implements ConstraintValidator<Max, Number> {
+
+ private long max;
+
+ public void initialize(Max annotation) {
+ this.max = annotation.value();
+ }
+
+ public boolean isValid(Number value, ConstraintValidatorContext context) {
+ if (value == null) {
+ return true;
+ } else if (value instanceof BigDecimal) {
+ return ((BigDecimal) value).compareTo(BigDecimal.valueOf(max)) != 1;
+ } else if (value instanceof BigInteger) {
+ return ((BigInteger) value).compareTo(BigInteger.valueOf(max)) != 1;
+ } else {
+ return value.doubleValue() <= max;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Max;
+import java.math.BigDecimal;
+
+/**
+ * Check that the String being validated represents a number, and has a value
+ * less than or equal to the maximum value specified.
+ */
+public class MaxValidatorForString implements ConstraintValidator<Max, String> {
+
+ private long max;
+
+ public void initialize(Max annotation) {
+ this.max = annotation.value();
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext context) {
+ if (value == null) {
+ return true;
+ }
+ try {
+ return new BigDecimal(value).compareTo(BigDecimal.valueOf(max)) != 1;
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * Description: validate that number-value of passed object is >= min-value<br/>
+ * User: roman <br/>
+ * Date: 03.02.2009 <br/>
+ * Time: 12:48:54 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class MinValidatorForNumber implements ConstraintValidator<Min, Number> {
+
+ private long minValue;
+
+ public void initialize(Min annotation) {
+ this.minValue = annotation.value();
+ }
+
+ public boolean isValid(Number value, ConstraintValidatorContext context) {
+ if (value == null) {
+ return true;
+ } else if (value instanceof BigDecimal) {
+ return ((BigDecimal) value).compareTo(BigDecimal.valueOf(minValue)) != -1;
+ } else if (value instanceof BigInteger) {
+ return ((BigInteger) value).compareTo(BigInteger.valueOf(minValue)) != -1;
+ } else {
+ return value.doubleValue() >= minValue;
+ }
+
+ }
+}
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java
------------------------------------------------------------------------------
svn:mime-type = text/plain