Code example for JSONArray

Methods: length, put

0
                return result;
            } 
 
            @Override 
            public int size() { 
                return state.length();
            } 
 
            @Override 
            public final <U extends GraphObject> GraphObjectList<U> castToListOf(Class<U> graphObjectClass) {
                if (GraphObject.class.isAssignableFrom(itemType)) {
                    if (graphObjectClass.isAssignableFrom(itemType)) {
                        @SuppressWarnings("unchecked") 
                        GraphObjectList<U> result = (GraphObjectList<U>)this;
                        return result;
                    } 
 
                    return createList(state, graphObjectClass);
                } else { 
                    throw new FacebookGraphObjectException("Can't cast GraphObjectCollection of non-GraphObject type "
                            + itemType);
                } 
            } 
 
            @Override 
            public final JSONArray getInnerJSONArray() {
                return state;
            } 
 
            @Override 
            public void clear() { 
                throw new UnsupportedOperationException();
            } 
 
            @Override 
            public boolean remove(Object o) {
                throw new UnsupportedOperationException();
            } 
 
            @Override 
            public boolean removeAll(Collection<?> c) {
                throw new UnsupportedOperationException();
            } 
 
            @Override 
            public boolean retainAll(Collection<?> c) {
                throw new UnsupportedOperationException();
            } 
 
            private void checkIndex(int index) {
                if (index < 0 || index >= state.length()) {
                    throw new IndexOutOfBoundsException();
                } 
            } 
 
            private void put(int index, T obj) {
                Object underlyingObject = getUnderlyingJSONObject(obj);
                try { 
                    state.put(index, underlyingObject);
                } catch (JSONException e) {
                    throw new IllegalArgumentException(e);
                } 
            } 
        }