@@ -21,6 +21,7 @@ public class Library {
2121 private String sentence ;
2222 private String paragraph ;
2323 private String url ;
24+ private String category ;
2425 private List <String > architectures ;
2526 private File folder ;
2627 private File srcFolder ;
@@ -31,6 +32,11 @@ public class Library {
3132 .asList (new String [] { "name" , "version" , "author" , "maintainer" ,
3233 "sentence" , "paragraph" , "url" });
3334
35+ private static final List <String > CATEGORIES = Arrays .asList (new String [] {
36+ "Display" , "Communication" , "Signal Input/Output" , "Sensors" ,
37+ "Device Control" , "Timing" , "Data Storage" , "Data Processing" , "Other" ,
38+ "Uncategorized" });
39+
3440 /**
3541 * Scans inside a folder and create a Library object out of it. Automatically
3642 * detects legacy libraries. Automatically fills metadata from
@@ -113,6 +119,12 @@ private static Library createLibrary(File libFolder) throws IOException {
113119 for (String arch : architectures .split ("," ))
114120 archs .add (arch .trim ());
115121
122+ String category = properties .get ("category" );
123+ if (category == null )
124+ category = "Uncategorized" ;
125+ if (!CATEGORIES .contains (category ))
126+ category = "Uncategorized" ;
127+
116128 Library res = new Library ();
117129 res .folder = libFolder ;
118130 res .srcFolder = srcFolder ;
@@ -123,6 +135,7 @@ private static Library createLibrary(File libFolder) throws IOException {
123135 res .sentence = properties .get ("sentence" ).trim ();
124136 res .paragraph = properties .get ("paragraph" ).trim ();
125137 res .url = properties .get ("url" ).trim ();
138+ res .category = category .trim ();
126139 res .architectures = archs ;
127140 res .useRecursion = useRecursion ;
128141 res .isLegacy = false ;
@@ -183,6 +196,14 @@ public String getUrl() {
183196 return url ;
184197 }
185198
199+ public String getCategory () {
200+ return category ;
201+ }
202+
203+ public static List <String > getCategories () {
204+ return CATEGORIES ;
205+ }
206+
186207 public String getVersion () {
187208 return version ;
188209 }
0 commit comments