projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move parsing of boolean options into its own method.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
freenet
/
fcp
/
AbstractCommand.java
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
538876a
..
515697d
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - AbstractCommand.java - Copyright © 2011 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
*
* 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
@@
-44,7
+44,7
@@
public abstract class AbstractCommand implements Command {
* if there is no value for the given key in the simple field
* set, or the value can not be converted to a String
*/
* if there is no value for the given key in the simple field
* set, or the value can not be converted to a String
*/
- protected String getString(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
+ protected
static
String getString(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
try {
return simpleFieldSet.getString(key);
} catch (FSParseException fspe1) {
try {
return simpleFieldSet.getString(key);
} catch (FSParseException fspe1) {
@@
-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.
*
/**
* Returns an int value from the given simple field set.
*
@@
-64,7
+72,7
@@
public abstract class AbstractCommand implements Command {
* if there is no value for the given key in the simple field
* set, or the value can not be converted to an int
*/
* 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 {
+ protected
static
int getInt(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
try {
return simpleFieldSet.getInt(key);
} catch (FSParseException fspe1) {
try {
return simpleFieldSet.getInt(key);
} catch (FSParseException fspe1) {
@@
-84,7
+92,7
@@
public abstract class AbstractCommand implements Command {
* The default value
* @return The int value
*/
* The default value
* @return The int value
*/
- protected int getInt(SimpleFieldSet simpleFieldSet, String key, int defaultValue) {
+ protected
static
int getInt(SimpleFieldSet simpleFieldSet, String key, int defaultValue) {
return simpleFieldSet.getInt(key, defaultValue);
}
return simpleFieldSet.getInt(key, defaultValue);
}
@@
-100,7
+108,7
@@
public abstract class AbstractCommand implements Command {
* if there is no value for the given key in the simple field
* set, or the value can not be converted to a boolean
*/
* if there is no value for the given key in the simple field
* set, or the value can not be converted to a boolean
*/
- protected boolean getBoolean(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
+ protected
static
boolean getBoolean(SimpleFieldSet simpleFieldSet, String key) throws FcpException {
try {
return simpleFieldSet.getBoolean(key);
} catch (FSParseException fspe1) {
try {
return simpleFieldSet.getBoolean(key);
} catch (FSParseException fspe1) {
@@
-120,7
+128,7
@@
public abstract class AbstractCommand implements Command {
* The default value
* @return The boolean value
*/
* The default value
* @return The boolean value
*/
- protected boolean getBoolean(SimpleFieldSet simpleFieldSet, String key, boolean defaultValue) {
+ protected
static
boolean getBoolean(SimpleFieldSet simpleFieldSet, String key, boolean defaultValue) {
return simpleFieldSet.getBoolean(key, defaultValue);
}
return simpleFieldSet.getBoolean(key, defaultValue);
}