加强注释
This commit is contained in:
@@ -43,7 +43,7 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
|
|||||||
private byte[] content;
|
private byte[] content;
|
||||||
|
|
||||||
public JsonBytesWriter() {
|
public JsonBytesWriter() {
|
||||||
this(defaultSize);
|
this(DEFAULT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonBytesWriter(int size) {
|
public JsonBytesWriter(int size) {
|
||||||
@@ -76,8 +76,8 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
|
|||||||
public boolean recycle() {
|
public boolean recycle() {
|
||||||
super.recycle();
|
super.recycle();
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
if (this.content != null && this.content.length > defaultSize * 100) {
|
if (this.content != null && this.content.length > DEFAULT_SIZE * 100) {
|
||||||
this.content = new byte[defaultSize];
|
this.content = new byte[DEFAULT_SIZE];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.redkale.convert.*;
|
|||||||
*/
|
*/
|
||||||
public abstract class JsonWriter extends Writer {
|
public abstract class JsonWriter extends Writer {
|
||||||
|
|
||||||
protected static final int defaultSize = Integer.getInteger("redkale.convert.json.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
|
protected static final int DEFAULT_SIZE = Integer.getInteger("redkale.convert.json.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
|
||||||
|
|
||||||
protected JsonWriter() {
|
protected JsonWriter() {
|
||||||
this.features = JsonFactory.root().getFeatures();
|
this.features = JsonFactory.root().getFeatures();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.redkale.source;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.redkale.annotation.ConstructorParameters;
|
import org.redkale.annotation.ConstructorParameters;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FilterKey主要用于自身字段间的表达式, 如: a.recordid = a.parentid , a.parentid就需要FilterKey来表示 new FilterKey("parentid")
|
* FilterKey主要用于自身字段间的表达式, 如: a.recordid = a.parentid , a.parentid就需要FilterKey来表示 new FilterKey("parentid")
|
||||||
@@ -20,6 +21,7 @@ import org.redkale.annotation.ConstructorParameters;
|
|||||||
*/
|
*/
|
||||||
public class FilterKey implements java.io.Serializable {
|
public class FilterKey implements java.io.Serializable {
|
||||||
|
|
||||||
|
@ConvertColumn(index = 1)
|
||||||
private final String column;
|
private final String column;
|
||||||
|
|
||||||
@ConstructorParameters({"column"})
|
@ConstructorParameters({"column"})
|
||||||
|
|||||||
@@ -697,6 +697,7 @@ public interface Copier<S, D> extends BiFunction<S, D, D> {
|
|||||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||||
return (Copier) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
return (Copier) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class Inners {
|
|||||||
|
|
||||||
static final IntFunction<String[]> stringFuncArray = x -> new String[x];
|
static final IntFunction<String[]> stringFuncArray = x -> new String[x];
|
||||||
|
|
||||||
|
private CreatorInner() {
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
creatorCacheMap.put(Object.class, p -> new Object());
|
creatorCacheMap.put(Object.class, p -> new Object());
|
||||||
creatorCacheMap.put(ArrayList.class, p -> new ArrayList<>());
|
creatorCacheMap.put(ArrayList.class, p -> new ArrayList<>());
|
||||||
@@ -187,6 +190,7 @@ class Inners {
|
|||||||
field = cz.getDeclaredField(names[i]);
|
field = cz.getDeclaredField(names[i]);
|
||||||
break;
|
break;
|
||||||
} catch (NoSuchFieldException nsfe) {
|
} catch (NoSuchFieldException nsfe) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
@@ -225,6 +229,7 @@ class Inners {
|
|||||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||||
return (IntFunction) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
return (IntFunction) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
@@ -289,6 +294,9 @@ class Inners {
|
|||||||
|
|
||||||
static final ConcurrentHashMap<Class, ConcurrentHashMap<Integer, ConcurrentHashMap<Class, ConcurrentHashMap<Class, Function>>>> copierFuncListTwoCaches = new ConcurrentHashMap();
|
static final ConcurrentHashMap<Class, ConcurrentHashMap<Integer, ConcurrentHashMap<Class, ConcurrentHashMap<Class, Function>>>> copierFuncListTwoCaches = new ConcurrentHashMap();
|
||||||
|
|
||||||
|
private CopierInner() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearCopierCache() {
|
public static void clearCopierCache() {
|
||||||
copierOneCaches.clear();
|
copierOneCaches.clear();
|
||||||
copierTwoCaches.clear();
|
copierTwoCaches.clear();
|
||||||
@@ -303,5 +311,7 @@ class Inners {
|
|||||||
|
|
||||||
static final ConcurrentHashMap<Class, ConcurrentHashMap<Method, Invoker>> invokerCaches = new ConcurrentHashMap();
|
static final ConcurrentHashMap<Class, ConcurrentHashMap<Method, Invoker>> invokerCaches = new ConcurrentHashMap();
|
||||||
|
|
||||||
|
private InvokerInner() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class RedkaleClassLoader extends URLClassLoader {
|
|||||||
try {
|
try {
|
||||||
url = URI.create("file://redkale/uri").toURL(); //不能是jar结尾,否则会视为jar文件url
|
url = URI.create("file://redkale/uri").toURL(); //不能是jar结尾,否则会视为jar文件url
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
URL_NONE = url;
|
URL_NONE = url;
|
||||||
}
|
}
|
||||||
@@ -42,16 +43,26 @@ public class RedkaleClassLoader extends URLClassLoader {
|
|||||||
|
|
||||||
private static final String[] buildPackages = {
|
private static final String[] buildPackages = {
|
||||||
"org.redkaledyn", //所有动态生成类的根package
|
"org.redkaledyn", //所有动态生成类的根package
|
||||||
"org.redkale.annotation", "org.redkale.asm",
|
"org.redkale.annotation",
|
||||||
"org.redkale.boot", "org.redkale.boot.watch",
|
"org.redkale.asm",
|
||||||
"org.redkale.cluster", "org.redkale.convert",
|
"org.redkale.boot",
|
||||||
"org.redkale.convert.bson", "org.redkale.convert.ext",
|
"org.redkale.boot.watch",
|
||||||
"org.redkale.convert.json", "org.redkale.convert.protobuf",
|
"org.redkale.cluster",
|
||||||
"org.redkale.mq", "org.redkale.net",
|
"org.redkale.convert",
|
||||||
"org.redkale.net.client", "org.redkale.net.http",
|
"org.redkale.convert.bson",
|
||||||
"org.redkale.net.sncp", "org.redkale.persistence",
|
"org.redkale.convert.ext",
|
||||||
"org.redkale.service", "org.redkale.source",
|
"org.redkale.convert.json",
|
||||||
"org.redkale.util", "org.redkale.watch"
|
"org.redkale.convert.protobuf",
|
||||||
|
"org.redkale.mq",
|
||||||
|
"org.redkale.net",
|
||||||
|
"org.redkale.net.client",
|
||||||
|
"org.redkale.net.http",
|
||||||
|
"org.redkale.net.sncp",
|
||||||
|
"org.redkale.persistence",
|
||||||
|
"org.redkale.service",
|
||||||
|
"org.redkale.source",
|
||||||
|
"org.redkale.util",
|
||||||
|
"org.redkale.watch"
|
||||||
};
|
};
|
||||||
|
|
||||||
//redkale里所有使用动态字节码生成的类都需要存于此处
|
//redkale里所有使用动态字节码生成的类都需要存于此处
|
||||||
@@ -473,6 +484,7 @@ public class RedkaleClassLoader extends URLClassLoader {
|
|||||||
try {
|
try {
|
||||||
set.add(Paths.get(path.replace("&&", "://").replace("##", ":\\")).toRealPath().toFile().toURI().toURL());
|
set.add(Paths.get(path.replace("&&", "://").replace("##", ":\\")).toRealPath().toFile().toURI().toURL());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -497,6 +509,7 @@ public class RedkaleClassLoader extends URLClassLoader {
|
|||||||
ucp = field.get(loader);
|
ucp = field.get(loader);
|
||||||
break;
|
break;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
} while ((loaderClazz = loaderClazz.getSuperclass()) != Object.class);
|
} while ((loaderClazz = loaderClazz.getSuperclass()) != Object.class);
|
||||||
if (ucp != null) { //URLClassPath
|
if (ucp != null) { //URLClassPath
|
||||||
@@ -505,6 +518,7 @@ public class RedkaleClassLoader extends URLClassLoader {
|
|||||||
Method method = ucp.getClass().getMethod("getURLs");
|
Method method = ucp.getClass().getMethod("getURLs");
|
||||||
urls = (URL[]) method.invoke(ucp);
|
urls = (URL[]) method.invoke(ucp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
if (urls != null) {
|
if (urls != null) {
|
||||||
for (URL url : urls) {
|
for (URL url : urls) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public abstract class TypeToken<T> {
|
|||||||
*
|
*
|
||||||
* @return 是否可反解析
|
* @return 是否可反解析
|
||||||
*/
|
*/
|
||||||
public final static boolean isClassType(final Type type) {
|
public static final boolean isClassType(final Type type) {
|
||||||
if (type instanceof Class) {
|
if (type instanceof Class) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ public abstract class TypeToken<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static boolean containsUnknownType(final Type type) {
|
public static final boolean containsUnknownType(final Type type) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public abstract class TypeToken<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static Class typeToClass(final Type type) {
|
public static final Class typeToClass(final Type type) {
|
||||||
if (type instanceof Class) {
|
if (type instanceof Class) {
|
||||||
return (Class) type;
|
return (Class) type;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public abstract class TypeToken<T> {
|
|||||||
return typeToClass(raw != null ? raw : owner);
|
return typeToClass(raw != null ? raw : owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static Class typeToClassOrElse(final Type type, final Class defClass) {
|
public static final Class typeToClassOrElse(final Type type, final Class defClass) {
|
||||||
Class clazz = typeToClass(type);
|
Class clazz = typeToClass(type);
|
||||||
return clazz == null ? defClass : clazz;
|
return clazz == null ? defClass : clazz;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,9 @@ public class XmlReader {
|
|||||||
throw newException("illegal character " + ch);
|
throw newException("illegal character " + ch);
|
||||||
}
|
}
|
||||||
} else if (ch >= 'a' && ch <= 'z') {
|
} else if (ch >= 'a' && ch <= 'z') {
|
||||||
|
//do nothing
|
||||||
} else if (ch >= 'A' && ch <= 'Z') {
|
} else if (ch >= 'A' && ch <= 'Z') {
|
||||||
|
//do nothing
|
||||||
} else if (ch == '.' || ch == '-' || ch == '_' || ch == ':') {
|
} else if (ch == '.' || ch == '-' || ch == '_' || ch == ':') {
|
||||||
if (first) {
|
if (first) {
|
||||||
throw newException("illegal character " + ch);
|
throw newException("illegal character " + ch);
|
||||||
|
|||||||
Reference in New Issue
Block a user