001/*
002 * ModeShape (http://www.modeshape.org)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *       http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.modeshape.schematic.document;
017
018import java.util.List;
019
020/**
021 * Primary read-only interface for an in-memory representation of JSON/BSON arrays. Note that this interface extends
022 * {@link Document}, where the field names are simply string representations of the array indices. This interface also extends the
023 * standard Java {@link List} interface.
024 * 
025 * @author Randall Hauch <rhauch@redhat.com> (C) 2011 Red Hat Inc.
026 */
027public interface Array extends Document, List<Object> {
028
029    /**
030     * Obtain a clone of this array.
031     * 
032     * @return the clone of this array; never null
033     */
034    @Override
035    Array clone();
036
037    /**
038     * Get the entries in this array.
039     * 
040     * @return an iterable containing the array's entries; never null
041     */
042    Iterable<Entry> getEntries();
043
044    /**
045     * A representation of an entry within the array.
046     */
047    static interface Entry extends Comparable<Entry> {
048        /**
049         * Get the index for this entry.
050         * 
051         * @return the index
052         */
053        int getIndex();
054
055        /**
056         * Get the value for this entry.
057         * 
058         * @return the value
059         */
060        Object getValue();
061    }
062
063}