Statistics
| Revision:

gvsig-raster / org.gvsig.raster.app / trunk / org.gvsig.raster.app / org.gvsig.raster.app.wmtsclient / src / main / java / org / gvsig / raster / app / extension / wmtsclient / layer / DynObjectSetWMTSInfo.java @ 238

History | View | Annotate | Download (4.14 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (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 General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.raster.app.extension.wmtsclient.layer;
23

    
24
import org.easymock.MockControl;
25
import org.gvsig.fmap.dal.feature.FeatureSet;
26
import org.gvsig.tools.dispose.DisposableIterator;
27
import org.gvsig.tools.dynobject.DynClass;
28
import org.gvsig.tools.dynobject.DynField;
29
import org.gvsig.tools.dynobject.DynObject;
30
import org.gvsig.tools.dynobject.DynObjectManager;
31
import org.gvsig.tools.dynobject.DynObjectSet;
32
import org.gvsig.tools.dynobject.impl.DefaultDynClass;
33
import org.gvsig.tools.dynobject.impl.DefaultDynClassName;
34
import org.gvsig.tools.dynobject.impl.DefaultDynObject;
35
import org.gvsig.tools.exception.BaseException;
36
import org.gvsig.tools.observer.Observable;
37
import org.gvsig.tools.observer.Observer;
38
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
39
import org.gvsig.tools.visitor.Visitor;
40

    
41
/**
42
 * {@link DynObject} implementation to facade of a {@link FeatureSet} and allow
43
 * to be used as a {@link DynObjectSet}.
44
 * 
45
 * @author Nacho Brodin (nachobrodin@gmail.com)
46
 * @version $Id$
47
 */
48
public class DynObjectSetWMTSInfo extends BaseWeakReferencingObservable
49
    implements DynObjectSet, Observer {
50
        public static final int             TYPE_TEXT = 0;
51
        public static final int             TYPE_HTML = 1;
52
        public static final int             TYPE_XML  = 2;
53
        private DynObjectIteratorWMTSInfo   ite = null;
54
        
55
        
56
    /**
57
     * Creates a new facade over a given info, with fast dynobject
58
     * iteration.
59
     */
60
    public DynObjectSetWMTSInfo(String txt, int type) {
61
            MockControl managerControl = MockControl.createNiceControl(DynObjectManager.class);
62
            DynObjectManager manager = (DynObjectManager) managerControl.getMock();
63
            DynClass dynClass = new DefaultDynClass(manager, new DefaultDynClassName("WMTS"), "WMTS Properties");
64
            DynField dynField1 = null;
65
            if(type == TYPE_TEXT)
66
                    dynField1 = dynClass.addDynField("info");
67
            if(type == TYPE_HTML)
68
                    dynField1 = dynClass.addDynField("info");
69
            if(type == TYPE_XML)
70
                    dynField1 = dynClass.addDynField("info");
71
            dynField1.setDefaultFieldValue(txt);
72
            DefaultDynObject dynObject = new DefaultDynObject(dynClass);
73
            ite = new DynObjectIteratorWMTSInfo(dynObject);
74
    }
75

    
76
    public void dispose() {
77

    
78
    }
79

    
80
    public void accept(final Visitor visitor, long firstValueIndex) throws BaseException {
81
            while(ite.hasNext()) {
82
                    visitor.visit(ite.next());
83
            }
84
    }
85

    
86
    public void accept(final Visitor visitor) throws BaseException {
87
            while(ite.hasNext()) {
88
                    visitor.visit(ite.next());
89
            }
90
    }
91

    
92
    public long getSize() throws BaseException {
93
       return ite.getSize();
94
    }
95

    
96
    public DisposableIterator iterator(long index) throws BaseException {
97
        return iterator();
98
    }
99

    
100
    public DisposableIterator iterator() throws BaseException {
101
            return ite;
102
    }
103

    
104
    public boolean isEmpty() throws BaseException {
105
            return (getSize() == 0);
106
    }
107

    
108
    public boolean isDeleteEnabled() {
109
            return true;
110
    }
111

    
112
    public void delete(DynObject dynObject) throws BaseException {
113

    
114
    }
115

    
116
    public boolean isUpdateEnabled() {
117
            return true;
118
    }
119

    
120
    public void update(DynObject dynObject) throws BaseException {
121
            System.out.println();
122
    }
123

    
124
    public void update(Observable observable, Object notification) {
125
            System.out.println();
126
    }
127
}