JAL-2871 added inputstream constructor to Configuration
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 4 Jan 2018 02:47:58 +0000 (02:47 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 4 Jan 2018 12:00:26 +0000 (12:00 +0000)
forester/java/src/org/forester/archaeopteryx/Configuration.java

index 3db44f7..6797874 100644 (file)
@@ -33,6 +33,7 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.Arrays;
@@ -276,7 +277,23 @@ public final class Configuration {
     public Configuration() {
         this( null, false, false, false );
     }
-
+    public Configuration(final InputStream is, final boolean is_applet, final boolean verbose) {
+        setDisplayColors( new TreeMap<String, Color>() );
+        try {
+            InputStreamReader isr = new InputStreamReader(is);
+            final BufferedReader bf = new BufferedReader( isr );
+            readConfig( bf );
+            bf.close();
+            ForesterUtil.programMessage( AptxConstants.PRG_NAME, "successfully read from configuration url ["
+                    + config_filename + "]" );
+            _could_read_config_file = true;
+        }
+        catch ( final Exception e ) {
+            ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "failed to read configuration from ["
+                    + config_filename + "]: " + e.getLocalizedMessage() );
+        }
+    }
     public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
         if ( ForesterUtil.isEmpty( cf ) ) {
             config_filename = default_config_filename;