CMapCodesSpace.java
3.56 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.fontengine.FontEngineException
*/
package com.adobe.internal.pdftoolkit.pdf.graphics.font.impl;
import com.adobe.fontengine.FontEngineException;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.CMapObject;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class CMapCodesSpace
implements Serializable {
static final long serialVersionUID = 1;
long minCodePos = 0;
long maxCodePos = 0;
int[] codes;
boolean hasInited = false;
int longValuesIndicator = -2;
HashMap<Long, int[]> longValues = null;
public CMapCodesSpace(long min, long max) {
this.minCodePos = min;
this.maxCodePos = max;
}
public long getMinCodePos() {
return this.minCodePos;
}
public long getMaxCodePos() {
return this.maxCodePos;
}
public void addCode(long code, int[] values) {
if (code <= Integer.MAX_VALUE) {
if (!this.hasInited) {
this.init();
this.hasInited = true;
}
if (values.length > 1) {
this.addLongCode(code, values);
int codePos = (int)(code - this.minCodePos);
this.codes[codePos] = this.longValuesIndicator;
} else {
this.addIntCode(code, values[0]);
}
} else {
this.addLongCode(code, values);
}
}
private void addLongCode(long code, int[] values) {
if (this.longValues == null) {
this.longValues = new HashMap();
}
this.longValues.put(code, values);
}
private void addIntCode(long code, int value) {
this.codes[(int)(code - this.minCodePos)] = value;
}
public boolean isCodeInCodeSpace(long code) {
return code >= this.minCodePos && code <= this.maxCodePos;
}
public int[] getCodeValue(long code) {
if (this.isCodeInCodeSpace(code)) {
if (code > Integer.MAX_VALUE) {
return this.longValues.get(code);
}
int codePos = (int)(code - this.minCodePos);
int valuePos = this.codes[codePos];
if (valuePos == -1) {
return new int[]{-1};
}
if (valuePos == this.longValuesIndicator) {
return this.longValues.get(code);
}
return new int[]{this.codes[codePos]};
}
return null;
}
public void enumerateValues(CMapObject.CMapValueConsumer consumer) throws FontEngineException {
for (long i = this.minCodePos; i <= this.maxCodePos; ++i) {
if (i > Integer.MAX_VALUE) {
int[] values = this.longValues.get(i);
consumer.value(i, values);
continue;
}
int codePos = (int)(i - this.minCodePos);
int valuePos = this.codes[codePos];
if (valuePos == -1) continue;
if (valuePos == this.longValuesIndicator) {
consumer.value(i, this.longValues.get(i));
continue;
}
consumer.value(i, this.codes[codePos]);
}
}
int[] getCodes() {
return this.codes;
}
HashMap<Long, int[]> getLongValues() {
return this.longValues;
}
private void init() {
this.codes = new int[(int)(this.maxCodePos - this.minCodePos + 1)];
Arrays.fill(this.codes, -1);
}
}