Java 类com.itextpdf.text.io.RandomAccessSourceFactory 实例源码

项目:testarea-itext5    文件:StrictPdfCleanUpProcessor.java   
Map<String, List> parseDAParam(PdfString DA) throws IOException {
    Map<String, List> commandArguments = new HashMap<String, List>();

    PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(DA.getBytes())));
    List currentArguments = new ArrayList();

    while (tokeniser.nextToken()) {
        if (tokeniser.getTokenType() == PRTokeniser.TokenType.OTHER) {
            String key = tokeniser.getStringValue();

            if (key.equals("RG") || key.equals("G") || key.equals("K")) {
                key = STROKE_COLOR;
            } else if (key.equals("rg") || key.equals("g") || key.equals("k")) {
                key = FILL_COLOR;
            }

            commandArguments.put(key, currentArguments);
            currentArguments = new ArrayList();
        } else {
            switch (tokeniser.getTokenType()) {
                case NUMBER:
                    currentArguments.add(new PdfNumber(tokeniser.getStringValue()));
                    break;

                case NAME:
                    currentArguments.add(new PdfName(tokeniser.getStringValue()));
                    break;

                default:
                    currentArguments.add(tokeniser.getStringValue());
            }
        }
    }

    return commandArguments;
}