1 package cytoscape.data;
2
3 import cytoscape.data.attr.CyData;
4 import cytoscape.data.attr.CyDataDefinition;
5
6 import java.util.List;
7 import java.util.Map;
8
9
10 public interface AttributeData {
11
12 // TODO: Event Listener Framework?
13 // TODO: Rowan's labels?
14
15 /**
16 * Gets a List of All Attribute Names.
17 *
18 * @return An Array of String Objects.
19 */
20 public String[] getAttributeNames();
21
22 /**
23 * Determines if the specified id/attributeName pair exists.
24 *
25 * @param id unique identifier.
26 * @param attributeName attribute name.
27 * @return true or false.
28 */
29 public boolean hasAttribute(String id, String attributeName);
30
31 /**
32 * Sets an id/attributeName pair of type boolean.
33 *
34 * @param id unique identifier.
35 * @param attributeName attribute name.
36 * @param value boolean value.
37 */
38 public void setAttribute(String id, String attributeName, boolean value);
39
40 /**
41 * Sets an id/attributeName pair of type integer.
42 *
43 * @param id unique identifier.
44 * @param attributeName attribute name.
45 * @param value integer value.
46 */
47 public void setAttribute(String id, String attributeName, int value);
48
49 /**
50 * Sets an id/attributeName pair of type double.
51 *
52 * @param id unique identifier.
53 * @param attributeName attribute name.
54 * @param value double value.
55 */
56 public void setAttribute(String id, String attributeName, double value);
57
58 /**
59 * Sets an id/attributeName pair of type String.
60 *
61 * @param id unique identifier.
62 * @param attributeName attribute name.
63 * @param value string value.
64 */
65 public void setAttribute(String id, String attributeName, String value);
66
67 /**
68 * Gets a boolean value at the specified id/attributeName.
69 * <P>If attributeName refers to a List, the zeroeth element in that list is
70 * returned.
71 *
72 * @param id unique identifier.
73 * @param attributeName attribute name.
74 * @return Boolean object, or null if no id/attributeName pair is found.
75 * @throws ClassCastException Indicates that the specified attribute
76 * is not of type Boolean.
77 */
78 public Boolean getBooleanAttribute(String id, String attributeName)
79 throws ClassCastException;
80
81 /**
82 * Gets an integer value at the specified id/attributeName.
83 * <P>If attributeName refers to a List, the zeroeth element in that list is
84 * returned.
85 *
86 * @param id unique identifier.
87 * @param attributeName attribute name.
88 * @return Integer object, or null if no id/attributeName pair is found.
89 * @throws ClassCastException Indicates that the specified attribute
90 * is not of type Integer.
91 */
92 public Integer getIntegerAttribute(String id, String attributeName)
93 throws ClassCastException;
94
95 /**
96 * Gets a double value at the specified id/attributeName.
97 * <P>If attributeName refers to a List, the zeroeth element in that list is
98 * returned.
99 *
100 * @param id unique identifier.
101 * @param attributeName attribute name.
102 * @return Double object, or null if no id/attributeName pair is found..
103 * @throws ClassCastException Indicates that the specified attribute
104 * is not of type Double.
105 */
106 public Double getDoubleAttribute(String id, String attributeName)
107 throws ClassCastException;
108
109 /**
110 * Gets a String value at the specified id/attributeName.
111 * <P>If attributeName refers to a List, the zeroeth element in that list is
112 * returned.
113 *
114 * @param id unique identifier.
115 * @param attributeName attribute name.
116 * @return String object, or null if no id/attributeName pair is found.
117 * @throws ClassCastException Indicates that the specified attribute
118 * is not of type String.
119 */
120 public String getStringAttribute(String id, String attributeName)
121 throws ClassCastException;
122
123 /**
124 * Gets the Class of the specified attribute.
125 *
126 * @param attributeName Attribute Name.
127 * @return Return type will be of type: Boolean, Integer, Double,
128 * String, List or Map. If attributeName has not been
129 * defined, this method will return null.
130 */
131 public Class getClass(String attributeName);
132
133 /**
134 * Delete the id/attributeName pair.
135 *
136 * @param id unique identifier.
137 * @param attributeName attribute name.
138 * @return true indicates attribute was
139 * successfully removed.
140 */
141 public boolean deleteAttribute(String id, String attributeName);
142
143 /**
144 * Sets a List of Attributes.
145 * <P><B>Note:</B>
146 * <UL>
147 * <LI>All items within the list must be of the same type,
148 * and and chosen from the following list: Boolean, Integer, Double,
149 * or String.
150 * </LI>
151 * </UL>
152 * If the above requirement is not met, an IllegalArgumentException
153 * will be thrown.
154 *
155 * @param id unique identifier.
156 * @param list attribute name.
157 * @param list List Object.
158 */
159 public void setAttributeList(String id, String attributeName, List list)
160 throws IllegalArgumentException;
161
162 /**
163 * Gets a List of attributes for the id/attributeName pair.
164 *
165 * @param id unique identifier.
166 * @param attributeName attribute name.
167 * @return List object.
168 * @throws ClassCastException Indicates that the specified attribute
169 * is not of type List.
170 */
171 public List getAttributeList(String id, String attributeName)
172 throws ClassCastException;
173
174 /**
175 * Sets a Map of Attribute Values.
176 * <P><B>Note:</B>
177 * <UL>
178 * <LI>All keys within the Map must be of type String.
179 * <LI>All values within the Map must be of the same type,
180 * and chosen from the following list: Boolean, Integer, Double, or String.
181 * </UL>
182 * If the above requirements are not met, an IllegalArgumentException
183 * will be thrown.
184 *
185 * @param id unique identifier.
186 * @param attributeName attribute name.
187 * @param map Map Object.
188 */
189 public void setAttributeMap(String id, String attributeName,
190 Map map);
191
192 /**
193 * Gets a Map of Attribute Value.
194 *
195 * @param id unique identifier.
196 * @param attributeName attribute name.
197 * @return Map Object.
198 */
199 public Map getAttributeMap(String id, String attributeName);
200
201 /**
202 * Gets the CyData Object, which stores the actual attribute values.
203 * <P>By using CyData and CyDataDefintion directly, you can store
204 * arbitrarily complex data structures. Recommended for advanced
205 * coders only.
206 *
207 * @return CyData Object.
208 */
209 public CyData getCyData();
210
211 /**
212 * Gets the CyDataDefinition Object, which stores attribute definitions.
213 * <P>By using CyData and CyDataDefintion directly, you can store
214 * arbitrarily complex data structures. Recommended for advanced
215 * coders only.
216 *
217 * @return CyDataDefintion Object.
218 */
219 public CyDataDefinition getCyDataDefinition();
220 }
221