ReplaceableUCharacterIterator.java
2.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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.impl;
import com.adobe.agl.impl.UCharacterProperty;
import com.adobe.agl.text.Replaceable;
import com.adobe.agl.text.ReplaceableString;
import com.adobe.agl.text.UCharacterIterator;
import com.adobe.agl.text.UTF16;
public class ReplaceableUCharacterIterator
extends UCharacterIterator {
private Replaceable replaceable;
private int currentIndex;
public ReplaceableUCharacterIterator(Replaceable replaceable) {
if (replaceable == null) {
throw new IllegalArgumentException();
}
this.replaceable = replaceable;
this.currentIndex = 0;
}
public ReplaceableUCharacterIterator(String str) {
if (str == null) {
throw new IllegalArgumentException();
}
this.replaceable = new ReplaceableString(str);
this.currentIndex = 0;
}
public ReplaceableUCharacterIterator(StringBuffer buf) {
if (buf == null) {
throw new IllegalArgumentException();
}
this.replaceable = new ReplaceableString(buf);
this.currentIndex = 0;
}
public Object clone() {
try {
return super.clone();
}
catch (CloneNotSupportedException e) {
return null;
}
}
public int current() {
if (this.currentIndex < this.replaceable.length()) {
return this.replaceable.charAt(this.currentIndex);
}
return -1;
}
public int currentCodePoint() {
int ch = this.current();
if (UTF16.isLeadSurrogate((char)ch)) {
this.next();
int ch2 = this.current();
this.previous();
if (UTF16.isTrailSurrogate((char)ch2)) {
return UCharacterProperty.getRawSupplementary((char)ch, (char)ch2);
}
}
return ch;
}
public int getLength() {
return this.replaceable.length();
}
public int getIndex() {
return this.currentIndex;
}
public int next() {
if (this.currentIndex < this.replaceable.length()) {
return this.replaceable.charAt(this.currentIndex++);
}
return -1;
}
public int previous() {
if (this.currentIndex > 0) {
return this.replaceable.charAt(--this.currentIndex);
}
return -1;
}
public void setIndex(int currentIndex) throws IndexOutOfBoundsException {
if (currentIndex < 0 || currentIndex > this.replaceable.length()) {
throw new IndexOutOfBoundsException();
}
this.currentIndex = currentIndex;
}
public int getText(char[] fillIn, int offset) {
int length = this.replaceable.length();
if (offset < 0 || offset + length > fillIn.length) {
throw new IndexOutOfBoundsException(Integer.toString(length));
}
this.replaceable.getChars(0, length, fillIn, offset);
return length;
}
}