1 | package PIANOS.datastructures; |
2 | |
3 | import PIANOS.exceptions.*; |
4 | import java.util.HashMap; |
5 | import java.util.LinkedList; |
6 | |
7 | public class Entity{ |
8 | |
9 | private String name; |
10 | private String dataFile; |
11 | private String spatialMatrixFile; |
12 | |
13 | private boolean isMatrix; |
14 | |
15 | private int size; |
16 | private int lineLength; |
17 | |
18 | private LinkedList<Variable> variableList; |
19 | |
20 | private Entity xCoordinate; |
21 | private Entity yCoordinate; |
22 | |
23 | public Entity (){ |
24 | this.name = null; |
25 | this.dataFile = null; |
26 | this.spatialMatrixFile = null; |
27 | this.isMatrix = false; |
28 | this.size = -1; |
29 | this.lineLength = -1; |
30 | this.xCoordinate = null; |
31 | this.yCoordinate = null; |
32 | variableList = new LinkedList<Variable>(); |
33 | } |
34 | |
35 | public void addVariable (Variable variable){ |
36 | variableList.add(variable); |
37 | } |
38 | |
39 | public LinkedList<Variable> getVariableList (){ |
40 | return this.variableList; |
41 | } |
42 | |
43 | public String getName(){ |
44 | return this.name; |
45 | } |
46 | |
47 | public void setName(String name) { |
48 | this.name=name; |
49 | } |
50 | |
51 | public void setSize (int size){ |
52 | this.size = size; |
53 | } |
54 | |
55 | public int getSize (){ |
56 | return this.size; |
57 | } |
58 | |
59 | public void setLineLength (int lineLength){ |
60 | this.lineLength = lineLength; |
61 | } |
62 | |
63 | public int getLineLength (){ |
64 | return this.lineLength; |
65 | } |
66 | |
67 | public String getDataFile (){ |
68 | return this.dataFile; |
69 | } |
70 | |
71 | public void setDataFile (String dataFile){ |
72 | this.dataFile = dataFile; |
73 | } |
74 | |
75 | public boolean isMatrix (){ |
76 | return isMatrix; |
77 | } |
78 | |
79 | public void setMatrix (boolean isMatrix){ |
80 | this.isMatrix=isMatrix; |
81 | } |
82 | |
83 | public String getSpatialMatrixFile (){ |
84 | return spatialMatrixFile; |
85 | } |
86 | |
87 | public void setSpatialMatrixFile (String spatialMatrixFile){ |
88 | this.spatialMatrixFile=spatialMatrixFile; |
89 | } |
90 | |
91 | public Entity getXCoordinate (){ |
92 | return xCoordinate; |
93 | } |
94 | |
95 | public void setXCoordinate (Entity xCoordinate){ |
96 | this.xCoordinate = xCoordinate; |
97 | } |
98 | |
99 | public Entity getYCoordinate (){ |
100 | return yCoordinate; |
101 | } |
102 | |
103 | public void setYCoordinate (Entity yCoordinate){ |
104 | this.yCoordinate = yCoordinate; |
105 | } |
106 | |
107 | public boolean isSpatial (){ |
108 | if (this.spatialMatrixFile == null) |
109 | return false; |
110 | else |
111 | return true; |
112 | } |
113 | |
114 | public String toString(){ |
115 | String toReturn = ""; |
116 | toReturn += "ENTITY " + this.getName(); |
117 | if (this.getDataFile() != null) |
118 | toReturn += " \"" + this.getDataFile() + "\""; |
119 | |
120 | if (this.isMatrix()){ |
121 | toReturn += ", combines(" + this.getXCoordinate().getName(); |
122 | toReturn += ", " + this.getYCoordinate().getName() + ")"; |
123 | |
124 | } |
125 | else { |
126 | if (this.getSpatialMatrixFile() != null) |
127 | toReturn += ", " + this.getSpatialMatrixFile(); |
128 | } |
129 | toReturn += " size "+ this.getSize() + "\n"; |
130 | toReturn += "\tVariables: \n"; |
131 | |
132 | for (Variable var : this.getVariableList()){ |
133 | toReturn += "\t" + var + "\n"; |
134 | } |
135 | return toReturn; |
136 | } |
137 | } |