You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/06/28 12:12:19 UTC
[2/4] incubator-guacamole-client git commit: GUACAMOLE-320: Add
parse() convenience function for TextField which interprets empty strings as
equivalent to null.
GUACAMOLE-320: Add parse() convenience function for TextField which interprets empty strings as equivalent to null.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/ed066c88
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/ed066c88
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/ed066c88
Branch: refs/heads/master
Commit: ed066c88e7b4b544ff3f597cd597aca2a76cf9cd
Parents: 04c70c7
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Jun 27 15:58:59 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Jun 27 16:31:29 2017 -0700
----------------------------------------------------------------------
.../org/apache/guacamole/form/TextField.java | 21 ++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/ed066c88/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java b/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java
index 0880771..2751e14 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java
@@ -35,4 +35,25 @@ public class TextField extends Field {
super(name, Field.Type.TEXT);
}
+ /**
+ * Parses the given string, interpreting empty strings as equivalent to
+ * null. For all other cases, the given string is returned verbatim.
+ *
+ * @param str
+ * The string to parse, which may be null.
+ *
+ * @return
+ * The given string, or null if the given string was null or empty.
+ */
+ public static String parse(String str) {
+
+ // Return null if no value provided
+ if (str == null || str.isEmpty())
+ return null;
+
+ // Otherwise, return string unmodified
+ return str;
+
+ }
+
}