Add method to get a string with default value.
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / fcp / AbstractCommand.java
index b73fb1d..515697d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - AbstractCommand.java - Copyright © 2011–2012 David Roden
+ * Sone - AbstractCommand.java - Copyright © 2011–2013 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,6 +52,14 @@ public abstract class AbstractCommand implements Command {
                }
        }
 
+       protected static String getString(SimpleFieldSet simpleFieldSet, String key, String defaultValue) {
+               try {
+                       return simpleFieldSet.getString(key);
+               } catch (FSParseException fspe1) {
+                       return defaultValue;
+               }
+       }
+
        /**
         * Returns an int value from the given simple field set.
         *