01 
02 /*
03  *  JScripter Standard 1.0 - To Script In Java
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package js;
21 
22 /**
23  * <p>An <b>opaque</b> interface resembling JavaScript arrays including the system 
24  * read-only ones such as HTMLElementCollection, NodeList, Arguments, etc.</p>
25  * <p>This interface must be implemented in JS Simulation Libraries.</p>
26  * 
27  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
28  * 
29  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be 
30  * generated into the target codes. Re-compilers must exit with error on the operations of 
31  * accessing that kind of class objects.
32  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored 
33  * and <tt>instanceof</tt> to it always <tt>true</tt>.
34  */
35 
36 public interface ArrayObject<T>
37 {
38     /**
39      * <p>Reads an element of the current array instance.</p>
40      * @param i Array index of the element
41      * @return value of the element
42      * @since 1.0
43      * @javascript Re-compilers must convert the interface invocation of this method into the 
44      * JavaScript expression: 
45      * <pre>a[i]</pre>
46      * where <tt>a</tt> is the current array instance of the invocation.
47      */
48     public T get(int i);
49 
50     /**
51      * <p>Gets the size of the current array instance.</p>
52      * @return size of the array
53      * @see jsx.core.ArrayLikes#length(ArrayObject)
54      * @since 1.0
55      * @javascript Re-compilers must convert the interface invocation of this method into the 
56      * JavaScript expression: 
57      * <pre>a.length</pre>
58      * where <tt>a</tt> is the current array instance of the invocation.
59      */
60     public int length();
61     /**
62      * <p>Returns the string representing the current instance.</p>
63      * @return A string representing the current array.
64      * @since 1.0
65      * @javascript Re-compilers must convert the interface invocation of this method directly 
66      * into a JavaScript invocation on its current array instance without changing the 
67      * method name, but expanding variable arguments, if any, into comma-separated values. 
68      */
69     public String toString();
70 }