JSONArrayIterator.java 1.33 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.sling.commons.json.JSONArray
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.JSONObject
 */
package com.adobe.aemds.guide.utils;

import java.util.Iterator;
import java.util.NoSuchElementException;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class JSONArrayIterator
implements Iterator<JSONObject> {
    private final JSONArray arr;
    private int current;

    public JSONArrayIterator(JSONArray arr) {
        this.arr = arr;
        this.current = 0;
    }

    @Override
    public boolean hasNext() {
        return this.current < this.arr.length();
    }

    @Override
    public JSONObject next() {
        if (!this.hasNext()) {
            throw new NoSuchElementException();
        }
        try {
            return (JSONObject)this.arr.get(this.current++);
        }
        catch (JSONException e) {
            throw new IllegalStateException(e.getMessage(), (Throwable)e);
        }
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("remove");
    }
}