private Object parseValue(String text,Type type,Type arrayElementType,int flags){
  boolean isint=false, isuint=false;
  Object result=null;
  if (type.equals(typeTable.noType) || type.equals(typeTable.objectType)) {
    result=parseObject(text,arrayElementType,flags);
  }
 else   if (type.equals(typeTable.stringType)) {
    result=parseString(text,flags);
  }
 else   if (type.equals(typeTable.numberType) || (isint=type.equals(typeTable.intType)) || (isuint=type.equals(typeTable.uintType))) {
    if (text.indexOf('%') >= 0) {
      if (allowPercentages(flags)) {
        if ((result=parsePercentage(text)) != null) {
          result=percentage((String)result);
        }
 else {
          result=new ParseError(ErrInvalidPercentage);
        }
      }
 else {
        result=new ParseError(ErrPercentagesNotAllowed);
      }
    }
 else {
      result=isint ? parseInt(text,flags) : isuint ? parseUInt(text,flags) : parseNumber(text,flags);
    }
  }
 else   if (type.equals(typeTable.booleanType)) {
    result=parseBoolean(text);
  }
 else   if (type.equals(typeTable.regExpType)) {
    result=parseRegExp(text);
  }
 else   if (type.equals(typeTable.arrayType)) {
    Collection<Object> c=parseArray(text,arrayElementType,true,flags);
    result=c != null ? array(c,arrayElementType) : null;
  }
 else   if (type.equals(typeTable.functionType)) {
    String f=parseFunction(text);
    result=f != null ? functionText(f) : null;
  }
 else   if (acceptsClassRef(type)) {
    String c=parseClassName(text);
    result=c != null ? className(c,type) : null;
  }
 else {
    result=new ParseError(ErrTypeNotSerializable);
  }
  if (result == null) {
    result=new ParseError(ErrInvalidTextForType);
  }
  if (result instanceof ParseError) {
    error(((ParseError)result).errno,text,type,arrayElementType);
    return null;
  }
 else {
    return result;
  }
}

private Object parseValue ( String text , Type type , Type arrayElementType , int flags ) { boolean isint = false , isuint = false ; Object result = null ; if ( type . equals ( typeTable . noType ) || type . equals ( typeTable . objectType ) ) { result = parseObject ( text , arrayElementType , flags ) ; } else if ( type . equals ( typeTable . stringType ) ) { result = parseString ( text , flags ) ; } else if ( type . equals ( typeTable . numberType ) || ( isint = type . equals ( typeTable . intType ) ) || ( isuint = type . equals ( typeTable . uintType ) ) ) { if ( text . indexOf ( '%' ) >= 0 ) { if ( allowPercentages ( flags ) ) { if ( ( result = parsePercentage ( text ) ) != null ) { result = percentage ( ( String ) result ) ; } else { result = new ParseError ( ErrInvalidPercentage ) ; } } else { result = new ParseError ( ErrPercentagesNotAllowed ) ; } } else { result = isint ? parseInt ( text , flags ) : isuint ? parseUInt ( text , flags ) : parseNumber ( text , flags ) ; } } else if ( type . equals ( typeTable . booleanType ) ) { result = parseBoolean ( text ) ; } else if ( type . equals ( typeTable . regExpType ) ) { result = parseRegExp ( text ) ; } else if ( type . equals ( typeTable . arrayType ) ) { Collection < Object > c = parseArray ( text , arrayElementType , true , flags ) ; result = c != null ? array ( c , arrayElementType ) : null ; } else if ( type . equals ( typeTable . functionType ) ) { String f = parseFunction ( text ) ; result = f != null ? functionText ( f ) : null ; } else if ( acceptsClassRef ( type ) ) { String c = parseClassName ( text ) ; result = c != null ? className ( c , type ) : null ; } else { result = new ParseError ( ErrTypeNotSerializable ) ; } if ( result == null ) { result = new ParseError ( ErrInvalidTextForType ) ; } if ( result instanceof ParseError ) { error ( ( ( ParseError ) result ) . errno , text , type , arrayElementType ) ; return null ; } else { return result ; } }
do type - directed deserialization of typed constant value from text note using equals ( ) not isassignableto ( ) for type testing - all tested classes are final as of 8 / 4 / 05 todo assertions confirming type finality
