Source code for DataObject.java
package PhoneApp.Data;
abstract class DataObject {
protected boolean testInt(int newInt, int contentType, int condition, int maxLength) {
boolean validity = true;
if (contentType == VERIFY_POSITIVE && newInt < 0 ) {
validity = false;
}
return validity;
}
protected boolean testString(String newString, int contentType, int condition, int maxLength) {
boolean validity = true;
if (contentType == VERIFY_TEXT) {
}
if (condition == VERIFY_MANDATORY) {
if (newString == null ) {
validity = false;
} else if ( newString.length() == 0 ) {
validity = false;
}
} else if ( condition == VERIFY_NOTNULL && newString == null ) {
validity = false;
} else if ( condition == VERIFY_EMPTY) {
if ( newString == null ) {
validity = false;
} else if ( newString.length() > 0 ) {
validity = false;
}
} else if ( condition == VERIFY_NULL && newString != null ) {
validity=false;
}
if ( newString != null ) {
if ( newString.length() > maxLength) {
validity = false;
}
}
return validity;
}
protected void debug(String method, String msg) {
System.out.println(method + ": " + msg);
System.out.flush();
}
protected static final int VERIFY_TEXT = 0;
protected static final int VERIFY_MANDATORY = 1;
protected static final int VERIFY_POSITIVE = 2;
protected static final int VERIFY_EMPTY = 3;
protected static final int VERIFY_NOTNULL = 4;
protected static final int VERIFY_NULL = 5;
protected static final int VERIFY_PHONENUMBER= 6;
protected static final int VERIFY_OPTIONAL = 7;
}