StatefulContentStreamProcessor.java 2.26 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
 */
package com.adobe.internal.pdftoolkit.pdf.content.processor;

import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.pdf.content.Content;
import com.adobe.internal.pdftoolkit.pdf.content.ContentReader;
import com.adobe.internal.pdftoolkit.pdf.content.ContentStack;
import com.adobe.internal.pdftoolkit.pdf.content.Instruction;
import com.adobe.internal.pdftoolkit.pdf.content.StatefulOperatorHandler;
import com.adobe.internal.pdftoolkit.pdf.content.processor.ContentStreamProcessor;
import com.adobe.internal.pdftoolkit.pdf.content.processor.IOperatorHandler;
import java.io.IOException;

public class StatefulContentStreamProcessor
extends ContentStreamProcessor {
    public StatefulContentStreamProcessor(StatefulOperatorHandler operatorHandlers) {
        this.operatorHandler = operatorHandlers;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void process(Content content) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        ((StatefulOperatorHandler)this.operatorHandler).getContentStack().push(content);
        ContentReader reader = null;
        try {
            reader = ContentReader.newInstance(content);
            this.process(reader);
        }
        finally {
            ((StatefulOperatorHandler)this.operatorHandler).getContentStack().pop();
            if (reader != null) {
                try {
                    reader.close();
                }
                catch (IOException e) {}
            }
        }
    }

    public void process(ContentReader reader) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        while (reader.hasNext()) {
            Instruction instruction = reader.next();
            this.process(instruction);
        }
    }
}