X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Ffcp%2FAbstractCommand.java;h=34759106163567db19c6159e7480a47ebf2d6aea;hb=82ad9f2d7d1731ddcaef241ad94db3a38c92b718;hp=8c155e58a7b1d4a153d22a82012aacb367c55b3f;hpb=9c742021ffb2667e7dc90c7fbf94f97d57e6ac5a;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java index 8c155e5..3475910 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java +++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java @@ -52,4 +52,24 @@ public abstract class AbstractCommand implements Command { } } + /** + * Returns an int value from the given simple field set. + * + * @param simpleFieldSet + * The simple field set to get the value from + * @param key + * The key of the value + * @return The int value + * @throws FcpException + * if there is no value for the given key in the simple field + * set, or the value can not be converted to an int + */ + protected int getInt(SimpleFieldSet simpleFieldSet, String key) throws FcpException { + try { + return simpleFieldSet.getInt(key); + } catch (FSParseException fspe1) { + throw new FcpException("Could not get parameter “" + key + "” as int.", fspe1); + } + } + }