svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.metadata.basic / org.gvsig.metadata.basic.lib / org.gvsig.metadata.lib.basic.impl / src / main / java / org / gvsig / metadata / lib / basic / impl / AbstractMetadata.java @ 40769
History | View | Annotate | Download (2.71 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.metadata.lib.basic.impl; |
25 |
|
26 |
import java.util.HashSet; |
27 |
import java.util.Set; |
28 |
|
29 |
import org.gvsig.metadata.Metadata; |
30 |
import org.gvsig.metadata.exceptions.MetadataException; |
31 |
import org.gvsig.tools.dynobject.DynStruct; |
32 |
import org.gvsig.tools.dynobject.impl.DefaultDynObject; |
33 |
|
34 |
/**
|
35 |
* Abstract metadata used in both metadata basic and full modules.
|
36 |
*/
|
37 |
public abstract class AbstractMetadata extends DefaultDynObject implements |
38 |
Metadata, Comparable {
|
39 |
|
40 |
public AbstractMetadata(DynStruct dynClass) {
|
41 |
super(dynClass);
|
42 |
} |
43 |
|
44 |
public Set getMetadataChildren() throws MetadataException { |
45 |
Set children = new HashSet(); |
46 |
DynStruct[] items = this.getDynClass().getSuperDynStructs(); |
47 |
if (items == null) |
48 |
return children;
|
49 |
|
50 |
Object item;
|
51 |
for (int i = 0; i < items.length; i++) { |
52 |
item = items[i]; |
53 |
if (item instanceof Metadata) { |
54 |
children.add(item); |
55 |
} |
56 |
} |
57 |
return children;
|
58 |
} |
59 |
|
60 |
public Object getMetadataID() throws MetadataException { |
61 |
return this.getDynClass().getFullName(); |
62 |
} |
63 |
|
64 |
public String getMetadataName() throws MetadataException { |
65 |
return this.getDynClass().getName(); |
66 |
} |
67 |
|
68 |
|
69 |
public int compareTo(Object object) { |
70 |
if (object == null) { |
71 |
return 0; |
72 |
} |
73 |
if (object instanceof Metadata) { |
74 |
return this |
75 |
.getDynClass() |
76 |
.getFullName() |
77 |
.toLowerCase() |
78 |
.compareTo( |
79 |
((Metadata) object).getDynClass().getFullName() |
80 |
.toLowerCase()); |
81 |
} |
82 |
if (object instanceof DynStruct) { |
83 |
return this |
84 |
.getDynClass() |
85 |
.getFullName() |
86 |
.toLowerCase() |
87 |
.compareTo(((DynStruct) object).getFullName().toLowerCase()); |
88 |
} |
89 |
return 0; |
90 |
} |
91 |
|
92 |
public String toString() { |
93 |
String name = this.getDynClass().getName(); |
94 |
return name.substring(0, 1).toUpperCase() + name.substring(1); |
95 |
} |
96 |
|
97 |
public String toDynObjectString() { |
98 |
return super.toString(); |
99 |
} |
100 |
} |