connectionUtils/src/main/java/com/ge/research/semtk/sparqlX/XSDSupportedType.java
public void validate(String proposedValue) throws Exception{
		
		// datetime: 2014-05-23T10:20:13+05:30
		// date    : 2014-05-23
		Object ret;
		// for each type: return object, throw special exception, or pass through to normal exception
		switch (this) {
		case DATE:
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
				ret = formatter.parse(proposedValue);
				return;
			}
			catch(Exception e){
				throw new Exception(proposedValue + " can't be converted to" + this.name() + ". Accepted format is yyyy-MM-dd." );
			}
		case STRING:
			ret = proposedValue;
			return;
		case BOOLEAN:
			try {
				ret = Boolean.parseBoolean(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case INT:
		case INTEGER:
		case NEGATIVEINTEGER:
		case NONNEGATIVEINTEGER:
		case POSITIVEINTEGER:
		case NONPOSISITIVEINTEGER:
		case UNSIGNEDINT:
			Integer i = null;
			try {
				i = Integer.parseInt(proposedValue);
			}
			catch(Exception e){
			}
			if (this == NEGATIVEINTEGER && i > -1 ||
				this == NONNEGATIVEINTEGER && i < 0 ||
				this == NONPOSISITIVEINTEGER && i > 0 ||
				this == POSITIVEINTEGER && i < 1 ||
				this == NONPOSISITIVEINTEGER && i > 0
				) {
					break;
			} else {
				ret = i;
				return;
			}
		case DECIMAL:	
		case LONG:
			try {
				ret = Long.parseLong(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case FLOAT:
			try {
				ret = Float.parseFloat(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case DOUBLE:
			try {
				ret = Double.parseDouble(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case DATETIME:
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
				ret = formatter.parse(proposedValue);
				return;
			}
			catch(Exception e){
				throw new Exception(proposedValue + " can't be converted to" + this.name() + ". Accepted format is yyyy-MM-dd'T'HH:mm:ss." );
			}
		case TIME:
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
				ret = formatter.parse(proposedValue);
				return;
			}
			catch(Exception e){
				throw new Exception(proposedValue + " can't be converted to" + this.name() + ". Accepted format is HH:mm:ss." );
			}
		case NODE_URI:
			if (SparqlToXUtils.isLegalURI(proposedValue)) {
				ret = proposedValue;
				return;
			}
			// let these types slip through unchecked
		case DURATION:
		case GYEARMONTH:
		case GMONTH:
		case GMONTHDAY:
		case ANYSIMPLETYPE:
		case UNSIGNEDBYTE:
		default:
			ret = proposedValue;
			return;
		}
	
		throw new Exception(proposedValue + " can't be converted to" + this.name());
		
	}
/**
	 * Throw exception if proposedValue is not a legal value
	 * @param proposedValue
	 * @throws Exception
	 */
Throw exception if proposedValue is not a legal value
@param proposedValue
@throws Exception
Throw exception if proposedValue is not a legal value @param proposedValue @throws Exception
public void validate(String proposedValue) throws Exception{
		Object ret;
		switch (this) {
		case DATE:
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
				ret = formatter.parse(proposedValue);
				return;
			}
			catch(Exception e){
				throw new Exception(proposedValue + " can't be converted to" + this.name() + ". Accepted format is yyyy-MM-dd." );
			}
		case STRING:
			ret = proposedValue;
			return;
		case BOOLEAN:
			try {
				ret = Boolean.parseBoolean(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case INT:
		case INTEGER:
		case NEGATIVEINTEGER:
		case NONNEGATIVEINTEGER:
		case POSITIVEINTEGER:
		case NONPOSISITIVEINTEGER:
		case UNSIGNEDINT:
			Integer i = null;
			try {
				i = Integer.parseInt(proposedValue);
			}
			catch(Exception e){
			}
			if (this == NEGATIVEINTEGER && i > -1 ||
				this == NONNEGATIVEINTEGER && i < 0 ||
				this == NONPOSISITIVEINTEGER && i > 0 ||
				this == POSITIVEINTEGER && i < 1 ||
				this == NONPOSISITIVEINTEGER && i > 0
				) {
					break;
			} else {
				ret = i;
				return;
			}
		case DECIMAL:	
		case LONG:
			try {
				ret = Long.parseLong(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case FLOAT:
			try {
				ret = Float.parseFloat(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case DOUBLE:
			try {
				ret = Double.parseDouble(proposedValue);
				return;
			}
			catch(Exception e){
			}
			break;
		case DATETIME:
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
				ret = formatter.parse(proposedValue);
				return;
			}
			catch(Exception e){
				throw new Exception(proposedValue + " can't be converted to" + this.name() + ". Accepted format is yyyy-MM-dd'T'HH:mm:ss." );
			}
		case TIME:
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
				ret = formatter.parse(proposedValue);
				return;
			}
			catch(Exception e){
				throw new Exception(proposedValue + " can't be converted to" + this.name() + ". Accepted format is HH:mm:ss." );
			}
		case NODE_URI:
			if (SparqlToXUtils.isLegalURI(proposedValue)) {
				ret = proposedValue;
				return;
			}
		case DURATION:
		case GYEARMONTH:
		case GMONTH:
		case GMONTHDAY:
		case ANYSIMPLETYPE:
		case UNSIGNEDBYTE:
		default:
			ret = proposedValue;
			return;
		}
		throw new Exception(proposedValue + " can't be converted to" + this.name());
	}
public void validate ( String proposedValue ) throws Exception { Object ret ; switch ( this ) { case DATE : try { SimpleDateFormat formatter = new SimpleDateFormat ( "yyyy-MM-dd" ) ; ret = formatter . parse ( proposedValue ) ; return ; } catch ( Exception e ) { throw new Exception ( proposedValue + " can't be converted to" + this . name ( ) + ". Accepted format is yyyy-MM-dd." ) ; } case STRING : ret = proposedValue ; return ; case BOOLEAN : try { ret = Boolean . parseBoolean ( proposedValue ) ; return ; } catch ( Exception e ) { } break ; case INT : case INTEGER : case NEGATIVEINTEGER : case NONNEGATIVEINTEGER : case POSITIVEINTEGER : case NONPOSISITIVEINTEGER : case UNSIGNEDINT : Integer i = null ; try { i = Integer . parseInt ( proposedValue ) ; } catch ( Exception e ) { } if ( this == NEGATIVEINTEGER && i > - 1 || this == NONNEGATIVEINTEGER && i < 0 || this == NONPOSISITIVEINTEGER && i > 0 || this == POSITIVEINTEGER && i < 1 || this == NONPOSISITIVEINTEGER && i > 0 ) { break ; } else { ret = i ; return ; } case DECIMAL : case LONG : try { ret = Long . parseLong ( proposedValue ) ; return ; } catch ( Exception e ) { } break ; case FLOAT : try { ret = Float . parseFloat ( proposedValue ) ; return ; } catch ( Exception e ) { } break ; case DOUBLE : try { ret = Double . parseDouble ( proposedValue ) ; return ; } catch ( Exception e ) { } break ; case DATETIME : try { SimpleDateFormat formatter = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss" ) ; ret = formatter . parse ( proposedValue ) ; return ; } catch ( Exception e ) { throw new Exception ( proposedValue + " can't be converted to" + this . name ( ) + ". Accepted format is yyyy-MM-dd'T'HH:mm:ss." ) ; } case TIME : try { SimpleDateFormat formatter = new SimpleDateFormat ( "HH:mm:ss" ) ; ret = formatter . parse ( proposedValue ) ; return ; } catch ( Exception e ) { throw new Exception ( proposedValue + " can't be converted to" + this . name ( ) + ". Accepted format is HH:mm:ss." ) ; } case NODE_URI : if ( SparqlToXUtils . isLegalURI ( proposedValue ) ) { ret = proposedValue ; return ; } case DURATION : case GYEARMONTH : case GMONTH : case GMONTHDAY : case ANYSIMPLETYPE : case UNSIGNEDBYTE : default : ret = proposedValue ; return ; } throw new Exception ( proposedValue + " can't be converted to" + this . name ( ) ) ; }
Throw exception if proposedValue is not a legal value
 @param proposedValue
 @throws Exception
Throw exception if proposedValue is not a legal value @param proposedValue @throws Exception
// datetime: 2014-05-23T10:20:13+05:30 // date    : 2014-05-23 // for each type: return object, throw special exception, or pass through to normal exception // let these types slip through unchecked