fixed code template and format

This commit is contained in:
agapple
2015-04-28 21:11:41 +08:00
parent ea889cb004
commit 7ebb3fd1ab
86 changed files with 2763 additions and 3554 deletions

View File

@@ -14,15 +14,17 @@ import com.alibaba.otter.canal.common.utils.CanalToStringStyle;
* </pre>
*
* <br>
* The Packet Header will not be shown in the descriptions of packets that follow this section. Think of it as always
* there. But logically, it "precedes the packet" rather than "is included in the packet".<br>
* The Packet Header will not be shown in the descriptions of packets that
* follow this section. Think of it as always there. But logically, it
* "precedes the packet" rather than "is included in the packet".<br>
*
* @author fujohnwang
*/
public class HeaderPacket implements IPacket {
/**
* this field indicates the packet length that follows the header, with header packet's 4 bytes excluded.
* this field indicates the packet length that follows the header, with
* header packet's 4 bytes excluded.
*/
private int packetBodyLength;
private byte packetSequenceNumber;

View File

@@ -12,6 +12,7 @@ import java.io.IOException;
* @see 1.0
*/
public interface IPacket {
/**
* un-marshal raw bytes into {@link IPacket} state for application usage.<br>
*

View File

@@ -56,24 +56,24 @@ public class FieldPacket extends PacketWithHeaderPacket {
this.name = reader.readLengthCodedString(data);
this.originalName = reader.readLengthCodedString(data);
index = reader.getIndex();
//
//
index++;
//
//
this.character = ByteHelper.readUnsignedShortLittleEndian(data, index);
index += 2;
//
this.length = ByteHelper.readUnsignedIntLittleEndian(data, index);
index += 4;
//
//
this.type = data[index];
index++;
//
//
this.flags = ByteHelper.readUnsignedShortLittleEndian(data, index);
index += 2;
//
//
this.decimals = data[index];
index++;
//
//
if (index < data.length) {
reader.setIndex(index);
this.definition = reader.readLengthCodedString(data);

View File

@@ -75,7 +75,8 @@ public class HandshakeInitializationPacket extends PacketWithHeaderPacket {
// 8. bypass filtered bytes
index += 13;
// 9. read rest of scramble_buff
this.restOfScrambleBuff = ByteHelper.readFixedLengthBytes(data, index, 12); // 虽然Handshake Initialization
this.restOfScrambleBuff = ByteHelper.readFixedLengthBytes(data, index, 12); // 虽然Handshake
// Initialization
// Packet规定最后13个byte是剩下的scrumble,
// 但实际上最后一个字节是0, 不应该包含在scrumble中.
// end read

View File

@@ -23,7 +23,7 @@ public abstract class ByteHelper {
out.write(str.getBytes());
out.write(MSC.NULL_TERMINATED_STRING_DELIMITER);
}
public static void writeNullTerminated(byte[] data, ByteArrayOutputStream out) throws IOException {
out.write(data);
out.write(MSC.NULL_TERMINATED_STRING_DELIMITER);

View File

@@ -26,7 +26,7 @@ public class LengthCodedStringReader {
try {
return new String(ArrayUtils.subarray(data, getIndex(), (int) (getIndex() + length)),
encoding == null ? CODE_PAGE_1252 : encoding);
encoding == null ? CODE_PAGE_1252 : encoding);
} finally {
setIndex((int) (getIndex() + length));
}

View File

@@ -30,8 +30,10 @@ public abstract class PacketManager {
}
/**
* Since We r using blocking IO, so we will just write once and assert the length to simplify the read operation.<br>
* If the block write doesn't work as we expected, we will change this implementation as per the result.
* Since We r using blocking IO, so we will just write once and assert the
* length to simplify the read operation.<br>
* If the block write doesn't work as we expected, we will change this
* implementation as per the result.
*
* @param ch
* @param len