增加javadoc注释

This commit is contained in:
Redkale
2017-02-27 11:56:18 +08:00
parent 2979fcc33d
commit 26ffb04834
39 changed files with 116 additions and 76 deletions

View File

@@ -9,7 +9,8 @@ import java.lang.reflect.*;
import java.util.*;
/**
* 对象数组的序列化不包含int[]、long[]这样的primitive class数组.
* 数组的序列化操作类
* 对象数组的反序列化不包含int[]、long[]这样的primitive class数组。
* 数组长度不能超过 32767。 在BSON中数组长度设定的是short对于大于32767长度的数组传输会影响性能所以没有采用int存储。
* 支持一定程度的泛型。
*

View File

@@ -8,7 +8,8 @@ package org.redkale.convert;
import java.lang.reflect.*;
/**
* 对象数组的序列化不包含int[]、long[]这样的primitive class数组.
* 数组的序列化操作类
* 对象数组的序列化不包含int[]、long[]这样的primitive class数组。
* 数组长度不能超过 32767。 在BSON中数组长度设定的是short对于大于32767长度的数组传输会影响性能所以没有必要采用int存储。
* 支持一定程度的泛型。
*

View File

@@ -11,7 +11,7 @@ import java.lang.reflect.Type;
import java.util.Collection;
/**
* 对象集合的反序列化.
* Collection的反序列化操作类
* 集合大小不能超过 32767。 在BSON中集合大小设定的是short对于大于32767长度的集合传输会影响性能所以没有采用int存储。
* 支持一定程度的泛型。
*

View File

@@ -9,8 +9,8 @@ import java.lang.reflect.*;
import java.util.Collection;
/**
* 对象集合的序列化.
* 集合大小不能超过 32767。 在BSON中集合大小设定的是short对于大于32767长度的集合传输会影响性能所以没有采用int存储。
* Collection的序列化操作类
* 集合大小不能超过 32767。 在BSON中集合大小设定的是short对于大于32767长度的集合传输会影响性能没有采用int存储。
* 支持一定程度的泛型。
*
* <p>

View File

@@ -6,7 +6,7 @@
package org.redkale.convert;
/**
* 序列化操作类
* 序列化/反序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -10,11 +10,13 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.*;
/**
* 用于类名的别名 类似javax.persistence.Table
* 用于类名的别名
* 该值必须是全局唯一
* 使用场景: 当BSON序列化为了不指定class可以使用@ConvertEntity来取个别名。关联方法: Reader.readClassName() 和 Writer.writeClassName(String value) 。
* 使用场景: 当BSON序列化为了不指定class可以使用@ConvertEntity来取个别名。关联方法: Reader.readClassName() 和 Writer.writeClassName(String value) 。
*
* <p>
* 详情见: https://redkale.org
*
* <p> 详情见: https://redkale.org
* @author zhangjx
*/
@Inherited
@@ -23,5 +25,10 @@ import java.lang.annotation.*;
@Retention(RUNTIME)
public @interface ConvertEntity {
/**
* 别名值
*
* @return String
*/
String value();
}

View File

