Version 1.0.0
[fanfix.git] / src / be / nikiroo / fanfix / Library.java
index 15b81e44db7aca3caf8869f8f0b53539e1ddb8aa..0d9e067f30dcb6c24fe2e3a1e48fa098464f04e9 100644 (file)
@@ -52,6 +52,23 @@ public class Library {
                dir.mkdirs();
        }
 
+       /**
+        * List all the known types of stories.
+        * 
+        * @return the types
+        */
+       public List<String> getTypes() {
+               List<String> list = new ArrayList<String>();
+               for (Entry<MetaData, File> entry : getStories().entrySet()) {
+                       String storyType = entry.getValue().getParentFile().getName();
+                       if (!list.contains(storyType)) {
+                               list.add(storyType);
+                       }
+               }
+
+               return list;
+       }
+
        /**
         * List all the stories of the given source type in the {@link Library}, or
         * all the stories if NULL is passed as a type.
@@ -61,13 +78,11 @@ public class Library {
         * 
         * @return the stories
         */
-       public List<MetaData> getList(SupportType type) {
-               String typeString = type == null ? null : type.getSourceName();
-
+       public List<MetaData> getList(String type) {
                List<MetaData> list = new ArrayList<MetaData>();
                for (Entry<MetaData, File> entry : getStories().entrySet()) {
                        String storyType = entry.getValue().getParentFile().getName();
-                       if (typeString == null || typeString.equalsIgnoreCase(storyType)) {
+                       if (type == null || type.equalsIgnoreCase(storyType)) {
                                list.add(entry.getKey());
                        }
                }
@@ -121,7 +136,7 @@ public class Library {
         * @param luid
         *            the Library UID of the story
         * 
-        * @return the corresponding {@link Story}
+        * @return the corresponding {@link Story} or NULL if not found
         */
        public Story getStory(String luid) {
                if (luid != null) {
@@ -231,7 +246,7 @@ public class Library {
         * @throws IOException
         *             in case of I/O error
         */
-       private Story save(Story story, String luid) throws IOException {
+       public Story save(Story story, String luid) throws IOException {
                // Do not change the original metadata, but change the original story
                MetaData key = story.getMeta().clone();
                story.setMeta(key);