Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1aef12eb94 | ||
|
6f615bc1a8 | ||
|
0c3e7790b7 | ||
|
a1e88a4a4c | ||
|
d12d3d8abb | ||
|
ef7b0da917 | ||
|
2ed806c296 | ||
|
998df7b907 | ||
|
3e93fc970e | ||
|
010a7f3d8a | ||
|
99f024f546 | ||
|
ca3361703e | ||
|
1840d49e0a | ||
|
70d1e5a9eb | ||
|
e0abc218b1 | ||
|
bd1949fc56 |
3
LICENSE
3
LICENSE
@@ -188,4 +188,5 @@ third-party archives.
|
|||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
|
85
README.md
85
README.md
@@ -1,42 +1,43 @@
|
|||||||
### Enjoy
|
### Enjoy
|
||||||
|
|
||||||
Enjoy 是基于 Java 语言的极轻量极魔板引擎。极轻量级仅 171K 并且不依赖任何第三方。极简设计仅 if、for、set、define、include、render 六个核心指令,让学习成本低到极致。独创 DKFF(Dynamic Key Feature Forward) 词法分析算法与 DLRD (Double Layer Recursive Descent)语法分析算法,避免使用 javacc、antlr、jflex 生成器,令代码量少到极致。
|
Enjoy 是基于 Java 语言的极轻量极魔板引擎。极轻量级仅 171K 并且不依赖任何第三方。极简设计仅 if、for、set、define、include、render 六个核心指令,让学习成本低到极致。独创 DKFF(Dynamic Key Feature Forward) 词法分析算法与 DLRD (Double Layer Recursive Descent)语法分析算法,避免使用 javacc、antlr、jflex 生成器,令代码量少到极致。
|
||||||
|
|
||||||
#### Enjoy 主要特点
|
#### Enjoy 主要特点
|
||||||
- 消灭传统模板引擎中大量繁杂概念,仅六个核心指令,学习成本极低
|
- 消灭传统模板引擎中大量繁杂概念,仅六个核心指令,学习成本极低
|
||||||
- 独创 DKFF 词法分析算法与 DLRD 语法分析算法,避免使用javacc、antlr
|
- 独创 DKFF 词法分析算法与 DLRD 语法分析算法,避免使用javacc、antlr
|
||||||
- 功能强大,极为简单覆盖掉 freemarker、velocity 的核心功能
|
- 功能强大,极为简单覆盖掉 freemarker、velocity 的核心功能
|
||||||
- 扩展性强,支持多种扩展方式,且是唯一支持指令级扩展的模板引擎
|
- 扩展性强,支持多种扩展方式,且是唯一支持指令级扩展的模板引擎
|
||||||
- 与 java 打通式设计,在模板中与 java 交互极为方便
|
- 与 java 打通式设计,在模板中与 java 交互极为方便
|
||||||
- 贴近 java 使用直觉,为 java 开发者量身打造
|
- 贴近 java 使用直觉,为 java 开发者量身打造
|
||||||
- 回归模板引擎渲染 View 数据的本质,采用指令式设计,避免 view 层表达复杂逻辑
|
- 回归模板引擎渲染 View 数据的本质,采用指令式设计,避免 view 层表达复杂逻辑
|
||||||
- 体积小,仅 171K,且不依赖于任何第三方
|
- 体积小,仅 171K,且不依赖于任何第三方
|
||||||
|
|
||||||
|
|
||||||
#### 简单示例:
|
#### 简单示例:
|
||||||
|
|
||||||
**1. 在 spring 中的配置**
|
**1. 在 spring 中的配置**
|
||||||
|
|
||||||
```java
|
```java
|
||||||
<bean id="viewResolver" class="com.jfinal.template.ext.spring.JFinalViewResolver">
|
<bean id="viewResolver" class="com.jfinal.template.ext.spring.JFinalViewResolver">
|
||||||
<!-- 是否热加载模板文件 -->
|
<!-- 是否热加载模板文件 -->
|
||||||
<property name="devMode" value="true" />
|
<property name="devMode" value="true" />
|
||||||
<!-- 配置shared function,多文件用逗号分隔 -->
|
<!-- 配置shared function,多文件用逗号分隔 -->
|
||||||
<property name="sharedFunction" value="/view/_layout.html, /view/_paginate.html" />
|
<property name="sharedFunction" value="/view/_layout.html, /view/_paginate.html" />
|
||||||
|
|
||||||
<!-- 是否支持以 #(session.value) 的方式访问 session -->
|
<!-- 是否支持以 #(session.value) 的方式访问 session -->
|
||||||
<property name="sessionInView" value="true" />
|
<property name="sessionInView" value="true" />
|
||||||
<property name="prefix" value="/view/" />
|
<property name="prefix" value="/view/" />
|
||||||
<property name="suffix" value=".html" />
|
<property name="suffix" value=".html" />
|
||||||
<property name="order" value="1" />
|
<property name="order" value="1" />
|
||||||
<property name="contentType" value="text/html; charset=utf-8" />
|
<property name="contentType" value="text/html; charset=utf-8" />
|
||||||
</bean>
|
</bean>
|
||||||
```
|
```
|
||||||
|
|
||||||
**2.详细使用方法见 jfinal 手册**
|
**2.详细使用方法见 jfinal 手册**
|
||||||
read me 正在补充,详细使用文档请下载 jfinal.com 官网的 jfinal 手册[http://www.jfinal.com](http://www.jfinal.com)
|
read me 正在补充,详细使用文档请下载 jfinal.com 官网的 jfinal 手册[http://www.jfinal.com](http://www.jfinal.com)
|
||||||
|
|
||||||
**JFinal 官方网站:[http://www.jfinal.com](http://www.jfinal.com)**
|
**JFinal 官方网站:[http://www.jfinal.com](http://www.jfinal.com)**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
260
pom.xml
260
pom.xml
@@ -1,130 +1,130 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.jfinal</groupId>
|
<groupId>com.jfinal</groupId>
|
||||||
<artifactId>enjoy</artifactId>
|
<artifactId>enjoy</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>enjoy</name>
|
<name>enjoy</name>
|
||||||
<version>3.3</version>
|
<version>3.4</version>
|
||||||
<url>http://www.jfinal.com</url>
|
<url>http://www.jfinal.com</url>
|
||||||
<description>Enjoy is a simple, light, rapid, independent, extensible Java Template Engine.</description>
|
<description>Enjoy is a simple, light, rapid, independent, extensible Java Template Engine.</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>Git Issue</system>
|
<system>Git Issue</system>
|
||||||
<url>http://git.oschina.net/jfinal/enjoy/issues</url>
|
<url>https://gitee.com/jfinal/enjoy/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>The Apache Software License, Version 2.0</name>
|
<name>The Apache Software License, Version 2.0</name>
|
||||||
<url>http://apache.org/licenses/LICENSE-2.0.txt</url>
|
<url>http://apache.org/licenses/LICENSE-2.0.txt</url>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>jfinal</id>
|
<id>jfinal</id>
|
||||||
<name>James</name>
|
<name>James</name>
|
||||||
<email>jfinal@126.com</email>
|
<email>jfinal@126.com</email>
|
||||||
<url>http://jfinal.com/user/1</url>
|
<url>http://jfinal.com/user/1</url>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@git.oschina.net:jfinal/enjoy.git</connection>
|
<connection>scm:git:git@gitee.com:jfinal/enjoy.git</connection>
|
||||||
<developerConnection>scm:git:git@git.oschina.net:jfinal/enjoy.git</developerConnection>
|
<developerConnection>scm:git:git@gitee.com:jfinal/enjoy.git</developerConnection>
|
||||||
<url>git@git.oschina.net:jfinal/enjoy.git</url>
|
<url>git@gitee.com:jfinal/enjoy.git</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
<artifactId>oss-parent</artifactId>
|
<artifactId>oss-parent</artifactId>
|
||||||
<version>7</version>
|
<version>7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.8.2</version>
|
<version>4.8.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<version>4.3.8.RELEASE</version>
|
<version>4.3.8.RELEASE</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>2.10.3</version>
|
<version>2.10.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- 解决 java8 发布到 maven 异常 -->
|
<!-- 解决 java8 发布到 maven 异常 -->
|
||||||
<additionalparam>-Xdoclint:none</additionalparam>
|
<additionalparam>-Xdoclint:none</additionalparam>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<outputDirectory>${basedir}</outputDirectory>
|
<outputDirectory>${basedir}</outputDirectory>
|
||||||
<reportOutputDirectory>${basedir}</reportOutputDirectory>
|
<reportOutputDirectory>${basedir}</reportOutputDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- 安装源码到本地仓库 -->
|
<!-- 安装源码到本地仓库 -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>2.1.2</version>
|
<version>2.1.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
<phase>verify</phase>
|
<phase>verify</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>jar-no-fork</goal>
|
<goal>jar-no-fork</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>sign-artifacts</id>
|
<id>sign-artifacts</id>
|
||||||
<phase>verify</phase>
|
<phase>verify</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>sign</goal>
|
<goal>sign</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>false</skip>
|
<skip>false</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -45,7 +45,7 @@ public class ElKit {
|
|||||||
engine.addDirective("eval", InnerEvalDirective.class);
|
engine.addDirective("eval", InnerEvalDirective.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Engine getEngine() {
|
public static Engine getEngine() {
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,7 @@ import java.util.Map;
|
|||||||
import com.jfinal.kit.HashKit;
|
import com.jfinal.kit.HashKit;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.template.expr.ast.MethodKit;
|
import com.jfinal.template.expr.ast.MethodKit;
|
||||||
|
import com.jfinal.template.source.ClassPathSourceFactory;
|
||||||
import com.jfinal.template.source.ISource;
|
import com.jfinal.template.source.ISource;
|
||||||
import com.jfinal.template.source.ISourceFactory;
|
import com.jfinal.template.source.ISourceFactory;
|
||||||
import com.jfinal.template.source.StringSource;
|
import com.jfinal.template.source.StringSource;
|
||||||
@@ -161,6 +162,13 @@ public class Engine {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get template by string content and do not cache the template
|
* Get template by string content and do not cache the template
|
||||||
|
*/
|
||||||
|
public Template getTemplateByString(String content) {
|
||||||
|
return getTemplateByString(content, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get template by string content
|
||||||
*
|
*
|
||||||
* 重要:StringSource 中的 key = HashKit.md5(content),也即 key
|
* 重要:StringSource 中的 key = HashKit.md5(content),也即 key
|
||||||
* 与 content 有紧密的对应关系,当 content 发生变化时 key 值也相应变化
|
* 与 content 有紧密的对应关系,当 content 发生变化时 key 值也相应变化
|
||||||
@@ -169,13 +177,7 @@ public class Engine {
|
|||||||
*
|
*
|
||||||
* 当 getTemplateByString(String, boolean) 中的 String 参数的
|
* 当 getTemplateByString(String, boolean) 中的 String 参数的
|
||||||
* 数量可控并且确定时,才可对其使用缓存
|
* 数量可控并且确定时,才可对其使用缓存
|
||||||
*/
|
*
|
||||||
public Template getTemplateByString(String content) {
|
|
||||||
return getTemplateByString(content, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get template by string content
|
|
||||||
* @param content 模板内容
|
* @param content 模板内容
|
||||||
* @param cache true 则缓存 Template,否则不缓存
|
* @param cache true 则缓存 Template,否则不缓存
|
||||||
*/
|
*/
|
||||||
@@ -426,6 +428,13 @@ public class Engine {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置为 ClassPathSourceFactory 的快捷方法
|
||||||
|
*/
|
||||||
|
public Engine setToClassPathSourceFactory() {
|
||||||
|
return setSourceFactory(new ClassPathSourceFactory());
|
||||||
|
}
|
||||||
|
|
||||||
public ISourceFactory getSourceFactory() {
|
public ISourceFactory getSourceFactory() {
|
||||||
return sourceFactory;
|
return sourceFactory;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.jfinal.template;
|
package com.jfinal.template;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -108,6 +112,32 @@ public class Template {
|
|||||||
return fsw.getBuffer();
|
return fsw.getBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染到 File 中去
|
||||||
|
* 适用于代码生成器类似应用场景
|
||||||
|
*/
|
||||||
|
public void render(Map<?, ?> data, File file) {
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
fos = new FileOutputStream(file);
|
||||||
|
render(data, fos);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
if (fos != null) {
|
||||||
|
try {fos.close();} catch (IOException e) {e.printStackTrace(System.err);}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染到 String fileName 参数所指定的文件中去
|
||||||
|
* 适用于代码生成器类似应用场景
|
||||||
|
*/
|
||||||
|
public void render(Map<?, ?> data, String fileName) {
|
||||||
|
render(data, new File(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
return env.isSourceListModified();
|
return env.isSourceListModified();
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -292,7 +292,7 @@ public class ExprParser {
|
|||||||
case ADD:
|
case ADD:
|
||||||
case SUB:
|
case SUB:
|
||||||
move();
|
move();
|
||||||
return new Unary(tok.sym, unary(), location);
|
return new Unary(tok.sym, unary(), location).toConstIfPossible();
|
||||||
case INC:
|
case INC:
|
||||||
case DEC:
|
case DEC:
|
||||||
move();
|
move();
|
||||||
@@ -468,21 +468,26 @@ public class ExprParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mapEntry : (ID | STR) ':' expr
|
* mapEntry : (ID | STR | INT | LONG | FLOAT | DOUBLE | TRUE | FALSE | NULL) ':' expr
|
||||||
|
* 设计目标为 map 定义与初始化,所以 ID 仅当成 STR 不进行求值
|
||||||
*/
|
*/
|
||||||
void buildMapEntry(LinkedHashMap<Object, Expr> map) {
|
void buildMapEntry(LinkedHashMap<Object, Expr> map) {
|
||||||
Tok tok = peek();
|
Expr keyExpr = expr();
|
||||||
if (tok.sym == Sym.ID || tok.sym == Sym.STR) {
|
Object key;
|
||||||
move();
|
if (keyExpr instanceof Id) {
|
||||||
match(Sym.COLON);
|
key = ((Id)keyExpr).getId();
|
||||||
Expr value = expr();
|
} else if (keyExpr instanceof Const) {
|
||||||
if (value == null) {
|
key = ((Const)keyExpr).getValue();
|
||||||
throw new ParseException("Expression error: the value on the right side of map entry can not be blank", location);
|
} else {
|
||||||
}
|
throw new ParseException("Expression error: the value of map key must be identifier, String, Boolean, null or Number", location);
|
||||||
map.put(tok.value(), value);
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
throw new ParseException("Expression error: the value of map key must be identifier or String", location);
|
|
||||||
|
match(Sym.COLON);
|
||||||
|
Expr value = expr();
|
||||||
|
if (value == null) {
|
||||||
|
throw new ParseException("Expression error: the value on the right side of map entry can not be blank", location);
|
||||||
|
}
|
||||||
|
map.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -528,12 +533,14 @@ public class ExprParser {
|
|||||||
move();
|
move();
|
||||||
return new Id(tok.value());
|
return new Id(tok.value());
|
||||||
case STR:
|
case STR:
|
||||||
|
move();
|
||||||
|
return new Const(tok.sym, tok.value());
|
||||||
case INT:
|
case INT:
|
||||||
case LONG:
|
case LONG:
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
move();
|
move();
|
||||||
return new Const(tok.sym, tok.value());
|
return new Const(tok.sym, ((NumTok)tok).getNumberValue());
|
||||||
case TRUE:
|
case TRUE:
|
||||||
move();
|
move();
|
||||||
return Const.TRUE;
|
return Const.TRUE;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,7 +43,7 @@ import com.jfinal.template.stat.ParseException;
|
|||||||
*/
|
*/
|
||||||
public class NumTok extends Tok {
|
public class NumTok extends Tok {
|
||||||
|
|
||||||
private Object value;
|
private Number value;
|
||||||
|
|
||||||
NumTok(Sym sym, String s, int radix, boolean isScientificNotation, Location location) {
|
NumTok(Sym sym, String s, int radix, boolean isScientificNotation, Location location) {
|
||||||
super(sym, location.getRow());
|
super(sym, location.getRow());
|
||||||
@@ -101,3 +101,8 @@ public class NumTok extends Tok {
|
|||||||
return sym.value() + " : " + value;
|
return sym.value() + " : " + value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,54 +20,25 @@ import com.jfinal.template.expr.Sym;
|
|||||||
import com.jfinal.template.stat.Scope;
|
import com.jfinal.template.stat.Scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STR INT LONG FLOAT DOUBLE true false null
|
* STR INT LONG FLOAT DOUBLE TRUE FALSE NULL
|
||||||
*/
|
*/
|
||||||
public class Const extends Expr {
|
public class Const extends Expr {
|
||||||
|
|
||||||
public static final Const TRUE = new Const(Boolean.TRUE, Sym.TRUE);
|
public static final Const TRUE = new Const(Sym.TRUE, Boolean.TRUE);
|
||||||
public static final Const FALSE = new Const(Boolean.FALSE, Sym.FALSE);
|
public static final Const FALSE = new Const(Sym.FALSE, Boolean.FALSE);
|
||||||
public static final Const NULL = new Const(null, Sym.NULL);
|
public static final Const NULL = new Const(Sym.NULL, null);
|
||||||
|
|
||||||
private Sym type;
|
private final Sym type;
|
||||||
private Object value;
|
private final Object value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造 TRUE FALSE NULL 常量,无需对 value 进行转换
|
* INT LONG FLOAT DOUBLE 常量已在 NumTok 中转换成了确切的类型,无需再次转换
|
||||||
*/
|
*/
|
||||||
private Const(Object value, Sym type) {
|
public Const(Sym type, Object value) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Const(Sym type, String value) {
|
|
||||||
this.type = type;
|
|
||||||
this.value = typeConvert(type, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object typeConvert(Sym type, String value) {
|
|
||||||
switch (type) {
|
|
||||||
case STR:
|
|
||||||
return value;
|
|
||||||
case INT:
|
|
||||||
return Integer.parseInt(value);
|
|
||||||
case LONG:
|
|
||||||
return Long.parseLong(value);
|
|
||||||
case FLOAT:
|
|
||||||
return Float.parseFloat(value);
|
|
||||||
case DOUBLE:
|
|
||||||
return Double.parseDouble(value);
|
|
||||||
/*
|
|
||||||
case TRUE:
|
|
||||||
case FALSE:
|
|
||||||
return Boolean.parseBoolean(value);
|
|
||||||
case NULL:
|
|
||||||
return null;
|
|
||||||
*/
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("never happend");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object eval(Scope scope) {
|
public Object eval(Scope scope) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -108,6 +79,10 @@ public class Const extends Expr {
|
|||||||
return type == Sym.DOUBLE;
|
return type == Sym.DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNumber() {
|
||||||
|
return value instanceof Number;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -136,6 +111,10 @@ public class Const extends Expr {
|
|||||||
return (Double)value;
|
return (Double)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Number getNumber() {
|
||||||
|
return (Number)value;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return value != null ? value.toString() : "null";
|
return value != null ? value.toString() : "null";
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -113,9 +113,9 @@ public class Field extends Expr {
|
|||||||
|
|
||||||
if (expr instanceof Id) {
|
if (expr instanceof Id) {
|
||||||
String id = ((Id)expr).getId();
|
String id = ((Id)expr).getId();
|
||||||
throw new TemplateException("Field not found: \"" + id + "." + fieldName + "\" and getter method not found: \"" + id + "." + getterName + "()\"", location);
|
throw new TemplateException("public field not found: \"" + id + "." + fieldName + "\" and public getter method not found: \"" + id + "." + getterName + "()\"", location);
|
||||||
}
|
}
|
||||||
throw new TemplateException("Field not found: \"" + fieldName + "\" and getter method not found: \"" + getterName + "()\"", location);
|
throw new TemplateException("public field not found: \"" + fieldName + "\" and public getter method not found: \"" + getterName + "()\"", location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long buildFieldKey(Class<?> targetClass) {
|
private Long buildFieldKey(Class<?> targetClass) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,7 +23,7 @@ import com.jfinal.template.stat.Scope;
|
|||||||
*/
|
*/
|
||||||
public class Id extends Expr {
|
public class Id extends Expr {
|
||||||
|
|
||||||
private String id;
|
private final String id;
|
||||||
|
|
||||||
public Id(String id) {
|
public Id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,8 +43,8 @@ public class Index extends Expr {
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Object eval(Scope scope) {
|
public Object eval(Scope scope) {
|
||||||
Object array = expr.eval(scope);
|
Object target = expr.eval(scope);
|
||||||
if (array == null) {
|
if (target == null) {
|
||||||
if (scope.getCtrl().isNullSafe()) {
|
if (scope.getCtrl().isNullSafe()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -56,25 +56,30 @@ public class Index extends Expr {
|
|||||||
if (scope.getCtrl().isNullSafe()) {
|
if (scope.getCtrl().isNullSafe()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new TemplateException("The index of list/array and the key of map can not be null", location);
|
|
||||||
}
|
if (target instanceof java.util.Map) {
|
||||||
|
// Map 的 key 可以是 null,不能抛异常
|
||||||
if (array instanceof List) {
|
} else {
|
||||||
if (idx instanceof Integer) {
|
throw new TemplateException("The index of list and array can not be null", location);
|
||||||
return ((List<?>)array).get((Integer)idx);
|
|
||||||
}
|
}
|
||||||
throw new TemplateException("The index of list can only be integer", location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array instanceof java.util.Map) {
|
if (target instanceof List) {
|
||||||
return ((java.util.Map)array).get(idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array.getClass().isArray()) {
|
|
||||||
if (idx instanceof Integer) {
|
if (idx instanceof Integer) {
|
||||||
return java.lang.reflect.Array.get(array, (Integer)idx);
|
return ((List<?>)target).get((Integer)idx);
|
||||||
}
|
}
|
||||||
throw new TemplateException("The index of array can only be integer", location);
|
throw new TemplateException("The index of list must be integer", location);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target instanceof java.util.Map) {
|
||||||
|
return ((java.util.Map)target).get(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.getClass().isArray()) {
|
||||||
|
if (idx instanceof Integer) {
|
||||||
|
return java.lang.reflect.Array.get(target, (Integer)idx);
|
||||||
|
}
|
||||||
|
throw new TemplateException("The index of array must be integer", location);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new TemplateException("Only the list array and map is supported by index access", location);
|
throw new TemplateException("Only the list array and map is supported by index access", location);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,8 +24,10 @@ import com.jfinal.template.stat.Scope;
|
|||||||
* Map
|
* Map
|
||||||
*
|
*
|
||||||
* 1:定义 map 常量
|
* 1:定义 map 常量
|
||||||
* {k1:123, k2:"abc", 'k3':true, "k4":[1,2,3], k5:1+2}
|
* {k1:123, k2:"abc", 'k3':true, "k4":[1,2,3], k5:1+2, 1:12, true:"Y", null:"abc"}
|
||||||
* 如上所示,map定义的 key 可以为 String 或者 id 标识符,而右侧的 value 可以是任意的常量与表达式
|
* 如上所示,map定义的 key 可以为 id 标识符或者 String、Integer、Long、Boolean、null
|
||||||
|
* 等常量值 (详见 ExprParser.buildMapEntry(...) 方法),
|
||||||
|
* 右侧的 value 可以是任意的常量与表达式
|
||||||
*
|
*
|
||||||
* 2:取值
|
* 2:取值
|
||||||
* 先将 Map 常量赋值给某个变量: #set(map = {...})
|
* 先将 Map 常量赋值给某个变量: #set(map = {...})
|
||||||
@@ -34,6 +36,10 @@ import com.jfinal.template.stat.Scope;
|
|||||||
* map[expr]
|
* map[expr]
|
||||||
* map.get("k1")
|
* map.get("k1")
|
||||||
* map.k1
|
* map.k1
|
||||||
|
*
|
||||||
|
* 3:不通过中间变量取值
|
||||||
|
* {1:'自买', 2:'跟买'}.get(1)
|
||||||
|
* {1:'自买', 2:'跟买'}[2]
|
||||||
*
|
*
|
||||||
* 如上所示,当以下标方式取值时,下标参数可以是 string 与 expr,而 expr 求值以后的值必须也为 string类型
|
* 如上所示,当以下标方式取值时,下标参数可以是 string 与 expr,而 expr 求值以后的值必须也为 string类型
|
||||||
* 当用 map.k1 这类 field 字段取值形式时,则是使用 id 标识符,而不是 string 形参数
|
* 当用 map.k1 这类 field 字段取值形式时,则是使用 id 标识符,而不是 string 形参数
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -75,7 +75,7 @@ public class Method extends Expr {
|
|||||||
if (scope.getCtrl().isNullSafe()) {
|
if (scope.getCtrl().isNullSafe()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new TemplateException(buildMethodNotFoundSignature("Method not found: " + target.getClass().getName() + ".", methodName, argValues), location);
|
throw new TemplateException(buildMethodNotFoundSignature("public method not found: " + target.getClass().getName() + ".", methodName, argValues), location);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -87,6 +87,9 @@ public abstract class MethodKeyBuilder {
|
|||||||
if (type != null) {
|
if (type != null) {
|
||||||
hash ^= type.getName().hashCode();
|
hash ^= type.getName().hashCode();
|
||||||
hash *= HashKit.FNV_PRIME_64;
|
hash *= HashKit.FNV_PRIME_64;
|
||||||
|
} else {
|
||||||
|
hash ^= "null".hashCode();
|
||||||
|
hash *= HashKit.FNV_PRIME_64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,6 +113,8 @@ public abstract class MethodKeyBuilder {
|
|||||||
Class<?> type = argTypes[i];
|
Class<?> type = argTypes[i];
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
hash = fnv1a64(hash, type.getName());
|
hash = fnv1a64(hash, type.getName());
|
||||||
|
} else {
|
||||||
|
hash = fnv1a64(hash, "null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -156,6 +156,9 @@ public class SharedMethodKit {
|
|||||||
if (type != null) {
|
if (type != null) {
|
||||||
hash ^= type.getName().hashCode();
|
hash ^= type.getName().hashCode();
|
||||||
hash *= HashKit.FNV_PRIME_64;
|
hash *= HashKit.FNV_PRIME_64;
|
||||||
|
} else {
|
||||||
|
hash ^= "null".hashCode();
|
||||||
|
hash *= HashKit.FNV_PRIME_64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -83,6 +83,51 @@ public class Unary extends Expr {
|
|||||||
throw new TemplateException("Unsupported operator: " + op.value(), location);
|
throw new TemplateException("Unsupported operator: " + op.value(), location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果可能的话,将 Unary 表达式转化成 Const 表达式,类似于 ExprParser.buildMapEntry() 需要这种转化来简化实现
|
||||||
|
* 除了可简化程序外,还起到一定的性能优化作用
|
||||||
|
*
|
||||||
|
* Number : +123 -456 +3.14 -0.12
|
||||||
|
* Boolean : !true !false
|
||||||
|
*
|
||||||
|
* 特别注意:
|
||||||
|
* Boolean 的支持并不需要,!true、!false 已在 ExprParser 中被 Logic 表达式接管,在此仅为逻辑上的完备性而添加
|
||||||
|
*/
|
||||||
|
public Expr toConstIfPossible() {
|
||||||
|
if (expr instanceof Const && (op == Sym.SUB || op == Sym.ADD || op == Sym.NOT)) {
|
||||||
|
} else {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Expr ret = this;
|
||||||
|
Const c = (Const)expr;
|
||||||
|
if (op == Sym.SUB) {
|
||||||
|
if (c.isInt()) {
|
||||||
|
ret = new Const(Sym.INT, -c.getInt());
|
||||||
|
} else if (c.isLong()) {
|
||||||
|
ret = new Const(Sym.LONG, -c.getLong());
|
||||||
|
} else if (c.isFloat()) {
|
||||||
|
ret = new Const(Sym.FLOAT, -c.getFloat());
|
||||||
|
} else if (c.isDouble()) {
|
||||||
|
ret = new Const(Sym.DOUBLE, -c.getDouble());
|
||||||
|
}
|
||||||
|
} else if (op == Sym.ADD) {
|
||||||
|
if (c.isNumber()) {
|
||||||
|
ret = c;
|
||||||
|
}
|
||||||
|
} else if (op == Sym.NOT) {
|
||||||
|
if (c.isBoolean()) {
|
||||||
|
ret = c.isTrue() ? Const.FALSE : Const.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return op.toString() + expr.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,7 +32,7 @@ import com.jfinal.template.stat.Scope;
|
|||||||
*/
|
*/
|
||||||
public class NowDirective extends Directive {
|
public class NowDirective extends Directive {
|
||||||
|
|
||||||
public void setExrpList(ExprList exprList) {
|
public void setExprList(ExprList exprList) {
|
||||||
if (exprList.length() > 1) {
|
if (exprList.length() > 1) {
|
||||||
throw new ParseException("#now directive support one parameter only", location);
|
throw new ParseException("#now directive support one parameter only", location);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,22 +16,29 @@
|
|||||||
|
|
||||||
package com.jfinal.template.ext.directive;
|
package com.jfinal.template.ext.directive;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import com.jfinal.template.Directive;
|
import com.jfinal.template.Directive;
|
||||||
import com.jfinal.template.Env;
|
import com.jfinal.template.Env;
|
||||||
|
import com.jfinal.template.TemplateException;
|
||||||
import com.jfinal.template.io.Writer;
|
import com.jfinal.template.io.Writer;
|
||||||
import com.jfinal.template.stat.Scope;
|
import com.jfinal.template.stat.Scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输出随机数
|
* 输出 int 型随机数
|
||||||
*/
|
*/
|
||||||
public class RandomDirective extends Directive {
|
public class RandomDirective extends Directive {
|
||||||
|
|
||||||
private java.util.Random random = new java.util.Random();
|
private java.util.Random random = new java.util.Random();
|
||||||
|
|
||||||
public void exec(Env env, Scope scope, Writer writer) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -70,7 +70,7 @@ public class RenderDirective extends Directive {
|
|||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
for (int i = 1; i < len; i++) {
|
for (int i = 1; i < len; i++) {
|
||||||
if (!(exprList.getExpr(i) instanceof Assign)) {
|
if (!(exprList.getExpr(i) instanceof Assign)) {
|
||||||
throw new ParseException("The " + i + "th parameter of #render directive must be an assignment expression", location);
|
throw new ParseException("The " + (i + 1) + "th parameter of #render directive must be an assignment expression", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,6 +43,14 @@ public class ByteExt {
|
|||||||
public Double toDouble(Byte self) {
|
public Double toDouble(Byte self) {
|
||||||
return self.doubleValue();
|
return self.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Short toShort(Byte self) {
|
||||||
|
return self.shortValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte toByte(Byte self) {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,6 +43,14 @@ public class DoubleExt {
|
|||||||
public Double toDouble(Double self) {
|
public Double toDouble(Double self) {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Short toShort(Double self) {
|
||||||
|
return self.shortValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte toByte(Double self) {
|
||||||
|
return self.byteValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,6 +43,14 @@ public class FloatExt {
|
|||||||
public Double toDouble(Float self) {
|
public Double toDouble(Float self) {
|
||||||
return self.doubleValue();
|
return self.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Short toShort(Float self) {
|
||||||
|
return self.shortValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte toByte(Float self) {
|
||||||
|
return self.byteValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -63,6 +63,14 @@ public class IntegerExt {
|
|||||||
public Double toDouble(Integer self) {
|
public Double toDouble(Integer self) {
|
||||||
return self.doubleValue();
|
return self.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Short toShort(Integer self) {
|
||||||
|
return self.shortValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte toByte(Integer self) {
|
||||||
|
return self.byteValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,6 +43,14 @@ public class LongExt {
|
|||||||
public Double toDouble(Long self) {
|
public Double toDouble(Long self) {
|
||||||
return self.doubleValue();
|
return self.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Short toShort(Long self) {
|
||||||
|
return self.shortValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte toByte(Long self) {
|
||||||
|
return self.byteValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,6 +43,14 @@ public class ShortExt {
|
|||||||
public Double toDouble(Short self) {
|
public Double toDouble(Short self) {
|
||||||
return self.doubleValue();
|
return self.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Short toShort(Short self) {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte toByte(Short self) {
|
||||||
|
return self.byteValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -79,6 +79,14 @@ public class StringExt {
|
|||||||
public Double toDouble(String self) {
|
public Double toDouble(String self) {
|
||||||
return StrKit.isBlank(self) ? null : Double.parseDouble(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -59,101 +59,105 @@ public class JFinalView extends AbstractTemplateView {
|
|||||||
OutputStream os = response.getOutputStream();
|
OutputStream os = response.getOutputStream();
|
||||||
JFinalViewResolver.engine.getTemplate(getUrl()).render(model, os);
|
JFinalViewResolver.engine.getTemplate(getUrl()).render(model, os);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
|
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
|
||||||
class InnerSession extends HashMap<Object, Object> implements HttpSession {
|
public static class InnerSession extends HashMap<Object, Object> implements HttpSession {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8679493647540628009L;
|
private static final long serialVersionUID = -8679493647540628009L;
|
||||||
private HttpSession session;
|
private HttpSession session;
|
||||||
|
|
||||||
public InnerSession(HttpSession session) {
|
public InnerSession(HttpSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashMap 相关方法处理 ----------------------------------------------------
|
// HashMap 相关方法处理 ----------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* 覆盖 HashMap 的 put
|
* 覆盖 HashMap 的 put
|
||||||
*/
|
*/
|
||||||
public Object put(Object name, Object value) {
|
public Object put(Object name, Object value) {
|
||||||
session.setAttribute((String)name, value);
|
session.setAttribute((String)name, value);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 覆盖 HashMap 的 get
|
* 覆盖 HashMap 的 get
|
||||||
*/
|
*/
|
||||||
public Object get(Object name) {
|
public Object get(Object name) {
|
||||||
return session.getAttribute((String)name);
|
return session.getAttribute((String)name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session 相关方法处理 ----------------------------------------------------
|
// Session 相关方法处理 ----------------------------------------------------
|
||||||
public Object getAttribute(String key) {
|
public Object getAttribute(String key) {
|
||||||
return session.getAttribute(key);
|
return session.getAttribute(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enumeration getAttributeNames() {
|
public Enumeration getAttributeNames() {
|
||||||
return session.getAttributeNames();
|
return session.getAttributeNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCreationTime() {
|
public long getCreationTime() {
|
||||||
return session.getCreationTime();
|
return session.getCreationTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return session.getId();
|
return session.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastAccessedTime() {
|
public long getLastAccessedTime() {
|
||||||
return session.getLastAccessedTime();
|
return session.getLastAccessedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxInactiveInterval() {
|
public int getMaxInactiveInterval() {
|
||||||
return session.getMaxInactiveInterval();
|
return session.getMaxInactiveInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServletContext getServletContext() {
|
public ServletContext getServletContext() {
|
||||||
return session.getServletContext();
|
return session.getServletContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public javax.servlet.http.HttpSessionContext getSessionContext() {
|
public javax.servlet.http.HttpSessionContext getSessionContext() {
|
||||||
return session.getSessionContext();
|
return session.getSessionContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue(String key) {
|
public Object getValue(String key) {
|
||||||
return session.getValue(key);
|
return session.getValue(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getValueNames() {
|
public String[] getValueNames() {
|
||||||
return session.getValueNames();
|
return session.getValueNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNew() {
|
public boolean isNew() {
|
||||||
return session.isNew();
|
return session.isNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putValue(String key, Object value) {
|
public void putValue(String key, Object value) {
|
||||||
session.putValue(key, value);
|
session.putValue(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAttribute(String key) {
|
public void removeAttribute(String key) {
|
||||||
session.removeAttribute(key);
|
session.removeAttribute(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeValue(String key) {
|
public void removeValue(String key) {
|
||||||
session.removeValue(key);
|
session.removeValue(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttribute(String key, Object value) {
|
public void setAttribute(String key, Object value) {
|
||||||
session.setAttribute(key, value);
|
session.setAttribute(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxInactiveInterval(int maxInactiveInterval) {
|
public void setMaxInactiveInterval(int maxInactiveInterval) {
|
||||||
session.setMaxInactiveInterval(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 {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -77,6 +77,9 @@ public class FileSource implements ISource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String buildFinalFileName(String baseTemplatePath, String fileName) {
|
private String buildFinalFileName(String baseTemplatePath, String fileName) {
|
||||||
|
if (baseTemplatePath == null) {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
char firstChar = fileName.charAt(0);
|
char firstChar = fileName.charAt(0);
|
||||||
String finalFileName;
|
String finalFileName;
|
||||||
if (firstChar == '/' || firstChar == '\\') {
|
if (firstChar == '/' || firstChar == '\\') {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2011-2017, James Zhan 詹波 (jfinal@126.com).
|
* Copyright (c) 2011-2019, James Zhan 詹波 (jfinal@126.com).
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user