Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / DxfGroupVector.java @ 4578

History | View | Annotate | Download (3.24 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io;
25

    
26
import java.util.Vector;
27

    
28

    
29
/**
30
 * Vector de DxfGroup. Auxiliar para leer ficheros .dxf
31
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
32
 */
33
public class DxfGroupVector extends Vector {
34
    final private static long serialVersionUID = -3370601314380922368L;
35

    
36
    /**
37
     * Valor del dato del codigo de grupo especificado.
38
     *
39
     * @param code C?digo de grupo dxf.
40
     * @return Valor del data del grupo dxf, null si no existe.
41
     */
42
    public boolean hasCode(int code) {
43
        DxfGroup grp = null;
44

    
45
        for (int i = 0; i < size(); i++) {
46
            grp = (DxfGroup) get(i);
47

    
48
            if (grp.code == code) {
49
                return true;
50
            }
51
        }
52

    
53
        return false;
54
    }
55
    
56
    /**
57
     * Devuelve la informaci?n contenida en un DxfGroup.
58
     * @param code, la parte concreta del DxfGroup a la que queremos acceder
59
     * @return
60
     */
61
    public Object getData(int code) {
62
        DxfGroup grp = null;
63

    
64
        for (int i = 0; i < size(); i++) {
65
            grp = (DxfGroup) get(i);
66

    
67
            if (grp.code == code) {
68
                return grp.data;
69
            }
70
        }
71

    
72
        return null;
73
    }
74
    
75
    /**
76
     * Obtiene la informaci?n contenida en un DxfGroup en forma de String
77
     * @param code
78
     * @return
79
     */
80
    public String getDataAsString(int code) {
81
        return (String) getData(code);
82
    }
83
    
84
    /**
85
     * Obtiene la informaci?n contenida en un DxfGroup en forma de double
86
     * @param code
87
     * @return
88
     */
89
    public double getDataAsDouble(int code) {
90
        Double f = (Double) getData(code);
91

    
92
        if (f == null) {
93
            System.err.println(this);
94
        }
95

    
96
        return f.doubleValue();
97
    }
98
    
99
    /**
100
     * Obtiene la informaci?n contenida en un DxfGroup en forma de integer
101
     * @param code
102
     * @return
103
     */
104
    public int getDataAsInt(int code) {
105
        Integer i = (Integer) getData(code);
106

    
107
        if (i == null) {
108
            System.err.println(this);
109
        }
110

    
111
        return i.intValue();
112
    }
113
    
114
    /**
115
     * Permite obtener el contenido de un DxfGroup en forma de String
116
     */
117
    public String toString() {
118
        String str = "DxfGroupVector[";
119
        DxfGroup grp = null;
120

    
121
        for (int i = 0; i < size(); i++) {
122
            grp = (DxfGroup) get(i);
123
            str += ("(" + grp.code + ":" + grp.data + "),");
124
        }
125

    
126
        return str;
127
    }
128
}