mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-23 01:48:31 +08:00
Merge branch 'master' of https://github.com/alibaba/fastjson
This commit is contained in:
@@ -96,11 +96,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
DEFAULT_GENERATE_FEATURE = features;
|
||||
}
|
||||
|
||||
public static final Object parse(String text) {
|
||||
public static Object parse(String text) {
|
||||
return parse(text, DEFAULT_PARSER_FEATURE);
|
||||
}
|
||||
|
||||
public static final Object parse(String text, int features) {
|
||||
public static Object parse(String text, int features) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -115,11 +115,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static final Object parse(byte[] input, Feature... features) {
|
||||
public static Object parse(byte[] input, Feature... features) {
|
||||
return parse(input, 0, input.length, ThreadLocalCache.getUTF8Decoder(), features);
|
||||
}
|
||||
|
||||
public static final Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features) {
|
||||
public static Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features) {
|
||||
if (input == null || input.length == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return parse(input, off, len, charsetDecoder, featureValues);
|
||||
}
|
||||
|
||||
public static final Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, int features) {
|
||||
public static Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, int features) {
|
||||
charsetDecoder.reset();
|
||||
|
||||
int scaleLength = (int) (len * (double) charsetDecoder.maxCharsPerByte());
|
||||
@@ -154,7 +154,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static final Object parse(String text, Feature... features) {
|
||||
public static Object parse(String text, Feature... features) {
|
||||
int featureValues = DEFAULT_PARSER_FEATURE;
|
||||
for (Feature featrue : features) {
|
||||
featureValues = Feature.config(featureValues, featrue, true);
|
||||
@@ -163,11 +163,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return parse(text, featureValues);
|
||||
}
|
||||
|
||||
public static final JSONObject parseObject(String text, Feature... features) {
|
||||
public static JSONObject parseObject(String text, Feature... features) {
|
||||
return (JSONObject) parse(text, features);
|
||||
}
|
||||
|
||||
public static final JSONObject parseObject(String text) {
|
||||
public static JSONObject parseObject(String text) {
|
||||
Object obj = parse(text);
|
||||
if (obj instanceof JSONObject) {
|
||||
return (JSONObject) obj;
|
||||
@@ -177,33 +177,33 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String text, TypeReference<T> type, Feature... features) {
|
||||
public static <T> T parseObject(String text, TypeReference<T> type, Feature... features) {
|
||||
return (T) parseObject(text, type.getType(), ParserConfig.getGlobalInstance(), DEFAULT_PARSER_FEATURE, features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String text, Class<T> clazz, Feature... features) {
|
||||
public static <T> T parseObject(String text, Class<T> clazz, Feature... features) {
|
||||
return (T) parseObject(text, (Type) clazz, ParserConfig.getGlobalInstance(), DEFAULT_PARSER_FEATURE, features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String text, Class<T> clazz, ParseProcess processor, Feature... features) {
|
||||
public static <T> T parseObject(String text, Class<T> clazz, ParseProcess processor, Feature... features) {
|
||||
return (T) parseObject(text, (Type) clazz, ParserConfig.getGlobalInstance(), processor, DEFAULT_PARSER_FEATURE,
|
||||
features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String input, Type clazz, Feature... features) {
|
||||
public static <T> T parseObject(String input, Type clazz, Feature... features) {
|
||||
return (T) parseObject(input, clazz, ParserConfig.getGlobalInstance(), DEFAULT_PARSER_FEATURE, features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String input, Type clazz, ParseProcess processor, Feature... features) {
|
||||
public static <T> T parseObject(String input, Type clazz, ParseProcess processor, Feature... features) {
|
||||
return (T) parseObject(input, clazz, ParserConfig.getGlobalInstance(), DEFAULT_PARSER_FEATURE, features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String input, Type clazz, int featureValues, Feature... features) {
|
||||
public static <T> T parseObject(String input, Type clazz, int featureValues, Feature... features) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -222,13 +222,13 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public static final <T> T parseObject(String input, Type clazz, ParserConfig config, int featureValues,
|
||||
public static <T> T parseObject(String input, Type clazz, ParserConfig config, int featureValues,
|
||||
Feature... features) {
|
||||
return parseObject(input, clazz, config, null, featureValues, features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(String input, Type clazz, ParserConfig config, ParseProcess processor,
|
||||
public static <T> T parseObject(String input, Type clazz, ParserConfig config, ParseProcess processor,
|
||||
int featureValues, Feature... features) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
@@ -258,12 +258,12 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(byte[] input, Type clazz, Feature... features) {
|
||||
public static <T> T parseObject(byte[] input, Type clazz, Feature... features) {
|
||||
return (T) parseObject(input, 0, input.length, ThreadLocalCache.getUTF8Decoder(), clazz, features);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Type clazz,
|
||||
public static <T> T parseObject(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Type clazz,
|
||||
Feature... features) {
|
||||
charsetDecoder.reset();
|
||||
|
||||
@@ -280,7 +280,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(char[] input, int length, Type clazz, Feature... features) {
|
||||
public static <T> T parseObject(char[] input, int length, Type clazz, Feature... features) {
|
||||
if (input == null || input.length == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -300,11 +300,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public static final <T> T parseObject(String text, Class<T> clazz) {
|
||||
public static <T> T parseObject(String text, Class<T> clazz) {
|
||||
return parseObject(text, clazz, new Feature[0]);
|
||||
}
|
||||
|
||||
public static final JSONArray parseArray(String text) {
|
||||
public static JSONArray parseArray(String text) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return array;
|
||||
}
|
||||
|
||||
public static final <T> List<T> parseArray(String text, Class<T> clazz) {
|
||||
public static <T> List<T> parseArray(String text, Class<T> clazz) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static final List<Object> parseArray(String text, Type[] types) {
|
||||
public static List<Object> parseArray(String text, Type[] types) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -378,11 +378,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
|
||||
// ======================
|
||||
public static final String toJSONString(Object object) {
|
||||
public static String toJSONString(Object object) {
|
||||
return toJSONString(object, new SerializerFeature[0]);
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, SerializerFeature... features) {
|
||||
public static String toJSONString(Object object, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
try {
|
||||
@@ -402,7 +402,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
/**
|
||||
* @since 1.1.14
|
||||
*/
|
||||
public static final String toJSONStringWithDateFormat(Object object, String dateFormat,
|
||||
public static String toJSONStringWithDateFormat(Object object, String dateFormat,
|
||||
SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
@@ -426,7 +426,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, SerializeFilter filter, SerializerFeature... features) {
|
||||
public static String toJSONString(Object object, SerializeFilter filter, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
try {
|
||||
@@ -447,7 +447,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, SerializeFilter[] filters, SerializerFeature... features) {
|
||||
public static String toJSONString(Object object, SerializeFilter[] filters, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
try {
|
||||
@@ -468,7 +468,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte[] toJSONBytes(Object object, SerializerFeature... features) {
|
||||
public static byte[] toJSONBytes(Object object, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
try {
|
||||
@@ -485,11 +485,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, SerializeConfig config, SerializerFeature... features) {
|
||||
public static String toJSONString(Object object, SerializeConfig config, SerializerFeature... features) {
|
||||
return toJSONString(object, config, (SerializeFilter) null, features);
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, SerializeConfig config, SerializeFilter filter,
|
||||
public static String toJSONString(Object object, SerializeConfig config, SerializeFilter filter,
|
||||
SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
@@ -509,7 +509,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, SerializeConfig config, SerializeFilter[] filters,
|
||||
public static String toJSONString(Object object, SerializeConfig config, SerializeFilter[] filters,
|
||||
SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
@@ -529,7 +529,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toJSONStringZ(Object object, SerializeConfig mapping, SerializerFeature... features) {
|
||||
public static String toJSONStringZ(Object object, SerializeConfig mapping, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter(features);
|
||||
|
||||
try {
|
||||
@@ -543,7 +543,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte[] toJSONBytes(Object object, SerializeConfig config, SerializerFeature... features) {
|
||||
public static byte[] toJSONBytes(Object object, SerializeConfig config, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter();
|
||||
|
||||
try {
|
||||
@@ -560,7 +560,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toJSONString(Object object, boolean prettyFormat) {
|
||||
public static String toJSONString(Object object, boolean prettyFormat) {
|
||||
if (!prettyFormat) {
|
||||
return toJSONString(object);
|
||||
}
|
||||
@@ -568,7 +568,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
return toJSONString(object, SerializerFeature.PrettyFormat);
|
||||
}
|
||||
|
||||
public static final void writeJSONStringTo(Object object, Writer writer, SerializerFeature... features) {
|
||||
public static void writeJSONStringTo(Object object, Writer writer, SerializerFeature... features) {
|
||||
SerializeWriter out = new SerializeWriter(writer);
|
||||
|
||||
try {
|
||||
@@ -612,18 +612,18 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
|
||||
// ///////
|
||||
public static final Object toJSON(Object javaObject) {
|
||||
public static Object toJSON(Object javaObject) {
|
||||
return toJSON(javaObject, ParserConfig.getGlobalInstance());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Object toJSON(Object javaObject, ParserConfig mapping) {
|
||||
public static Object toJSON(Object javaObject, ParserConfig mapping) {
|
||||
if (javaObject == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (javaObject instanceof JSON) {
|
||||
return (JSON) javaObject;
|
||||
return javaObject;
|
||||
}
|
||||
|
||||
if (javaObject instanceof Map) {
|
||||
@@ -698,7 +698,7 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static final <T> T toJavaObject(JSON json, Class<T> clazz) {
|
||||
public static <T> T toJavaObject(JSON json, Class<T> clazz) {
|
||||
return TypeUtils.cast(json, clazz, ParserConfig.getGlobalInstance());
|
||||
}
|
||||
|
||||
|
||||
@@ -948,7 +948,7 @@ public class JSONPath implements ObjectSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
static interface Segement {
|
||||
interface Segement {
|
||||
|
||||
Object eval(JSONPath path, Object rootObject, Object currentObject);
|
||||
}
|
||||
@@ -1442,7 +1442,7 @@ public class JSONPath implements ObjectSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
static enum Operator {
|
||||
enum Operator {
|
||||
EQ, NE, GT, GE, LT, LE, LIKE, NOT_LIKE, RLIKE, NOT_RLIKE, IN, NOT_IN, BETWEEN, NOT_BETWEEN
|
||||
}
|
||||
|
||||
@@ -1484,7 +1484,7 @@ public class JSONPath implements ObjectSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
static interface Filter {
|
||||
interface Filter {
|
||||
|
||||
boolean apply(JSONPath path, Object rootObject, Object currentObject, Object item);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public enum Feature {
|
||||
DisableSpecialKeyDetect
|
||||
;
|
||||
|
||||
private Feature(){
|
||||
Feature(){
|
||||
mask = (1 << ordinal());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@ import java.util.Collection;
|
||||
|
||||
public interface JSONLexer {
|
||||
|
||||
public final static byte EOI = 0x1A;
|
||||
public final static int NOT_MATCH = -1;
|
||||
public final static int NOT_MATCH_NAME = -2;
|
||||
public final static int UNKOWN = 0;
|
||||
public final static int OBJECT = 1;
|
||||
public final static int ARRAY = 2;
|
||||
public final static int VALUE = 3;
|
||||
public final static int END = 4;
|
||||
byte EOI = 0x1A;
|
||||
int NOT_MATCH = -1;
|
||||
int NOT_MATCH_NAME = -2;
|
||||
int UNKOWN = 0;
|
||||
int OBJECT = 1;
|
||||
int ARRAY = 2;
|
||||
int VALUE = 3;
|
||||
int END = 4;
|
||||
|
||||
int token();
|
||||
|
||||
|
||||
@@ -2662,7 +2662,7 @@ public abstract class JSONLexerBase implements JSONLexer, Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
private final void scanStringSingleQuote() {
|
||||
private void scanStringSingleQuote() {
|
||||
np = bp;
|
||||
hasSpecial = false;
|
||||
char chLocal;
|
||||
@@ -2981,7 +2981,7 @@ public abstract class JSONLexerBase implements JSONLexer, Closeable {
|
||||
return new BigDecimal(numberString());
|
||||
}
|
||||
|
||||
public static final boolean isWhitespace(char ch) {
|
||||
public static boolean isWhitespace(char ch) {
|
||||
// 专门调整了判断顺序
|
||||
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' || ch == '\b';
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class JSONScanner extends JSONLexerBase {
|
||||
return matchStat;
|
||||
}
|
||||
|
||||
static final boolean charArrayCompare(String src, int offset, char[] dest) {
|
||||
static boolean charArrayCompare(String src, int offset, char[] dest) {
|
||||
final int destLen = dest.length;
|
||||
if (destLen + offset > src.length()) {
|
||||
return false;
|
||||
|
||||
@@ -208,7 +208,7 @@ public class SymbolTable {
|
||||
return size;
|
||||
}
|
||||
|
||||
public static final int hash(char[] buffer, int offset, int len) {
|
||||
public static int hash(char[] buffer, int offset, int len) {
|
||||
int h = 0;
|
||||
int off = offset;
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ public class JSONSerializer {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static final void write(Writer out, Object object) {
|
||||
public static void write(Writer out, Object object) {
|
||||
SerializeWriter writer = new SerializeWriter();
|
||||
try {
|
||||
JSONSerializer serializer = new JSONSerializer(writer);
|
||||
@@ -356,7 +356,7 @@ public class JSONSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
public static final void write(SerializeWriter out, Object object) {
|
||||
public static void write(SerializeWriter out, Object object) {
|
||||
JSONSerializer serializer = new JSONSerializer(out);
|
||||
serializer.write(object);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ import com.alibaba.fastjson.util.ServiceLoader;
|
||||
public class SerializeConfig extends IdentityHashMap<Type, ObjectSerializer> {
|
||||
private final static SerializeConfig globalInstance = new SerializeConfig();
|
||||
|
||||
private boolean asm = !ASMUtils.isAndroid();;
|
||||
private boolean asm = !ASMUtils.isAndroid();
|
||||
|
||||
private ASMSerializerFactory asmFactory;
|
||||
|
||||
@@ -149,7 +149,7 @@ public class SerializeConfig extends IdentityHashMap<Type, ObjectSerializer> {
|
||||
this.asm = asmEnable;
|
||||
}
|
||||
|
||||
public final static SerializeConfig getGlobalInstance() {
|
||||
public static SerializeConfig getGlobalInstance() {
|
||||
return globalInstance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1472,7 +1472,7 @@ public final class SerializeWriter extends Writer {
|
||||
buf[count - 1] = '\"';
|
||||
}
|
||||
|
||||
final static boolean isSpecial(char ch, int features) {
|
||||
static boolean isSpecial(char ch, int features) {
|
||||
// if (ch > ']') {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@@ -134,7 +134,7 @@ public enum SerializerFeature {
|
||||
IgnoreNonFieldGetter
|
||||
;
|
||||
|
||||
private SerializerFeature(){
|
||||
SerializerFeature(){
|
||||
mask = (1 << ordinal());
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Base64 {
|
||||
* @param chars The source array. Length 0 will return an empty array. <code>null</code> will throw an exception.
|
||||
* @return The decoded array of bytes. May be of length 0.
|
||||
*/
|
||||
public final static byte[] decodeFast(char[] chars, int offset, int charsLen) {
|
||||
public static byte[] decodeFast(char[] chars, int offset, int charsLen) {
|
||||
// Check special case
|
||||
if (charsLen == 0) {
|
||||
return new byte[0];
|
||||
@@ -85,7 +85,7 @@ public class Base64 {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public final static byte[] decodeFast(String chars, int offset, int charsLen) {
|
||||
public static byte[] decodeFast(String chars, int offset, int charsLen) {
|
||||
// Check special case
|
||||
if (charsLen == 0) {
|
||||
return new byte[0];
|
||||
@@ -151,7 +151,7 @@ public class Base64 {
|
||||
* @param s The source string. Length 0 will return an empty array. <code>null</code> will throw an exception.
|
||||
* @return The decoded array of bytes. May be of length 0.
|
||||
*/
|
||||
public final static byte[] decodeFast(String s) {
|
||||
public static byte[] decodeFast(String s) {
|
||||
// Check special case
|
||||
int sLen = s.length();
|
||||
if (sLen == 0) {
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TypeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String castToString(Object value) {
|
||||
public static String castToString(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class TypeUtils {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static final Byte castToByte(Object value) {
|
||||
public static Byte castToByte(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to byte, value : " + value);
|
||||
}
|
||||
|
||||
public static final Character castToChar(Object value) {
|
||||
public static Character castToChar(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to byte, value : " + value);
|
||||
}
|
||||
|
||||
public static final Short castToShort(Object value) {
|
||||
public static Short castToShort(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to short, value : " + value);
|
||||
}
|
||||
|
||||
public static final BigDecimal castToBigDecimal(Object value) {
|
||||
public static BigDecimal castToBigDecimal(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class TypeUtils {
|
||||
return new BigDecimal(strVal);
|
||||
}
|
||||
|
||||
public static final BigInteger castToBigInteger(Object value) {
|
||||
public static BigInteger castToBigInteger(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class TypeUtils {
|
||||
return new BigInteger(strVal);
|
||||
}
|
||||
|
||||
public static final Float castToFloat(Object value) {
|
||||
public static Float castToFloat(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to float, value : " + value);
|
||||
}
|
||||
|
||||
public static final Double castToDouble(Object value) {
|
||||
public static Double castToDouble(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to double, value : " + value);
|
||||
}
|
||||
|
||||
public static final Date castToDate(Object value) {
|
||||
public static Date castToDate(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ public class TypeUtils {
|
||||
return new Date(longValue);
|
||||
}
|
||||
|
||||
public static final java.sql.Date castToSqlDate(Object value) {
|
||||
public static java.sql.Date castToSqlDate(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -354,7 +354,7 @@ public class TypeUtils {
|
||||
return new java.sql.Date(longValue);
|
||||
}
|
||||
|
||||
public static final java.sql.Timestamp castToTimestamp(Object value) {
|
||||
public static java.sql.Timestamp castToTimestamp(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ public class TypeUtils {
|
||||
return new java.sql.Timestamp(longValue);
|
||||
}
|
||||
|
||||
public static final Long castToLong(Object value) {
|
||||
public static Long castToLong(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to long, value : " + value);
|
||||
}
|
||||
|
||||
public static final Integer castToInt(Object value) {
|
||||
public static Integer castToInt(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to int, value : " + value);
|
||||
}
|
||||
|
||||
public static final byte[] castToBytes(Object value) {
|
||||
public static byte[] castToBytes(Object value) {
|
||||
if (value instanceof byte[]) {
|
||||
return (byte[]) value;
|
||||
}
|
||||
@@ -478,7 +478,7 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to int, value : " + value);
|
||||
}
|
||||
|
||||
public static final Boolean castToBoolean(Object value) {
|
||||
public static Boolean castToBoolean(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -521,12 +521,12 @@ public class TypeUtils {
|
||||
throw new JSONException("can not cast to boolean, value : " + value);
|
||||
}
|
||||
|
||||
public static final <T> T castToJavaBean(Object obj, Class<T> clazz) {
|
||||
public static <T> T castToJavaBean(Object obj, Class<T> clazz) {
|
||||
return cast(obj, clazz, ParserConfig.getGlobalInstance());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static final <T> T cast(Object obj, Class<T> clazz, ParserConfig mapping) {
|
||||
public static <T> T cast(Object obj, Class<T> clazz, ParserConfig mapping) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -668,7 +668,7 @@ public class TypeUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static final <T> T castToEnum(Object obj, Class<T> clazz, ParserConfig mapping) {
|
||||
public static <T> T castToEnum(Object obj, Class<T> clazz, ParserConfig mapping) {
|
||||
try {
|
||||
if (obj instanceof String) {
|
||||
String name = (String) obj;
|
||||
@@ -699,7 +699,7 @@ public class TypeUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T cast(Object obj, Type type, ParserConfig mapping) {
|
||||
public static <T> T cast(Object obj, Type type, ParserConfig mapping) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -727,7 +727,7 @@ public class TypeUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static final <T> T cast(Object obj, ParameterizedType type, ParserConfig mapping) {
|
||||
public static <T> T cast(Object obj, ParameterizedType type, ParserConfig mapping) {
|
||||
Type rawTye = type.getRawType();
|
||||
|
||||
if (rawTye == Set.class
|
||||
@@ -792,7 +792,7 @@ public class TypeUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public static final <T> T castToJavaBean(Map<String, Object> map, Class<T> clazz, ParserConfig mapping) {
|
||||
public static <T> T castToJavaBean(Map<String, Object> map, Class<T> clazz, ParserConfig mapping) {
|
||||
try {
|
||||
if (clazz == StackTraceElement.class) {
|
||||
String declaringClass = (String) map.get("className");
|
||||
|
||||
@@ -40,7 +40,7 @@ public class UTF8Decoder extends CharsetDecoder {
|
||||
}
|
||||
|
||||
// [C2..DF] [80..BF]
|
||||
private static final boolean isMalformed2(int b1, int b2) {
|
||||
private static boolean isMalformed2(int b1, int b2) {
|
||||
return (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class UTF8Decoder extends CharsetDecoder {
|
||||
// [F4] [80..8F] [80..BF] [80..BF]
|
||||
// only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
|
||||
// will be checked by Surrogate.neededFor(uc)
|
||||
private static final boolean isMalformed4(int b2, int b3, int b4) {
|
||||
private static boolean isMalformed4(int b2, int b3, int b4) {
|
||||
return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || (b4 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class UTF8Decoder extends CharsetDecoder {
|
||||
return decodeArrayLoop(src, dst);
|
||||
}
|
||||
|
||||
static final void updatePositions(Buffer src, int sp, Buffer dst, int dp) {
|
||||
static void updatePositions(Buffer src, int sp, Buffer dst, int dp) {
|
||||
// src.position(sp - src.arrayOffset());
|
||||
// dst.position(dp - dst.arrayOffset());
|
||||
src.position(sp);
|
||||
|
||||
Reference in New Issue
Block a user