1010 */
1111public class CategoryDefinition implements ISourceSinkCategory {
1212
13- public static enum CATEGORY {
14- // all categories
15- ALL ,
16-
17- // SOURCES
18- NO_CATEGORY , HARDWARE_INFO , UNIQUE_IDENTIFIER , LOCATION_INFORMATION , NETWORK_INFORMATION , ACCOUNT_INFORMATION ,
19- EMAIL_INFORMATION , FILE_INFORMATION , BLUETOOTH_INFORMATION , VOIP_INFORMATION , DATABASE_INFORMATION ,
20- PHONE_INFORMATION ,
21-
22- // SINKS
23- PHONE_CONNECTION , INTER_APP_COMMUNICATION , VOIP , PHONE_STATE , EMAIL , BLUETOOTH , ACCOUNT_SETTINGS , VIDEO ,
24- SYNCHRONIZATION_DATA , NETWORK , EMAIL_SETTINGS , FILE , LOG ,
25-
26- // SHARED
27- AUDIO , SMS_MMS , CONTACT_INFORMATION , CALENDAR_INFORMATION , SYSTEM_SETTINGS , IMAGE , BROWSER_INFORMATION , NFC
28- }
29-
30- private CATEGORY systemCategory = null ;
31- private String customCategory ;
32- private String customDescription ;
33-
34- public static final CategoryDefinition NO_CATEGORY = new CategoryDefinition (CATEGORY .NO_CATEGORY );
13+ public static final CategoryDefinition ALL_CATEGORIES = new CategoryDefinition ("all" );
14+ private String categoryId ;
15+ private String humanReadableName ;
3516
3617 /**
3718 * Creates a new instance of the {@link CategoryDefinition} class
3819 *
39- * @param systemCategory The system -defined category
20+ * @param categoryId user -defined category ID
4021 */
41- public CategoryDefinition (CATEGORY systemCategory ) {
42- this (systemCategory , null );
22+ public CategoryDefinition (String categoryId ) {
23+ this (categoryId , null );
4324 }
4425
4526 /**
4627 * Creates a new instance of the {@link CategoryDefinition} class
4728 *
48- * @param systemCategory The system-defined category
49- * @param customCategory A user-defined category ID. This parameter may only be
50- * used if the system-defined category is set to
51- * NO_CATEGORY.
52- */
53- public CategoryDefinition (CATEGORY systemCategory , String customCategory ) {
54- this (systemCategory , customCategory , null );
55- }
56-
57- /**
58- * Creates a new instance of the {@link CategoryDefinition} class
59- *
60- * @param systemCategory The system-defined category
61- * @param customCategory A user-defined category ID. This parameter may only
62- * be used if the system-defined category is set to
63- * NO_CATEGORY.
64- * @param customDescription An optional description for the custom category
65- */
66- public CategoryDefinition (CATEGORY systemCategory , String customCategory , String customDescription ) {
67- this .systemCategory = systemCategory ;
68- this .customCategory = customCategory ;
69- this .customDescription = customDescription ;
70- }
71-
72- /**
73- * Gets the system-defined category name. If this value is NO_CATEGORY, there
74- * may be a user-defined custom category name.
75- *
76- * @return The system-defined category name
29+ * @param customCategoryId A user-defined category ID
30+ * @param humanReadableNmae An optional human-readable name
7731 */
78- public CATEGORY getSystemCategory () {
79- return systemCategory ;
80- }
81-
82- public void setSystemCategory (CATEGORY systemCategory ) {
83- this .systemCategory = systemCategory ;
32+ public CategoryDefinition (String customCategoryId , String humanReadableNmae ) {
33+ this .categoryId = customCategoryId ;
34+ this .humanReadableName = humanReadableNmae ;
8435 }
8536
8637 /**
87- * Gets the user-defined category name. User-defined categories must have a
88- * system category of NO_CATEGORY.
38+ * Gets the user-defined category id.
8939 *
90- * @return The user-defined category name
40+ * @return The user-defined category id
9141 */
92- public String getCustomCategory () {
93- return customCategory ;
42+ public String getCategoryId () {
43+ return categoryId ;
9444 }
9545
9646 /**
9747 * Sets the user-defined category id. This is an identifier for the system. To
9848 * define a human-readable category description, use the setCustomDescription()
9949 * instead.
10050 *
101- * @param customCategory The user-defined category id. Category identifiers must
51+ * @param id The user-defined category id. Category identifiers must
10252 * be unique.
10353 */
104- public void setCustomCategory (String customCategory ) {
105- this .customCategory = customCategory ;
106- }
107-
108- /**
109- * Gets the description of the user-defined category
110- *
111- * @return The description of the user-defined category
112- */
113- public String getCustomDescription () {
114- return customDescription ;
115- }
116-
117- /**
118- * Sets the description of the user-defined category
119- *
120- * @param customDescription The description of the user-defined category
121- */
122- public void setCustomDescription (String customDescription ) {
123- this .customDescription = customDescription ;
54+ public void setCategoryId (String id ) {
55+ this .categoryId = id ;
12456 }
12557
12658 @ Override
12759 public int hashCode () {
12860 final int prime = 31 ;
12961 int result = 1 ;
130- result = prime * result + ((customCategory == null ) ? 0 : customCategory .hashCode ());
131- result = prime * result + ((customDescription == null ) ? 0 : customDescription .hashCode ());
132- result = prime * result + ((systemCategory == null ) ? 0 : systemCategory .hashCode ());
62+ result = prime * result + ((categoryId == null ) ? 0 : categoryId .hashCode ());
63+ result = prime * result + ((humanReadableName == null ) ? 0 : humanReadableName .hashCode ());
13364 return result ;
13465 }
13566
@@ -142,31 +73,22 @@ public boolean equals(Object obj) {
14273 if (getClass () != obj .getClass ())
14374 return false ;
14475 CategoryDefinition other = (CategoryDefinition ) obj ;
145- if (customCategory == null ) {
146- if (other .customCategory != null )
76+ if (categoryId == null ) {
77+ if (other .categoryId != null )
14778 return false ;
148- } else if (!customCategory .equals (other .customCategory ))
79+ } else if (!categoryId .equals (other .categoryId ))
14980 return false ;
150- if (customDescription == null ) {
151- if (other .customDescription != null )
81+ if (humanReadableName == null ) {
82+ if (other .humanReadableName != null )
15283 return false ;
153- } else if (!customDescription .equals (other .customDescription ))
154- return false ;
155- if (systemCategory != other .systemCategory )
84+ } else if (!humanReadableName .equals (other .humanReadableName ))
15685 return false ;
15786 return true ;
15887 }
15988
16089 @ Override
16190 public String toString () {
162- if (customCategory == null || customCategory .isEmpty ()) {
163- if (systemCategory != null )
164- return systemCategory .toString ();
165- else
166- return "<invalid>" ;
167- } else {
168- return customCategory ;
169- }
91+ return categoryId ;
17092 }
17193
17294 /**
@@ -179,86 +101,7 @@ public String toString() {
179101 */
180102 @ Override
181103 public String getHumanReadableDescription () {
182- if (customCategory != null && !customCategory .isEmpty ()) {
183- // Prefer the description text over the id
184- if (customDescription != null && !customDescription .isEmpty ())
185- return customDescription ;
186- return customCategory ;
187- } else if (systemCategory != null ) {
188- switch (systemCategory ) {
189- case ALL :
190- return "All Categories" ;
191- case NO_CATEGORY :
192- return "No Category" ;
193- case HARDWARE_INFO :
194- return "Hardware Information" ;
195- case UNIQUE_IDENTIFIER :
196- return "Unique Identifier" ;
197- case LOCATION_INFORMATION :
198- return "Location Information" ;
199- case NETWORK_INFORMATION :
200- return "Network Information" ;
201- case ACCOUNT_INFORMATION :
202- return "Account Information" ;
203- case EMAIL_INFORMATION :
204- return "E-Mail Information" ;
205- case FILE_INFORMATION :
206- return "File Information" ;
207- case BLUETOOTH_INFORMATION :
208- return "Bluetooth Information" ;
209- case VOIP_INFORMATION :
210- return "Voice-over-IP Information" ;
211- case DATABASE_INFORMATION :
212- return "Database Information" ;
213- case PHONE_INFORMATION :
214- return "Phone Information" ;
215- case PHONE_CONNECTION :
216- return "Phone (Line) Connection" ;
217- case INTER_APP_COMMUNICATION :
218- return "Inter-App Communication" ;
219- case VOIP :
220- return "Voice-over-IP" ;
221- case PHONE_STATE :
222- return "Phone State" ;
223- case EMAIL :
224- return "E-Mail" ;
225- case BLUETOOTH :
226- return "Bluetooth" ;
227- case ACCOUNT_SETTINGS :
228- return "Account Settings" ;
229- case VIDEO :
230- return "Video" ;
231- case SYNCHRONIZATION_DATA :
232- return "Synchronization Data" ;
233- case NETWORK :
234- return "Network" ;
235- case EMAIL_SETTINGS :
236- return "E-Mail Settings" ;
237- case FILE :
238- return "File" ;
239- case LOG :
240- return "Log Files" ;
241- case AUDIO :
242- return "Audio" ;
243- case SMS_MMS :
244- return "SMS / MMS" ;
245- case CONTACT_INFORMATION :
246- return "Contact Information" ;
247- case CALENDAR_INFORMATION :
248- return "Calendar Information" ;
249- case SYSTEM_SETTINGS :
250- return "System Settings" ;
251- case IMAGE :
252- return "Image" ;
253- case BROWSER_INFORMATION :
254- return "Browser Information" ;
255- case NFC :
256- return "NFC" ;
257- default :
258- return "<invalid system category>" ;
259- }
260- } else
261- return "<invalid>" ;
104+ return humanReadableName ;
262105 }
263106
264107 /**
@@ -270,14 +113,12 @@ public String getHumanReadableDescription() {
270113 * but not, e.g., descriptions
271114 */
272115 public CategoryDefinition getIdOnlyDescription () {
273- return new CategoryDefinition (systemCategory , customCategory );
116+ return new CategoryDefinition (categoryId );
274117 }
275118
276119 @ Override
277120 public String getID () {
278- if (systemCategory == null || systemCategory == CATEGORY .NO_CATEGORY )
279- return customCategory ;
280- return systemCategory .name ();
121+ return categoryId ;
281122 }
282123
283124}
0 commit comments