c = (char)pdfSource.peek(); //check for second left bracket
pdfSource.unread( leftBracket ); //put back first bracket
if(c == '<')
{
COSDictionary pod = parseCOSDictionary();
skipSpaces();
if((char)pdfSource.peek() == 's')
{
retval = parseCOSStream( pod, file );
}
else
{
retval = pod;
}
}
else
{
retval = parseCOSString();
}
break;
}
case '[': // array
{
retval = parseCOSArray();
break;
}
case '(': // string
retval = parseCOSString();
break;
case '/': // name
retval = parseCOSName();
break;
case 'n': // null
{
String nullString = readString();
if( nullString.equals( "null") )
{
retval = COSNull.NULL;
}
else
{
retval = PDFOperator.getOperator( nullString );
}
break;
}
case 't':
case 'f':
{
String next = readString();
if( next.equals( "true" ) )
{
retval = COSBoolean.TRUE;
break;
}
else if( next.equals( "false" ) )
{
retval = COSBoolean.FALSE;
}
else
{
retval = PDFOperator.getOperator( next );
}
break;
}
case 'R':
{
String line = readString();
if( line.equals( "R" ) )
{
retval = new COSObject( null );
}
else
{
retval = PDFOperator.getOperator( line );
}
break;
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '+':
case '.':
{
if( Character.isDigit(c) || c == '-' || c == '+' || c == '.')
{
StringBuffer buf = new StringBuffer();
while( Character.isDigit(( c = (char)pdfSource.peek()) )|| c== '-' || c== '+' || c =='.' )
{
buf.append( c );
pdfSource.read();
}
retval = COSNumber.get( buf.toString() );
}
else
{
throw new IOException( "Unknown dir object c='" + c +
"' peek='" + (char)pdfSource.peek() + "' " + pdfSource );
}
break;
}
case 'B':
{
String next = readString();
retval = PDFOperator.getOperator( next );
if( next.equals( "BI" ) )
{
lastBIToken = (PDFOperator)retval;
COSDictionary imageParams = new COSDictionary();
lastBIToken.setImageParameters( new ImageParameters( imageParams ) );
Object nextToken = null;
while( (nextToken = parseNextToken()) instanceof COSName )
{
Object value = parseNextToken();
imageParams.setItem( (COSName)nextToken, (COSBase)value );
}
//final token will be the image data, maybe??
PDFOperator imageData = (PDFOperator)nextToken;
lastBIToken.setImageData( imageData.getImageData() );
}