类 ProtobufProxy
java.lang.Object
com.baidu.bjf.remoting.protobuf.ProtobufProxy
A simple protocol buffer encode and decode utility tool.
example code as follow: User user = new User(); ... Codeccodec = ProtobufProxy.create(User.class); // do encode byte[] result = codec.encode(user); // do decode User user2 = codec.decode(result);
- 从以下版本开始:
- 1.0.0
- 作者:
- xiemalin
-
字段概要
字段修饰符和类型字段说明static final ThreadLocal<Boolean>The Constant OUTPUT_PATH for target directory to create generated source code out.static final ThreadLocal<Boolean>The Constant DEBUG_CONTROLLER.static final ThreadLocal<File>The Constant OUTPUT_PATH for target directory to create generated source code out. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidClear cache.static voidCompile.static <T> Codec<T>To create a protobuf proxy class for target class.static <T> Codec<T>Creates the.static <T> Codec<T>To create a protobuf proxy class for target class.static <T> Codec<T>create(Class<T> cls, boolean debug, File path, Compiler compiler, ICodeGenerator codeGenerator) To create a protobuf proxy class for target class.static <T> Codec<T>create(Class<T> cls, Compiler compiler, ICodeGenerator codeGenerator) To create a protobuf proxy class for target class.protected static <T> Codec<T>doCreate(Class<T> cls, boolean debug, Compiler compiler, ICodeGenerator cg) To create a protobuf proxy class for target class.static voiddynamicCodeGenerate(OutputStream os, Class cls, Charset charset) To generate a protobuf proxy java source code for target class.static voiddynamicCodeGenerate(OutputStream os, Class cls, Charset charset, ICodeGenerator codeGenerator) To generate a protobuf proxy java source code for target class.static voidenableCache(boolean enabled) Enable cache.static StringgetFullClassName(Class cls) Gets the full class name.static booleanChecks if is cache enabled.static booleanChecks if is debug enabled.
-
字段详细资料
-
DEBUG_CONTROLLER
The Constant DEBUG_CONTROLLER. -
OUTPUT_PATH
The Constant OUTPUT_PATH for target directory to create generated source code out. -
CACHE_ENABLED
The Constant OUTPUT_PATH for target directory to create generated source code out.
-
-
构造器详细资料
-
ProtobufProxy
public ProtobufProxy()
-
-
方法详细资料
-
clearCache
public static void clearCache()Clear cache. -
compile
Compile.- 参数:
cls- target class to be compiledoutputPath- compile byte files output stream
-
create
To create a protobuf proxy class for target class.- 类型参数:
T- generic type- 参数:
cls- target class to parse@Protobufannotation- 返回:
Codecinstance proxy
-
create
Creates the.- 类型参数:
T- the generic type- 参数:
cls- the clsdebug- the debug- 返回:
- the codec
-
create
To create a protobuf proxy class for target class.- 类型参数:
T- target object type to be proxied.- 参数:
cls- target object classdebug- true will print generate java source codepath- the path- 返回:
- proxy instance object.
-
create
public static <T> Codec<T> create(Class<T> cls, boolean debug, File path, Compiler compiler, ICodeGenerator codeGenerator) To create a protobuf proxy class for target class.- 类型参数:
T- target object type to be proxied.- 参数:
cls- target object classdebug- true will print generate java source codepath- the pathcompiler- the compilercodeGenerator- the code generator- 返回:
- proxy instance object.
-
create
To create a protobuf proxy class for target class.- 类型参数:
T- generic type- 参数:
cls- target class to parse@Protobufannotationcompiler- the compilercodeGenerator- the code generator- 返回:
Codecinstance proxy
-
doCreate
protected static <T> Codec<T> doCreate(Class<T> cls, boolean debug, Compiler compiler, ICodeGenerator cg) To create a protobuf proxy class for target class.- 类型参数:
T- target object type to be proxied.- 参数:
cls- target object classdebug- true will print generate java source codecompiler- the compilercg- the cg- 返回:
- proxy instance object.
-
dynamicCodeGenerate
public static void dynamicCodeGenerate(OutputStream os, Class cls, Charset charset) throws IOException To generate a protobuf proxy java source code for target class.- 参数:
os- to generate java source codecls- target classcharset- charset type- 抛出:
IOException- in case of any io relative exception.
-
dynamicCodeGenerate
public static void dynamicCodeGenerate(OutputStream os, Class cls, Charset charset, ICodeGenerator codeGenerator) throws IOException To generate a protobuf proxy java source code for target class.- 参数:
os- to generate java source codecls- target classcharset- charset typecodeGenerator- the code generator- 抛出:
IOException- in case of any io relative exception.
-
enableCache
public static void enableCache(boolean enabled) Enable cache.- 参数:
enabled- the enabled
-
getFullClassName
Gets the full class name.- 参数:
cls- the cls- 返回:
- the full class name
-
isCacheEnabled
public static boolean isCacheEnabled()Checks if is cache enabled.- 返回:
- true, if is cache enabled
-
isDebugEnabled
public static boolean isDebugEnabled()Checks if is debug enabled.- 返回:
- true, if is debug enabled
-