Renamed serial component to data, moved consumers to briar-core.

This commit is contained in:
akwizgran
2015-05-02 20:39:24 +01:00
parent 416719e3d9
commit b8e37a5421
42 changed files with 129 additions and 135 deletions

View File

@@ -0,0 +1,10 @@
package org.briarproject.api.data;
import java.io.IOException;
public interface Consumer {
void write(byte b) throws IOException;
void write(byte[] b, int off, int len) throws IOException;
}

View File

@@ -0,0 +1,12 @@
package org.briarproject.api.data;
import org.briarproject.api.UniqueId;
public interface DataConstants {
int LIST_START_LENGTH = 1;
int LIST_END_LENGTH = 1;
int UNIQUE_ID_LENGTH = 2 + UniqueId.LENGTH;
}

View File

@@ -0,0 +1,8 @@
package org.briarproject.api.data;
import java.io.IOException;
public interface ObjectReader<T> {
T readObject(Reader r) throws IOException;
}

View File

@@ -0,0 +1,48 @@
package org.briarproject.api.data;
import java.io.IOException;
public interface Reader {
boolean eof() throws IOException;
void close() throws IOException;
void addConsumer(Consumer c);
void removeConsumer(Consumer c);
boolean hasNull() throws IOException;
void readNull() throws IOException;
void skipNull() throws IOException;
boolean hasBoolean() throws IOException;
boolean readBoolean() throws IOException;
void skipBoolean() throws IOException;
boolean hasInteger() throws IOException;
long readInteger() throws IOException;
void skipInteger() throws IOException;
boolean hasFloat() throws IOException;
double readFloat() throws IOException;
void skipFloat() throws IOException;
boolean hasString() throws IOException;
String readString(int maxLength) throws IOException;
void skipString() throws IOException;
boolean hasBytes() throws IOException;
byte[] readBytes(int maxLength) throws IOException;
void skipBytes() throws IOException;
boolean hasList() throws IOException;
void readListStart() throws IOException;
boolean hasListEnd() throws IOException;
void readListEnd() throws IOException;
void skipList() throws IOException;
boolean hasMap() throws IOException;
void readMapStart() throws IOException;
boolean hasMapEnd() throws IOException;
void readMapEnd() throws IOException;
void skipMap() throws IOException;
}

View File

@@ -0,0 +1,8 @@
package org.briarproject.api.data;
import java.io.InputStream;
public interface ReaderFactory {
Reader createReader(InputStream in);
}

View File

@@ -0,0 +1,29 @@
package org.briarproject.api.data;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
public interface Writer {
void flush() throws IOException;
void close() throws IOException;
void addConsumer(Consumer c);
void removeConsumer(Consumer c);
void writeNull() throws IOException;
void writeBoolean(boolean b) throws IOException;
void writeInteger(long l) throws IOException;
void writeFloat(double d) throws IOException;
void writeString(String s) throws IOException;
void writeBytes(byte[] b) throws IOException;
void writeList(Collection<?> c) throws IOException;
void writeListStart() throws IOException;
void writeListEnd() throws IOException;
void writeMap(Map<?, ?> m) throws IOException;
void writeMapStart() throws IOException;
void writeMapEnd() throws IOException;
}

View File

@@ -0,0 +1,8 @@
package org.briarproject.api.data;
import java.io.OutputStream;
public interface WriterFactory {
Writer createWriter(OutputStream out);
}