package org.verapdf.model.impl.pb.cos;

import org.apache.log4j.Logger;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSObject;
import org.verapdf.model.coslayer.CosIndirect;
import org.verapdf.model.coslayer.CosObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Evgeniy Muravitskiy on 4/28/15.
 * <p>
 *     Current class is representation of CosIndirect interface of abstract model.
 *     This class is analogue of COSObject in pdfbox.
 * </p>
 */
public class PBCosIndirect extends PBCosObject implements CosIndirect {

    private final static Logger logger = Logger.getLogger(PBCosIndirect.class);

    public final static String DIRECT_OBJECT = "directObject";

    private Boolean isSpacingComplyPDFA;

    public PBCosIndirect(COSBase directObject, Boolean isSpacingComplyPDFA) {
        super(directObject);
        this.isSpacingComplyPDFA = isSpacingComplyPDFA;
        setType("CosIndirect");
    }

    @Override
    public List<? extends org.verapdf.model.baselayer.Object> getLinkedObjects(String link) {
        List<? extends org.verapdf.model.baselayer.Object> list;

        switch (link) {
            case DIRECT_OBJECT:
                list = getDirectObject();
                break;
            default:
                throw new IllegalArgumentException("Unknown link " + link + " for " + getType());
        }

        return list;
    }

    /** Get the direct contents of the indirect object
     */
    protected List<CosObject> getDirectObject() {
        List<CosObject> list = new ArrayList<>();
        COSBase base = baseObject instanceof COSObject ? ((COSObject) baseObject).getObject() : baseObject;
        list.add(getFromValue(base));
        return list;
    }

    /**  true if the words 'obj' and 'endobj' are surrounded by the correct spacings according to PDF/A standard
     */
    @Override
    public Boolean getspacingComplyPDFA() {
        logger.warn("Feature of CosIndirect about spacings comply PDFA not supported yet.");
        return isSpacingComplyPDFA;
    }
}

@@ -37,40 +37,8 @@
 s;%0A%0A
-import org.apache.log4j.Logger;%0A
 impo
@@ -539,89 +539,8 @@
  %7B%0A%0A
-    private final static Logger logger = Logger.getLogger(PBCosIndirect.class);%0A%0A
     
@@ -603,50 +603,8 @@
 %22;%0A%0A
-    private Boolean isSpacingComplyPDFA;%0A%0A
     
@@ -648,37 +648,8 @@
 ject
-, Boolean isSpacingComplyPDFA
 ) %7B%0A
@@ -681,64 +681,8 @@
 t);%0A
-        this.isSpacingComplyPDFA = isSpacingComplyPDFA;%0A
     
@@ -1671,25 +1671,27 @@
 spacingCompl
-y
+ies
 PDFA() %7B%0A   
@@ -1699,117 +1699,197 @@
     
-logger.warn(%22Feature of CosIndirect about spacings c
+return ((COSObject) baseObject).isEndOfObjectC
 omply
- 
 PDFA
- not supported yet.%22);%0A        return isSpacing
+()%0A                && ((COSObject) baseObject).isHeaderFormatComplyPDFA()%0A                && ((COSObject) baseObject).isHeaderOfObject
 Comp
@@ -1894,16 +1894,18 @@
 mplyPDFA
+()
 ;%0A    %7D%0A

Add support of spacings for CosIndirect