PDFCollectionItem.java
6.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* 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.PDFCosParseException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException
* 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.PDFCosParseException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionaryMap;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObjectContainer;
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;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.collection.PDFCollectionNameIterator;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.collection.PDFCollectionSubItem;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class PDFCollectionItem
extends PDFCosDictionaryMap<PDFCollectionData> {
public static final ASName k_CollectionItem = ASName.create((String)"CollectionItem");
private ASName mFieldKey = null;
private PDFCollectionItem(CosObject cosDict) throws PDFInvalidDocumentException {
super(cosDict);
}
public static PDFCollectionItem getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFCollectionItem pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFCollectionItem.class);
if (pdfObject == null) {
pdfObject = new PDFCollectionItem(cosObject);
}
return pdfObject;
}
public static PDFCollectionItem newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosObject = PDFCosObject.newCosDictionary(pdfDocument);
PDFCollectionItem pdfObject = new PDFCollectionItem((CosObject)cosObject);
pdfObject.setDictionaryNameValue(ASName.k_Type, k_CollectionItem);
return pdfObject;
}
@Override
protected PDFCollectionData itemInstantiator(CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFInvalidDocumentException, PDFSecurityException {
return cosObject == null ? null : (cosObject.getType() == 6 ? PDFCollectionSubItem.getInstance(cosObject, this.mFieldKey) : PDFCollectionItemData.getInstance(cosObject, this.mFieldKey));
}
public PDFCollectionNameIterator getKeyIterator() {
return new PDFCollectionNameIterator(this);
}
private PDFCollectionData getItemsData(ASName key) {
this.mFieldKey = key;
PDFCollectionData itemData = (PDFCollectionData)PDFCosDictionaryMap.super.get((Object)key);
this.mFieldKey = null;
return itemData;
}
public boolean isData(ASName fieldKey) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return fieldKey.equals((Object)ASName.k_Type) ? false : !this.isSubItem(fieldKey);
}
public boolean isSubItem(ASName fieldKey) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject item = this.getDictionaryValue(fieldKey);
return item != null && item.getType() == 6;
}
public PDFCollectionItemData getData(ASName fieldKey) throws PDFInvalidDocumentException {
PDFCollectionData itemData = this.getItemsData(fieldKey);
if (!(itemData instanceof PDFCollectionItemData)) {
throw new PDFInvalidDocumentException("Collection item's entry is not data");
}
return (PDFCollectionItemData)itemData;
}
public PDFCollectionItemData getItemData(ASName fieldKey) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.isSubItem(fieldKey) ? this.getSubItem(fieldKey).getData() : (this.isData(fieldKey) ? this.getData(fieldKey) : null);
}
public PDFCollectionSubItem getSubItem(ASName fieldKey) throws PDFInvalidDocumentException {
PDFCollectionData itemData = this.getItemsData(fieldKey);
if (!(itemData instanceof PDFCollectionSubItem)) {
throw new PDFInvalidDocumentException("Collection item's entry is not subItem");
}
return (PDFCollectionSubItem)itemData;
}
public void setSubItem(ASName key, PDFCollectionSubItem item) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFCosDictionaryMap.super.put(key, item);
}
public void setData(ASName key, PDFCollectionItemData data) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (data != null) {
PDFCosDictionaryMap.super.put(key, data);
} else {
this.removeData(key);
}
}
public PDFCollectionItemData removeData(ASName key) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFCollectionData oldValue = this.getItemsData(key);
if (oldValue != null && !(oldValue instanceof PDFCollectionItemData)) {
throw new PDFInvalidDocumentException("Collection item's entry is not data");
}
PDFCosDictionaryMap.super.removeValue(key);
return (PDFCollectionItemData)oldValue;
}
public PDFCollectionSubItem removeSubItem(ASName key) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFCollectionData oldValue = this.getItemsData(key);
if (!(oldValue instanceof PDFCollectionSubItem)) {
throw new PDFInvalidDocumentException("Collection item's entry is not SubItem");
}
PDFCosDictionaryMap.super.removeValue(key);
return (PDFCollectionSubItem)oldValue;
}
public boolean containsElement(Object key) {
return this.containsKey(key);
}
}