You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2013/03/08 11:45:18 UTC
svn commit: r1454316 [2/2] - in /pivot/branches/2.0.x:
examples/src/org/apache/pivot/examples/scripting/
examples/src/org/apache/pivot/examples/svg/
tests/src/org/apache/pivot/tests/ tests/src/org/apache/pivot/tests/issues/
tests/src/org/apache/pivot/t...
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableRangeValidator.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableRangeValidator.java?rev=1454316&r1=1454315&r2=1454316&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableRangeValidator.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableRangeValidator.java Fri Mar 8 10:45:17 2013
@@ -1,91 +1,91 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.wtk.validation;
-
-import java.util.Locale;
-
-/**
- * Generic validator version for a Comparable value limited in a range.
- */
-public class ComparableRangeValidator<T extends Comparable<T>> extends ComparableValidator<T> {
- private T minValue;
- private T maxValue;
-
- public ComparableRangeValidator() {
- this(Locale.getDefault());
- }
-
- public ComparableRangeValidator(Locale locale) {
- super(locale);
- this.minValue = null;
- this.maxValue = null;
- }
-
- public ComparableRangeValidator(T minValue, T maxValue) {
- this(Locale.getDefault(), minValue, maxValue);
- }
-
- public ComparableRangeValidator(Locale locale, T minValue, T maxValue) {
- super(locale);
- setMinimum(minValue);
- setMaximum(maxValue);
-
- if (maxValue.compareTo(minValue)< 0) {
- throw new IllegalArgumentException("maxValue must be higher or equals than minValue");
- }
- }
-
- public T getMinimum() {
- return minValue;
- }
-
- public void setMinimum(T minValue) {
- if (minValue == null) {
- throw new IllegalArgumentException("minValue must be not null");
- }
- this.minValue = minValue;
- }
-
- public T getMaximum() {
- return maxValue;
- }
-
- public void setMaximum(T maxValue) {
- if (minValue == null) {
- throw new IllegalArgumentException("minValue must be not null");
- }
- this.maxValue = maxValue;
- }
-
- @Override
- public boolean isValid(String text) {
- boolean valid = false;
-
- if (super.isValid(text)) {
- @SuppressWarnings("unchecked")
- final Comparable<T> value = (Comparable<T>) textToComparable(text);
- if (value != null) {
- valid = (value.compareTo(minValue) >= 0 && value.compareTo(maxValue) <= 0);
- }
- }
-
- return valid;
- }
-
- @Override
- public String toString() {
- return ( this.getClass().getSimpleName() + "(" + minValue + "," + maxValue + ")" );
- }
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.wtk.validation;
+
+import java.util.Locale;
+
+/**
+ * Generic validator version for a Comparable value limited in a range.
+ */
+public class ComparableRangeValidator<T extends Comparable<T>> extends ComparableValidator<T> {
+ private T minValue;
+ private T maxValue;
+
+ public ComparableRangeValidator() {
+ this(Locale.getDefault());
+ }
+
+ public ComparableRangeValidator(Locale locale) {
+ super(locale);
+ this.minValue = null;
+ this.maxValue = null;
+ }
+
+ public ComparableRangeValidator(T minValue, T maxValue) {
+ this(Locale.getDefault(), minValue, maxValue);
+ }
+
+ public ComparableRangeValidator(Locale locale, T minValue, T maxValue) {
+ super(locale);
+ setMinimum(minValue);
+ setMaximum(maxValue);
+
+ if (maxValue.compareTo(minValue)< 0) {
+ throw new IllegalArgumentException("maxValue must be higher or equals than minValue");
+ }
+ }
+
+ public T getMinimum() {
+ return minValue;
+ }
+
+ public void setMinimum(T minValue) {
+ if (minValue == null) {
+ throw new IllegalArgumentException("minValue must be not null");
+ }
+ this.minValue = minValue;
+ }
+
+ public T getMaximum() {
+ return maxValue;
+ }
+
+ public void setMaximum(T maxValue) {
+ if (minValue == null) {
+ throw new IllegalArgumentException("minValue must be not null");
+ }
+ this.maxValue = maxValue;
+ }
+
+ @Override
+ public boolean isValid(String text) {
+ boolean valid = false;
+
+ if (super.isValid(text)) {
+ @SuppressWarnings("unchecked")
+ final Comparable<T> value = (Comparable<T>) textToComparable(text);
+ if (value != null) {
+ valid = (value.compareTo(minValue) >= 0 && value.compareTo(maxValue) <= 0);
+ }
+ }
+
+ return valid;
+ }
+
+ @Override
+ public String toString() {
+ return ( this.getClass().getSimpleName() + "(" + minValue + "," + maxValue + ")" );
+ }
+
+}
Propchange: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableRangeValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java?rev=1454316&r1=1454315&r2=1454316&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java Fri Mar 8 10:45:17 2013
@@ -1,56 +1,56 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.wtk.validation;
-
-import java.util.Locale;
-
-/**
- * A validator for a Comparable value.
- */
-public class ComparableValidator<T extends Comparable<T>> extends DecimalValidator {
-
- public ComparableValidator() {
- super();
- }
-
- public ComparableValidator(Locale locale) {
- super(locale);
- }
-
-// @Override
-// public boolean isValid(String text) {
-// if (!super.isValid(text))
-// return false;
-//
-// return true;
-// }
-
- @Override
- public boolean isValid(String text) {
- boolean valid = false;
-
- if (super.isValid(text)) {
- @SuppressWarnings("unchecked")
- final Comparable<T> value = (Comparable<T>) textToComparable(text);
- valid = (value != null);
- }
-
- return valid;
- }
-
- protected final Comparable<?> textToComparable(String text) {
- return textToBigDecimal(text);
- }
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.wtk.validation;
+
+import java.util.Locale;
+
+/**
+ * A validator for a Comparable value.
+ */
+public class ComparableValidator<T extends Comparable<T>> extends DecimalValidator {
+
+ public ComparableValidator() {
+ super();
+ }
+
+ public ComparableValidator(Locale locale) {
+ super(locale);
+ }
+
+// @Override
+// public boolean isValid(String text) {
+// if (!super.isValid(text))
+// return false;
+//
+// return true;
+// }
+
+ @Override
+ public boolean isValid(String text) {
+ boolean valid = false;
+
+ if (super.isValid(text)) {
+ @SuppressWarnings("unchecked")
+ final Comparable<T> value = (Comparable<T>) textToComparable(text);
+ valid = (value != null);
+ }
+
+ return valid;
+ }
+
+ protected final Comparable<?> textToComparable(String text) {
+ return textToBigDecimal(text);
+ }
+
+}
Propchange: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/ComparableValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/EmptyTextValidator.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/EmptyTextValidator.java?rev=1454316&r1=1454315&r2=1454316&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/EmptyTextValidator.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/EmptyTextValidator.java Fri Mar 8 10:45:17 2013
@@ -1,31 +1,31 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.wtk.validation;
-
-/**
- * A validator for a (trimmed) text.
- * <p>
- * This is useful only when a value to be valid has to be absent.
- */
-public class EmptyTextValidator implements Validator {
-
- public EmptyTextValidator() {
- }
-
- @Override
- public boolean isValid(String text) {
- return (text.trim()).length() == 0;
- }
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.wtk.validation;
+
+/**
+ * A validator for a (trimmed) text.
+ * <p>
+ * This is useful only when a value to be valid has to be absent.
+ */
+public class EmptyTextValidator implements Validator {
+
+ public EmptyTextValidator() {
+ }
+
+ @Override
+ public boolean isValid(String text) {
+ return (text.trim()).length() == 0;
+ }
+
+}
Propchange: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/validation/EmptyTextValidator.java
------------------------------------------------------------------------------
svn:eol-style = native