enjoy 3.4

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

View File

@ -57,43 +57,47 @@ public class Text extends Stat implements IWritable {
return bytes; return bytes;
} }
if (content != null) {
synchronized (this) { synchronized (this) {
if (bytes != null) {
return bytes;
}
if (content != null) { if (content != null) {
bytes = content.toString().getBytes(charset); bytes = content.toString().getBytes(charset);
content = null; content = null;
return bytes; return bytes;
} } else {
}
}
bytes = new String(chars).getBytes(charset); bytes = new String(chars).getBytes(charset);
return bytes; return bytes;
} }
}
}
public char[] getChars() { public char[] getChars() {
if (chars != null) { if (chars != null) {
return chars; return chars;
} }
if (content != null) {
synchronized (this) { synchronized (this) {
if (chars != null) {
return chars;
}
if (content != null) { if (content != null) {
char[] charsTemp = new char[content.length()]; char[] charsTemp = new char[content.length()];
content.getChars(0, content.length(), charsTemp, 0); content.getChars(0, content.length(), charsTemp, 0);
chars = charsTemp; chars = charsTemp;
content = null; content = null;
return chars; return chars;
} } else {
}
}
String strTemp = new String(bytes, charset); String strTemp = new String(bytes, charset);
char[] charsTemp = new char[strTemp.length()]; char[] charsTemp = new char[strTemp.length()];
strTemp.getChars(0, strTemp.length(), charsTemp, 0); strTemp.getChars(0, strTemp.length(), charsTemp, 0);
chars = charsTemp; chars = charsTemp;
return chars; return chars;
} }
}
}
public boolean isEmpty() { public boolean isEmpty() {
if (content != null) { if (content != null) {