View Javadoc
1   /*
2    * Copyright 2010 Daniel Kurka
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package com.googlecode.mgwt.collection.shared.java;
17  
18  import com.googlecode.mgwt.collection.shared.LightArrayInt;
19  
20  /**
21   * Java implemntation of {@link LightArrayInt}
22   * 
23   * @author Daniel Kurka
24   * 
25   */
26  public class JavaLightArrayInt implements LightArrayInt {
27  
28  	private JavaLightArray<Integer> array;
29  
30    /**
31     * Construct a {@link JavaLightArray}
32     */
33  	public JavaLightArrayInt() {
34  		array = new JavaLightArray<Integer>();
35  	}
36  
37  	@Override
38  	public int get(int index) {
39  		Integer integer = array.get(index);
40  		if (integer != null)
41  			return integer;
42  		return 0;
43  	}
44  
45  	@Override
46  	public int length() {
47  		return array.length();
48  	}
49  
50  	@Override
51  	public void push(int value) {
52  		array.push(Integer.valueOf(value));
53  
54  	}
55  
56  	@Override
57  	public void set(int index, int value) {
58  		array.set(index, Integer.valueOf(value));
59  
60  	}
61  
62  	@Override
63  	public int shift() {
64  		Integer shift = array.shift();
65  		if (shift != null)
66  			return shift;
67  		return 0;
68  	}
69  
70  	@Override
71  	public void unshift(int value) {
72  		array.unshift(Integer.valueOf(value));
73  
74  	}
75  
76  }