root / tags / Root_CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / DxfGroupVector.java @ 1732
History | View | Annotate | Download (1.36 KB)
1 |
/*
|
---|---|
2 |
* Created on 04-may-2004
|
3 |
*/
|
4 |
package org.cresques.io; |
5 |
|
6 |
import java.util.Vector; |
7 |
|
8 |
/**
|
9 |
* Vector de DxfGroup. Auxiliar para leer ficheros .dxf
|
10 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
11 |
*/
|
12 |
|
13 |
public class DxfGroupVector extends Vector { |
14 |
/**
|
15 |
* Valor del dato del codigo de grupo especificado.
|
16 |
*
|
17 |
* @param code C?digo de grupo dxf.
|
18 |
* @return Valor del data del grupo dxf, null si no existe.
|
19 |
*/
|
20 |
|
21 |
public boolean hasCode(int code) { |
22 |
DxfGroup grp = null;
|
23 |
for (int i=0; i<size(); i++) { |
24 |
grp = (DxfGroup) get(i); |
25 |
if (grp.code == code)
|
26 |
return true; |
27 |
} |
28 |
return false; |
29 |
} |
30 |
public Object getData(int code) { |
31 |
DxfGroup grp = null;
|
32 |
for (int i=0; i<size(); i++) { |
33 |
grp = (DxfGroup) get(i); |
34 |
if (grp.code == code)
|
35 |
return grp.data;
|
36 |
} |
37 |
return null; |
38 |
} |
39 |
|
40 |
public String getDataAsString(int code) { |
41 |
return (String) getData(code); |
42 |
} |
43 |
public double getDataAsDouble(int code) { |
44 |
Double f = (Double) getData(code); |
45 |
if (f == null) { |
46 |
System.err.println(this); |
47 |
} |
48 |
return f.doubleValue();
|
49 |
} |
50 |
public int getDataAsInt(int code) { |
51 |
Integer i = (Integer) getData(code); |
52 |
if (i == null) { |
53 |
System.err.println(this); |
54 |
} |
55 |
return i.intValue();
|
56 |
} |
57 |
public String toString() { |
58 |
String str = "DxfGroupVector["; |
59 |
DxfGroup grp = null;
|
60 |
for (int i=0; i<size(); i++) { |
61 |
grp = (DxfGroup) get(i); |
62 |
str += "("+grp.code+":"+grp.data+"),"; |
63 |
} |
64 |
|
65 |
return str;
|
66 |
} |
67 |
} |
68 |
|