KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > quercus > env > ArrayValueWrapper


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.quercus.env;
31
32 import java.util.IdentityHashMap JavaDoc;
33
34 /**
35  * Represents a PHP array value.
36  */

37 public class ArrayValueWrapper extends ArrayValue {
38   private ArrayValue _array;
39
40   protected ArrayValueWrapper(ArrayValue array)
41   {
42     _array = array;
43   }
44
45   /**
46    * Returns the wrapped array.
47    */

48   public ArrayValue getArray()
49   {
50     return _array;
51   }
52   
53   /**
54    * Copy for assignment.
55    */

56   public Value copy()
57   {
58     return _array.copy();
59   }
60   
61   /**
62    * Copy for serialization
63    */

64   public Value copy(Env env, IdentityHashMap JavaDoc<Value,Value> map)
65   {
66     return _array.copy(env, map);
67   }
68
69   /**
70    * Returns the size.
71    */

72   public int getSize()
73   {
74     return _array.getSize();
75   }
76
77   /**
78    * Clears the array
79    */

80   public void clear()
81   {
82     _array.clear();
83   }
84   
85   /**
86    * Adds a new value.
87    */

88   public Value put(Value key, Value value)
89   {
90     return _array.put(key, value);
91   }
92
93   /**
94    * Add
95    */

96   public Value put(Value value)
97   {
98     return _array.put(value);
99   }
100
101   /**
102    * Add to front.
103    */

104   public ArrayValue unshift(Value value)
105   {
106     return _array.unshift(value);
107   }
108
109   /**
110    * Splices values
111    */

112   public ArrayValue splice(int start, int end, ArrayValue replace)
113   {
114     return _array.splice(start, end, replace);
115   }
116
117   /**
118    * Returns the value as an argument which may be a reference.
119    */

120   public Value getArg(Value index)
121   {
122     return _array.getArg(index);
123   }
124
125   /**
126    * Sets the array ref.
127    */

128   public Value putRef()
129   {
130     return _array.putRef();
131   }
132
133   /**
134    * Creatse a tail index.
135    */

136   public Value createTailKey()
137   {
138     return _array.createTailKey();
139   }
140
141   /**
142    * Gets a new value.
143    */

144   public Value get(Value key)
145   {
146     return _array.get(key);
147   }
148
149   /**
150    * Removes a value.
151    */

152   public Value remove(Value key)
153   {
154     return _array.remove(key);
155   }
156
157   /**
158    * Returns the array ref.
159    */

160   public Var getRef(Value index)
161   {
162     return _array.getRef(index);
163   }
164   
165   /**
166    * Pops the top value.
167    */

168   public Value pop()
169   {
170     return _array.pop();
171   }
172
173   /**
174    * Shuffles the array
175    */

176   public void shuffle()
177   {
178     _array.shuffle();
179   }
180
181   /**
182    * Returns the head.
183    */

184   public Entry getHead()
185   {
186     return _array.getHead();
187   }
188
189   /**
190    * Returns the tail.
191    */

192   protected Entry getTail()
193   {
194     return _array.getTail();
195   }
196   
197   /**
198    * Returns the current value.
199    */

200   public Value current()
201   {
202     return _array.current();
203   }
204
205   /**
206    * Returns the current key
207    */

208   public Value key()
209   {
210     return _array.key();
211   }
212
213   /**
214    * Returns true if there are more elements.
215    */

216   public boolean hasCurrent()
217   {
218     return _array.hasCurrent();
219   }
220
221   /**
222    * Returns the next value.
223    */

224   public Value next()
225   {
226     return _array.next();
227   }
228
229   /**
230    * Returns the previous value.
231    */

232   public Value prev()
233   {
234     return _array.prev();
235   }
236
237   /**
238    * The each iterator
239    */

240   public Value each()
241   {
242     return _array.each();
243   }
244
245   /**
246    * Returns the first value.
247    */

248   public Value reset()
249   {
250     return _array.reset();
251   }
252
253   /**
254    * Returns the last value.
255    */

256   public Value end()
257   {
258     return _array.end();
259   }
260   
261   /**
262    * Returns the corresponding valeu if this array contains the given key
263    *
264    * @param key the key to search for in the array
265    *
266    * @return the value if it is found in the array, NULL otherwise
267    *
268    * @throws NullPointerException
269    */

270   public Value containsKey(Value key)
271   {
272     return _array.containsKey(key);
273   }
274 }
275
276
Popular Tags