Add method to delegate Sone parsing.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 25 Oct 2010 20:42:28 +0000 (22:42 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 25 Oct 2010 20:42:28 +0000 (22:42 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java

index 4fe969d..e0f2649 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.core;
 
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -438,6 +439,26 @@ public class Core extends AbstractService {
        }
 
        /**
+        * Loads a Sone from an input stream.
+        *
+        * @param soneInputStream
+        *            The input stream to load the Sone from
+        * @return The parsed Sone, or {@code null} if the Sone could not be parsed
+        */
+       public Sone loadSone(InputStream soneInputStream) {
+               Sone parsedSone = soneDownloader.parseSone(soneInputStream);
+               if (parsedSone == null) {
+                       return null;
+               }
+               if (parsedSone.getInsertUri() != null) {
+                       addLocalSone(parsedSone);
+               } else {
+                       addSone(parsedSone);
+               }
+               return parsedSone;
+       }
+
+       /**
         * Loads and updates the given Sone.
         *
         * @param sone