PDFOCContentUsageUserList.java
5.21 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.CosObject
* com.adobe.internal.pdftoolkit.core.cos.CosString
* com.adobe.internal.pdftoolkit.core.exceptions.PDFException
* 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.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.cos.CosString;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFException;
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.ASString;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class PDFOCContentUsageUserList
extends PDFCosObject {
private PDFOCContentUsageUserList(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFOCContentUsageUserList getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFOCContentUsageUserList pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFOCContentUsageUserList.class);
if (pdfObject == null) {
pdfObject = new PDFOCContentUsageUserList(cosObject);
}
return pdfObject;
}
public static PDFOCContentUsageUserList newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosObject = PDFCosObject.newCosArray(pdfDocument);
return new PDFOCContentUsageUserList((CosObject)cosObject);
}
public static PDFOCContentUsageUserList newInstance(PDFDocument pdfDocument, ASString user) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosObject = PDFCosObject.newCosArray(pdfDocument);
PDFOCContentUsageUserList pdfObject = new PDFOCContentUsageUserList((CosObject)cosObject);
cosObject.addString(user);
return pdfObject;
}
public Iterator iterator() {
return new UserIterator(this.getCosObject());
}
public boolean contains(ASString user) throws PDFSecurityException {
boolean result = false;
CosObject myObj = this.getCosObject();
if (myObj instanceof CosString) {
result = ((CosString)myObj).stringValue().equals(user);
} else if (myObj instanceof CosArray) {
Iterator iter = this.iterator();
boolean iterResult = false;
while (iter.hasNext()) {
ASString objString = (ASString)iter.next();
if (!objString.equals(user)) continue;
iterResult = true;
break;
}
result = iterResult;
}
return result;
}
static class UserIterator
implements Iterator {
private CosObject mNextObj = null;
private int mType;
private Iterator mIterator = null;
private static final int ARRAY = 1;
private static final int STRING = 2;
UserIterator(CosObject cosObject) {
if (cosObject instanceof CosArray) {
this.mIterator = ((CosArray)cosObject).iterator();
this.mType = 1;
} else if (cosObject instanceof CosString) {
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() {
ASString result = null;
try {
if (this.mType == 1) {
CosString resultObj = (CosString)this.mIterator.next();
result = resultObj.stringValue();
} else if (this.mType == 2) {
CosString obj = (CosString)this.mNextObj;
this.mNextObj = null;
result = obj.stringValue();
}
}
catch (PDFException e) {
NoSuchElementException newException = new NoSuchElementException("Error during UserIterator.next().");
newException.initCause((Throwable)e);
throw newException;
}
return result;
}
}
}