Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.xml2db / org.gvsig.xml2db.lib / org.gvsig.xml2db.lib.impl / src / main / java / org / gvsig / xml2db / lib / impl / xmlinfo / XMLInfoImpl.java @ 47283

History | View | Annotate | Download (3.08 KB)

1
package org.gvsig.xml2db.lib.impl.xmlinfo;
2

    
3
import java.nio.charset.Charset;
4
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo;
5
import java.util.ArrayList;
6
import java.util.Collection;
7
import java.util.Iterator;
8
import java.util.LinkedHashMap;
9
import java.util.List;
10
import java.util.Map;
11
import org.apache.commons.lang3.StringUtils;
12
import org.cresques.cts.IProjection;
13
import org.gvsig.tools.util.CompareUtils;
14
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo;
15

    
16
/**
17
 *
18
 * @author jjdelcerro
19
 */
20
public class XMLInfoImpl implements XMLInfo {
21

    
22
    private final Map<String,XMLAttributeInfoImpl> tags;
23
    private final Map<String,XMLTableInfo> tables;
24
    private IProjection srid;
25
    private long countLines;
26
    private String repositoryID;
27
    private Charset charset;
28
    
29
    public XMLInfoImpl() {
30
        this.tags = new LinkedHashMap<>();
31
        this.tables = new LinkedHashMap<>();
32
        this.countLines = -1;
33
    }
34
    
35
    @Override
36
    public IProjection getSrid() {
37
        return this.srid;
38
    }
39
    
40
    @Override
41
    public void setSrid(IProjection srid) {
42
        this.srid = srid;
43
    }
44
    
45
    public XMLAttributeInfoImpl getTag(String path) {
46
        return this.tags.get(path);
47
    }
48
    
49
    public Collection<String> getTagsPaths() {
50
        return this.tags.keySet();
51
    }
52
    
53
    public void addTag(XMLAttributeInfoImpl info) {
54
        tags.put(info.getPath(), info);
55
    }
56
    
57
    public XMLAttributeInfoImpl getTagInfo(String path) {
58
        return this.tags.get(path);
59
    }
60

    
61
    public void addTable(XMLTableInfoImpl tableInfo) {
62
        tables.put(tableInfo.getPath(), tableInfo);
63
    }
64

    
65
    public XMLTableInfoImpl getTableByPath(String path) {
66
        return (XMLTableInfoImpl) this.tables.get(path);
67
                
68
    }
69

    
70
    public boolean existsTableByPath(String path) {
71
        return this.tables.containsKey(path);
72
    }
73
    
74
    @Override
75
    public int size() {
76
        return this.tables.size();
77
    }
78

    
79
    @Override
80
    public XMLTableInfo get(String name) {
81
        for (XMLTableInfo tableInfo : this) {
82
            if( StringUtils.equals(name, tableInfo.getName()) ) {
83
                return tableInfo;
84
            }
85
        }
86
        return null;
87
    }
88

    
89
    @Override
90
    public List<String> getKeys() {
91
        List<String> names = new ArrayList<>(this.tables.keySet());
92
        names.sort(CompareUtils.EQUALS_IGNORECASE_COMPARATOR);
93
        return names;
94
    }
95

    
96
    @Override
97
    public Iterator<XMLTableInfo> iterator() {
98
        return this.tables.values().iterator();
99
    }
100

    
101
    @Override
102
    public boolean isEmpty() {
103
        return this.tables.isEmpty();
104
    }
105

    
106
    public void setCountLines(long countlines) {
107
        this.countLines = countlines;
108
    }
109
    
110
    public long getCountLines() {
111
        return this.countLines;
112
    }
113

    
114
    @Override
115
    public String getRepositoryID() {
116
        return this.repositoryID;
117
    }
118

    
119
    @Override
120
    public void setRepositoryID(String id) {
121
        this.repositoryID = id;
122
    }
123

    
124
    public Charset getCharset() {
125
        return this.charset;
126
    }
127
    
128
    public void setCharset(Charset charset) {
129
        this.charset = charset;
130
    }
131
}