OperandStack.java
9.92 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.stream.InputByteStream
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidContentException
* com.adobe.internal.pdftoolkit.core.types.ASArray
* com.adobe.internal.pdftoolkit.core.types.ASBoolean
* com.adobe.internal.pdftoolkit.core.types.ASDictionary
* com.adobe.internal.pdftoolkit.core.types.ASHexString
* com.adobe.internal.pdftoolkit.core.types.ASName
* com.adobe.internal.pdftoolkit.core.types.ASNumber
* com.adobe.internal.pdftoolkit.core.types.ASObject
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.content;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidContentException;
import com.adobe.internal.pdftoolkit.core.types.ASArray;
import com.adobe.internal.pdftoolkit.core.types.ASBoolean;
import com.adobe.internal.pdftoolkit.core.types.ASDictionary;
import com.adobe.internal.pdftoolkit.core.types.ASHexString;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASNumber;
import com.adobe.internal.pdftoolkit.core.types.ASObject;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import java.util.ArrayList;
import java.util.Iterator;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class OperandStack
implements Cloneable {
protected ArrayList<Object> mStack;
public OperandStack() {
this.mStack = new ArrayList();
}
protected OperandStack(ArrayList<Object> aList) {
this.mStack = aList;
}
public Iterator<Object> iterator() {
return this.mStack.iterator();
}
public void pushBoolean(ASBoolean bool) {
this.mStack.add((Object)bool);
}
public void pushArray(ASArray bool) {
this.mStack.add((Object)bool);
}
public void pushDictionary(ASDictionary dictionary) {
this.mStack.add((Object)dictionary);
}
public void pushName(ASName name) {
this.mStack.add((Object)name);
}
public void pushString(ASString string) {
this.mStack.add((Object)string);
}
public void pushASNumber(ASNumber number) {
this.mStack.add((Object)number);
}
public void pushInputByteStream(InputByteStream ibs) {
this.mStack.add((Object)ibs);
}
public boolean peekTypeIsNumber() {
Object object = this.peek();
if (object instanceof ASNumber) {
return true;
}
return false;
}
public boolean peekTypeIsInputByteStream() {
Object object = this.peek();
if (object instanceof InputByteStream) {
return true;
}
return false;
}
public boolean peekTypeIsBoolean() {
Object object = this.peek();
if (object instanceof ASBoolean) {
return true;
}
return false;
}
public boolean peekTypeIsDictionary() {
Object object = this.peek();
if (object instanceof ASDictionary) {
return true;
}
return false;
}
public boolean peekTypeIsArray() {
Object object = this.peek();
if (object instanceof ASArray) {
return true;
}
return false;
}
public boolean peekTypeIsName() {
Object object = this.peek();
if (object instanceof ASName) {
return true;
}
return false;
}
public boolean peekTypeIsString() {
Object object = this.peek();
if (object instanceof ASString) {
return true;
}
return false;
}
public ASNumber peekNumber() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof ASNumber)) {
throw new PDFInvalidContentException("Unexpected operand type: ASNumber was expected for the object " + object);
}
return (ASNumber)object;
}
public InputByteStream peekInputByteStream() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof InputByteStream)) {
throw new PDFInvalidContentException("Unexpected operand type: InputByteStream was expected for the object " + object);
}
return (InputByteStream)object;
}
public String toString() {
StringBuilder str = new StringBuilder("");
for (int i = 0; i < this.mStack.size(); ++i) {
Object operand = this.mStack.get(i);
if (operand instanceof ASString) {
str.append("(").append(((ASString)operand).asString()).append(") ");
continue;
}
if (operand instanceof ASHexString) {
str.append("<").append(((ASHexString)operand).asString()).append("> ");
continue;
}
str.append(this.mStack.get(i).toString()).append(" ");
}
return str.toString();
}
public ASBoolean peekBoolean() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof ASBoolean)) {
throw new PDFInvalidContentException("Unexpected operand type: ASBoolean was expected for the object " + object);
}
return (ASBoolean)object;
}
public ASArray peekArray() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof ASArray)) {
throw new PDFInvalidContentException("Unexpected operand type: ASArray was expected for the object " + object);
}
return (ASArray)object;
}
public ASDictionary peekDictionary() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof ASDictionary)) {
throw new PDFInvalidContentException("Unexpected operand type: ASDictionary was expected for the object " + object);
}
return (ASDictionary)object;
}
public ASName peekName() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof ASName)) {
throw new PDFInvalidContentException("Unexpected operand type: ASName was expected for the object " + object);
}
return (ASName)object;
}
public ASString peekString() throws PDFInvalidContentException {
Object object = this.peek();
if (!(object instanceof ASString)) {
throw new PDFInvalidContentException("Unexpected operand type: ASString was expected for the object " + object);
}
return (ASString)object;
}
public ASNumber popNumber() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof ASNumber)) {
throw new PDFInvalidContentException("Unexpected operand type: ASNumber was expected for the object " + object);
}
return (ASNumber)object;
}
public InputByteStream popInputByteStream() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof InputByteStream)) {
throw new PDFInvalidContentException("Unexpected operand type: InputByteStream was expected for the object " + object);
}
return (InputByteStream)object;
}
public ASBoolean popBoolean() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof ASBoolean)) {
throw new PDFInvalidContentException("Unexpected operand type: ASBoolean was expected for the object " + object);
}
return (ASBoolean)object;
}
public ASDictionary popDictionary() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof ASDictionary)) {
throw new PDFInvalidContentException("Unexpected operand type: ASDictionary was expected for the object " + object);
}
return (ASDictionary)object;
}
public ASArray popArray() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof ASArray)) {
throw new PDFInvalidContentException("Unexpected operand type: ASArray was expected for the object " + object);
}
return (ASArray)object;
}
public ASName popName() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof ASName)) {
throw new PDFInvalidContentException("Unexpected operand type: ASName was expected for the object " + object);
}
return (ASName)object;
}
public ASString popString() throws PDFInvalidContentException {
Object object = this.pop();
if (!(object instanceof ASString)) {
throw new PDFInvalidContentException("Unexpected operand type: ASString was expected for the object " + object);
}
return (ASString)object;
}
public ASDictionary stackToImageDictionary() throws PDFInvalidContentException {
ASDictionary dict = new ASDictionary();
int i = this.mStack.size() - 1;
while (i > 0) {
Object operand;
if ((operand = this.mStack.get(i--)) instanceof InputByteStream) continue;
Object value = operand;
ASName key = (ASName)this.mStack.get(i--);
dict.put(key, (ASObject)value);
}
return dict;
}
public Object peek() {
return this.mStack.get(this.mStack.size() - 1);
}
public Object pop() {
return this.mStack.remove(this.mStack.size() - 1);
}
public void push(Object obj) {
this.mStack.add(obj);
}
public boolean isEmpty() {
return this.mStack.isEmpty();
}
public int getSize() {
return this.mStack.size();
}
protected OperandStack clone() {
if (this.mStack != null) {
ArrayList copy = (ArrayList)this.mStack.clone();
return new OperandStack(copy);
}
return null;
}
}