Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions src/main/java/com/esri/core/geometry/JSONObjectEnumerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,58 @@
*/
package com.esri.core.geometry;

import java.util.ArrayList;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.Iterator;

final class JSONObjectEnumerator {

private JSONObject m_jsonObject;
private boolean m_bStarted;
private int m_currentIndex;
private String[] m_keys;
private int m_troolean;
private Iterator<?> m_keys_iter;
private String m_current_key;

JSONObjectEnumerator(JSONObject jsonObject) {
m_bStarted = false;
m_currentIndex = -1;
m_troolean = 0;
m_jsonObject = jsonObject;
}

String getCurrentKey() {
if (!m_bStarted) {
throw new GeometryException("invalid call");
}

if (m_currentIndex == m_jsonObject.length()) {
if (m_troolean != 1) {
throw new GeometryException("invalid call");
}

return m_keys[m_currentIndex];
return m_current_key;
}

Object getCurrentObject() {
if (!m_bStarted) {
if (m_troolean != 1) {
throw new GeometryException("invalid call");
}

if (m_currentIndex == m_jsonObject.length()) {
throw new GeometryException("invalid call");
}

return m_jsonObject.opt(m_keys[m_currentIndex]);
return m_jsonObject.opt(m_current_key);
}

boolean next() {
if (!m_bStarted) {
m_currentIndex = 0;
m_keys = JSONObject.getNames(m_jsonObject);
m_bStarted = true;
} else if (m_currentIndex != m_jsonObject.length()) {
m_currentIndex++;
if (m_troolean == 0) {
if (m_jsonObject.length() > 0) {
m_keys_iter = m_jsonObject.keys();
m_troolean = 1;//started
}
else {
m_troolean = -1;//stopped
}
}

if (m_troolean == 1) {//still exploring
if (m_keys_iter.hasNext()) {
m_current_key = (String)m_keys_iter.next();
}
else {
m_troolean = -1; //done
}
}

return m_currentIndex != m_jsonObject.length();
return m_troolean == 1;
}
}