svn-gvsig-desktop / tags / J2ME_compat_v1_2_Build_1209 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / DefaultRow.java @ 19509
History | View | Annotate | Download (2.08 KB)
1 | 19509 | jcarrasco | package com.iver.cit.gvsig.fmap.core; |
---|---|---|---|
2 | |||
3 | import java.rmi.server.UID; |
||
4 | |||
5 | import com.hardcode.gdbms.engine.values.NullValue; |
||
6 | import com.hardcode.gdbms.engine.values.Value; |
||
7 | |||
8 | |||
9 | /**
|
||
10 | * DOCUMENT ME!
|
||
11 | *
|
||
12 | * @author Vicente Caballero Navarro
|
||
13 | */
|
||
14 | public class DefaultRow implements IRow { |
||
15 | private Value[] attributes; |
||
16 | private String id; |
||
17 | |||
18 | |||
19 | |||
20 | /**
|
||
21 | * FROM GEOTOOLS: Creates an ID from a hashcode.
|
||
22 | *
|
||
23 | * @return an id for the feature.
|
||
24 | */
|
||
25 | String defaultID() {
|
||
26 | return "fid-" + (new UID()).toString(); |
||
27 | } |
||
28 | |||
29 | /**
|
||
30 | * Crea un nuevo DefaultRow.
|
||
31 | *
|
||
32 | * @param att DOCUMENT ME!
|
||
33 | */
|
||
34 | public DefaultRow(Value[] att) { |
||
35 | this.attributes = att;
|
||
36 | this.id = defaultID();
|
||
37 | } |
||
38 | |||
39 | /**
|
||
40 | * Crea un nuevo DefaultRow.
|
||
41 | *
|
||
42 | * @param att DOCUMENT ME!
|
||
43 | * @param id DOCUMENT ME!
|
||
44 | */
|
||
45 | public DefaultRow(Value[] att, String id) { |
||
46 | this.attributes = att;
|
||
47 | this.id = id;
|
||
48 | } |
||
49 | |||
50 | /**
|
||
51 | * DOCUMENT ME!
|
||
52 | *
|
||
53 | * @return DOCUMENT ME!
|
||
54 | */
|
||
55 | public String getID() { |
||
56 | return id;
|
||
57 | } |
||
58 | |||
59 | /**
|
||
60 | * DOCUMENT ME!
|
||
61 | *
|
||
62 | * @param fieldIndex DOCUMENT ME!
|
||
63 | *
|
||
64 | * @return DOCUMENT ME!
|
||
65 | */
|
||
66 | public Value getAttribute(int fieldIndex) { |
||
67 | if (attributes == null) |
||
68 | return new NullValue(); |
||
69 | if (fieldIndex >= attributes.length)
|
||
70 | return new NullValue(); |
||
71 | return attributes[fieldIndex];
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * DOCUMENT ME!
|
||
76 | *
|
||
77 | * @return DOCUMENT ME!
|
||
78 | */
|
||
79 | public Value[] getAttributes() { |
||
80 | return attributes;
|
||
81 | } |
||
82 | |||
83 | /**
|
||
84 | * DOCUMENT ME!
|
||
85 | *
|
||
86 | * @return DOCUMENT ME!
|
||
87 | */
|
||
88 | public IRow cloneRow() {
|
||
89 | Value[] values = new Value[attributes.length]; |
||
90 | |||
91 | if (attributes != null) { |
||
92 | values = (Value[]) attributes.clone();
|
||
93 | } |
||
94 | |||
95 | DefaultRow dr = new DefaultRow(values, id);
|
||
96 | |||
97 | return dr;
|
||
98 | } |
||
99 | |||
100 | public void setID(String ID) { |
||
101 | id = ID; |
||
102 | } |
||
103 | |||
104 | public void setAttributes(Value[] att) { |
||
105 | this.attributes = att;
|
||
106 | } |
||
107 | |||
108 | } |