svn-gvsig-desktop / trunk / extensions / extGPE-gvSIG / src / org / gvsig / fmap / drivers / gpe / model / GPEElement.java @ 27067
History | View | Annotate | Download (2.64 KB)
1 |
package org.gvsig.fmap.drivers.gpe.model; |
---|---|
2 |
|
3 |
import java.util.HashMap; |
4 |
import java.util.Iterator; |
5 |
|
6 |
import com.hardcode.gdbms.engine.values.ComplexValue; |
7 |
import com.hardcode.gdbms.engine.values.Value; |
8 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
9 |
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
11 |
*
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
13 |
*
|
14 |
* This program is free software; you can redistribute it and/or
|
15 |
* modify it under the terms of the GNU General Public License
|
16 |
* as published by the Free Software Foundation; either version 2
|
17 |
* of the License, or (at your option) any later version.
|
18 |
*
|
19 |
* This program is distributed in the hope that it will be useful,
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
* GNU General Public License for more details.
|
23 |
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
27 |
*
|
28 |
* For more information, contact:
|
29 |
*
|
30 |
* Generalitat Valenciana
|
31 |
* Conselleria d'Infraestructures i Transport
|
32 |
* Av. Blasco Ib??ez, 50
|
33 |
* 46010 VALENCIA
|
34 |
* SPAIN
|
35 |
*
|
36 |
* +34 963862235
|
37 |
* gvsig@gva.es
|
38 |
* www.gvsig.gva.es
|
39 |
*
|
40 |
* or
|
41 |
*
|
42 |
* IVER T.I. S.A
|
43 |
* Salamanca 50
|
44 |
* 46005 Valencia
|
45 |
* Spain
|
46 |
*
|
47 |
* +34 963163400
|
48 |
* dac@iver.es
|
49 |
*/
|
50 |
/* CVS MESSAGES:
|
51 |
*
|
52 |
* $Id$
|
53 |
* $Log$
|
54 |
*
|
55 |
*/
|
56 |
/**
|
57 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
58 |
*/
|
59 |
public class GPEElement { |
60 |
private String name = null; |
61 |
private Value value = null; |
62 |
private HashMap subElements = null; |
63 |
|
64 |
public GPEElement(String name, Value value) { |
65 |
super();
|
66 |
this.name = name;
|
67 |
this.value = value;
|
68 |
subElements = new HashMap(); |
69 |
} |
70 |
|
71 |
public GPEElement(String name, Value value, GPEElement parentElement) { |
72 |
this(name,value);
|
73 |
//If it is a complex value
|
74 |
if (parentElement != null){ |
75 |
parentElement.addChildElement(this);
|
76 |
} |
77 |
} |
78 |
|
79 |
/**
|
80 |
* It adds a new child element
|
81 |
* @param children
|
82 |
* The element to add
|
83 |
*/
|
84 |
public void addChildElement(GPEElement children){ |
85 |
subElements.put(children.getName(), children); |
86 |
} |
87 |
|
88 |
/**
|
89 |
* @return the name
|
90 |
*/
|
91 |
public String getName() { |
92 |
return name;
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* @return the value
|
97 |
*/
|
98 |
public Value getValue() {
|
99 |
if (subElements.size() > 0){ |
100 |
ComplexValue cValue = ValueFactory.createComplexValue(name); |
101 |
Iterator it = subElements.keySet().iterator();
|
102 |
while(it.hasNext()){
|
103 |
GPEElement element = (GPEElement)subElements.get(it.next()); |
104 |
cValue.put(element.getName(), element.getValue()); |
105 |
} |
106 |
return cValue;
|
107 |
} |
108 |
return value;
|
109 |
} |
110 |
} |