/** * This is used to handle an operation. * * @param operator The operation to perform. * @param operands The list of arguments. * @throws IOException If there is an error processing the operation. */ protected void processOperator(Operator operator, List<COSBase> operands) throws IOException { String name = operator.getName(); OperatorProcessor processor = operators.get(name); if (processor != null) { processor.setContext(this); try { processor.process(operator, operands); } catch (IOException e) { operatorException(operator, operands, e); } } else { unsupportedOperator(operator, operands); } }
/** * Called when an exception is thrown by an operator. * * @param operator The unknown operator. * @param operands The list of operands. */ protected void operatorException(Operator operator, List<COSBase> operands, IOException e) throws IOException { if (e instanceof MissingOperandException || e instanceof MissingResourceException || e instanceof MissingImageReaderException) { // LOG.error(e.getMessage()); } else if (e instanceof EmptyGraphicsStackException) { // LOG.warn(e.getMessage()); } else if (operator.getName().equals("Do")) { // todo: this too forgiving, but PDFBox has always worked this way for DrawObject // some careful refactoring is needed // LOG.warn(e.getMessage()); } else { throw e; } }
/** * This is used to handle an operation. * * @param operation The operation to perform. * @param arguments The list of arguments. * @throws IOException If there is an error processing the operation. */ public void processOperator(String operation, List<COSBase> arguments) throws IOException { Operator operator = Operator.getOperator(operation); processOperator(operator, arguments); }