public Object readObject(Class expectedClass) throws IOException {
  if (!parseTag())   throw new BurlapProtocolException("expected <tag>");
  String tag=sbuf.toString();
  if (tag.equals("null")) {
    expectEndTag("null");
    return null;
  }
 else   if (tag.equals("boolean")) {
    int value=parseInt();
    expectEndTag("boolean");
    return new Boolean(value != 0);
  }
 else   if (tag.equals("int")) {
    int value=parseInt();
    expectEndTag("int");
    return new Integer(value);
  }
 else   if (tag.equals("long")) {
    long value=parseLong();
    expectEndTag("long");
    return new Long(value);
  }
 else   if (tag.equals("string")) {
    sbuf.setLength(0);
    parseString(sbuf);
    String value=sbuf.toString();
    expectEndTag("string");
    return value;
  }
 else   if (tag.equals("xml")) {
    sbuf.setLength(0);
    parseString(sbuf);
    String value=sbuf.toString();
    expectEndTag("xml");
    return value;
  }
 else   if (tag.equals("date")) {
    if (utcCalendar == null)     utcCalendar=Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    long value=parseDate(utcCalendar);
    expectEndTag("date");
    return new Date(value);
  }
 else   if (tag.equals("map")) {
    String type=readType();
    return readMap(expectedClass,type);
  }
 else   if (tag.equals("list")) {
    String type=readType();
    int length=readLength();
    return readList(expectedClass,type,length);
  }
 else   if (tag.equals("ref")) {
    int value=parseInt();
    expectEndTag("ref");
    return refs.elementAt(value);
  }
 else   if (tag.equals("remote")) {
    String type=readType();
    String url=readString();
    expectEndTag("remote");
    return resolveRemote(type,url);
  }
 else   return readExtensionObject(expectedClass,tag);
}

public Object readObject ( Class expectedClass ) throws IOException { if ( ! parseTag ( ) ) throw new BurlapProtocolException ( "expected <tag>" ) ; String tag = sbuf . toString ( ) ; if ( tag . equals ( "null" ) ) { expectEndTag ( "null" ) ; return null ; } else if ( tag . equals ( "boolean" ) ) { int value = parseInt ( ) ; expectEndTag ( "boolean" ) ; return new Boolean ( value != 0 ) ; } else if ( tag . equals ( "int" ) ) { int value = parseInt ( ) ; expectEndTag ( "int" ) ; return new Integer ( value ) ; } else if ( tag . equals ( "long" ) ) { long value = parseLong ( ) ; expectEndTag ( "long" ) ; return new Long ( value ) ; } else if ( tag . equals ( "string" ) ) { sbuf . setLength ( 0 ) ; parseString ( sbuf ) ; String value = sbuf . toString ( ) ; expectEndTag ( "string" ) ; return value ; } else if ( tag . equals ( "xml" ) ) { sbuf . setLength ( 0 ) ; parseString ( sbuf ) ; String value = sbuf . toString ( ) ; expectEndTag ( "xml" ) ; return value ; } else if ( tag . equals ( "date" ) ) { if ( utcCalendar == null ) utcCalendar = Calendar . getInstance ( TimeZone . getTimeZone ( "UTC" ) ) ; long value = parseDate ( utcCalendar ) ; expectEndTag ( "date" ) ; return new Date ( value ) ; } else if ( tag . equals ( "map" ) ) { String type = readType ( ) ; return readMap ( expectedClass , type ) ; } else if ( tag . equals ( "list" ) ) { String type = readType ( ) ; int length = readLength ( ) ; return readList ( expectedClass , type , length ) ; } else if ( tag . equals ( "ref" ) ) { int value = parseInt ( ) ; expectEndTag ( "ref" ) ; return refs . elementAt ( value ) ; } else if ( tag . equals ( "remote" ) ) { String type = readType ( ) ; String url = readString ( ) ; expectEndTag ( "remote" ) ; return resolveRemote ( type , url ) ; } else return readExtensionObject ( expectedClass , tag ) ; }
reads an arbitrary object the input stream .
