重新格式化所有java代码

This commit is contained in:
veryben
2017-05-19 09:56:24 +08:00
parent 69417006f4
commit 75931a8053
32 changed files with 7826 additions and 8880 deletions
@@ -1,10 +1,10 @@
/**
* Copyright (C) 2008 Happy Fish / YuQing
*
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
* General Public License (LGPL).
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
*/
* Copyright (C) 2008 Happy Fish / YuQing
* <p>
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
* General Public License (LGPL).
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
*/
package org.csource.fastdfs;
@@ -12,73 +12,62 @@ import java.io.UnsupportedEncodingException;
import java.util.Date;
/**
* C struct body decoder
* @author Happy Fish / YuQing
* @version Version 1.17
*/
public abstract class StructBase
{
protected static class FieldInfo
{
protected String name;
protected int offset;
protected int size;
public FieldInfo(String name, int offset, int size)
{
this.name = name;
this.offset = offset;
this.size = size;
}
}
/**
* set fields
* @param bs byte array
* @param offset start offset
*/
public abstract void setFields(byte[] bs, int offset);
protected String stringValue(byte[] bs, int offset, FieldInfo filedInfo)
{
try
{
return (new String(bs, offset + filedInfo.offset, filedInfo.size, ClientGlobal.g_charset)).trim();
}
catch(UnsupportedEncodingException ex)
{
ex.printStackTrace();
return null;
}
}
protected long longValue(byte[] bs, int offset, FieldInfo filedInfo)
{
return ProtoCommon.buff2long(bs, offset + filedInfo.offset);
}
protected int intValue(byte[] bs, int offset, FieldInfo filedInfo)
{
return (int)ProtoCommon.buff2long(bs, offset + filedInfo.offset);
}
protected int int32Value(byte[] bs, int offset, FieldInfo filedInfo)
{
return ProtoCommon.buff2int(bs, offset + filedInfo.offset);
}
* C struct body decoder
*
* @author Happy Fish / YuQing
* @version Version 1.17
*/
public abstract class StructBase {
/**
* set fields
*
* @param bs byte array
* @param offset start offset
*/
public abstract void setFields(byte[] bs, int offset);
protected byte byteValue(byte[] bs, int offset, FieldInfo filedInfo)
{
return bs[offset + filedInfo.offset];
}
protected String stringValue(byte[] bs, int offset, FieldInfo filedInfo) {
try {
return (new String(bs, offset + filedInfo.offset, filedInfo.size, ClientGlobal.g_charset)).trim();
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
return null;
}
}
protected boolean booleanValue(byte[] bs, int offset, FieldInfo filedInfo)
{
return bs[offset + filedInfo.offset] != 0;
}
protected Date dateValue(byte[] bs, int offset, FieldInfo filedInfo)
{
return new Date(ProtoCommon.buff2long(bs, offset + filedInfo.offset) * 1000);
}
protected long longValue(byte[] bs, int offset, FieldInfo filedInfo) {
return ProtoCommon.buff2long(bs, offset + filedInfo.offset);
}
protected int intValue(byte[] bs, int offset, FieldInfo filedInfo) {
return (int) ProtoCommon.buff2long(bs, offset + filedInfo.offset);
}
protected int int32Value(byte[] bs, int offset, FieldInfo filedInfo) {
return ProtoCommon.buff2int(bs, offset + filedInfo.offset);
}
protected byte byteValue(byte[] bs, int offset, FieldInfo filedInfo) {
return bs[offset + filedInfo.offset];
}
protected boolean booleanValue(byte[] bs, int offset, FieldInfo filedInfo) {
return bs[offset + filedInfo.offset] != 0;
}
protected Date dateValue(byte[] bs, int offset, FieldInfo filedInfo) {
return new Date(ProtoCommon.buff2long(bs, offset + filedInfo.offset) * 1000);
}
protected static class FieldInfo {
protected String name;
protected int offset;
protected int size;
public FieldInfo(String name, int offset, int size) {
this.name = name;
this.offset = offset;
this.size = size;
}
}
}