Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DataQuery.java @ 26252

History | View | Annotate | Download (3.61 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (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

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {Create Parameter object to define queries}
26
 */
27
package org.gvsig.fmap.dal;
28

    
29
import java.util.HashMap;
30
import java.util.Map;
31

    
32
import org.gvsig.tools.persistence.AbstractPersistenceManager;
33
import org.gvsig.tools.persistence.PersistenceException;
34
import org.gvsig.tools.persistence.Persistent;
35
import org.gvsig.tools.persistence.PersistentState;
36

    
37
/**
38
 * Defines the properties of a collection of data, as a result of a query
39
 * through a DataStore.
40
 * <p>
41
 * The scale parameter can be used by the DataStore as a hint about the quality
42
 * or resolution of the data needed to view or operate with the data returned.
43
 * As an example, it may use the scale to return only a representative subset of
44
 * the data, or maybe to return Data with less detail, like a point or a line
45
 * instead of a polygon.
46
 * </p>
47
 *
48
 * @author <a href="mailto:cordin@disid.com">César Ordiñana</a>
49
 */
50
public class DataQuery implements Persistent {
51

    
52
    private double scale;
53

    
54
    private Map queryParameters = new HashMap();
55

    
56
    /**
57
     * Empty constructor.
58
     */
59
    public DataQuery() {
60
        super();
61
    }
62

    
63
    /**
64
     * Constructor with an scale.
65
     *
66
     * @param scale
67
     *            the scale for the data
68
     */
69
    public DataQuery(double scale) {
70
        super();
71
        this.scale = scale;
72
    }
73

    
74
    /**
75
     * Returns the scale.
76
     *
77
     * @return the scale
78
     */
79
    public double getScale() {
80
        return scale;
81
    }
82

    
83
    /**
84
     * Sets the scale.
85
     *
86
     * @param scale
87
     *            the scale to set
88
     */
89
    public void setScale(double scale) {
90
        this.scale = scale;
91
    }
92

    
93
        /**
94
         * Returns the value of an query parameter.
95
         *
96
         * @param name
97
         *            of the parameter
98
         * @return the parameter value
99
         */
100
    public Object getQueryParameter(String name) {
101
        return queryParameters.get(name);
102
    }
103

    
104
        /**
105
         * Sets the value of an query parameter.
106
         * 
107
         * @param name
108
         *            of the query parameter
109
         * @param value
110
         *            for the query parameter
111
         */
112
    public void setQueryParameter(String name, Object value) {
113
        queryParameters.put(name, value);
114
    }
115

    
116
    /**
117
     * @see Persistent#getState()
118
     */
119
        public PersistentState getState() throws PersistenceException {
120
                return AbstractPersistenceManager.getState(this);
121
        }
122

    
123
    /**
124
     * @see Persistent#loadState()
125
     */
126
        public void loadState(PersistentState state) throws PersistenceException {
127
                // FIXME: falta por terminar de implementar
128
                state.set("scale", scale);
129
        }
130

    
131
    /**
132
     * @see Persistent#setState()
133
     */
134
        public void setState(PersistentState state) throws PersistenceException {
135
                // FIXME: falta por terminar de implementar
136
                this.scale = state.getDouble("scale");
137
        }
138

    
139
}