CharacterIteratorWrapper.java
2.73 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.impl;
import com.adobe.agl.text.UCharacterIterator;
import java.text.CharacterIterator;
public class CharacterIteratorWrapper
extends UCharacterIterator {
private CharacterIterator iterator;
public CharacterIteratorWrapper(CharacterIterator iter) {
if (iter == null) {
throw new IllegalArgumentException();
}
this.iterator = iter;
}
public int current() {
char c = this.iterator.current();
if (c == '\uffff') {
return -1;
}
return c;
}
public int getLength() {
return this.iterator.getEndIndex() - this.iterator.getBeginIndex();
}
public int getIndex() {
return this.iterator.getIndex();
}
public int next() {
char i = this.iterator.current();
this.iterator.next();
if (i == '\uffff') {
return -1;
}
return i;
}
public int previous() {
char i = this.iterator.previous();
if (i == '\uffff') {
return -1;
}
return i;
}
public void setIndex(int index) {
try {
this.iterator.setIndex(index);
}
catch (IllegalArgumentException e) {
throw new IndexOutOfBoundsException();
}
}
public void setToLimit() {
this.iterator.setIndex(this.iterator.getEndIndex());
}
public int getText(char[] fillIn, int offset) {
int length = this.iterator.getEndIndex() - this.iterator.getBeginIndex();
int currentIndex = this.iterator.getIndex();
if (offset < 0 || offset + length > fillIn.length) {
throw new IndexOutOfBoundsException(Integer.toString(length));
}
char ch = this.iterator.first();
while (ch != '\uffff') {
fillIn[offset++] = ch;
ch = this.iterator.next();
}
this.iterator.setIndex(currentIndex);
return length;
}
public Object clone() {
try {
CharacterIteratorWrapper result = (CharacterIteratorWrapper)super.clone();
result.iterator = (CharacterIterator)this.iterator.clone();
return result;
}
catch (CloneNotSupportedException e) {
return null;
}
}
public int moveIndex(int delta) {
int length = this.iterator.getEndIndex() - this.iterator.getBeginIndex();
int idx = this.iterator.getIndex() + delta;
if (idx < 0) {
idx = 0;
} else if (idx > length) {
idx = length;
}
return this.iterator.setIndex(idx);
}
public CharacterIterator getCharacterIterator() {
return (CharacterIterator)this.iterator.clone();
}
}