ParseState.java
1.33 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.internal.xmp.impl;
import com.adobe.internal.xmp.XMPException;
class ParseState {
private String str;
private int pos = 0;
public ParseState(String str) {
this.str = str;
}
public int length() {
return this.str.length();
}
public boolean hasNext() {
return this.pos < this.str.length();
}
public char ch(int index) {
return index < this.str.length() ? this.str.charAt(index) : '\u0000';
}
public char ch() {
return this.pos < this.str.length() ? this.str.charAt(this.pos) : '\u0000';
}
public void skip() {
++this.pos;
}
public int pos() {
return this.pos;
}
public int gatherInt(String errorMsg, int maxValue) throws XMPException {
int value = 0;
boolean success = false;
char ch = this.ch(this.pos);
while ('0' <= ch && ch <= '9') {
value = value * 10 + (ch - 48);
success = true;
++this.pos;
ch = this.ch(this.pos);
}
if (success) {
if (value > maxValue) {
return maxValue;
}
if (value < 0) {
return 0;
}
return value;
}
throw new XMPException(errorMsg, 5);
}
}