mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Cleaned up serial and protocol packages in preparation for user-defined types.
This commit is contained in:
12
api/net/sf/briar/api/serial/Consumer.java
Normal file
12
api/net/sf/briar/api/serial/Consumer.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package net.sf.briar.api.serial;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface Consumer {
|
||||
|
||||
void write(byte b) throws IOException;
|
||||
|
||||
void write(byte[] b) throws IOException;
|
||||
|
||||
void write(byte[] b, int off, int len) throws IOException;
|
||||
}
|
||||
@@ -7,11 +7,11 @@ import java.util.Map;
|
||||
public interface Reader {
|
||||
|
||||
boolean eof() throws IOException;
|
||||
void setReadLimit(long limit);
|
||||
void resetReadLimit();
|
||||
long getRawBytesRead();
|
||||
void close() throws IOException;
|
||||
|
||||
void addConsumer(Consumer c);
|
||||
void removeConsumer(Consumer c);
|
||||
|
||||
boolean hasBoolean() throws IOException;
|
||||
boolean readBoolean() throws IOException;
|
||||
|
||||
@@ -33,8 +33,8 @@ public interface Reader {
|
||||
boolean hasFloat64() throws IOException;
|
||||
double readFloat64() throws IOException;
|
||||
|
||||
boolean hasUtf8() throws IOException;
|
||||
String readUtf8() throws IOException;
|
||||
boolean hasString() throws IOException;
|
||||
String readString() throws IOException;
|
||||
boolean hasRaw() throws IOException;
|
||||
byte[] readRaw() throws IOException;
|
||||
|
||||
|
||||
@@ -2,11 +2,29 @@ package net.sf.briar.api.serial;
|
||||
|
||||
public interface Tag {
|
||||
|
||||
public static final byte FALSE = -1, TRUE = -2;
|
||||
public static final byte INT8 = -3, INT16 = -4, INT32 = -5, INT64 = -6;
|
||||
public static final byte FLOAT32 = -7, FLOAT64 = -8;
|
||||
public static final byte UTF8 = -9, RAW = -10;
|
||||
public static final byte LIST_DEF = -11, MAP_DEF = -12;
|
||||
public static final byte LIST_INDEF = -13, MAP_INDEF = -14, END = -15;
|
||||
public static final byte NULL = -16;
|
||||
public static final byte FALSE = -1; // 1111 1111
|
||||
public static final byte TRUE = -2; // 1111 1110
|
||||
public static final byte INT8 = -3; // 1111 1101
|
||||
public static final byte INT16 = -4; // 1111 1100
|
||||
public static final byte INT32 = -5; // 1111 1011
|
||||
public static final byte INT64 = -6; // 1111 1010
|
||||
public static final byte FLOAT32 = -7; // 1111 1001
|
||||
public static final byte FLOAT64 = -8; // 1111 1000
|
||||
public static final byte STRING = -9; // 1111 0111
|
||||
public static final byte RAW = -10; // 1111 0110
|
||||
public static final byte LIST = -11; // 1111 0101
|
||||
public static final byte MAP = -12; // 1111 0100
|
||||
public static final byte LIST_START = -13; // 1111 0011
|
||||
public static final byte MAP_START = -14; // 1111 0010
|
||||
public static final byte END = -15; // 1111 0001
|
||||
public static final byte NULL = -16; // 1111 0000
|
||||
|
||||
public static final int SHORT_MASK = 0xF0; // Match first four bits
|
||||
public static final int SHORT_STRING = 0x80; // 1000 xxxx
|
||||
public static final int SHORT_RAW = 0x90; // 1001 xxxx
|
||||
public static final int SHORT_LIST = 0xA0; // 1010 xxxx
|
||||
public static final int SHORT_MAP = 0xB0; // 1011 xxxx
|
||||
public static final int USER_MASK = 0xE0; // Match first three bits
|
||||
public static final int USER = 0xC0; // 110x xxxx
|
||||
public static final byte USER_EXT = -32; // 1110 0000
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Map;
|
||||
|
||||
public interface Writer {
|
||||
|
||||
long getRawBytesWritten();
|
||||
long getBytesWritten();
|
||||
void close() throws IOException;
|
||||
|
||||
void writeBoolean(boolean b) throws IOException;
|
||||
@@ -21,7 +21,7 @@ public interface Writer {
|
||||
void writeFloat32(float f) throws IOException;
|
||||
void writeFloat64(double d) throws IOException;
|
||||
|
||||
void writeUtf8(String s) throws IOException;
|
||||
void writeString(String s) throws IOException;
|
||||
void writeRaw(byte[] b) throws IOException;
|
||||
void writeRaw(Raw r) throws IOException;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user