You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/10 18:20:02 UTC
[commons-validator] 01/02: Use final.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
commit 411a907a143d8d5e85f01c480686f7b9c396cbea
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 10 14:16:39 2022 -0400
Use final.
---
.../java/org/apache/commons/validator/Arg.java | 14 +-
.../commons/validator/CreditCardValidator.java | 32 ++--
.../apache/commons/validator/DateValidator.java | 10 +-
.../apache/commons/validator/EmailValidator.java | 34 ++--
.../java/org/apache/commons/validator/Field.java | 179 +++++++++++----------
.../java/org/apache/commons/validator/Form.java | 49 +++---
.../java/org/apache/commons/validator/FormSet.java | 36 ++---
.../apache/commons/validator/FormSetFactory.java | 18 +--
.../commons/validator/GenericTypeValidator.java | 74 ++++-----
.../apache/commons/validator/GenericValidator.java | 68 ++++----
.../apache/commons/validator/ISBNValidator.java | 2 +-
.../java/org/apache/commons/validator/Msg.java | 12 +-
.../org/apache/commons/validator/UrlValidator.java | 48 +++---
.../org/apache/commons/validator/Validator.java | 26 +--
.../apache/commons/validator/ValidatorAction.java | 108 ++++++-------
.../commons/validator/ValidatorException.java | 2 +-
.../commons/validator/ValidatorResources.java | 80 ++++-----
.../apache/commons/validator/ValidatorResult.java | 24 +--
.../apache/commons/validator/ValidatorResults.java | 26 +--
.../java/org/apache/commons/validator/Var.java | 16 +-
.../routines/AbstractCalendarValidator.java | 56 +++----
.../routines/AbstractFormatValidator.java | 24 +--
.../routines/AbstractNumberValidator.java | 32 ++--
.../validator/routines/BigDecimalValidator.java | 24 +--
.../validator/routines/BigIntegerValidator.java | 18 +--
.../commons/validator/routines/ByteValidator.java | 26 +--
.../validator/routines/CalendarValidator.java | 44 ++---
.../commons/validator/routines/CodeValidator.java | 20 +--
.../validator/routines/CreditCardValidator.java | 40 ++---
.../validator/routines/CurrencyValidator.java | 10 +-
.../commons/validator/routines/DateValidator.java | 54 +++----
.../validator/routines/DomainValidator.java | 48 +++---
.../validator/routines/DoubleValidator.java | 24 +--
.../commons/validator/routines/EmailValidator.java | 22 +--
.../commons/validator/routines/FloatValidator.java | 28 ++--
.../commons/validator/routines/IBANValidator.java | 24 +--
.../commons/validator/routines/ISBNValidator.java | 28 ++--
.../commons/validator/routines/ISINValidator.java | 10 +-
.../commons/validator/routines/ISSNValidator.java | 26 +--
.../validator/routines/InetAddressValidator.java | 20 +--
.../validator/routines/IntegerValidator.java | 26 +--
.../commons/validator/routines/LongValidator.java | 24 +--
.../validator/routines/PercentValidator.java | 10 +-
.../commons/validator/routines/RegexValidator.java | 38 ++---
.../commons/validator/routines/ShortValidator.java | 26 +--
.../commons/validator/routines/TimeValidator.java | 28 ++--
.../commons/validator/routines/UrlValidator.java | 66 ++++----
.../routines/checkdigit/ABANumberCheckDigit.java | 4 +-
.../routines/checkdigit/CUSIPCheckDigit.java | 10 +-
.../routines/checkdigit/CheckDigitException.java | 4 +-
.../routines/checkdigit/EAN13CheckDigit.java | 4 +-
.../routines/checkdigit/IBANCheckDigit.java | 20 +--
.../routines/checkdigit/ISBN10CheckDigit.java | 6 +-
.../routines/checkdigit/ISBNCheckDigit.java | 4 +-
.../routines/checkdigit/ISINCheckDigit.java | 14 +-
.../routines/checkdigit/ISSNCheckDigit.java | 6 +-
.../routines/checkdigit/LuhnCheckDigit.java | 6 +-
.../routines/checkdigit/ModulusCheckDigit.java | 30 ++--
.../routines/checkdigit/ModulusTenCheckDigit.java | 18 +--
.../routines/checkdigit/SedolCheckDigit.java | 8 +-
.../routines/checkdigit/VerhoeffCheckDigit.java | 16 +-
.../org/apache/commons/validator/util/Flags.java | 18 +--
.../commons/validator/util/ValidatorUtils.java | 35 ++--
.../commons/validator/AbstractCommonTest.java | 4 +-
.../commons/validator/AbstractNumberTest.java | 14 +-
.../org/apache/commons/validator/ByteTest.java | 14 +-
.../commons/validator/CreditCardValidatorTest.java | 8 +-
.../validator/CustomValidatorResourcesTest.java | 6 +-
.../org/apache/commons/validator/DateTest.java | 14 +-
.../org/apache/commons/validator/DoubleTest.java | 10 +-
.../org/apache/commons/validator/EmailTest.java | 42 ++---
.../apache/commons/validator/EntityImportTest.java | 10 +-
.../apache/commons/validator/ExceptionTest.java | 22 +--
.../apache/commons/validator/ExtensionTest.java | 76 ++++-----
.../org/apache/commons/validator/FieldTest.java | 18 +--
.../org/apache/commons/validator/FloatTest.java | 10 +-
.../validator/GenericTypeValidatorImpl.java | 60 +++----
.../validator/GenericTypeValidatorTest.java | 32 ++--
.../commons/validator/GenericValidatorImpl.java | 56 +++----
.../commons/validator/GenericValidatorTest.java | 2 +-
.../commons/validator/ISBNValidatorTest.java | 4 +-
.../org/apache/commons/validator/IntegerTest.java | 14 +-
.../org/apache/commons/validator/LocaleTest.java | 24 +--
.../org/apache/commons/validator/LongTest.java | 14 +-
.../commons/validator/MultipleConfigFilesTest.java | 62 +++----
.../org/apache/commons/validator/MultipleTest.java | 74 ++++-----
.../org/apache/commons/validator/NameBean.java | 6 +-
.../apache/commons/validator/ParameterTest.java | 16 +-
.../apache/commons/validator/RequiredIfTest.java | 52 +++---
.../apache/commons/validator/RequiredNameTest.java | 62 +++----
.../org/apache/commons/validator/ResultPair.java | 2 +-
.../apache/commons/validator/RetrieveFormTest.java | 26 +--
.../org/apache/commons/validator/ShortTest.java | 10 +-
.../org/apache/commons/validator/TypeBean.java | 16 +-
.../java/org/apache/commons/validator/UrlTest.java | 44 ++---
.../commons/validator/ValidatorResourcesTest.java | 4 +-
.../commons/validator/ValidatorResultsTest.java | 26 +--
.../apache/commons/validator/ValidatorTest.java | 94 +++++------
.../org/apache/commons/validator/ValueBean.java | 2 +-
.../java/org/apache/commons/validator/VarTest.java | 14 +-
.../validator/custom/CustomValidatorResources.java | 2 +-
.../routines/AbstractCalendarValidatorTest.java | 48 +++---
.../routines/AbstractNumberValidatorTest.java | 38 ++---
.../routines/BigDecimalValidatorTest.java | 42 ++---
.../routines/BigIntegerValidatorTest.java | 32 ++--
.../validator/routines/ByteValidatorTest.java | 36 ++---
.../validator/routines/CalendarValidatorTest.java | 90 +++++------
.../validator/routines/CodeValidatorTest.java | 34 ++--
.../routines/CreditCardValidatorTest.java | 64 ++++----
.../validator/routines/CurrencyValidatorTest.java | 38 ++---
.../validator/routines/DateValidatorTest.java | 72 ++++-----
.../routines/DomainValidatorStartupTest.java | 36 ++---
.../validator/routines/DomainValidatorTest.java | 104 ++++++------
.../validator/routines/DoubleValidatorTest.java | 32 ++--
.../validator/routines/EmailValidatorTest.java | 32 ++--
.../validator/routines/FloatValidatorTest.java | 52 +++---
.../validator/routines/IBANValidatorTest.java | 64 ++++----
.../validator/routines/ISBNValidatorTest.java | 38 ++---
.../validator/routines/ISINValidatorTest.java | 12 +-
.../validator/routines/ISSNValidatorTest.java | 34 ++--
.../routines/InetAddressValidatorTest.java | 10 +-
.../validator/routines/IntegerValidatorTest.java | 32 ++--
.../validator/routines/LongValidatorTest.java | 32 ++--
.../validator/routines/PercentValidatorTest.java | 14 +-
.../validator/routines/RegexValidatorTest.java | 54 +++----
.../validator/routines/ShortValidatorTest.java | 36 ++---
.../validator/routines/TimeValidatorTest.java | 62 +++----
.../validator/routines/UrlValidatorTest.java | 102 ++++++------
.../checkdigit/ABANumberCheckDigitTest.java | 2 +-
.../checkdigit/AbstractCheckDigitTest.java | 52 +++---
.../routines/checkdigit/CUSIPCheckDigitTest.java | 6 +-
.../routines/checkdigit/EAN13CheckDigitTest.java | 2 +-
.../routines/checkdigit/IBANCheckDigitTest.java | 18 +--
.../routines/checkdigit/ISBN10CheckDigitTest.java | 2 +-
.../routines/checkdigit/ISBNCheckDigitTest.java | 10 +-
.../routines/checkdigit/ISINCheckDigitTest.java | 4 +-
.../routines/checkdigit/ISSNCheckDigitTest.java | 2 +-
.../routines/checkdigit/LuhnCheckDigitTest.java | 2 +-
.../checkdigit/ModulusTenABACheckDigitTest.java | 2 +-
.../checkdigit/ModulusTenCUSIPCheckDigitTest.java | 6 +-
.../checkdigit/ModulusTenEAN13CheckDigitTest.java | 2 +-
.../checkdigit/ModulusTenLuhnCheckDigitTest.java | 2 +-
.../checkdigit/ModulusTenSedolCheckDigitTest.java | 4 +-
.../routines/checkdigit/SedolCheckDigitTest.java | 4 +-
.../checkdigit/VerhoeffCheckDigitTest.java | 2 +-
.../apache/commons/validator/util/FlagsTest.java | 24 +--
146 files changed, 2106 insertions(+), 2103 deletions(-)
diff --git a/src/main/java/org/apache/commons/validator/Arg.java b/src/main/java/org/apache/commons/validator/Arg.java
index e3ce7de6..e6ff96aa 100644
--- a/src/main/java/org/apache/commons/validator/Arg.java
+++ b/src/main/java/org/apache/commons/validator/Arg.java
@@ -80,7 +80,7 @@ public class Arg implements Cloneable, Serializable {
try {
return super.clone();
- } catch(CloneNotSupportedException e) {
+ } catch(final CloneNotSupportedException e) {
throw new RuntimeException(e.toString());
}
}
@@ -131,7 +131,7 @@ public class Arg implements Cloneable, Serializable {
* @param bundle The new bundle name.
* @since Validator 1.1
*/
- public void setBundle(String bundle) {
+ public void setBundle(final String bundle) {
this.bundle = bundle;
}
@@ -139,7 +139,7 @@ public class Arg implements Cloneable, Serializable {
* Sets the key/value.
* @param key They to access the argument.
*/
- public void setKey(String key) {
+ public void setKey(final String key) {
this.key = key;
}
@@ -147,7 +147,7 @@ public class Arg implements Cloneable, Serializable {
* Sets the name of the dependency.
* @param name the name of the dependency.
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -155,7 +155,7 @@ public class Arg implements Cloneable, Serializable {
* Set this argument's replacement position.
* @param position set this argument's replacement position.
*/
- public void setPosition(int position) {
+ public void setPosition(final int position) {
this.position = position;
}
@@ -163,7 +163,7 @@ public class Arg implements Cloneable, Serializable {
* Sets whether or not the key is a resource.
* @param resource If true indicates the key is a resource.
*/
- public void setResource(boolean resource) {
+ public void setResource(final boolean resource) {
this.resource = resource;
}
@@ -173,7 +173,7 @@ public class Arg implements Cloneable, Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
results.append("Arg: name=");
results.append(name);
diff --git a/src/main/java/org/apache/commons/validator/CreditCardValidator.java b/src/main/java/org/apache/commons/validator/CreditCardValidator.java
index e82822bf..71ac1818 100644
--- a/src/main/java/org/apache/commons/validator/CreditCardValidator.java
+++ b/src/main/java/org/apache/commons/validator/CreditCardValidator.java
@@ -110,8 +110,8 @@ public class CreditCardValidator {
* CreditCardValidator.VISA + CreditCardValidator.AMEX to specify that
* those are the only valid card types.
*/
- public CreditCardValidator(int options) {
- Flags f = new Flags(options);
+ public CreditCardValidator(final int options) {
+ final Flags f = new Flags(options);
if (f.isOn(VISA)) {
this.cardTypes.add(new Visa());
}
@@ -134,7 +134,7 @@ public class CreditCardValidator {
* @param card The card number to validate.
* @return Whether the card number is valid.
*/
- public boolean isValid(String card) {
+ public boolean isValid(final String card) {
if ((card == null) || (card.length() < 13) || (card.length() > 19)) {
return false;
}
@@ -143,8 +143,8 @@ public class CreditCardValidator {
return false;
}
- for (Object cardType : this.cardTypes) {
- CreditCardType type = (CreditCardType) cardType;
+ for (final Object cardType : this.cardTypes) {
+ final CreditCardType type = (CreditCardType) cardType;
if (type.matches(card)) {
return true;
}
@@ -159,7 +159,7 @@ public class CreditCardValidator {
* @param type The type that is now allowed to pass validation.
* @since Validator 1.1.2
*/
- public void addAllowedCardType(CreditCardType type){
+ public void addAllowedCardType(final CreditCardType type){
this.cardTypes.add(type);
}
@@ -168,16 +168,16 @@ public class CreditCardValidator {
* @param cardNumber Credit Card Number.
* @return Whether the card number passes the luhnCheck.
*/
- protected boolean luhnCheck(String cardNumber) {
+ protected boolean luhnCheck(final String cardNumber) {
// number must be validated as 0..9 numeric first!!
- int digits = cardNumber.length();
- int oddOrEven = digits & 1;
+ final int digits = cardNumber.length();
+ final int oddOrEven = digits & 1;
long sum = 0;
for (int count = 0; count < digits; count++) {
int digit = 0;
try {
digit = Integer.parseInt(cardNumber.charAt(count) + "");
- } catch(NumberFormatException e) {
+ } catch(final NumberFormatException e) {
return false;
}
@@ -222,7 +222,7 @@ public class CreditCardValidator {
private static class Visa implements CreditCardType {
private static final String PREFIX = "4";
@Override
- public boolean matches(String card) {
+ public boolean matches(final String card) {
return (
card.substring(0, 1).equals(PREFIX)
&& (card.length() == 13 || card.length() == 16));
@@ -232,8 +232,8 @@ public class CreditCardValidator {
private static class Amex implements CreditCardType {
private static final String PREFIX = "34,37,";
@Override
- public boolean matches(String card) {
- String prefix2 = card.substring(0, 2) + ",";
+ public boolean matches(final String card) {
+ final String prefix2 = card.substring(0, 2) + ",";
return ((PREFIX.contains(prefix2)) && (card.length() == 15));
}
}
@@ -241,7 +241,7 @@ public class CreditCardValidator {
private static class Discover implements CreditCardType {
private static final String PREFIX = "6011";
@Override
- public boolean matches(String card) {
+ public boolean matches(final String card) {
return (card.substring(0, 4).equals(PREFIX) && (card.length() == 16));
}
}
@@ -249,8 +249,8 @@ public class CreditCardValidator {
private static class Mastercard implements CreditCardType {
private static final String PREFIX = "51,52,53,54,55,";
@Override
- public boolean matches(String card) {
- String prefix2 = card.substring(0, 2) + ",";
+ public boolean matches(final String card) {
+ final String prefix2 = card.substring(0, 2) + ",";
return ((PREFIX.contains(prefix2)) && (card.length() == 16));
}
}
diff --git a/src/main/java/org/apache/commons/validator/DateValidator.java b/src/main/java/org/apache/commons/validator/DateValidator.java
index af42a007..024b5c7c 100644
--- a/src/main/java/org/apache/commons/validator/DateValidator.java
+++ b/src/main/java/org/apache/commons/validator/DateValidator.java
@@ -67,7 +67,7 @@ public class DateValidator {
* @param strict Whether or not to have an exact match of the datePattern.
* @return true if the date is valid.
*/
- public boolean isValid(String value, String datePattern, boolean strict) {
+ public boolean isValid(final String value, final String datePattern, final boolean strict) {
if (value == null
|| datePattern == null
@@ -76,12 +76,12 @@ public class DateValidator {
return false;
}
- SimpleDateFormat formatter = new SimpleDateFormat(datePattern);
+ final SimpleDateFormat formatter = new SimpleDateFormat(datePattern);
formatter.setLenient(false);
try {
formatter.parse(value);
- } catch(ParseException e) {
+ } catch(final ParseException e) {
return false;
}
@@ -102,7 +102,7 @@ public class DateValidator {
* system default if null.
* @return true if the date is valid.
*/
- public boolean isValid(String value, Locale locale) {
+ public boolean isValid(final String value, final Locale locale) {
if (value == null) {
return false;
@@ -122,7 +122,7 @@ public class DateValidator {
try {
formatter.parse(value);
- } catch(ParseException e) {
+ } catch(final ParseException e) {
return false;
}
diff --git a/src/main/java/org/apache/commons/validator/EmailValidator.java b/src/main/java/org/apache/commons/validator/EmailValidator.java
index 44f6b4c2..705830a8 100644
--- a/src/main/java/org/apache/commons/validator/EmailValidator.java
+++ b/src/main/java/org/apache/commons/validator/EmailValidator.java
@@ -85,7 +85,7 @@ public class EmailValidator {
* value is considered invalid.
* @return true if the email address is valid.
*/
- public boolean isValid(String email) {
+ public boolean isValid(final String email) {
return org.apache.commons.validator.routines.EmailValidator.getInstance().isValid(email);
}
@@ -94,14 +94,14 @@ public class EmailValidator {
* @param domain being validated.
* @return true if the email address's domain is valid.
*/
- protected boolean isValidDomain(String domain) {
+ protected boolean isValidDomain(final String domain) {
boolean symbolic = false;
// see if domain is an IP address in brackets
- Matcher ipDomainMatcher = IP_DOMAIN_PATTERN.matcher(domain);
+ final Matcher ipDomainMatcher = IP_DOMAIN_PATTERN.matcher(domain);
if (ipDomainMatcher.matches()) {
- InetAddressValidator inetAddressValidator =
+ final InetAddressValidator inetAddressValidator =
InetAddressValidator.getInstance();
if (inetAddressValidator.isValid(ipDomainMatcher.group(1))) {
return true;
@@ -126,7 +126,7 @@ public class EmailValidator {
* @param user being validated
* @return true if the user name is valid.
*/
- protected boolean isValidUser(String user) {
+ protected boolean isValidUser(final String user) {
return USER_PATTERN.matcher(user).matches();
}
@@ -135,10 +135,10 @@ public class EmailValidator {
* @param ipAddress IP address
* @return true if the ip address is valid.
*/
- protected boolean isValidIpAddress(String ipAddress) {
- Matcher ipAddressMatcher = IP_DOMAIN_PATTERN.matcher(ipAddress);
+ protected boolean isValidIpAddress(final String ipAddress) {
+ final Matcher ipAddressMatcher = IP_DOMAIN_PATTERN.matcher(ipAddress);
for (int i = 1; i <= 4; i++) { // CHECKSTYLE IGNORE MagicNumber
- String ipSegment = ipAddressMatcher.group(i);
+ final String ipSegment = ipAddressMatcher.group(i);
if (ipSegment == null || ipSegment.isEmpty()) {
return false;
}
@@ -147,7 +147,7 @@ public class EmailValidator {
try {
iIpSegment = Integer.parseInt(ipSegment);
- } catch(NumberFormatException e) {
+ } catch(final NumberFormatException e) {
return false;
}
@@ -165,15 +165,15 @@ public class EmailValidator {
* @return true if the symbolic domain name is valid.
*/
protected boolean isValidSymbolicDomain(String domain) {
- String[] domainSegment = new String[10]; // CHECKSTYLE IGNORE MagicNumber
+ final String[] domainSegment = new String[10]; // CHECKSTYLE IGNORE MagicNumber
boolean match = true;
int i = 0;
- Matcher atomMatcher = ATOM_PATTERN.matcher(domain);
+ final Matcher atomMatcher = ATOM_PATTERN.matcher(domain);
while (match) {
match = atomMatcher.matches();
if (match) {
domainSegment[i] = atomMatcher.group(1);
- int l = domainSegment[i].length() + 1;
+ final int l = domainSegment[i].length() + 1;
domain =
(l >= domain.length())
? ""
@@ -183,14 +183,14 @@ public class EmailValidator {
}
}
- int len = i;
+ final int len = i;
// Make sure there's a host name preceding the domain.
if (len < 2) {
return false;
}
- String tld = domainSegment[len - 1];
+ final String tld = domainSegment[len - 1];
if (tld.length() <= 1) {
return false;
}
@@ -208,10 +208,10 @@ public class EmailValidator {
* @param emailStr The email address
* @return address with comments removed.
*/
- protected String stripComments(String emailStr) {
+ protected String stripComments(final String emailStr) {
String result = emailStr;
- String commentPat = "^((?:[^\"\\\\]|\\\\.)*(?:\"(?:[^\"\\\\]|\\\\.)*\"(?:[^\"\\\\]|\111111\\\\.)*)*)\\((?:[^()\\\\]|\\\\.)*\\)/";
- Pattern commentMatcher = Pattern.compile(commentPat);
+ final String commentPat = "^((?:[^\"\\\\]|\\\\.)*(?:\"(?:[^\"\\\\]|\\\\.)*\"(?:[^\"\\\\]|\111111\\\\.)*)*)\\((?:[^()\\\\]|\\\\.)*\\)/";
+ final Pattern commentMatcher = Pattern.compile(commentPat);
while (commentMatcher.matcher(result).matches()) {
result = result.replaceFirst(commentPat, "\1 ");
diff --git a/src/main/java/org/apache/commons/validator/Field.java b/src/main/java/org/apache/commons/validator/Field.java
index 4ba9e688..9e872ad8 100644
--- a/src/main/java/org/apache/commons/validator/Field.java
+++ b/src/main/java/org/apache/commons/validator/Field.java
@@ -162,7 +162,7 @@ public class Field implements Cloneable, Serializable {
* validation.
* @param page The page number.
*/
- public void setPage(int page) {
+ public void setPage(final int page) {
this.page = page;
}
@@ -178,7 +178,7 @@ public class Field implements Cloneable, Serializable {
* Sets the position of the <code>Field</code> in the validation list.
* @param fieldOrder The field position.
*/
- public void setFieldOrder(int fieldOrder) {
+ public void setFieldOrder(final int fieldOrder) {
this.fieldOrder = fieldOrder;
}
@@ -194,7 +194,7 @@ public class Field implements Cloneable, Serializable {
* Sets the property name of the field.
* @param property The field's property name.
*/
- public void setProperty(String property) {
+ public void setProperty(final String property) {
this.property = property;
}
@@ -212,7 +212,7 @@ public class Field implements Cloneable, Serializable {
* Sets the indexed property name of the field.
* @param indexedProperty The field's indexed property name.
*/
- public void setIndexedProperty(String indexedProperty) {
+ public void setIndexedProperty(final String indexedProperty) {
this.indexedProperty = indexedProperty;
}
@@ -232,7 +232,7 @@ public class Field implements Cloneable, Serializable {
* Sets the indexed property name of the field.
* @param indexedListProperty The field's indexed List property name.
*/
- public void setIndexedListProperty(String indexedListProperty) {
+ public void setIndexedListProperty(final String indexedListProperty) {
this.indexedListProperty = indexedListProperty;
}
@@ -248,14 +248,14 @@ public class Field implements Cloneable, Serializable {
* Sets the validation rules for this field as a comma separated list.
* @param depends A comma separated list of validator names.
*/
- public void setDepends(String depends) {
+ public void setDepends(final String depends) {
this.depends = depends;
this.dependencyList.clear();
- StringTokenizer st = new StringTokenizer(depends, ",");
+ final StringTokenizer st = new StringTokenizer(depends, ",");
while (st.hasMoreTokens()) {
- String depend = st.nextToken().trim();
+ final String depend = st.nextToken().trim();
if (depend != null && !depend.isEmpty()) {
this.dependencyList.add(depend);
@@ -267,7 +267,7 @@ public class Field implements Cloneable, Serializable {
* Add a <code>Msg</code> to the <code>Field</code>.
* @param msg A validation message.
*/
- public void addMsg(Msg msg) {
+ public void addMsg(final Msg msg) {
getMsgMap().put(msg.getName(), msg);
}
@@ -276,8 +276,8 @@ public class Field implements Cloneable, Serializable {
* @param key Validation key.
* @return A validation message for a specified validator.
*/
- public String getMsg(String key) {
- Msg msg = getMessage(key);
+ public String getMsg(final String key) {
+ final Msg msg = getMessage(key);
return (msg == null) ? null : msg.getKey();
}
@@ -287,7 +287,7 @@ public class Field implements Cloneable, Serializable {
* @param key Validation key.
* @return A validation message for a specified validator.
*/
- public Msg getMessage(String key) {
+ public Msg getMessage(final String key) {
return getMsgMap().get(key);
}
@@ -319,7 +319,7 @@ public class Field implements Cloneable, Serializable {
* @see #isClientValidation()
* @since Validator 1.4
*/
- public void setClientValidation(boolean clientValidation) {
+ public void setClientValidation(final boolean clientValidation) {
this.clientValidation = clientValidation;
}
@@ -328,7 +328,7 @@ public class Field implements Cloneable, Serializable {
* @since Validator 1.1
* @param arg Validation message's argument.
*/
- public void addArg(Arg arg) {
+ public void addArg(final Arg arg) {
// TODO this first if check can go away after arg0, etc. are removed from dtd
if (arg == null || arg.getKey() == null || arg.getKey().isEmpty()) {
return;
@@ -354,9 +354,9 @@ public class Field implements Cloneable, Serializable {
/**
* Calculate the position of the Arg
*/
- private void determineArgPosition(Arg arg) {
+ private void determineArgPosition(final Arg arg) {
- int position = arg.getPosition();
+ final int position = arg.getPosition();
// position has been explicity set
if (position >= 0) {
@@ -371,7 +371,7 @@ public class Field implements Cloneable, Serializable {
// determine the position of the last argument with
// the same name or the last default argument
- String keyName = arg.getName() == null ? DEFAULT_ARG : arg.getName();
+ final String keyName = arg.getName() == null ? DEFAULT_ARG : arg.getName();
int lastPosition = -1;
int lastDefault = -1;
for (int i = 0; i < args.length; i++) {
@@ -398,9 +398,10 @@ public class Field implements Cloneable, Serializable {
* @param arg Determine if the args array is long enough to store this arg's
* position.
*/
- private void ensureArgsCapacity(Arg arg) {
+ private void ensureArgsCapacity(final Arg arg) {
if (arg.getPosition() >= this.args.length) {
@SuppressWarnings("unchecked") // cannot check this at compile time, but it is OK
+ final
Map<String, Arg>[] newArgs = new Map[arg.getPosition() + 1];
System.arraycopy(this.args, 0, newArgs, 0, this.args.length);
this.args = newArgs;
@@ -413,7 +414,7 @@ public class Field implements Cloneable, Serializable {
* @return The default Arg or null if not found.
* @since Validator 1.1
*/
- public Arg getArg(int position) {
+ public Arg getArg(final int position) {
return this.getArg(DEFAULT_ARG, position);
}
@@ -427,12 +428,12 @@ public class Field implements Cloneable, Serializable {
* @return The Arg with the given name and position or null if not found.
* @since Validator 1.1
*/
- public Arg getArg(String key, int position) {
+ public Arg getArg(final String key, final int position) {
if ((position >= this.args.length) || (this.args[position] == null)) {
return null;
}
- Arg arg = args[position].get(key);
+ final Arg arg = args[position].get(key);
// Didn't find default arg so exit, otherwise we would get into
// infinite recursion
@@ -450,8 +451,8 @@ public class Field implements Cloneable, Serializable {
* has a position of 0).
* @since Validator 1.1.1
*/
- public Arg[] getArgs(String key){
- Arg[] argList = new Arg[this.args.length];
+ public Arg[] getArgs(final String key){
+ final Arg[] argList = new Arg[this.args.length];
for (int i = 0; i < this.args.length; i++) {
argList[i] = this.getArg(key, i);
@@ -464,7 +465,7 @@ public class Field implements Cloneable, Serializable {
* Add a <code>Var</code> to the <code>Field</code>.
* @param v The Validator Argument.
*/
- public void addVar(Var v) {
+ public void addVar(final Var v) {
this.getVarMap().put(v.getName(), v);
}
@@ -475,7 +476,7 @@ public class Field implements Cloneable, Serializable {
* @param value The Argument's value.
* @param jsType The Javascript type.
*/
- public void addVar(String name, String value, String jsType) {
+ public void addVar(final String name, final String value, final String jsType) {
this.addVar(new Var(name, value, jsType));
}
@@ -484,7 +485,7 @@ public class Field implements Cloneable, Serializable {
* @param mainKey The Variable's key
* @return the Variable
*/
- public Var getVar(String mainKey) {
+ public Var getVar(final String mainKey) {
return getVarMap().get(mainKey);
}
@@ -493,10 +494,10 @@ public class Field implements Cloneable, Serializable {
* @param mainKey The Variable's key
* @return the Variable's value
*/
- public String getVarValue(String mainKey) {
+ public String getVarValue(final String mainKey) {
String value = null;
- Var v = getVarMap().get(mainKey);
+ final Var v = getVarMap().get(mainKey);
if (v != null) {
value = v.getValue();
}
@@ -530,7 +531,7 @@ public class Field implements Cloneable, Serializable {
* the key temporarily to have a unique key for an indexed field.
* @param key a unique key for the field
*/
- public void setKey(String key) {
+ public void setKey(final String key) {
this.key = key;
}
@@ -559,17 +560,17 @@ public class Field implements Cloneable, Serializable {
* Replace constants with values in fields and process the depends field
* to create the dependency <code>Map</code>.
*/
- void process(Map<String, String> globalConstants, Map<String, String> constants) {
+ void process(final Map<String, String> globalConstants, final Map<String, String> constants) {
this.hMsgs.setFast(false);
this.hVars.setFast(true);
this.generateKey();
// Process FormSet Constants
- for (Entry<String, String> entry : constants.entrySet()) {
- String key1 = entry.getKey();
- String key2 = TOKEN_START + key1 + TOKEN_END;
- String replaceValue = entry.getValue();
+ for (final Entry<String, String> entry : constants.entrySet()) {
+ final String key1 = entry.getKey();
+ final String key2 = TOKEN_START + key1 + TOKEN_END;
+ final String replaceValue = entry.getValue();
property = ValidatorUtils.replace(property, key2, replaceValue);
@@ -579,10 +580,10 @@ public class Field implements Cloneable, Serializable {
}
// Process Global Constants
- for (Entry<String, String> entry : globalConstants.entrySet()) {
- String key1 = entry.getKey();
- String key2 = TOKEN_START + key1 + TOKEN_END;
- String replaceValue = entry.getValue();
+ for (final Entry<String, String> entry : globalConstants.entrySet()) {
+ final String key1 = entry.getKey();
+ final String key2 = TOKEN_START + key1 + TOKEN_END;
+ final String replaceValue = entry.getValue();
property = ValidatorUtils.replace(property, key2, replaceValue);
@@ -592,10 +593,10 @@ public class Field implements Cloneable, Serializable {
}
// Process Var Constant Replacement
- for (String key1 : getVarMap().keySet()) {
- String key2 = TOKEN_START + TOKEN_VAR + key1 + TOKEN_END;
- Var var = this.getVar(key1);
- String replaceValue = var.getValue();
+ for (final String key1 : getVarMap().keySet()) {
+ final String key2 = TOKEN_START + TOKEN_VAR + key1 + TOKEN_END;
+ final Var var = this.getVar(key1);
+ final String replaceValue = var.getValue();
this.processMessageComponents(key2, replaceValue);
}
@@ -606,11 +607,11 @@ public class Field implements Cloneable, Serializable {
/**
* Replace the vars value with the key/value pairs passed in.
*/
- private void processVars(String key, String replaceValue) {
- Iterator<String> i = getVarMap().keySet().iterator();
+ private void processVars(final String key, final String replaceValue) {
+ final Iterator<String> i = getVarMap().keySet().iterator();
while (i.hasNext()) {
- String varKey = i.next();
- Var var = this.getVar(varKey);
+ final String varKey = i.next();
+ final Var var = this.getVar(varKey);
var.setValue(ValidatorUtils.replace(var.getValue(), key, replaceValue));
}
@@ -620,11 +621,11 @@ public class Field implements Cloneable, Serializable {
/**
* Replace the args key value with the key/value pairs passed in.
*/
- private void processMessageComponents(String key, String replaceValue) {
- String varKey = TOKEN_START + TOKEN_VAR;
+ private void processMessageComponents(final String key, final String replaceValue) {
+ final String varKey = TOKEN_START + TOKEN_VAR;
// Process Messages
if (key != null && !key.startsWith(varKey)) {
- for (Msg msg : getMsgMap().values()) {
+ for (final Msg msg : getMsgMap().values()) {
msg.setKey(ValidatorUtils.replace(msg.getKey(), key, replaceValue));
}
}
@@ -636,16 +637,16 @@ public class Field implements Cloneable, Serializable {
* Replace the arg <code>Collection</code> key value with the key/value
* pairs passed in.
*/
- private void processArg(String key, String replaceValue) {
- for (Map<String, Arg> argMap : this.args) {
+ private void processArg(final String key, final String replaceValue) {
+ for (final Map<String, Arg> argMap : this.args) {
if (argMap == null) {
continue;
}
- Iterator<Arg> iter = argMap.values().iterator();
+ final Iterator<Arg> iter = argMap.values().iterator();
while (iter.hasNext()) {
- Arg arg = iter.next();
+ final Arg arg = iter.next();
if (arg != null) {
arg.setKey(
@@ -660,7 +661,7 @@ public class Field implements Cloneable, Serializable {
* @param validatorName Name of the validator to check.
* @return Whether the field is dependant on a validator.
*/
- public boolean isDependency(String validatorName) {
+ public boolean isDependency(final String validatorName) {
return this.dependencyList.contains(validatorName);
}
@@ -682,7 +683,7 @@ public class Field implements Cloneable, Serializable {
Field field = null;
try {
field = (Field) super.clone();
- } catch(CloneNotSupportedException e) {
+ } catch(final CloneNotSupportedException e) {
throw new RuntimeException(e.toString());
}
@@ -694,12 +695,12 @@ public class Field implements Cloneable, Serializable {
continue;
}
- Map<String, Arg> argMap = new HashMap<>(this.args[i]);
- Iterator<Entry<String, Arg>> iter = argMap.entrySet().iterator();
+ final Map<String, Arg> argMap = new HashMap<>(this.args[i]);
+ final Iterator<Entry<String, Arg>> iter = argMap.entrySet().iterator();
while (iter.hasNext()) {
- Entry<String, Arg> entry = iter.next();
- String validatorName = entry.getKey();
- Arg arg = entry.getValue();
+ final Entry<String, Arg> entry = iter.next();
+ final String validatorName = entry.getKey();
+ final Arg arg = entry.getValue();
argMap.put(validatorName, (Arg) arg.clone());
}
field.args[i] = argMap;
@@ -717,7 +718,7 @@ public class Field implements Cloneable, Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
results.append("\t\tkey = " + key + "\n");
results.append("\t\tproperty = " + property + "\n");
@@ -729,7 +730,7 @@ public class Field implements Cloneable, Serializable {
if (hVars != null) {
results.append("\t\tVars:\n");
- for (Object key1 : getVarMap().keySet()) {
+ for (final Object key1 : getVarMap().keySet()) {
results.append("\t\t\t");
results.append(key1);
results.append("=");
@@ -748,7 +749,7 @@ public class Field implements Cloneable, Serializable {
* @throws ValidatorException If there's an error looking up the property
* or, the property found is not indexed.
*/
- Object[] getIndexedProperty(Object bean) throws ValidatorException {
+ Object[] getIndexedProperty(final Object bean) throws ValidatorException {
Object indexProp = null;
try {
@@ -777,7 +778,7 @@ public class Field implements Cloneable, Serializable {
* @throws ValidatorException If there's an error looking up the property
* or, the property found is not indexed.
*/
- private int getIndexedPropertySize(Object bean) throws ValidatorException {
+ private int getIndexedPropertySize(final Object bean) throws ValidatorException {
Object indexProp = null;
try {
@@ -807,14 +808,14 @@ public class Field implements Cloneable, Serializable {
* @return true if the validation succeeded.
*/
private boolean validateForRule(
- ValidatorAction va,
- ValidatorResults results,
- Map<String, ValidatorAction> actions,
- Map<String, Object> params,
- int pos)
+ final ValidatorAction va,
+ final ValidatorResults results,
+ final Map<String, ValidatorAction> actions,
+ final Map<String, Object> params,
+ final int pos)
throws ValidatorException {
- ValidatorResult result = results.getValidatorResult(this.getKey());
+ final ValidatorResult result = results.getValidatorResult(this.getKey());
if (result != null && result.containsAction(va.getName())) {
return result.isValid(va.getName());
}
@@ -837,24 +838,24 @@ public class Field implements Cloneable, Serializable {
* @throws ValidatorException If there's an error running a validator
*/
private boolean runDependentValidators(
- ValidatorAction va,
- ValidatorResults results,
- Map<String, ValidatorAction> actions,
- Map<String, Object> params,
- int pos)
+ final ValidatorAction va,
+ final ValidatorResults results,
+ final Map<String, ValidatorAction> actions,
+ final Map<String, Object> params,
+ final int pos)
throws ValidatorException {
- List<String> dependentValidators = va.getDependencyList();
+ final List<String> dependentValidators = va.getDependencyList();
if (dependentValidators.isEmpty()) {
return true;
}
- Iterator<String> iter = dependentValidators.iterator();
+ final Iterator<String> iter = dependentValidators.iterator();
while (iter.hasNext()) {
- String depend = iter.next();
+ final String depend = iter.next();
- ValidatorAction action = actions.get(depend);
+ final ValidatorAction action = actions.get(depend);
if (action == null) {
this.handleMissingAction(depend);
}
@@ -878,33 +879,33 @@ public class Field implements Cloneable, Serializable {
* this field.
* @throws ValidatorException If an error occurs during validation.
*/
- public ValidatorResults validate(Map<String, Object> params, Map<String, ValidatorAction> actions)
+ public ValidatorResults validate(final Map<String, Object> params, final Map<String, ValidatorAction> actions)
throws ValidatorException {
if (this.getDepends() == null) {
return new ValidatorResults();
}
- ValidatorResults allResults = new ValidatorResults();
+ final ValidatorResults allResults = new ValidatorResults();
- Object bean = params.get(Validator.BEAN_PARAM);
- int numberOfFieldsToValidate =
+ final Object bean = params.get(Validator.BEAN_PARAM);
+ final int numberOfFieldsToValidate =
this.isIndexed() ? this.getIndexedPropertySize(bean) : 1;
for (int fieldNumber = 0; fieldNumber < numberOfFieldsToValidate; fieldNumber++) {
- ValidatorResults results = new ValidatorResults();
+ final ValidatorResults results = new ValidatorResults();
synchronized(dependencyList) {
- Iterator<String> dependencies = this.dependencyList.iterator();
+ final Iterator<String> dependencies = this.dependencyList.iterator();
while (dependencies.hasNext()) {
- String depend = dependencies.next();
+ final String depend = dependencies.next();
- ValidatorAction action = actions.get(depend);
+ final ValidatorAction action = actions.get(depend);
if (action == null) {
this.handleMissingAction(depend);
}
- boolean good =
+ final boolean good =
validateForRule(action, results, actions, params, fieldNumber);
if (!good) {
@@ -925,7 +926,7 @@ public class Field implements Cloneable, Serializable {
* @param name The name of the validator in the depends list.
* @throws ValidatorException
*/
- private void handleMissingAction(String name) throws ValidatorException {
+ private void handleMissingAction(final String name) throws ValidatorException {
throw new ValidatorException("No ValidatorAction named " + name
+ " found for field " + this.getProperty());
}
diff --git a/src/main/java/org/apache/commons/validator/Form.java b/src/main/java/org/apache/commons/validator/Form.java
index e522f98b..6de70925 100644
--- a/src/main/java/org/apache/commons/validator/Form.java
+++ b/src/main/java/org/apache/commons/validator/Form.java
@@ -87,7 +87,7 @@ public class Form implements Serializable {
*
* @param name The new name value
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -96,7 +96,7 @@ public class Form implements Serializable {
*
* @param f The field
*/
- public void addField(Field f) {
+ public void addField(final Field f) {
this.lFields.add(f);
getFieldMap().put(f.getKey(), f);
}
@@ -119,7 +119,7 @@ public class Form implements Serializable {
* @return The field value
* @since Validator 1.1
*/
- public Field getField(String fieldName) {
+ public Field getField(final String fieldName) {
return getFieldMap().get(fieldName);
}
@@ -130,7 +130,7 @@ public class Form implements Serializable {
* @return True if this form contains the field by the given name
* @since Validator 1.1
*/
- public boolean containsField(String fieldName) {
+ public boolean containsField(final String fieldName) {
return getFieldMap().containsKey(fieldName);
}
@@ -142,22 +142,23 @@ public class Form implements Serializable {
* @param depends the form we want to merge
* @since Validator 1.2.0
*/
- protected void merge(Form depends) {
+ protected void merge(final Form depends) {
- List<Field> templFields = new ArrayList<>();
+ final List<Field> templFields = new ArrayList<>();
@SuppressWarnings("unchecked") // FastHashMap is not generic
+ final
Map<String, Field> temphFields = new FastHashMap();
- Iterator<Field> dependsIt = depends.getFields().iterator();
+ final Iterator<Field> dependsIt = depends.getFields().iterator();
while (dependsIt.hasNext()) {
- Field defaultField = dependsIt.next();
+ final Field defaultField = dependsIt.next();
if (defaultField != null) {
- String fieldKey = defaultField.getKey();
+ final String fieldKey = defaultField.getKey();
if (!this.containsField(fieldKey)) {
templFields.add(defaultField);
temphFields.put(fieldKey, defaultField);
}
else {
- Field old = getField(fieldKey);
+ final Field old = getField(fieldKey);
getFieldMap().remove(fieldKey);
lFields.remove(old);
templFields.add(old);
@@ -177,20 +178,20 @@ public class Form implements Serializable {
* @param forms Map of forms
* @since Validator 1.2.0
*/
- protected void process(Map<String, String> globalConstants, Map<String, String> constants, Map<String, Form> forms) {
+ protected void process(final Map<String, String> globalConstants, final Map<String, String> constants, final Map<String, Form> forms) {
if (isProcessed()) {
return;
}
int n = 0;//we want the fields from its parent first
if (isExtending()) {
- Form parent = forms.get(inherit);
+ final Form parent = forms.get(inherit);
if (parent != null) {
if (!parent.isProcessed()) {
//we want to go all the way up the tree
parent.process(constants, globalConstants, forms);
}
- for (Field f : parent.getFields()) {
+ for (final Field f : parent.getFields()) {
//we want to be able to override any fields we like
if (getFieldMap().get(f.getKey()) == null) {
lFields.add(n, f);
@@ -202,8 +203,8 @@ public class Form implements Serializable {
}
hFields.setFast(true);
//no need to reprocess parent's fields, we iterate from 'n'
- for (Iterator<Field> i = lFields.listIterator(n); i.hasNext(); ) {
- Field f = i.next();
+ for (final Iterator<Field> i = lFields.listIterator(n); i.hasNext(); ) {
+ final Field f = i.next();
f.process(globalConstants, constants);
}
@@ -217,13 +218,13 @@ public class Form implements Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
results.append("Form: ");
results.append(name);
results.append("\n");
- for (Field lField : lFields) {
+ for (final Field lField : lFields) {
results.append("\tField: \n");
results.append(lField);
results.append("\n");
@@ -245,7 +246,7 @@ public class Form implements Serializable {
* validation messages.
* @throws ValidatorException
*/
- ValidatorResults validate(Map<String, Object> params, Map<String, ValidatorAction> actions, int page)
+ ValidatorResults validate(final Map<String, Object> params, final Map<String, ValidatorAction> actions, final int page)
throws ValidatorException {
return validate(params, actions, page, null);
}
@@ -264,14 +265,14 @@ public class Form implements Serializable {
* @throws ValidatorException
* @since 1.2.0
*/
- ValidatorResults validate(Map<String, Object> params, Map<String, ValidatorAction> actions, int page, String fieldName)
+ ValidatorResults validate(final Map<String, Object> params, final Map<String, ValidatorAction> actions, final int page, final String fieldName)
throws ValidatorException {
- ValidatorResults results = new ValidatorResults();
+ final ValidatorResults results = new ValidatorResults();
params.put(Validator.VALIDATOR_RESULTS_PARAM, results);
// Only validate a single field if specified
if (fieldName != null) {
- Field field = getFieldMap().get(fieldName);
+ final Field field = getFieldMap().get(fieldName);
if (field == null) {
throw new ValidatorException("Unknown field "+fieldName+" in form "+getName());
@@ -282,9 +283,9 @@ public class Form implements Serializable {
results.merge(field.validate(params, actions));
}
} else {
- Iterator<Field> fields = this.lFields.iterator();
+ final Iterator<Field> fields = this.lFields.iterator();
while (fields.hasNext()) {
- Field field = fields.next();
+ final Field field = fields.next();
params.put(Validator.FIELD_PARAM, field);
@@ -324,7 +325,7 @@ public class Form implements Serializable {
* @param inherit The new extends value
* @since Validator 1.2.0
*/
- public void setExtends(String inherit) {
+ public void setExtends(final String inherit) {
this.inherit = inherit;
}
diff --git a/src/main/java/org/apache/commons/validator/FormSet.java b/src/main/java/org/apache/commons/validator/FormSet.java
index ba546645..71b7ff08 100644
--- a/src/main/java/org/apache/commons/validator/FormSet.java
+++ b/src/main/java/org/apache/commons/validator/FormSet.java
@@ -144,13 +144,13 @@ public class FormSet implements Serializable {
* @param depends FormSet to be merged
* @since Validator 1.2.0
*/
- protected void merge(FormSet depends) {
+ protected void merge(final FormSet depends) {
if (depends != null) {
- Map<String, Form> pForms = getForms();
- Map<String, Form> dForms = depends.getForms();
- for (Entry<String, Form> entry : dForms.entrySet()) {
- String key = entry.getKey();
- Form pForm = pForms.get(key);
+ final Map<String, Form> pForms = getForms();
+ final Map<String, Form> dForms = depends.getForms();
+ for (final Entry<String, Form> entry : dForms.entrySet()) {
+ final String key = entry.getKey();
+ final Form pForm = pForms.get(key);
if (pForm != null) {//merge, but principal 'rules', don't overwrite
// anything
pForm.merge(entry.getValue());
@@ -187,7 +187,7 @@ public class FormSet implements Serializable {
*
* @param language The new language value
*/
- public void setLanguage(String language) {
+ public void setLanguage(final String language) {
this.language = language;
}
@@ -205,7 +205,7 @@ public class FormSet implements Serializable {
*
* @param country The new country value
*/
- public void setCountry(String country) {
+ public void setCountry(final String country) {
this.country = country;
}
@@ -223,7 +223,7 @@ public class FormSet implements Serializable {
*
* @param variant The new variant value
*/
- public void setVariant(String variant) {
+ public void setVariant(final String variant) {
this.variant = variant;
}
@@ -233,7 +233,7 @@ public class FormSet implements Serializable {
* @param name The constant name
* @param value The constant value
*/
- public void addConstant(String name, String value) {
+ public void addConstant(final String name, final String value) {
if (constants.containsKey(name)) {
getLog().error("Constant '" + name + "' already exists in FormSet["
@@ -250,9 +250,9 @@ public class FormSet implements Serializable {
*
* @param f The form
*/
- public void addForm(Form f) {
+ public void addForm(final Form f) {
- String formName = f.getName();
+ final String formName = f.getName();
if (forms.containsKey(formName)) {
getLog().error("Form '" + formName + "' already exists in FormSet["
+ this.displayKey() + "] - ignoring.");
@@ -269,7 +269,7 @@ public class FormSet implements Serializable {
* @param formName The form name
* @return The form
*/
- public Form getForm(String formName) {
+ public Form getForm(final String formName) {
return this.forms.get(formName);
}
@@ -288,8 +288,8 @@ public class FormSet implements Serializable {
*
* @param globalConstants Global constants
*/
- synchronized void process(Map<String, String> globalConstants) {
- for (Form f : forms.values()) {
+ synchronized void process(final Map<String, String> globalConstants) {
+ for (final Form f : forms.values()) {
f.process(globalConstants, constants, forms);
}
@@ -302,7 +302,7 @@ public class FormSet implements Serializable {
* @return A string representation of the key
*/
public String displayKey() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
if (language != null && !language.isEmpty()) {
results.append("language=");
results.append(language);
@@ -335,7 +335,7 @@ public class FormSet implements Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
results.append("FormSet: language=");
results.append(language);
@@ -345,7 +345,7 @@ public class FormSet implements Serializable {
results.append(variant);
results.append("\n");
- for (Object name : getForms().values()) {
+ for (final Object name : getForms().values()) {
results.append(" ");
results.append(name);
results.append("\n");
diff --git a/src/main/java/org/apache/commons/validator/FormSetFactory.java b/src/main/java/org/apache/commons/validator/FormSetFactory.java
index 679ceeca..c9826523 100644
--- a/src/main/java/org/apache/commons/validator/FormSetFactory.java
+++ b/src/main/java/org/apache/commons/validator/FormSetFactory.java
@@ -41,13 +41,13 @@ public class FormSetFactory extends AbstractObjectCreationFactory {
* @throws Exception If an error occurs creating the FormSet.
*/
@Override
- public Object createObject(Attributes attributes) throws Exception {
+ public Object createObject(final Attributes attributes) throws Exception {
- ValidatorResources resources = (ValidatorResources)digester.peek(0);
+ final ValidatorResources resources = (ValidatorResources)digester.peek(0);
- String language = attributes.getValue("language");
- String country = attributes.getValue("country");
- String variant = attributes.getValue("variant");
+ final String language = attributes.getValue("language");
+ final String country = attributes.getValue("country");
+ final String variant = attributes.getValue("variant");
return createFormSet(resources, language, country, variant);
@@ -64,10 +64,10 @@ public class FormSetFactory extends AbstractObjectCreationFactory {
* @return The FormSet for a locale.
* @since Validator 1.2
*/
- private FormSet createFormSet(ValidatorResources resources,
- String language,
- String country,
- String variant) throws Exception {
+ private FormSet createFormSet(final ValidatorResources resources,
+ final String language,
+ final String country,
+ final String variant) throws Exception {
// Retrieve existing FormSet for the language/country/variant
FormSet formSet = resources.getFormSet(language, country, variant);
diff --git a/src/main/java/org/apache/commons/validator/GenericTypeValidator.java b/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
index b27b6c83..5020cfba 100644
--- a/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
+++ b/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
@@ -46,14 +46,14 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Byte value.
*/
- public static Byte formatByte(String value) {
+ public static Byte formatByte(final String value) {
if (value == null) {
return null;
}
try {
return Byte.valueOf(value);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -67,7 +67,7 @@ public class GenericTypeValidator implements Serializable {
* null)
* @return the converted Byte value.
*/
- public static Byte formatByte(String value, Locale locale) {
+ public static Byte formatByte(final String value, final Locale locale) {
Byte result = null;
if (value != null) {
@@ -78,8 +78,8 @@ public class GenericTypeValidator implements Serializable {
formatter = NumberFormat.getNumberInstance(Locale.getDefault());
}
formatter.setParseIntegerOnly(true);
- ParsePosition pos = new ParsePosition(0);
- Number num = formatter.parse(value, pos);
+ final ParsePosition pos = new ParsePosition(0);
+ final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
@@ -98,14 +98,14 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Short value.
*/
- public static Short formatShort(String value) {
+ public static Short formatShort(final String value) {
if (value == null) {
return null;
}
try {
return Short.valueOf(value);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -119,7 +119,7 @@ public class GenericTypeValidator implements Serializable {
* null)
* @return the converted Short value.
*/
- public static Short formatShort(String value, Locale locale) {
+ public static Short formatShort(final String value, final Locale locale) {
Short result = null;
if (value != null) {
@@ -130,8 +130,8 @@ public class GenericTypeValidator implements Serializable {
formatter = NumberFormat.getNumberInstance(Locale.getDefault());
}
formatter.setParseIntegerOnly(true);
- ParsePosition pos = new ParsePosition(0);
- Number num = formatter.parse(value, pos);
+ final ParsePosition pos = new ParsePosition(0);
+ final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
@@ -150,14 +150,14 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Integer value.
*/
- public static Integer formatInt(String value) {
+ public static Integer formatInt(final String value) {
if (value == null) {
return null;
}
try {
return Integer.valueOf(value);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -171,7 +171,7 @@ public class GenericTypeValidator implements Serializable {
* null)
* @return the converted Integer value.
*/
- public static Integer formatInt(String value, Locale locale) {
+ public static Integer formatInt(final String value, final Locale locale) {
Integer result = null;
if (value != null) {
@@ -182,8 +182,8 @@ public class GenericTypeValidator implements Serializable {
formatter = NumberFormat.getNumberInstance(Locale.getDefault());
}
formatter.setParseIntegerOnly(true);
- ParsePosition pos = new ParsePosition(0);
- Number num = formatter.parse(value, pos);
+ final ParsePosition pos = new ParsePosition(0);
+ final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
@@ -202,14 +202,14 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Long value.
*/
- public static Long formatLong(String value) {
+ public static Long formatLong(final String value) {
if (value == null) {
return null;
}
try {
return Long.valueOf(value);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -223,7 +223,7 @@ public class GenericTypeValidator implements Serializable {
* null)
* @return the converted Long value.
*/
- public static Long formatLong(String value, Locale locale) {
+ public static Long formatLong(final String value, final Locale locale) {
Long result = null;
if (value != null) {
@@ -234,8 +234,8 @@ public class GenericTypeValidator implements Serializable {
formatter = NumberFormat.getNumberInstance(Locale.getDefault());
}
formatter.setParseIntegerOnly(true);
- ParsePosition pos = new ParsePosition(0);
- Number num = formatter.parse(value, pos);
+ final ParsePosition pos = new ParsePosition(0);
+ final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
@@ -254,14 +254,14 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Float value.
*/
- public static Float formatFloat(String value) {
+ public static Float formatFloat(final String value) {
if (value == null) {
return null;
}
try {
return Float.valueOf(value);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -275,7 +275,7 @@ public class GenericTypeValidator implements Serializable {
* null)
* @return the converted Float value.
*/
- public static Float formatFloat(String value, Locale locale) {
+ public static Float formatFloat(final String value, final Locale locale) {
Float result = null;
if (value != null) {
@@ -285,8 +285,8 @@ public class GenericTypeValidator implements Serializable {
} else {
formatter = NumberFormat.getInstance(Locale.getDefault());
}
- ParsePosition pos = new ParsePosition(0);
- Number num = formatter.parse(value, pos);
+ final ParsePosition pos = new ParsePosition(0);
+ final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
@@ -305,14 +305,14 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Double value.
*/
- public static Double formatDouble(String value) {
+ public static Double formatDouble(final String value) {
if (value == null) {
return null;
}
try {
return Double.valueOf(value);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -326,7 +326,7 @@ public class GenericTypeValidator implements Serializable {
* null)
* @return the converted Double value.
*/
- public static Double formatDouble(String value, Locale locale) {
+ public static Double formatDouble(final String value, final Locale locale) {
Double result = null;
if (value != null) {
@@ -336,8 +336,8 @@ public class GenericTypeValidator implements Serializable {
} else {
formatter = NumberFormat.getInstance(Locale.getDefault());
}
- ParsePosition pos = new ParsePosition(0);
- Number num = formatter.parse(value, pos);
+ final ParsePosition pos = new ParsePosition(0);
+ final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
@@ -361,7 +361,7 @@ public class GenericTypeValidator implements Serializable {
* @param locale The Locale to use to parse the date (system default if null)
* @return the converted Date value.
*/
- public static Date formatDate(String value, Locale locale) {
+ public static Date formatDate(final String value, final Locale locale) {
Date date = null;
if (value == null) {
@@ -395,11 +395,11 @@ public class GenericTypeValidator implements Serializable {
// Firstly, try with the short form
try {
date = formatterShort.parse(value);
- } catch (ParseException e) {
+ } catch (final ParseException e) {
// Fall back on the default one
date = formatterDefault.parse(value);
}
- } catch (ParseException e) {
+ } catch (final ParseException e) {
// Bad date, so LOG and return null
if (LOG.isDebugEnabled()) {
LOG.debug("Date parse failed value=[" + value + "], " +
@@ -426,7 +426,7 @@ public class GenericTypeValidator implements Serializable {
* datePattern.
* @return the converted Date value.
*/
- public static Date formatDate(String value, String datePattern, boolean strict) {
+ public static Date formatDate(final String value, final String datePattern, final boolean strict) {
Date date = null;
if (value == null
@@ -436,7 +436,7 @@ public class GenericTypeValidator implements Serializable {
}
try {
- SimpleDateFormat formatter = new SimpleDateFormat(datePattern);
+ final SimpleDateFormat formatter = new SimpleDateFormat(datePattern);
formatter.setLenient(false);
date = formatter.parse(value);
@@ -444,7 +444,7 @@ public class GenericTypeValidator implements Serializable {
if (strict && datePattern.length() != value.length()) {
date = null;
}
- } catch (ParseException e) {
+ } catch (final ParseException e) {
// Bad date so return null
if (LOG.isDebugEnabled()) {
LOG.debug("Date parse failed value=[" + value + "], " +
@@ -465,7 +465,7 @@ public class GenericTypeValidator implements Serializable {
* @param value The value validation is being performed on.
* @return the converted Credit Card number.
*/
- public static Long formatCreditCard(String value) {
+ public static Long formatCreditCard(final String value) {
return GenericValidator.isCreditCard(value) ? Long.valueOf(value) : null;
}
diff --git a/src/main/java/org/apache/commons/validator/GenericValidator.java b/src/main/java/org/apache/commons/validator/GenericValidator.java
index a2baef2f..788bebd6 100644
--- a/src/main/java/org/apache/commons/validator/GenericValidator.java
+++ b/src/main/java/org/apache/commons/validator/GenericValidator.java
@@ -52,7 +52,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if blank or null.
*/
- public static boolean isBlankOrNull(String value) {
+ public static boolean isBlankOrNull(final String value) {
return value == null || value.trim().isEmpty();
}
@@ -63,7 +63,7 @@ public class GenericValidator implements Serializable {
* @param regexp The regular expression.
* @return true if matches the regular expression.
*/
- public static boolean matchRegexp(String value, String regexp) {
+ public static boolean matchRegexp(final String value, final String regexp) {
if (regexp == null || regexp.isEmpty()) {
return false;
}
@@ -77,7 +77,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value can be converted to a Byte.
*/
- public static boolean isByte(String value) {
+ public static boolean isByte(final String value) {
return (GenericTypeValidator.formatByte(value) != null);
}
@@ -87,7 +87,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value can be converted to a Short.
*/
- public static boolean isShort(String value) {
+ public static boolean isShort(final String value) {
return (GenericTypeValidator.formatShort(value) != null);
}
@@ -97,7 +97,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value can be converted to an Integer.
*/
- public static boolean isInt(String value) {
+ public static boolean isInt(final String value) {
return (GenericTypeValidator.formatInt(value) != null);
}
@@ -107,7 +107,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value can be converted to a Long.
*/
- public static boolean isLong(String value) {
+ public static boolean isLong(final String value) {
return (GenericTypeValidator.formatLong(value) != null);
}
@@ -117,7 +117,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value can be converted to a Float.
*/
- public static boolean isFloat(String value) {
+ public static boolean isFloat(final String value) {
return (GenericTypeValidator.formatFloat(value) != null);
}
@@ -127,7 +127,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value can be converted to a Double.
*/
- public static boolean isDouble(String value) {
+ public static boolean isDouble(final String value) {
return (GenericTypeValidator.formatDouble(value) != null);
}
@@ -141,7 +141,7 @@ public class GenericValidator implements Serializable {
* system default if null.
* @return true if the value can be converted to a Date.
*/
- public static boolean isDate(String value, Locale locale) {
+ public static boolean isDate(final String value, final Locale locale) {
return DateValidator.getInstance().isValid(value, locale);
}
@@ -157,7 +157,7 @@ public class GenericValidator implements Serializable {
* @param strict Whether or not to have an exact match of the datePattern.
* @return true if the value can be converted to a Date.
*/
- public static boolean isDate(String value, String datePattern, boolean strict) {
+ public static boolean isDate(final String value, final String datePattern, final boolean strict) {
// TODO method isValid() not yet supported in routines version
return org.apache.commons.validator.DateValidator.getInstance().isValid(value, datePattern, strict);
}
@@ -171,7 +171,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum value of the range.
* @return true if the value is in the specified range.
*/
- public static boolean isInRange(byte value, byte min, byte max) {
+ public static boolean isInRange(final byte value, final byte min, final byte max) {
return ((value >= min) && (value <= max));
}
@@ -184,7 +184,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum value of the range.
* @return true if the value is in the specified range.
*/
- public static boolean isInRange(int value, int min, int max) {
+ public static boolean isInRange(final int value, final int min, final int max) {
return ((value >= min) && (value <= max));
}
@@ -197,7 +197,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum value of the range.
* @return true if the value is in the specified range.
*/
- public static boolean isInRange(float value, float min, float max) {
+ public static boolean isInRange(final float value, final float min, final float max) {
return ((value >= min) && (value <= max));
}
@@ -210,7 +210,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum value of the range.
* @return true if the value is in the specified range.
*/
- public static boolean isInRange(short value, short min, short max) {
+ public static boolean isInRange(final short value, final short min, final short max) {
return ((value >= min) && (value <= max));
}
@@ -223,7 +223,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum value of the range.
* @return true if the value is in the specified range.
*/
- public static boolean isInRange(long value, long min, long max) {
+ public static boolean isInRange(final long value, final long min, final long max) {
return ((value >= min) && (value <= max));
}
@@ -236,7 +236,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum value of the range.
* @return true if the value is in the specified range.
*/
- public static boolean isInRange(double value, double min, double max) {
+ public static boolean isInRange(final double value, final double min, final double max) {
return ((value >= min) && (value <= max));
}
@@ -245,7 +245,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value is valid Credit Card Number.
*/
- public static boolean isCreditCard(String value) {
+ public static boolean isCreditCard(final String value) {
return CREDIT_CARD_VALIDATOR.isValid(value);
}
@@ -255,7 +255,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value is valid Email Address.
*/
- public static boolean isEmail(String value) {
+ public static boolean isEmail(final String value) {
return EmailValidator.getInstance().isValid(value);
}
@@ -267,7 +267,7 @@ public class GenericValidator implements Serializable {
* @param value The value validation is being performed on.
* @return true if the value is valid Url.
*/
- public static boolean isUrl(String value) {
+ public static boolean isUrl(final String value) {
return URL_VALIDATOR.isValid(value);
}
@@ -278,7 +278,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum length.
* @return true if the value's length is less than the specified maximum.
*/
- public static boolean maxLength(String value, int max) {
+ public static boolean maxLength(final String value, final int max) {
return (value.length() <= max);
}
@@ -290,8 +290,8 @@ public class GenericValidator implements Serializable {
* @param lineEndLength The length to use for line endings.
* @return true if the value's length is less than the specified maximum.
*/
- public static boolean maxLength(String value, int max, int lineEndLength) {
- int adjustAmount = adjustForLineEnding(value, lineEndLength);
+ public static boolean maxLength(final String value, final int max, final int lineEndLength) {
+ final int adjustAmount = adjustForLineEnding(value, lineEndLength);
return ((value.length() + adjustAmount) <= max);
}
@@ -302,7 +302,7 @@ public class GenericValidator implements Serializable {
* @param min The minimum length.
* @return true if the value's length is more than the specified minimum.
*/
- public static boolean minLength(String value, int min) {
+ public static boolean minLength(final String value, final int min) {
return (value.length() >= min);
}
@@ -314,8 +314,8 @@ public class GenericValidator implements Serializable {
* @param lineEndLength The length to use for line endings.
* @return true if the value's length is more than the specified minimum.
*/
- public static boolean minLength(String value, int min, int lineEndLength) {
- int adjustAmount = adjustForLineEnding(value, lineEndLength);
+ public static boolean minLength(final String value, final int min, final int lineEndLength) {
+ final int adjustAmount = adjustForLineEnding(value, lineEndLength);
return ((value.length() + adjustAmount) >= min);
}
@@ -328,7 +328,7 @@ public class GenericValidator implements Serializable {
* @param lineEndLength The length to use for line endings.
* @return the adjustment amount.
*/
- private static int adjustForLineEnding(String value, int lineEndLength) {
+ private static int adjustForLineEnding(final String value, final int lineEndLength) {
int nCount = 0;
int rCount = 0;
for (int i = 0; i < value.length(); i++) {
@@ -351,7 +351,7 @@ public class GenericValidator implements Serializable {
* @param min The minimum numeric value.
* @return true if the value is >= the specified minimum.
*/
- public static boolean minValue(int value, int min) {
+ public static boolean minValue(final int value, final int min) {
return (value >= min);
}
@@ -362,7 +362,7 @@ public class GenericValidator implements Serializable {
* @param min The minimum numeric value.
* @return true if the value is >= the specified minimum.
*/
- public static boolean minValue(long value, long min) {
+ public static boolean minValue(final long value, final long min) {
return (value >= min);
}
@@ -373,7 +373,7 @@ public class GenericValidator implements Serializable {
* @param min The minimum numeric value.
* @return true if the value is >= the specified minimum.
*/
- public static boolean minValue(double value, double min) {
+ public static boolean minValue(final double value, final double min) {
return (value >= min);
}
@@ -384,7 +384,7 @@ public class GenericValidator implements Serializable {
* @param min The minimum numeric value.
* @return true if the value is >= the specified minimum.
*/
- public static boolean minValue(float value, float min) {
+ public static boolean minValue(final float value, final float min) {
return (value >= min);
}
@@ -395,7 +395,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum numeric value.
* @return true if the value is <= the specified maximum.
*/
- public static boolean maxValue(int value, int max) {
+ public static boolean maxValue(final int value, final int max) {
return (value <= max);
}
@@ -406,7 +406,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum numeric value.
* @return true if the value is <= the specified maximum.
*/
- public static boolean maxValue(long value, long max) {
+ public static boolean maxValue(final long value, final long max) {
return (value <= max);
}
@@ -417,7 +417,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum numeric value.
* @return true if the value is <= the specified maximum.
*/
- public static boolean maxValue(double value, double max) {
+ public static boolean maxValue(final double value, final double max) {
return (value <= max);
}
@@ -428,7 +428,7 @@ public class GenericValidator implements Serializable {
* @param max The maximum numeric value.
* @return true if the value is <= the specified maximum.
*/
- public static boolean maxValue(float value, float max) {
+ public static boolean maxValue(final float value, final float max) {
return (value <= max);
}
diff --git a/src/main/java/org/apache/commons/validator/ISBNValidator.java b/src/main/java/org/apache/commons/validator/ISBNValidator.java
index 155c357a..3a8f20d2 100644
--- a/src/main/java/org/apache/commons/validator/ISBNValidator.java
+++ b/src/main/java/org/apache/commons/validator/ISBNValidator.java
@@ -48,7 +48,7 @@ public class ISBNValidator {
* considered invalid.
* @return true if the string is a valid ISBN code.
*/
- public boolean isValid(String isbn) {
+ public boolean isValid(final String isbn) {
return org.apache.commons.validator.routines.ISBNValidator.getInstance().isValidISBN10(isbn);
}
diff --git a/src/main/java/org/apache/commons/validator/Msg.java b/src/main/java/org/apache/commons/validator/Msg.java
index 31d12280..e37fb4e0 100644
--- a/src/main/java/org/apache/commons/validator/Msg.java
+++ b/src/main/java/org/apache/commons/validator/Msg.java
@@ -70,7 +70,7 @@ public class Msg implements Cloneable, Serializable {
* @param bundle The new bundle name.
* @since Validator 1.1
*/
- public void setBundle(String bundle) {
+ public void setBundle(final String bundle) {
this.bundle = bundle;
}
@@ -86,7 +86,7 @@ public class Msg implements Cloneable, Serializable {
* Sets the name of the dependency.
* @param name The dependency name.
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -102,7 +102,7 @@ public class Msg implements Cloneable, Serializable {
* Sets the key/value.
* @param key The message key/value.
*/
- public void setKey(String key) {
+ public void setKey(final String key) {
this.key = key;
}
@@ -120,7 +120,7 @@ public class Msg implements Cloneable, Serializable {
* @param resource If true indicates the key is a resource.
* @since Validator 1.1.4
*/
- public void setResource(boolean resource) {
+ public void setResource(final boolean resource) {
this.resource = resource;
}
@@ -133,7 +133,7 @@ public class Msg implements Cloneable, Serializable {
try {
return super.clone();
- } catch(CloneNotSupportedException e) {
+ } catch(final CloneNotSupportedException e) {
throw new RuntimeException(e.toString());
}
}
@@ -144,7 +144,7 @@ public class Msg implements Cloneable, Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
results.append("Msg: name=");
results.append(name);
diff --git a/src/main/java/org/apache/commons/validator/UrlValidator.java b/src/main/java/org/apache/commons/validator/UrlValidator.java
index f190667a..b9306dcd 100644
--- a/src/main/java/org/apache/commons/validator/UrlValidator.java
+++ b/src/main/java/org/apache/commons/validator/UrlValidator.java
@@ -198,7 +198,7 @@ public class UrlValidator implements Serializable {
* be specified. Setting the ALLOW_ALL_SCHEMES option will
* ignore the contents of schemes.
*/
- public UrlValidator(String[] schemes) {
+ public UrlValidator(final String[] schemes) {
this(schemes, 0);
}
@@ -208,7 +208,7 @@ public class UrlValidator implements Serializable {
* this class. To set multiple options you simply add them together. For example,
* ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.
*/
- public UrlValidator(int options) {
+ public UrlValidator(final int options) {
this(null, options);
}
@@ -219,7 +219,7 @@ public class UrlValidator implements Serializable {
* this class. To set multiple options you simply add them together. For example,
* ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.
*/
- public UrlValidator(String[] schemes, int options) {
+ public UrlValidator(String[] schemes, final int options) {
this.options = new Flags(options);
if (this.options.isOn(ALLOW_ALL_SCHEMES)) {
@@ -240,7 +240,7 @@ public class UrlValidator implements Serializable {
* value is considered invalid.
* @return true if the url is valid.
*/
- public boolean isValid(String value) {
+ public boolean isValid(final String value) {
if (value == null) {
return false;
}
@@ -249,7 +249,7 @@ public class UrlValidator implements Serializable {
}
// Check the whole url address structure
- Matcher urlMatcher = URL_PATTERN.matcher(value);
+ final Matcher urlMatcher = URL_PATTERN.matcher(value);
if (!urlMatcher.matches()) {
return false;
}
@@ -285,7 +285,7 @@ public class UrlValidator implements Serializable {
* invalid.
* @return true if valid.
*/
- protected boolean isValidScheme(String scheme) {
+ protected boolean isValidScheme(final String scheme) {
if (scheme == null) {
return false;
}
@@ -307,15 +307,15 @@ public class UrlValidator implements Serializable {
* @param authority Authority value to validate.
* @return true if authority (hostname and port) is valid.
*/
- protected boolean isValidAuthority(String authority) {
+ protected boolean isValidAuthority(final String authority) {
if (authority == null) {
return false;
}
- InetAddressValidator inetAddressValidator =
+ final InetAddressValidator inetAddressValidator =
InetAddressValidator.getInstance();
- Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authority);
+ final Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authority);
if (!authorityMatcher.matches()) {
return false;
}
@@ -323,7 +323,7 @@ public class UrlValidator implements Serializable {
boolean hostname = false;
// check if authority is IP address or hostname
String hostIP = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
- boolean ipV4Address = inetAddressValidator.isValid(hostIP);
+ final boolean ipV4Address = inetAddressValidator.isValid(hostIP);
if (!ipV4Address) {
// Domain is hostname name
@@ -334,20 +334,20 @@ public class UrlValidator implements Serializable {
if (hostname) {
// LOW-TECH FIX FOR VALIDATOR-202
// TODO: Rewrite to use ArrayList and .add semantics: see VALIDATOR-203
- char[] chars = hostIP.toCharArray();
+ final char[] chars = hostIP.toCharArray();
int size = 1;
- for (char element : chars) {
+ for (final char element : chars) {
if(element == '.') {
size++;
}
}
- String[] domainSegment = new String[size];
+ final String[] domainSegment = new String[size];
boolean match = true;
int segmentCount = 0;
int segmentLength = 0;
while (match) {
- Matcher atomMatcher = ATOM_PATTERN.matcher(hostIP);
+ final Matcher atomMatcher = ATOM_PATTERN.matcher(hostIP);
match = atomMatcher.matches();
if (match) {
domainSegment[segmentCount] = atomMatcher.group(1);
@@ -360,7 +360,7 @@ public class UrlValidator implements Serializable {
segmentCount++;
}
}
- String topLevel = domainSegment[segmentCount - 1];
+ final String topLevel = domainSegment[segmentCount - 1];
if (topLevel.length() < 2 || topLevel.length() > 4) { // CHECKSTYLE IGNORE MagicNumber (deprecated code)
return false;
}
@@ -380,12 +380,12 @@ public class UrlValidator implements Serializable {
return false;
}
- String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
+ final String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
if (port != null && !PORT_PATTERN.matcher(port).matches()) {
return false;
}
- String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
+ final String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
if (!GenericValidator.isBlankOrNull(extra)) {
return false;
}
@@ -398,7 +398,7 @@ public class UrlValidator implements Serializable {
* @param path Path value to validate.
* @return true if path is valid.
*/
- protected boolean isValidPath(String path) {
+ protected boolean isValidPath(final String path) {
if (path == null) {
return false;
}
@@ -407,13 +407,13 @@ public class UrlValidator implements Serializable {
return false;
}
- int slash2Count = countToken("//", path);
+ final int slash2Count = countToken("//", path);
if (options.isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) {
return false;
}
- int slashCount = countToken("/", path);
- int dot2Count = countToken("..", path);
+ final int slashCount = countToken("/", path);
+ final int dot2Count = countToken("..", path);
if (dot2Count > 0 && (slashCount - slash2Count - 1) <= dot2Count){
return false;
}
@@ -426,7 +426,7 @@ public class UrlValidator implements Serializable {
* @param query Query value to validate.
* @return true if query is valid.
*/
- protected boolean isValidQuery(String query) {
+ protected boolean isValidQuery(final String query) {
if (query == null) {
return true;
}
@@ -439,7 +439,7 @@ public class UrlValidator implements Serializable {
* @param fragment Fragment value to validate.
* @return true if fragment is valid.
*/
- protected boolean isValidFragment(String fragment) {
+ protected boolean isValidFragment(final String fragment) {
if (fragment == null) {
return true;
}
@@ -453,7 +453,7 @@ public class UrlValidator implements Serializable {
* @param target Target value to count tokens in.
* @return the number of tokens.
*/
- protected int countToken(String token, String target) {
+ protected int countToken(final String token, final String target) {
int tokenIndex = 0;
int count = 0;
while (tokenIndex != -1) {
diff --git a/src/main/java/org/apache/commons/validator/Validator.java b/src/main/java/org/apache/commons/validator/Validator.java
index f8c4f972..aca88a4a 100644
--- a/src/main/java/org/apache/commons/validator/Validator.java
+++ b/src/main/java/org/apache/commons/validator/Validator.java
@@ -143,7 +143,7 @@ public class Validator implements Serializable {
*
* @param resources <code>ValidatorResources</code> to use during validation.
*/
- public Validator(ValidatorResources resources) {
+ public Validator(final ValidatorResources resources) {
this(resources, null);
}
@@ -156,7 +156,7 @@ public class Validator implements Serializable {
* @param resources <code>ValidatorResources</code> to use during validation.
* @param formName Key used for retrieving the set of validation rules.
*/
- public Validator(ValidatorResources resources, String formName) {
+ public Validator(final ValidatorResources resources, final String formName) {
if (resources == null) {
throw new IllegalArgumentException("Resources cannot be null.");
}
@@ -176,7 +176,7 @@ public class Validator implements Serializable {
* @param fieldName Key used for retrieving the set of validation rules for a field
* @since 1.2.0
*/
- public Validator(ValidatorResources resources, String formName, String fieldName) {
+ public Validator(final ValidatorResources resources, final String formName, final String fieldName) {
if (resources == null) {
throw new IllegalArgumentException("Resources cannot be null.");
}
@@ -195,7 +195,7 @@ public class Validator implements Serializable {
* @param parameterValue The instance that will be passed into the
* validation method.
*/
- public void setParameter(String parameterClassName, Object parameterValue) {
+ public void setParameter(final String parameterClassName, final Object parameterValue) {
this.parameters.put(parameterClassName, parameterValue);
}
@@ -207,7 +207,7 @@ public class Validator implements Serializable {
* validation method that corresponds to the value/instance passed in with it.
* @return value of the specified parameter.
*/
- public Object getParameterValue(String parameterClassName) {
+ public Object getParameterValue(final String parameterClassName) {
return this.parameters.get(parameterClassName);
}
@@ -223,7 +223,7 @@ public class Validator implements Serializable {
* Sets the form name which is the key to a set of validation rules.
* @param formName the name of the form.
*/
- public void setFormName(String formName) {
+ public void setFormName(final String formName) {
this.formName = formName;
}
@@ -233,7 +233,7 @@ public class Validator implements Serializable {
* @param fieldName The name of the field in a form set
* @since 1.2.0
*/
- public void setFieldName(String fieldName) {
+ public void setFieldName(final String fieldName) {
this.fieldName = fieldName;
}
@@ -262,7 +262,7 @@ public class Validator implements Serializable {
*
* @param page the page number.
*/
- public void setPage(int page) {
+ public void setPage(final int page) {
this.page = page;
}
@@ -299,7 +299,7 @@ public class Validator implements Serializable {
*
* @param use determines whether to use Context ClassLoader.
*/
- public void setUseContextClassLoader(boolean use) {
+ public void setUseContextClassLoader(final boolean use) {
this.useContextClassLoader = use;
}
@@ -320,7 +320,7 @@ public class Validator implements Serializable {
}
if (this.useContextClassLoader) {
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
if (contextLoader != null) {
return contextLoader;
}
@@ -336,7 +336,7 @@ public class Validator implements Serializable {
* @param classLoader The new class loader to use, or <code>null</code>
* to revert to the standard rules
*/
- public void setClassLoader(ClassLoader classLoader) {
+ public void setClassLoader(final ClassLoader classLoader) {
this.classLoader = classLoader;
}
@@ -357,7 +357,7 @@ public class Validator implements Serializable {
this.setParameter(VALIDATOR_PARAM, this);
- Form form = this.resources.getForm(locale, this.formName);
+ final Form form = this.resources.getForm(locale, this.formName);
if (form != null) {
this.setParameter(FORM_PARAM, form);
return form.validate(
@@ -384,7 +384,7 @@ public class Validator implements Serializable {
* all fields.
* @param onlyReturnErrors whether only failed fields are returned.
*/
- public void setOnlyReturnErrors(boolean onlyReturnErrors) {
+ public void setOnlyReturnErrors(final boolean onlyReturnErrors) {
this.onlyReturnErrors = onlyReturnErrors;
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorAction.java b/src/main/java/org/apache/commons/validator/ValidatorAction.java
index f560be39..a56242b5 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorAction.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorAction.java
@@ -169,7 +169,7 @@ public class ValidatorAction implements Serializable {
* Sets the name of the validator action.
* @param name Validator Action name.
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -185,7 +185,7 @@ public class ValidatorAction implements Serializable {
* Sets the class of the validator action.
* @param classname Class name of the validator Action.
*/
- public void setClassname(String classname) {
+ public void setClassname(final String classname) {
this.classname = classname;
}
@@ -201,7 +201,7 @@ public class ValidatorAction implements Serializable {
* Sets the name of method being called for the validator action.
* @param method The method name.
*/
- public void setMethod(String method) {
+ public void setMethod(final String method) {
this.method = method;
}
@@ -217,14 +217,14 @@ public class ValidatorAction implements Serializable {
* Sets the method parameters for the method.
* @param methodParams A comma separated list of parameters.
*/
- public void setMethodParams(String methodParams) {
+ public void setMethodParams(final String methodParams) {
this.methodParams = methodParams;
this.methodParameterList.clear();
- StringTokenizer st = new StringTokenizer(methodParams, ",");
+ final StringTokenizer st = new StringTokenizer(methodParams, ",");
while (st.hasMoreTokens()) {
- String value = st.nextToken().trim();
+ final String value = st.nextToken().trim();
if (value != null && !value.isEmpty()) {
this.methodParameterList.add(value);
@@ -245,14 +245,14 @@ public class ValidatorAction implements Serializable {
* Sets the dependencies of the validator action.
* @param depends A comma separated list of validator names.
*/
- public void setDepends(String depends) {
+ public void setDepends(final String depends) {
this.depends = depends;
this.dependencyList.clear();
- StringTokenizer st = new StringTokenizer(depends, ",");
+ final StringTokenizer st = new StringTokenizer(depends, ",");
while (st.hasMoreTokens()) {
- String depend = st.nextToken().trim();
+ final String depend = st.nextToken().trim();
if (depend != null && !depend.isEmpty()) {
this.dependencyList.add(depend);
@@ -272,7 +272,7 @@ public class ValidatorAction implements Serializable {
* Sets the message associated with the validator action.
* @param msg The message for the validator action.
*/
- public void setMsg(String msg) {
+ public void setMsg(final String msg) {
this.msg = msg;
}
@@ -292,7 +292,7 @@ public class ValidatorAction implements Serializable {
* Javascript function/object.
* @param jsFunctionName The Javascript function name.
*/
- public void setJsFunctionName(String jsFunctionName) {
+ public void setJsFunctionName(final String jsFunctionName) {
this.jsFunctionName = jsFunctionName;
}
@@ -322,7 +322,7 @@ public class ValidatorAction implements Serializable {
* </pre>
* @param jsFunction The Javascript function's fully qualified class path.
*/
- public void setJsFunction(String jsFunction) {
+ public void setJsFunction(final String jsFunction) {
if (javascript != null) {
throw new IllegalStateException("Cannot call setJsFunction() after calling setJavascript()");
}
@@ -344,7 +344,7 @@ public class ValidatorAction implements Serializable {
* associated with this action.
* @param javascript The Javascript validation.
*/
- public void setJavascript(String javascript) {
+ public void setJavascript(final String javascript) {
if (jsFunction != null) {
throw new IllegalStateException("Cannot call setJavascript() after calling setJsFunction()");
}
@@ -384,7 +384,7 @@ public class ValidatorAction implements Serializable {
this.jsFunction = this.generateJsFunction();
}
- String javascriptFileName = this.formatJavascriptFileName();
+ final String javascriptFileName = this.formatJavascriptFileName();
if (getLog().isTraceEnabled()) {
getLog().trace(" Loading js function '" + javascriptFileName + "'");
@@ -403,7 +403,7 @@ public class ValidatorAction implements Serializable {
* @param javascriptFileName The file containing the javascript.
* @return The javascript function or null if it could not be loaded.
*/
- private String readJavascriptFile(String javascriptFileName) {
+ private String readJavascriptFile(final String javascriptFileName) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = this.getClass().getClassLoader();
@@ -419,26 +419,26 @@ public class ValidatorAction implements Serializable {
return null;
}
- StringBuilder buffer = new StringBuilder();
- BufferedReader reader = new BufferedReader(new InputStreamReader(is)); // TODO encoding
+ final StringBuilder buffer = new StringBuilder();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); // TODO encoding
try {
String line = null;
while ((line = reader.readLine()) != null) {
buffer.append(line).append("\n");
}
- } catch(IOException e) {
+ } catch(final IOException e) {
getLog().error("Error reading javascript file.", e);
} finally {
try {
reader.close();
- } catch(IOException e) {
+ } catch(final IOException e) {
getLog().error("Error closing stream to javascript file.", e);
}
}
- String function = buffer.toString();
+ final String function = buffer.toString();
return function.equals("") ? null : function;
}
@@ -467,7 +467,7 @@ public class ValidatorAction implements Serializable {
* Used to generate the javascript name when it is not specified.
*/
private String generateJsFunction() {
- StringBuilder jsName =
+ final StringBuilder jsName =
new StringBuilder("org.apache.commons.validator.javascript");
jsName.append(".validate");
@@ -482,7 +482,7 @@ public class ValidatorAction implements Serializable {
* @param validatorName Name of the dependency to check.
* @return Whether the named validator is a dependant.
*/
- public boolean isDependency(String validatorName) {
+ public boolean isDependency(final String validatorName) {
return this.dependencyList.contains(validatorName);
}
@@ -501,7 +501,7 @@ public class ValidatorAction implements Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder("ValidatorAction: ");
+ final StringBuilder results = new StringBuilder("ValidatorAction: ");
results.append(name);
results.append("\n");
@@ -518,12 +518,12 @@ public class ValidatorAction implements Serializable {
* @throws ValidatorException
*/
boolean executeValidationMethod(
- Field field,
+ final Field field,
// TODO What is this the correct value type?
// both ValidatorAction and Validator are added as parameters
- Map<String, Object> params,
- ValidatorResults results,
- int pos)
+ final Map<String, Object> params,
+ final ValidatorResults results,
+ final int pos)
throws ValidatorException {
params.put(Validator.VALIDATOR_ACTION_PARAM, this);
@@ -531,14 +531,14 @@ public class ValidatorAction implements Serializable {
try {
if (this.validationMethod == null) {
synchronized(this) {
- ClassLoader loader = this.getClassLoader(params);
+ final ClassLoader loader = this.getClassLoader(params);
this.loadValidationClass(loader);
this.loadParameterClasses(loader);
this.loadValidationMethod();
}
}
- Object[] paramValues = this.getParameterValues(params);
+ final Object[] paramValues = this.getParameterValues(params);
if (field.isIndexed()) {
this.handleIndexedField(field, pos, paramValues);
@@ -553,7 +553,7 @@ public class ValidatorAction implements Serializable {
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new ValidatorException(e.getMessage());
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
if (e.getTargetException() instanceof Exception) {
throw (Exception) e.getTargetException();
@@ -564,7 +564,7 @@ public class ValidatorAction implements Serializable {
}
}
- boolean valid = this.isValid(result);
+ final boolean valid = this.isValid(result);
if (!valid || (valid && !onlyReturnErrors(params))) {
results.add(field, this.name, valid, result);
}
@@ -575,7 +575,7 @@ public class ValidatorAction implements Serializable {
// TODO This catch block remains for backward compatibility. Remove
// this for Validator 2.0 when exception scheme changes.
- } catch (Exception e) {
+ } catch (final Exception e) {
if (e instanceof ValidatorException) {
throw (ValidatorException) e;
}
@@ -604,7 +604,7 @@ public class ValidatorAction implements Serializable {
this.validationMethod =
this.validationClass.getMethod(this.method, this.parameterClasses);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
throw new ValidatorException("No such validation method: " +
e.getMessage());
}
@@ -615,7 +615,7 @@ public class ValidatorAction implements Serializable {
* @param loader The ClassLoader used to load the Class object.
* @throws ValidatorException
*/
- private void loadValidationClass(ClassLoader loader)
+ private void loadValidationClass(final ClassLoader loader)
throws ValidatorException {
if (this.validationClass != null) {
@@ -624,7 +624,7 @@ public class ValidatorAction implements Serializable {
try {
this.validationClass = loader.loadClass(this.classname);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new ValidatorException(e.toString());
}
}
@@ -636,22 +636,22 @@ public class ValidatorAction implements Serializable {
* to the validation method.
* @throws ValidatorException if a class cannot be loaded.
*/
- private void loadParameterClasses(ClassLoader loader)
+ private void loadParameterClasses(final ClassLoader loader)
throws ValidatorException {
if (this.parameterClasses != null) {
return;
}
- Class<?>[] parameterClasses = new Class[this.methodParameterList.size()];
+ final Class<?>[] parameterClasses = new Class[this.methodParameterList.size()];
for (int i = 0; i < this.methodParameterList.size(); i++) {
- String paramClassName = this.methodParameterList.get(i);
+ final String paramClassName = this.methodParameterList.get(i);
try {
parameterClasses[i] = loader.loadClass(paramClassName);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new ValidatorException(e.getMessage());
}
}
@@ -667,12 +667,12 @@ public class ValidatorAction implements Serializable {
* array is in the same order as the given List and is suitable for passing
* to the validation method.
*/
- private Object[] getParameterValues(Map<String, ? super Object> params) {
+ private Object[] getParameterValues(final Map<String, ? super Object> params) {
- Object[] paramValue = new Object[this.methodParameterList.size()];
+ final Object[] paramValue = new Object[this.methodParameterList.size()];
for (int i = 0; i < this.methodParameterList.size(); i++) {
- String paramClassName = this.methodParameterList.get(i);
+ final String paramClassName = this.methodParameterList.get(i);
paramValue[i] = params.get(paramClassName);
}
@@ -691,7 +691,7 @@ public class ValidatorAction implements Serializable {
try {
this.instance = this.validationClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
- String msg1 =
+ final String msg1 =
"Couldn't create instance of "
+ this.classname
+ ". "
@@ -711,20 +711,20 @@ public class ValidatorAction implements Serializable {
* @param pos
* @param paramValues
*/
- private void handleIndexedField(Field field, int pos, Object[] paramValues)
+ private void handleIndexedField(final Field field, final int pos, final Object[] paramValues)
throws ValidatorException {
- int beanIndex = this.methodParameterList.indexOf(Validator.BEAN_PARAM);
- int fieldIndex = this.methodParameterList.indexOf(Validator.FIELD_PARAM);
+ final int beanIndex = this.methodParameterList.indexOf(Validator.BEAN_PARAM);
+ final int fieldIndex = this.methodParameterList.indexOf(Validator.FIELD_PARAM);
- Object indexedList[] = field.getIndexedProperty(paramValues[beanIndex]);
+ final Object indexedList[] = field.getIndexedProperty(paramValues[beanIndex]);
// Set current iteration object to the parameter array
paramValues[beanIndex] = indexedList[pos];
// Set field clone with the key modified to represent
// the current field
- Field indexedField = (Field) field.clone();
+ final Field indexedField = (Field) field.clone();
indexedField.setKey(
ValidatorUtils.replace(
indexedField.getKey(),
@@ -739,9 +739,9 @@ public class ValidatorAction implements Serializable {
* value. If not it will return <code>false</code> if the object is
* <code>null</code> and <code>true</code> if it isn't.
*/
- private boolean isValid(Object result) {
+ private boolean isValid(final Object result) {
if (result instanceof Boolean) {
- Boolean valid = (Boolean) result;
+ final Boolean valid = (Boolean) result;
return valid.booleanValue();
}
return result != null;
@@ -751,8 +751,8 @@ public class ValidatorAction implements Serializable {
* Returns the ClassLoader set in the Validator contained in the parameter
* Map.
*/
- private ClassLoader getClassLoader(Map<String, Object> params) {
- Validator v = (Validator) params.get(Validator.VALIDATOR_PARAM);
+ private ClassLoader getClassLoader(final Map<String, Object> params) {
+ final Validator v = (Validator) params.get(Validator.VALIDATOR_PARAM);
return v.getClassLoader();
}
@@ -760,8 +760,8 @@ public class ValidatorAction implements Serializable {
* Returns the onlyReturnErrors setting in the Validator contained in the
* parameter Map.
*/
- private boolean onlyReturnErrors(Map<String, Object> params) {
- Validator v = (Validator) params.get(Validator.VALIDATOR_PARAM);
+ private boolean onlyReturnErrors(final Map<String, Object> params) {
+ final Validator v = (Validator) params.get(Validator.VALIDATOR_PARAM);
return v.getOnlyReturnErrors();
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorException.java b/src/main/java/org/apache/commons/validator/ValidatorException.java
index 2328b844..73935c02 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorException.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorException.java
@@ -38,7 +38,7 @@ public class ValidatorException extends Exception {
*
* @param message The error message.
*/
- public ValidatorException(String message) {
+ public ValidatorException(final String message) {
super(message);
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorResources.java b/src/main/java/org/apache/commons/validator/ValidatorResources.java
index 06449f67..784a9ab4 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorResources.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorResources.java
@@ -134,7 +134,7 @@ public class ValidatorResources implements Serializable {
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.1
*/
- public ValidatorResources(InputStream in) throws IOException, SAXException {
+ public ValidatorResources(final InputStream in) throws IOException, SAXException {
this(new InputStream[]{in});
}
@@ -149,10 +149,10 @@ public class ValidatorResources implements Serializable {
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.1
*/
- public ValidatorResources(InputStream[] streams)
+ public ValidatorResources(final InputStream[] streams)
throws IOException, SAXException {
- Digester digester = initDigester();
+ final Digester digester = initDigester();
for (int i = 0; i < streams.length; i++) {
if (streams[i] == null) {
throw new IllegalArgumentException("Stream[" + i + "] is null");
@@ -173,7 +173,7 @@ public class ValidatorResources implements Serializable {
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.2
*/
- public ValidatorResources(String uri) throws IOException, SAXException {
+ public ValidatorResources(final String uri) throws IOException, SAXException {
this(new String[]{uri});
}
@@ -187,11 +187,11 @@ public class ValidatorResources implements Serializable {
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.2
*/
- public ValidatorResources(String[] uris)
+ public ValidatorResources(final String[] uris)
throws IOException, SAXException {
- Digester digester = initDigester();
- for (String element : uris) {
+ final Digester digester = initDigester();
+ for (final String element : uris) {
digester.push(this);
digester.parse(element);
}
@@ -209,7 +209,7 @@ public class ValidatorResources implements Serializable {
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.3.1
*/
- public ValidatorResources(URL url)
+ public ValidatorResources(final URL url)
throws IOException, SAXException {
this(new URL[]{url});
}
@@ -224,11 +224,11 @@ public class ValidatorResources implements Serializable {
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.3.1
*/
- public ValidatorResources(URL[] urls)
+ public ValidatorResources(final URL[] urls)
throws IOException, SAXException {
- Digester digester = initDigester();
- for (URL url : urls) {
+ final Digester digester = initDigester();
+ for (final URL url : urls) {
digester.push(this);
digester.parse(url);
}
@@ -248,7 +248,7 @@ public class ValidatorResources implements Serializable {
if (getLog().isDebugEnabled()) {
getLog().debug("Loading rules from '" + rulesUrl + "'");
}
- Digester digester = DigesterLoader.createDigester(rulesUrl);
+ final Digester digester = DigesterLoader.createDigester(rulesUrl);
digester.setNamespaceAware(true);
digester.setValidating(true);
digester.setUseContextClassLoader(true);
@@ -258,7 +258,7 @@ public class ValidatorResources implements Serializable {
// register DTDs
for (int i = 0; i < REGISTRATIONS.length; i += 2) {
- URL url = this.getClass().getResource(REGISTRATIONS[i + 1]);
+ final URL url = this.getClass().getResource(REGISTRATIONS[i + 1]);
if (url != null) {
digester.register(REGISTRATIONS[i], url.toString());
}
@@ -275,15 +275,15 @@ public class ValidatorResources implements Serializable {
* versions of the DTD prior to Validator 1.2.0 to continue
* working.
*/
- private void addOldArgRules(Digester digester) {
+ private void addOldArgRules(final Digester digester) {
// Create a new rule to process args elements
- Rule rule = new Rule() {
+ final Rule rule = new Rule() {
@Override
- public void begin(String namespace, String name,
- Attributes attributes) throws Exception {
+ public void begin(final String namespace, final String name,
+ final Attributes attributes) throws Exception {
// Create the Arg
- Arg arg = new Arg();
+ final Arg arg = new Arg();
arg.setKey(attributes.getValue("key"));
arg.setName(attributes.getValue("name"));
if ("false".equalsIgnoreCase(attributes.getValue("resource"))) {
@@ -292,7 +292,7 @@ public class ValidatorResources implements Serializable {
try {
final int length = "arg".length(); // skip the arg prefix
arg.setPosition(Integer.parseInt(name.substring(length)));
- } catch (Exception ex) {
+ } catch (final Exception ex) {
getLog().error("Error parsing Arg position: "
+ name + " " + arg + " " + ex);
}
@@ -317,8 +317,8 @@ public class ValidatorResources implements Serializable {
* @param fs The form set to add.
* @since Validator 1.1
*/
- public void addFormSet(FormSet fs) {
- String key = this.buildKey(fs);
+ public void addFormSet(final FormSet fs) {
+ final String key = this.buildKey(fs);
if (key.isEmpty()) {// there can only be one default formset
if (getLog().isWarnEnabled() && defaultFormSet != null) {
// warn the user he might not get the expected results
@@ -326,7 +326,7 @@ public class ValidatorResources implements Serializable {
}
defaultFormSet = fs;
} else {
- FormSet formset = getFormSets().get(key);
+ final FormSet formset = getFormSets().get(key);
if (formset == null) {// it hasn't been included yet
if (getLog().isDebugEnabled()) {
getLog().debug("Adding FormSet '" + fs.toString() + "'.");
@@ -346,7 +346,7 @@ public class ValidatorResources implements Serializable {
* @param name The constant name.
* @param value The constant value.
*/
- public void addConstant(String name, String value) {
+ public void addConstant(final String name, final String value) {
if (getLog().isDebugEnabled()) {
getLog().debug("Adding Global Constant: " + name + "," + value);
}
@@ -361,7 +361,7 @@ public class ValidatorResources implements Serializable {
* in the <code>ValidatorAction</code>.
* @param va The validator action.
*/
- public void addValidatorAction(ValidatorAction va) {
+ public void addValidatorAction(final ValidatorAction va) {
va.init();
getActions().put(va.getName(), va);
@@ -376,7 +376,7 @@ public class ValidatorResources implements Serializable {
* @param key The validator action key.
* @return The validator action.
*/
- public ValidatorAction getValidatorAction(String key) {
+ public ValidatorAction getValidatorAction(final String key) {
return getActions().get(key);
}
@@ -394,7 +394,7 @@ public class ValidatorResources implements Serializable {
* @param fs The Form Set.
* @return generated key for a formset.
*/
- protected String buildKey(FormSet fs) {
+ protected String buildKey(final FormSet fs) {
return
this.buildLocale(fs.getLanguage(), fs.getCountry(), fs.getVariant());
}
@@ -402,7 +402,7 @@ public class ValidatorResources implements Serializable {
/**
* Assembles a Locale code from the given parts.
*/
- private String buildLocale(String lang, String country, String variant) {
+ private String buildLocale(final String lang, final String country, final String variant) {
String key = ((lang != null && !lang.isEmpty()) ? lang : "");
key += ((country != null && !country.isEmpty()) ? "_" + country : "");
key += ((variant != null && !variant.isEmpty()) ? "_" + variant : "");
@@ -424,7 +424,7 @@ public class ValidatorResources implements Serializable {
* @return The validator Form.
* @since Validator 1.1
*/
- public Form getForm(Locale locale, String formKey) {
+ public Form getForm(final Locale locale, final String formKey) {
return this.getForm(locale.getLanguage(), locale.getCountry(), locale
.getVariant(), formKey);
}
@@ -446,27 +446,27 @@ public class ValidatorResources implements Serializable {
* @return The validator Form.
* @since Validator 1.1
*/
- public Form getForm(String language, String country, String variant,
- String formKey) {
+ public Form getForm(final String language, final String country, final String variant,
+ final String formKey) {
Form form = null;
// Try language/country/variant
String key = this.buildLocale(language, country, variant);
if (!key.isEmpty()) {
- FormSet formSet = getFormSets().get(key);
+ final FormSet formSet = getFormSets().get(key);
if (formSet != null) {
form = formSet.getForm(formKey);
}
}
- String localeKey = key;
+ final String localeKey = key;
// Try language/country
if (form == null) {
key = buildLocale(language, country, null);
if (!key.isEmpty()) {
- FormSet formSet = getFormSets().get(key);
+ final FormSet formSet = getFormSets().get(key);
if (formSet != null) {
form = formSet.getForm(formKey);
}
@@ -477,7 +477,7 @@ public class ValidatorResources implements Serializable {
if (form == null) {
key = buildLocale(language, null, null);
if (!key.isEmpty()) {
- FormSet formSet = getFormSets().get(key);
+ final FormSet formSet = getFormSets().get(key);
if (formSet != null) {
form = formSet.getForm(formKey);
}
@@ -532,13 +532,13 @@ public class ValidatorResources implements Serializable {
}
defaultFormSet.process(getConstants());
// Loop through FormSets and merge if necessary
- for (String key : getFormSets().keySet()) {
- FormSet fs = getFormSets().get(key);
+ for (final String key : getFormSets().keySet()) {
+ final FormSet fs = getFormSets().get(key);
fs.merge(getParent(fs));
}
// Process Fully Constructed FormSets
- for (FormSet fs : getFormSets().values()) {
+ for (final FormSet fs : getFormSets().values()) {
if (!fs.isProcessed()) {
fs.process(getConstants());
}
@@ -555,7 +555,7 @@ public class ValidatorResources implements Serializable {
* the formSet we want to get the parent from
* @return fs's parent
*/
- private FormSet getParent(FormSet fs) {
+ private FormSet getParent(final FormSet fs) {
FormSet parent = null;
if (fs.getType() == FormSet.LANGUAGE_FORMSET) {
@@ -589,9 +589,9 @@ public class ValidatorResources implements Serializable {
* @return The FormSet for a locale.
* @since Validator 1.2
*/
- FormSet getFormSet(String language, String country, String variant) {
+ FormSet getFormSet(final String language, final String country, final String variant) {
- String key = buildLocale(language, country, variant);
+ final String key = buildLocale(language, country, variant);
if (key.isEmpty()) {
return defaultFormSet;
diff --git a/src/main/java/org/apache/commons/validator/ValidatorResult.java b/src/main/java/org/apache/commons/validator/ValidatorResult.java
index 34c482f5..fed2e31f 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorResult.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorResult.java
@@ -50,7 +50,7 @@ public class ValidatorResult implements Serializable {
* validated.
* @param field Field that was validated.
*/
- public ValidatorResult(Field field) {
+ public ValidatorResult(final Field field) {
this.field = field;
}
@@ -59,7 +59,7 @@ public class ValidatorResult implements Serializable {
* @param validatorName Name of the validator.
* @param result Whether the validation passed or failed.
*/
- public void add(String validatorName, boolean result) {
+ public void add(final String validatorName, final boolean result) {
this.add(validatorName, result, null);
}
@@ -69,7 +69,7 @@ public class ValidatorResult implements Serializable {
* @param result Whether the validation passed or failed.
* @param value Value returned by the validator.
*/
- public void add(String validatorName, boolean result, Object value) {
+ public void add(final String validatorName, final boolean result, final Object value) {
hAction.put(validatorName, new ResultStatus(result, value));
}
@@ -78,7 +78,7 @@ public class ValidatorResult implements Serializable {
* @param validatorName Name of the validator.
* @return true if the validator is in the result.
*/
- public boolean containsAction(String validatorName) {
+ public boolean containsAction(final String validatorName) {
return hAction.containsKey(validatorName);
}
@@ -87,8 +87,8 @@ public class ValidatorResult implements Serializable {
* @param validatorName Name of the validator.
* @return true if the validation passed.
*/
- public boolean isValid(String validatorName) {
- ResultStatus status = hAction.get(validatorName);
+ public boolean isValid(final String validatorName) {
+ final ResultStatus status = hAction.get(validatorName);
return (status == null) ? false : status.isValid();
}
@@ -97,8 +97,8 @@ public class ValidatorResult implements Serializable {
* @param validatorName Name of the validator.
* @return The validation result.
*/
- public Object getResult(String validatorName) {
- ResultStatus status = hAction.get(validatorName);
+ public Object getResult(final String validatorName) {
+ final ResultStatus status = hAction.get(validatorName);
return (status == null) ? null : status.getResult();
}
@@ -146,7 +146,7 @@ public class ValidatorResult implements Serializable {
* @param valid Whether the validator passed or failed.
* @param result Value returned by the validator.
*/
- public ResultStatus(boolean valid, Object result) {
+ public ResultStatus(final boolean valid, final Object result) {
this.valid = valid;
this.result = result;
}
@@ -160,7 +160,7 @@ public class ValidatorResult implements Serializable {
* @deprecated Use {@code ResultStatus(boolean, Object)} instead
*/
@Deprecated
- public ResultStatus(ValidatorResult ignored, boolean valid, Object result) {
+ public ResultStatus(final ValidatorResult ignored, final boolean valid, final Object result) {
this(valid, result);
}
@@ -176,7 +176,7 @@ public class ValidatorResult implements Serializable {
* Sets whether or not the validation passed.
* @param valid Whether the validation passed.
*/
- public void setValid(boolean valid) {
+ public void setValid(final boolean valid) {
this.valid = valid;
}
@@ -196,7 +196,7 @@ public class ValidatorResult implements Serializable {
* typed value of a date validation for example.
* @param result The value returned by the validation.
*/
- public void setResult(Object result) {
+ public void setResult(final Object result) {
this.result = result;
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorResults.java b/src/main/java/org/apache/commons/validator/ValidatorResults.java
index f3054f31..bbb9763a 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorResults.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorResults.java
@@ -44,7 +44,7 @@ public class ValidatorResults implements Serializable {
*
* @param results ValidatorResults to merge.
*/
- public void merge(ValidatorResults results) {
+ public void merge(final ValidatorResults results) {
this.hResults.putAll(results.hResults);
}
@@ -55,7 +55,7 @@ public class ValidatorResults implements Serializable {
* @param validatorName The name of the validator.
* @param result The result of the validation.
*/
- public void add(Field field, String validatorName, boolean result) {
+ public void add(final Field field, final String validatorName, final boolean result) {
this.add(field, validatorName, result, null);
}
@@ -68,10 +68,10 @@ public class ValidatorResults implements Serializable {
* @param value The value returned by the validator.
*/
public void add(
- Field field,
- String validatorName,
- boolean result,
- Object value) {
+ final Field field,
+ final String validatorName,
+ final boolean result,
+ final Object value) {
ValidatorResult validatorResult = this.getValidatorResult(field.getKey());
@@ -110,7 +110,7 @@ public class ValidatorResults implements Serializable {
*
* @return The result of a specified key.
*/
- public ValidatorResult getValidatorResult(String key) {
+ public ValidatorResult getValidatorResult(final String key) {
return this.hResults.get(key);
}
@@ -130,14 +130,14 @@ public class ValidatorResults implements Serializable {
* @return Map of objections returned by validators.
*/
public Map<String, Object> getResultValueMap() {
- Map<String, Object> results = new HashMap<>();
+ final Map<String, Object> results = new HashMap<>();
- for (String propertyKey : hResults.keySet()) {
- ValidatorResult vr = this.getValidatorResult(propertyKey);
+ for (final String propertyKey : hResults.keySet()) {
+ final ValidatorResult vr = this.getValidatorResult(propertyKey);
- for (Iterator<String> x = vr.getActions(); x.hasNext();) {
- String actionKey = x.next();
- Object result = vr.getResult(actionKey);
+ for (final Iterator<String> x = vr.getActions(); x.hasNext();) {
+ final String actionKey = x.next();
+ final Object result = vr.getResult(actionKey);
if (result != null && !(result instanceof Boolean)) {
results.put(propertyKey, result);
diff --git a/src/main/java/org/apache/commons/validator/Var.java b/src/main/java/org/apache/commons/validator/Var.java
index 043076f5..fa9501cf 100644
--- a/src/main/java/org/apache/commons/validator/Var.java
+++ b/src/main/java/org/apache/commons/validator/Var.java
@@ -85,7 +85,7 @@ public class Var implements Cloneable, Serializable {
* @param value Variable value.
* @param jsType Variable Javascript type.
*/
- public Var(String name, String value, String jsType) {
+ public Var(final String name, final String value, final String jsType) {
this.name = name;
this.value = value;
this.jsType = jsType;
@@ -103,7 +103,7 @@ public class Var implements Cloneable, Serializable {
* Sets the name of the variable.
* @param name The name of the variable.
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -119,7 +119,7 @@ public class Var implements Cloneable, Serializable {
* Sets the value of the variable.
* @param value The value of the variable.
*/
- public void setValue(String value) {
+ public void setValue(final String value) {
this.value = value;
}
@@ -137,7 +137,7 @@ public class Var implements Cloneable, Serializable {
* @param resource If true indicates the value is a resource.
* @since Validator 1.2.0
*/
- public void setResource(boolean resource) {
+ public void setResource(final boolean resource) {
this.resource = resource;
}
@@ -155,7 +155,7 @@ public class Var implements Cloneable, Serializable {
* @param bundle The new bundle name.
* @since Validator 1.2.0
*/
- public void setBundle(String bundle) {
+ public void setBundle(final String bundle) {
this.bundle = bundle;
}
@@ -171,7 +171,7 @@ public class Var implements Cloneable, Serializable {
* Sets the JavaScript type of the variable.
* @param jsType The Javascript type of the variable.
*/
- public void setJsType(String jsType) {
+ public void setJsType(final String jsType) {
this.jsType = jsType;
}
@@ -184,7 +184,7 @@ public class Var implements Cloneable, Serializable {
try {
return super.clone();
- } catch(CloneNotSupportedException e) {
+ } catch(final CloneNotSupportedException e) {
throw new RuntimeException(e.toString());
}
}
@@ -195,7 +195,7 @@ public class Var implements Cloneable, Serializable {
*/
@Override
public String toString() {
- StringBuilder results = new StringBuilder();
+ final StringBuilder results = new StringBuilder();
results.append("Var: name=");
results.append(name);
diff --git a/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java b/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java
index 7567a64f..7d431d70 100644
--- a/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java
@@ -50,7 +50,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @param dateStyle the date style to use for Locale validation.
* @param timeStyle the time style to use for Locale validation.
*/
- public AbstractCalendarValidator(boolean strict, int dateStyle, int timeStyle) {
+ public AbstractCalendarValidator(final boolean strict, final int dateStyle, final int timeStyle) {
super(strict);
this.dateStyle = dateStyle;
this.timeStyle = timeStyle;
@@ -65,8 +65,8 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return <code>true</code> if the value is valid.
*/
@Override
- public boolean isValid(String value, String pattern, Locale locale) {
- Object parsedValue = parse(value, pattern, locale, (TimeZone)null);
+ public boolean isValid(final String value, final String pattern, final Locale locale) {
+ final Object parsedValue = parse(value, pattern, locale, (TimeZone)null);
return (parsedValue == null ? false : true);
}
@@ -79,7 +79,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* system default if null (unless value is a <code>Calendar</code>.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, TimeZone timeZone) {
+ public String format(final Object value, final TimeZone timeZone) {
return format(value, (String)null, (Locale)null, timeZone);
}
@@ -93,7 +93,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* system default if null (unless value is a <code>Calendar</code>.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, String pattern, TimeZone timeZone) {
+ public String format(final Object value, final String pattern, final TimeZone timeZone) {
return format(value, pattern, (Locale)null, timeZone);
}
@@ -107,7 +107,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* system default if null (unless value is a <code>Calendar</code>.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, Locale locale, TimeZone timeZone) {
+ public String format(final Object value, final Locale locale, final TimeZone timeZone) {
return format(value, (String)null, locale, timeZone);
}
@@ -121,7 +121,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return The value formatted as a <code>String</code>.
*/
@Override
- public String format(Object value, String pattern, Locale locale) {
+ public String format(final Object value, final String pattern, final Locale locale) {
return format(value, pattern, locale, (TimeZone)null);
}
@@ -136,8 +136,8 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* system default if null (unless value is a <code>Calendar</code>.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, String pattern, Locale locale, TimeZone timeZone) {
- DateFormat formatter = (DateFormat)getFormat(pattern, locale);
+ public String format(final Object value, final String pattern, final Locale locale, final TimeZone timeZone) {
+ final DateFormat formatter = (DateFormat)getFormat(pattern, locale);
if (timeZone != null) {
formatter.setTimeZone(timeZone);
} else if (value instanceof Calendar) {
@@ -154,7 +154,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return The formatted value.
*/
@Override
- protected String format(Object value, Format formatter) {
+ protected String format(Object value, final Format formatter) {
if (value == null) {
return null;
}
@@ -174,13 +174,13 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed value if valid or <code>null</code> if invalid.
*/
- protected Object parse(String value, String pattern, Locale locale, TimeZone timeZone) {
+ protected Object parse(String value, final String pattern, final Locale locale, final TimeZone timeZone) {
value = (value == null ? null : value.trim());
if (value == null || value.isEmpty()) {
return null;
}
- DateFormat formatter = (DateFormat)getFormat(pattern, locale);
+ final DateFormat formatter = (DateFormat)getFormat(pattern, locale);
if (timeZone != null) {
formatter.setTimeZone(timeZone);
}
@@ -210,15 +210,15 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return The <code>DateFormat</code> to created.
*/
@Override
- protected Format getFormat(String pattern, Locale locale) {
+ protected Format getFormat(final String pattern, final Locale locale) {
DateFormat formatter = null;
- boolean usePattern = pattern != null && !pattern.isEmpty();
+ final boolean usePattern = pattern != null && !pattern.isEmpty();
if (!usePattern) {
formatter = (DateFormat)getFormat(locale);
} else if (locale == null) {
formatter = new SimpleDateFormat(pattern);
} else {
- DateFormatSymbols symbols = new DateFormatSymbols(locale);
+ final DateFormatSymbols symbols = new DateFormatSymbols(locale);
formatter = new SimpleDateFormat(pattern, symbols);
}
formatter.setLenient(false);
@@ -232,7 +232,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* system default if null.
* @return The <code>DateFormat</code> to created.
*/
- protected Format getFormat(Locale locale) {
+ protected Format getFormat(final Locale locale) {
DateFormat formatter = null;
if (dateStyle >= 0 && timeStyle >= 0) {
@@ -248,7 +248,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
formatter = DateFormat.getTimeInstance(timeStyle, locale);
}
} else {
- int useDateStyle = dateStyle >= 0 ? dateStyle : DateFormat.SHORT;
+ final int useDateStyle = dateStyle >= 0 ? dateStyle : DateFormat.SHORT;
if (locale == null) {
formatter = DateFormat.getDateInstance(useDateStyle);
} else {
@@ -272,7 +272,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return Zero if the first value is equal to the second, -1
* if it is less than the second or +1 if it is greater than the second.
*/
- protected int compare(Calendar value, Calendar compare, int field) {
+ protected int compare(final Calendar value, final Calendar compare, final int field) {
int result;
@@ -328,7 +328,7 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return Zero if the first value is equal to the second, -1
* if it is less than the second or +1 if it is greater than the second.
*/
- protected int compareTime(Calendar value, Calendar compare, int field) {
+ protected int compareTime(final Calendar value, final Calendar compare, final int field) {
int result;
@@ -369,9 +369,9 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return Zero if the first quarter is equal to the second, -1
* if it is less than the second or +1 if it is greater than the second.
*/
- protected int compareQuarters(Calendar value, Calendar compare, int monthOfFirstQuarter) {
- int valueQuarter = calculateQuarter(value, monthOfFirstQuarter);
- int compareQuarter = calculateQuarter(compare, monthOfFirstQuarter);
+ protected int compareQuarters(final Calendar value, final Calendar compare, final int monthOfFirstQuarter) {
+ final int valueQuarter = calculateQuarter(value, monthOfFirstQuarter);
+ final int compareQuarter = calculateQuarter(compare, monthOfFirstQuarter);
if (valueQuarter < compareQuarter) {
return -1;
}
@@ -388,15 +388,15 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @param monthOfFirstQuarter The month that the first quarter starts.
* @return The calculated quarter.
*/
- private int calculateQuarter(Calendar calendar, int monthOfFirstQuarter) {
+ private int calculateQuarter(final Calendar calendar, final int monthOfFirstQuarter) {
// Add Year
int year = calendar.get(Calendar.YEAR);
- int month = (calendar.get(Calendar.MONTH) + 1);
- int relativeMonth = (month >= monthOfFirstQuarter)
+ final int month = (calendar.get(Calendar.MONTH) + 1);
+ final int relativeMonth = (month >= monthOfFirstQuarter)
? (month - monthOfFirstQuarter)
: (month + (12 - monthOfFirstQuarter)); // CHECKSTYLE IGNORE MagicNumber
- int quarter = ((relativeMonth / 3) + 1); // CHECKSTYLE IGNORE MagicNumber
+ final int quarter = ((relativeMonth / 3) + 1); // CHECKSTYLE IGNORE MagicNumber
// adjust the year if the quarter doesn't start in January
if (month < monthOfFirstQuarter) {
--year;
@@ -415,8 +415,8 @@ public abstract class AbstractCalendarValidator extends AbstractFormatValidator
* @return Zero if the first calendar's field is equal to the seconds, -1
* if it is less than the seconds or +1 if it is greater than the seconds.
*/
- private int calculateCompareResult(Calendar value, Calendar compare, int field) {
- int difference = value.get(field) - compare.get(field);
+ private int calculateCompareResult(final Calendar value, final Calendar compare, final int field) {
+ final int difference = value.get(field) - compare.get(field);
if (difference < 0) {
return -1;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/AbstractFormatValidator.java b/src/main/java/org/apache/commons/validator/routines/AbstractFormatValidator.java
index 1eff3ceb..88ec4c2a 100644
--- a/src/main/java/org/apache/commons/validator/routines/AbstractFormatValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/AbstractFormatValidator.java
@@ -42,7 +42,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param strict <code>true</code> if strict
* <code>Format</code> parsing should be used.
*/
- public AbstractFormatValidator(boolean strict) {
+ public AbstractFormatValidator(final boolean strict) {
this.strict = strict;
}
@@ -73,7 +73,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param value The value validation is being performed on.
* @return <code>true</code> if the value is valid.
*/
- public boolean isValid(String value) {
+ public boolean isValid(final String value) {
return isValid(value, (String)null, (Locale)null);
}
@@ -84,7 +84,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param pattern The pattern used to validate the value against.
* @return <code>true</code> if the value is valid.
*/
- public boolean isValid(String value, String pattern) {
+ public boolean isValid(final String value, final String pattern) {
return isValid(value, pattern, (Locale)null);
}
@@ -95,7 +95,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param locale The locale to use for the Format, defaults to the default
* @return <code>true</code> if the value is valid.
*/
- public boolean isValid(String value, Locale locale) {
+ public boolean isValid(final String value, final Locale locale) {
return isValid(value, (String)null, locale);
}
@@ -116,7 +116,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param value The value validation is being performed on.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value) {
+ public String format(final Object value) {
return format(value, (String)null, (Locale)null);
}
@@ -128,7 +128,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param pattern The pattern used to format the value.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, String pattern) {
+ public String format(final Object value, final String pattern) {
return format(value, pattern, (Locale)null);
}
@@ -140,7 +140,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param locale The locale to use for the Format.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, Locale locale) {
+ public String format(final Object value, final Locale locale) {
return format(value, (String)null, locale);
}
@@ -153,8 +153,8 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param locale The locale to use for the Format.
* @return The value formatted as a <code>String</code>.
*/
- public String format(Object value, String pattern, Locale locale) {
- Format formatter = getFormat(pattern, locale);
+ public String format(final Object value, final String pattern, final Locale locale) {
+ final Format formatter = getFormat(pattern, locale);
return format(value, formatter);
}
@@ -165,7 +165,7 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param formatter The Format to use.
* @return The formatted value.
*/
- protected String format(Object value, Format formatter) {
+ protected String format(final Object value, final Format formatter) {
return formatter.format(value);
}
@@ -176,9 +176,9 @@ public abstract class AbstractFormatValidator implements Serializable {
* @param formatter The Format to parse the value with.
* @return The parsed value if valid or <code>null</code> if invalid.
*/
- protected Object parse(String value, Format formatter) {
+ protected Object parse(final String value, final Format formatter) {
- ParsePosition pos = new ParsePosition(0);
+ final ParsePosition pos = new ParsePosition(0);
Object parsedValue = formatter.parseObject(value, pos);
if (pos.getErrorIndex() > -1) {
return null;
diff --git a/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java b/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
index 9d257e39..4a95ad5a 100644
--- a/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
@@ -58,7 +58,7 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @param allowFractions <code>true</code> if fractions are
* allowed or <code>false</code> if integers only.
*/
- public AbstractNumberValidator(boolean strict, int formatType, boolean allowFractions) {
+ public AbstractNumberValidator(final boolean strict, final int formatType, final boolean allowFractions) {
super(strict);
this.allowFractions = allowFractions;
this.formatType = formatType;
@@ -95,8 +95,8 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @return <code>true</code> if the value is valid.
*/
@Override
- public boolean isValid(String value, String pattern, Locale locale) {
- Object parsedValue = parse(value, pattern, locale);
+ public boolean isValid(final String value, final String pattern, final Locale locale) {
+ final Object parsedValue = parse(value, pattern, locale);
return (parsedValue == null ? false : true);
}
@@ -109,7 +109,7 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Number value, Number min, Number max) {
+ public boolean isInRange(final Number value, final Number min, final Number max) {
return (minValue(value, min) && maxValue(value, max));
}
@@ -121,7 +121,7 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Number value, Number min) {
+ public boolean minValue(final Number value, final Number min) {
if (isAllowFractions()) {
return (value.doubleValue() >= min.doubleValue());
}
@@ -136,7 +136,7 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Number value, Number max) {
+ public boolean maxValue(final Number value, final Number max) {
if (isAllowFractions()) {
return (value.doubleValue() <= max.doubleValue());
}
@@ -152,13 +152,13 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed value if valid or <code>null</code> if invalid.
*/
- protected Object parse(String value, String pattern, Locale locale) {
+ protected Object parse(String value, final String pattern, final Locale locale) {
value = (value == null ? null : value.trim());
if (value == null || value.isEmpty()) {
return null;
}
- Format formatter = getFormat(pattern, locale);
+ final Format formatter = getFormat(pattern, locale);
return parse(value, formatter);
}
@@ -185,16 +185,16 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* @return The <code>NumberFormat</code> to created.
*/
@Override
- protected Format getFormat(String pattern, Locale locale) {
+ protected Format getFormat(final String pattern, final Locale locale) {
NumberFormat formatter = null;
- boolean usePattern = pattern != null && !pattern.isEmpty();
+ final boolean usePattern = pattern != null && !pattern.isEmpty();
if (!usePattern) {
formatter = (NumberFormat)getFormat(locale);
} else if (locale == null) {
formatter = new DecimalFormat(pattern);
} else {
- DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
+ final DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
formatter = new DecimalFormat(pattern, symbols);
}
@@ -211,21 +211,21 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* multiplier of.
* @return The multiplying factor for the format..
*/
- protected int determineScale(NumberFormat format) {
+ protected int determineScale(final NumberFormat format) {
if (!isStrict()) {
return -1;
}
if (!isAllowFractions() || format.isParseIntegerOnly()) {
return 0;
}
- int minimumFraction = format.getMinimumFractionDigits();
- int maximumFraction = format.getMaximumFractionDigits();
+ final int minimumFraction = format.getMinimumFractionDigits();
+ final int maximumFraction = format.getMaximumFractionDigits();
if (minimumFraction != maximumFraction) {
return -1;
}
int scale = minimumFraction;
if (format instanceof DecimalFormat) {
- int multiplier = ((DecimalFormat)format).getMultiplier();
+ final int multiplier = ((DecimalFormat)format).getMultiplier();
if (multiplier == 100) { // CHECKSTYLE IGNORE MagicNumber
scale += 2; // CHECKSTYLE IGNORE MagicNumber
} else if (multiplier == 1000) { // CHECKSTYLE IGNORE MagicNumber
@@ -244,7 +244,7 @@ public abstract class AbstractNumberValidator extends AbstractFormatValidator {
* system default if null.
* @return The <code>NumberFormat</code> to created.
*/
- protected Format getFormat(Locale locale) {
+ protected Format getFormat(final Locale locale) {
NumberFormat formatter = null;
switch (formatType) {
case CURRENCY_FORMAT:
diff --git a/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java b/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
index d12eeb29..90c675f2 100644
--- a/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
@@ -93,7 +93,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @param strict <code>true</code> if strict
* <code>Format</code> parsing should be used.
*/
- public BigDecimalValidator(boolean strict) {
+ public BigDecimalValidator(final boolean strict) {
this(strict, STANDARD_FORMAT, true);
}
@@ -120,8 +120,8 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @param allowFractions <code>true</code> if fractions are
* allowed or <code>false</code> if integers only.
*/
- protected BigDecimalValidator(boolean strict, int formatType,
- boolean allowFractions) {
+ protected BigDecimalValidator(final boolean strict, final int formatType,
+ final boolean allowFractions) {
super(strict, formatType, allowFractions);
}
@@ -133,7 +133,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @return The parsed <code>BigDecimal</code> if valid or <code>null</code>
* if invalid.
*/
- public BigDecimal validate(String value) {
+ public BigDecimal validate(final String value) {
return (BigDecimal)parse(value, (String)null, (Locale)null);
}
@@ -146,7 +146,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* default for the <code>Locale</code> if <code>null</code>.
* @return The parsed <code>BigDecimal</code> if valid or <code>null</code> if invalid.
*/
- public BigDecimal validate(String value, String pattern) {
+ public BigDecimal validate(final String value, final String pattern) {
return (BigDecimal)parse(value, pattern, (Locale)null);
}
@@ -158,7 +158,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>BigDecimal</code> if valid or <code>null</code> if invalid.
*/
- public BigDecimal validate(String value, Locale locale) {
+ public BigDecimal validate(final String value, final Locale locale) {
return (BigDecimal)parse(value, (String)null, locale);
}
@@ -172,7 +172,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>BigDecimal</code> if valid or <code>null</code> if invalid.
*/
- public BigDecimal validate(String value, String pattern, Locale locale) {
+ public BigDecimal validate(final String value, final String pattern, final Locale locale) {
return (BigDecimal)parse(value, pattern, locale);
}
@@ -185,7 +185,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(BigDecimal value, double min, double max) {
+ public boolean isInRange(final BigDecimal value, final double min, final double max) {
return (value.doubleValue() >= min && value.doubleValue() <= max);
}
@@ -197,7 +197,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(BigDecimal value, double min) {
+ public boolean minValue(final BigDecimal value, final double min) {
return (value.doubleValue() >= min);
}
@@ -209,7 +209,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(BigDecimal value, double max) {
+ public boolean maxValue(final BigDecimal value, final double max) {
return (value.doubleValue() <= max);
}
@@ -222,7 +222,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
* <code>BigDecimal</code>.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
BigDecimal decimal = null;
if (value instanceof Long) {
decimal = BigDecimal.valueOf(((Long)value).longValue());
@@ -230,7 +230,7 @@ public class BigDecimalValidator extends AbstractNumberValidator {
decimal = new BigDecimal(value.toString());
}
- int scale = determineScale((NumberFormat)formatter);
+ final int scale = determineScale((NumberFormat)formatter);
if (scale >= 0) {
decimal = decimal.setScale(scale, BigDecimal.ROUND_DOWN);
}
diff --git a/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java b/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java
index 32cdd5b0..9a5cf9b9 100644
--- a/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java
@@ -105,7 +105,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public BigIntegerValidator(boolean strict, int formatType) {
+ public BigIntegerValidator(final boolean strict, final int formatType) {
super(strict, formatType, false);
}
@@ -117,7 +117,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @return The parsed <code>BigInteger</code> if valid or <code>null</code>
* if invalid.
*/
- public BigInteger validate(String value) {
+ public BigInteger validate(final String value) {
return (BigInteger)parse(value, (String)null, (Locale)null);
}
@@ -129,7 +129,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>BigInteger</code> if valid or <code>null</code> if invalid.
*/
- public BigInteger validate(String value, String pattern) {
+ public BigInteger validate(final String value, final String pattern) {
return (BigInteger)parse(value, pattern, (Locale)null);
}
@@ -141,7 +141,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>BigInteger</code> if valid or <code>null</code> if invalid.
*/
- public BigInteger validate(String value, Locale locale) {
+ public BigInteger validate(final String value, final Locale locale) {
return (BigInteger)parse(value, (String)null, locale);
}
@@ -155,7 +155,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>BigInteger</code> if valid or <code>null</code> if invalid.
*/
- public BigInteger validate(String value, String pattern, Locale locale) {
+ public BigInteger validate(final String value, final String pattern, final Locale locale) {
return (BigInteger)parse(value, pattern, locale);
}
@@ -168,7 +168,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(BigInteger value, long min, long max) {
+ public boolean isInRange(final BigInteger value, final long min, final long max) {
return (value.longValue() >= min && value.longValue() <= max);
}
@@ -180,7 +180,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(BigInteger value, long min) {
+ public boolean minValue(final BigInteger value, final long min) {
return (value.longValue() >= min);
}
@@ -192,7 +192,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(BigInteger value, long max) {
+ public boolean maxValue(final BigInteger value, final long max) {
return (value.longValue() <= max);
}
@@ -205,7 +205,7 @@ public class BigIntegerValidator extends AbstractNumberValidator {
* <code>BigInteger</code>.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
return BigInteger.valueOf(((Number)value).longValue());
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/ByteValidator.java b/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
index 46882608..e7923564 100644
--- a/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
@@ -104,7 +104,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public ByteValidator(boolean strict, int formatType) {
+ public ByteValidator(final boolean strict, final int formatType) {
super(strict, formatType, false);
}
@@ -116,7 +116,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return The parsed <code>Byte</code> if valid or <code>null</code>
* if invalid.
*/
- public Byte validate(String value) {
+ public Byte validate(final String value) {
return (Byte)parse(value, (String)null, (Locale)null);
}
@@ -128,7 +128,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Byte</code> if valid or <code>null</code> if invalid.
*/
- public Byte validate(String value, String pattern) {
+ public Byte validate(final String value, final String pattern) {
return (Byte)parse(value, pattern, (Locale)null);
}
@@ -140,7 +140,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>Byte</code> if valid or <code>null</code> if invalid.
*/
- public Byte validate(String value, Locale locale) {
+ public Byte validate(final String value, final Locale locale) {
return (Byte)parse(value, (String)null, locale);
}
@@ -154,7 +154,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Byte</code> if valid or <code>null</code> if invalid.
*/
- public Byte validate(String value, String pattern, Locale locale) {
+ public Byte validate(final String value, final String pattern, final Locale locale) {
return (Byte)parse(value, pattern, locale);
}
@@ -167,7 +167,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(byte value, byte min, byte max) {
+ public boolean isInRange(final byte value, final byte min, final byte max) {
return (value >= min && value <= max);
}
@@ -180,7 +180,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Byte value, byte min, byte max) {
+ public boolean isInRange(final Byte value, final byte min, final byte max) {
return isInRange(value.byteValue(), min, max);
}
@@ -192,7 +192,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(byte value, byte min) {
+ public boolean minValue(final byte value, final byte min) {
return (value >= min);
}
@@ -204,7 +204,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Byte value, byte min) {
+ public boolean minValue(final Byte value, final byte min) {
return minValue(value.byteValue(), min);
}
@@ -216,7 +216,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(byte value, byte max) {
+ public boolean maxValue(final byte value, final byte max) {
return (value <= max);
}
@@ -228,7 +228,7 @@ public class ByteValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Byte value, byte max) {
+ public boolean maxValue(final Byte value, final byte max) {
return maxValue(value.byteValue(), max);
}
@@ -242,11 +242,11 @@ public class ByteValidator extends AbstractNumberValidator {
* <code>Byte</code> if valid or <code>null</code> if invalid.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
// Parsed value will be Long if it fits in a long and is not fractional
if (value instanceof Long) {
- long longValue = ((Long)value).longValue();
+ final long longValue = ((Long)value).longValue();
if (longValue >= Byte.MIN_VALUE &&
longValue <= Byte.MAX_VALUE) {
return Byte.valueOf((byte)longValue);
diff --git a/src/main/java/org/apache/commons/validator/routines/CalendarValidator.java b/src/main/java/org/apache/commons/validator/routines/CalendarValidator.java
index 1e94114b..3b7500f9 100644
--- a/src/main/java/org/apache/commons/validator/routines/CalendarValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/CalendarValidator.java
@@ -115,7 +115,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* <code>Format</code> parsing should be used.
* @param dateStyle the date style to use for Locale validation.
*/
- public CalendarValidator(boolean strict, int dateStyle) {
+ public CalendarValidator(final boolean strict, final int dateStyle) {
super(strict, dateStyle, -1);
}
@@ -127,7 +127,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @return The parsed <code>Calendar</code> if valid or <code>null</code>
* if invalid.
*/
- public Calendar validate(String value) {
+ public Calendar validate(final String value) {
return (Calendar)parse(value, (String)null, (Locale)null, (TimeZone)null);
}
@@ -140,7 +140,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @return The parsed <code>Calendar</code> if valid or <code>null</code>
* if invalid.
*/
- public Calendar validate(String value, TimeZone timeZone) {
+ public Calendar validate(final String value, final TimeZone timeZone) {
return (Calendar)parse(value, (String)null, (Locale)null, timeZone);
}
@@ -152,7 +152,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern) {
+ public Calendar validate(final String value, final String pattern) {
return (Calendar)parse(value, pattern, (Locale)null, (TimeZone)null);
}
@@ -165,7 +165,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern, TimeZone timeZone) {
+ public Calendar validate(final String value, final String pattern, final TimeZone timeZone) {
return (Calendar)parse(value, pattern, (Locale)null, timeZone);
}
@@ -177,7 +177,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, Locale locale) {
+ public Calendar validate(final String value, final Locale locale) {
return (Calendar)parse(value, (String)null, locale, (TimeZone)null);
}
@@ -190,7 +190,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, Locale locale, TimeZone timeZone) {
+ public Calendar validate(final String value, final Locale locale, final TimeZone timeZone) {
return (Calendar)parse(value, (String)null, locale, timeZone);
}
@@ -204,7 +204,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern, Locale locale) {
+ public Calendar validate(final String value, final String pattern, final Locale locale) {
return (Calendar)parse(value, pattern, locale, (TimeZone)null);
}
@@ -219,7 +219,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern, Locale locale, TimeZone timeZone) {
+ public Calendar validate(final String value, final String pattern, final Locale locale, final TimeZone timeZone) {
return (Calendar)parse(value, pattern, locale, timeZone);
}
@@ -229,15 +229,15 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @param value The value to adjust.
* @param timeZone The new time zone to use to adjust the Calendar to.
*/
- public static void adjustToTimeZone(Calendar value, TimeZone timeZone) {
+ public static void adjustToTimeZone(final Calendar value, final TimeZone timeZone) {
if (value.getTimeZone().hasSameRules(timeZone)) {
value.setTimeZone(timeZone);
} else {
- int year = value.get(Calendar.YEAR);
- int month = value.get(Calendar.MONTH);
- int date = value.get(Calendar.DATE);
- int hour = value.get(Calendar.HOUR_OF_DAY);
- int minute = value.get(Calendar.MINUTE);
+ final int year = value.get(Calendar.YEAR);
+ final int month = value.get(Calendar.MONTH);
+ final int date = value.get(Calendar.DATE);
+ final int hour = value.get(Calendar.HOUR_OF_DAY);
+ final int minute = value.get(Calendar.MINUTE);
value.setTimeZone(timeZone);
value.set(year, month, date, hour, minute);
}
@@ -252,7 +252,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* date is less than the seconds and +1 if the first
* date is greater than.
*/
- public int compareDates(Calendar value, Calendar compare) {
+ public int compareDates(final Calendar value, final Calendar compare) {
return compare(value, compare, Calendar.DATE);
}
@@ -265,7 +265,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* parameter's week is less than the seconds and +1 if the first
* parameter's week is greater than.
*/
- public int compareWeeks(Calendar value, Calendar compare) {
+ public int compareWeeks(final Calendar value, final Calendar compare) {
return compare(value, compare, Calendar.WEEK_OF_YEAR);
}
@@ -278,7 +278,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* parameter's month is less than the seconds and +1 if the first
* parameter's month is greater than.
*/
- public int compareMonths(Calendar value, Calendar compare) {
+ public int compareMonths(final Calendar value, final Calendar compare) {
return compare(value, compare, Calendar.MONTH);
}
@@ -291,7 +291,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* parameter's quarter is less than the seconds and +1 if the first
* parameter's quarter is greater than.
*/
- public int compareQuarters(Calendar value, Calendar compare) {
+ public int compareQuarters(final Calendar value, final Calendar compare) {
return compareQuarters(value, compare, 1);
}
@@ -306,7 +306,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* parameter's quarter is greater than.
*/
@Override
- public int compareQuarters(Calendar value, Calendar compare, int monthOfFirstQuarter) {
+ public int compareQuarters(final Calendar value, final Calendar compare, final int monthOfFirstQuarter) {
return super.compareQuarters(value, compare, monthOfFirstQuarter);
}
@@ -319,7 +319,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* parameter's year is less than the seconds and +1 if the first
* parameter's year is greater than.
*/
- public int compareYears(Calendar value, Calendar compare) {
+ public int compareYears(final Calendar value, final Calendar compare) {
return compare(value, compare, Calendar.YEAR);
}
@@ -331,7 +331,7 @@ public class CalendarValidator extends AbstractCalendarValidator {
* @return The parsed value converted to a <code>Calendar</code>.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
return ((DateFormat)formatter).getCalendar();
}
diff --git a/src/main/java/org/apache/commons/validator/routines/CodeValidator.java b/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
index 82e662b4..38c30c98 100644
--- a/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
@@ -84,7 +84,7 @@ public final class CodeValidator implements Serializable {
* @param regex The format regular expression
* @param checkdigit The check digit validation routine
*/
- public CodeValidator(String regex, CheckDigit checkdigit) {
+ public CodeValidator(final String regex, final CheckDigit checkdigit) {
this(regex, -1, -1, checkdigit);
}
@@ -98,7 +98,7 @@ public final class CodeValidator implements Serializable {
* (sets the mimimum/maximum to the same)
* @param checkdigit The check digit validation routine
*/
- public CodeValidator(String regex, int length, CheckDigit checkdigit) {
+ public CodeValidator(final String regex, final int length, final CheckDigit checkdigit) {
this(regex, length, length, checkdigit);
}
@@ -112,8 +112,8 @@ public final class CodeValidator implements Serializable {
* @param maxLength The maximum length of the code
* @param checkdigit The check digit validation routine
*/
- public CodeValidator(String regex, int minLength, int maxLength,
- CheckDigit checkdigit) {
+ public CodeValidator(final String regex, final int minLength, final int maxLength,
+ final CheckDigit checkdigit) {
if (regex != null && !regex.isEmpty()) {
this.regexValidator = new RegexValidator(regex);
} else {
@@ -131,7 +131,7 @@ public final class CodeValidator implements Serializable {
* @param regexValidator The format regular expression validator
* @param checkdigit The check digit validation routine.
*/
- public CodeValidator(RegexValidator regexValidator, CheckDigit checkdigit) {
+ public CodeValidator(final RegexValidator regexValidator, final CheckDigit checkdigit) {
this(regexValidator, -1, -1, checkdigit);
}
@@ -144,7 +144,7 @@ public final class CodeValidator implements Serializable {
* (sets the mimimum/maximum to the same value)
* @param checkdigit The check digit validation routine
*/
- public CodeValidator(RegexValidator regexValidator, int length, CheckDigit checkdigit) {
+ public CodeValidator(final RegexValidator regexValidator, final int length, final CheckDigit checkdigit) {
this(regexValidator, length, length, checkdigit);
}
@@ -157,8 +157,8 @@ public final class CodeValidator implements Serializable {
* @param maxLength The maximum length of the code
* @param checkdigit The check digit validation routine
*/
- public CodeValidator(RegexValidator regexValidator, int minLength, int maxLength,
- CheckDigit checkdigit) {
+ public CodeValidator(final RegexValidator regexValidator, final int minLength, final int maxLength,
+ final CheckDigit checkdigit) {
this.regexValidator = regexValidator;
this.minLength = minLength;
this.maxLength = maxLength;
@@ -230,7 +230,7 @@ public final class CodeValidator implements Serializable {
* @return <code>true</code> if valid, otherwise
* <code>false</code>
*/
- public boolean isValid(String input) {
+ public boolean isValid(final String input) {
return (validate(input) != null);
}
@@ -246,7 +246,7 @@ public final class CodeValidator implements Serializable {
* @return The code if valid, otherwise <code>null</code>
* if invalid
*/
- public Object validate(String input) {
+ public Object validate(final String input) {
if (input == null) {
return null;
diff --git a/src/main/java/org/apache/commons/validator/routines/CreditCardValidator.java b/src/main/java/org/apache/commons/validator/routines/CreditCardValidator.java
index 1eab2a6a..1da7483f 100644
--- a/src/main/java/org/apache/commons/validator/routines/CreditCardValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/CreditCardValidator.java
@@ -115,7 +115,7 @@ public class CreditCardValidator implements Serializable {
* @param minLen the minimum length of the entire number
* @param maxLen the maximum length of the entire number
*/
- public CreditCardRange(String low, String high, int minLen, int maxLen) {
+ public CreditCardRange(final String low, final String high, final int minLen, final int maxLen) {
this.low = low;
this.high = high;
this.minLen = minLen;
@@ -138,7 +138,7 @@ public class CreditCardValidator implements Serializable {
* @param high the high digits of the IIN range
* @param lengths array of valid lengths
*/
- public CreditCardRange(String low, String high, int [] lengths) {
+ public CreditCardRange(final String low, final String high, final int [] lengths) {
this.low = low;
this.high = high;
this.minLen = -1;
@@ -298,7 +298,7 @@ public class CreditCardValidator implements Serializable {
* CreditCardValidator.VISA + CreditCardValidator.AMEX to specify that
* those are the only valid card types.
*/
- public CreditCardValidator(long options) {
+ public CreditCardValidator(final long options) {
if (isOn(options, VISA)) {
this.cardTypes.add(VISA_VALIDATOR);
}
@@ -332,7 +332,7 @@ public class CreditCardValidator implements Serializable {
* Create a new CreditCardValidator with the specified {@link CodeValidator}s.
* @param creditCardValidators Set of valid code validators
*/
- public CreditCardValidator(CodeValidator[] creditCardValidators) {
+ public CreditCardValidator(final CodeValidator[] creditCardValidators) {
if (creditCardValidators == null) {
throw new IllegalArgumentException("Card validators are missing");
}
@@ -344,7 +344,7 @@ public class CreditCardValidator implements Serializable {
* @param creditCardRanges Set of valid code validators
* @since 1.6
*/
- public CreditCardValidator(CreditCardRange[] creditCardRanges) {
+ public CreditCardValidator(final CreditCardRange[] creditCardRanges) {
if (creditCardRanges == null) {
throw new IllegalArgumentException("Card ranges are missing");
}
@@ -361,7 +361,7 @@ public class CreditCardValidator implements Serializable {
* @param creditCardRanges Set of valid code validators
* @since 1.6
*/
- public CreditCardValidator(CodeValidator[] creditCardValidators, CreditCardRange[] creditCardRanges) {
+ public CreditCardValidator(final CodeValidator[] creditCardValidators, final CreditCardRange[] creditCardRanges) {
if (creditCardValidators == null) {
throw new IllegalArgumentException("Card validators are missing");
}
@@ -381,7 +381,7 @@ public class CreditCardValidator implements Serializable {
* @return the validator
* @since 1.6
*/
- public static CreditCardValidator genericCreditCardValidator(int minLen, int maxLen) {
+ public static CreditCardValidator genericCreditCardValidator(final int minLen, final int maxLen) {
return new CreditCardValidator(new CodeValidator[] {new CodeValidator("(\\d+)", minLen, maxLen, LUHN_VALIDATOR)});
}
@@ -393,7 +393,7 @@ public class CreditCardValidator implements Serializable {
* @return the validator
* @since 1.6
*/
- public static CreditCardValidator genericCreditCardValidator(int length) {
+ public static CreditCardValidator genericCreditCardValidator(final int length) {
return genericCreditCardValidator(length, length);
}
@@ -413,11 +413,11 @@ public class CreditCardValidator implements Serializable {
* @param card The card number to validate.
* @return Whether the card number is valid.
*/
- public boolean isValid(String card) {
+ public boolean isValid(final String card) {
if (card == null || card.isEmpty()) {
return false;
}
- for (CodeValidator cardType : cardTypes) {
+ for (final CodeValidator cardType : cardTypes) {
if (cardType.isValid(card)) {
return true;
}
@@ -431,12 +431,12 @@ public class CreditCardValidator implements Serializable {
* @return The card number if valid or <code>null</code>
* if invalid.
*/
- public Object validate(String card) {
+ public Object validate(final String card) {
if (card == null || card.isEmpty()) {
return null;
}
Object result = null;
- for (CodeValidator cardType : cardTypes) {
+ for (final CodeValidator cardType : cardTypes) {
result = cardType.validate(card);
if (result != null) {
return result;
@@ -447,9 +447,9 @@ public class CreditCardValidator implements Serializable {
}
// package protected for unit test access
- static boolean validLength(int valueLength, CreditCardRange range) {
+ static boolean validLength(final int valueLength, final CreditCardRange range) {
if (range.lengths != null) {
- for(int length : range.lengths) {
+ for(final int length : range.lengths) {
if (valueLength == length) {
return true;
}
@@ -468,10 +468,10 @@ public class CreditCardValidator implements Serializable {
private final CreditCardRange[] ccr = creditCardRanges.clone();
@Override
// must return full string
- public String validate(String value) {
+ public String validate(final String value) {
if (super.match(value) != null) {
- int length = value.length();
- for(CreditCardRange range : ccr) {
+ final int length = value.length();
+ for(final CreditCardRange range : ccr) {
if (validLength(length, range)) {
if (range.high == null) { // single prefix only
if (value.startsWith(range.low)) {
@@ -489,11 +489,11 @@ public class CreditCardValidator implements Serializable {
return null;
}
@Override
- public boolean isValid(String value) {
+ public boolean isValid(final String value) {
return validate(value) != null;
}
@Override
- public String[] match(String value) {
+ public String[] match(final String value) {
return new String[]{validate(value)};
}
}, digitCheck);
@@ -508,7 +508,7 @@ public class CreditCardValidator implements Serializable {
*
* @return whether the specified flag value is on.
*/
- private boolean isOn(long options, long flag) {
+ private boolean isOn(final long options, final long flag) {
return (options & flag) > 0;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/CurrencyValidator.java b/src/main/java/org/apache/commons/validator/routines/CurrencyValidator.java
index 3dce07bd..f12ee812 100644
--- a/src/main/java/org/apache/commons/validator/routines/CurrencyValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/CurrencyValidator.java
@@ -74,7 +74,7 @@ public class CurrencyValidator extends BigDecimalValidator {
* @param allowFractions <code>true</code> if fractions are
* allowed or <code>false</code> if integers only.
*/
- public CurrencyValidator(boolean strict, boolean allowFractions) {
+ public CurrencyValidator(final boolean strict, final boolean allowFractions) {
super(strict, CURRENCY_FORMAT, allowFractions);
}
@@ -92,7 +92,7 @@ public class CurrencyValidator extends BigDecimalValidator {
* @return The parsed value if valid or <code>null</code> if invalid.
*/
@Override
- protected Object parse(String value, Format formatter) {
+ protected Object parse(final String value, final Format formatter) {
// Initial parse of the value
Object parsedValue = super.parse(value, formatter);
@@ -101,10 +101,10 @@ public class CurrencyValidator extends BigDecimalValidator {
}
// Re-parse using a pattern without the currency symbol
- DecimalFormat decimalFormat = (DecimalFormat)formatter;
- String pattern = decimalFormat.toPattern();
+ final DecimalFormat decimalFormat = (DecimalFormat)formatter;
+ final String pattern = decimalFormat.toPattern();
if (pattern.indexOf(CURRENCY_SYMBOL) >= 0) {
- StringBuilder buffer = new StringBuilder(pattern.length());
+ final StringBuilder buffer = new StringBuilder(pattern.length());
for (int i = 0; i < pattern.length(); i++) {
if (pattern.charAt(i) != CURRENCY_SYMBOL) {
buffer.append(pattern.charAt(i));
diff --git a/src/main/java/org/apache/commons/validator/routines/DateValidator.java b/src/main/java/org/apache/commons/validator/routines/DateValidator.java
index 60a6b433..57c35ebb 100644
--- a/src/main/java/org/apache/commons/validator/routines/DateValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/DateValidator.java
@@ -112,7 +112,7 @@ public class DateValidator extends AbstractCalendarValidator {
* <code>Format</code> parsing should be used.
* @param dateStyle the date style to use for Locale validation.
*/
- public DateValidator(boolean strict, int dateStyle) {
+ public DateValidator(final boolean strict, final int dateStyle) {
super(strict, dateStyle, -1);
}
@@ -124,7 +124,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @return The parsed <code>Date</code> if valid or <code>null</code>
* if invalid.
*/
- public Date validate(String value) {
+ public Date validate(final String value) {
return (Date)parse(value, (String)null, (Locale)null, (TimeZone)null);
}
@@ -136,7 +136,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, TimeZone timeZone) {
+ public Date validate(final String value, final TimeZone timeZone) {
return (Date)parse(value, (String)null, (Locale)null, timeZone);
}
@@ -149,7 +149,7 @@ public class DateValidator extends AbstractCalendarValidator {
* default for the <code>Locale</code> if <code>null</code>.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, String pattern) {
+ public Date validate(final String value, final String pattern) {
return (Date)parse(value, pattern, (Locale)null, (TimeZone)null);
}
@@ -163,7 +163,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, String pattern, TimeZone timeZone) {
+ public Date validate(final String value, final String pattern, final TimeZone timeZone) {
return (Date)parse(value, pattern, (Locale)null, timeZone);
}
@@ -175,7 +175,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, Locale locale) {
+ public Date validate(final String value, final Locale locale) {
return (Date)parse(value, (String)null, locale, (TimeZone)null);
}
@@ -188,7 +188,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, Locale locale, TimeZone timeZone) {
+ public Date validate(final String value, final Locale locale, final TimeZone timeZone) {
return (Date)parse(value, (String)null, locale, timeZone);
}
@@ -202,7 +202,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, String pattern, Locale locale) {
+ public Date validate(final String value, final String pattern, final Locale locale) {
return (Date)parse(value, pattern, locale, (TimeZone)null);
}
@@ -217,7 +217,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Date</code> if valid or <code>null</code> if invalid.
*/
- public Date validate(String value, String pattern, Locale locale, TimeZone timeZone) {
+ public Date validate(final String value, final String pattern, final Locale locale, final TimeZone timeZone) {
return (Date)parse(value, pattern, locale, timeZone);
}
@@ -231,9 +231,9 @@ public class DateValidator extends AbstractCalendarValidator {
* date is less than the seconds and +1 if the first
* date is greater than.
*/
- public int compareDates(Date value, Date compare, TimeZone timeZone) {
- Calendar calendarValue = getCalendar(value, timeZone);
- Calendar calendarCompare = getCalendar(compare, timeZone);
+ public int compareDates(final Date value, final Date compare, final TimeZone timeZone) {
+ final Calendar calendarValue = getCalendar(value, timeZone);
+ final Calendar calendarCompare = getCalendar(compare, timeZone);
return compare(calendarValue, calendarCompare, Calendar.DATE);
}
@@ -247,9 +247,9 @@ public class DateValidator extends AbstractCalendarValidator {
* parameter's week is less than the seconds and +1 if the first
* parameter's week is greater than.
*/
- public int compareWeeks(Date value, Date compare, TimeZone timeZone) {
- Calendar calendarValue = getCalendar(value, timeZone);
- Calendar calendarCompare = getCalendar(compare, timeZone);
+ public int compareWeeks(final Date value, final Date compare, final TimeZone timeZone) {
+ final Calendar calendarValue = getCalendar(value, timeZone);
+ final Calendar calendarCompare = getCalendar(compare, timeZone);
return compare(calendarValue, calendarCompare, Calendar.WEEK_OF_YEAR);
}
@@ -263,9 +263,9 @@ public class DateValidator extends AbstractCalendarValidator {
* parameter's month is less than the seconds and +1 if the first
* parameter's month is greater than.
*/
- public int compareMonths(Date value, Date compare, TimeZone timeZone) {
- Calendar calendarValue = getCalendar(value, timeZone);
- Calendar calendarCompare = getCalendar(compare, timeZone);
+ public int compareMonths(final Date value, final Date compare, final TimeZone timeZone) {
+ final Calendar calendarValue = getCalendar(value, timeZone);
+ final Calendar calendarCompare = getCalendar(compare, timeZone);
return compare(calendarValue, calendarCompare, Calendar.MONTH);
}
@@ -279,7 +279,7 @@ public class DateValidator extends AbstractCalendarValidator {
* parameter's quarter is less than the seconds and +1 if the first
* parameter's quarter is greater than.
*/
- public int compareQuarters(Date value, Date compare, TimeZone timeZone) {
+ public int compareQuarters(final Date value, final Date compare, final TimeZone timeZone) {
return compareQuarters(value, compare, timeZone, 1);
}
@@ -294,9 +294,9 @@ public class DateValidator extends AbstractCalendarValidator {
* parameter's quarter is less than the seconds and +1 if the first
* parameter's quarter is greater than.
*/
- public int compareQuarters(Date value, Date compare, TimeZone timeZone, int monthOfFirstQuarter) {
- Calendar calendarValue = getCalendar(value, timeZone);
- Calendar calendarCompare = getCalendar(compare, timeZone);
+ public int compareQuarters(final Date value, final Date compare, final TimeZone timeZone, final int monthOfFirstQuarter) {
+ final Calendar calendarValue = getCalendar(value, timeZone);
+ final Calendar calendarCompare = getCalendar(compare, timeZone);
return super.compareQuarters(calendarValue, calendarCompare, monthOfFirstQuarter);
}
@@ -310,9 +310,9 @@ public class DateValidator extends AbstractCalendarValidator {
* parameter's year is less than the seconds and +1 if the first
* parameter's year is greater than.
*/
- public int compareYears(Date value, Date compare, TimeZone timeZone) {
- Calendar calendarValue = getCalendar(value, timeZone);
- Calendar calendarCompare = getCalendar(compare, timeZone);
+ public int compareYears(final Date value, final Date compare, final TimeZone timeZone) {
+ final Calendar calendarValue = getCalendar(value, timeZone);
+ final Calendar calendarCompare = getCalendar(compare, timeZone);
return compare(calendarValue, calendarCompare, Calendar.YEAR);
}
@@ -324,7 +324,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @return The parsed value converted to a <code>Calendar</code>.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
return value;
}
@@ -334,7 +334,7 @@ public class DateValidator extends AbstractCalendarValidator {
* @param value The date value to be converted.
* @return The converted <code>Calendar</code>.
*/
- private Calendar getCalendar(Date value, TimeZone timeZone) {
+ private Calendar getCalendar(final Date value, final TimeZone timeZone) {
Calendar calendar = null;
if (timeZone != null) {
diff --git a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
index b7be90e1..9a685356 100644
--- a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
@@ -142,7 +142,7 @@ public class DomainValidator implements Serializable {
* @param allowLocal Should local addresses be considered valid?
* @return the singleton instance of this validator
*/
- public static synchronized DomainValidator getInstance(boolean allowLocal) {
+ public static synchronized DomainValidator getInstance(final boolean allowLocal) {
inUse = true;
if(allowLocal) {
return LazyHolder.DOMAIN_VALIDATOR_WITH_LOCAL;
@@ -164,7 +164,7 @@ public class DomainValidator implements Serializable {
* @return an instance of this validator
* @since 1.7
*/
- public static synchronized DomainValidator getInstance(boolean allowLocal, List<Item> items) {
+ public static synchronized DomainValidator getInstance(final boolean allowLocal, final List<Item> items) {
inUse = true;
return new DomainValidator(allowLocal, items);
}
@@ -189,7 +189,7 @@ public class DomainValidator implements Serializable {
/**
* Private constructor.
*/
- private DomainValidator(boolean allowLocal) {
+ private DomainValidator(final boolean allowLocal) {
this.allowLocal = allowLocal;
// link to class overrides
mycountryCodeTLDsMinus = countryCodeTLDsMinus;
@@ -204,7 +204,7 @@ public class DomainValidator implements Serializable {
* Private constructor, allowing local overrides
* @since 1.7
*/
- private DomainValidator(boolean allowLocal, List<Item> items) {
+ private DomainValidator(final boolean allowLocal, final List<Item> items) {
this.allowLocal = allowLocal;
// default to class overrides
@@ -216,8 +216,8 @@ public class DomainValidator implements Serializable {
String[] localPlus = localTLDsPlus;
// apply the instance overrides
- for(Item item: items) {
- String [] copy = new String[item.values.length];
+ for(final Item item: items) {
+ final String [] copy = new String[item.values.length];
// Comparisons are always done with lower-case entries
for (int i = 0; i < item.values.length; i++) {
copy[i] = item.values[i].toLowerCase(Locale.ENGLISH);
@@ -281,7 +281,7 @@ public class DomainValidator implements Serializable {
if (domain.length() > MAX_DOMAIN_LENGTH) {
return false;
}
- String[] groups = domainRegex.match(domain);
+ final String[] groups = domainRegex.match(domain);
if (groups != null && groups.length > 0) {
return isValidTld(groups[0]);
}
@@ -302,7 +302,7 @@ public class DomainValidator implements Serializable {
if (domain.length() > MAX_DOMAIN_LENGTH) {
return false;
}
- String[] groups = domainRegex.match(domain);
+ final String[] groups = domainRegex.match(domain);
return (groups != null && groups.length > 0)
|| hostnameRegex.isValid(domain);
}
@@ -318,7 +318,7 @@ public class DomainValidator implements Serializable {
* @param tld the parameter to check for TLD status, not null
* @return true if the parameter is a TLD
*/
- public boolean isValidTld(String tld) {
+ public boolean isValidTld(final String tld) {
if(allowLocal && isValidLocalTld(tld)) {
return true;
}
@@ -334,7 +334,7 @@ public class DomainValidator implements Serializable {
* @param iTld the parameter to check for infrastructure TLD status, not null
* @return true if the parameter is an infrastructure TLD
*/
- public boolean isValidInfrastructureTld(String iTld) {
+ public boolean isValidInfrastructureTld(final String iTld) {
final String key = chompLeadingDot(unicodeToASCII(iTld).toLowerCase(Locale.ENGLISH));
return arrayContains(INFRASTRUCTURE_TLDS, key);
}
@@ -346,7 +346,7 @@ public class DomainValidator implements Serializable {
* @param gTld the parameter to check for generic TLD status, not null
* @return true if the parameter is a generic TLD
*/
- public boolean isValidGenericTld(String gTld) {
+ public boolean isValidGenericTld(final String gTld) {
final String key = chompLeadingDot(unicodeToASCII(gTld).toLowerCase(Locale.ENGLISH));
return (arrayContains(GENERIC_TLDS, key) || arrayContains(mygenericTLDsPlus, key))
&& !arrayContains(mygenericTLDsMinus, key);
@@ -359,7 +359,7 @@ public class DomainValidator implements Serializable {
* @param ccTld the parameter to check for country code TLD status, not null
* @return true if the parameter is a country code TLD
*/
- public boolean isValidCountryCodeTld(String ccTld) {
+ public boolean isValidCountryCodeTld(final String ccTld) {
final String key = chompLeadingDot(unicodeToASCII(ccTld).toLowerCase(Locale.ENGLISH));
return (arrayContains(COUNTRY_CODE_TLDS, key) || arrayContains(mycountryCodeTLDsPlus, key))
&& !arrayContains(mycountryCodeTLDsMinus, key);
@@ -372,7 +372,7 @@ public class DomainValidator implements Serializable {
* @param lTld the parameter to check for local TLD status, not null
* @return true if the parameter is an local TLD
*/
- public boolean isValidLocalTld(String lTld) {
+ public boolean isValidLocalTld(final String lTld) {
final String key = chompLeadingDot(unicodeToASCII(lTld).toLowerCase(Locale.ENGLISH));
return (arrayContains(LOCAL_TLDS, key) || arrayContains(mylocalTLDsPlus, key))
&& !arrayContains(mylocalTLDsMinus, key);
@@ -388,7 +388,7 @@ public class DomainValidator implements Serializable {
return this.allowLocal;
}
- private String chompLeadingDot(String str) {
+ private String chompLeadingDot(final String str) {
if (str.startsWith(".")) {
return str.substring(1);
}
@@ -2084,7 +2084,7 @@ public class DomainValidator implements Serializable {
* @param type ArrayType, e.g. GENERIC_PLUS, LOCAL_PLUS
* @param values array of TLDs. Will be lower-cased and sorted
*/
- public Item(ArrayType type, String[] values) {
+ public Item(final ArrayType type, final String[] values) {
this.type = type;
this.values = values; // no need to copy here
}
@@ -2115,11 +2115,11 @@ public class DomainValidator implements Serializable {
* @throws IllegalArgumentException if one of the read-only tables is requested
* @since 1.5.0
*/
- public static synchronized void updateTLDOverride(ArrayType table, String [] tlds) {
+ public static synchronized void updateTLDOverride(final ArrayType table, final String [] tlds) {
if (inUse) {
throw new IllegalStateException("Can only invoke this method before calling getInstance");
}
- String [] copy = new String[tlds.length];
+ final String [] copy = new String[tlds.length];
// Comparisons are always done with lower-case entries
for (int i = 0; i < tlds.length; i++) {
copy[i] = tlds[i].toLowerCase(Locale.ENGLISH);
@@ -2161,7 +2161,7 @@ public class DomainValidator implements Serializable {
* @throws IllegalArgumentException if the table type is unexpected (should not happen)
* @since 1.5.1
*/
- public static synchronized String [] getTLDEntries(ArrayType table) {
+ public static synchronized String [] getTLDEntries(final ArrayType table) {
final String[] array;
switch(table) {
case COUNTRY_CODE_MINUS:
@@ -2207,7 +2207,7 @@ public class DomainValidator implements Serializable {
* @throws IllegalArgumentException if the table type is unexpected, e.g. GENERIC_RO
* @since 1.7
*/
- public String [] getOverrides(ArrayType table) {
+ public String [] getOverrides(final ArrayType table) {
final String[] array;
switch(table) {
case COUNTRY_CODE_MINUS:
@@ -2241,7 +2241,7 @@ public class DomainValidator implements Serializable {
* @return converted input, or original input if conversion fails
*/
// Needed by UrlValidator
- static String unicodeToASCII(String input) {
+ static String unicodeToASCII(final String input) {
if (isOnlyASCII(input)) { // skip possibly expensive processing
return input;
}
@@ -2259,7 +2259,7 @@ public class DomainValidator implements Serializable {
// characters MUST be recognized as dots: U+002E (full stop), U+3002
// (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61
// (halfwidth ideographic full stop).
- char lastChar = input.charAt(length-1);// fetch original last char
+ final char lastChar = input.charAt(length-1);// fetch original last char
switch(lastChar) {
case '\u002E': // "." full stop
case '\u3002': // ideographic full stop
@@ -2269,7 +2269,7 @@ public class DomainValidator implements Serializable {
default:
return ascii;
}
- } catch (IllegalArgumentException e) { // input is not valid
+ } catch (final IllegalArgumentException e) { // input is not valid
return input;
}
}
@@ -2286,7 +2286,7 @@ public class DomainValidator implements Serializable {
* Check if input contains only ASCII
* Treats null as all ASCII
*/
- private static boolean isOnlyASCII(String input) {
+ private static boolean isOnlyASCII(final String input) {
if (input == null) {
return true;
}
@@ -2305,7 +2305,7 @@ public class DomainValidator implements Serializable {
* @param key the key to find
* @return {@code true} if the array contains the key
*/
- private static boolean arrayContains(String[] sortedArray, String key) {
+ private static boolean arrayContains(final String[] sortedArray, final String key) {
return Arrays.binarySearch(sortedArray, key) >= 0;
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java b/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java
index d24a3d83..ae039118 100644
--- a/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java
@@ -104,7 +104,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public DoubleValidator(boolean strict, int formatType) {
+ public DoubleValidator(final boolean strict, final int formatType) {
super(strict, formatType, true);
}
@@ -116,7 +116,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return The parsed <code>Double</code> if valid or <code>null</code>
* if invalid.
*/
- public Double validate(String value) {
+ public Double validate(final String value) {
return (Double)parse(value, (String)null, (Locale)null);
}
@@ -128,7 +128,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>BigDecimal</code> if valid or <code>null</code> if invalid.
*/
- public Double validate(String value, String pattern) {
+ public Double validate(final String value, final String pattern) {
return (Double)parse(value, pattern, (Locale)null);
}
@@ -140,7 +140,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>Double</code> if valid or <code>null</code> if invalid.
*/
- public Double validate(String value, Locale locale) {
+ public Double validate(final String value, final Locale locale) {
return (Double)parse(value, (String)null, locale);
}
@@ -154,7 +154,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Double</code> if valid or <code>null</code> if invalid.
*/
- public Double validate(String value, String pattern, Locale locale) {
+ public Double validate(final String value, final String pattern, final Locale locale) {
return (Double)parse(value, pattern, locale);
}
@@ -167,7 +167,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(double value, double min, double max) {
+ public boolean isInRange(final double value, final double min, final double max) {
return (value >= min && value <= max);
}
@@ -180,7 +180,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Double value, double min, double max) {
+ public boolean isInRange(final Double value, final double min, final double max) {
return isInRange(value.doubleValue(), min, max);
}
@@ -192,7 +192,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(double value, double min) {
+ public boolean minValue(final double value, final double min) {
return (value >= min);
}
@@ -204,7 +204,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Double value, double min) {
+ public boolean minValue(final Double value, final double min) {
return minValue(value.doubleValue(), min);
}
@@ -216,7 +216,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(double value, double max) {
+ public boolean maxValue(final double value, final double max) {
return (value <= max);
}
@@ -228,7 +228,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Double value, double max) {
+ public boolean maxValue(final Double value, final double max) {
return maxValue(value.doubleValue(), max);
}
@@ -241,7 +241,7 @@ public class DoubleValidator extends AbstractNumberValidator {
* or <code>null</code> if invalid.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
if (value instanceof Double) {
return value;
diff --git a/src/main/java/org/apache/commons/validator/routines/EmailValidator.java b/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
index 1dee0407..49203058 100644
--- a/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
@@ -98,7 +98,7 @@ public class EmailValidator implements Serializable {
* @param allowTld Should TLDs be allowed?
* @return singleton instance of this validator
*/
- public static EmailValidator getInstance(boolean allowLocal, boolean allowTld) {
+ public static EmailValidator getInstance(final boolean allowLocal, final boolean allowTld) {
if (allowLocal) {
if (allowTld) {
return EMAIL_VALIDATOR_WITH_LOCAL_WITH_TLD;
@@ -118,7 +118,7 @@ public class EmailValidator implements Serializable {
* @param allowLocal Should local addresses be considered valid?
* @return singleton instance of this validator
*/
- public static EmailValidator getInstance(boolean allowLocal) {
+ public static EmailValidator getInstance(final boolean allowLocal) {
return getInstance(allowLocal, false);
}
@@ -131,7 +131,7 @@ public class EmailValidator implements Serializable {
* The instance must have the same allowLocal setting.
* @since 1.7
*/
- public EmailValidator(boolean allowLocal, boolean allowTld, DomainValidator domainValidator) {
+ public EmailValidator(final boolean allowLocal, final boolean allowTld, final DomainValidator domainValidator) {
this.allowTld = allowTld;
if (domainValidator == null) {
throw new IllegalArgumentException("DomainValidator cannot be null");
@@ -148,7 +148,7 @@ public class EmailValidator implements Serializable {
* @param allowLocal Should local addresses be considered valid?
* @param allowTld Should TLDs be allowed?
*/
- protected EmailValidator(boolean allowLocal, boolean allowTld) {
+ protected EmailValidator(final boolean allowLocal, final boolean allowTld) {
this.allowTld = allowTld;
this.domainValidator = DomainValidator.getInstance(allowLocal);
}
@@ -158,7 +158,7 @@ public class EmailValidator implements Serializable {
*
* @param allowLocal Should local addresses be considered valid?
*/
- protected EmailValidator(boolean allowLocal) {
+ protected EmailValidator(final boolean allowLocal) {
this(allowLocal, false);
}
@@ -169,7 +169,7 @@ public class EmailValidator implements Serializable {
* value is considered invalid.
* @return true if the email address is valid.
*/
- public boolean isValid(String email) {
+ public boolean isValid(final String email) {
if (email == null) {
return false;
}
@@ -179,7 +179,7 @@ public class EmailValidator implements Serializable {
}
// Check the whole email address structure
- Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
+ final Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
if (!emailMatcher.matches()) {
return false;
}
@@ -201,12 +201,12 @@ public class EmailValidator implements Serializable {
* @param domain being validated, may be in IDN format
* @return true if the email address's domain is valid.
*/
- protected boolean isValidDomain(String domain) {
+ protected boolean isValidDomain(final String domain) {
// see if domain is an IP address in brackets
- Matcher ipDomainMatcher = IP_DOMAIN_PATTERN.matcher(domain);
+ final Matcher ipDomainMatcher = IP_DOMAIN_PATTERN.matcher(domain);
if (ipDomainMatcher.matches()) {
- InetAddressValidator inetAddressValidator =
+ final InetAddressValidator inetAddressValidator =
InetAddressValidator.getInstance();
return inetAddressValidator.isValid(ipDomainMatcher.group(1));
}
@@ -223,7 +223,7 @@ public class EmailValidator implements Serializable {
* @param user being validated
* @return true if the user name is valid.
*/
- protected boolean isValidUser(String user) {
+ protected boolean isValidUser(final String user) {
if (user == null || user.length() > MAX_USERNAME_LEN) {
return false;
diff --git a/src/main/java/org/apache/commons/validator/routines/FloatValidator.java b/src/main/java/org/apache/commons/validator/routines/FloatValidator.java
index 612aa952..25d13d59 100644
--- a/src/main/java/org/apache/commons/validator/routines/FloatValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/FloatValidator.java
@@ -104,7 +104,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public FloatValidator(boolean strict, int formatType) {
+ public FloatValidator(final boolean strict, final int formatType) {
super(strict, formatType, true);
}
@@ -116,7 +116,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return The parsed <code>Float</code> if valid or <code>null</code>
* if invalid.
*/
- public Float validate(String value) {
+ public Float validate(final String value) {
return (Float)parse(value, (String)null, (Locale)null);
}
@@ -128,7 +128,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Float</code> if valid or <code>null</code> if invalid.
*/
- public Float validate(String value, String pattern) {
+ public Float validate(final String value, final String pattern) {
return (Float)parse(value, pattern, (Locale)null);
}
@@ -140,7 +140,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>Float</code> if valid or <code>null</code> if invalid.
*/
- public Float validate(String value, Locale locale) {
+ public Float validate(final String value, final Locale locale) {
return (Float)parse(value, (String)null, locale);
}
@@ -154,7 +154,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Float</code> if valid or <code>null</code> if invalid.
*/
- public Float validate(String value, String pattern, Locale locale) {
+ public Float validate(final String value, final String pattern, final Locale locale) {
return (Float)parse(value, pattern, locale);
}
@@ -167,7 +167,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(float value, float min, float max) {
+ public boolean isInRange(final float value, final float min, final float max) {
return (value >= min && value <= max);
}
@@ -180,7 +180,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Float value, float min, float max) {
+ public boolean isInRange(final Float value, final float min, final float max) {
return isInRange(value.floatValue(), min, max);
}
@@ -192,7 +192,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(float value, float min) {
+ public boolean minValue(final float value, final float min) {
return (value >= min);
}
@@ -204,7 +204,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Float value, float min) {
+ public boolean minValue(final Float value, final float min) {
return minValue(value.floatValue(), min);
}
@@ -216,7 +216,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(float value, float max) {
+ public boolean maxValue(final float value, final float max) {
return (value <= max);
}
@@ -228,7 +228,7 @@ public class FloatValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Float value, float max) {
+ public boolean maxValue(final Float value, final float max) {
return maxValue(value.floatValue(), max);
}
@@ -242,9 +242,9 @@ public class FloatValidator extends AbstractNumberValidator {
* <code>Float</code> if valid or <code>null</code> if invalid.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
- double doubleValue = ((Number)value).doubleValue();
+ final double doubleValue = ((Number)value).doubleValue();
if (doubleValue > 0) {
if (doubleValue < Float.MIN_VALUE) {
@@ -254,7 +254,7 @@ public class FloatValidator extends AbstractNumberValidator {
return null;
}
} else if (doubleValue < 0){
- double posDouble = doubleValue * -1;
+ final double posDouble = doubleValue * -1;
if (posDouble < Float.MIN_VALUE) {
return null;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/IBANValidator.java b/src/main/java/org/apache/commons/validator/routines/IBANValidator.java
index 463828cf..54ff53b9 100644
--- a/src/main/java/org/apache/commons/validator/routines/IBANValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/IBANValidator.java
@@ -75,7 +75,7 @@ public class IBANValidator {
* @param len the length of the IBAN
* @param format the regex to use to check the format
*/
- public Validator(String cc, int len, String format) {
+ public Validator(final String cc, final int len, final String format) {
if (!(cc.length() == 2 && Character.isUpperCase(cc.charAt(0)) && Character.isUpperCase(cc.charAt(1)))) {
throw new IllegalArgumentException("Invalid country Code; must be exactly 2 upper-case characters");
}
@@ -224,13 +224,13 @@ public class IBANValidator {
*
* @param formatMap map of IBAN formats
*/
- public IBANValidator(Validator[] formatMap) {
+ public IBANValidator(final Validator[] formatMap) {
this.formatValidators = createValidators(formatMap);
}
- private Map<String, Validator> createValidators(Validator[] formatMap) {
- Map<String, Validator> m = new ConcurrentHashMap<>();
- for(Validator v : formatMap) {
+ private Map<String, Validator> createValidators(final Validator[] formatMap) {
+ final Map<String, Validator> m = new ConcurrentHashMap<>();
+ for(final Validator v : formatMap) {
m.put(v.countryCode, v);
}
return m;
@@ -242,8 +242,8 @@ public class IBANValidator {
* @param code The value validation is being performed on
* @return <code>true</code> if the value is valid
*/
- public boolean isValid(String code) {
- Validator formatValidator = getValidator(code);
+ public boolean isValid(final String code) {
+ final Validator formatValidator = getValidator(code);
if (formatValidator == null || code.length() != formatValidator.lengthOfIBAN || !formatValidator.validator.isValid(code)) {
return false;
}
@@ -256,7 +256,7 @@ public class IBANValidator {
* @param code the code to check
* @return true if there is a validator
*/
- public boolean hasValidator(String code) {
+ public boolean hasValidator(final String code) {
return getValidator(code) != null;
}
@@ -276,11 +276,11 @@ public class IBANValidator {
*
* @return the validator or {@code null} if there is not one registered.
*/
- public Validator getValidator(String code) {
+ public Validator getValidator(final String code) {
if (code == null || code.length() < 2) { // ensure we can extract the code
return null;
}
- String key = code.substring(0, 2);
+ final String key = code.substring(0, 2);
return formatValidators.get(key);
}
@@ -292,7 +292,7 @@ public class IBANValidator {
* @return the previous Validator, or {@code null} if there was none
* @throws IllegalStateException if an attempt is made to modify the singleton validator
*/
- public Validator setValidator(Validator validator) {
+ public Validator setValidator(final Validator validator) {
if (this == DEFAULT_IBAN_VALIDATOR) {
throw new IllegalStateException("The singleton validator cannot be modified");
}
@@ -311,7 +311,7 @@ public class IBANValidator {
* @throws IllegalArgumentException if there is a problem
* @throws IllegalStateException if an attempt is made to modify the singleton validator
*/
- public Validator setValidator(String countryCode, int length, String format) {
+ public Validator setValidator(final String countryCode, final int length, final String format) {
if (this == DEFAULT_IBAN_VALIDATOR) {
throw new IllegalStateException("The singleton validator cannot be modified");
}
diff --git a/src/main/java/org/apache/commons/validator/routines/ISBNValidator.java b/src/main/java/org/apache/commons/validator/routines/ISBNValidator.java
index 0f8036ef..a449a15b 100644
--- a/src/main/java/org/apache/commons/validator/routines/ISBNValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ISBNValidator.java
@@ -125,7 +125,7 @@ public class ISBNValidator implements Serializable {
* if valid ISBN-10 codes should be returned unchanged.
* @return A singleton instance of the ISBN validator.
*/
- public static ISBNValidator getInstance(boolean convert) {
+ public static ISBNValidator getInstance(final boolean convert) {
return (convert ? ISBN_VALIDATOR : ISBN_VALIDATOR_NO_CONVERT);
}
@@ -145,7 +145,7 @@ public class ISBNValidator implements Serializable {
* should be converted to ISBN-13 codes or <code>false</code>
* if valid ISBN-10 codes should be returned unchanged.
*/
- public ISBNValidator(boolean convert) {
+ public ISBNValidator(final boolean convert) {
this.convert = convert;
}
@@ -156,7 +156,7 @@ public class ISBNValidator implements Serializable {
* @return <code>true</code> if a valid ISBN-10 or
* ISBN-13 code, otherwise <code>false</code>.
*/
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
return (isValidISBN13(code) || isValidISBN10(code));
}
@@ -167,7 +167,7 @@ public class ISBNValidator implements Serializable {
* @return <code>true</code> if a valid ISBN-10
* code, otherwise <code>false</code>.
*/
- public boolean isValidISBN10(String code) {
+ public boolean isValidISBN10(final String code) {
return isbn10Validator.isValid(code);
}
@@ -178,7 +178,7 @@ public class ISBNValidator implements Serializable {
* @return <code>true</code> if a valid ISBN-13
* code, otherwise <code>false</code>.
*/
- public boolean isValidISBN13(String code) {
+ public boolean isValidISBN13(final String code) {
return isbn13Validator.isValid(code);
}
@@ -194,7 +194,7 @@ public class ISBNValidator implements Serializable {
* @param code The code to validate.
* @return A valid ISBN code if valid, otherwise <code>null</code>.
*/
- public String validate(String code) {
+ public String validate(final String code) {
String result = validateISBN13(code);
if (result == null) {
result = validateISBN10(code);
@@ -215,8 +215,8 @@ public class ISBNValidator implements Serializable {
* @return A valid ISBN-10 code if valid,
* otherwise <code>null</code>.
*/
- public String validateISBN10(String code) {
- Object result = isbn10Validator.validate(code);
+ public String validateISBN10(final String code) {
+ final Object result = isbn10Validator.validate(code);
return (result == null ? null : result.toString());
}
@@ -230,8 +230,8 @@ public class ISBNValidator implements Serializable {
* @return A valid ISBN-13 code if valid,
* otherwise <code>null</code>.
*/
- public String validateISBN13(String code) {
- Object result = isbn13Validator.validate(code);
+ public String validateISBN13(final String code) {
+ final Object result = isbn13Validator.validate(code);
return (result == null ? null : result.toString());
}
@@ -245,13 +245,13 @@ public class ISBNValidator implements Serializable {
* @return A converted ISBN-13 code or <code>null</code>
* if the ISBN-10 code is not valid
*/
- public String convertToISBN13(String isbn10) {
+ public String convertToISBN13(final String isbn10) {
if (isbn10 == null) {
return null;
}
- String input = isbn10.trim();
+ final String input = isbn10.trim();
if (input.length() != ISBN_10_LEN) {
throw new IllegalArgumentException("Invalid length " + input.length() + " for '" + input + "'");
}
@@ -259,10 +259,10 @@ public class ISBNValidator implements Serializable {
// Calculate the new ISBN-13 code (drop the original checkdigit)
String isbn13 = "978" + input.substring(0, ISBN_10_LEN - 1);
try {
- String checkDigit = isbn13Validator.getCheckDigit().calculate(isbn13);
+ final String checkDigit = isbn13Validator.getCheckDigit().calculate(isbn13);
isbn13 += checkDigit;
return isbn13;
- } catch (CheckDigitException e) {
+ } catch (final CheckDigitException e) {
throw new IllegalArgumentException("Check digit error for '" + input + "' - " + e.getMessage());
}
diff --git a/src/main/java/org/apache/commons/validator/routines/ISINValidator.java b/src/main/java/org/apache/commons/validator/routines/ISINValidator.java
index 165fc756..acdc18b7 100644
--- a/src/main/java/org/apache/commons/validator/routines/ISINValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ISINValidator.java
@@ -77,11 +77,11 @@ public class ISINValidator implements Serializable {
* @param checkCountryCode whether to check the country-code prefix or not
* @return A singleton instance of the appropriate ISIN validator.
*/
- public static ISINValidator getInstance(boolean checkCountryCode) {
+ public static ISINValidator getInstance(final boolean checkCountryCode) {
return checkCountryCode ? ISIN_VALIDATOR_TRUE : ISIN_VALIDATOR_FALSE;
}
- private ISINValidator(boolean checkCountryCode) {
+ private ISINValidator(final boolean checkCountryCode) {
this.checkCountryCode = checkCountryCode;
}
@@ -92,7 +92,7 @@ public class ISINValidator implements Serializable {
* @return <code>true</code> if a valid ISIN
* code, otherwise <code>false</code>.
*/
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
final boolean valid = VALIDATOR.isValid(code);
if (valid && checkCountryCode) {
return checkCode(code.substring(0,2));
@@ -106,7 +106,7 @@ public class ISINValidator implements Serializable {
* @param code The code to validate.
* @return A valid ISIN code if valid, otherwise <code>null</code>.
*/
- public Object validate(String code) {
+ public Object validate(final String code) {
final Object validate = VALIDATOR.validate(code);
if (validate != null && checkCountryCode) {
return checkCode(code.substring(0,2)) ? validate : null;
@@ -114,7 +114,7 @@ public class ISINValidator implements Serializable {
return validate;
}
- private boolean checkCode(String code) {
+ private boolean checkCode(final String code) {
return Arrays.binarySearch(CCODES, code) >= 0
||
Arrays.binarySearch(SPECIALS, code) >= 0
diff --git a/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java b/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java
index 0588c800..06263dcb 100644
--- a/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java
@@ -99,7 +99,7 @@ public class ISSNValidator implements Serializable {
* @return A valid EAN code if valid, otherwise <code>null</code>.
* @since 1.7
*/
- public Object validateEan(String code) {
+ public Object validateEan(final String code) {
return EAN_VALIDATOR.validate(code);
}
@@ -110,7 +110,7 @@ public class ISSNValidator implements Serializable {
* @return <code>true</code> if a valid ISSN
* code, otherwise <code>false</code>.
*/
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
return VALIDATOR.isValid(code);
}
@@ -123,7 +123,7 @@ public class ISSNValidator implements Serializable {
* @param code The code to validate.
* @return A valid ISSN code if valid, otherwise <code>null</code>.
*/
- public Object validate(String code) {
+ public Object validate(final String code) {
return VALIDATOR.validate(code);
}
@@ -140,13 +140,13 @@ public class ISSNValidator implements Serializable {
* @return A converted EAN-13 code or <code>null</code>
* if the input ISSN code is not valid
*/
- public String convertToEAN13(String issn, String suffix) {
+ public String convertToEAN13(final String issn, final String suffix) {
if (suffix == null || !suffix.matches("\\d\\d")) {
throw new IllegalArgumentException("Suffix must be two digits: '" + suffix + "'");
}
- Object result = validate(issn);
+ final Object result = validate(issn);
if (result == null) {
return null;
}
@@ -155,10 +155,10 @@ public class ISSNValidator implements Serializable {
final String input = result.toString();
String ean13 = ISSN_PREFIX + input.substring(0, input.length() -1) + suffix;
try {
- String checkDigit = EAN13CheckDigit.EAN13_CHECK_DIGIT.calculate(ean13);
+ final String checkDigit = EAN13CheckDigit.EAN13_CHECK_DIGIT.calculate(ean13);
ean13 += checkDigit;
return ean13;
- } catch (CheckDigitException e) { // Should not happen
+ } catch (final CheckDigitException e) { // Should not happen
throw new IllegalArgumentException("Check digit error for '" + ean13 + "' - " + e.getMessage());
}
@@ -176,7 +176,7 @@ public class ISSNValidator implements Serializable {
* if the input ISSN EAN-13 code is not valid
* @since 1.7
*/
- public String extractFromEAN13(String ean13) {
+ public String extractFromEAN13(final String ean13) {
String input = ean13.trim();
if (input.length() != EAN_ISSN_LEN ) {
throw new IllegalArgumentException("Invalid length " + input.length() + " for '" + input + "'");
@@ -184,7 +184,7 @@ public class ISSNValidator implements Serializable {
if (!input.startsWith(ISSN_PREFIX)) {
throw new IllegalArgumentException("Prefix must be " + ISSN_PREFIX + " to contain an ISSN: '" + ean13 + "'");
}
- Object result = validateEan(input);
+ final Object result = validateEan(input);
if (result == null) {
return null;
}
@@ -192,12 +192,12 @@ public class ISSNValidator implements Serializable {
input = result.toString();
try {
//CHECKSTYLE:OFF: MagicNumber
- String issnBase = input.substring(3,10); // TODO: how to derive these
+ final String issnBase = input.substring(3,10); // TODO: how to derive these
//CHECKSTYLE:ON: MagicNumber
- String checkDigit = ISSNCheckDigit.ISSN_CHECK_DIGIT.calculate(issnBase);
- String issn = issnBase + checkDigit;
+ final String checkDigit = ISSNCheckDigit.ISSN_CHECK_DIGIT.calculate(issnBase);
+ final String issn = issnBase + checkDigit;
return issn;
- } catch (CheckDigitException e) { // Should not happen
+ } catch (final CheckDigitException e) { // Should not happen
throw new IllegalArgumentException("Check digit error for '" + ean13 + "' - " + e.getMessage());
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
index 6ef8241b..5830a3a9 100644
--- a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
@@ -76,7 +76,7 @@ public class InetAddressValidator implements Serializable {
* @param inetAddress the string to validate
* @return true if the string validates as an IP address
*/
- public boolean isValid(String inetAddress) {
+ public boolean isValid(final String inetAddress) {
return isValidInet4Address(inetAddress) || isValidInet6Address(inetAddress);
}
@@ -85,16 +85,16 @@ public class InetAddressValidator implements Serializable {
* @param inet4Address the IPv4 address to validate
* @return true if the argument contains a valid IPv4 address
*/
- public boolean isValidInet4Address(String inet4Address) {
+ public boolean isValidInet4Address(final String inet4Address) {
// verify that address conforms to generic IPv4 format
- String[] groups = ipv4Validator.match(inet4Address);
+ final String[] groups = ipv4Validator.match(inet4Address);
if (groups == null) {
return false;
}
// verify that address subgroups are legal
- for (String ipSegment : groups) {
+ for (final String ipSegment : groups) {
if (ipSegment == null || ipSegment.isEmpty()) {
return false;
}
@@ -103,7 +103,7 @@ public class InetAddressValidator implements Serializable {
try {
iIpSegment = Integer.parseInt(ipSegment);
- } catch(NumberFormatException e) {
+ } catch(final NumberFormatException e) {
return false;
}
@@ -138,7 +138,7 @@ public class InetAddressValidator implements Serializable {
if (!parts[1].matches("\\d{1,3}")) {
return false; // not a valid number
}
- int bits = Integer.parseInt(parts[1]); // cannot fail because of RE check
+ final int bits = Integer.parseInt(parts[1]); // cannot fail because of RE check
if (bits < 0 || bits > MAX_BYTE) {
return false; // out of range
}
@@ -154,7 +154,7 @@ public class InetAddressValidator implements Serializable {
return false; // invalid id
}
inet6Address = parts[0];
- boolean containsCompressedZeroes = inet6Address.contains("::");
+ final boolean containsCompressedZeroes = inet6Address.contains("::");
if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) {
return false;
}
@@ -164,7 +164,7 @@ public class InetAddressValidator implements Serializable {
}
String[] octets = inet6Address.split(":");
if (containsCompressedZeroes) {
- List<String> octetList = new ArrayList<>(Arrays.asList(octets));
+ final List<String> octetList = new ArrayList<>(Arrays.asList(octets));
if (inet6Address.endsWith("::")) {
// String.split() drops ending empty segments
octetList.add("");
@@ -179,7 +179,7 @@ public class InetAddressValidator implements Serializable {
int validOctets = 0;
int emptyOctets = 0; // consecutive empty chunks
for (int index = 0; index < octets.length; index++) {
- String octet = octets[index];
+ final String octet = octets[index];
if (octet.isEmpty()) {
emptyOctets++;
if (emptyOctets > 1) {
@@ -201,7 +201,7 @@ public class InetAddressValidator implements Serializable {
int octetInt = 0;
try {
octetInt = Integer.parseInt(octet, BASE_16);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return false;
}
if (octetInt < 0 || octetInt > MAX_UNSIGNED_SHORT) {
diff --git a/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java b/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java
index c80d0fe9..b7115819 100644
--- a/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java
@@ -104,7 +104,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public IntegerValidator(boolean strict, int formatType) {
+ public IntegerValidator(final boolean strict, final int formatType) {
super(strict, formatType, false);
}
@@ -116,7 +116,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return The parsed <code>Integer</code> if valid or <code>null</code>
* if invalid.
*/
- public Integer validate(String value) {
+ public Integer validate(final String value) {
return (Integer)parse(value, (String)null, (Locale)null);
}
@@ -128,7 +128,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Integer</code> if valid or <code>null</code> if invalid.
*/
- public Integer validate(String value, String pattern) {
+ public Integer validate(final String value, final String pattern) {
return (Integer)parse(value, pattern, (Locale)null);
}
@@ -140,7 +140,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>Integer</code> if valid or <code>null</code> if invalid.
*/
- public Integer validate(String value, Locale locale) {
+ public Integer validate(final String value, final Locale locale) {
return (Integer)parse(value, (String)null, locale);
}
@@ -154,7 +154,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Integer</code> if valid or <code>null</code> if invalid.
*/
- public Integer validate(String value, String pattern, Locale locale) {
+ public Integer validate(final String value, final String pattern, final Locale locale) {
return (Integer)parse(value, pattern, locale);
}
@@ -167,7 +167,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(int value, int min, int max) {
+ public boolean isInRange(final int value, final int min, final int max) {
return (value >= min && value <= max);
}
@@ -180,7 +180,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Integer value, int min, int max) {
+ public boolean isInRange(final Integer value, final int min, final int max) {
return isInRange(value.intValue(), min, max);
}
@@ -192,7 +192,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(int value, int min) {
+ public boolean minValue(final int value, final int min) {
return (value >= min);
}
@@ -204,7 +204,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Integer value, int min) {
+ public boolean minValue(final Integer value, final int min) {
return minValue(value.intValue(), min);
}
@@ -216,7 +216,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(int value, int max) {
+ public boolean maxValue(final int value, final int max) {
return (value <= max);
}
@@ -228,7 +228,7 @@ public class IntegerValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Integer value, int max) {
+ public boolean maxValue(final Integer value, final int max) {
return maxValue(value.intValue(), max);
}
@@ -242,11 +242,11 @@ public class IntegerValidator extends AbstractNumberValidator {
* <code>Integer</code> if valid or <code>null</code> if invalid.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
// Parsed value will be Long if it fits in a long and is not fractional
if (value instanceof Long) {
- long longValue = ((Long)value).longValue();
+ final long longValue = ((Long)value).longValue();
if (longValue >= Integer.MIN_VALUE &&
longValue <= Integer.MAX_VALUE) {
return Integer.valueOf((int)longValue);
diff --git a/src/main/java/org/apache/commons/validator/routines/LongValidator.java b/src/main/java/org/apache/commons/validator/routines/LongValidator.java
index 9aa96572..8971e7b8 100644
--- a/src/main/java/org/apache/commons/validator/routines/LongValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/LongValidator.java
@@ -103,7 +103,7 @@ public class LongValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public LongValidator(boolean strict, int formatType) {
+ public LongValidator(final boolean strict, final int formatType) {
super(strict, formatType, false);
}
@@ -115,7 +115,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return The parsed <code>Long</code> if valid or <code>null</code>
* if invalid.
*/
- public Long validate(String value) {
+ public Long validate(final String value) {
return (Long)parse(value, (String)null, (Locale)null);
}
@@ -127,7 +127,7 @@ public class LongValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Long</code> if valid or <code>null</code> if invalid.
*/
- public Long validate(String value, String pattern) {
+ public Long validate(final String value, final String pattern) {
return (Long)parse(value, pattern, (Locale)null);
}
@@ -139,7 +139,7 @@ public class LongValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>Long</code> if valid or <code>null</code> if invalid.
*/
- public Long validate(String value, Locale locale) {
+ public Long validate(final String value, final Locale locale) {
return (Long)parse(value, (String)null, locale);
}
@@ -153,7 +153,7 @@ public class LongValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Long</code> if valid or <code>null</code> if invalid.
*/
- public Long validate(String value, String pattern, Locale locale) {
+ public Long validate(final String value, final String pattern, final Locale locale) {
return (Long)parse(value, pattern, locale);
}
@@ -166,7 +166,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(long value, long min, long max) {
+ public boolean isInRange(final long value, final long min, final long max) {
return (value >= min && value <= max);
}
@@ -179,7 +179,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Long value, long min, long max) {
+ public boolean isInRange(final Long value, final long min, final long max) {
return isInRange(value.longValue(), min, max);
}
@@ -191,7 +191,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(long value, long min) {
+ public boolean minValue(final long value, final long min) {
return (value >= min);
}
@@ -203,7 +203,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Long value, long min) {
+ public boolean minValue(final Long value, final long min) {
return minValue(value.longValue(), min);
}
@@ -215,7 +215,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(long value, long max) {
+ public boolean maxValue(final long value, final long max) {
return (value <= max);
}
@@ -227,7 +227,7 @@ public class LongValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Long value, long max) {
+ public boolean maxValue(final Long value, final long max) {
return maxValue(value.longValue(), max);
}
@@ -240,7 +240,7 @@ public class LongValidator extends AbstractNumberValidator {
* <code>Long</code>.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
// Parsed value will be Long if it fits in a long and is not fractional
if (value instanceof Long) {
diff --git a/src/main/java/org/apache/commons/validator/routines/PercentValidator.java b/src/main/java/org/apache/commons/validator/routines/PercentValidator.java
index 05dd1ded..742c58e9 100644
--- a/src/main/java/org/apache/commons/validator/routines/PercentValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/PercentValidator.java
@@ -77,7 +77,7 @@ public class PercentValidator extends BigDecimalValidator {
* @param strict <code>true</code> if strict
* <code>Format</code> parsing should be used.
*/
- public PercentValidator(boolean strict) {
+ public PercentValidator(final boolean strict) {
super(strict, PERCENT_FORMAT, true);
}
@@ -95,7 +95,7 @@ public class PercentValidator extends BigDecimalValidator {
* @return The parsed value if valid or <code>null</code> if invalid.
*/
@Override
- protected Object parse(String value, Format formatter) {
+ protected Object parse(final String value, final Format formatter) {
// Initial parse of the value
BigDecimal parsedValue = (BigDecimal)super.parse(value, formatter);
@@ -104,10 +104,10 @@ public class PercentValidator extends BigDecimalValidator {
}
// Re-parse using a pattern without the percent symbol
- DecimalFormat decimalFormat = (DecimalFormat)formatter;
- String pattern = decimalFormat.toPattern();
+ final DecimalFormat decimalFormat = (DecimalFormat)formatter;
+ final String pattern = decimalFormat.toPattern();
if (pattern.indexOf(PERCENT_SYMBOL) >= 0) {
- StringBuilder buffer = new StringBuilder(pattern.length());
+ final StringBuilder buffer = new StringBuilder(pattern.length());
for (int i = 0; i < pattern.length(); i++) {
if (pattern.charAt(i) != PERCENT_SYMBOL) {
buffer.append(pattern.charAt(i));
diff --git a/src/main/java/org/apache/commons/validator/routines/RegexValidator.java b/src/main/java/org/apache/commons/validator/routines/RegexValidator.java
index 79d7feff..e8ba422b 100644
--- a/src/main/java/org/apache/commons/validator/routines/RegexValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/RegexValidator.java
@@ -80,7 +80,7 @@ public class RegexValidator implements Serializable {
* @param regex The regular expression this validator will
* validate against
*/
- public RegexValidator(String regex) {
+ public RegexValidator(final String regex) {
this(regex, true);
}
@@ -93,7 +93,7 @@ public class RegexValidator implements Serializable {
* @param caseSensitive when <code>true</code> matching is <i>case
* sensitive</i>, otherwise matching is <i>case in-sensitive</i>
*/
- public RegexValidator(String regex, boolean caseSensitive) {
+ public RegexValidator(final String regex, final boolean caseSensitive) {
this(new String[] {regex}, caseSensitive);
}
@@ -104,7 +104,7 @@ public class RegexValidator implements Serializable {
* @param regexs The set of regular expressions this validator will
* validate against
*/
- public RegexValidator(String[] regexs) {
+ public RegexValidator(final String[] regexs) {
this(regexs, true);
}
@@ -117,12 +117,12 @@ public class RegexValidator implements Serializable {
* @param caseSensitive when <code>true</code> matching is <i>case
* sensitive</i>, otherwise matching is <i>case in-sensitive</i>
*/
- public RegexValidator(String[] regexs, boolean caseSensitive) {
+ public RegexValidator(final String[] regexs, final boolean caseSensitive) {
if (regexs == null || regexs.length == 0) {
throw new IllegalArgumentException("Regular expressions are missing");
}
patterns = new Pattern[regexs.length];
- int flags = (caseSensitive ? 0: Pattern.CASE_INSENSITIVE);
+ final int flags = (caseSensitive ? 0: Pattern.CASE_INSENSITIVE);
for (int i = 0; i < regexs.length; i++) {
if (regexs[i] == null || regexs[i].isEmpty()) {
throw new IllegalArgumentException("Regular expression[" + i + "] is missing");
@@ -138,11 +138,11 @@ public class RegexValidator implements Serializable {
* @return <code>true</code> if the value is valid
* otherwise <code>false</code>.
*/
- public boolean isValid(String value) {
+ public boolean isValid(final String value) {
if (value == null) {
return false;
}
- for (Pattern pattern : patterns) {
+ for (final Pattern pattern : patterns) {
if (pattern.matcher(value).matches()) {
return true;
}
@@ -158,15 +158,15 @@ public class RegexValidator implements Serializable {
* @return String array of the <i>groups</i> matched if
* valid or <code>null</code> if invalid
*/
- public String[] match(String value) {
+ public String[] match(final String value) {
if (value == null) {
return null;
}
- for (Pattern pattern : patterns) {
- Matcher matcher = pattern.matcher(value);
+ for (final Pattern pattern : patterns) {
+ final Matcher matcher = pattern.matcher(value);
if (matcher.matches()) {
- int count = matcher.groupCount();
- String[] groups = new String[count];
+ final int count = matcher.groupCount();
+ final String[] groups = new String[count];
for (int j = 0; j < count; j++) {
groups[j] = matcher.group(j+1);
}
@@ -185,20 +185,20 @@ public class RegexValidator implements Serializable {
* @return Aggregated String value comprised of the
* <i>groups</i> matched if valid or <code>null</code> if invalid
*/
- public String validate(String value) {
+ public String validate(final String value) {
if (value == null) {
return null;
}
- for (Pattern pattern : patterns) {
- Matcher matcher = pattern.matcher(value);
+ for (final Pattern pattern : patterns) {
+ final Matcher matcher = pattern.matcher(value);
if (matcher.matches()) {
- int count = matcher.groupCount();
+ final int count = matcher.groupCount();
if (count == 1) {
return matcher.group(1);
}
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
for (int j = 0; j < count; j++) {
- String component = matcher.group(j+1);
+ final String component = matcher.group(j+1);
if (component != null) {
buffer.append(component);
}
@@ -215,7 +215,7 @@ public class RegexValidator implements Serializable {
*/
@Override
public String toString() {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
buffer.append("RegexValidator{");
for (int i = 0; i < patterns.length; i++) {
if (i > 0) {
diff --git a/src/main/java/org/apache/commons/validator/routines/ShortValidator.java b/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
index 80517b28..92b1a940 100644
--- a/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
@@ -104,7 +104,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @param formatType The <code>NumberFormat</code> type to
* create for validation, default is STANDARD_FORMAT.
*/
- public ShortValidator(boolean strict, int formatType) {
+ public ShortValidator(final boolean strict, final int formatType) {
super(strict, formatType, false);
}
@@ -116,7 +116,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return The parsed <code>Short</code> if valid or <code>null</code>
* if invalid.
*/
- public Short validate(String value) {
+ public Short validate(final String value) {
return (Short)parse(value, (String)null, (Locale)null);
}
@@ -128,7 +128,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Short</code> if valid or <code>null</code> if invalid.
*/
- public Short validate(String value, String pattern) {
+ public Short validate(final String value, final String pattern) {
return (Short)parse(value, pattern, (Locale)null);
}
@@ -140,7 +140,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @param locale The locale to use for the number format, system default if null.
* @return The parsed <code>Short</code> if valid or <code>null</code> if invalid.
*/
- public Short validate(String value, Locale locale) {
+ public Short validate(final String value, final Locale locale) {
return (Short)parse(value, (String)null, locale);
}
@@ -154,7 +154,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Short</code> if valid or <code>null</code> if invalid.
*/
- public Short validate(String value, String pattern, Locale locale) {
+ public Short validate(final String value, final String pattern, final Locale locale) {
return (Short)parse(value, pattern, locale);
}
@@ -167,7 +167,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(short value, short min, short max) {
+ public boolean isInRange(final short value, final short min, final short max) {
return (value >= min && value <= max);
}
@@ -180,7 +180,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is within the
* specified range.
*/
- public boolean isInRange(Short value, short min, short max) {
+ public boolean isInRange(final Short value, final short min, final short max) {
return isInRange(value.shortValue(), min, max);
}
@@ -192,7 +192,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(short value, short min) {
+ public boolean minValue(final short value, final short min) {
return (value >= min);
}
@@ -204,7 +204,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is greater than
* or equal to the minimum.
*/
- public boolean minValue(Short value, short min) {
+ public boolean minValue(final Short value, final short min) {
return minValue(value.shortValue(), min);
}
@@ -216,7 +216,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(short value, short max) {
+ public boolean maxValue(final short value, final short max) {
return (value <= max);
}
@@ -228,7 +228,7 @@ public class ShortValidator extends AbstractNumberValidator {
* @return <code>true</code> if the value is less than
* or equal to the maximum.
*/
- public boolean maxValue(Short value, short max) {
+ public boolean maxValue(final Short value, final short max) {
return maxValue(value.shortValue(), max);
}
@@ -242,9 +242,9 @@ public class ShortValidator extends AbstractNumberValidator {
* <code>Short</code> if valid or <code>null</code> if invalid.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
- long longValue = ((Number)value).longValue();
+ final long longValue = ((Number)value).longValue();
if (longValue < Short.MIN_VALUE ||
longValue > Short.MAX_VALUE) {
diff --git a/src/main/java/org/apache/commons/validator/routines/TimeValidator.java b/src/main/java/org/apache/commons/validator/routines/TimeValidator.java
index 007e18c7..856598fc 100644
--- a/src/main/java/org/apache/commons/validator/routines/TimeValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/TimeValidator.java
@@ -112,7 +112,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* <code>Format</code> parsing should be used.
* @param timeStyle the time style to use for Locale validation.
*/
- public TimeValidator(boolean strict, int timeStyle) {
+ public TimeValidator(final boolean strict, final int timeStyle) {
super(strict, -1, timeStyle);
}
@@ -124,7 +124,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @return The parsed <code>Calendar</code> if valid or <code>null</code>
* if invalid.
*/
- public Calendar validate(String value) {
+ public Calendar validate(final String value) {
return (Calendar)parse(value, (String)null, (Locale)null, (TimeZone)null);
}
@@ -136,7 +136,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the time, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, TimeZone timeZone) {
+ public Calendar validate(final String value, final TimeZone timeZone) {
return (Calendar)parse(value, (String)null, (Locale)null, timeZone);
}
@@ -148,7 +148,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param pattern The pattern used to validate the value against.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern) {
+ public Calendar validate(final String value, final String pattern) {
return (Calendar)parse(value, pattern, (Locale)null, (TimeZone)null);
}
@@ -161,7 +161,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the time, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern, TimeZone timeZone) {
+ public Calendar validate(final String value, final String pattern, final TimeZone timeZone) {
return (Calendar)parse(value, pattern, (Locale)null, timeZone);
}
@@ -173,7 +173,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param locale The locale to use for the time format, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, Locale locale) {
+ public Calendar validate(final String value, final Locale locale) {
return (Calendar)parse(value, (String)null, locale, (TimeZone)null);
}
@@ -186,7 +186,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the time, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, Locale locale, TimeZone timeZone) {
+ public Calendar validate(final String value, final Locale locale, final TimeZone timeZone) {
return (Calendar)parse(value, (String)null, locale, timeZone);
}
@@ -200,7 +200,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param locale The locale to use for the date format, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern, Locale locale) {
+ public Calendar validate(final String value, final String pattern, final Locale locale) {
return (Calendar)parse(value, pattern, locale, (TimeZone)null);
}
@@ -215,7 +215,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @param timeZone The Time Zone used to parse the date, system default if null.
* @return The parsed <code>Calendar</code> if valid or <code>null</code> if invalid.
*/
- public Calendar validate(String value, String pattern, Locale locale, TimeZone timeZone) {
+ public Calendar validate(final String value, final String pattern, final Locale locale, final TimeZone timeZone) {
return (Calendar)parse(value, pattern, locale, timeZone);
}
@@ -228,7 +228,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* time is less than the seconds and +1 if the first
* time is greater than.
*/
- public int compareTime(Calendar value, Calendar compare) {
+ public int compareTime(final Calendar value, final Calendar compare) {
return compareTime(value, compare, Calendar.MILLISECOND);
}
@@ -241,7 +241,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* parameter's seconds are less than the seconds and +1 if the first
* parameter's seconds are greater than.
*/
- public int compareSeconds(Calendar value, Calendar compare) {
+ public int compareSeconds(final Calendar value, final Calendar compare) {
return compareTime(value, compare, Calendar.SECOND);
}
@@ -254,7 +254,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* parameter's minutes are less than the seconds and +1 if the first
* parameter's minutes are greater than.
*/
- public int compareMinutes(Calendar value, Calendar compare) {
+ public int compareMinutes(final Calendar value, final Calendar compare) {
return compareTime(value, compare, Calendar.MINUTE);
}
@@ -267,7 +267,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* parameter's hour is less than the seconds and +1 if the first
* parameter's hour is greater than.
*/
- public int compareHours(Calendar value, Calendar compare) {
+ public int compareHours(final Calendar value, final Calendar compare) {
return compareTime(value, compare, Calendar.HOUR_OF_DAY);
}
@@ -279,7 +279,7 @@ public class TimeValidator extends AbstractCalendarValidator {
* @return The parsed value converted to a <code>Calendar</code>.
*/
@Override
- protected Object processParsedValue(Object value, Format formatter) {
+ protected Object processParsedValue(final Object value, final Format formatter) {
return ((DateFormat)formatter).getCalendar();
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/UrlValidator.java b/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
index cb138b5d..f8f046b3 100644
--- a/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
@@ -199,7 +199,7 @@ public class UrlValidator implements Serializable {
* be specified. Setting the ALLOW_ALL_SCHEMES option will
* ignore the contents of schemes.
*/
- public UrlValidator(String[] schemes) {
+ public UrlValidator(final String[] schemes) {
this(schemes, 0L);
}
@@ -209,7 +209,7 @@ public class UrlValidator implements Serializable {
* this class. To set multiple options you simply add them together. For example,
* ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.
*/
- public UrlValidator(long options) {
+ public UrlValidator(final long options) {
this(null, null, options);
}
@@ -220,7 +220,7 @@ public class UrlValidator implements Serializable {
* this class. To set multiple options you simply add them together. For example,
* ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.
*/
- public UrlValidator(String[] schemes, long options) {
+ public UrlValidator(final String[] schemes, final long options) {
this(schemes, null, options);
}
@@ -233,7 +233,7 @@ public class UrlValidator implements Serializable {
* <p><code>ALLOW_2_SLASHES + NO_FRAGMENTS</code></p>
* enables both of those options.
*/
- public UrlValidator(RegexValidator authorityValidator, long options) {
+ public UrlValidator(final RegexValidator authorityValidator, final long options) {
this(null, authorityValidator, options);
}
@@ -246,7 +246,7 @@ public class UrlValidator implements Serializable {
* <p><code>ALLOW_2_SLASHES + NO_FRAGMENTS</code></p>
* enables both of those options.
*/
- public UrlValidator(String[] schemes, RegexValidator authorityValidator, long options) {
+ public UrlValidator(final String[] schemes, final RegexValidator authorityValidator, final long options) {
this(schemes, authorityValidator, options, DomainValidator.getInstance(isOn(ALLOW_LOCAL_URLS, options)));
}
@@ -261,7 +261,7 @@ public class UrlValidator implements Serializable {
* @param domainValidator the DomainValidator to use; must agree with ALLOW_LOCAL_URLS setting
* @since 1.7
*/
- public UrlValidator(String[] schemes, RegexValidator authorityValidator, long options, DomainValidator domainValidator) {
+ public UrlValidator(String[] schemes, final RegexValidator authorityValidator, final long options, final DomainValidator domainValidator) {
this.options = options;
if (domainValidator == null) {
throw new IllegalArgumentException("DomainValidator must not be null");
@@ -278,7 +278,7 @@ public class UrlValidator implements Serializable {
schemes = DEFAULT_SCHEMES;
}
allowedSchemes = new HashSet<>(schemes.length);
- for (String scheme : schemes) {
+ for (final String scheme : schemes) {
allowedSchemes.add(scheme.toLowerCase(Locale.ENGLISH));
}
}
@@ -296,7 +296,7 @@ public class UrlValidator implements Serializable {
* value is considered invalid.
* @return true if the url is valid.
*/
- public boolean isValid(String value) {
+ public boolean isValid(final String value) {
if (value == null) {
return false;
}
@@ -304,17 +304,17 @@ public class UrlValidator implements Serializable {
URI uri; // ensure value is a valid URI
try {
uri = new URI(value);
- } catch (URISyntaxException e) {
+ } catch (final URISyntaxException e) {
return false;
}
// OK, perfom additional validation
- String scheme = uri.getScheme();
+ final String scheme = uri.getScheme();
if (!isValidScheme(scheme)) {
return false;
}
- String authority = uri.getRawAuthority();
+ final String authority = uri.getRawAuthority();
if ("file".equals(scheme) && (authority == null || "".equals(authority))) {// Special case - file: allows an empty authority
return true; // this is a local file - nothing more to do here
}
@@ -350,7 +350,7 @@ public class UrlValidator implements Serializable {
* invalid.
* @return true if valid.
*/
- protected boolean isValidScheme(String scheme) {
+ protected boolean isValidScheme(final String scheme) {
if (scheme == null) {
return false;
}
@@ -376,7 +376,7 @@ public class UrlValidator implements Serializable {
* @param authority Authority value to validate, alllows IDN
* @return true if authority (hostname and port) is valid.
*/
- protected boolean isValidAuthority(String authority) {
+ protected boolean isValidAuthority(final String authority) {
if (authority == null) {
return false;
}
@@ -388,44 +388,44 @@ public class UrlValidator implements Serializable {
// convert to ASCII if possible
final String authorityASCII = DomainValidator.unicodeToASCII(authority);
- Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authorityASCII);
+ final Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authorityASCII);
if (!authorityMatcher.matches()) {
return false;
}
// We have to process IPV6 separately because that is parsed in a different group
- String ipv6 = authorityMatcher.group(PARSE_AUTHORITY_IPV6);
+ final String ipv6 = authorityMatcher.group(PARSE_AUTHORITY_IPV6);
if (ipv6 != null) {
- InetAddressValidator inetAddressValidator = InetAddressValidator.getInstance();
+ final InetAddressValidator inetAddressValidator = InetAddressValidator.getInstance();
if (!inetAddressValidator.isValidInet6Address(ipv6)) {
return false;
}
} else {
- String hostLocation = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
+ final String hostLocation = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
// check if authority is hostname or IP address:
// try a hostname first since that's much more likely
if (!this.domainValidator.isValid(hostLocation)) {
// try an IPv4 address
- InetAddressValidator inetAddressValidator = InetAddressValidator.getInstance();
+ final InetAddressValidator inetAddressValidator = InetAddressValidator.getInstance();
if (!inetAddressValidator.isValidInet4Address(hostLocation)) {
// isn't IPv4, so the URL is invalid
return false;
}
}
- String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
+ final String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
if (port != null && !port.isEmpty()) {
try {
- int iPort = Integer.parseInt(port);
+ final int iPort = Integer.parseInt(port);
if (iPort < 0 || iPort > MAX_UNSIGNED_16_BIT_INT) {
return false;
}
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return false; // this can happen for big numbers
}
}
}
- String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
+ final String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
if (extra != null && !extra.trim().isEmpty()){
return false;
}
@@ -438,7 +438,7 @@ public class UrlValidator implements Serializable {
* @param path Path value to validate.
* @return true if path is valid.
*/
- protected boolean isValidPath(String path) {
+ protected boolean isValidPath(final String path) {
if (path == null) {
return false;
}
@@ -449,17 +449,17 @@ public class UrlValidator implements Serializable {
try {
// Don't omit host otherwise leading path may be taken as host if it starts with //
- URI uri = new URI(null,"localhost",path,null);
- String norm = uri.normalize().getPath();
+ final URI uri = new URI(null,"localhost",path,null);
+ final String norm = uri.normalize().getPath();
if (norm.startsWith("/../") // Trying to go via the parent dir
|| norm.equals("/..")) { // Trying to go to the parent dir
return false;
}
- } catch (URISyntaxException e) {
+ } catch (final URISyntaxException e) {
return false;
}
- int slash2Count = countToken("//", path);
+ final int slash2Count = countToken("//", path);
if (isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) {
return false;
}
@@ -472,7 +472,7 @@ public class UrlValidator implements Serializable {
* @param query Query value to validate.
* @return true if query is valid.
*/
- protected boolean isValidQuery(String query) {
+ protected boolean isValidQuery(final String query) {
if (query == null) {
return true;
}
@@ -485,7 +485,7 @@ public class UrlValidator implements Serializable {
* @param fragment Fragment value to validate.
* @return true if fragment is valid.
*/
- protected boolean isValidFragment(String fragment) {
+ protected boolean isValidFragment(final String fragment) {
if (fragment == null) {
return true;
}
@@ -499,7 +499,7 @@ public class UrlValidator implements Serializable {
* @param target Target value to count tokens in.
* @return the number of tokens.
*/
- protected int countToken(String token, String target) {
+ protected int countToken(final String token, final String target) {
int tokenIndex = 0;
int count = 0;
while (tokenIndex != -1) {
@@ -520,7 +520,7 @@ public class UrlValidator implements Serializable {
*
* @return whether the specified flag value is on.
*/
- private boolean isOn(long flag) {
+ private boolean isOn(final long flag) {
return (options & flag) > 0;
}
@@ -533,7 +533,7 @@ public class UrlValidator implements Serializable {
*
* @return whether the specified flag value is on.
*/
- private static boolean isOn(long flag, long options) {
+ private static boolean isOn(final long flag, final long options) {
return (options & flag) > 0;
}
@@ -545,7 +545,7 @@ public class UrlValidator implements Serializable {
*
* @return whether the specified flag value is off.
*/
- private boolean isOff(long flag) {
+ private boolean isOff(final long flag) {
return (options & flag) == 0;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
index c8d082b6..024e45fe 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
@@ -77,8 +77,8 @@ public final class ABANumberCheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
- int weight = POSITION_WEIGHT[rightPos % 3]; // CHECKSTYLE IGNORE MagicNumber
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
+ final int weight = POSITION_WEIGHT[rightPos % 3]; // CHECKSTYLE IGNORE MagicNumber
return charValue * weight;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
index e2eead83..2869bb37 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
@@ -66,9 +66,9 @@ public final class CUSIPCheckDigit extends ModulusCheckDigit {
* @throws CheckDigitException if character is not alphanumeric
*/
@Override
- protected int toInt(char character, int leftPos, int rightPos)
+ protected int toInt(final char character, final int leftPos, final int rightPos)
throws CheckDigitException {
- int charValue = Character.getNumericValue(character);
+ final int charValue = Character.getNumericValue(character);
// the final character is only allowed to reach 9
final int charMax = rightPos == 1 ? 9 : 35; // CHECKSTYLE IGNORE MagicNumber
if (charValue < 0 || charValue > charMax) {
@@ -92,9 +92,9 @@ public final class CUSIPCheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
- int weight = POSITION_WEIGHT[rightPos % 2];
- int weightedValue = (charValue * weight);
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
+ final int weight = POSITION_WEIGHT[rightPos % 2];
+ final int weightedValue = (charValue * weight);
return ModulusCheckDigit.sumDigits(weightedValue);
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/CheckDigitException.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/CheckDigitException.java
index cbbae666..95f079f8 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/CheckDigitException.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/CheckDigitException.java
@@ -37,7 +37,7 @@ public class CheckDigitException extends Exception {
*
* @param msg The error message.
*/
- public CheckDigitException(String msg) {
+ public CheckDigitException(final String msg) {
super(msg);
}
@@ -48,7 +48,7 @@ public class CheckDigitException extends Exception {
* @param msg The error message.
* @param cause The underlying cause of the error
*/
- public CheckDigitException(String msg, Throwable cause) {
+ public CheckDigitException(final String msg, final Throwable cause) {
super(msg, cause);
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
index b5a21661..6e671f34 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
@@ -71,8 +71,8 @@ public final class EAN13CheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
- int weight = POSITION_WEIGHT[rightPos % 2];
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
+ final int weight = POSITION_WEIGHT[rightPos % 2];
return charValue * weight;
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigit.java
index b1106345..f3e3778c 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigit.java
@@ -69,18 +69,18 @@ public final class IBANCheckDigit implements CheckDigit, Serializable {
* <code>false</code>
*/
@Override
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
if (code == null || code.length() < MIN_CODE_LEN) {
return false;
}
- String check = code.substring(2,4); // CHECKSTYLE IGNORE MagicNumber
+ final String check = code.substring(2,4); // CHECKSTYLE IGNORE MagicNumber
if ("00".equals(check) || "01".equals(check) || "99".equals(check)) {
return false;
}
try {
- int modulusResult = calculateModulus(code);
+ final int modulusResult = calculateModulus(code);
return (modulusResult == 1);
- } catch (CheckDigitException ex) {
+ } catch (final CheckDigitException ex) {
return false;
}
}
@@ -103,9 +103,9 @@ public final class IBANCheckDigit implements CheckDigit, Serializable {
(code == null ? 0 : code.length()));
}
code = code.substring(0, 2) + "00" + code.substring(4); // CHECKSTYLE IGNORE MagicNumber
- int modulusResult = calculateModulus(code);
- int charValue = (98 - modulusResult); // CHECKSTYLE IGNORE MagicNumber
- String checkDigit = Integer.toString(charValue);
+ final int modulusResult = calculateModulus(code);
+ final int charValue = (98 - modulusResult); // CHECKSTYLE IGNORE MagicNumber
+ final String checkDigit = Integer.toString(charValue);
return (charValue > 9 ? checkDigit : "0" + checkDigit); // CHECKSTYLE IGNORE MagicNumber
}
@@ -117,11 +117,11 @@ public final class IBANCheckDigit implements CheckDigit, Serializable {
* @throws CheckDigitException if an error occurs calculating the modulus
* for the specified code
*/
- private int calculateModulus(String code) throws CheckDigitException {
- String reformattedCode = code.substring(4) + code.substring(0, 4); // CHECKSTYLE IGNORE MagicNumber
+ private int calculateModulus(final String code) throws CheckDigitException {
+ final String reformattedCode = code.substring(4) + code.substring(0, 4); // CHECKSTYLE IGNORE MagicNumber
long total = 0;
for (int i = 0; i < reformattedCode.length(); i++) {
- int charValue = Character.getNumericValue(reformattedCode.charAt(i));
+ final int charValue = Character.getNumericValue(reformattedCode.charAt(i));
if (charValue < 0 || charValue > MAX_ALPHANUMERIC_VALUE) {
throw new CheckDigitException("Invalid Character[" +
i + "] = '" + charValue + "'");
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
index b59934fc..ed88ac3e 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
@@ -69,7 +69,7 @@ public final class ISBN10CheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
return charValue * rightPos;
}
@@ -86,7 +86,7 @@ public final class ISBN10CheckDigit extends ModulusCheckDigit {
* @throws CheckDigitException if an error occurs.
*/
@Override
- protected int toInt(char character, int leftPos, int rightPos)
+ protected int toInt(final char character, final int leftPos, final int rightPos)
throws CheckDigitException {
if (rightPos == 1 && character == 'X') {
return 10; // CHECKSTYLE IGNORE MagicNumber
@@ -104,7 +104,7 @@ public final class ISBN10CheckDigit extends ModulusCheckDigit {
* @throws CheckDigitException if an error occurs.
*/
@Override
- protected String toCheckDigit(int charValue)
+ protected String toCheckDigit(final int charValue)
throws CheckDigitException {
if (charValue == 10) { // CHECKSTYLE IGNORE MagicNumber
return "X";
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBNCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBNCheckDigit.java
index 3775c1aa..f38328d0 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBNCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBNCheckDigit.java
@@ -64,7 +64,7 @@ public final class ISBNCheckDigit implements CheckDigit, Serializable {
* check digit.
*/
@Override
- public String calculate(String code) throws CheckDigitException {
+ public String calculate(final String code) throws CheckDigitException {
if (code == null || code.isEmpty()) {
throw new CheckDigitException("ISBN Code is missing");
}
@@ -92,7 +92,7 @@ public final class ISBNCheckDigit implements CheckDigit, Serializable {
* a valid ISBN-13 check digit - otherwise <code>false</code>.
*/
@Override
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
if (code == null) {
return false;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
index 84dd3257..dd412251 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
@@ -68,16 +68,16 @@ public final class ISINCheckDigit extends ModulusCheckDigit {
* for the specified code
*/
@Override
- protected int calculateModulus(String code, boolean includesCheckDigit) throws CheckDigitException {
- StringBuilder transformed = new StringBuilder(code.length() * 2); // CHECKSTYLE IGNORE MagicNumber
+ protected int calculateModulus(final String code, final boolean includesCheckDigit) throws CheckDigitException {
+ final StringBuilder transformed = new StringBuilder(code.length() * 2); // CHECKSTYLE IGNORE MagicNumber
if (includesCheckDigit) {
- char checkDigit = code.charAt(code.length()-1); // fetch the last character
+ final char checkDigit = code.charAt(code.length()-1); // fetch the last character
if (!Character.isDigit(checkDigit)){
throw new CheckDigitException("Invalid checkdigit["+ checkDigit+ "] in " + code);
}
}
for (int i = 0; i < code.length(); i++) {
- int charValue = Character.getNumericValue(code.charAt(i));
+ final int charValue = Character.getNumericValue(code.charAt(i));
if (charValue < 0 || charValue > MAX_ALPHANUMERIC_VALUE) {
throw new CheckDigitException("Invalid Character[" +
(i + 1) + "] = '" + charValue + "'");
@@ -103,9 +103,9 @@ public final class ISINCheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
- int weight = POSITION_WEIGHT[rightPos % 2]; // CHECKSTYLE IGNORE MagicNumber
- int weightedValue = charValue * weight;
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
+ final int weight = POSITION_WEIGHT[rightPos % 2]; // CHECKSTYLE IGNORE MagicNumber
+ final int weightedValue = charValue * weight;
return ModulusCheckDigit.sumDigits(weightedValue);
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISSNCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISSNCheckDigit.java
index c34280cb..dc0e19ce 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ISSNCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ISSNCheckDigit.java
@@ -62,12 +62,12 @@ public final class ISSNCheckDigit extends ModulusCheckDigit {
}
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) throws CheckDigitException {
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) throws CheckDigitException {
return charValue * (9 - leftPos); // CHECKSTYLE IGNORE MagicNumber
}
@Override
- protected String toCheckDigit(int charValue) throws CheckDigitException {
+ protected String toCheckDigit(final int charValue) throws CheckDigitException {
if (charValue == 10) { // CHECKSTYLE IGNORE MagicNumber
return "X";
}
@@ -75,7 +75,7 @@ public final class ISSNCheckDigit extends ModulusCheckDigit {
}
@Override
- protected int toInt(char character, int leftPos, int rightPos)
+ protected int toInt(final char character, final int leftPos, final int rightPos)
throws CheckDigitException {
if (rightPos == 1 && character == 'X') {
return 10; // CHECKSTYLE IGNORE MagicNumber
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
index ff81474e..0e628210 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
@@ -68,9 +68,9 @@ public final class LuhnCheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
- int weight = POSITION_WEIGHT[rightPos % 2]; // CHECKSTYLE IGNORE MagicNumber
- int weightedValue = charValue * weight;
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
+ final int weight = POSITION_WEIGHT[rightPos % 2]; // CHECKSTYLE IGNORE MagicNumber
+ final int weightedValue = charValue * weight;
return weightedValue > 9 ? (weightedValue - 9) : weightedValue; // CHECKSTYLE IGNORE MagicNumber
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
index a5c3247e..6157fcbf 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
@@ -46,7 +46,7 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
*
* @param modulus The modulus value to use for the check digit calculation
*/
- public ModulusCheckDigit(int modulus) {
+ public ModulusCheckDigit(final int modulus) {
this.modulus = modulus;
}
@@ -67,14 +67,14 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
* <code>false</code>
*/
@Override
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
if (code == null || code.isEmpty()) {
return false;
}
try {
- int modulusResult = calculateModulus(code, true);
+ final int modulusResult = calculateModulus(code, true);
return (modulusResult == 0);
- } catch (CheckDigitException ex) {
+ } catch (final CheckDigitException ex) {
return false;
}
}
@@ -88,12 +88,12 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
* @throws CheckDigitException if an error occurs calculating the check digit
*/
@Override
- public String calculate(String code) throws CheckDigitException {
+ public String calculate(final String code) throws CheckDigitException {
if (code == null || code.isEmpty()) {
throw new CheckDigitException("Code is missing");
}
- int modulusResult = calculateModulus(code, false);
- int charValue = (modulus - modulusResult) % modulus;
+ final int modulusResult = calculateModulus(code, false);
+ final int charValue = (modulus - modulusResult) % modulus;
return toCheckDigit(charValue);
}
@@ -106,13 +106,13 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
* @throws CheckDigitException if an error occurs calculating the modulus
* for the specified code
*/
- protected int calculateModulus(String code, boolean includesCheckDigit) throws CheckDigitException {
+ protected int calculateModulus(final String code, final boolean includesCheckDigit) throws CheckDigitException {
int total = 0;
for (int i = 0; i < code.length(); i++) {
- int lth = code.length() + (includesCheckDigit ? 0 : 1);
- int leftPos = i + 1;
- int rightPos = lth - i;
- int charValue = toInt(code.charAt(i), leftPos, rightPos);
+ final int lth = code.length() + (includesCheckDigit ? 0 : 1);
+ final int leftPos = i + 1;
+ final int rightPos = lth - i;
+ final int charValue = toInt(code.charAt(i), leftPos, rightPos);
total += weightedValue(charValue, leftPos, rightPos);
}
if (total == 0) {
@@ -155,7 +155,7 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
* @return The integer value of the character
* @throws CheckDigitException if character is non-numeric
*/
- protected int toInt(char character, int leftPos, int rightPos)
+ protected int toInt(final char character, final int leftPos, final int rightPos)
throws CheckDigitException {
if (Character.isDigit(character)) {
return Character.getNumericValue(character);
@@ -176,7 +176,7 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
* @throws CheckDigitException if integer character value
* doesn't represent a numeric character
*/
- protected String toCheckDigit(int charValue)
+ protected String toCheckDigit(final int charValue)
throws CheckDigitException {
if (charValue >= 0 && charValue <= 9) { // CHECKSTYLE IGNORE MagicNumber
return Integer.toString(charValue);
@@ -191,7 +191,7 @@ public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
* @param number The number whose digits are to be added
* @return The sum of the digits
*/
- public static int sumDigits(int number) {
+ public static int sumDigits(final int number) {
int total = 0;
int todo = number;
while (todo > 0) {
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusTenCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusTenCheckDigit.java
index 8134efd2..a586c3b4 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusTenCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusTenCheckDigit.java
@@ -126,7 +126,7 @@ public final class ModulusTenCheckDigit extends ModulusCheckDigit {
* @param postitionWeight the weighted values to apply based on the
* character position
*/
- public ModulusTenCheckDigit(int[] postitionWeight) {
+ public ModulusTenCheckDigit(final int[] postitionWeight) {
this(postitionWeight, false, false);
}
@@ -139,7 +139,7 @@ public final class ModulusTenCheckDigit extends ModulusCheckDigit {
* @param useRightPos <code>true</code> if use positionWeights from right to
* left
*/
- public ModulusTenCheckDigit(int[] postitionWeight, boolean useRightPos) {
+ public ModulusTenCheckDigit(final int[] postitionWeight, final boolean useRightPos) {
this(postitionWeight, useRightPos, false);
}
@@ -155,7 +155,7 @@ public final class ModulusTenCheckDigit extends ModulusCheckDigit {
* @param sumWeightedDigits <code>true</code> if sum the digits of the
* weighted value
*/
- public ModulusTenCheckDigit(int[] postitionWeight, boolean useRightPos, boolean sumWeightedDigits) {
+ public ModulusTenCheckDigit(final int[] postitionWeight, final boolean useRightPos, final boolean sumWeightedDigits) {
super(10); // CHECKSTYLE IGNORE MagicNumber
this.postitionWeight = Arrays.copyOf(postitionWeight, postitionWeight.length);
this.useRightPos = useRightPos;
@@ -172,7 +172,7 @@ public final class ModulusTenCheckDigit extends ModulusCheckDigit {
* <code>false</code>
*/
@Override
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
if (code == null || code.isEmpty()) {
return false;
}
@@ -199,8 +199,8 @@ public final class ModulusTenCheckDigit extends ModulusCheckDigit {
* negative number
*/
@Override
- protected int toInt(char character, int leftPos, int rightPos) throws CheckDigitException {
- int num = Character.getNumericValue(character);
+ protected int toInt(final char character, final int leftPos, final int rightPos) throws CheckDigitException {
+ final int num = Character.getNumericValue(character);
if (num < 0) {
throw new CheckDigitException("Invalid Character[" + leftPos + "] = '" + character + "'");
}
@@ -219,9 +219,9 @@ public final class ModulusTenCheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
- int pos = useRightPos ? rightPos : leftPos;
- int weight = postitionWeight[(pos - 1) % postitionWeight.length];
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
+ final int pos = useRightPos ? rightPos : leftPos;
+ final int weight = postitionWeight[(pos - 1) % postitionWeight.length];
int weightedValue = charValue * weight;
if (sumWeightedDigits) {
weightedValue = ModulusCheckDigit.sumDigits(weightedValue);
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
index 50726a4d..d5c18fd8 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
@@ -68,7 +68,7 @@ public final class SedolCheckDigit extends ModulusCheckDigit {
* for the specified code
*/
@Override
- protected int calculateModulus(String code, boolean includesCheckDigit) throws CheckDigitException {
+ protected int calculateModulus(final String code, final boolean includesCheckDigit) throws CheckDigitException {
if (code.length() > POSITION_WEIGHT.length) {
throw new CheckDigitException("Invalid Code Length = " + code.length());
}
@@ -85,7 +85,7 @@ public final class SedolCheckDigit extends ModulusCheckDigit {
* @return The weighted value of the character.
*/
@Override
- protected int weightedValue(int charValue, int leftPos, int rightPos) {
+ protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
return charValue * POSITION_WEIGHT[leftPos - 1];
}
@@ -99,9 +99,9 @@ public final class SedolCheckDigit extends ModulusCheckDigit {
* @throws CheckDigitException if character is not alphanumeric
*/
@Override
- protected int toInt(char character, int leftPos, int rightPos)
+ protected int toInt(final char character, final int leftPos, final int rightPos)
throws CheckDigitException {
- int charValue = Character.getNumericValue(character);
+ final int charValue = Character.getNumericValue(character);
// the check digit is only allowed to reach 9
final int charMax = rightPos == 1 ? 9 : MAX_ALPHANUMERIC_VALUE; // CHECKSTYLE IGNORE MagicNumber
if (charValue < 0 || charValue > charMax) {
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java
index cc6c7851..c5b50bb8 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java
@@ -74,13 +74,13 @@ public final class VerhoeffCheckDigit implements CheckDigit, Serializable {
* otherwise <code>false</code>
*/
@Override
- public boolean isValid(String code) {
+ public boolean isValid(final String code) {
if (code == null || code.isEmpty()) {
return false;
}
try {
return (calculateChecksum(code, true) == 0);
- } catch (CheckDigitException e) {
+ } catch (final CheckDigitException e) {
return false;
}
}
@@ -94,11 +94,11 @@ public final class VerhoeffCheckDigit implements CheckDigit, Serializable {
* the check digit for the specified code
*/
@Override
- public String calculate(String code) throws CheckDigitException {
+ public String calculate(final String code) throws CheckDigitException {
if (code == null || code.isEmpty()) {
throw new CheckDigitException("Code is missing");
}
- int checksum = calculateChecksum(code, false);
+ final int checksum = calculateChecksum(code, false);
return Integer.toString(INV_TABLE[checksum]);
}
@@ -110,16 +110,16 @@ public final class VerhoeffCheckDigit implements CheckDigit, Serializable {
* @return The checksum value
* @throws CheckDigitException if the code contains an invalid character (i.e. not numeric)
*/
- private int calculateChecksum(String code, boolean includesCheckDigit) throws CheckDigitException {
+ private int calculateChecksum(final String code, final boolean includesCheckDigit) throws CheckDigitException {
int checksum = 0;
for (int i = 0; i < code.length(); i++) {
- int idx = code.length() - (i + 1);
- int num = Character.getNumericValue(code.charAt(idx));
+ final int idx = code.length() - (i + 1);
+ final int num = Character.getNumericValue(code.charAt(idx));
if (num < 0 || num > 9) { // CHECKSTYLE IGNORE MagicNumber
throw new CheckDigitException("Invalid Character[" +
i + "] = '" + ((int)code.charAt(idx)) + "'");
}
- int pos = includesCheckDigit ? i : i + 1;
+ final int pos = includesCheckDigit ? i : i + 1;
checksum = D_TABLE[checksum][P_TABLE[pos % 8][num]]; // CHECKSTYLE IGNORE MagicNumber
}
return checksum;
diff --git a/src/main/java/org/apache/commons/validator/util/Flags.java b/src/main/java/org/apache/commons/validator/util/Flags.java
index 4b2bf335..30550f47 100644
--- a/src/main/java/org/apache/commons/validator/util/Flags.java
+++ b/src/main/java/org/apache/commons/validator/util/Flags.java
@@ -58,7 +58,7 @@ public class Flags implements Serializable, Cloneable {
*
* @param flags collection of boolean flags to represent.
*/
- public Flags(long flags) {
+ public Flags(final long flags) {
this.flags = flags;
}
@@ -79,7 +79,7 @@ public class Flags implements Serializable, Cloneable {
*
* @return whether the specified flag value is on.
*/
- public boolean isOn(long flag) {
+ public boolean isOn(final long flag) {
return (this.flags & flag) == flag;
}
@@ -91,7 +91,7 @@ public class Flags implements Serializable, Cloneable {
*
* @return whether the specified flag value is off.
*/
- public boolean isOff(long flag) {
+ public boolean isOff(final long flag) {
return (this.flags & flag) == 0;
}
@@ -101,7 +101,7 @@ public class Flags implements Serializable, Cloneable {
*
* @param flag Flag value to turn on.
*/
- public void turnOn(long flag) {
+ public void turnOn(final long flag) {
this.flags |= flag;
}
@@ -111,7 +111,7 @@ public class Flags implements Serializable, Cloneable {
*
* @param flag Flag value to turn off.
*/
- public void turnOff(long flag) {
+ public void turnOff(final long flag) {
this.flags &= ~flag;
}
@@ -147,7 +147,7 @@ public class Flags implements Serializable, Cloneable {
public Object clone() {
try {
return super.clone();
- } catch(CloneNotSupportedException e) {
+ } catch(final CloneNotSupportedException e) {
throw new RuntimeException("Couldn't clone Flags object.");
}
}
@@ -160,7 +160,7 @@ public class Flags implements Serializable, Cloneable {
* @return whether the objects are equal.
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (!(obj instanceof Flags)) {
return false;
}
@@ -169,7 +169,7 @@ public class Flags implements Serializable, Cloneable {
return true;
}
- Flags f = (Flags) obj;
+ final Flags f = (Flags) obj;
return this.flags == f.flags;
}
@@ -194,7 +194,7 @@ public class Flags implements Serializable, Cloneable {
*/
@Override
public String toString() {
- StringBuilder bin = new StringBuilder(Long.toBinaryString(this.flags));
+ final StringBuilder bin = new StringBuilder(Long.toBinaryString(this.flags));
for (int i = 64 - bin.length(); i > 0; i--) { // CHECKSTYLE IGNORE MagicNumber
bin.insert(0, "0");
}
diff --git a/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java b/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java
index d063250f..6ef31ac2 100644
--- a/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java
+++ b/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java
@@ -53,21 +53,21 @@ public class ValidatorUtils {
*
* @return The modified value.
*/
- public static String replace(String value, String key, String replaceValue) {
+ public static String replace(String value, final String key, final String replaceValue) {
if (value == null || key == null || replaceValue == null) {
return value;
}
- int pos = value.indexOf(key);
+ final int pos = value.indexOf(key);
if (pos < 0) {
return value;
}
- int length = value.length();
- int start = pos;
- int end = pos + key.length();
+ final int length = value.length();
+ final int start = pos;
+ final int end = pos + key.length();
if (length == key.length()) {
value = replaceValue;
@@ -98,7 +98,7 @@ public class ValidatorUtils {
*
* @return The value of the property.
*/
- public static String getValueAsString(Object bean, String property) {
+ public static String getValueAsString(final Object bean, final String property) {
Object value = null;
try {
@@ -137,15 +137,16 @@ public class ValidatorUtils {
* copyMap() instead.
*/
@Deprecated
- public static FastHashMap copyFastHashMap(FastHashMap map) {
- FastHashMap results = new FastHashMap();
+ public static FastHashMap copyFastHashMap(final FastHashMap map) {
+ final FastHashMap results = new FastHashMap();
@SuppressWarnings("unchecked") // FastHashMap is not generic
+ final
Iterator<Entry<String, ?>> i = map.entrySet().iterator();
while (i.hasNext()) {
- Entry<String, ?> entry = i.next();
- String key = entry.getKey();
- Object value = entry.getValue();
+ final Entry<String, ?> entry = i.next();
+ final String key = entry.getKey();
+ final Object value = entry.getValue();
if (value instanceof Msg) {
results.put(key, ((Msg) value).clone());
@@ -171,14 +172,14 @@ public class ValidatorUtils {
*
* @return A copy of the <code>Map</code> that was passed in.
*/
- public static Map<String, Object> copyMap(Map<String, Object> map) {
- Map<String, Object> results = new HashMap<>();
+ public static Map<String, Object> copyMap(final Map<String, Object> map) {
+ final Map<String, Object> results = new HashMap<>();
- Iterator<Entry<String, Object>> i = map.entrySet().iterator();
+ final Iterator<Entry<String, Object>> i = map.entrySet().iterator();
while (i.hasNext()) {
- Entry<String, Object> entry = i.next();
- String key = entry.getKey();
- Object value = entry.getValue();
+ final Entry<String, Object> entry = i.next();
+ final String key = entry.getKey();
+ final Object value = entry.getValue();
if (value instanceof Msg) {
results.put(key, ((Msg) value).clone());
diff --git a/src/test/java/org/apache/commons/validator/AbstractCommonTest.java b/src/test/java/org/apache/commons/validator/AbstractCommonTest.java
index 86181a0a..fadfda43 100644
--- a/src/test/java/org/apache/commons/validator/AbstractCommonTest.java
+++ b/src/test/java/org/apache/commons/validator/AbstractCommonTest.java
@@ -35,7 +35,7 @@ abstract public class AbstractCommonTest extends TestCase {
*/
protected ValidatorResources resources = null;
- public AbstractCommonTest(String string) {
+ public AbstractCommonTest(final String string) {
super(string);
}
@@ -43,7 +43,7 @@ abstract public class AbstractCommonTest extends TestCase {
* Load <code>ValidatorResources</code> from
* validator-numeric.xml.
*/
- protected void loadResources(String file) throws IOException, SAXException {
+ protected void loadResources(final String file) throws IOException, SAXException {
// Load resources
try (InputStream in = this.getClass().getResourceAsStream(file)) {
resources = new ValidatorResources(in);
diff --git a/src/test/java/org/apache/commons/validator/AbstractNumberTest.java b/src/test/java/org/apache/commons/validator/AbstractNumberTest.java
index cd0c0f03..2c5af14a 100644
--- a/src/test/java/org/apache/commons/validator/AbstractNumberTest.java
+++ b/src/test/java/org/apache/commons/validator/AbstractNumberTest.java
@@ -39,7 +39,7 @@ abstract public class AbstractNumberTest extends AbstractCommonTest {
protected String ACTION;
- public AbstractNumberTest(String name) {
+ public AbstractNumberTest(final String name) {
super(name);
}
@@ -62,7 +62,7 @@ abstract public class AbstractNumberTest extends AbstractCommonTest {
*/
public void testNumber() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("0");
valueTest(info, true);
}
@@ -72,7 +72,7 @@ abstract public class AbstractNumberTest extends AbstractCommonTest {
*/
public void testNumberFailure() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
valueTest(info, false);
}
@@ -82,10 +82,10 @@ abstract public class AbstractNumberTest extends AbstractCommonTest {
* @param info Value to run test on.
* @param passed Whether or not the test is expected to pass.
*/
- protected void valueTest(Object info, boolean passed) throws ValidatorException {
+ protected void valueTest(final Object info, final boolean passed) throws ValidatorException {
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -95,11 +95,11 @@ abstract public class AbstractNumberTest extends AbstractCommonTest {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult result = results.getValidatorResult("value");
+ final ValidatorResult result = results.getValidatorResult("value");
assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION + "' action.", result.containsAction(ACTION));
diff --git a/src/test/java/org/apache/commons/validator/ByteTest.java b/src/test/java/org/apache/commons/validator/ByteTest.java
index 741f0ae4..e3e6bf3c 100644
--- a/src/test/java/org/apache/commons/validator/ByteTest.java
+++ b/src/test/java/org/apache/commons/validator/ByteTest.java
@@ -25,7 +25,7 @@ package org.apache.commons.validator;
*/
public class ByteTest extends AbstractNumberTest {
- public ByteTest(String name) {
+ public ByteTest(final String name) {
super(name);
ACTION = "byte";
FORM_KEY = "byteForm";
@@ -36,7 +36,7 @@ public class ByteTest extends AbstractNumberTest {
*/
public void testByte() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("0");
valueTest(info, true);
@@ -47,7 +47,7 @@ public class ByteTest extends AbstractNumberTest {
*/
public void testByteMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Byte.toString(Byte.MIN_VALUE));
valueTest(info, true);
@@ -58,7 +58,7 @@ public class ByteTest extends AbstractNumberTest {
*/
public void testByteMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Byte.toString(Byte.MAX_VALUE));
valueTest(info, true);
@@ -69,7 +69,7 @@ public class ByteTest extends AbstractNumberTest {
*/
public void testByteFailure() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
valueTest(info, false);
}
@@ -79,7 +79,7 @@ public class ByteTest extends AbstractNumberTest {
*/
public void testByteBeyondMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Byte.MIN_VALUE + "1");
valueTest(info, false);
@@ -90,7 +90,7 @@ public class ByteTest extends AbstractNumberTest {
*/
public void testByteBeyondMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Byte.MAX_VALUE + "1");
valueTest(info, false);
diff --git a/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java b/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java
index 4680c4c5..18c2fc5e 100644
--- a/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java
@@ -37,7 +37,7 @@ public class CreditCardValidatorTest extends TestCase {
/**
* Constructor for CreditCardValidatorTest.
*/
- public CreditCardValidatorTest(String name) {
+ public CreditCardValidatorTest(final String name) {
super(name);
}
@@ -62,7 +62,7 @@ public class CreditCardValidatorTest extends TestCase {
}
public void testAddAllowedCardType() {
- CreditCardValidator ccv = new CreditCardValidator(CreditCardValidator.NONE);
+ final CreditCardValidator ccv = new CreditCardValidator(CreditCardValidator.NONE);
// Turned off all cards so even valid numbers should fail
assertFalse(ccv.isValid(VALID_VISA));
assertFalse(ccv.isValid(VALID_AMEX));
@@ -80,8 +80,8 @@ public class CreditCardValidatorTest extends TestCase {
private static class DinersClub implements CreditCardValidator.CreditCardType {
private static final String PREFIX = "300,301,302,303,304,305,";
@Override
- public boolean matches(String card) {
- String prefix = card.substring(0, 3) + ",";
+ public boolean matches(final String card) {
+ final String prefix = card.substring(0, 3) + ",";
return ((PREFIX.contains(prefix)) && (card.length() == 14));
}
}
diff --git a/src/test/java/org/apache/commons/validator/CustomValidatorResourcesTest.java b/src/test/java/org/apache/commons/validator/CustomValidatorResourcesTest.java
index 9f5448ef..b899e38a 100644
--- a/src/test/java/org/apache/commons/validator/CustomValidatorResourcesTest.java
+++ b/src/test/java/org/apache/commons/validator/CustomValidatorResourcesTest.java
@@ -31,7 +31,7 @@ public class CustomValidatorResourcesTest extends TestCase {
* Construct a test case with the specified name.
* @param name Name of the test
*/
- public CustomValidatorResourcesTest(String name) {
+ public CustomValidatorResourcesTest(final String name) {
super(name);
}
@@ -57,14 +57,14 @@ public class CustomValidatorResourcesTest extends TestCase {
InputStream in = null;
try {
in = this.getClass().getResourceAsStream("TestNumber-config.xml");
- } catch(Exception e) {
+ } catch(final Exception e) {
fail("Error loading resources: " + e);
} finally {
try {
if (in != null) {
in.close();
}
- } catch(Exception e) {
+ } catch(final Exception e) {
}
}
}
diff --git a/src/test/java/org/apache/commons/validator/DateTest.java b/src/test/java/org/apache/commons/validator/DateTest.java
index 072afe03..667b8108 100644
--- a/src/test/java/org/apache/commons/validator/DateTest.java
+++ b/src/test/java/org/apache/commons/validator/DateTest.java
@@ -40,7 +40,7 @@ public class DateTest extends AbstractCommonTest {
protected String ACTION = "date";
- public DateTest(String name) {
+ public DateTest(final String name) {
super(name);
}
@@ -59,7 +59,7 @@ public class DateTest extends AbstractCommonTest {
*/
public void testValidDate() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("12/01/2005");
valueTest(info, true);
}
@@ -69,7 +69,7 @@ public class DateTest extends AbstractCommonTest {
*/
public void testInvalidDate() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("12/01as/2005");
valueTest(info, false);
}
@@ -81,10 +81,10 @@ public class DateTest extends AbstractCommonTest {
* @param info Value to run test on.
* @param passed Whether or not the test is expected to pass.
*/
- protected void valueTest(Object info, boolean passed) throws ValidatorException {
+ protected void valueTest(final Object info, final boolean passed) throws ValidatorException {
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -95,11 +95,11 @@ public class DateTest extends AbstractCommonTest {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult result = results.getValidatorResult("value");
+ final ValidatorResult result = results.getValidatorResult("value");
assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION + "' action.", result.containsAction(ACTION));
diff --git a/src/test/java/org/apache/commons/validator/DoubleTest.java b/src/test/java/org/apache/commons/validator/DoubleTest.java
index 111c6708..428563fb 100644
--- a/src/test/java/org/apache/commons/validator/DoubleTest.java
+++ b/src/test/java/org/apache/commons/validator/DoubleTest.java
@@ -24,7 +24,7 @@ package org.apache.commons.validator;
*/
public class DoubleTest extends AbstractNumberTest {
- public DoubleTest(String name) {
+ public DoubleTest(final String name) {
super(name);
ACTION = "double";
FORM_KEY = "doubleForm";
@@ -36,7 +36,7 @@ public class DoubleTest extends AbstractNumberTest {
*/
public void testDouble() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("0");
valueTest(info, true);
@@ -47,7 +47,7 @@ public class DoubleTest extends AbstractNumberTest {
*/
public void testDoubleMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Double.toString(Double.MIN_VALUE));
valueTest(info, true);
@@ -58,7 +58,7 @@ public class DoubleTest extends AbstractNumberTest {
*/
public void testDoubleMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Double.toString(Double.MAX_VALUE));
valueTest(info, true);
@@ -69,7 +69,7 @@ public class DoubleTest extends AbstractNumberTest {
*/
public void testDoubleFailure() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
valueTest(info, false);
}
diff --git a/src/test/java/org/apache/commons/validator/EmailTest.java b/src/test/java/org/apache/commons/validator/EmailTest.java
index 8091a045..3d9a4498 100644
--- a/src/test/java/org/apache/commons/validator/EmailTest.java
+++ b/src/test/java/org/apache/commons/validator/EmailTest.java
@@ -42,7 +42,7 @@ public class EmailTest extends AbstractCommonTest {
protected static String ACTION = "email";
- public EmailTest(String name) {
+ public EmailTest(final String name) {
super(name);
}
@@ -60,7 +60,7 @@ protected void setUp() throws IOException, SAXException {
*/
public void testEmail() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("jsmith@apache.org");
valueTest(info, true);
@@ -70,7 +70,7 @@ protected void setUp() throws IOException, SAXException {
* Tests the email validation with numeric domains.
*/
public void testEmailWithNumericAddress() throws ValidatorException {
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("someone@[216.109.118.76]");
valueTest(info, true);
info.setValue("someone@yahoo.com");
@@ -82,7 +82,7 @@ protected void setUp() throws IOException, SAXException {
*/
public void testEmailExtension() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("jsmith@apache.org");
valueTest(info, true);
@@ -115,7 +115,7 @@ protected void setUp() throws IOException, SAXException {
*/
public void testEmailWithDash() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("andy.noble@data-workshop.com");
valueTest(info, true);
@@ -136,7 +136,7 @@ protected void setUp() throws IOException, SAXException {
*/
public void testEmailWithDotEnd() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("andy.noble@data-workshop.com.");
valueTest(info, false);
@@ -149,7 +149,7 @@ protected void setUp() throws IOException, SAXException {
*/
public void testEmailWithBogusCharacter() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("andy.noble@\u008fdata-workshop.com");
valueTest(info, false);
@@ -170,7 +170,7 @@ protected void setUp() throws IOException, SAXException {
* Tests the email validation with commas.
*/
public void testEmailWithCommas() throws ValidatorException {
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("joeblow@apa,che.org");
valueTest(info, false);
info.setValue("joeblow@apache.o,rg");
@@ -184,7 +184,7 @@ protected void setUp() throws IOException, SAXException {
* Tests the email validation with spaces.
*/
public void testEmailWithSpaces() throws ValidatorException {
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("joeblow @apache.org");
valueTest(info, false);
info.setValue("joeblow@ apache.org");
@@ -207,7 +207,7 @@ protected void setUp() throws IOException, SAXException {
* (i.e. Ascii chars 0 - 31 and 127)
*/
public void testEmailWithControlChars() {
- EmailValidator validator = new EmailValidator();
+ final EmailValidator validator = new EmailValidator();
for (char c = 0; c < 32; c++) {
assertFalse("Test control char " + ((int)c), validator.isValid("foo" + c + "bar@domain.com"));
}
@@ -219,14 +219,14 @@ protected void setUp() throws IOException, SAXException {
*/
public void testEmailAtTLD() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("m@de");
valueTest(info, false);
- org.apache.commons.validator.routines.EmailValidator validator =
+ final org.apache.commons.validator.routines.EmailValidator validator =
org.apache.commons.validator.routines.EmailValidator.getInstance(true, true);
- boolean result = validator.isValid("m@de");
+ final boolean result = validator.isValid("m@de");
assertTrue("Result should have been true", result);
}
@@ -236,7 +236,7 @@ protected void setUp() throws IOException, SAXException {
* addresses aren't declared valid by default
*/
public void testEmailLocalhost() throws ValidatorException {
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("joe@localhost");
valueTest(info, false);
info.setValue("joe@localhost.localdomain");
@@ -253,7 +253,7 @@ protected void setUp() throws IOException, SAXException {
* @throws ValidatorException
*/
public void _testEmailUserName() throws ValidatorException {
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("joe1blow@apache.org");
valueTest(info, true);
info.setValue("joe$blow@apache.org");
@@ -408,8 +408,8 @@ protected void setUp() throws IOException, SAXException {
* The real solution is to fix the email parsing.
*/
public void _testEmailFromPerl() throws ValidatorException {
- ValueBean info = new ValueBean();
- for (ResultPair element : testEmailFromPerl) {
+ final ValueBean info = new ValueBean();
+ for (final ResultPair element : testEmailFromPerl) {
info.setValue(element.item);
valueTest(info, element.valid);
}
@@ -421,10 +421,10 @@ protected void setUp() throws IOException, SAXException {
* @param info Value to run test on.
* @param passed Whether or not the test is expected to pass.
*/
- private void valueTest(ValueBean info, boolean passed) throws ValidatorException {
+ private void valueTest(final ValueBean info, final boolean passed) throws ValidatorException {
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -434,11 +434,11 @@ protected void setUp() throws IOException, SAXException {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult result = results.getValidatorResult("value");
+ final ValidatorResult result = results.getValidatorResult("value");
assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
assertTrue("Value "+info.getValue()+" ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
diff --git a/src/test/java/org/apache/commons/validator/EntityImportTest.java b/src/test/java/org/apache/commons/validator/EntityImportTest.java
index 4983ebf7..ba6ad579 100644
--- a/src/test/java/org/apache/commons/validator/EntityImportTest.java
+++ b/src/test/java/org/apache/commons/validator/EntityImportTest.java
@@ -27,7 +27,7 @@ import java.util.Locale;
*/
public class EntityImportTest extends AbstractCommonTest {
- public EntityImportTest(String name) {
+ public EntityImportTest(final String name) {
super(name);
}
@@ -35,8 +35,8 @@ public class EntityImportTest extends AbstractCommonTest {
* Tests the entity import loading the <code>byteForm</code> form.
*/
public void testEntityImport() throws Exception {
- URL url = getClass().getResource("EntityImportTest-config.xml");
- ValidatorResources resources = new ValidatorResources(url.toExternalForm());
+ final URL url = getClass().getResource("EntityImportTest-config.xml");
+ final ValidatorResources resources = new ValidatorResources(url.toExternalForm());
assertNotNull("Form should be found", resources.getForm(Locale.getDefault(), "byteForm"));
}
@@ -44,8 +44,8 @@ public class EntityImportTest extends AbstractCommonTest {
* Tests loading ValidatorResources from a URL
*/
public void testParseURL() throws Exception {
- URL url = getClass().getResource("EntityImportTest-config.xml");
- ValidatorResources resources = new ValidatorResources(url);
+ final URL url = getClass().getResource("EntityImportTest-config.xml");
+ final ValidatorResources resources = new ValidatorResources(url);
assertNotNull("Form should be found", resources.getForm(Locale.getDefault(), "byteForm"));
}
}
diff --git a/src/test/java/org/apache/commons/validator/ExceptionTest.java b/src/test/java/org/apache/commons/validator/ExceptionTest.java
index ab9a2c3e..78ec09fe 100644
--- a/src/test/java/org/apache/commons/validator/ExceptionTest.java
+++ b/src/test/java/org/apache/commons/validator/ExceptionTest.java
@@ -38,7 +38,7 @@ public class ExceptionTest extends AbstractCommonTest {
*/
protected static String ACTION = "raiseException";
- public ExceptionTest(String name) {
+ public ExceptionTest(final String name) {
super(name);
}
@@ -57,12 +57,12 @@ public class ExceptionTest extends AbstractCommonTest {
*/
public void testValidatorException() {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("VALIDATOR");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -71,7 +71,7 @@ public class ExceptionTest extends AbstractCommonTest {
try {
validator.validate();
fail("ValidatorException should occur here!");
- } catch (ValidatorException expected) {
+ } catch (final ValidatorException expected) {
assertTrue("VALIDATOR-EXCEPTION".equals(expected.getMessage()));
}
}
@@ -86,12 +86,12 @@ public class ExceptionTest extends AbstractCommonTest {
*/
public void XtestRuntimeException() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("RUNTIME");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -100,7 +100,7 @@ public class ExceptionTest extends AbstractCommonTest {
try {
validator.validate();
//fail("RuntimeException should occur here!");
- } catch (RuntimeException expected) {
+ } catch (final RuntimeException expected) {
fail("RuntimeExceptions should be treated as validation failures in Validator 1.x.");
// This will be true in Validator 2.0
//assertTrue("RUNTIME-EXCEPTION".equals(expected.getMessage()));
@@ -118,12 +118,12 @@ public class ExceptionTest extends AbstractCommonTest {
*/
public void XtestCheckedException() {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("CHECKED");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -133,9 +133,9 @@ public class ExceptionTest extends AbstractCommonTest {
// Tests Validator 1.x exception handling
try {
validator.validate();
- } catch (ValidatorException expected) {
+ } catch (final ValidatorException expected) {
fail("Checked exceptions are not wrapped in ValidatorException in Validator 1.x.");
- } catch (Exception e) {
+ } catch (final Exception e) {
assertTrue("CHECKED-EXCEPTION".equals(e.getMessage()));
}
diff --git a/src/test/java/org/apache/commons/validator/ExtensionTest.java b/src/test/java/org/apache/commons/validator/ExtensionTest.java
index 2b55f86d..00d777b7 100644
--- a/src/test/java/org/apache/commons/validator/ExtensionTest.java
+++ b/src/test/java/org/apache/commons/validator/ExtensionTest.java
@@ -62,7 +62,7 @@ public class ExtensionTest extends TestCase {
* Constructor de ExtensionTest.
* @param arg0
*/
- public ExtensionTest(String arg0) {
+ public ExtensionTest(final String arg0) {
super(arg0);
}
@@ -87,11 +87,11 @@ public class ExtensionTest extends TestCase {
*/
public void testRequired() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
@@ -101,12 +101,12 @@ public class ExtensionTest extends TestCase {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -122,23 +122,23 @@ public class ExtensionTest extends TestCase {
*/
public void testRequiredFirstNameBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -154,23 +154,23 @@ public class ExtensionTest extends TestCase {
*/
public void testRequiredFirstName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -186,23 +186,23 @@ public class ExtensionTest extends TestCase {
*/
public void testRequiredLastNameBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setLastName("");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -218,23 +218,23 @@ public class ExtensionTest extends TestCase {
*/
public void testRequiredLastName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setLastName("Smith");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -251,24 +251,24 @@ public class ExtensionTest extends TestCase {
*/
public void testRequiredName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
name.setLastName("Smith");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -287,23 +287,23 @@ public class ExtensionTest extends TestCase {
public void testOverrideRule() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setLastName("Smith");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY2);
+ final Validator validator = new Validator(resources, FORM_KEY2);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have '" + CHECK_MSG_KEY + " as a key.", firstNameResult.field.getArg(0).getKey().equals(CHECK_MSG_KEY));
@@ -317,8 +317,8 @@ public class ExtensionTest extends TestCase {
*/
public void testOrder() {
- Form form = resources.getForm(ValidatorResources.defaultLocale, FORM_KEY);
- Form form2 = resources.getForm(ValidatorResources.defaultLocale, FORM_KEY2);
+ final Form form = resources.getForm(ValidatorResources.defaultLocale, FORM_KEY);
+ final Form form2 = resources.getForm(ValidatorResources.defaultLocale, FORM_KEY2);
assertNotNull(FORM_KEY + " is null.", form);
assertTrue("There should only be 2 fields in " + FORM_KEY, form.getFields().size() == 2);
diff --git a/src/test/java/org/apache/commons/validator/FieldTest.java b/src/test/java/org/apache/commons/validator/FieldTest.java
index 64ee3aa7..f6127adb 100644
--- a/src/test/java/org/apache/commons/validator/FieldTest.java
+++ b/src/test/java/org/apache/commons/validator/FieldTest.java
@@ -38,7 +38,7 @@ public class FieldTest extends TestCase {
* FieldTest constructor.
* @param name
*/
- public FieldTest(String name) {
+ public FieldTest(final String name) {
super(name);
}
@@ -249,8 +249,8 @@ public class FieldTest extends TestCase {
/**
* Convenience Method - create argument (no name or position specified)
*/
- private Arg createArg(String key) {
- Arg arg = new Arg();
+ private Arg createArg(final String key) {
+ final Arg arg = new Arg();
arg.setKey(key);
return arg;
}
@@ -258,8 +258,8 @@ public class FieldTest extends TestCase {
/**
* Convenience Method - create argument (no name, position specified)
*/
- private Arg createArg(String key, int position) {
- Arg arg = createArg(key);
+ private Arg createArg(final String key, final int position) {
+ final Arg arg = createArg(key);
arg.setPosition(position);
return arg;
}
@@ -267,8 +267,8 @@ public class FieldTest extends TestCase {
/**
* Convenience Method - create argument (name specified, no position)
*/
- private Arg createArg(String key, String name) {
- Arg arg = createArg(key);
+ private Arg createArg(final String key, final String name) {
+ final Arg arg = createArg(key);
arg.setName(name);
return arg;
}
@@ -276,8 +276,8 @@ public class FieldTest extends TestCase {
/**
* Convenience Method - create argument (name & position specified)
*/
- private Arg createArg(String key, String name, int position) {
- Arg arg = createArg(key, name);
+ private Arg createArg(final String key, final String name, final int position) {
+ final Arg arg = createArg(key, name);
arg.setPosition(position);
return arg;
}
diff --git a/src/test/java/org/apache/commons/validator/FloatTest.java b/src/test/java/org/apache/commons/validator/FloatTest.java
index 6cfec4e1..faa962a9 100644
--- a/src/test/java/org/apache/commons/validator/FloatTest.java
+++ b/src/test/java/org/apache/commons/validator/FloatTest.java
@@ -24,7 +24,7 @@ package org.apache.commons.validator;
*/
public class FloatTest extends AbstractNumberTest {
- public FloatTest(String name) {
+ public FloatTest(final String name) {
super(name);
ACTION = "float";
FORM_KEY = "floatForm";
@@ -35,7 +35,7 @@ public class FloatTest extends AbstractNumberTest {
*/
public void testFloat() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("0");
valueTest(info, true);
@@ -46,7 +46,7 @@ public class FloatTest extends AbstractNumberTest {
*/
public void testFloatMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Float.toString(Float.MIN_VALUE));
valueTest(info, true);
@@ -57,7 +57,7 @@ public class FloatTest extends AbstractNumberTest {
*/
public void testFloatMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Float.toString(Float.MAX_VALUE));
valueTest(info, true);
@@ -68,7 +68,7 @@ public class FloatTest extends AbstractNumberTest {
*/
public void testFloatFailure() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
valueTest(info, false);
}
diff --git a/src/test/java/org/apache/commons/validator/GenericTypeValidatorImpl.java b/src/test/java/org/apache/commons/validator/GenericTypeValidatorImpl.java
index a4fbe1c9..9ab6affe 100644
--- a/src/test/java/org/apache/commons/validator/GenericTypeValidatorImpl.java
+++ b/src/test/java/org/apache/commons/validator/GenericTypeValidatorImpl.java
@@ -36,8 +36,8 @@ public class GenericTypeValidatorImpl {
* to a <code>byte</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Byte validateByte(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Byte validateByte(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatByte(value);
}
@@ -51,8 +51,8 @@ public class GenericTypeValidatorImpl {
* to a <code>byte</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Byte validateByte(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Byte validateByte(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatByte(value, locale);
}
@@ -66,8 +66,8 @@ public class GenericTypeValidatorImpl {
* to a <code>short</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Short validateShort(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Short validateShort(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatShort(value);
}
@@ -81,8 +81,8 @@ public class GenericTypeValidatorImpl {
* to a <code>short</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Short validateShort(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Short validateShort(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatShort(value, locale);
}
@@ -96,8 +96,8 @@ public class GenericTypeValidatorImpl {
* to a <code>int</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Integer validateInt(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Integer validateInt(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatInt(value);
}
@@ -111,8 +111,8 @@ public class GenericTypeValidatorImpl {
* to a <code>int</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Integer validateInt(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Integer validateInt(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatInt(value, locale);
}
@@ -126,8 +126,8 @@ public class GenericTypeValidatorImpl {
* to a <code>long</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Long validateLong(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Long validateLong(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatLong(value);
}
@@ -141,8 +141,8 @@ public class GenericTypeValidatorImpl {
* to a <code>long</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Long validateLong(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Long validateLong(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatLong(value, locale);
}
@@ -156,8 +156,8 @@ public class GenericTypeValidatorImpl {
* to a <code>float</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Float validateFloat(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Float validateFloat(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatFloat(value);
}
@@ -171,8 +171,8 @@ public class GenericTypeValidatorImpl {
* to a <code>float</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Float validateFloat(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Float validateFloat(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatFloat(value, locale);
}
@@ -186,8 +186,8 @@ public class GenericTypeValidatorImpl {
* to a <code>double</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Double validateDouble(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Double validateDouble(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatDouble(value);
}
@@ -201,8 +201,8 @@ public class GenericTypeValidatorImpl {
* to a <code>double</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Double validateDouble(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Double validateDouble(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatDouble(value, locale);
}
@@ -216,8 +216,8 @@ public class GenericTypeValidatorImpl {
* to a <code>date</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Date validateDate(Object bean, Field field, Locale locale) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static Date validateDate(final Object bean, final Field field, final Locale locale) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatDate(value, locale);
}
@@ -231,10 +231,10 @@ public class GenericTypeValidatorImpl {
* to a <code>date</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static Date validateDate(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
- String datePattern = field.getVarValue("datePattern");
- String datePatternStrict = field.getVarValue("datePatternStrict");
+ public static Date validateDate(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ final String datePattern = field.getVarValue("datePattern");
+ final String datePatternStrict = field.getVarValue("datePatternStrict");
Date result = null;
if (datePattern != null && !datePattern.isEmpty()) {
diff --git a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
index 16127c76..f1f6ed00 100644
--- a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
@@ -41,7 +41,7 @@ public class GenericTypeValidatorTest extends AbstractCommonTest {
*/
protected static String ACTION = "byte";
- public GenericTypeValidatorTest(String name) {
+ public GenericTypeValidatorTest(final String name) {
super(name);
}
@@ -64,7 +64,7 @@ protected void tearDown() {
*/
public void testType() throws ValidatorException {
// Create bean to run test on.
- TypeBean info = new TypeBean();
+ final TypeBean info = new TypeBean();
info.setByte("12");
info.setShort("129");
info.setInteger("-144");
@@ -74,7 +74,7 @@ protected void tearDown() {
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -84,11 +84,11 @@ protected void tearDown() {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- Map<String, ?> hResultValues = results.getResultValueMap();
+ final Map<String, ?> hResultValues = results.getResultValueMap();
assertTrue("Expecting byte result to be an instance of Byte.", (hResultValues.get("byte") instanceof Byte));
assertTrue("Expecting short result to be an instance of Short.", (hResultValues.get("short") instanceof Short));
@@ -97,8 +97,8 @@ protected void tearDown() {
assertTrue("Expecting float result to be an instance of Float.", (hResultValues.get("float") instanceof Float));
assertTrue("Expecting double result to be an instance of Double.", (hResultValues.get("double") instanceof Double));
- for (String key : hResultValues.keySet()) {
- Object value = hResultValues.get(key);
+ for (final String key : hResultValues.keySet()) {
+ final Object value = hResultValues.get(key);
assertNotNull("value ValidatorResults.getResultValueMap() should not be null.", value);
}
@@ -116,7 +116,7 @@ protected void tearDown() {
*/
public void testUSLocale() throws ValidatorException {
// Create bean to run test on.
- TypeBean info = new TypeBean();
+ final TypeBean info = new TypeBean();
info.setByte("12");
info.setShort("129");
info.setInteger("-144");
@@ -132,7 +132,7 @@ protected void tearDown() {
*/
public void testFRLocale() throws ValidatorException {
// Create bean to run test on.
- TypeBean info = new TypeBean();
+ final TypeBean info = new TypeBean();
info.setByte("12");
info.setShort("-129");
info.setInteger("1443");
@@ -140,7 +140,7 @@ protected void tearDown() {
info.setFloat("12,1555");
info.setDouble("129,1551511111");
info.setDate("21/12/2010");
- Map<String, ?> map = localeTest(info, Locale.FRENCH);
+ final Map<String, ?> map = localeTest(info, Locale.FRENCH);
assertTrue("float value not correct", ((Float)map.get("float")).intValue() == 12);
assertTrue("double value not correct", ((Double)map.get("double")).intValue() == 129);
}
@@ -148,11 +148,11 @@ protected void tearDown() {
/**
* Tests the locale.
*/
- private Map<String, ?> localeTest(TypeBean info, Locale locale) throws ValidatorException {
+ private Map<String, ?> localeTest(final TypeBean info, final Locale locale) throws ValidatorException {
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, "typeLocaleForm");
+ final Validator validator = new Validator(resources, "typeLocaleForm");
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, info);
@@ -163,11 +163,11 @@ protected void tearDown() {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- Map<String, ?> hResultValues = results.getResultValueMap();
+ final Map<String, ?> hResultValues = results.getResultValueMap();
assertTrue("Expecting byte result to be an instance of Byte for locale: "+locale, (hResultValues.get("byte") instanceof Byte));
assertTrue("Expecting short result to be an instance of Short for locale: "+locale, (hResultValues.get("short") instanceof Short));
@@ -177,8 +177,8 @@ protected void tearDown() {
assertTrue("Expecting double result to be an instance of Double for locale: "+locale, (hResultValues.get("double") instanceof Double));
assertTrue("Expecting date result to be an instance of Date for locale: "+locale, (hResultValues.get("date") instanceof Date));
- for (String key : hResultValues.keySet()) {
- Object value = hResultValues.get(key);
+ for (final String key : hResultValues.keySet()) {
+ final Object value = hResultValues.get(key);
assertNotNull("value ValidatorResults.getResultValueMap() should not be null for locale: "+locale, value);
}
diff --git a/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java b/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java
index 358a131a..8b6981bc 100644
--- a/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java
+++ b/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java
@@ -63,8 +63,8 @@ public class GenericValidatorImpl {
* has a length greater than zero, <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateRequired(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateRequired(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return !GenericValidator.isBlankOrNull(value);
}
@@ -78,8 +78,8 @@ public class GenericValidatorImpl {
* to a <code>byte</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateByte(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateByte(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isByte(value);
}
@@ -93,8 +93,8 @@ public class GenericValidatorImpl {
* to a <code>short</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateShort(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateShort(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isShort(value);
}
@@ -108,8 +108,8 @@ public class GenericValidatorImpl {
* to a <code>int</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateInt(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateInt(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isInt(value);
}
@@ -122,8 +122,8 @@ public class GenericValidatorImpl {
* @return boolean If the integer field is greater than zero, returns
* true, otherwise returns false.
*/
- public static boolean validatePositive(Object bean , Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validatePositive(final Object bean , final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericTypeValidator.formatInt(value).intValue() > 0;
}
@@ -137,8 +137,8 @@ public class GenericValidatorImpl {
* to a <code>long</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateLong(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateLong(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isLong(value);
}
@@ -152,8 +152,8 @@ public class GenericValidatorImpl {
* to a <code>float</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateFloat(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateFloat(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isFloat(value);
}
@@ -167,8 +167,8 @@ public class GenericValidatorImpl {
* to a <code>double</code> <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateDouble(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateDouble(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isDouble(value);
}
@@ -182,8 +182,8 @@ public class GenericValidatorImpl {
* <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
- public static boolean validateEmail(Object bean, Field field) {
- String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
+ public static boolean validateEmail(final Object bean, final Field field) {
+ final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
return GenericValidator.isEmail(value);
}
@@ -193,11 +193,11 @@ public class GenericValidatorImpl {
public final static String FIELD_TEST_EQUAL = "EQUAL";
public static boolean validateRequiredIf(
- Object bean,
- Field field,
- Validator validator) {
+ final Object bean,
+ final Field field,
+ final Validator validator) {
- Object form = validator.getParameterValue(Validator.BEAN_PARAM);
+ final Object form = validator.getParameterValue(Validator.BEAN_PARAM);
String value = null;
boolean required = false;
if (isStringOrNull(bean)) {
@@ -215,21 +215,21 @@ public class GenericValidatorImpl {
}
while (!GenericValidator.isBlankOrNull(field.getVarValue("field[" + i + "]"))) {
String dependProp = field.getVarValue("field[" + i + "]");
- String dependTest = field.getVarValue("fieldTest[" + i + "]");
- String dependTestValue = field.getVarValue("fieldValue[" + i + "]");
+ final String dependTest = field.getVarValue("fieldTest[" + i + "]");
+ final String dependTestValue = field.getVarValue("fieldValue[" + i + "]");
String dependIndexed = field.getVarValue("fieldIndexed[" + i + "]");
if (dependIndexed == null) {
dependIndexed = "false";
}
boolean this_required = false;
if (field.isIndexed() && dependIndexed.equalsIgnoreCase("true")) {
- String key = field.getKey();
+ final String key = field.getKey();
if ((key.contains("[")) && (key.contains("]"))) {
- String ind = key.substring(0, key.indexOf(".") + 1);
+ final String ind = key.substring(0, key.indexOf(".") + 1);
dependProp = ind + dependProp;
}
}
- String dependVal = ValidatorUtils.getValueAsString(form, dependProp);
+ final String dependVal = ValidatorUtils.getValueAsString(form, dependProp);
if (dependTest.equals(FIELD_TEST_NULL)) {
if ((dependVal != null) && (!dependVal.isEmpty())) {
this_required = false;
@@ -263,7 +263,7 @@ public class GenericValidatorImpl {
return true;
}
- private static boolean isStringOrNull(Object o) {
+ private static boolean isStringOrNull(final Object o) {
if (o == null) {
return true; // TODO this condition is not exercised by any tests currently
}
diff --git a/src/test/java/org/apache/commons/validator/GenericValidatorTest.java b/src/test/java/org/apache/commons/validator/GenericValidatorTest.java
index df6130a0..e37af506 100644
--- a/src/test/java/org/apache/commons/validator/GenericValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/GenericValidatorTest.java
@@ -28,7 +28,7 @@ public class GenericValidatorTest extends TestCase {
/**
* Constructor for GenericValidatorTest.
*/
- public GenericValidatorTest(String name) {
+ public GenericValidatorTest(final String name) {
super(name);
}
diff --git a/src/test/java/org/apache/commons/validator/ISBNValidatorTest.java b/src/test/java/org/apache/commons/validator/ISBNValidatorTest.java
index 514b5769..b90cc548 100644
--- a/src/test/java/org/apache/commons/validator/ISBNValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/ISBNValidatorTest.java
@@ -33,12 +33,12 @@ public class ISBNValidatorTest extends TestCase {
private static final String VALID_ISBN_X = "0-201-63385-X";
private static final String INVALID_ISBN = "068-556-98-45";
- public ISBNValidatorTest(String name) {
+ public ISBNValidatorTest(final String name) {
super(name);
}
public void testIsValid() throws Exception {
- ISBNValidator validator = new ISBNValidator();
+ final ISBNValidator validator = new ISBNValidator();
assertFalse(validator.isValid(null));
assertFalse(validator.isValid(""));
assertFalse(validator.isValid("1"));
diff --git a/src/test/java/org/apache/commons/validator/IntegerTest.java b/src/test/java/org/apache/commons/validator/IntegerTest.java
index f7133a0b..9a4e641a 100644
--- a/src/test/java/org/apache/commons/validator/IntegerTest.java
+++ b/src/test/java/org/apache/commons/validator/IntegerTest.java
@@ -27,7 +27,7 @@ package org.apache.commons.validator;
public class IntegerTest extends AbstractNumberTest {
- public IntegerTest(String name) {
+ public IntegerTest(final String name) {
super(name);
FORM_KEY = "intForm";
ACTION = "int";
@@ -38,7 +38,7 @@ public class IntegerTest extends AbstractNumberTest {
*/
public void testInt() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("0");
valueTest(info, true);
@@ -49,7 +49,7 @@ public class IntegerTest extends AbstractNumberTest {
*/
public void testIntMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Integer.toString(Integer.MIN_VALUE));
valueTest(info, true);
@@ -60,7 +60,7 @@ public class IntegerTest extends AbstractNumberTest {
*/
public void testIntegerMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Integer.toString(Integer.MAX_VALUE));
valueTest(info, true);
@@ -71,7 +71,7 @@ public class IntegerTest extends AbstractNumberTest {
*/
public void testIntFailure() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
valueTest(info, false);
}
@@ -81,7 +81,7 @@ public class IntegerTest extends AbstractNumberTest {
*/
public void testIntBeyondMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Integer.MIN_VALUE + "1");
valueTest(info, false);
@@ -92,7 +92,7 @@ public class IntegerTest extends AbstractNumberTest {
*/
public void testIntBeyondMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Integer.MAX_VALUE + "1");
valueTest(info, false);
diff --git a/src/test/java/org/apache/commons/validator/LocaleTest.java b/src/test/java/org/apache/commons/validator/LocaleTest.java
index 2d9cda42..e5c537e4 100644
--- a/src/test/java/org/apache/commons/validator/LocaleTest.java
+++ b/src/test/java/org/apache/commons/validator/LocaleTest.java
@@ -41,7 +41,7 @@ public class LocaleTest extends AbstractCommonTest {
*
* @param name param
*/
- public LocaleTest(String name) {
+ public LocaleTest(final String name) {
super(name);
}
@@ -72,7 +72,7 @@ public class LocaleTest extends AbstractCommonTest {
public void testLocale1()
throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("");
@@ -88,7 +88,7 @@ public class LocaleTest extends AbstractCommonTest {
public void testLocale2()
throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("");
@@ -104,7 +104,7 @@ public class LocaleTest extends AbstractCommonTest {
public void testLocale3()
throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("");
@@ -121,7 +121,7 @@ public class LocaleTest extends AbstractCommonTest {
public void testLocale4()
throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("");
@@ -136,7 +136,7 @@ public class LocaleTest extends AbstractCommonTest {
public void testLocale5()
throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("");
@@ -153,12 +153,12 @@ public class LocaleTest extends AbstractCommonTest {
* @param middleGood param
* @throws ValidatorException If something goes wrong
*/
- private void valueTest(Object name, Locale loc, boolean firstGood, boolean lastGood, boolean middleGood)
+ private void valueTest(final Object name, final Locale loc, final boolean firstGood, final boolean lastGood, final boolean middleGood)
throws ValidatorException {
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
@@ -168,13 +168,13 @@ public class LocaleTest extends AbstractCommonTest {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult resultlast = results.getValidatorResult("lastName");
- ValidatorResult resultfirst = results.getValidatorResult("firstName");
- ValidatorResult resultmiddle = results.getValidatorResult("middleName");
+ final ValidatorResult resultlast = results.getValidatorResult("lastName");
+ final ValidatorResult resultfirst = results.getValidatorResult("firstName");
+ final ValidatorResult resultmiddle = results.getValidatorResult("middleName");
if (firstGood) {
assertNull(resultfirst);
diff --git a/src/test/java/org/apache/commons/validator/LongTest.java b/src/test/java/org/apache/commons/validator/LongTest.java
index 8e26537b..56f29ab8 100644
--- a/src/test/java/org/apache/commons/validator/LongTest.java
+++ b/src/test/java/org/apache/commons/validator/LongTest.java
@@ -24,7 +24,7 @@ package org.apache.commons.validator;
*/
public class LongTest extends AbstractNumberTest {
- public LongTest(String name) {
+ public LongTest(final String name) {
super(name);
FORM_KEY = "longForm";
ACTION = "long";
@@ -35,7 +35,7 @@ public class LongTest extends AbstractNumberTest {
*/
public void testLong() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue("0");
valueTest(info, true);
@@ -46,7 +46,7 @@ public class LongTest extends AbstractNumberTest {
*/
public void testLongMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Long.toString(Long.MIN_VALUE));
valueTest(info, true);
@@ -57,7 +57,7 @@ public class LongTest extends AbstractNumberTest {
*/
public void testLongMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Long.toString(Long.MAX_VALUE));
valueTest(info, true);
@@ -68,7 +68,7 @@ public class LongTest extends AbstractNumberTest {
*/
public void testLongFailure() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
valueTest(info, false);
}
@@ -78,7 +78,7 @@ public class LongTest extends AbstractNumberTest {
*/
public void testLongBeyondMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Long.MIN_VALUE + "1");
valueTest(info, false);
@@ -89,7 +89,7 @@ public class LongTest extends AbstractNumberTest {
*/
public void testLongBeyondMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Long.MAX_VALUE + "1");
valueTest(info, false);
diff --git a/src/test/java/org/apache/commons/validator/MultipleConfigFilesTest.java b/src/test/java/org/apache/commons/validator/MultipleConfigFilesTest.java
index 6cfb126e..cdfc732a 100644
--- a/src/test/java/org/apache/commons/validator/MultipleConfigFilesTest.java
+++ b/src/test/java/org/apache/commons/validator/MultipleConfigFilesTest.java
@@ -51,7 +51,7 @@ public class MultipleConfigFilesTest extends TestCase {
* Constructor for MultipleConfigFilesTest.
* @param name
*/
- public MultipleConfigFilesTest(String name) {
+ public MultipleConfigFilesTest(final String name) {
super(name);
}
@@ -60,7 +60,7 @@ public class MultipleConfigFilesTest extends TestCase {
*/
@Override
protected void setUp() throws IOException, SAXException {
- InputStream[] streams =
+ final InputStream[] streams =
{
this.getClass().getResourceAsStream(
"MultipleConfigFilesTest-1-config.xml"),
@@ -69,7 +69,7 @@ public class MultipleConfigFilesTest extends TestCase {
this.resources = new ValidatorResources(streams);
- for (InputStream stream : streams) {
+ for (final InputStream stream : streams) {
stream.close();
}
}
@@ -83,40 +83,40 @@ public class MultipleConfigFilesTest extends TestCase {
// *********** Default Locale *******************
// Check the form from the first config file exists
- Form form1 = resources.getForm("", "", "", "testForm1");
+ final Form form1 = resources.getForm("", "", "", "testForm1");
assertNotNull("Form 'testForm1' not found", form1);
// Check the form from the second config file exists
- Form form2 = resources.getForm("", "", "", "testForm2");
+ final Form form2 = resources.getForm("", "", "", "testForm2");
assertNotNull("Form 'testForm2' not found", form2);
// Check the Constants for the form from the first config file
- Field field1 = form1.getField("testProperty1");
+ final Field field1 = form1.getField("testProperty1");
assertEquals("testProperty1 - const 1", "testConstValue1", field1.getVarValue("var11"));
assertEquals("testProperty1 - const 2", "testConstValue2", field1.getVarValue("var12"));
// Check the Constants for the form from the second config file
- Field field2 = form2.getField("testProperty2");
+ final Field field2 = form2.getField("testProperty2");
assertEquals("testProperty2 - const 1", "testConstValue1", field2.getVarValue("var21"));
assertEquals("testProperty2 - const 2", "testConstValue2", field2.getVarValue("var22"));
// *********** 'fr' locale *******************
// Check the form from the first config file exists
- Form form1_fr = resources.getForm("fr", "", "", "testForm1_fr");
+ final Form form1_fr = resources.getForm("fr", "", "", "testForm1_fr");
assertNotNull("Form 'testForm1_fr' not found", form1_fr);
// Check the form from the second config file exists
- Form form2_fr = resources.getForm("fr", "", "", "testForm2_fr");
+ final Form form2_fr = resources.getForm("fr", "", "", "testForm2_fr");
assertNotNull("Form 'testForm2_fr' not found", form2_fr);
// Check the Constants for the form from the first config file
- Field field1_fr = form1_fr.getField("testProperty1_fr");
+ final Field field1_fr = form1_fr.getField("testProperty1_fr");
assertEquals("testProperty1_fr - const 1", "testConstValue1_fr", field1_fr.getVarValue("var11_fr"));
assertEquals("testProperty1_fr - const 2", "testConstValue2_fr", field1_fr.getVarValue("var12_fr"));
// Check the Constants for the form from the second config file
- Field field2_fr = form2_fr.getField("testProperty2_fr");
+ final Field field2_fr = form2_fr.getField("testProperty2_fr");
assertEquals("testProperty2_fr - const 1", "testConstValue1_fr", field2_fr.getVarValue("var21_fr"));
assertEquals("testProperty2_fr - const 2", "testConstValue2_fr", field2_fr.getVarValue("var22_fr"));
}
@@ -126,11 +126,11 @@ public class MultipleConfigFilesTest extends TestCase {
*/
public void testBothBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
@@ -140,12 +140,12 @@ public class MultipleConfigFilesTest extends TestCase {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull(firstNameResult);
assertTrue(firstNameResult.containsAction(ACTION));
@@ -163,24 +163,24 @@ public class MultipleConfigFilesTest extends TestCase {
public void testRequiredFirstNameBlankLastNameShort()
throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("Test");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull(firstNameResult);
assertTrue(firstNameResult.containsAction(ACTION));
@@ -196,24 +196,24 @@ public class MultipleConfigFilesTest extends TestCase {
*/
public void testRequiredLastNameShort() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Test");
name.setLastName("Test");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull(firstNameResult);
assertTrue(firstNameResult.containsAction(ACTION));
@@ -229,24 +229,24 @@ public class MultipleConfigFilesTest extends TestCase {
*/
public void testRequiredLastNameLong() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
name.setLastName("12345678");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull(firstNameResult);
assertTrue(firstNameResult.containsAction(ACTION));
diff --git a/src/test/java/org/apache/commons/validator/MultipleTest.java b/src/test/java/org/apache/commons/validator/MultipleTest.java
index 903df622..417d55ad 100644
--- a/src/test/java/org/apache/commons/validator/MultipleTest.java
+++ b/src/test/java/org/apache/commons/validator/MultipleTest.java
@@ -40,7 +40,7 @@ public class MultipleTest extends AbstractCommonTest {
- public MultipleTest(String name) {
+ public MultipleTest(final String name) {
super(name);
}
@@ -63,11 +63,11 @@ protected void tearDown() {
*/
public void testBothBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
@@ -77,12 +77,12 @@ protected void tearDown() {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -99,24 +99,24 @@ protected void tearDown() {
*/
public void testRequiredFirstNameBlankLastNameShort() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("Test");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -132,24 +132,24 @@ protected void tearDown() {
*/
public void testRequiredLastNameShort() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Test");
name.setLastName("Test");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -165,24 +165,24 @@ protected void tearDown() {
*/
public void testRequiredLastNameLong() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
name.setLastName("12345678");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -201,21 +201,21 @@ protected void tearDown() {
*/
public void testFailingFirstDependentValidator() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult middleNameResult = results.getValidatorResult("middleName");
+ final ValidatorResult middleNameResult = results.getValidatorResult("middleName");
assertNotNull("Middle Name ValidatorResult should not be null.", middleNameResult);
@@ -236,22 +236,22 @@ protected void tearDown() {
*/
public void testFailingNextDependentValidator() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setMiddleName("TEST");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult middleNameResult = results.getValidatorResult("middleName");
+ final ValidatorResult middleNameResult = results.getValidatorResult("middleName");
assertNotNull("Middle Name ValidatorResult should not be null.", middleNameResult);
@@ -272,22 +272,22 @@ protected void tearDown() {
*/
public void testPassingDependentsFailingMain() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setMiddleName("-2534");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult middleNameResult = results.getValidatorResult("middleName");
+ final ValidatorResult middleNameResult = results.getValidatorResult("middleName");
assertNotNull("Middle Name ValidatorResult should not be null.", middleNameResult);
@@ -309,22 +309,22 @@ protected void tearDown() {
*/
public void testPassingDependentsPassingMain() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setMiddleName("2534");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult middleNameResult = results.getValidatorResult("middleName");
+ final ValidatorResult middleNameResult = results.getValidatorResult("middleName");
assertNotNull("Middle Name ValidatorResult should not be null.", middleNameResult);
diff --git a/src/test/java/org/apache/commons/validator/NameBean.java b/src/test/java/org/apache/commons/validator/NameBean.java
index 24579dd0..32f9894f 100644
--- a/src/test/java/org/apache/commons/validator/NameBean.java
+++ b/src/test/java/org/apache/commons/validator/NameBean.java
@@ -33,7 +33,7 @@ public class NameBean {
return firstName;
}
- public void setFirstName(String firstName) {
+ public void setFirstName(final String firstName) {
this.firstName = firstName;
}
@@ -41,7 +41,7 @@ public class NameBean {
return middleName;
}
- public void setMiddleName(String middleName) {
+ public void setMiddleName(final String middleName) {
this.middleName = middleName;
}
@@ -49,7 +49,7 @@ public class NameBean {
return lastName;
}
- public void setLastName(String lastName) {
+ public void setLastName(final String lastName) {
this.lastName = lastName;
}
diff --git a/src/test/java/org/apache/commons/validator/ParameterTest.java b/src/test/java/org/apache/commons/validator/ParameterTest.java
index 7a6cb606..dfb68f85 100644
--- a/src/test/java/org/apache/commons/validator/ParameterTest.java
+++ b/src/test/java/org/apache/commons/validator/ParameterTest.java
@@ -39,7 +39,7 @@ public class ParameterTest extends AbstractCommonTest {
/**
* Constructor.
*/
- public ParameterTest(String name) {
+ public ParameterTest(final String name) {
super(name);
}
@@ -69,9 +69,9 @@ public class ParameterTest extends AbstractCommonTest {
public void testAllValid() {
// Create bean to run test on.
- NameBean bean = createNameBean();
+ final NameBean bean = createNameBean();
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
@@ -81,7 +81,7 @@ public class ParameterTest extends AbstractCommonTest {
// Get results of the validation.
try {
validator.validate();
- } catch(Exception e) {
+ } catch(final Exception e) {
fail("Validator.validate() threw " + e);
}
assertParameterValue(validator, Validator.BEAN_PARAM, Object.class);
@@ -96,9 +96,9 @@ public class ParameterTest extends AbstractCommonTest {
ValidatorResults.class);
}
- private void assertParameterValue(Validator validator, String name,
- Class<?> type) {
- Object value = validator.getParameterValue(name);
+ private void assertParameterValue(final Validator validator, final String name,
+ final Class<?> type) {
+ final Object value = validator.getParameterValue(name);
assertNotNull("Expected '" + type.getName() + "' but was null", value);
assertTrue("Expected '" + type.getName() + "' but was '" + value.getClass().getName() + "'",
type.isInstance(value));
@@ -108,7 +108,7 @@ public class ParameterTest extends AbstractCommonTest {
* Create a NameBean.
*/
private NameBean createNameBean() {
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName(firstName);
name.setMiddleName(middleName);
name.setLastName(lastName);
diff --git a/src/test/java/org/apache/commons/validator/RequiredIfTest.java b/src/test/java/org/apache/commons/validator/RequiredIfTest.java
index 397ce348..273eb155 100644
--- a/src/test/java/org/apache/commons/validator/RequiredIfTest.java
+++ b/src/test/java/org/apache/commons/validator/RequiredIfTest.java
@@ -38,7 +38,7 @@ public class RequiredIfTest extends AbstractCommonTest {
*/
protected static String ACTION = "requiredif";
- public RequiredIfTest(String name) {
+ public RequiredIfTest(final String name) {
super(name);
}
@@ -62,11 +62,11 @@ protected void tearDown() {
*/
public void testRequired() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
@@ -76,12 +76,12 @@ protected void tearDown() {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -97,24 +97,24 @@ protected void tearDown() {
*/
public void testRequiredFirstNameBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
name.setLastName("Test");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -130,24 +130,24 @@ protected void tearDown() {
*/
public void testRequiredFirstName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Test");
name.setLastName("Test");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -163,24 +163,24 @@ protected void tearDown() {
*/
public void testRequiredLastNameBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
name.setLastName("");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -196,24 +196,24 @@ protected void tearDown() {
*/
public void testRequiredLastName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
name.setLastName("Smith");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
diff --git a/src/test/java/org/apache/commons/validator/RequiredNameTest.java b/src/test/java/org/apache/commons/validator/RequiredNameTest.java
index df55f661..472301c8 100644
--- a/src/test/java/org/apache/commons/validator/RequiredNameTest.java
+++ b/src/test/java/org/apache/commons/validator/RequiredNameTest.java
@@ -39,7 +39,7 @@ public class RequiredNameTest extends AbstractCommonTest {
*/
protected static String ACTION = "required";
- public RequiredNameTest(String name) {
+ public RequiredNameTest(final String name) {
super(name);
}
@@ -62,11 +62,11 @@ protected void tearDown() {
*/
public void testRequired() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
@@ -76,12 +76,12 @@ protected void tearDown() {
// but we aren't catching for testing
// since no validation methods we use
// throw this
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -97,23 +97,23 @@ protected void tearDown() {
*/
public void testRequiredFirstNameBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -129,23 +129,23 @@ protected void tearDown() {
*/
public void testRequiredFirstName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -161,23 +161,23 @@ protected void tearDown() {
*/
public void testRequiredLastNameBlank() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setLastName("");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -193,23 +193,23 @@ protected void tearDown() {
*/
public void testRequiredLastName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setLastName("Smith");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
@@ -226,24 +226,24 @@ protected void tearDown() {
*/
public void testRequiredName() throws ValidatorException {
// Create bean to run test on.
- NameBean name = new NameBean();
+ final NameBean name = new NameBean();
name.setFirstName("Joe");
name.setLastName("Smith");
// Construct validator based on the loaded resources
// and the form key
- Validator validator = new Validator(resources, FORM_KEY);
+ final Validator validator = new Validator(resources, FORM_KEY);
// add the name bean to the validator as a resource
// for the validations to be performed on.
validator.setParameter(Validator.BEAN_PARAM, name);
// Get results of the validation.
- ValidatorResults results = validator.validate();
+ final ValidatorResults results = validator.validate();
assertNotNull("Results are null.", results);
- ValidatorResult firstNameResult = results.getValidatorResult("firstName");
- ValidatorResult lastNameResult = results.getValidatorResult("lastName");
+ final ValidatorResult firstNameResult = results.getValidatorResult("firstName");
+ final ValidatorResult lastNameResult = results.getValidatorResult("lastName");
assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
diff --git a/src/test/java/org/apache/commons/validator/ResultPair.java b/src/test/java/org/apache/commons/validator/ResultPair.java
index 37f63c5d..9f7cdc47 100644
--- a/src/test/java/org/apache/commons/validator/ResultPair.java
+++ b/src/test/java/org/apache/commons/validator/ResultPair.java
@@ -25,7 +25,7 @@
public final String item;
public final boolean valid;
- public ResultPair(String item, boolean valid) {
+ public ResultPair(final String item, final boolean valid) {
this.item = item;
this.valid = valid; //Whether the individual part of url is valid.
}
diff --git a/src/test/java/org/apache/commons/validator/RetrieveFormTest.java b/src/test/java/org/apache/commons/validator/RetrieveFormTest.java
index 701afc7b..68240be6 100644
--- a/src/test/java/org/apache/commons/validator/RetrieveFormTest.java
+++ b/src/test/java/org/apache/commons/validator/RetrieveFormTest.java
@@ -48,7 +48,7 @@ public class RetrieveFormTest extends TestCase {
* Constructor for FormTest.
* @param name
*/
- public RetrieveFormTest(String name) {
+ public RetrieveFormTest(final String name) {
super(name);
}
@@ -57,14 +57,14 @@ public class RetrieveFormTest extends TestCase {
*/
@Override
protected void setUp() throws IOException, SAXException {
- InputStream[] streams =
+ final InputStream[] streams =
{
this.getClass().getResourceAsStream(
"RetrieveFormTest-config.xml")};
this.resources = new ValidatorResources(streams);
- for (InputStream stream : streams) {
+ for (final InputStream stream : streams) {
stream.close();
}
}
@@ -74,7 +74,7 @@ public class RetrieveFormTest extends TestCase {
*/
public void testDefaultForm() {
- String formKey = FORM_PREFIX + "default";
+ final String formKey = FORM_PREFIX + "default";
// *** US locale ***
checkForm(Locale.US, formKey, "default");
@@ -102,7 +102,7 @@ public class RetrieveFormTest extends TestCase {
*/
public void testLanguageForm() {
- String formKey = FORM_PREFIX + "language";
+ final String formKey = FORM_PREFIX + "language";
// *** US locale ***
checkForm(Locale.US, formKey, "default");
@@ -131,7 +131,7 @@ public class RetrieveFormTest extends TestCase {
*/
public void testLanguageCountryForm() {
- String formKey = FORM_PREFIX + "language_country";
+ final String formKey = FORM_PREFIX + "language_country";
// *** US locale ***
checkForm(Locale.US, formKey, "default");
@@ -158,7 +158,7 @@ public class RetrieveFormTest extends TestCase {
*/
public void testLanguageCountryVariantForm() {
- String formKey = FORM_PREFIX + "language_country_variant";
+ final String formKey = FORM_PREFIX + "language_country_variant";
// *** US locale ***
checkForm(Locale.US, formKey, "default");
@@ -185,7 +185,7 @@ public class RetrieveFormTest extends TestCase {
*/
public void testFormNotFound() {
- String formKey = "INVALID_NAME";
+ final String formKey = "INVALID_NAME";
// *** US locale ***
checkFormNotFound(Locale.US, formKey);
@@ -208,24 +208,24 @@ public class RetrieveFormTest extends TestCase {
}
- private void checkForm(Locale locale, String formKey, String expectedVarValue) {
+ private void checkForm(final Locale locale, final String formKey, final String expectedVarValue) {
// Retrieve the Form
- Form testForm = resources.getForm(locale, formKey);
+ final Form testForm = resources.getForm(locale, formKey);
assertNotNull("Form '" +formKey+"' null for locale " + locale, testForm);
// Validate the expected Form is retrieved by checking the "localeVar"
// value of the field.
- Field testField = testForm.getField("testProperty");
+ final Field testField = testForm.getField("testProperty");
assertEquals("Incorrect Form '" + formKey + "' for locale '" + locale + "'",
expectedVarValue,
testField.getVarValue("localeVar"));
}
- private void checkFormNotFound(Locale locale, String formKey) {
+ private void checkFormNotFound(final Locale locale, final String formKey) {
// Retrieve the Form
- Form testForm = resources.getForm(locale, formKey);
+ final Form testForm = resources.getForm(locale, formKey);
assertNull("Form '" +formKey+"' not null for locale " + locale, testForm);
}
diff --git a/src/test/java/org/apache/commons/validator/ShortTest.java b/src/test/java/org/apache/commons/validator/ShortTest.java
index 902474a6..13d804c7 100644
--- a/src/test/java/org/apache/commons/validator/ShortTest.java
+++ b/src/test/java/org/apache/commons/validator/ShortTest.java
@@ -24,7 +24,7 @@ package org.apache.commons.validator;
*/
public class ShortTest extends AbstractNumberTest {
- public ShortTest(String name) {
+ public ShortTest(final String name) {
super(name);
FORM_KEY = "shortForm";
ACTION = "short";
@@ -35,7 +35,7 @@ public class ShortTest extends AbstractNumberTest {
*/
public void testShortMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Short.toString(Short.MIN_VALUE));
valueTest(info, true);
@@ -46,7 +46,7 @@ public class ShortTest extends AbstractNumberTest {
*/
public void testShortMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Short.toString(Short.MAX_VALUE));
valueTest(info, true);
@@ -57,7 +57,7 @@ public class ShortTest extends AbstractNumberTest {
*/
public void testShortBeyondMin() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Short.MIN_VALUE + "1");
valueTest(info, false);
@@ -68,7 +68,7 @@ public class ShortTest extends AbstractNumberTest {
*/
public void testShortBeyondMax() throws ValidatorException {
// Create bean to run test on.
- ValueBean info = new ValueBean();
+ final ValueBean info = new ValueBean();
info.setValue(Short.MAX_VALUE + "1");
valueTest(info, false);
diff --git a/src/test/java/org/apache/commons/validator/TypeBean.java b/src/test/java/org/apache/commons/validator/TypeBean.java
index f493ea86..f1e92c7e 100644
--- a/src/test/java/org/apache/commons/validator/TypeBean.java
+++ b/src/test/java/org/apache/commons/validator/TypeBean.java
@@ -37,7 +37,7 @@ public class TypeBean {
return sByte;
}
- public void setByte(String sByte) {
+ public void setByte(final String sByte) {
this.sByte = sByte;
}
@@ -45,7 +45,7 @@ public class TypeBean {
return sShort;
}
- public void setShort(String sShort) {
+ public void setShort(final String sShort) {
this.sShort = sShort;
}
@@ -53,7 +53,7 @@ public class TypeBean {
return sInteger;
}
- public void setInteger(String sInteger) {
+ public void setInteger(final String sInteger) {
this.sInteger = sInteger;
}
@@ -61,7 +61,7 @@ public class TypeBean {
return sLong;
}
- public void setLong(String sLong) {
+ public void setLong(final String sLong) {
this.sLong = sLong;
}
@@ -69,7 +69,7 @@ public class TypeBean {
return sFloat;
}
- public void setFloat(String sFloat) {
+ public void setFloat(final String sFloat) {
this.sFloat = sFloat;
}
@@ -77,7 +77,7 @@ public class TypeBean {
return sDouble;
}
- public void setDouble(String sDouble) {
+ public void setDouble(final String sDouble) {
this.sDouble = sDouble;
}
@@ -85,7 +85,7 @@ public class TypeBean {
return sDate;
}
- public void setDate(String sDate) {
+ public void setDate(final String sDate) {
this.sDate = sDate;
}
@@ -93,7 +93,7 @@ public class TypeBean {
return sCreditCard;
}
- public void setCreditCard(String sCreditCard) {
+ public void setCreditCard(final String sCreditCard) {
this.sCreditCard = sCreditCard;
}
diff --git a/src/test/java/org/apache/commons/validator/UrlTest.java b/src/test/java/org/apache/commons/validator/UrlTest.java
index 3a1f7ca1..22ff8c2b 100644
--- a/src/test/java/org/apache/commons/validator/UrlTest.java
+++ b/src/test/java/org/apache/commons/validator/UrlTest.java
@@ -30,7 +30,7 @@ public class UrlTest extends TestCase {
private final boolean printStatus = false;
private final boolean printIndex = false;//print index that indicates current scheme,host,port,path, query test were using.
- public UrlTest(String testName) {
+ public UrlTest(final String testName) {
super(testName);
}
@@ -44,7 +44,7 @@ protected void setUp() {
public void testIsValid() {
testIsValid(testUrlParts, UrlValidator.ALLOW_ALL_SCHEMES);
setUp();
- int options =
+ final int options =
UrlValidator.ALLOW_2_SLASHES
+ UrlValidator.ALLOW_ALL_SCHEMES
+ UrlValidator.NO_FRAGMENTS;
@@ -56,11 +56,11 @@ protected void setUp() {
if (printStatus) {
System.out.print("\n testIsValidScheme() ");
}
- String[] schemes = {"http", "gopher"};
+ final String[] schemes = {"http", "gopher"};
//UrlValidator urlVal = new UrlValidator(schemes,false,false,false);
- UrlValidator urlVal = new UrlValidator(schemes, 0);
- for (ResultPair testPair : testScheme) {
- boolean result = urlVal.isValidScheme(testPair.item);
+ final UrlValidator urlVal = new UrlValidator(schemes, 0);
+ for (final ResultPair testPair : testScheme) {
+ final boolean result = urlVal.isValidScheme(testPair.item);
assertEquals(testPair.item, testPair.valid, result);
if (printStatus) {
if (result == testPair.valid) {
@@ -82,8 +82,8 @@ protected void setUp() {
*
* @param testObjects Used to create a url.
*/
- public void testIsValid(Object[] testObjects, int options) {
- UrlValidator urlVal = new UrlValidator(null, options);
+ public void testIsValid(final Object[] testObjects, final int options) {
+ final UrlValidator urlVal = new UrlValidator(null, options);
assertTrue(urlVal.isValid("http://www.google.com"));
assertTrue(urlVal.isValid("http://www.google.com/"));
int statusPerLine = 60;
@@ -92,16 +92,16 @@ protected void setUp() {
statusPerLine = 6;
}
do {
- StringBuilder testBuffer = new StringBuilder();
+ final StringBuilder testBuffer = new StringBuilder();
boolean expected = true;
for (int testPartsIndexIndex = 0; testPartsIndexIndex < testPartsIndex.length; ++testPartsIndexIndex) {
- int index = testPartsIndex[testPartsIndexIndex];
- ResultPair[] part = (ResultPair[]) testObjects[testPartsIndexIndex];
+ final int index = testPartsIndex[testPartsIndexIndex];
+ final ResultPair[] part = (ResultPair[]) testObjects[testPartsIndexIndex];
testBuffer.append(part[index].item);
expected &= part[index].valid;
}
- String url = testBuffer.toString();
- boolean result = urlVal.isValid(url);
+ final String url = testBuffer.toString();
+ final boolean result = urlVal.isValid(url);
assertEquals(url, expected, result);
if (printStatus) {
if (printIndex) {
@@ -124,23 +124,23 @@ protected void setUp() {
}
public void testValidator202() {
- String[] schemes = {"http","https"};
- UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.NO_FRAGMENTS);
+ final String[] schemes = {"http","https"};
+ final UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.NO_FRAGMENTS);
urlValidator.isValid("http://www.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks.comwww.logoworks. [...]
}
public void testValidator204() {
- String[] schemes = {"http","https"};
- UrlValidator urlValidator = new UrlValidator(schemes);
+ final String[] schemes = {"http","https"};
+ final UrlValidator urlValidator = new UrlValidator(schemes);
assertTrue(urlValidator.isValid("http://tech.yahoo.com/rc/desktops/102;_ylt=Ao8yevQHlZ4On0O3ZJGXLEQFLZA5"));
}
- static boolean incrementTestPartsIndex(int[] testPartsIndex, Object[] testParts) {
+ static boolean incrementTestPartsIndex(final int[] testPartsIndex, final Object[] testParts) {
boolean carry = true; //add 1 to lowest order part.
boolean maxIndex = true;
for (int testPartsIndexIndex = testPartsIndex.length - 1; testPartsIndexIndex >= 0; --testPartsIndexIndex) {
int index = testPartsIndex[testPartsIndexIndex];
- ResultPair[] part = (ResultPair[]) testParts[testPartsIndexIndex];
+ final ResultPair[] part = (ResultPair[]) testParts[testPartsIndexIndex];
if (carry) {
if (index < part.length - 1) {
index++;
@@ -159,7 +159,7 @@ protected void setUp() {
}
private String testPartsIndextoString() {
- StringBuilder carryMsg = new StringBuilder("{");
+ final StringBuilder carryMsg = new StringBuilder("{");
for (int testPartsIndexIndex = 0; testPartsIndexIndex < testPartsIndex.length; ++testPartsIndexIndex) {
carryMsg.append(testPartsIndex[testPartsIndexIndex]);
if (testPartsIndexIndex < testPartsIndex.length - 1) {
@@ -180,9 +180,9 @@ protected void setUp() {
* Only used to debug the unit tests.
* @param argv
*/
- public static void main(String[] argv) {
+ public static void main(final String[] argv) {
- UrlTest fct = new UrlTest("url test");
+ final UrlTest fct = new UrlTest("url test");
fct.setUp();
fct.testIsValid();
fct.testIsValidScheme();
diff --git a/src/test/java/org/apache/commons/validator/ValidatorResourcesTest.java b/src/test/java/org/apache/commons/validator/ValidatorResourcesTest.java
index 3b95c187..aa46b9be 100644
--- a/src/test/java/org/apache/commons/validator/ValidatorResourcesTest.java
+++ b/src/test/java/org/apache/commons/validator/ValidatorResourcesTest.java
@@ -30,7 +30,7 @@ public class ValidatorResourcesTest extends TestCase {
/**
* Constructor.
*/
- public ValidatorResourcesTest(String name) {
+ public ValidatorResourcesTest(final String name) {
super(name);
}
@@ -42,7 +42,7 @@ public class ValidatorResourcesTest extends TestCase {
try {
new ValidatorResources((InputStream)null);
fail("Expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
// expected result
// System.out.println("Exception: " + e);
}
diff --git a/src/test/java/org/apache/commons/validator/ValidatorResultsTest.java b/src/test/java/org/apache/commons/validator/ValidatorResultsTest.java
index eb452f13..d0eee994 100644
--- a/src/test/java/org/apache/commons/validator/ValidatorResultsTest.java
+++ b/src/test/java/org/apache/commons/validator/ValidatorResultsTest.java
@@ -39,7 +39,7 @@ public class ValidatorResultsTest extends AbstractCommonTest {
/**
* Constructor.
*/
- public ValidatorResultsTest(String name) {
+ public ValidatorResultsTest(final String name) {
super(name);
}
@@ -69,10 +69,10 @@ protected void tearDown() {
public void testAllValid() throws ValidatorException {
// Create bean to run test on.
- NameBean bean = createNameBean();
+ final NameBean bean = createNameBean();
// Validate.
- ValidatorResults results = validate(bean);
+ final ValidatorResults results = validate(bean);
// Check results
checkValidatorResult(results, firstNameField, "required", true);
@@ -93,10 +93,10 @@ protected void tearDown() {
lastName = null;
// Create bean to run test on.
- NameBean bean = createNameBean();
+ final NameBean bean = createNameBean();
// Validate.
- ValidatorResults results = validate(bean);
... 4225 lines suppressed ...