decrement footprint

This commit is contained in:
高铁
2016-04-02 01:58:56 +08:00
parent 60e0e5d83e
commit 552fd4d1ff
13 changed files with 178 additions and 182 deletions
@@ -364,7 +364,7 @@ public class DefaultJSONParser implements Closeable {
if ((lexer.features & Feature.AllowISO8601DateFormat.mask) != 0) {
JSONScanner iso8601Lexer = new JSONScanner(strValue);
if (iso8601Lexer.scanISO8601DateIfMatch()) {
if (iso8601Lexer.scanISO8601DateIfMatch(true)) {
value = iso8601Lexer.getCalendar().getTime();
}
iso8601Lexer.close();
@@ -977,7 +977,7 @@ public class DefaultJSONParser implements Closeable {
if ((lexer.features & Feature.AllowISO8601DateFormat.mask) != 0) {
JSONScanner iso8601Lexer = new JSONScanner(stringLiteral);
if (iso8601Lexer.scanISO8601DateIfMatch()) {
if (iso8601Lexer.scanISO8601DateIfMatch(true)) {
value = iso8601Lexer.getCalendar().getTime();
} else {
value = stringLiteral;
@@ -1160,7 +1160,7 @@ public class DefaultJSONParser implements Closeable {
if ((lexer.features & Feature.AllowISO8601DateFormat.mask) != 0) {
JSONScanner iso8601Lexer = new JSONScanner(stringLiteral);
try {
if (iso8601Lexer.scanISO8601DateIfMatch()) {
if (iso8601Lexer.scanISO8601DateIfMatch(true)) {
return iso8601Lexer.getCalendar().getTime();
}
} finally {
@@ -116,7 +116,8 @@ public final class JSONScanner extends JSONLexer {
}
public final String numberString() {
char chLocal = charAt(np + sp - 1);
int index = np + sp - 1;
char chLocal = text.charAt(index);
int sp = this.sp;
if (chLocal == 'L' || chLocal == 'S' || chLocal == 'B' || chLocal == 'F' || chLocal == 'D') {
@@ -127,13 +128,9 @@ public final class JSONScanner extends JSONLexer {
return this.subString(np, sp);
}
public final int ISO8601_LEN_0 = "0000-00-00".length();
public final int ISO8601_LEN_1 = "0000-00-00T00:00:00".length();
public final int ISO8601_LEN_2 = "0000-00-00T00:00:00.000".length();
public boolean scanISO8601DateIfMatch() {
return scanISO8601DateIfMatch(true);
}
public static final int ISO8601_LEN_0 = "0000-00-00".length();
public static final int ISO8601_LEN_1 = "0000-00-00T00:00:00".length();
public static final int ISO8601_LEN_2 = "0000-00-00T00:00:00.000".length();
public boolean scanISO8601DateIfMatch(boolean strict) {
int rest = len - bp;
@@ -95,7 +95,7 @@ public class ParserConfig {
private final IdentityHashMap<Type, ObjectDeserializer> derializers = new IdentityHashMap<Type, ObjectDeserializer>();
public final SymbolTable symbolTable = new SymbolTable();
public final SymbolTable symbolTable = new SymbolTable(512);
public ClassLoader defaultClassLoader;
@@ -22,10 +22,6 @@ import com.alibaba.fastjson.JSON;
*/
public class SymbolTable {
public static final int DEFAULT_TABLE_SIZE = 512;
public static final int MAX_BUCKET_LENTH = 8;
public static final int MAX_SIZE = 4096;
private final Entry[] buckets;
private final String[] symbols;
private final char[][] symbols_char;
@@ -34,23 +30,13 @@ public class SymbolTable {
private int size = 0;
public SymbolTable(){
this(DEFAULT_TABLE_SIZE);
this.addSymbol("$ref", 0, 4, "$ref".hashCode());
this.addSymbol(JSON.DEFAULT_TYPE_KEY, 0, 5, JSON.DEFAULT_TYPE_KEY.hashCode());
}
public SymbolTable(int tableSize){
this.indexMask = tableSize - 1;
this.buckets = new Entry[tableSize];
this.symbols = new String[tableSize];
this.symbols_char = new char[tableSize][];
}
public String addSymbol(char[] buffer, int offset, int len) {
// search for identical symbol
int hash = hash(buffer, offset, len);
return addSymbol(buffer, offset, len, hash);
this.addSymbol("$ref", 0, 4, "$ref".hashCode());
this.addSymbol(JSON.DEFAULT_TYPE_KEY, 0, 5, JSON.DEFAULT_TYPE_KEY.hashCode());
}
/**
@@ -109,12 +95,12 @@ public class SymbolTable {
return entry.symbol;
}
}
if (entryIndex >= MAX_BUCKET_LENTH) {
if (entryIndex >= 8) {
return new String(buffer, offset, len);
}
}
if (size >= MAX_SIZE) {
if (size >= 4096) {
return new String(buffer, offset, len);
}
@@ -175,13 +161,13 @@ public class SymbolTable {
return entry.symbol;
}
}
if (entryIndex >= MAX_BUCKET_LENTH) {
if (entryIndex >= 8) {
//return buffer.substring(offset, offset + len);
return subString(buffer, offset, len);
}
}
if (size >= MAX_SIZE) {
if (size >= 4096) {
// return buffer.substring(offset, offset + len);
return subString(buffer, offset, len);
}
@@ -203,10 +189,6 @@ public class SymbolTable {
}
return new String(chars);
}
public int size() {
return size;
}
public static final int hash(char[] buffer, int offset, int len) {
int h = 0;
@@ -28,7 +28,7 @@ public abstract class AbstractDateDeserializer implements ObjectDeserializer {
if ((lexer.features & Feature.AllowISO8601DateFormat.mask) != 0) {
JSONScanner iso8601Lexer = new JSONScanner(strVal);
if (iso8601Lexer.scanISO8601DateIfMatch()) {
if (iso8601Lexer.scanISO8601DateIfMatch(true)) {
val = iso8601Lexer.getCalendar().getTime();
}
iso8601Lexer.close();
@@ -1,10 +1,13 @@
package com.alibaba.json.bvt;
import java.lang.reflect.Field;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.SymbolTable;
import org.junit.Assert;
import junit.framework.TestCase;
public class OOMTest extends TestCase {
@@ -15,6 +18,9 @@ public class OOMTest extends TestCase {
JSON.parse(text);
}
Assert.assertEquals(SymbolTable.MAX_SIZE, ParserConfig.getGlobalInstance().symbolTable.size());
Field field = SymbolTable.class.getDeclaredField("size");
field.setAccessible(true);
int size = field.getInt(ParserConfig.getGlobalInstance().symbolTable);
Assert.assertEquals(4096, size);
}
}
@@ -27,22 +27,27 @@ public class SymbolTableTest extends TestCase {
symbols_char[i] = symbols[i].toCharArray();
}
SymbolTable table = new SymbolTable();
SymbolTable table = new SymbolTable(512);
for (int i = 0; i < symbols.length; ++i) {
String symbol = symbols[i];
char[] charArray = symbol.toCharArray();
table.addSymbol(charArray, 0, charArray.length);
addSymbol(table, charArray, 0, charArray.length);
//System.out.println((table.hash(symbol) & table.getIndexMask()) + "\t\t:" + symbol + "\t\t" + table.hash(symbol));
}
String symbol = "name";
table.addSymbol(symbol.toCharArray(), 0, symbol.length());
table.addSymbol(symbol.toCharArray(), 0, symbol.length());
addSymbol(table, symbol.toCharArray(), 0, symbol.length());
addSymbol(table, symbol.toCharArray(), 0, symbol.length());
Assert.assertTrue(symbol == table.addSymbol("name".toCharArray(), 0, 4));
Assert.assertTrue(symbol == table.addSymbol(" name".toCharArray(), 1, 4));
Assert.assertTrue(symbol == table.addSymbol(" name ".toCharArray(), 1, 4));
Assert.assertTrue(symbol != table.addSymbol(" namf ".toCharArray(), 1, 4));
Assert.assertTrue(symbol == addSymbol(table, "name".toCharArray(), 0, 4));
Assert.assertTrue(symbol == addSymbol(table, " name".toCharArray(), 1, 4));
Assert.assertTrue(symbol == addSymbol(table, " name ".toCharArray(), 1, 4));
Assert.assertTrue(symbol != addSymbol(table, " namf ".toCharArray(), 1, 4));
}
public String addSymbol(SymbolTable table, char[] buffer, int offset, int len) {
int hash = SymbolTable.hash(buffer, offset, len);
return table.addSymbol(buffer, offset, len, hash);
}
}
@@ -2,46 +2,52 @@ package com.alibaba.json.bvt.android;
import com.alibaba.fastjson.JSON;
public class OnlyFieldTest {
public void test_0 () throws Exception {
import junit.framework.TestCase;
public class OnlyFieldTest extends TestCase {
public void test_0() throws Exception {
TestParcel parcel = new TestParcel();
String text = JSON.toJSONString(parcel);
System.out.println(text);
JSON.parseObject(text, TestParcel.class);
}
public static interface Parcelable {
}
public static class ParcelCompany implements Parcelable {
public int entryAge = 1;
public int entryAge = 1;
public String companyName = "";
public String phoneNum = "";
public String address = "";
public String phoneNum = "";
public String address = "";
public void setAddress(String address) {
throw new UnsupportedOperationException();
}
public String getPhoneNum() {
throw new UnsupportedOperationException();
}
public void setPhoneNum(String phoneNum) {
throw new UnsupportedOperationException();
}
}
public static class TestParcel {
public int mAge = 15;
public int mSex = 0;
public String mName = "";
public String mPhoneNum = "";
public String mAddress = "";
public ParcelCompany mCompany = new ParcelCompany();
}
public static void main(String[] args) throws Exception {
OnlyFieldTest test = new OnlyFieldTest();
test.test_0();
Thread.sleep(1000 * 1000);
public int mAge = 15;
public int mSex = 0;
public String mName = "";
public String mPhoneNum = "";
public String mAddress = "";
public ParcelCompany mCompany = new ParcelCompany();
}
}
@@ -480,10 +480,10 @@ public class DefaultExtJSONParserTest extends TestCase {
public static class ErrorObject2 {
private String name;
private String _name;
public String getName() {
return name;
return _name;
}
public void setName(String name) {
@@ -10,99 +10,99 @@ import com.alibaba.fastjson.parser.JSONToken;
public class JSONScannerTest_ISO8601 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals(false, new JSONScanner("1").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("3").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("3000-10-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("1997").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("1997-2-2").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("1997-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("1997:02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("1997-02:02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2A00-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2!00-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("20A0-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("20!0-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("200A-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("200!-02-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-32-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-1A-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-1!-02").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-10-02").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-11-02").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-12-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-13-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-20-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-0A-02").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-0!-02").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-00").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-0!").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-0A").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-20").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-2A").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-2!").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-30").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-31").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-32").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-42").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("1").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("3").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("3000-10-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("1997").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("1997-2-2").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("1997-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("1997:02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("1997-02:02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2A00-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2!00-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("20A0-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("20!0-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("200A-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("200!-02-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-32-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-1A-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-1!-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-10-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-11-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-12-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-13-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-20-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-0A-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-0!-02").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-00").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-0!").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-0A").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-20").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-2A").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-2!").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-30").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-31").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-32").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-42").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:00").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00-00").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T01:01:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T0A:01:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T0!:01:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:10:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:11:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T10011:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T10:11:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T1!:11:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T1a:11:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:1A:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:1!:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T20:20:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T21:21:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T22:22:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T23:23:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T24:24:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T25:25:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T2!:20:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T30:20:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00A22:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:22:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:!2:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:A2:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:2A:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:2!:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:60:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:61:01").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:01").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:0!").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:0A").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:60").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:61").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:70").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:!0").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:A0").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:00").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.0").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:00.000").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.A00").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.!00").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.0A0").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.0!0").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00!").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00a").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2000-02-10T").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:00").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00-00").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T01:01:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T0A:01:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T0!:01:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:10:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:11:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T10011:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T10:11:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T1!:11:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T1a:11:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:1A:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:1!:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T20:20:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T21:21:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T22:22:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T23:23:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T24:24:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T25:25:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T2!:20:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T30:20:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00A22:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:22:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:!2:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:A2:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:2A:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:2!:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:60:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:61:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:01").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:0!").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:0A").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:60").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:61").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:70").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:!0").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:A0").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:00").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.0").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00").scanISO8601DateIfMatch(true));
Assert.assertEquals(true, new JSONScanner("2000-02-10T00:00:00.000").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.A00").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.!00").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.0A0").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.0!0").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00!").scanISO8601DateIfMatch(true));
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00a").scanISO8601DateIfMatch(true));
}
public void test_2() throws Exception {
JSONScanner lexer = new JSONScanner("2000-02-10T00:00:00.000");
lexer.config(Feature.AllowISO8601DateFormat, true);
Assert.assertEquals(true, lexer.scanISO8601DateIfMatch());
Assert.assertEquals(true, lexer.scanISO8601DateIfMatch(true));
Assert.assertEquals(JSONToken.LITERAL_ISO8601_DATE, lexer.token());
lexer.nextToken();
Assert.assertEquals(JSONToken.EOF, lexer.token());
@@ -15,7 +15,7 @@ import com.alibaba.fastjson.parser.SymbolTable;
public class JSONScannerTest_symbol extends TestCase {
public void test_0() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -24,7 +24,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_1() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -33,7 +33,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_2() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\\"name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -42,7 +42,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_3() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\\\name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -51,7 +51,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_4() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\/name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -60,7 +60,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_5() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\bname\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -69,7 +69,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_6() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\f name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -78,7 +78,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_7() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\F name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -87,7 +87,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_8() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\n name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -96,7 +96,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_9() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\r name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -105,7 +105,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_10() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\t name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -114,7 +114,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_11() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\u4e2d name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
@@ -123,7 +123,7 @@ public class JSONScannerTest_symbol extends TestCase {
}
public void test_12() throws Exception {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner(
"\"\\tabcdefghijklmnopqrstuvwxyz01234567890abcdefghijklmnopqrstuvwxyz01234567890abcdefghijklmnopqrstuvwxyz01234567890abcdefghijklmnopqrstuvwxyz01234567890\"");
@@ -135,7 +135,7 @@ public class JSONScannerTest_symbol extends TestCase {
public void test_error() throws Exception {
JSONException error = null;
try {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\a name\"");
lexer.scanSymbol(symbolTable, '"');
@@ -149,7 +149,7 @@ public class JSONScannerTest_symbol extends TestCase {
public void test_error_2() throws Exception {
JSONException error = null;
try {
SymbolTable symbolTable = new SymbolTable();
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"name");
lexer.scanSymbol(symbolTable, '"');
@@ -20,10 +20,10 @@ public class FieldDeserializerTest extends TestCase {
private static class Entity {
private V1 value;
private V1 _value;
public V1 getValue() {
return value;
return _value;
}
public void setValue(V1 value) {
@@ -44,10 +44,10 @@ public class FieldDeserializerTest3 extends TestCase {
private static class Entity {
private String value;
private String _value;
public String getValue() {
return value;
return _value;
}
public void setValue(String value) {