Android Open Source - json-interface Json Array Interface






From Project

Back to project page json-interface.

License

The source code is released under:

MIT License

If you think the Android project json-interface listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * This file is part of JSON Interface library.
 * Copyright (C) 2014 Noor Dawod. All rights reserved.
 * https://github.com/noordawod/json-interface
 *// w ww. j a  v  a 2s .  co  m
 * Released under the MIT license
 * http://en.wikipedia.org/wiki/MIT_License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

package com.fine47.json;

import android.os.Parcelable;
import java.util.List;

/**
 * Main interface for manipulating JSON arrays. Pay attention that due to the
 * important rule played by {@link Parcelable} class in Android, this interface
 * extends the former for your convenience.
 *
 * @since 1.0
 */
public interface JsonArrayInterface extends JsonInterface {

  /**
   * Reusable logging tag for any JSON array implementation.
   */
  public final static String LOG_TAG = "JsonArray";

  /**
   * Checks whether this JSON array contains the specified value.
   *
   * @param value to check if it's contained in this JSON array
   * @return TRUE if value is contained in this JSON array, FALSE otherwise
   */
  public boolean contains(Object value);

  /**
   * Returns the position of the specified value in this JSON array. Note that
   * only the first occurrence of the specified value is returned; the same
   * value could potentially be contained more than one time.
   *
   * @param value to check if it's contained in this JSON array
   * @return position of value (0-based) if found, -1 otherwise
   */
  public int indexOf(Object value);

  /**
   * Returns a value contained in this JSON array at the specified position and
   * is of the specified type. If the position is out of the array's bounds, or
   * the value is of a different type, NULL is returned.
   *
   * @param <T> type of the value to return
   * @param position of the value to return
   * @return the value at the specified position
   */
  public <T> T get(int position);

  /**
   * Returns a value contained in this JSON array at the specified position and
   * is of the specified type. If the position is out of the array's bounds, or
   * the value is of a different type, the specified default value is returned.
   *
   * @param <T> type of the value to return
   * @param position of the value to return
   * @param defValue default value to return in case of error
   * @return the value at the specified position
   */
  public <T> T get(int position, T defValue);

  /**
   * Adds the specified value to this JSON array at the end.
   *
   * @param value to add to this JSON array
   */
  public void add(Object value);

  /**
   * Adds the specified value to this JSON array at the specified position.
   *
   * @param position of the value to return
   * @param value to add to this JSON array
   */
  public void add(int position, Object value);

  /**
   * Removes the value contained in this JSON array at the specified position.
   *
   * @param position of the value to remove
   */
  public void remove(int position);

  /**
   * Removes all occurrences contained in this JSON array for the specified
   * value.
   *
   * @param value to remove
   */
  public void remove(Object value);

  /**
   * Merges the entries contained in the specified Android-native JSON data
   * array into this JSON array.
   *
   * @param json to merge in into this JSON array
   */
  public void merge(org.json.JSONArray json);

  /**
   * Merges the entries contained in the specified JSON data array into this
   * JSON array.
   *
   * @param json to merge in into this JSON array
   */
  public void merge(JsonArrayInterface json);

  /**
   * Merges the entries contained in the specified list into this JSON array.
   *
   * @param list to merge in into this JSON array
   */
  public void merge(List list);

  /**
   * Clones the items contained within this JSON array and returns them in a
   * new JSON array.
   *
   * @return cloned JSON array
   */
  public JsonArrayInterface clone();
}




Java Source Code List

com.fine47.json.JsonArrayInterface.java
com.fine47.json.JsonInterface.java
com.fine47.json.JsonObjectInterface.java
com.fine47.json.Marshaller.java
com.fine47.json.builtin.JsonArray.java
com.fine47.json.builtin.JsonObject.java
com.fine47.json.builtin.JsonUtil.java
com.fine47.json.simple.JsonArray.java
com.fine47.json.simple.JsonObject.java
com.fine47.json.simple.JsonUtil.java