private Object parseObject() throws PDFParseException {
  final Tok t=nextToken();
switch (t.type) {
case Tok.NUM:
    return new Double(tok.value);
case Tok.STR:
case Tok.NAME:
  return tok.name;
case Tok.BRKB:
{
  final HashMap<String,PDFObject> hm=new HashMap<String,PDFObject>();
  String name=null;
  for (Object obj=null; (obj=parseObject()) != null; ) {
    if (name == null) {
      name=(String)obj;
    }
 else {
      hm.put(name,new PDFObject(obj));
      name=null;
    }
  }
  if (tok.type != Tok.BRKE) {
    throw new PDFParseException("Inline dict should have ended with '>>'");
  }
  return hm;
}
case Tok.ARYB:
{
final ArrayList<Object> ary=new ArrayList<Object>();
for (Object obj=null; (obj=parseObject()) != null; ) {
  ary.add(obj);
}
if (tok.type != Tok.ARYE) {
  throw new PDFParseException("Expected ']'");
}
return ary.toArray();
}
case Tok.CMD:
return t;
}
if (!RELEASE) {
debug("**** WARNING! parseObject unknown token! (t.type=" + t.type + ") *************************",4);
}
return null;
}

private Object parseObject ( ) throws PDFParseException { final Tok t = nextToken ( ) ; switch ( t . type ) { case Tok . NUM : return new Double ( tok . value ) ; case Tok . STR : case Tok . NAME : return tok . name ; case Tok . BRKB : { final HashMap < String , PDFObject > hm = new HashMap < String , PDFObject > ( ) ; String name = null ; for ( Object obj = null ; ( obj = parseObject ( ) ) != null ; ) { if ( name == null ) { name = ( String ) obj ; } else { hm . put ( name , new PDFObject ( obj ) ) ; name = null ; } } if ( tok . type != Tok . BRKE ) { throw new PDFParseException ( "Inline dict should have ended with '>>'" ) ; } return hm ; } case Tok . ARYB : { final ArrayList < Object > ary = new ArrayList < Object > ( ) ; for ( Object obj = null ; ( obj = parseObject ( ) ) != null ; ) { ary . add ( obj ) ; } if ( tok . type != Tok . ARYE ) { throw new PDFParseException ( "Expected ']'" ) ; } return ary . toArray ( ) ; } case Tok . CMD : return t ; } if ( ! RELEASE ) { debug ( "**** WARNING! parseObject unknown token! (t.type=" + t . type + ") *************************" , 4 ) ; } return null ; }
parse the next object out of the pdf stream . this could be a double , a string , a hashmap ( dictionary ) , object [ ] array , or a tok containing a pdf command .
