FileDocCategorySizeDatePackage
JSONArray.javaAPI DocExample2277Wed Jul 26 13:30:26 BST 2006com.oreilly.ajax.client

JSONArray

public class JSONArray extends JSONValue
Represents an array of JSONValue objects.

Fields Summary
private ArrayList
values
Constructors Summary
Methods Summary
public voidadd(JSONValue value)
Add an item to the end of the list

param
value

    values.add(value);
  
public voidadd(int index, JSONValue element)
Add an item at the specified position within the array.

    values.add(index, element);
  
public JSONValueget(int index)
throws java array index out of bounds

param
index
return

    return (JSONValue) values.get(index);
  
public com.oreilly.ajax.client.JSONArrayisArray()

  
     
    return this;
  
public JSONValueset(int index, JSONValue element)
Replaces the JSONValue object at the specified instance

param
index
param
value
return
returns the previous value at the specified index

    return (JSONValue) values.set(index, element);
  
public intsize()
Returns the number of elements in this array.

return
size of this array

    return values.size();
  
public java.lang.StringtoString()
Create the JSON encoded string representation of this JSONArray instance.

    StringBuffer sb = new StringBuffer();
    Iterator iter = values.iterator();
    
    sb.append("[");
    while (iter.hasNext()) {      
      JSONValue value = (JSONValue) iter.next();
      sb.append(value.toString());
      
      if (iter.hasNext()) {
        sb.append(",");
      }
    }
    sb.append("]");
    
    return sb.toString();