Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libGeocoding / src / org / gvsig / normalization / pattern / Patternnormalization.java @ 29125

History | View | Annotate | Download (4.49 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

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 Prodevelop S.L. main development
26
 */
27

    
28
package org.gvsig.normalization.pattern;
29

    
30
/**
31
 * 
32
 * @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
33
 * @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
34
 * 
35
 */
36

    
37
import java.util.ArrayList;
38
import java.util.List;
39

    
40

    
41
/**
42
 * Class Patternnormalization.
43
 * 
44
 * This class is the normalization pattern. This pattern has your name
45
 * (_patternname), your xml file path (_patternurl), the attribute
46
 * (_nofirstrows) that says the number of the rows in the text file that will
47
 * not be normalized and the list of elements (_elements) that make the pattern
48
 */
49
public class Patternnormalization implements Persistent {
50
        
51
        /**
52
         * Pattern name
53
         */
54
        private String _patternname;
55

    
56

    
57
        /**
58
         * number of file rows that they will not be normalized
59
         */
60
        private int _nofirstrows;
61

    
62
        /**
63
         * List of elements. Each element is one new field. One element has
64
         * attributes that they define the new field and split strings process.
65
         */
66
        private List _elements;
67

    
68
        /**
69
         * Constructor
70
         */
71
        public Patternnormalization() {
72
                super();
73
        }
74

    
75
        /**
76
         * Returns the value of field 'elements'.
77
         * 
78
         * @return the value of field 'elements'.
79
         */
80

    
81
        public List getElements() {
82
                return this._elements;
83
        }
84

    
85
        /**
86
         * Returns the value of field 'elements'.
87
         * 
88
         * @return the value of field 'elements'.
89
         */
90
        public Element[] getArrayElements() {
91
                Element[] eles = new Element[this._elements.size()];
92
                for (int i = 0; i < this._elements.size(); i++) {
93
                        eles[i] = (Element) this._elements.get(i);
94
                }
95
                return eles;
96
        }
97

    
98
        /**
99
         * Returns the value of field 'nofirstrows'.
100
         * 
101
         * @return the value of field 'nofirstrows'.
102
         */
103
        public int getNofirstrows() {
104
                return this._nofirstrows;
105
        }
106

    
107
        /**
108
         * Returns the value of field 'patternname'.
109
         * 
110
         * @return the value of field 'patternname'.
111
         */
112
        public java.lang.String getPatternname() {
113
                return this._patternname;
114
        }
115

    
116

    
117
        /**
118
         * Sets the value of field 'elements'.
119
         * 
120
         * @param elements
121
         *            the value of field 'elements'.
122
         */
123

    
124
        public void setElements(List elements) {
125
                this._elements = elements;
126
        }
127

    
128
        /**
129
         * Sets the value of field 'nofirstrows'.
130
         * 
131
         * @param nofirstrows
132
         *            the value of field 'nofirstrows'.
133
         */
134
        public void setNofirstrows(int nofirstrows) {
135
                this._nofirstrows = nofirstrows;
136
        }
137

    
138
        /**
139
         * Sets the value of field 'patternname'.
140
         * 
141
         * @param patternname
142
         *            the value of field 'patternname'.
143
         */
144
        public void setPatternname(String patternname) {
145
                this._patternname = patternname;
146
        }
147

    
148
        /**
149
         * This method serializes the pattern object
150
         * 
151
         * @param state
152
         */
153
        public void getstate(IStorage state) {
154
                state.setName("patternnormalization");
155
                state.setTheClass(this);
156
                state.put("patternname", this._patternname);
157
                state.put("nofirstrows", this._nofirstrows);
158
                state.put("elements", "element", this._elements);
159
        }
160

    
161
        /**
162
         * This method parses the pattern object
163
         * 
164
         * @param state
165
         */
166
        public void setstate(IStorage state) {
167
                this._patternname = ((String) state.get("patternname")).trim();
168
                this._nofirstrows = state.getInt("nofirstrows");
169
                try {
170
                        StorageCollection sto = (StorageCollection) state
171
                                        .getObject("elements");
172
                        this._elements = new ArrayList();
173
                        for (int i = 0; i < sto.size(); i++) {
174
                                Element elem = (Element) sto.get(i);
175
                                this._elements.add(elem);
176
                        }
177
                } catch (Exception e) {
178
                        log.error("parsing pattern", e);
179
                }
180
        }
181

    
182
}