valerybokov commented on pull request #107:
URL: https://github.com/apache/pdfbox/pull/107#issuecomment-818582148
The CMapParser.parceNextToken method returns an Object instead of a specific
data type, and you must use the instanceof statement to understand the type.
It will be much faster if you add a field that will be initialized inside
the parceNextToken.
Example:
public class CMapParser
{
private static final byte RETURNTYPE_STRING = 0;
private static byte final RETURNTYPE_NUMBER = 1;
private static byte final RETURNTYPE_OPERATOR = 2;
private byte currentReturnType;
//...
private Object parseNextToken(PushbackInputStream is) throws IOException
{
Object retval = null;
int nextByte = is.read();
// skip whitespace
while (nextByte == 0x09 || nextByte == 0x20 || nextByte == 0x0D ||
nextByte == 0x0A)
{
nextByte = is.read();
}
switch (nextByte)
{
case '%':
{
// header operations, for now return the entire line
// may need to smarter in the future
StringBuilder buffer = new StringBuilder();
buffer.append((char) nextByte);
readUntilEndOfLine(is, buffer);
retval = buffer.toString();
currentReturnType = RETURNTYPE_STRING;//HERE!!!
break;
}
//...
}
//...
}
/*
using:
................................
case "CMapVersion":
{
Object next = parseNextToken(cmapStream);
if (currentReturnType == RETURNTYPE_NUMBER)
{
result.setVersion(next.toString());
}
else if (currentReturnType == RETURNTYPE_STRING)
{
result.setVersion((String) next);
}
break;
}
................................
*/
}
I able to change it if you will interested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]