PDFCollectionSubItem.java 3.76 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.internal.pdftoolkit.core.cos.CosDictionary
 *  com.adobe.internal.pdftoolkit.core.cos.CosObject
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
 *  com.adobe.internal.pdftoolkit.core.types.ASName
 */
package com.adobe.internal.pdftoolkit.pdf.interactive.navigation.collection;

import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
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.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.collection.PDFCollectionData;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.collection.PDFCollectionItemData;

public class PDFCollectionSubItem
extends PDFCosDictionary
implements PDFCollectionData {
    public static final ASName k_CollectionSubitem = ASName.create((String)"CollectionSubitem");
    ASName mFieldKey = null;

    private PDFCollectionSubItem(CosObject cosObject) throws PDFInvalidDocumentException {
        super(cosObject);
    }

    public static PDFCollectionSubItem getInstance(CosObject cosObject, ASName fieldKey) throws PDFInvalidDocumentException {
        if (PDFCosObject.checkNullCosObject(cosObject) == null) {
            return null;
        }
        PDFCollectionSubItem pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFCollectionSubItem.class);
        if (pdfObject == null) {
            pdfObject = new PDFCollectionSubItem(cosObject);
        }
        pdfObject.mFieldKey = fieldKey;
        return pdfObject;
    }

    public static PDFCollectionSubItem newInstance(PDFDocument pdfDocument, PDFCollectionItemData data, String prefix, ASName fieldKey) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        CosDictionary cosObject = PDFCosObject.newCosDictionary(pdfDocument);
        PDFCollectionSubItem pdfObject = new PDFCollectionSubItem((CosObject)cosObject);
        pdfObject.setDictionaryNameValue(ASName.k_Type, k_CollectionSubitem);
        if (data != null) {
            pdfObject.setDictionaryValue(ASName.k_D, data);
        }
        if (prefix != null) {
            pdfObject.setDictionaryStringValue(ASName.k_P, prefix);
        }
        return pdfObject;
    }

    public PDFCollectionItemData getData() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        return PDFCollectionItemData.getInstance(this.getDictionaryValue(ASName.k_D), this.mFieldKey);
    }

    public void setData(PDFCollectionItemData data) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        if (data != null) {
            this.setDictionaryValue(ASName.k_D, data);
        } else {
            this.removeValue(ASName.k_D);
        }
    }

    public String getPrefix() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        return this.getDictionaryTextStringValue(ASName.k_P);
    }

    public void setPrefix(String prefix) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        if (prefix != null) {
            this.setDictionaryStringValue(ASName.k_P, prefix);
        } else {
            this.removeValue(ASName.k_P);
        }
    }
}