PDFOCIntentList.java
5.23 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosName
* 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.PDFInvalidParameterException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosName;
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.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import java.util.Iterator;
public class PDFOCIntentList
extends PDFCosObject {
private PDFOCIntentList(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFOCIntentList getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFOCIntentList pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFOCIntentList.class);
if (pdfObject == null) {
pdfObject = new PDFOCIntentList(cosObject);
}
return pdfObject;
}
public static PDFOCIntentList newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosObject = PDFCosObject.newCosArray(pdfDocument);
return new PDFOCIntentList((CosObject)cosObject);
}
public static PDFOCIntentList newInstance(PDFDocument pdfDocument, ASName intent) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
CosArray cosObject = PDFCosObject.newCosArray(pdfDocument);
PDFOCIntentList pdfObject = new PDFOCIntentList((CosObject)cosObject);
pdfObject.add(intent);
return pdfObject;
}
private void add(ASName intent) throws PDFIOException, PDFSecurityException, PDFInvalidParameterException, PDFInvalidDocumentException {
CosObject currentCosObj = this.getCosObject();
if (!(currentCosObj instanceof CosArray)) {
throw new PDFInvalidParameterException("Illegal attempt to add an intent name to a single Intent name rather than an Intent array.");
}
((CosArray)currentCosObj).addName(intent);
}
public Iterator iterator() {
return new IntentIterator(this.getCosObject());
}
public boolean contains(ASName intent) {
boolean result = false;
CosObject myObj = this.getCosObject();
if (myObj instanceof CosName) {
result = ((CosName)myObj).nameValue().equals((Object)intent);
} else if (myObj instanceof CosArray) {
Iterator iter = this.iterator();
boolean iterResult = false;
while (iter.hasNext()) {
ASName objName = (ASName)iter.next();
if (objName == null || !objName.equals((Object)intent)) continue;
iterResult = true;
break;
}
result = iterResult;
}
return result;
}
static class IntentIterator
implements Iterator {
private CosObject mNextObj = null;
private int mType;
private Iterator mIterator = null;
private static final int ARRAY = 1;
private static final int NAME = 2;
IntentIterator(CosObject cosObject) {
if (cosObject instanceof CosArray) {
this.mIterator = ((CosArray)cosObject).iterator();
this.mType = 1;
} else if (cosObject instanceof CosName) {
this.mNextObj = cosObject;
this.mType = 2;
}
}
public void remove() {
throw new UnsupportedOperationException("Not implemented");
}
public boolean hasNext() {
boolean result = false;
if (this.mType == 1) {
result = this.mIterator.hasNext();
} else if (this.mType == 2) {
result = this.mNextObj != null;
}
return result;
}
public Object next() {
ASName result = null;
if (this.mType == 1) {
CosName resultObj = (CosName)this.mIterator.next();
result = resultObj.nameValue();
} else if (this.mType == 2) {
CosName obj = (CosName)this.mNextObj;
this.mNextObj = null;
result = obj.nameValue();
}
return result;
}
}
}