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

@@ -1,4 +1,4 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import java.io.IOException;

View File

@@ -1,8 +1,8 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import org.briarproject.api.UniqueId;
public interface SerialConstants {
public interface DataConstants {
int LIST_START_LENGTH = 1;

View File

@@ -1,4 +1,4 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import java.io.IOException;

View File

@@ -1,4 +1,4 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import java.io.IOException;

View File

@@ -1,4 +1,4 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import java.io.InputStream;

View File

@@ -1,4 +1,4 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import java.io.IOException;
import java.util.Collection;

View File

@@ -1,4 +1,4 @@
package org.briarproject.api.serial;
package org.briarproject.api.data;
import java.io.OutputStream;

View File

@@ -1,22 +0,0 @@
package org.briarproject.api.serial;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/** A consumer that makes a copy of the bytes consumed. */
public class CopyingConsumer implements Consumer {
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
public byte[] getCopy() {
return out.toByteArray();
}
public void write(byte b) throws IOException {
out.write(b);
}
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
}
}

View File

@@ -1,33 +0,0 @@
package org.briarproject.api.serial;
import java.io.IOException;
import org.briarproject.api.FormatException;
/**
* A consumer that counts the number of bytes consumed and throws a
* FormatException if the count exceeds a given limit.
*/
public class CountingConsumer implements Consumer {
private final long limit;
private long count = 0;
public CountingConsumer(long limit) {
this.limit = limit;
}
public long getCount() {
return count;
}
public void write(byte b) throws IOException {
count++;
if(count > limit) throw new FormatException();
}
public void write(byte[] b, int off, int len) throws IOException {
count += len;
if(count > limit) throw new FormatException();
}
}

View File

@@ -1,21 +0,0 @@
package org.briarproject.api.serial;
import org.briarproject.api.crypto.MessageDigest;
/** A consumer that passes its input through a message digest. */
public class DigestingConsumer implements Consumer {
private final MessageDigest messageDigest;
public DigestingConsumer(MessageDigest messageDigest) {
this.messageDigest = messageDigest;
}
public void write(byte b) {
messageDigest.update(b);
}
public void write(byte[] b, int off, int len) {
messageDigest.update(b, off, len);
}
}

View File

@@ -1,21 +0,0 @@
package org.briarproject.api.serial;
import org.briarproject.api.crypto.Signature;
/** A consumer that passes its input through a signature. */
public class SigningConsumer implements Consumer {
private final Signature signature;
public SigningConsumer(Signature signature) {
this.signature = signature;
}
public void write(byte b) {
signature.update(b);
}
public void write(byte[] b, int off, int len) {
signature.update(b, off, len);
}
}