Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Options

  • Loading branch information...
commit 81e69cb697ed5bf0e4b486ff89aeb73522c1a7ce 1 parent db8ef21
@kawasima authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/main/java/net/unit8/sastruts/routing/Options.java
View
37 src/main/java/net/unit8/sastruts/routing/Options.java
@@ -0,0 +1,37 @@
+package net.unit8.sastruts.routing;
+
+import java.util.HashMap;
+
+import org.seasar.framework.util.IntegerConversionUtil;
+import org.seasar.framework.util.NumberConversionUtil;
+import org.seasar.framework.util.StringUtil;
+
+public class Options extends HashMap<String, Object>{
+ private static final long serialVersionUID = 1L;
+
+ public Options(Options options) {
+ super(options);
+ }
+ public String getString(String key) {
+ Object value = this.get(key);
+ return value == null ? null : value.toString();
+ }
+ public Options except(String...keys) {
+ Options copy = new Options(this);
+ for (String key : keys) {
+ copy.remove(key);
+ }
+ return copy;
+ }
+ public boolean getBoolean(String key) {
+ Object value = this.get(key);
+ if (value != null && (
+ (value instanceof Boolean && (Boolean)value) ||
+ (value instanceof Number && IntegerConversionUtil.toPrimitiveInt(value) == 1) ||
+ StringUtil.equals(value.toString(), "true")
+ )) {
+ return true;
+ }
+ return false;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.