enjoy 3.4
This commit is contained in:
@@ -32,7 +32,7 @@ import com.jfinal.template.stat.Scope;
|
||||
*/
|
||||
public class NowDirective extends Directive {
|
||||
|
||||
public void setExrpList(ExprList exprList) {
|
||||
public void setExprList(ExprList exprList) {
|
||||
if (exprList.length() > 1) {
|
||||
throw new ParseException("#now directive support one parameter only", location);
|
||||
}
|
||||
|
@@ -16,22 +16,29 @@
|
||||
|
||||
package com.jfinal.template.ext.directive;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.jfinal.template.Directive;
|
||||
import com.jfinal.template.Env;
|
||||
import com.jfinal.template.TemplateException;
|
||||
import com.jfinal.template.io.Writer;
|
||||
import com.jfinal.template.stat.Scope;
|
||||
|
||||
/**
|
||||
* 输出随机数
|
||||
* 输出 int 型随机数
|
||||
*/
|
||||
public class RandomDirective extends Directive {
|
||||
|
||||
private java.util.Random random = new java.util.Random();
|
||||
|
||||
public void exec(Env env, Scope scope, Writer writer) {
|
||||
write(writer, String.valueOf(random.nextInt()));
|
||||
try {
|
||||
writer.write(random.nextInt());
|
||||
} catch (IOException e) {
|
||||
throw new TemplateException(e.getMessage(), location, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -43,6 +43,14 @@ public class ByteExt {
|
||||
public Double toDouble(Byte self) {
|
||||
return self.doubleValue();
|
||||
}
|
||||
|
||||
public Short toShort(Byte self) {
|
||||
return self.shortValue();
|
||||
}
|
||||
|
||||
public Byte toByte(Byte self) {
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,6 +43,14 @@ public class DoubleExt {
|
||||
public Double toDouble(Double self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
public Short toShort(Double self) {
|
||||
return self.shortValue();
|
||||
}
|
||||
|
||||
public Byte toByte(Double self) {
|
||||
return self.byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,6 +43,14 @@ public class FloatExt {
|
||||
public Double toDouble(Float self) {
|
||||
return self.doubleValue();
|
||||
}
|
||||
|
||||
public Short toShort(Float self) {
|
||||
return self.shortValue();
|
||||
}
|
||||
|
||||
public Byte toByte(Float self) {
|
||||
return self.byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -63,6 +63,14 @@ public class IntegerExt {
|
||||
public Double toDouble(Integer self) {
|
||||
return self.doubleValue();
|
||||
}
|
||||
|
||||
public Short toShort(Integer self) {
|
||||
return self.shortValue();
|
||||
}
|
||||
|
||||
public Byte toByte(Integer self) {
|
||||
return self.byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,6 +43,14 @@ public class LongExt {
|
||||
public Double toDouble(Long self) {
|
||||
return self.doubleValue();
|
||||
}
|
||||
|
||||
public Short toShort(Long self) {
|
||||
return self.shortValue();
|
||||
}
|
||||
|
||||
public Byte toByte(Long self) {
|
||||
return self.byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,6 +43,14 @@ public class ShortExt {
|
||||
public Double toDouble(Short self) {
|
||||
return self.doubleValue();
|
||||
}
|
||||
|
||||
public Short toShort(Short self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
public Byte toByte(Short self) {
|
||||
return self.byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -79,6 +79,14 @@ public class StringExt {
|
||||
public Double toDouble(String self) {
|
||||
return StrKit.isBlank(self) ? null : Double.parseDouble(self);
|
||||
}
|
||||
|
||||
public Short toShort(String self) {
|
||||
return StrKit.isBlank(self) ? null : Short.parseShort(self);
|
||||
}
|
||||
|
||||
public Byte toByte(String self) {
|
||||
return StrKit.isBlank(self) ? null : Byte.parseByte(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -59,101 +59,105 @@ public class JFinalView extends AbstractTemplateView {
|
||||
OutputStream os = response.getOutputStream();
|
||||
JFinalViewResolver.engine.getTemplate(getUrl()).render(model, os);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
|
||||
class InnerSession extends HashMap<Object, Object> implements HttpSession {
|
||||
|
||||
private static final long serialVersionUID = -8679493647540628009L;
|
||||
private HttpSession session;
|
||||
|
||||
public InnerSession(HttpSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
// HashMap 相关方法处理 ----------------------------------------------------
|
||||
/**
|
||||
* 覆盖 HashMap 的 put
|
||||
*/
|
||||
public Object put(Object name, Object value) {
|
||||
session.setAttribute((String)name, value);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖 HashMap 的 get
|
||||
*/
|
||||
public Object get(Object name) {
|
||||
return session.getAttribute((String)name);
|
||||
}
|
||||
|
||||
// Session 相关方法处理 ----------------------------------------------------
|
||||
public Object getAttribute(String key) {
|
||||
return session.getAttribute(key);
|
||||
}
|
||||
|
||||
public Enumeration getAttributeNames() {
|
||||
return session.getAttributeNames();
|
||||
}
|
||||
|
||||
public long getCreationTime() {
|
||||
return session.getCreationTime();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return session.getId();
|
||||
}
|
||||
|
||||
public long getLastAccessedTime() {
|
||||
return session.getLastAccessedTime();
|
||||
}
|
||||
|
||||
public int getMaxInactiveInterval() {
|
||||
return session.getMaxInactiveInterval();
|
||||
}
|
||||
|
||||
public ServletContext getServletContext() {
|
||||
return session.getServletContext();
|
||||
}
|
||||
|
||||
public javax.servlet.http.HttpSessionContext getSessionContext() {
|
||||
return session.getSessionContext();
|
||||
}
|
||||
|
||||
public Object getValue(String key) {
|
||||
return session.getValue(key);
|
||||
}
|
||||
|
||||
public String[] getValueNames() {
|
||||
return session.getValueNames();
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
session.invalidate();
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return session.isNew();
|
||||
}
|
||||
|
||||
public void putValue(String key, Object value) {
|
||||
session.putValue(key, value);
|
||||
}
|
||||
|
||||
public void removeAttribute(String key) {
|
||||
session.removeAttribute(key);
|
||||
}
|
||||
|
||||
public void removeValue(String key) {
|
||||
session.removeValue(key);
|
||||
}
|
||||
|
||||
public void setAttribute(String key, Object value) {
|
||||
session.setAttribute(key, value);
|
||||
}
|
||||
|
||||
public void setMaxInactiveInterval(int maxInactiveInterval) {
|
||||
session.setMaxInactiveInterval(maxInactiveInterval);
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
|
||||
public static class InnerSession extends HashMap<Object, Object> implements HttpSession {
|
||||
|
||||
private static final long serialVersionUID = -8679493647540628009L;
|
||||
private HttpSession session;
|
||||
|
||||
public InnerSession(HttpSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
// HashMap 相关方法处理 ----------------------------------------------------
|
||||
/**
|
||||
* 覆盖 HashMap 的 put
|
||||
*/
|
||||
public Object put(Object name, Object value) {
|
||||
session.setAttribute((String)name, value);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖 HashMap 的 get
|
||||
*/
|
||||
public Object get(Object name) {
|
||||
return session.getAttribute((String)name);
|
||||
}
|
||||
|
||||
// Session 相关方法处理 ----------------------------------------------------
|
||||
public Object getAttribute(String key) {
|
||||
return session.getAttribute(key);
|
||||
}
|
||||
|
||||
public Enumeration getAttributeNames() {
|
||||
return session.getAttributeNames();
|
||||
}
|
||||
|
||||
public long getCreationTime() {
|
||||
return session.getCreationTime();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return session.getId();
|
||||
}
|
||||
|
||||
public long getLastAccessedTime() {
|
||||
return session.getLastAccessedTime();
|
||||
}
|
||||
|
||||
public int getMaxInactiveInterval() {
|
||||
return session.getMaxInactiveInterval();
|
||||
}
|
||||
|
||||
public ServletContext getServletContext() {
|
||||
return session.getServletContext();
|
||||
}
|
||||
|
||||
public javax.servlet.http.HttpSessionContext getSessionContext() {
|
||||
return session.getSessionContext();
|
||||
}
|
||||
|
||||
public Object getValue(String key) {
|
||||
return session.getValue(key);
|
||||
}
|
||||
|
||||
public String[] getValueNames() {
|
||||
return session.getValueNames();
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
session.invalidate();
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return session.isNew();
|
||||
}
|
||||
|
||||
public void putValue(String key, Object value) {
|
||||
session.putValue(key, value);
|
||||
}
|
||||
|
||||
public void removeAttribute(String key) {
|
||||
session.removeAttribute(key);
|
||||
}
|
||||
|
||||
public void removeValue(String key) {
|
||||
session.removeValue(key);
|
||||
}
|
||||
|
||||
public void setAttribute(String key, Object value) {
|
||||
session.setAttribute(key, value);
|
||||
}
|
||||
|
||||
public void setMaxInactiveInterval(int maxInactiveInterval) {
|
||||
session.setMaxInactiveInterval(maxInactiveInterval);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return session != null ? session.toString() : "null";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,4 +166,3 @@ class InnerSession extends HashMap<Object, Object> implements HttpSession {
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user