Skip to content

Commit 0b58f1d

Browse files
committed
cleanup
1 parent cb33db4 commit 0b58f1d

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

src/main/java/com/esri/core/geometry/JSONObjectEnumerator.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,51 @@
3030
final class JSONObjectEnumerator {
3131

3232
private JSONObject m_jsonObject;
33-
private boolean m_bStarted;
34-
private int m_currentIndex;
33+
private int m_troolean;
3534
private Iterator<?> m_keys_iter;
3635
private String m_current_key;
3736

3837
JSONObjectEnumerator(JSONObject jsonObject) {
39-
m_bStarted = false;
40-
m_currentIndex = -1;
38+
m_troolean = 0;
4139
m_jsonObject = jsonObject;
4240
}
4341

4442
String getCurrentKey() {
45-
if (!m_bStarted) {
46-
throw new GeometryException("invalid call");
47-
}
48-
49-
if (m_currentIndex == m_jsonObject.length()) {
43+
if (m_troolean != 1) {
5044
throw new GeometryException("invalid call");
5145
}
5246

5347
return m_current_key;
5448
}
5549

5650
Object getCurrentObject() {
57-
if (!m_bStarted) {
58-
throw new GeometryException("invalid call");
59-
}
60-
61-
if (m_currentIndex == m_jsonObject.length()) {
51+
if (m_troolean != 1) {
6252
throw new GeometryException("invalid call");
6353
}
6454

6555
return m_jsonObject.opt(m_current_key);
6656
}
6757

6858
boolean next() {
69-
if (!m_bStarted) {
70-
m_currentIndex = 0;
71-
m_keys_iter = m_jsonObject.keys();
72-
m_bStarted = true;
73-
if (m_keys_iter.hasNext()) {
74-
m_current_key = (String)m_keys_iter.next();
59+
if (m_troolean == 0) {
60+
if (m_jsonObject.length() > 0) {
61+
m_keys_iter = m_jsonObject.keys();
62+
m_troolean = 1;//started
7563
}
76-
77-
} else if (m_currentIndex != m_jsonObject.length()) {
64+
else {
65+
m_troolean = -1;//stopped
66+
}
67+
}
68+
69+
if (m_troolean == 1) {//still exploring
7870
if (m_keys_iter.hasNext()) {
7971
m_current_key = (String)m_keys_iter.next();
8072
}
81-
82-
m_currentIndex++;
73+
else {
74+
m_troolean = -1; //done
75+
}
8376
}
8477

85-
return m_currentIndex != m_jsonObject.length();
78+
return m_troolean == 1;
8679
}
8780
}

0 commit comments

Comments
 (0)