001 
002 /*
003  *  JScripter Simulation 1.0 - For Java To Script
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package org.jscripter.sim;
021 
022 import java.util.Arrays;
023 
024 import js.ArrayLike;
025 import js.Vars;
026 import js.core.JsArray;
027 import js.core.JsFunction;
028 
029 final class SimArrayShort implements ArrayLike<Short>
030 {
031     private final short[] arr;
032 
033     public SimArrayShort(short[] arr) {
034         this.arr = arr;
035     }
036 
037     //@Override
038     public final synchronized ArrayLike<Short> concat(Vars<?> args) {
039         return SimArrays.concat(new SimArrayList<Short>(), this, args);
040     }
041 
042     //@Override
043     public final synchronized ArrayLike<Short> concat(Object arg) {
044         return SimArrays.concat(new SimArrayList<Short>(), this, arg);
045     }
046 
047     //@Override
048     public final synchronized boolean delete(int i) {
049         throw new UnsupportedOperationException();
050     }
051 
052     //@Override
053     public final synchronized Short get(int i) {
054         return i < arr.length ? arr[i] : null;
055     }
056 
057     //@Override
058     public final synchronized String join() {
059         return SimArrays.join(this);
060     }
061 
062     //@Override
063     public final synchronized String join(Object separator) {
064         return SimArrays.join(this, separator);
065     }
066 
067     //@Override
068     public final synchronized int length() {
069         return arr.length;
070     }
071 
072     //@Override
073     public final synchronized int length(int len) {
074         throw new UnsupportedOperationException();
075     }
076 
077     //@Override
078     public final Integer index() {
079         return null;
080     }
081 
082     //@Override
083     public final String input() {
084         return null;
085     }
086 
087     //@Override
088     public final synchronized Short pop() {
089         throw new UnsupportedOperationException();
090     }
091 
092     //@Override
093     public final synchronized int push(Object v) {
094         throw new UnsupportedOperationException();
095     }
096 
097     //@Override
098     public final synchronized int push(Vars<?> args) {
099         throw new UnsupportedOperationException();
100     }
101 
102     //@Override
103     public final synchronized void reverse() {
104         SimArrays.reverse(this);
105     }
106 
107     //@Override
108     public final synchronized Short set(int i, Short v) {
109         if (i >= length()) {
110             throw new UnsupportedOperationException();
111         }
112         arr[i] = v;
113         return v;
114     }
115 
116     //@Override
117     public final synchronized Short shift() {
118         throw new UnsupportedOperationException();
119     }
120 
121     //@Override
122     public final synchronized ArrayLike<Short> slice(Vars<?> args) {
123         return SimArrays.slice(this, args);
124     }
125 
126     //@Override
127     public final synchronized ArrayLike<Short> slice(Object start) {
128         return SimArrays.slice(this, start);
129     }
130 
131     //@Override
132     public final synchronized ArrayLike<Short> slice(Object start, Object end) {
133         return SimArrays.slice(this, start, end);
134     }
135 
136     //@Override
137     public final synchronized ArrayLike<Short> sort() {
138         Arrays.sort(arr);
139         return this;
140     }
141 
142     //@Override
143     public final synchronized ArrayLike<Short> sort(final JsFunction<? extends Number> orderfunc) {
144         throw new UnsupportedOperationException();
145     }
146 
147     //@Override
148     public final synchronized ArrayLike<Short> splice(Vars<?> args) {
149         throw new UnsupportedOperationException();
150     }
151 
152     //@Override
153     public final synchronized ArrayLike<Short> splice(Object start) {
154         throw new UnsupportedOperationException();
155     }
156 
157     //@Override
158     public final synchronized ArrayLike<Short> splice(Object start, Object deleteCount) {
159         throw new UnsupportedOperationException();
160     }
161 
162     //@Override
163     public final synchronized ArrayLike<Short> splice(Object start, Object deleteCount, Object value) {
164         throw new UnsupportedOperationException();
165     }
166 
167     //@Override
168     public final synchronized ArrayLike<Short> splice(Object start, Object deleteCount, Vars<?> args) {
169         throw new UnsupportedOperationException();
170     }
171 
172     //@Override
173     public final synchronized int unshift(Vars<?> args) {
174         throw new UnsupportedOperationException();
175     }
176 
177     //@Override
178     public final synchronized int unshift(Object value) {
179         throw new UnsupportedOperationException();
180     }
181 
182     //@Override
183     public final String toString() {
184         return SimArrays.toString(this);
185     }
186 
187     //@Override
188     public final synchronized ArrayLike<Short> valueOf() {
189         return this;
190     }
191 
192     //@Override
193     public final JsArray var() {
194         throw new UnsupportedOperationException();
195     }
196 }