ソースを参照

Merge branch 'master' into jfinal-java8

James 8 年 前
コミット
dfc6cbc2e3

+ 3 - 0
src/main/java/com/jfinal/plugin/activerecord/generator/TypeMapping.java

@@ -72,6 +72,9 @@ public class TypeMapping {
 		
 		// unsigned bigint
 		put("java.math.BigInteger", "java.math.BigInteger");
+		
+		// short
+		put("java.lang.Short", "java.lang.Short");
 	}};
 	
 	public String getType(String typeString) {

+ 4 - 7
src/main/java/com/jfinal/template/expr/ast/Arith.java

@@ -26,22 +26,17 @@ import com.jfinal.template.stat.Scope;
 
 /**
  * Arithmetic
- * 1:支持 int long float double BigDecimal 的 + - * / % 运算
+ * 1:支持 byte short int long float double BigDecimal 的 + - * / % 运算
  * 2:支持字符串加法运算
  */
 public class Arith extends Expr {
 	
-	public static final int INT = 0;
+	public static final int INT = 0;	// byte、short 用 int 类型支持,java 表达式亦如此
 	public static final int LONG = 1;
 	public static final int FLOAT = 2;
 	public static final int DOUBLE = 3;
 	public static final int BIGDECIMAL = 4;
 	
-	// 后续版本考虑支持
-	// public static final int BYTE = 5;
-	// public static final int SHORT = 6;
-	// public static final int BIGINTEGER = 7;
-	
 	private Sym op;
 	private Expr left;
 	private Expr right;
@@ -136,6 +131,8 @@ public class Arith extends Expr {
 			return DOUBLE;
 		} else if (obj instanceof BigDecimal) {
 			return BIGDECIMAL;
+		} else if (obj instanceof Short || obj instanceof Byte) {
+			return INT;	// short byte 用 int 支持,java 表达式亦如此
 		}
 		throw new TemplateException("Unsupported data type: " + obj.getClass().getName(), location);
 	}

+ 3 - 1
src/main/java/com/jfinal/template/expr/ast/Compare.java

@@ -26,7 +26,7 @@ import com.jfinal.template.stat.Scope;
 /**
  * Compare
  * 
- * 1:支持 int long float double BigDecimal 的 == != > >= < <= 操作
+ * 1:支持 byte short int long float double BigDecimal 的 == != > >= < <= 操作
  * 2:== != 作用于 string,调用其 equals 方法进行比较
  * 3:> >= < <= 可以比较实现了 Comparable 接口的对象
  * 
@@ -247,6 +247,8 @@ public class Compare extends Expr {
 			return Arith.DOUBLE;
 		} else if (obj instanceof BigDecimal) {
 			return Arith.BIGDECIMAL;
+		} else if (obj instanceof Short || obj instanceof Byte) {
+			return Arith.INT;	// short byte 用 int 支持,java 表达式亦如此
 		}
 		throw new TemplateException("Unsupported data type: " + obj.getClass().getName(), location);
 	}

+ 2 - 2
src/main/java/com/jfinal/token/TokenManager.java

@@ -103,7 +103,7 @@ public class TokenManager {
 	 * @param tokenName the token name used in view's form
 	 * @return true if token is correct
 	 */
-	public static synchronized boolean validateToken(Controller controller, String tokenName) {
+	public static boolean validateToken(Controller controller, String tokenName) {
 		String clientTokenId = controller.getPara(tokenName);
 		if (tokenCache == null) {
 			String serverTokenId = controller.getSessionAttr(tokenName);
@@ -112,7 +112,7 @@ public class TokenManager {
 		}
 		else {
 			Token token = new Token(clientTokenId);
-			boolean result = tokenCache.contains(token); 
+			boolean result = tokenCache.contains(token);
 			tokenCache.remove(token);
 			return result;
 		}