Example usage for org.apache.pdfbox.cos COSString accept

List of usage examples for org.apache.pdfbox.cos COSString accept

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSString accept.

Prototype

@Override
public Object accept(ICOSVisitor visitor) throws IOException 

Source Link

Document

Visitor pattern double dispatch method.

Usage

From source file:com.aaasec.sigserv.csspsupport.pdfbox.modifications.CsCOSWriter.java

License:Apache License

/**
 * visitFromArray method comment.//from   w  ww . ja  v  a2  s  . c  om
 *
 * @param obj The object that is being visited.
 *
 * @throws COSVisitorException If there is an exception while visiting this
 * object.
 *
 * @return null
 */
public Object visitFromArray(COSArray obj) throws COSVisitorException {
    try {
        int count = 0;
        getStandardOutput().write(ARRAY_OPEN);
        for (Iterator<COSBase> i = obj.iterator(); i.hasNext();) {
            COSBase current = i.next();
            if (current instanceof COSDictionary) {
                addObjectToWrite(current);
                writeReference(current);
            } else if (current instanceof COSObject) {
                COSBase subValue = ((COSObject) current).getObject();
                if (subValue instanceof COSDictionary || subValue == null) {
                    addObjectToWrite(current);
                    writeReference(current);
                } else {
                    subValue.accept(this);
                }
            } else if (current == null) {
                COSNull.NULL.accept(this);
            } else if (current instanceof COSString) {
                COSString copy = new COSString(((COSString) current).getString());
                copy.accept(this);
            } else {
                current.accept(this);
            }
            count++;
            if (i.hasNext()) {
                if (count % 10 == 0) {
                    getStandardOutput().writeEOL();
                } else {
                    getStandardOutput().write(SPACE);
                }
            }
        }
        getStandardOutput().write(ARRAY_CLOSE);
        getStandardOutput().writeEOL();
        return null;
    } catch (IOException e) {
        throw new COSVisitorException(e);
    }
}