@@ -5,8 +5,11 @@
package org.redkale.convert;
/**
* 序列化自定义异常类
*
* <p>
* 详情见: https://redkale.org
*
* <p> 详情见: https://redkale.org
* @author zhangjx
*/
public class ConvertException extends RuntimeException {

View File

@@ -17,6 +17,7 @@ import org.redkale.convert.ext.*;
import org.redkale.util.*;
/**
* 序列化模块的工厂类用于注册自定义的序列化类型获取Convert
*
* <p>
* 详情见: https://redkale.org

View File

@@ -6,8 +6,11 @@
package org.redkale.convert;
/**
* 序列化类型枚举,结合&#64;ConvertColumn使用
*
* <p>
* 详情见: https://redkale.org
*
* <p> 详情见: https://redkale.org
* @author zhangjx
*/
public enum ConvertType {

View File

@@ -9,6 +9,7 @@ import java.lang.reflect.*;
import org.redkale.util.Attribute;
/**
* 字段的反序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -8,6 +8,7 @@ package org.redkale.convert;
import java.lang.reflect.Type;
/**
* 反序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -9,6 +9,7 @@ import java.lang.reflect.*;
import org.redkale.util.Attribute;
/**
* 字段的序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -8,6 +8,7 @@ package org.redkale.convert;
import java.lang.reflect.Type;
/**
* 序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -11,6 +11,7 @@ import java.lang.reflect.Type;
import java.util.Map;
/**
* Map的反序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -10,6 +10,7 @@ import java.lang.reflect.Type;
import java.util.Map;
/**
* Map的序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -13,6 +13,7 @@ import java.util.Set;
import org.redkale.util.*;
/**
* 自定义对象的反序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -10,6 +10,7 @@ import java.util.*;
import org.redkale.util.*;
/**
* 自定义对象的序列化操作类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -6,6 +6,7 @@
package org.redkale.convert;
/**
* 反序列化的数据读取流
*
* <p>
* 详情见: https://redkale.org
@@ -42,6 +43,7 @@ public abstract class Reader {
* 读取对象的类名, 返回 null 表示对象为null 返回空字符串表示当前class与返回的class一致返回非空字符串表示class是当前class的子类。
*
* @param clazz 类名
*
* @return 返回字段数
*/
public String readObjectB(final Class clazz) {
@@ -86,6 +88,7 @@ public abstract class Reader {
* 根据字段读取字段对应的DeMember
*
* @param members DeMember的全量集合
*
* @return 匹配的DeMember
*/
public abstract DeMember readFieldName(final DeMember[] members);

View File

@@ -9,6 +9,8 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
* 简易类的序列化和反序列化操作类
* 能序列化为Boolean、Number或者字符串的类视为简易类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -8,6 +8,7 @@ package org.redkale.convert;
import org.redkale.util.Attribute;
/**
* 序列化的数据输出流
*
* <p>
* 详情见: https://redkale.org
@@ -37,7 +38,7 @@ public abstract class Writer {
* @return boolean
*/
public abstract boolean needWriteClassName();
/**
* 写入类名
*

View File

@@ -15,21 +15,21 @@ import org.redkale.util.*;
/**
* <blockquote><pre>
* BSON协议格式:
* 1). 基本数据类型: 直接转换成byte[]
* 2). SmallString(无特殊字符且长度小于256的字符串): length(1 byte) + byte[](utf8); 通常用于类名、字段名、枚举。
* 3). String: length(4 bytes) + byte[](utf8);
* 4). 数组: length(4 bytes) + byte[]...
* 5). Object:
* 1. realclass (SmallString) (如果指定格式化的class与实体对象的class不一致才会有该值, 该值可以使用@ConvertEntity给其取个别名)
* 2. 空字符串(SmallString)
* 3. SIGN_OBJECTB 标记位值固定为0xBB (short)
* 4. 循环字段值:
* 1) 基本数据类型: 直接转换成byte[]
* 2) SmallString(无特殊字符且长度小于256的字符串): length(1 byte) + byte[](utf8); 通常用于类名、字段名、枚举。
* 3) String: length(4 bytes) + byte[](utf8);
* 4) 数组: length(4 bytes) + byte[]...
* 5) Object:
* 1 realclass (SmallString) (如果指定格式化的class与实体对象的class不一致才会有该值, 该值可以使用@ConvertEntity给其取个别名)
* 2 空字符串(SmallString)
* 3 SIGN_OBJECTB 标记位值固定为0xBB (short)
* 4 循环字段值:
* 4.1 SIGN_HASNEXT 标记位值固定为1 (byte)
* 4.2 字段类型; 1-9为基本类型和字符串; 101-109为基本类型和字符串的数组; 127为Object
* 4.3 字段名 (SmallString)
* 4.4 字段的值Object
* 5. SIGN_NONEXT 标记位值固定为0 (byte)
* 6. SIGN_OBJECTE 标记位值固定为0xEE (short)
* 5 SIGN_NONEXT 标记位值固定为0 (byte)
* 6 SIGN_OBJECTE 标记位值固定为0xEE (short)
*
* </pre></blockquote>
* <p>

View File

@@ -5,7 +5,6 @@
*/
package org.redkale.convert.bson;
import java.util.function.*;
import org.redkale.convert.*;
import static org.redkale.convert.Reader.SIGN_NULL;
import org.redkale.convert.ext.*;
@@ -42,19 +41,7 @@ public class BsonReader extends Reader {
}
public static ObjectPool<BsonReader> createPool(int max) {
return new ObjectPool<BsonReader>(max, new Creator<BsonReader>() {
@Override
public BsonReader create(Object... params) {
return new BsonReader();
}
}, null, new Predicate<BsonReader>() {
@Override
public boolean test(BsonReader t) {
return t.recycle();
}
});
return new ObjectPool<>(max, (Object... params) -> new BsonReader(), null, (t) -> t.recycle());
}
public BsonReader(byte[] bytes) {
@@ -164,7 +151,7 @@ public class BsonReader extends Reader {
if (bt == Reader.SIGN_NULL) return null;
if (bt != SIGN_OBJECTB) {
throw new ConvertException("a bson object must begin with " + (SIGN_OBJECTB)
+ " (position = " + position + ") but '" + currentByte() + "'");
+ " (position = " + position + ") but '" + currentByte() + "'");
}
return "";
}
@@ -173,7 +160,7 @@ public class BsonReader extends Reader {
public final void readObjectE(final Class clazz) {
if (readShort() != SIGN_OBJECTE) {
throw new ConvertException("a bson object must end with " + (SIGN_OBJECTE)
+ " (position = " + position + ") but '" + currentByte() + "'");
+ " (position = " + position + ") but '" + currentByte() + "'");
}
}
@@ -223,7 +210,7 @@ public class BsonReader extends Reader {
byte b = readByte();
if (b == SIGN_HASNEXT) return true;
if (b != SIGN_NONEXT) throw new ConvertException("hasNext option must be (" + (SIGN_HASNEXT)
+ " or " + (SIGN_NONEXT) + ") but '" + b + "' at position(" + this.position + ")");
+ " or " + (SIGN_NONEXT) + ") but '" + b + "' at position(" + this.position + ")");
return false;
}
@@ -272,19 +259,19 @@ public class BsonReader extends Reader {
@Override
public int readInt() {
return ((content[++this.position] & 0xff) << 24) | ((content[++this.position] & 0xff) << 16)
| ((content[++this.position] & 0xff) << 8) | (content[++this.position] & 0xff);
| ((content[++this.position] & 0xff) << 8) | (content[++this.position] & 0xff);
}
@Override
public long readLong() {
return ((((long) content[++this.position] & 0xff) << 56)
| (((long) content[++this.position] & 0xff) << 48)
| (((long) content[++this.position] & 0xff) << 40)
| (((long) content[++this.position] & 0xff) << 32)
| (((long) content[++this.position] & 0xff) << 24)
| (((long) content[++this.position] & 0xff) << 16)
| (((long) content[++this.position] & 0xff) << 8)
| (((long) content[++this.position] & 0xff)));
| (((long) content[++this.position] & 0xff) << 48)
| (((long) content[++this.position] & 0xff) << 40)
| (((long) content[++this.position] & 0xff) << 32)
| (((long) content[++this.position] & 0xff) << 24)
| (((long) content[++this.position] & 0xff) << 16)
| (((long) content[++this.position] & 0xff) << 8)
| (((long) content[++this.position] & 0xff)));
}
@Override

View File

@@ -6,7 +6,6 @@
package org.redkale.convert.bson;
import java.nio.ByteBuffer;
import java.util.function.Predicate;
import org.redkale.convert.*;
import org.redkale.util.*;
@@ -28,19 +27,7 @@ public class BsonWriter extends Writer {
protected boolean tiny;
public static ObjectPool<BsonWriter> createPool(int max) {
return new ObjectPool<BsonWriter>(max, new Creator<BsonWriter>() {
@Override
public BsonWriter create(Object... params) {
return new BsonWriter();
}
}, null, new Predicate<BsonWriter>() {
@Override
public boolean test(BsonWriter t) {
return t.recycle();
}
});
return new ObjectPool<>(max, (Object... params) -> new BsonWriter(), null, (t) -> t.recycle());
}
public byte[] toArray() {
@@ -82,6 +69,7 @@ public class BsonWriter extends Writer {
* 扩充指定长度的缓冲区
*
* @param len 扩容长度
*
* @return 固定0
*/
protected int expand(int len) {

View File

@@ -17,47 +17,65 @@ import org.redkale.util.*;
import org.redkale.watch.*;
/**
* 服务器上下文对象
*
* <p>
* 详情见: https://redkale.org
*
* <p> 详情见: https://redkale.org
* @author zhangjx
*/
public class Context {
private static final Charset UTF8 = Charset.forName("UTF-8");
//服务启动时间
protected final long serverStartTime;
//Server的线程池
protected final ExecutorService executor;
//ByteBuffer的容量默认8K
protected final int bufferCapacity;
//ByteBuffer对象池
protected final ObjectPool<ByteBuffer> bufferPool;
//Response对象池
protected final ObjectPool<Response> responsePool;
//服务的根Servlet
protected final PrepareServlet prepare;
//服务的监听地址
private final InetSocketAddress address;
//字符集
protected final Charset charset;
//请求内容的大小上限, 默认64K
protected final int maxbody;
//IO读取的超时时间
protected final int readTimeoutSecond;
//IO写入的超时时间
protected final int writeTimeoutSecond;
//日志Logger
protected final Logger logger;
//BSON操作工厂
protected final BsonFactory bsonFactory;
//JSON操作工厂
protected final JsonFactory jsonFactory;
//监控对象
protected final WatchFactory watch;
public Context(long serverStartTime, Logger logger, ExecutorService executor, int bufferCapacity, ObjectPool<ByteBuffer> bufferPool, ObjectPool<Response> responsePool,
final int maxbody, Charset charset, InetSocketAddress address, final PrepareServlet prepare, final WatchFactory watch,
final int readTimeoutSecond, final int writeTimeoutSecond) {
final int maxbody, Charset charset, InetSocketAddress address, final PrepareServlet prepare, final WatchFactory watch,
final int readTimeoutSecond, final int writeTimeoutSecond) {
this.serverStartTime = serverStartTime;
this.logger = logger;
this.executor = executor;

View File

@@ -11,8 +11,11 @@ import java.util.logging.*;
import org.redkale.util.*;
/**
* 根Servlet的处理逻辑类
*
* <p>
* 详情见: https://redkale.org
*
* <p> 详情见: https://redkale.org
* @author zhangjx
*/
@SuppressWarnings("unchecked")

View File

@@ -14,6 +14,9 @@ import java.util.logging.*;
import org.redkale.util.*;
/**
* 根Servlet 一个Server只能存在一个根Servlet
*
* 用于分发Request请求
*
* <p>
* 详情见: https://redkale.org

View File

@@ -13,6 +13,7 @@ import java.util.*;
import java.util.concurrent.*;
/**
* 协议底层Server
*
* <p> 详情见: https://redkale.org
* @author zhangjx

View File

@@ -11,6 +11,7 @@ import org.redkale.convert.bson.BsonConvert;
import org.redkale.convert.json.JsonConvert;
/**
* 协议请求对象
*
* <p>
* 详情见: https://redkale.org

View File

@@ -10,6 +10,7 @@ import java.nio.channels.CompletionHandler;
import java.util.function.BiConsumer;
/**
* 协议响应对象
*
* <p>
* 详情见: https://redkale.org

View File

@@ -9,6 +9,7 @@ import org.redkale.util.AnyValue;
import java.io.IOException;
/**
* 协议请求处理类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -8,8 +8,11 @@ package org.redkale.net;
import java.util.concurrent.*;
/**
* 协议处理的自定义线程类
*
* <p>
* 详情见: https://redkale.org
*
* <p> 详情见: https://redkale.org
* @author zhangjx
*/
public class WorkThread extends Thread {

View File

@@ -155,7 +155,7 @@ public class HttpPrepareServlet extends PrepareServlet<String, HttpContext, Http
/**
* 设置静态资源HttpServlet
*
* @param servlet
* @param servlet HttpServlet
*/
public void setResourceServlet(HttpServlet servlet) {
if (servlet != null) {

View File

@@ -81,7 +81,7 @@ public final class MultiContext {
/**
* 判断请求是否包含上传文件
*
* @return
* @return boolean
*/
public boolean isMultipart() {
return this.boundary != null;
@@ -90,8 +90,8 @@ public final class MultiContext {
/**
* 获取上传文件信息列表
*
* @return
* @throws IOException
* @return Iterable
* @throws IOException IOException
*/
public Iterable<MultiPart> parts() throws IOException {
if (!isMultipart()) return emptyIterable;

View File

@@ -25,7 +25,7 @@ public @interface RestHeader {
/**
* Header参数名
*
* @return
* @return String
*/
String name();

View File

@@ -26,14 +26,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface RestParam {
//name='&'表示当前用户;
/**
* 参数名 n
* ame='&'表示当前用户;
* 参数名
* name='&#38;'表示当前用户;
* name='#'表示截取uri最后一段;
* name='#xxx:'表示从uri中/pipes/xxx:v/截取xxx:的值
*
* @return String
*/
*/
String name();
/**

View File

@@ -37,7 +37,7 @@ public @interface WebInitParam {
/**
* 参数描述
*
* @return
* @return String
*/
String description() default "";
}

View File

@@ -10,6 +10,7 @@ import static org.redkale.source.ColumnExpress.*;
/**
* ColumnValue主要用于多个字段更新的表达式。
* 用于 DataSource.updateColumn 方法
*
* <p>
* 详情见: https://redkale.org

View File

@@ -17,6 +17,7 @@ import static org.redkale.source.FilterFunc.*;
import org.redkale.util.*;
/**
* Entity数据的缓存类
*
* <p>
* 详情见: https://redkale.org

View File

@@ -18,6 +18,7 @@ import static org.redkale.source.DataDefaultSource.*;
import org.redkale.util.*;
/**
* Entity操作类
*
* <p>
* 详情见: https://redkale.org