enjoy 3.4

This commit is contained in:
James 2018-04-02 19:14:24 +08:00
parent d12d3d8abb
commit a1e88a4a4c

View File

@ -25,7 +25,7 @@ import com.jfinal.template.io.Writer;
import com.jfinal.template.stat.Scope; import com.jfinal.template.stat.Scope;
/** /**
* Text 输出纯文本块以及使用 "#[[" "]]#" 定义的原样输出块 * Text 输出纯文本块以及使用 "#[[" "]]#" 定义的原样输出块
*/ */
public class Text extends Stat implements IWritable { public class Text extends Stat implements IWritable {
@ -57,18 +57,20 @@ public class Text extends Stat implements IWritable {
return bytes; return bytes;
} }
if (content != null) { synchronized (this) {
synchronized (this) { if (bytes != null) {
if (content != null) { return bytes;
bytes = content.toString().getBytes(charset); }
content = null;
return bytes; if (content != null) {
} bytes = content.toString().getBytes(charset);
content = null;
return bytes;
} else {
bytes = new String(chars).getBytes(charset);
return bytes;
} }
} }
bytes = new String(chars).getBytes(charset);
return bytes;
} }
public char[] getChars() { public char[] getChars() {
@ -76,23 +78,25 @@ public class Text extends Stat implements IWritable {
return chars; return chars;
} }
if (content != null) { synchronized (this) {
synchronized (this) { if (chars != null) {
if (content != null) { return chars;
char[] charsTemp = new char[content.length()]; }
content.getChars(0, content.length(), charsTemp, 0);
chars = charsTemp; if (content != null) {
content = null; char[] charsTemp = new char[content.length()];
return chars; content.getChars(0, content.length(), charsTemp, 0);
} chars = charsTemp;
content = null;
return chars;
} else {
String strTemp = new String(bytes, charset);
char[] charsTemp = new char[strTemp.length()];
strTemp.getChars(0, strTemp.length(), charsTemp, 0);
chars = charsTemp;
return chars;
} }
} }
String strTemp = new String(bytes, charset);
char[] charsTemp = new char[strTemp.length()];
strTemp.getChars(0, strTemp.length(), charsTemp, 0);
chars = charsTemp;
return chars;
} }
public boolean isEmpty() { public boolean isEmpty() {