CosContainer.java
5.54 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.stream.InputByteStream
*/
package com.adobe.internal.pdftoolkit.core.cos;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.pdftoolkit.core.cos.CosContainerValuesIterator;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.cos.CosObjectInfo;
import com.adobe.internal.pdftoolkit.core.cos.CosParseBuf;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public abstract class CosContainer
extends CosObject {
protected CosContainer mParentObj;
private static final ASName k_endobj = ASName.create("endobj");
CosContainer(CosDocument doc, CosObjectInfo info) {
super(doc, info);
}
abstract void setParentObj(CosContainer var1);
CosContainer getParentObj() {
return this.mParentObj;
}
@Override
public boolean markNotDirty() {
if (this.isIndirect()) {
return super.markNotDirty();
}
if (this.mParentObj != null) {
return this.mParentObj.markNotDirty();
}
return false;
}
public Map findObjPos(Map keys) throws PDFIOException {
try {
HashMap<ASName, Long[]> retVal = new HashMap<ASName, Long[]>();
keys.put(k_endobj, 1);
long curPos = this.getObjPos();
InputByteStream fileStream = this.getDocument().getStreamRaw();
long endPos = fileStream.length();
fileStream.seek(curPos);
CosParseBuf pBuf = new CosParseBuf(fileStream, 4096);
int[] indexes = new int[keys.size()];
byte[][] byteKeys = new byte[keys.size()][];
ASName[] names = new ASName[keys.size()];
int[] locIndex = new int[keys.size()];
int k = 0;
for (ASName names[k] : keys.keySet()) {
byteKeys[k] = names[k].getBytes();
indexes[k] = (Integer)keys.get(names[k]);
Long[] location = new Long[((Integer)keys.get(names[k])).intValue()];
for (int i = 0; i < location.length; ++i) {
location[i] = 0;
}
retVal.put(names[k], location);
++k;
}
while (curPos < endPos) {
int c = pBuf.read();
++curPos;
boolean done = true;
for (k = 0; k < byteKeys.length; ++k) {
if (indexes[k] <= 0) continue;
done = false;
if ((byte)c == byteKeys[k][locIndex[k]]) {
int[] arrn = locIndex;
int n = k;
arrn[n] = arrn[n] + 1;
} else {
locIndex[k] = 0;
}
if (locIndex[k] != byteKeys[k].length) continue;
Long[] location = (Long[])retVal.get(names[k]);
location[((Integer)keys.get((Object)names[k])).intValue() - indexes[k]] = curPos;
int[] arrn = indexes;
int n = k;
arrn[n] = arrn[n] - 1;
locIndex[k] = 0;
if (names[k] != k_endobj) continue;
return retVal;
}
if (!done) continue;
break;
}
return retVal;
}
catch (IOException e) {
throw new PDFIOException(e);
}
}
protected int cosObjectPairAlreadyInList(Integer[] objectNums, HashMap<Integer, HashSet<Integer>> alreadyComparedCosObjectPairsList) {
HashSet<Integer> matchedCosObjectsSet;
if (objectNums[0] > objectNums[1]) {
int temp = objectNums[0];
objectNums[0] = objectNums[1];
objectNums[1] = temp;
}
if ((matchedCosObjectsSet = alreadyComparedCosObjectPairsList.get(objectNums[0])) != null) {
if (matchedCosObjectsSet.contains(objectNums[1])) {
return 0;
}
return 1;
}
return 2;
}
protected boolean addCosObjectPair(int objNum, HashMap<Integer, HashSet<Integer>> alreadyComparedCosObjectPairsList) {
Integer[] objectNums = new Integer[]{this.getObjNum(), objNum};
if (objectNums[0] <= 0 || objectNums[1] <= 0) {
return true;
}
int pairExistenceStatus = this.cosObjectPairAlreadyInList(objectNums, alreadyComparedCosObjectPairsList);
switch (pairExistenceStatus) {
case 0: {
return false;
}
case 1: {
alreadyComparedCosObjectPairsList.get(objectNums[0]).add(objectNums[1]);
break;
}
case 2: {
HashSet<Integer> matchedCosObjectsSet = new HashSet<Integer>();
matchedCosObjectsSet.add(objectNums[1]);
alreadyComparedCosObjectPairsList.put(objectNums[0], matchedCosObjectsSet);
}
}
return true;
}
public abstract CosContainerValuesIterator getValuesIterator();
abstract boolean safeEquals(CosObject var1, HashMap<Integer, HashSet<Integer>> var2);
}