Statistics
| Revision:

root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / DxfGroupVector.java @ 2664

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