Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/DxfGroupVector.java

View differences:

DxfGroupVector.java
1 1
/*
2 2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5 3
 *
4
 * Copyright (C) 2004-5.
5
 *
6 6
 * This program is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU General Public License
8 8
 * as published by the Free Software Foundation; either version 2
......
18 18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19 19
 *
20 20
 * For more information, contact:
21
 * 
21
 *
22 22
 * cresques@gmail.com
23 23
 */
24 24
package org.cresques.io;
25 25

  
26 26
import java.util.Vector;
27 27

  
28

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

  
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
	}
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
    public Object getData(int code) {
57
        DxfGroup grp = null;
58

  
59
        for (int i = 0; i < size(); i++) {
60
            grp = (DxfGroup) get(i);
61

  
62
            if (grp.code == code) {
63
                return grp.data;
64
            }
65
        }
66

  
67
        return null;
68
    }
69

  
70
    public String getDataAsString(int code) {
71
        return (String) getData(code);
72
    }
73

  
74
    public double getDataAsDouble(int code) {
75
        Double f = (Double) getData(code);
76

  
77
        if (f == null) {
78
            System.err.println(this);
79
        }
80

  
81
        return f.doubleValue();
82
    }
83

  
84
    public int getDataAsInt(int code) {
85
        Integer i = (Integer) getData(code);
86

  
87
        if (i == null) {
88
            System.err.println(this);
89
        }
90

  
91
        return i.intValue();
92
    }
93

  
94
    public String toString() {
95
        String str = "DxfGroupVector[";
96
        DxfGroup grp = null;
97

  
98
        for (int i = 0; i < size(); i++) {
99
            grp = (DxfGroup) get(i);
100
            str += ("(" + grp.code + ":" + grp.data + "),");
101
        }
102

  
103
        return str;
104
    }
90 105
}
91

  

Also available in: Unified diff