List of usage examples for io.netty.buffer ByteBuf writeByte
public abstract ByteBuf writeByte(int value);
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static void writeTimestamp(ByteBuf buf, Timestamp date) { buf.writeByte(11); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w . j av a 2 s . c om*/ BufferUtils.writeUB2(buf, cal.get(Calendar.YEAR)); buf.writeByte(cal.get(Calendar.MONTH) + 1); buf.writeByte(cal.get(Calendar.DAY_OF_MONTH)); buf.writeByte(cal.get(Calendar.HOUR_OF_DAY)); buf.writeByte(cal.get(Calendar.MINUTE)); buf.writeByte(cal.get(Calendar.SECOND)); BufferUtils.writeUB4(buf, cal.get(Calendar.MILLISECOND) * 1000); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static void writeDate(ByteBuf buf, java.util.Date date) { buf.writeByte(7); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w .j a v a 2s . c o m*/ BufferUtils.writeUB2(buf, cal.get(Calendar.YEAR)); buf.writeByte(cal.get(Calendar.MONTH) + 1); buf.writeByte(cal.get(Calendar.DAY_OF_MONTH)); buf.writeByte(cal.get(Calendar.HOUR_OF_DAY)); buf.writeByte(cal.get(Calendar.MINUTE)); buf.writeByte(cal.get(Calendar.SECOND)); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static final void writeLength(ByteBuf buffer, long l) { if (l < 251) { buffer.writeByte((byte) l); } else if (l < 0x10000L) { buffer.writeByte((byte) 252); writeUB2(buffer, (int) l); } else if (l < 0x1000000L) { buffer.writeByte((byte) 253); writeUB3(buffer, (int) l); } else {//from w w w. ja va 2 s .com buffer.writeByte((byte) 254); writeUB4(buffer, l); } }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static final void writeUB2(ByteBuf buf, int i) { buf.writeByte((byte) (i & 0xff)); buf.writeByte((byte) (i >>> 8)); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static final void writeUB3(ByteBuf buf, int i) { buf.writeByte((byte) (i & 0xff)); buf.writeByte((byte) (i >>> 8)); buf.writeByte((byte) (i >>> 16)); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static final void writeUB4(ByteBuf buf, long l) { buf.writeByte((byte) (l & 0xff)); buf.writeByte((byte) (l >>> 8)); buf.writeByte((byte) (l >>> 16)); buf.writeByte((byte) (l >>> 24)); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static void writeLongInt(ByteBuf buf, int length) { buf.writeByte((byte) (length & 0xff)); buf.writeByte((byte) (length >>> 8)); buf.writeByte((byte) (length >>> 16)); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static void writeLengthInt(ByteBuf buf, long value) { if (value < 251) { buf.writeByte((int) value); } else if (value < Math.pow(2, 16)) { buf.writeByte(0xfc);/* w ww . j a v a 2 s . c om*/ buf.writeByte((int) (value & 0xff)); buf.writeByte((int) (value >>> 8)); } else if (value < Math.pow(2, 24)) { buf.writeByte(0xfd); buf.writeByte((int) (value & 0xff)); buf.writeByte((int) (value >>> 8)); buf.writeByte((int) (value >>> 16)); } else if (value < Math.pow(2, 64)) { buf.writeByte(0xfe); buf.writeByte((int) (value & 0xff)); buf.writeByte((int) (value >>> 8)); buf.writeByte((int) (value >>> 16)); buf.writeByte((int) (value >>> 24)); buf.writeByte((int) (value >>> 32)); buf.writeByte((int) (value >>> 40)); buf.writeByte((int) (value >>> 48)); buf.writeByte((int) (value >>> 56)); } ; }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static void writeInt(ByteBuf buf, int i) { buf.writeByte((byte) (i & 0xff)); buf.writeByte((byte) (i >>> 8)); }
From source file:com.antsdb.saltedfish.server.mysql.util.BufferUtils.java
License:Open Source License
public static void writeLong(ByteBuf buf, long i) { buf.writeByte((byte) (i & 0xff)); buf.writeByte((byte) (i >>> 8)); buf.writeByte((byte) (i >>> 16)); buf.writeByte((byte) (i >>> 24)); }