001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.type;
020
021import java.util.Iterator;
022
023import lucee.runtime.PageContext;
024import lucee.runtime.dump.DumpData;
025import lucee.runtime.dump.DumpProperties;
026import lucee.runtime.exp.PageException;
027import lucee.runtime.op.Duplicator;
028import lucee.runtime.type.dt.DateTime;
029import lucee.runtime.type.util.StructSupport;
030
031public final class CollectionStruct extends StructSupport implements ObjectWrap,Struct {
032
033        private final Collection coll;
034
035        public CollectionStruct(Collection coll) {
036                this.coll=coll;
037        }
038
039        @Override
040        public void clear() {
041                coll.clear();
042        }
043
044        @Override
045        public boolean containsKey(Key key) {
046                return coll.containsKey(key);
047        }
048
049        @Override
050        public Collection duplicate(boolean deepCopy) {
051                return (Collection) Duplicator.duplicate(coll,deepCopy);
052        }
053        
054
055        @Override
056        public Object get(Key key) throws PageException {
057                return coll.get(key);
058        }
059
060        @Override
061        public Object get(Key key, Object defaultValue) {
062                return coll.get(key, defaultValue);
063        }
064
065        @Override
066        public Key[] keys() {
067                return coll.keys();
068        }
069
070        @Override
071        public Object remove(Key key) throws PageException {
072                return coll.remove(key);
073        }
074
075        @Override
076        public Object removeEL(Key key) {
077                return coll.removeEL(key);
078        }
079
080        @Override
081        public Object set(Key key, Object value) throws PageException {
082                return coll.set(key, value);
083        }
084
085        @Override
086        public Object setEL(Key key, Object value) {
087                return coll.setEL(key, value);
088        }
089
090        @Override
091        public int size() {
092                return coll.size();
093        }
094
095        @Override
096        public Iterator<Collection.Key> keyIterator() {
097                return coll.keyIterator();
098        }
099    
100        @Override
101        public Iterator<String> keysAsStringIterator() {
102        return coll.keysAsStringIterator();
103    }
104        
105        @Override
106        public Iterator<Entry<Key, Object>> entryIterator() {
107                return coll.entryIterator();
108        }
109        
110        @Override
111        public Iterator<Object> valueIterator() {
112                return coll.valueIterator();
113        }
114        
115
116        @Override
117        public DumpData toDumpData(PageContext pageContext, int maxlevel,DumpProperties properties) {
118                return coll.toDumpData(pageContext, maxlevel, properties);
119        }
120
121        @Override
122    public boolean castToBooleanValue() throws PageException {
123        return coll.castToBooleanValue();
124    }
125
126    @Override
127    public double castToDoubleValue() throws PageException {
128        return coll.castToDoubleValue();
129    }
130
131
132    @Override
133    public DateTime castToDateTime() throws PageException {
134        return coll.castToDateTime();
135    }
136
137    @Override
138    public String castToString() throws PageException {
139                return coll.castToString();
140    }
141
142
143        @Override
144        public int compareTo(boolean b) throws PageException {
145                return coll.compareTo(b);
146        }
147
148        @Override
149        public int compareTo(DateTime dt) throws PageException {
150                return coll.compareTo(dt);
151        }
152
153        @Override
154        public int compareTo(double d) throws PageException {
155                return coll.compareTo(d);
156        }
157
158        @Override
159        public int compareTo(String str) throws PageException {
160                return coll.compareTo(str);
161        }
162
163        @Override
164        public Object getEmbededObject(Object defaultValue) {
165                return coll;
166        }
167
168        @Override
169        public Object getEmbededObject() throws PageException {
170                return coll;
171        }
172
173        /**
174         * @return
175         */
176        public Collection getCollection() {
177                return coll;
178        }
179}