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 js.ArrayLike;
023 import js.Vars;
024 import js.core.JsArray;
025 import js.core.JsFunction;
026 
027 final class SimArrayBoolean implements ArrayLike<Boolean>
028 {
029     private final boolean[] arr;
030 
031     public SimArrayBoolean(boolean[] arr) {
032         this.arr = arr;
033     }
034 
035     //@Override
036     public final synchronized ArrayLike<Boolean> concat(Vars<?> args) {
037         return SimArrays.concat(new SimArrayList<Boolean>(), this, args);
038     }
039 
040     //@Override
041     public final synchronized ArrayLike<Boolean> concat(Object arg) {
042         return SimArrays.concat(new SimArrayList<Boolean>(), this, arg);
043     }
044 
045     //@Override
046     public final synchronized boolean delete(int i) {
047         throw new UnsupportedOperationException();
048     }
049 
050     //@Override
051     public final synchronized Boolean get(int i) {
052         return i < arr.length ? arr[i] : null;
053     }
054 
055     //@Override
056     public final synchronized String join() {
057         return SimArrays.join(this);
058     }
059 
060     //@Override
061     public final synchronized String join(Object separator) {
062         return SimArrays.join(this, separator);
063     }
064 
065     //@Override
066     public final synchronized int length() {
067         return arr.length;
068     }
069 
070     //@Override
071     public final synchronized int length(int len) {
072         throw new UnsupportedOperationException();
073     }
074 
075     //@Override
076     public final Integer index() {
077         return null;
078     }
079 
080     //@Override
081     public final String input() {
082         return null;
083     }
084 
085     //@Override
086     public final synchronized Boolean pop() {
087         throw new UnsupportedOperationException();
088     }
089 
090     //@Override
091     public final synchronized int push(Object v) {
092         throw new UnsupportedOperationException();
093     }
094 
095     //@Override
096     public final synchronized int push(Vars<?> args) {
097         throw new UnsupportedOperationException();
098     }
099 
100     //@Override
101     public final synchronized void reverse() {
102         SimArrays.reverse(this);
103     }
104 
105     //@Override
106     public final synchronized Boolean set(int i, Boolean v) {
107         if (i >= length()) {
108             throw new UnsupportedOperationException();
109         }
110         arr[i] = v;
111         return v;
112     }
113 
114     //@Override
115     public final synchronized Boolean shift() {
116         throw new UnsupportedOperationException();
117     }
118 
119     //@Override
120     public final synchronized ArrayLike<Boolean> slice(Vars<?> args) {
121         return SimArrays.slice(this, args);
122     }
123 
124     //@Override
125     public final synchronized ArrayLike<Boolean> slice(Object start) {
126         return SimArrays.slice(this, start);
127     }
128 
129     //@Override
130     public final synchronized ArrayLike<Boolean> slice(Object start, Object end) {
131         return SimArrays.slice(this, start, end);
132     }
133 
134     //@Override
135     public final synchronized ArrayLike<Boolean> sort() {
136         throw new UnsupportedOperationException();
137     }
138 
139     //@Override
140     public final synchronized ArrayLike<Boolean> sort(final JsFunction<? extends Number> orderfunc) {
141         throw new UnsupportedOperationException();
142     }
143 
144     //@Override
145     public final synchronized ArrayLike<Boolean> splice(Vars<?> args) {
146         throw new UnsupportedOperationException();
147     }
148 
149     //@Override
150     public final synchronized ArrayLike<Boolean> splice(Object start) {
151         throw new UnsupportedOperationException();
152     }
153 
154     //@Override
155     public final synchronized ArrayLike<Boolean> splice(Object start, Object deleteCount) {
156         throw new UnsupportedOperationException();
157     }
158 
159     //@Override
160     public final synchronized ArrayLike<Boolean> splice(Object start, Object deleteCount, Object value) {
161         throw new UnsupportedOperationException();
162     }
163 
164     //@Override
165     public final synchronized ArrayLike<Boolean> splice(Object start, Object deleteCount, Vars<?> args) {
166         throw new UnsupportedOperationException();
167     }
168 
169     //@Override
170     public final synchronized int unshift(Vars<?> args) {
171         throw new UnsupportedOperationException();
172     }
173 
174     //@Override
175     public final synchronized int unshift(Object value) {
176         throw new UnsupportedOperationException();
177     }
178 
179     //@Override
180     public final String toString() {
181         return SimArrays.toString(this);
182     }
183 
184     //@Override
185     public final synchronized ArrayLike<Boolean> valueOf() {
186         return this;
187     }
188 
189     //@Override
190     public final synchronized JsArray var() {
191         throw new UnsupportedOperationException();
192     }
193 }