Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / DxfGroupVector.java @ 2312

History | View | Annotate | Download (2.21 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
 * Vector de DxfGroup. Auxiliar para leer ficheros .dxf
30
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
31
 */
32

    
33
public class DxfGroupVector extends Vector {
34
        /**
35
         * Valor del dato del codigo de grupo especificado.
36
         * 
37
         * @param code C?digo de grupo dxf.
38
         * @return Valor del data del grupo dxf, null si no existe.
39
         */
40
        
41
        public boolean hasCode(int code) {
42
                DxfGroup grp = null;
43
                for (int i=0; i<size(); i++) {
44
                        grp = (DxfGroup) get(i);
45
                        if (grp.code == code)
46
                                return true;
47
                }
48
                return false;
49
        }
50
        public Object getData(int code) {
51
                DxfGroup grp = null;
52
                for (int i=0; i<size(); i++) {
53
                        grp = (DxfGroup) get(i);
54
                        if (grp.code == code)
55
                                return grp.data;
56
                }
57
                return null;
58
        }
59
        
60
        public String getDataAsString(int code) {
61
                return (String) getData(code);
62
        }
63
        public double getDataAsDouble(int code) {
64
                Double f = (Double) getData(code);
65
                if (f == null) {
66
                        System.err.println(this);
67
                }
68
                return f.doubleValue();
69
        }
70
        public int getDataAsInt(int code) {
71
                Integer i = (Integer) getData(code);
72
                if (i == null) {
73
                        System.err.println(this);
74
                }
75
                return i.intValue();
76
        }
77
        public String toString() {
78
                String str = "DxfGroupVector[";
79
                DxfGroup grp = null;
80
                for (int i=0; i<size(); i++) {
81
                        grp = (DxfGroup) get(i);
82
                        str += "("+grp.code+":"+grp.data+"),";
83
                }
84
                
85
                return str;
86
        }
87
}
88