001: /*
002: * Copyright 2005 Joe Walker
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: */
016: package org.directwebremoting.json;
017:
018: import java.util.Collection;
019: import java.util.Iterator;
020: import java.util.List;
021: import java.util.ListIterator;
022:
023: /**
024: * @author Joe Walker [joe at getahead dot ltd dot uk]
025: */
026: public class JsonArray extends JsonValue implements List<JsonValue> {
027: /* (non-Javadoc)
028: * @see org.directwebremoting.json.JsonValue#toExternalRepresentation()
029: */
030: @Override
031: public String toExternalRepresentation() {
032: StringBuffer output = new StringBuffer();
033: output.append("[ ");
034:
035: boolean isFirst = true;
036: for (JsonValue value : proxy) {
037: if (isFirst) {
038: isFirst = false;
039: } else {
040: output.append(", ");
041: }
042:
043: output.append(value.toExternalRepresentation());
044: }
045: output.append(" ]");
046: return output.toString();
047: }
048:
049: /* (non-Javadoc)
050: * @see java.lang.Object#toString()
051: */
052: @Override
053: public String toString() {
054: return toExternalRepresentation();
055: }
056:
057: /* (non-Javadoc)
058: * @see java.lang.Object#equals(java.lang.Object)
059: */
060: @Override
061: public boolean equals(Object o) {
062: return proxy.equals(o);
063: }
064:
065: /* (non-Javadoc)
066: * @see java.lang.Object#hashCode()
067: */
068: @Override
069: public int hashCode() {
070: return proxy.hashCode();
071: }
072:
073: /* (non-Javadoc)
074: * @see java.util.List#add(int, java.lang.Object)
075: */
076: public void add(int index, JsonValue value) {
077: proxy.add(index, value);
078: }
079:
080: /* (non-Javadoc)
081: * @see java.util.List#add(java.lang.Object)
082: */
083: public boolean add(JsonValue value) {
084: return proxy.add(value);
085: }
086:
087: /* (non-Javadoc)
088: * @see java.util.List#addAll(java.util.Collection)
089: */
090: public boolean addAll(Collection<? extends JsonValue> collection) {
091: return proxy.addAll(collection);
092: }
093:
094: /* (non-Javadoc)
095: * @see java.util.List#addAll(int, java.util.Collection)
096: */
097: public boolean addAll(int index,
098: Collection<? extends JsonValue> collection) {
099: return proxy.addAll(index, collection);
100: }
101:
102: /* (non-Javadoc)
103: * @see java.util.List#clear()
104: */
105: public void clear() {
106: proxy.clear();
107: }
108:
109: /* (non-Javadoc)
110: * @see java.util.List#contains(java.lang.Object)
111: */
112: public boolean contains(Object sought) {
113: return proxy.contains(sought);
114: }
115:
116: /* (non-Javadoc)
117: * @see java.util.List#containsAll(java.util.Collection)
118: */
119: public boolean containsAll(Collection<?> collection) {
120: return proxy.containsAll(collection);
121: }
122:
123: /* (non-Javadoc)
124: * @see java.util.List#get(int)
125: */
126: public JsonValue get(int index) {
127: return proxy.get(index);
128: }
129:
130: /* (non-Javadoc)
131: * @see java.util.List#indexOf(java.lang.Object)
132: */
133: public int indexOf(Object sought) {
134: return proxy.indexOf(sought);
135: }
136:
137: /* (non-Javadoc)
138: * @see java.util.List#isEmpty()
139: */
140: public boolean isEmpty() {
141: return proxy.isEmpty();
142: }
143:
144: /* (non-Javadoc)
145: * @see java.util.List#iterator()
146: */
147: public Iterator<JsonValue> iterator() {
148: return proxy.iterator();
149: }
150:
151: /* (non-Javadoc)
152: * @see java.util.List#lastIndexOf(java.lang.Object)
153: */
154: public int lastIndexOf(Object sought) {
155: return proxy.lastIndexOf(sought);
156: }
157:
158: /* (non-Javadoc)
159: * @see java.util.List#listIterator()
160: */
161: public ListIterator<JsonValue> listIterator() {
162: return proxy.listIterator();
163: }
164:
165: /* (non-Javadoc)
166: * @see java.util.List#listIterator(int)
167: */
168: public ListIterator<JsonValue> listIterator(int startIndex) {
169: return proxy.listIterator(startIndex);
170: }
171:
172: /* (non-Javadoc)
173: * @see java.util.List#remove(int)
174: */
175: public JsonValue remove(int value) {
176: return proxy.remove(value);
177: }
178:
179: /* (non-Javadoc)
180: * @see java.util.List#remove(java.lang.Object)
181: */
182: public boolean remove(Object value) {
183: return proxy.remove(value);
184: }
185:
186: /* (non-Javadoc)
187: * @see java.util.List#removeAll(java.util.Collection)
188: */
189: public boolean removeAll(Collection<?> collection) {
190: return proxy.removeAll(collection);
191: }
192:
193: /* (non-Javadoc)
194: * @see java.util.List#retainAll(java.util.Collection)
195: */
196: public boolean retainAll(Collection<?> collection) {
197: return proxy.retainAll(collection);
198: }
199:
200: /* (non-Javadoc)
201: * @see java.util.List#set(int, java.lang.Object)
202: */
203: public JsonValue set(int index, JsonValue value) {
204: return proxy.set(index, value);
205: }
206:
207: /* (non-Javadoc)
208: * @see java.util.List#size()
209: */
210: public int size() {
211: return proxy.size();
212: }
213:
214: /* (non-Javadoc)
215: * @see java.util.List#subList(int, int)
216: */
217: public List<JsonValue> subList(int startIndex, int endIndex) {
218: return proxy.subList(startIndex, endIndex);
219: }
220:
221: /* (non-Javadoc)
222: * @see java.util.List#toArray()
223: */
224: public Object[] toArray() {
225: return proxy.toArray();
226: }
227:
228: /* (non-Javadoc)
229: * @see java.util.List#toArray(T[])
230: */
231: public <T> T[] toArray(T[] toFill) {
232: return proxy.toArray(toFill);
233: }
234:
235: private List<JsonValue> proxy;
236: }
|