code
stringlengths 23
201k
| docstring
stringlengths 17
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
72
| path
stringlengths 11
317
| url
stringlengths 57
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public Double validate(String value, String pattern, Locale locale) {
return (Double)parse(value, pattern, locale);
}
|
<p>Validate/convert a <code>Double</code> using the
specified pattern and/ or <code>Locale</code>.
@param value The value validation is being performed on.
@param pattern The pattern used to validate the value against, or the
default for the <code>Locale</code> if <code>null</code>.
@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.
|
validate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public boolean isInRange(double value, double min, double max) {
return (value >= min && value <= max);
}
|
Check if the value is within a specified range.
@param value The <code>Number</code> value to check.
@param min The minimum value of the range.
@param max The maximum value of the range.
@return <code>true</code> if the value is within the
specified range.
|
isInRange
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public boolean isInRange(Double value, double min, double max) {
return isInRange(value.doubleValue(), min, max);
}
|
Check if the value is within a specified range.
@param value The <code>Number</code> value to check.
@param min The minimum value of the range.
@param max The maximum value of the range.
@return <code>true</code> if the value is within the
specified range.
|
isInRange
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public boolean minValue(double value, double min) {
return (value >= min);
}
|
Check if the value is greater than or equal to a minimum.
@param value The value validation is being performed on.
@param min The minimum value.
@return <code>true</code> if the value is greater than
or equal to the minimum.
|
minValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public boolean minValue(Double value, double min) {
return minValue(value.doubleValue(), min);
}
|
Check if the value is greater than or equal to a minimum.
@param value The value validation is being performed on.
@param min The minimum value.
@return <code>true</code> if the value is greater than
or equal to the minimum.
|
minValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public boolean maxValue(double value, double max) {
return (value <= max);
}
|
Check if the value is less than or equal to a maximum.
@param value The value validation is being performed on.
@param max The maximum value.
@return <code>true</code> if the value is less than
or equal to the maximum.
|
maxValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public boolean maxValue(Double value, double max) {
return maxValue(value.doubleValue(), max);
}
|
Check if the value is less than or equal to a maximum.
@param value The value validation is being performed on.
@param max The maximum value.
@return <code>true</code> if the value is less than
or equal to the maximum.
|
maxValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
protected Object processParsedValue(Object value, Format formatter) {
if (value instanceof Double) {
return value;
}
return new Double(((Number)value).doubleValue());
}
|
Convert the parsed value to a <code>Double</code>.
@param value The parsed <code>Number</code> object created.
@param formatter The Format used to parse the value with.
@return The validated/converted <code>Double</code> value if valid
or <code>null</code> if invalid.
|
processParsedValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/DoubleValidator.java
|
Apache-2.0
|
public static EmailValidator getInstance() {
return EMAIL_VALIDATOR;
}
|
Returns the Singleton instance of this validator.
@return singleton instance of this validator.
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/EmailValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/EmailValidator.java
|
Apache-2.0
|
public static EmailValidator getInstance(boolean allowLocal) {
if(allowLocal) {
return EMAIL_VALIDATOR_WITH_LOCAL;
}
return EMAIL_VALIDATOR;
}
|
Returns the Singleton instance of this validator,
with local validation as required.
@param allowLocal Should local addresses be considered valid?
@return singleton instance of this validator
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/EmailValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/EmailValidator.java
|
Apache-2.0
|
protected boolean isValidUser(String user) {
return USER_PATTERN.matcher(user).matches();
}
|
Returns true if the user component of an email address is valid.
@param user being validated
@return true if the user name is valid.
|
isValidUser
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/EmailValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/EmailValidator.java
|
Apache-2.0
|
public static InetAddressValidator getInstance() {
return VALIDATOR;
}
|
Returns the singleton instance of this validator.
@return the singleton instance of this validator
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
Apache-2.0
|
public boolean isValid(String inetAddress) {
return isValidInet4Address(inetAddress) || isValidInet6Address(inetAddress);
}
|
Checks if the specified string is a valid IP address.
@param inetAddress the string to validate
@return true if the string validates as an IP address
|
isValid
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
Apache-2.0
|
public boolean isValidInet4Address(String inet4Address) {
// verify that address conforms to generic IPv4 format
String[] groups = ipv4Validator.match(inet4Address);
if (groups == null) {
return false;
}
// verify that address subgroups are legal
for (int i = 0; i <= 3; i++) {
String ipSegment = groups[i];
if (ipSegment == null || ipSegment.length() == 0) {
return false;
}
int iIpSegment = 0;
try {
iIpSegment = Integer.parseInt(ipSegment);
} catch(NumberFormatException e) {
return false;
}
if (iIpSegment > 255) {
return false;
}
if (ipSegment.length() > 1 && ipSegment.startsWith("0")) {
return false;
}
}
return true;
}
|
Validates an IPv4 address. Returns true if valid.
@param inet4Address the IPv4 address to validate
@return true if the argument contains a valid IPv4 address
|
isValidInet4Address
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
Apache-2.0
|
public boolean isValidInet6Address(String inet6Address) {
boolean containsCompressedZeroes = inet6Address.indexOf("::") > -1; // contains is Java 1.5
if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) {
return false;
}
if ((inet6Address.startsWith(":") && !inet6Address.startsWith("::"))
|| (inet6Address.endsWith(":") && !inet6Address.endsWith("::"))) {
return false;
}
Object[] octets = inet6Address.split(":");
if (containsCompressedZeroes) {
List octetList = new ArrayList(Arrays.asList(octets));
if (inet6Address.endsWith("::")) {
// String.split() drops ending empty segments
octetList.add("");
} else if (inet6Address.startsWith("::") && !octetList.isEmpty()) {
octetList.remove(0);
}
octets = octetList.toArray();
}
if (octets.length > 8) {
return false;
}
int validOctets = 0;
int emptyOctets = 0;
for (int index = 0; index < octets.length; index++) {
String octet = (String) octets[index];
if (octet.length() == 0) {
emptyOctets++;
if (emptyOctets > 1) {
return false;
}
} else {
emptyOctets = 0;
if (octet.indexOf(".") > -1) { // contains is Java 1.5+
if (!inet6Address.endsWith(octet)) {
return false;
}
if (index > octets.length - 1 || index > 6) {
// IPV4 occupies last two octets
return false;
}
if (!isValidInet4Address(octet)) {
return false;
}
validOctets += 2;
continue;
}
if (octet.length() > 4) {
return false;
}
int octetInt = 0;
try {
octetInt = Integer.valueOf(octet, 16).intValue();
} catch (NumberFormatException e) {
return false;
}
if (octetInt < 0 || octetInt > 0xffff) {
return false;
}
}
validOctets++;
}
if (validOctets < 8 && !containsCompressedZeroes) {
return false;
}
return true;
}
|
Validates an IPv6 address. Returns true if valid.
@param inet6Address the IPv6 address to validate
@return true if the argument contains a valid IPv6 address
@since 1.4.1
|
isValidInet6Address
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/InetAddressValidator.java
|
Apache-2.0
|
public static IntegerValidator getInstance() {
return VALIDATOR;
}
|
Return a singleton instance of this validator.
@return A singleton instance of the IntegerValidator.
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public Integer validate(String value) {
return (Integer)parse(value, (String)null, (Locale)null);
}
|
<p>Validate/convert an <code>Integer</code> using the default
<code>Locale</code>.
@param value The value validation is being performed on.
@return The parsed <code>Integer</code> if valid or <code>null</code>
if invalid.
|
validate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public Integer validate(String value, String pattern) {
return (Integer)parse(value, pattern, (Locale)null);
}
|
<p>Validate/convert an <code>Integer</code> using the
specified <i>pattern</i>.
@param value The value validation is being performed on.
@param pattern The pattern used to validate the value against.
@return The parsed <code>Integer</code> if valid or <code>null</code> if invalid.
|
validate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public Integer validate(String value, Locale locale) {
return (Integer)parse(value, (String)null, locale);
}
|
<p>Validate/convert an <code>Integer</code> using the
specified <code>Locale</code>.
@param value The value validation is being performed on.
@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.
|
validate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public Integer validate(String value, String pattern, Locale locale) {
return (Integer)parse(value, pattern, locale);
}
|
<p>Validate/convert a <code>Integer</code> using the
specified pattern and/ or <code>Locale</code>.
@param value The value validation is being performed on.
@param pattern The pattern used to validate the value against, or the
default for the <code>Locale</code> if <code>null</code>.
@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.
|
validate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public boolean isInRange(int value, int min, int max) {
return (value >= min && value <= max);
}
|
Check if the value is within a specified range.
@param value The <code>Number</code> value to check.
@param min The minimum value of the range.
@param max The maximum value of the range.
@return <code>true</code> if the value is within the
specified range.
|
isInRange
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public boolean isInRange(Integer value, int min, int max) {
return isInRange(value.intValue(), min, max);
}
|
Check if the value is within a specified range.
@param value The <code>Number</code> value to check.
@param min The minimum value of the range.
@param max The maximum value of the range.
@return <code>true</code> if the value is within the
specified range.
|
isInRange
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public boolean minValue(int value, int min) {
return (value >= min);
}
|
Check if the value is greater than or equal to a minimum.
@param value The value validation is being performed on.
@param min The minimum value.
@return <code>true</code> if the value is greater than
or equal to the minimum.
|
minValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public boolean minValue(Integer value, int min) {
return minValue(value.intValue(), min);
}
|
Check if the value is greater than or equal to a minimum.
@param value The value validation is being performed on.
@param min The minimum value.
@return <code>true</code> if the value is greater than
or equal to the minimum.
|
minValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public boolean maxValue(int value, int max) {
return (value <= max);
}
|
Check if the value is less than or equal to a maximum.
@param value The value validation is being performed on.
@param max The maximum value.
@return <code>true</code> if the value is less than
or equal to the maximum.
|
maxValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public boolean maxValue(Integer value, int max) {
return maxValue(value.intValue(), max);
}
|
Check if the value is less than or equal to a maximum.
@param value The value validation is being performed on.
@param max The maximum value.
@return <code>true</code> if the value is less than
or equal to the maximum.
|
maxValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
protected Object processParsedValue(Object value, Format formatter) {
long longValue = ((Number)value).longValue();
if (longValue < Integer.MIN_VALUE ||
longValue > Integer.MAX_VALUE) {
return null;
}
return new Integer((int)longValue);
}
|
<p>Perform further validation and convert the <code>Number</code> to
an <code>Integer</code>.</p>
@param value The parsed <code>Number</code> object created.
@param formatter The Format used to parse the value with.
@return The parsed <code>Number</code> converted to an
<code>Integer</code> if valid or <code>null</code> if invalid.
|
processParsedValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/IntegerValidator.java
|
Apache-2.0
|
public static ISBNValidator getInstance() {
return ISBN_VALIDATOR;
}
|
Return a singleton instance of the ISBN validator which
converts ISBN-10 codes to ISBN-13.
@return A singleton instance of the ISBN validator.
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public static ISBNValidator getInstance(boolean convert) {
return (convert ? ISBN_VALIDATOR : ISBN_VALIDATOR_NO_CONVERT);
}
|
Return a singleton instance of the ISBN validator specifying
whether ISBN-10 codes should be converted to ISBN-13.
@param convert <code>true</code> if valid ISBN-10 codes
should be converted to ISBN-13 codes or <code>false</code>
if valid ISBN-10 codes should be returned unchanged.
@return A singleton instance of the ISBN validator.
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public boolean isValid(String code) {
return (isValidISBN13(code) || isValidISBN10(code));
}
|
Check the code is either a valid ISBN-10 or ISBN-13 code.
@param code The code to validate.
@return <code>true</code> if a valid ISBN-10 or
ISBN-13 code, otherwise <code>false</code>.
|
isValid
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public boolean isValidISBN10(String code) {
return isbn10Validator.isValid(code);
}
|
Check the code is a valid ISBN-10 code.
@param code The code to validate.
@return <code>true</code> if a valid ISBN-10
code, otherwise <code>false</code>.
|
isValidISBN10
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public boolean isValidISBN13(String code) {
return isbn13Validator.isValid(code);
}
|
Check the code is a valid ISBN-13 code.
@param code The code to validate.
@return <code>true</code> if a valid ISBN-13
code, otherwise <code>false</code>.
|
isValidISBN13
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public String validate(String code) {
String result = validateISBN13(code);
if (result == null) {
result = validateISBN10(code);
if (result != null && convert) {
result = convertToISBN13(result);
}
}
return result;
}
|
Check the code is either a valid ISBN-10 or ISBN-13 code.
<p>
If valid, this method returns the ISBN code with
formatting characters removed (i.e. space or hyphen).
<p>
Converts an ISBN-10 codes to ISBN-13 if
<code>convertToISBN13</code> is <code>true</code>.
@param code The code to validate.
@return A valid ISBN code if valid, otherwise <code>null</code>.
|
validate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public String validateISBN10(String code) {
Object result = isbn10Validator.validate(code);
return (result == null ? null : result.toString());
}
|
Check the code is a valid ISBN-10 code.
<p>
If valid, this method returns the ISBN-10 code with
formatting characters removed (i.e. space or hyphen).
@param code The code to validate.
@return A valid ISBN-10 code if valid,
otherwise <code>null</code>.
|
validateISBN10
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public String validateISBN13(String code) {
Object result = isbn13Validator.validate(code);
return (result == null ? null : result.toString());
}
|
Check the code is a valid ISBN-13 code.
<p>
If valid, this method returns the ISBN-13 code with
formatting characters removed (i.e. space or hyphen).
@param code The code to validate.
@return A valid ISBN-13 code if valid,
otherwise <code>null</code>.
|
validateISBN13
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public String convertToISBN13(String isbn10) {
if (isbn10 == null) {
return null;
}
String input = isbn10.trim();
if (input.length() != 10) {
throw new IllegalArgumentException("Invalid length " + input.length() + " for '" + input + "'");
}
// Calculate the new ISBN-13 code
String isbn13 = "978" + input.substring(0, 9);
try {
String checkDigit = isbn13Validator.getCheckDigit().calculate(isbn13);
isbn13 += checkDigit;
return isbn13;
} catch (CheckDigitException e) {
throw new IllegalArgumentException("Check digit error for '" + input + "' - " + e.getMessage());
}
}
|
Convert an ISBN-10 code to an ISBN-13 code.
<p>
This method requires a valid ISBN-10 with NO formatting
characters.
@param isbn10 The ISBN-10 code to convert
@return A converted ISBN-13 code or <code>null</code>
if the ISBN-10 code is not valid
|
convertToISBN13
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/ISBNValidator.java
|
Apache-2.0
|
public boolean isValid(String value) {
if (value == null) {
return false;
}
for (int i = 0; i < patterns.length; i++) {
if (patterns[i].matcher(value).matches()) {
return true;
}
}
return false;
}
|
Validate a value against the set of regular expressions.
@param value The value to validate.
@return <code>true</code> if the value is valid
otherwise <code>false</code>.
|
isValid
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/RegexValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/RegexValidator.java
|
Apache-2.0
|
public String[] match(String value) {
if (value == null) {
return null;
}
for (int i = 0; i < patterns.length; i++) {
Matcher matcher = patterns[i].matcher(value);
if (matcher.matches()) {
int count = matcher.groupCount();
String[] groups = new String[count];
for (int j = 0; j < count; j++) {
groups[j] = matcher.group(j+1);
}
return groups;
}
}
return null;
}
|
Validate a value against the set of regular expressions
returning the array of matched groups.
@param value The value to validate.
@return String array of the <i>groups</i> matched if
valid or <code>null</code> if invalid
|
match
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/RegexValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/RegexValidator.java
|
Apache-2.0
|
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("RegexValidator{");
for (int i = 0; i < patterns.length; i++) {
if (i > 0) {
buffer.append(",");
}
buffer.append(patterns[i].pattern());
}
buffer.append("}");
return buffer.toString();
}
|
Provide a String representation of this validator.
@return A String representation of this validator
|
toString
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/RegexValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/RegexValidator.java
|
Apache-2.0
|
public static UrlValidator getInstance() {
return DEFAULT_URL_VALIDATOR;
}
|
Returns the singleton instance of this class with default schemes and options.
@return singleton instance with default schemes and options
|
getInstance
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
public boolean isValid(String value) {
if (value == null) {
return false;
}
// Check the whole url address structure
Matcher urlMatcher = URL_PATTERN.matcher(value);
if (!urlMatcher.matches()) {
return false;
}
String scheme = urlMatcher.group(PARSE_URL_SCHEME);
if (!isValidScheme(scheme)) {
return false;
}
String authority = urlMatcher.group(PARSE_URL_AUTHORITY);
if ("file".equals(scheme) && "".equals(authority)) {
// Special case - file: allows an empty authority
} else {
// Validate the authority
if (!isValidAuthority(authority)) {
return false;
}
}
if (!isValidPath(urlMatcher.group(PARSE_URL_PATH))) {
return false;
}
if (!isValidQuery(urlMatcher.group(PARSE_URL_QUERY))) {
return false;
}
if (!isValidFragment(urlMatcher.group(PARSE_URL_FRAGMENT))) {
return false;
}
return true;
}
|
<p>Checks if a field has a valid url address.</p>
Note that the method calls #isValidAuthority()
which checks that the domain is valid.
@param value The value validation is being performed on. A <code>null</code>
value is considered invalid.
@return true if the url is valid.
|
isValid
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
protected boolean isValidScheme(String scheme) {
if (scheme == null) {
return false;
}
// TODO could be removed if external schemes were checked in the ctor before being stored
if (!SCHEME_PATTERN.matcher(scheme).matches()) {
return false;
}
if (isOff(ALLOW_ALL_SCHEMES) && !allowedSchemes.contains(scheme.toLowerCase(Locale.ENGLISH))) {
return false;
}
return true;
}
|
Validate scheme. If schemes[] was initialized to a non null,
then only those schemes are allowed.
Otherwise the default schemes are "http", "https", "ftp".
Matching is case-blind.
@param scheme The scheme to validate. A <code>null</code> value is considered
invalid.
@return true if valid.
|
isValidScheme
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
protected boolean isValidQuery(String query) {
if (query == null) {
return true;
}
return QUERY_PATTERN.matcher(query).matches();
}
|
Returns true if the query is null or it's a properly formatted query string.
@param query Query value to validate.
@return true if query is valid.
|
isValidQuery
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
protected boolean isValidFragment(String fragment) {
if (fragment == null) {
return true;
}
return isOff(NO_FRAGMENTS);
}
|
Returns true if the given fragment is null or fragments are allowed.
@param fragment Fragment value to validate.
@return true if fragment is valid.
|
isValidFragment
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
protected int countToken(String token, String target) {
int tokenIndex = 0;
int count = 0;
while (tokenIndex != -1) {
tokenIndex = target.indexOf(token, tokenIndex);
if (tokenIndex > -1) {
tokenIndex++;
count++;
}
}
return count;
}
|
Returns the number of times the token appears in the target.
@param token Token value to be counted.
@param target Target value to count tokens in.
@return the number of tokens.
|
countToken
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
private boolean isOn(long flag) {
return (options & flag) > 0;
}
|
Tests whether the given flag is on. If the flag is not a power of 2
(ie. 3) this tests whether the combination of flags is on.
@param flag Flag value to check.
@return whether the specified flag value is on.
|
isOn
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
private boolean isOff(long flag) {
return (options & flag) == 0;
}
|
Tests whether the given flag is off. If the flag is not a power of 2
(ie. 3) this tests whether the combination of flags is off.
@param flag Flag value to check.
@return whether the specified flag value is off.
|
isOff
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/UrlValidator.java
|
Apache-2.0
|
protected int weightedValue(int charValue, int leftPos, int rightPos) {
int weight = POSITION_WEIGHT[rightPos % 2];
return charValue * weight;
}
|
<p>Calculates the <i>weighted</i> value of a character in the
code at a specified position.</p>
<p>For EAN-13 (from right to left) <b>odd</b> digits are weighted
with a factor of <b>one</b> and <b>even</b> digits with a factor
of <b>three</b>.</p>
@param charValue The numeric value of the character.
@param leftPos The position of the character in the code, counting from left to right
@param rightPos The positionof the character in the code, counting from right to left
@return The weighted value of the character.
|
weightedValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/EAN13CheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/EAN13CheckDigit.java
|
Apache-2.0
|
protected int weightedValue(int charValue, int leftPos, int rightPos) {
return charValue * rightPos;
}
|
Calculates the <i>weighted</i> value of a charcter in the
code at a specified position.
<p>For ISBN-10 (from right to left) digits are weighted
by their position.</p>
@param charValue The numeric value of the character.
@param leftPos The position of the character in the code, counting from left to right
@param rightPos The positionof the character in the code, counting from right to left
@return The weighted value of the character.
|
weightedValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
|
Apache-2.0
|
protected int toInt(char character, int leftPos, int rightPos)
throws CheckDigitException {
if (rightPos == 1 && character == 'X') {
return 10;
}
return super.toInt(character, leftPos, rightPos);
}
|
<p>Convert a character at a specified position to an
integer value.</p>
<p>Character 'X' check digit converted to 10.</p>
@param character The character to convert.
@param leftPos The position of the character in the code, counting from left to right
@param rightPos The position of the character in the code, counting from right to left
@return The integer value of the character.
@throws CheckDigitException if an error occurs.
|
toInt
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
|
Apache-2.0
|
protected String toCheckDigit(int charValue)
throws CheckDigitException {
if (charValue == 10) {
return "X";
}
return super.toCheckDigit(charValue);
}
|
<p>Convert an integer value to a character at a specified position.</p>
<p>Value '10' for position 1 (check digit) converted to 'X'.</p>
@param charValue The integer value of the character.
@return The converted character.
@throws CheckDigitException if an error occurs.
|
toCheckDigit
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
|
Apache-2.0
|
protected int weightedValue(int charValue, int leftPos, int rightPos) {
int weight = POSITION_WEIGHT[rightPos % 2];
int weightedValue = charValue * weight;
return weightedValue > 9 ? (weightedValue - 9) : weightedValue;
}
|
<p>Calculates the <i>weighted</i> value of a charcter in the
code at a specified position.</p>
<p>For Luhn (from right to left) <b>odd</b> digits are weighted
with a factor of <b>one</b> and <b>even</b> digits with a factor
of <b>two</b>. Weighted values > 9, have 9 subtracted</p>
@param charValue The numeric value of the character.
@param leftPos The position of the character in the code, counting from left to right
@param rightPos The positionof the character in the code, counting from right to left
@return The weighted value of the character.
|
weightedValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/LuhnCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/LuhnCheckDigit.java
|
Apache-2.0
|
public int getModulus() {
return modulus;
}
|
Return the modulus value this check digit routine is based on.
@return The modulus value this check digit routine is based on
|
getModulus
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
public boolean isValid(String code) {
if (code == null || code.length() == 0) {
return false;
}
try {
int modulusResult = calculateModulus(code, true);
return (modulusResult == 0);
} catch (CheckDigitException ex) {
return false;
}
}
|
Validate a modulus check digit for a code.
@param code The code to validate
@return <code>true</code> if the check digit is valid, otherwise
<code>false</code>
|
isValid
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
public String calculate(String code) throws CheckDigitException {
if (code == null || code.length() == 0) {
throw new CheckDigitException("Code is missing");
}
int modulusResult = calculateModulus(code, false);
int charValue = (modulus - modulusResult) % modulus;
return toCheckDigit(charValue);
}
|
Calculate a modulus <i>Check Digit</i> for a code.
@param code The code to calculate the Check Digit for
@return The calculated Check Digit
@throws CheckDigitException if an error occurs calculating
the check digit for the specified code
|
calculate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
protected int calculateModulus(String code, 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);
total += weightedValue(charValue, leftPos, rightPos);
}
if (total == 0) {
throw new CheckDigitException("Invalid code, sum is zero");
}
return total % modulus;
}
|
Calculate the modulus for a code.
@param code The code to calculate the modulus for.
@param includesCheckDigit Whether the code includes the Check Digit or not.
@return The modulus value
@throws CheckDigitException if an error occurs calculating the modulus
for the specified code
|
calculateModulus
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
protected int toInt(char character, int leftPos, int rightPos)
throws CheckDigitException {
if (Character.isDigit(character)) {
return Character.getNumericValue(character);
}
throw new CheckDigitException("Invalid Character[" +
leftPos + "] = '" + character + "'");
}
|
Convert a character at a specified position to an integer value.
<p>
<b>Note:</b> this implementation only handlers numeric values
For non-numeric characters, override this method to provide
character-->integer conversion.
@param character The character to convert
@param leftPos The position of the character in the code, counting from left to right (for identifiying the position in the string)
@param rightPos The position of the character in the code, counting from right to left (not used here)
@return The integer value of the character
@throws CheckDigitException if character is non-numeric
|
toInt
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
protected String toCheckDigit(int charValue)
throws CheckDigitException {
if (charValue >= 0 && charValue <= 9) {
return Integer.toString(charValue);
}
throw new CheckDigitException("Invalid Check Digit Value =" +
+ charValue);
}
|
Convert an integer value to a check digit.
<p>
<b>Note:</b> this implementation only handles single-digit numeric values
For non-numeric characters, override this method to provide
integer-->character conversion.
@param charValue The integer value of the character
@return The converted character
@throws CheckDigitException if integer character value
doesn't represent a numeric character
|
toCheckDigit
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
public static int sumDigits(int number) {
int total = 0;
int todo = number;
while (todo > 0) {
total += todo % 10;
todo = todo / 10;
}
return total;
}
|
Add together the individual digits in a number.
@param number The number whose digits are to be added
@return The sum of the digits
|
sumDigits
|
java
|
ragunathjawahar/android-saripaar
|
saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar/src/main/java/commons/validator/routines/checkdigit/ModulusCheckDigit.java
|
Apache-2.0
|
@Override
protected void setUp() throws Exception {
super.setUp();
mResultTextView = (TextView) getActivity().findViewById(R.id.resultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
setUp
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
Apache-2.0
|
public void testInvalidZipCodeInvalidEmailNoQuickRule_failure() {
EspressoHelper.clickView(R.id.saripaarButton);
String result = String.format("%s %s", Constants.FIELD_ZIP_CODE, Constants.FIELD_EMAIL);
EspressoHelper.checkForText(result, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testInvalidZipCodeInvalidEmailNoQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
Apache-2.0
|
public void testAllInvalidWithQuickRule_failure() {
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.clickView(R.id.saripaarButton);
String result = String.format("%s %s %s",
Constants.FIELD_ZIP_CODE, Constants.FIELD_AIRTEL_NUMBER, Constants.FIELD_EMAIL);
EspressoHelper.checkForText(result, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testAllInvalidWithQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
Apache-2.0
|
public void testAllValidButQuickRule_failure() {
EspressoHelper.type(R.id.zipCodeEditText, Constants.ZIP_CODE);
EspressoHelper.type(R.id.emailEditText, Constants.EMAIL);
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.clickView(R.id.saripaarButton);
EspressoHelper.checkForText(Constants.FIELD_AIRTEL_NUMBER, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testAllValidButQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
Apache-2.0
|
public void testAllValidWithQuickRule_success() {
EspressoHelper.type(R.id.zipCodeEditText, Constants.ZIP_CODE);
EspressoHelper.type(R.id.airtelNumberEditText, Constants.AIRTEL_NUMBER);
EspressoHelper.type(R.id.emailEditText, Constants.EMAIL);
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.clickView(R.id.saripaarButton);
EspressoHelper.checkForText(Constants.STATE_SUCCESS, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testAllValidWithQuickRule_success
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleOrderedTest.java
|
Apache-2.0
|
@Override
protected void setUp() throws Exception {
super.setUp();
mResultTextView = (TextView) getActivity().findViewById(R.id.resultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
setUp
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedInOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedInOrderedTest.java
|
Apache-2.0
|
public void testInvalidZipCodeInvalidAirtelNumberNoEvenNumberQuickRule_failure() {
EspressoHelper.clickView(R.id.saripaarButton);
String result = String.format("%s %s",
Constants.FIELD_ZIP_CODE, Constants.FIELD_AIRTEL_NUMBER);
EspressoHelper.checkForText(result, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testInvalidZipCodeInvalidAirtelNumberNoEvenNumberQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedInOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedInOrderedTest.java
|
Apache-2.0
|
public void testInvalidZipCodeInvalidAirtelNumberWithEvenNumberQuickRule_crash() {
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.checkForText(Constants.STATE_CRASH, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testInvalidZipCodeInvalidAirtelNumberWithEvenNumberQuickRule_crash
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedInOrderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedInOrderedTest.java
|
Apache-2.0
|
@Override
protected void setUp() throws Exception {
super.setUp();
mResultTextView = (TextView) getActivity().findViewById(R.id.resultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
setUp
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
Apache-2.0
|
public void testInvalidZipCodeNoQuickRule_failure() {
EspressoHelper.clickView(R.id.saripaarButton);
EspressoHelper.checkForText(Constants.FIELD_ZIP_CODE, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testInvalidZipCodeNoQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
Apache-2.0
|
public void testValidZipCodeNoQuickRule_success() {
EspressoHelper.type(R.id.zipCodeEditText, Constants.ZIP_CODE);
EspressoHelper.clickView(R.id.saripaarButton);
EspressoHelper.checkForText(Constants.STATE_SUCCESS, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testValidZipCodeNoQuickRule_success
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
Apache-2.0
|
public void testValidZipCodeAirtelNumberQuickRule_failure() {
EspressoHelper.type(R.id.zipCodeEditText, Constants.ZIP_CODE);
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.clickView(R.id.saripaarButton);
EspressoHelper.checkForText(Constants.FIELD_AIRTEL_NUMBER, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testValidZipCodeAirtelNumberQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
Apache-2.0
|
public void testInvalidZipCodeInvalidAirtelNumberQuickRule_failure() {
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.clickView(R.id.saripaarButton);
String result = String.format("%s %s",
Constants.FIELD_ZIP_CODE, Constants.FIELD_AIRTEL_NUMBER);
EspressoHelper.checkForText(result, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testInvalidZipCodeInvalidAirtelNumberQuickRule_failure
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
Apache-2.0
|
public void testZipCodeAirtelNumberQuickRuleValid_success() {
EspressoHelper.clickView(R.id.useQuickRuleRadioButton);
EspressoHelper.type(R.id.zipCodeEditText, Constants.ZIP_CODE);
EspressoHelper.type(R.id.airtelNumberEditText, Constants.AIRTEL_NUMBER);
EspressoHelper.clickView(R.id.saripaarButton);
EspressoHelper.checkForText(Constants.STATE_SUCCESS, mResultTextView);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
testZipCodeAirtelNumberQuickRuleValid_success
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/androidTest/java/com/mobsandgeeks/saripaar/tests/QuickRuleUnorderedTest.java
|
Apache-2.0
|
public static String getFailedFieldNames(List<ValidationError> errors) {
StringBuilder stringBuilder = new StringBuilder();
for (ValidationError error : errors) {
View view = error.getView();
TextView textView = view instanceof FloatLabeledEditText
? ((FloatLabeledEditText) view).getEditText()
: (TextView) view;
List<Rule> failedRules = error.getFailedRules();
String fieldName = textView.getHint().toString().toUpperCase().replaceAll(" ", "_");
for (Rule failedRule : failedRules) {
stringBuilder.append(fieldName).append(" ");
Log.i(Rule.class.getSimpleName(), failedRule.toString());
}
}
return stringBuilder.toString();
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
getFailedFieldNames
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/Common.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/Common.java
|
Apache-2.0
|
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_annotation);
// UI References
mZipCodeEditText = (EditText) findViewById(R.id.zipCodeEditText);
RadioButton registerAnnotationRadioButton =
(RadioButton) findViewById(R.id.registerAnnotationRadioButton);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event listeners
registerAnnotationRadioButton.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Validator.registerAnnotation(HometownZipCode.class);
}
}
}
);
mSaripaarButton.setOnClickListener(this);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCreate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
Apache-2.0
|
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Validator.registerAnnotation(HometownZipCode.class);
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCheckedChanged
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
Apache-2.0
|
@Override
public void onValidationSucceeded() {
mResultTextView.setText(R.string.success);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationSucceeded
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
Apache-2.0
|
@Override
public void onValidationFailed(List<ValidationError> errors) {
mResultTextView.setText(Common.getFailedFieldNames(errors));
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationFailed
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
Apache-2.0
|
@Override
public void onClick(View v) {
try {
mValidator.validate();
} catch (IllegalStateException e) {
mResultTextView.setText("CRASH");
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onClick
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationActivity.java
|
Apache-2.0
|
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_annotation_with_adapter);
// UI References
mSeekBar = (SeekBar) findViewById(R.id.seekBar);
mRegisterAnnotationRadioButton =
(RadioButton) findViewById(R.id.registerAnnotationRadioButton);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validation
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event listeners
mRegisterAnnotationRadioButton.setOnCheckedChangeListener(this);
mSaripaarButton.setOnClickListener(this);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCreate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
public void onClick(final View v) {
try {
mValidator.validate();
} catch (IllegalStateException e) {
mResultTextView.setText("CRASH");
e.printStackTrace();
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onClick
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
public void onValidationSucceeded() {
mResultTextView.setText(R.string.success);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationSucceeded
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
public void onValidationFailed(final List<ValidationError> errors) {
mResultTextView.setText(R.string.failure);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationFailed
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (isChecked) {
SeekBarIntegerAdapter seekBarIntegerAdapter = new SeekBarIntegerAdapter();
Validator.registerAnnotation(To.class, SeekBar.class, seekBarIntegerAdapter);
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCheckedChanged
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
public Integer getData(final SeekBar seekBar) throws ConversionException {
return seekBar.getProgress();
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
getData
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
public <T extends Annotation> boolean containsOptionalValue(
final SeekBar view, final T ruleAnnotation) {
return false;
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
containsOptionalValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomAnnotationWithAdapterActivity.java
|
Apache-2.0
|
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_multiple_view_data_adapters);
// UI References
mEmailFloatLabeledEditText =
(FloatLabeledEditText) findViewById(R.id.emailFloatLabelEditText);
mMaxFloatLabeledEditText = (FloatLabeledEditText) findViewById(R.id.maxFloatLabelEditText);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
RadioButton registerEmailAdapterRadioButton =
(RadioButton) findViewById(R.id.registerEmailAdapterRadioButton);
RadioButton registerMaxAdapterRadioButton =
(RadioButton) findViewById(R.id.registerMaxAdapterRadioButton);
Button saripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event listeners
saripaarButton.setOnClickListener(this);
registerEmailAdapterRadioButton.setOnCheckedChangeListener(this);
registerMaxAdapterRadioButton.setOnCheckedChangeListener(this);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCreate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public void onValidationSucceeded() {
mResultTextView.setText(R.string.success);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationSucceeded
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public void onValidationFailed(List<ValidationError> errors) {
mResultTextView.setText(Common.getFailedFieldNames(errors));
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationFailed
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public void onClick(View v) {
try {
mValidator.validate();
} catch (UnsupportedOperationException e) {
e.printStackTrace();
mResultTextView.setText("CRASH");
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onClick
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
ViewDataAdapter viewDataAdapter;
switch (buttonView.getId()) {
case R.id.registerEmailAdapterRadioButton:
viewDataAdapter = new FletStringAdapter();
break;
case R.id.registerMaxAdapterRadioButton:
viewDataAdapter = new FletIntegerAdapter();
break;
default:
throw new RuntimeException("This should never happen.");
}
mValidator.registerAdapter(FloatLabeledEditText.class, viewDataAdapter);
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCheckedChanged
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public String getData(FloatLabeledEditText flet) throws ConversionException {
return flet.getEditText().getText().toString();
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
getData
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public <T extends Annotation> boolean containsOptionalValue(
final FloatLabeledEditText editText, final T ruleAnnotation) {
return false;
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
containsOptionalValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public Integer getData(FloatLabeledEditText editText) throws ConversionException {
String numberText = editText.getEditText().getText().toString().trim();
int number;
try {
number = Integer.parseInt(numberText);
} catch (NumberFormatException e) {
String message = String.format(
"Unable to convert %s to Integer.", numberText);
throw new ConversionException(message);
}
return number;
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
getData
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
public <T extends Annotation> boolean containsOptionalValue(
final FloatLabeledEditText editText, final T ruleAnnotation) {
return false;
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
containsOptionalValue
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomMultipleViewDataAdaptersActivity.java
|
Apache-2.0
|
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_view_data_adapter);
// UI References
mBooleanFloatLabeledEditText =
(FloatLabeledEditText) findViewById(R.id.booleanFloatLabelEditText);
mRegisterAdapterRadioButton = (RadioButton) findViewById(R.id.registerAdapterRadioButton);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event listeners
mSaripaarButton.setOnClickListener(this);
mRegisterAdapterRadioButton.setOnCheckedChangeListener(this);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCreate
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
Apache-2.0
|
@Override
public void onValidationSucceeded() {
mResultTextView.setText(R.string.success);
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationSucceeded
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
Apache-2.0
|
@Override
public void onValidationFailed(List<ValidationError> errors) {
mResultTextView.setText(Common.getFailedFieldNames(errors));
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onValidationFailed
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
Apache-2.0
|
@Override
public void onClick(View v) {
try {
mValidator.validate();
} catch (UnsupportedOperationException e) {
mResultTextView.setText("CRASH");
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onClick
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
Apache-2.0
|
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mValidator.registerAdapter(FloatLabeledEditText.class,
new ViewDataAdapter<FloatLabeledEditText, Boolean>() {
@Override
public Boolean getData(FloatLabeledEditText flet) throws ConversionException {
String booleanText = flet.getEditText().getText().toString().trim();
return Boolean.parseBoolean(booleanText);
}
@Override
public <T extends Annotation> boolean containsOptionalValue(
final FloatLabeledEditText editText, final T ruleAnnotation) {
return false;
}
}
);
}
}
|
@author Ragunath Jawahar {@literal <rj@mobsandgeeks.com>}
|
onCheckedChanged
|
java
|
ragunathjawahar/android-saripaar
|
saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
https://github.com/ragunathjawahar/android-saripaar/blob/master/saripaar-tests/src/main/java/com/mobsandgeeks/saripaar/tests/ui/CustomViewDataAdapterActivity.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.