Statistics
| Revision:

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 @ 40608

History | View | Annotate | Download (2.86 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
 * 2011 Geographic Information research group: http://www.geoinfo.uji.es
26
 * Departamento de Lenguajes y Sistemas Inform�ticos (LSI)
27
 * Universitat Jaume I   
28
 */
29
package org.gvsig.metadata.lib.basic.impl;
30

    
31
import java.util.HashSet;
32
import java.util.Set;
33

    
34
import org.gvsig.metadata.Metadata;
35
import org.gvsig.metadata.exceptions.MetadataException;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.dynobject.impl.DefaultDynObject;
38

    
39
/**
40
 * Abstract metadata used in both metadata basic and full modules.
41
 */
42
public abstract class AbstractMetadata extends DefaultDynObject implements
43
                Metadata, Comparable {
44

    
45
        public AbstractMetadata(DynStruct dynClass) {
46
                super(dynClass);
47
        }
48

    
49
        public Set getMetadataChildren() throws MetadataException {
50
                Set children = new HashSet();
51
                DynStruct[] items = this.getDynClass().getSuperDynStructs();
52
                if (items == null)
53
                        return children;
54

    
55
                Object item;
56
                for (int i = 0; i < items.length; i++) {
57
                        item = items[i];
58
                        if (item instanceof Metadata) {
59
                                children.add(item);
60
                        }
61
                }
62
                return children;
63
        }
64

    
65
        public Object getMetadataID() throws MetadataException {
66
                return this.getDynClass().getFullName();
67
        }
68

    
69
        public String getMetadataName() throws MetadataException {
70
                return this.getDynClass().getName();
71
        }
72

    
73

    
74
        public int compareTo(Object object) {
75
                if (object == null) {
76
                        return 0;
77
                }
78
                if (object instanceof Metadata) {
79
                        return this
80
                                        .getDynClass()
81
                                        .getFullName()
82
                                        .toLowerCase()
83
                                        .compareTo(
84
                                                        ((Metadata) object).getDynClass().getFullName()
85
                                                                        .toLowerCase());
86
                }
87
                if (object instanceof DynStruct) {
88
                        return this
89
                                        .getDynClass()
90
                                        .getFullName()
91
                                        .toLowerCase()
92
                                        .compareTo(((DynStruct) object).getFullName().toLowerCase());
93
                }
94
                return 0;
95
        }
96

    
97
        public String toString() {
98
                String name = this.getDynClass().getName();
99
                return name.substring(0, 1).toUpperCase() + name.substring(1);
100
        }
101

    
102
        public String toDynObjectString() {
103
                return super.toString();
104
        }
105
}