001    package railo.runtime.type;
002    import java.util.Comparator;
003    import java.util.List;
004    
005    import railo.runtime.exp.PageException;
006    
007    /**
008     * 
009     */
010    public interface Array extends Collection,Cloneable,Objects {
011                    
012            /**
013             * return dimension of the array
014             * @return dimension of the array
015             */
016            public int getDimension();
017            
018            /**
019             * return object a given position, key can only be a integer from 1 to array len
020             * @param key key as integer
021             * @return value at key position
022             */
023            public Object get(int key, Object defaultValue);
024            
025            /**
026             * return object a given position, key can only be a integer from 1 to array len
027             * @param key key as integer
028             * @return value at key position
029             * @throws PageException
030             */
031            public Object getE(int key) throws PageException;
032            
033            /**
034             * set value at defined position, on error return null
035             * @param key key of the new value
036             * @param value value to set
037             * @return setted value
038             */
039            public Object setEL(int key, Object value);
040            
041            /**
042             * set value at defined position
043             * @param key 
044             * @param value
045             * @return defined value
046             * @throws PageException
047             */
048            public Object setE(int key, Object value) throws PageException;
049            
050            /**
051             * @return return all array keys as int
052             */
053            public int[] intKeys();
054            
055            /**
056             * insert a value add defined position 
057             * @param key position to insert
058             * @param value value to insert
059             * @return has done or not
060             * @throws PageException
061             */
062            public boolean insert(int key, Object value) throws PageException;
063            
064            /**
065             * append a new value to the end of the array
066             * @param o value to insert
067             * @return inserted value
068             * @throws PageException
069             */
070            public Object append(Object o) throws PageException;
071            
072            public Object appendEL(Object o);
073            
074            /**
075             * add a new value to the begin of the array
076             * @param o value to insert
077             * @return inserted value
078             * @throws PageException
079             */
080            public Object prepend(Object o) throws PageException;
081            
082            /**
083             * resize array to defined size
084             * @param to new minimum size of the array
085             * @throws PageException
086             */
087            public void resize(int to) throws PageException;
088    
089            /**
090             * sort values of a array
091             * @param sortType search type (text,textnocase,numeric)
092             * @param sortOrder (asc,desc)
093             * @throws PageException
094             * @deprecated use instead <code>sort(Comparator comp)</code>
095             */
096            public void sort(String sortType, String sortOrder) throws PageException;
097            
098            
099            public void sort(Comparator comp) throws PageException;
100            
101            /**
102             * @return return arra as native (Java) Object Array
103             */
104            public Object[] toArray();
105            
106            /**
107             * @return return array as ArrayList
108             */
109            //public ArrayList toArrayList();
110            
111            public List toList();
112    
113            
114            /**
115             * removes a value ad defined key
116             * @param key key to remove
117             * @return retuns if value is removed or not
118             * @throws PageException
119            */
120            public Object removeE(int key) throws PageException;    
121            
122            /**
123             * removes a value ad defined key
124             * @param key key to remove
125             * @return retuns if value is removed or not
126            */
127            public Object removeEL(int key) ;
128        
129        /**
130         * contains this key
131         * @param key
132         * @return returns if collection has a key with given name
133         */
134        public boolean containsKey(int key);
135    }