diff --git a/api/net/sf/briar/api/protocol/AuthorId.java b/api/net/sf/briar/api/protocol/AuthorId.java index a353f2766..c34d32c05 100644 --- a/api/net/sf/briar/api/protocol/AuthorId.java +++ b/api/net/sf/briar/api/protocol/AuthorId.java @@ -16,7 +16,7 @@ public class AuthorId extends UniqueId { } public void writeTo(Writer w) throws IOException { - w.writeUserDefinedTag(Tags.AUTHOR_ID); + w.writeUserDefinedTag(Types.AUTHOR_ID); w.writeBytes(id); } diff --git a/api/net/sf/briar/api/protocol/BatchId.java b/api/net/sf/briar/api/protocol/BatchId.java index 95949e087..f2b2f542f 100644 --- a/api/net/sf/briar/api/protocol/BatchId.java +++ b/api/net/sf/briar/api/protocol/BatchId.java @@ -16,7 +16,7 @@ public class BatchId extends UniqueId { } public void writeTo(Writer w) throws IOException { - w.writeUserDefinedTag(Tags.BATCH_ID); + w.writeUserDefinedTag(Types.BATCH_ID); w.writeBytes(id); } diff --git a/api/net/sf/briar/api/protocol/GroupId.java b/api/net/sf/briar/api/protocol/GroupId.java index 6621777de..aa34e728a 100644 --- a/api/net/sf/briar/api/protocol/GroupId.java +++ b/api/net/sf/briar/api/protocol/GroupId.java @@ -16,7 +16,7 @@ public class GroupId extends UniqueId { } public void writeTo(Writer w) throws IOException { - w.writeUserDefinedTag(Tags.GROUP_ID); + w.writeUserDefinedTag(Types.GROUP_ID); w.writeBytes(id); } diff --git a/api/net/sf/briar/api/protocol/MessageId.java b/api/net/sf/briar/api/protocol/MessageId.java index 10ba76d73..e70a44f76 100644 --- a/api/net/sf/briar/api/protocol/MessageId.java +++ b/api/net/sf/briar/api/protocol/MessageId.java @@ -17,7 +17,7 @@ public class MessageId extends UniqueId { } public void writeTo(Writer w) throws IOException { - w.writeUserDefinedTag(Tags.MESSAGE_ID); + w.writeUserDefinedTag(Types.MESSAGE_ID); w.writeBytes(id); } diff --git a/api/net/sf/briar/api/protocol/Tags.java b/api/net/sf/briar/api/protocol/Types.java similarity index 66% rename from api/net/sf/briar/api/protocol/Tags.java rename to api/net/sf/briar/api/protocol/Types.java index 77ca61c57..54dc03d96 100644 --- a/api/net/sf/briar/api/protocol/Tags.java +++ b/api/net/sf/briar/api/protocol/Types.java @@ -1,11 +1,7 @@ package net.sf.briar.api.protocol; -/** - * User-defined tags for encoding and decoding protocol objects. An object - * should have a user-defined tag if it appears in a list or a map, or if - * objects of different types may be encountered in a given protocol state. - */ -public interface Tags { +/** User-defined type identifiers for encoding and decoding protocol objects. */ +public interface Types { static final int ACK = 0; static final int AUTHOR = 1; diff --git a/api/net/sf/briar/api/serial/Reader.java b/api/net/sf/briar/api/serial/Reader.java index c00acfe93..1b41585f0 100644 --- a/api/net/sf/briar/api/serial/Reader.java +++ b/api/net/sf/briar/api/serial/Reader.java @@ -18,8 +18,8 @@ public interface Reader { void addConsumer(Consumer c); void removeConsumer(Consumer c); - void addObjectReader(int tag, ObjectReader o); - void removeObjectReader(int tag); + void addObjectReader(int id, ObjectReader o); + void removeObjectReader(int id); boolean hasBoolean() throws IOException; boolean readBoolean() throws IOException; @@ -69,7 +69,7 @@ public interface Reader { boolean hasNull() throws IOException; void readNull() throws IOException; - boolean hasUserDefined(int tag) throws IOException; - T readUserDefined(int tag, Class t) throws IOException; - void readUserDefinedTag(int tag) throws IOException; + boolean hasUserDefined(int id) throws IOException; + T readUserDefined(int id, Class t) throws IOException; + void readUserDefinedId(int id) throws IOException; } diff --git a/components/net/sf/briar/protocol/AckReader.java b/components/net/sf/briar/protocol/AckReader.java index f6474609c..5f78511ae 100644 --- a/components/net/sf/briar/protocol/AckReader.java +++ b/components/net/sf/briar/protocol/AckReader.java @@ -7,7 +7,7 @@ import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.Ack; import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Consumer; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -28,11 +28,11 @@ class AckReader implements ObjectReader { new CountingConsumer(ProtocolConstants.MAX_PACKET_LENGTH); // Read and digest the data r.addConsumer(counting); - r.readUserDefinedTag(Tags.ACK); - r.addObjectReader(Tags.BATCH_ID, batchIdReader); + r.readUserDefinedId(Types.ACK); + r.addObjectReader(Types.BATCH_ID, batchIdReader); Collection batches = r.readList(BatchId.class); if(batches.size() > Ack.MAX_IDS_PER_ACK) throw new FormatException(); - r.removeObjectReader(Tags.BATCH_ID); + r.removeObjectReader(Types.BATCH_ID); r.removeConsumer(counting); // Build and return the ack return ackFactory.createAck(batches); diff --git a/components/net/sf/briar/protocol/AuthorImpl.java b/components/net/sf/briar/protocol/AuthorImpl.java index 2bbc960d2..9596dffbb 100644 --- a/components/net/sf/briar/protocol/AuthorImpl.java +++ b/components/net/sf/briar/protocol/AuthorImpl.java @@ -4,7 +4,7 @@ import java.io.IOException; import net.sf.briar.api.protocol.Author; import net.sf.briar.api.protocol.AuthorId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Writer; class AuthorImpl implements Author { @@ -32,7 +32,7 @@ class AuthorImpl implements Author { } public void writeTo(Writer w) throws IOException { - w.writeUserDefinedTag(Tags.AUTHOR); + w.writeUserDefinedTag(Types.AUTHOR); w.writeString(name); w.writeBytes(publicKey); } diff --git a/components/net/sf/briar/protocol/AuthorReader.java b/components/net/sf/briar/protocol/AuthorReader.java index 4ce4cc8e4..06d509caf 100644 --- a/components/net/sf/briar/protocol/AuthorReader.java +++ b/components/net/sf/briar/protocol/AuthorReader.java @@ -7,7 +7,7 @@ import net.sf.briar.api.crypto.CryptoComponent; import net.sf.briar.api.protocol.Author; import net.sf.briar.api.protocol.AuthorFactory; import net.sf.briar.api.protocol.AuthorId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -27,7 +27,7 @@ class AuthorReader implements ObjectReader { messageDigest.reset(); // Read and digest the data r.addConsumer(digesting); - r.readUserDefinedTag(Tags.AUTHOR); + r.readUserDefinedId(Types.AUTHOR); String name = r.readString(Author.MAX_NAME_LENGTH); byte[] publicKey = r.readBytes(Author.MAX_PUBLIC_KEY_LENGTH); r.removeConsumer(digesting); diff --git a/components/net/sf/briar/protocol/BatchIdReader.java b/components/net/sf/briar/protocol/BatchIdReader.java index 21807eb47..f288f04ab 100644 --- a/components/net/sf/briar/protocol/BatchIdReader.java +++ b/components/net/sf/briar/protocol/BatchIdReader.java @@ -4,7 +4,7 @@ import java.io.IOException; import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.BatchId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.UniqueId; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -12,7 +12,7 @@ import net.sf.briar.api.serial.Reader; class BatchIdReader implements ObjectReader { public BatchId readObject(Reader r) throws IOException { - r.readUserDefinedTag(Tags.BATCH_ID); + r.readUserDefinedId(Types.BATCH_ID); byte[] b = r.readBytes(UniqueId.LENGTH); if(b.length != UniqueId.LENGTH) throw new FormatException(); return new BatchId(b); diff --git a/components/net/sf/briar/protocol/BatchReader.java b/components/net/sf/briar/protocol/BatchReader.java index 5f3bce328..e77c711f5 100644 --- a/components/net/sf/briar/protocol/BatchReader.java +++ b/components/net/sf/briar/protocol/BatchReader.java @@ -9,7 +9,7 @@ import net.sf.briar.api.protocol.Batch; import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.Message; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Consumer; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -36,10 +36,10 @@ class BatchReader implements ObjectReader { // Read and digest the data r.addConsumer(counting); r.addConsumer(digesting); - r.readUserDefinedTag(Tags.BATCH); - r.addObjectReader(Tags.MESSAGE, messageReader); + r.readUserDefinedId(Types.BATCH); + r.addObjectReader(Types.MESSAGE, messageReader); List messages = r.readList(Message.class); - r.removeObjectReader(Tags.MESSAGE); + r.removeObjectReader(Types.MESSAGE); r.removeConsumer(digesting); r.removeConsumer(counting); // Build and return the batch diff --git a/components/net/sf/briar/protocol/GroupIdReader.java b/components/net/sf/briar/protocol/GroupIdReader.java index bf9fd81b1..b121fd8cb 100644 --- a/components/net/sf/briar/protocol/GroupIdReader.java +++ b/components/net/sf/briar/protocol/GroupIdReader.java @@ -4,7 +4,7 @@ import java.io.IOException; import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.GroupId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.UniqueId; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -12,7 +12,7 @@ import net.sf.briar.api.serial.Reader; class GroupIdReader implements ObjectReader { public GroupId readObject(Reader r) throws IOException { - r.readUserDefinedTag(Tags.GROUP_ID); + r.readUserDefinedId(Types.GROUP_ID); byte[] b = r.readBytes(UniqueId.LENGTH); if(b.length != UniqueId.LENGTH) throw new FormatException(); return new GroupId(b); diff --git a/components/net/sf/briar/protocol/GroupImpl.java b/components/net/sf/briar/protocol/GroupImpl.java index 34fe24e6d..ad265d51d 100644 --- a/components/net/sf/briar/protocol/GroupImpl.java +++ b/components/net/sf/briar/protocol/GroupImpl.java @@ -4,7 +4,7 @@ import java.io.IOException; import net.sf.briar.api.protocol.Group; import net.sf.briar.api.protocol.GroupId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Writer; class GroupImpl implements Group { @@ -32,7 +32,7 @@ class GroupImpl implements Group { } public void writeTo(Writer w) throws IOException { - w.writeUserDefinedTag(Tags.GROUP); + w.writeUserDefinedTag(Types.GROUP); w.writeString(name); if(publicKey == null) w.writeNull(); else w.writeBytes(publicKey); diff --git a/components/net/sf/briar/protocol/GroupReader.java b/components/net/sf/briar/protocol/GroupReader.java index d855850dd..9b371c19d 100644 --- a/components/net/sf/briar/protocol/GroupReader.java +++ b/components/net/sf/briar/protocol/GroupReader.java @@ -7,7 +7,7 @@ import net.sf.briar.api.crypto.CryptoComponent; import net.sf.briar.api.protocol.Group; import net.sf.briar.api.protocol.GroupFactory; import net.sf.briar.api.protocol.GroupId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -27,7 +27,7 @@ class GroupReader implements ObjectReader { messageDigest.reset(); // Read and digest the data r.addConsumer(digesting); - r.readUserDefinedTag(Tags.GROUP); + r.readUserDefinedId(Types.GROUP); String name = r.readString(Group.MAX_NAME_LENGTH); byte[] publicKey = null; if(r.hasNull()) r.readNull(); diff --git a/components/net/sf/briar/protocol/MessageEncoderImpl.java b/components/net/sf/briar/protocol/MessageEncoderImpl.java index 2907689ea..af8f7b902 100644 --- a/components/net/sf/briar/protocol/MessageEncoderImpl.java +++ b/components/net/sf/briar/protocol/MessageEncoderImpl.java @@ -14,7 +14,7 @@ import net.sf.briar.api.protocol.Group; import net.sf.briar.api.protocol.Message; import net.sf.briar.api.protocol.MessageEncoder; import net.sf.briar.api.protocol.MessageId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -65,7 +65,7 @@ class MessageEncoderImpl implements MessageEncoder { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer w = writerFactory.createWriter(out); // Write the message - w.writeUserDefinedTag(Tags.MESSAGE); + w.writeUserDefinedTag(Types.MESSAGE); parent.writeTo(w); group.writeTo(w); if(author == null) w.writeNull(); diff --git a/components/net/sf/briar/protocol/MessageIdReader.java b/components/net/sf/briar/protocol/MessageIdReader.java index 32e4e905a..a47ef6a2d 100644 --- a/components/net/sf/briar/protocol/MessageIdReader.java +++ b/components/net/sf/briar/protocol/MessageIdReader.java @@ -4,7 +4,7 @@ import java.io.IOException; import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.MessageId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.UniqueId; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -12,7 +12,7 @@ import net.sf.briar.api.serial.Reader; class MessageIdReader implements ObjectReader { public MessageId readObject(Reader r) throws IOException { - r.readUserDefinedTag(Tags.MESSAGE_ID); + r.readUserDefinedId(Types.MESSAGE_ID); byte[] b = r.readBytes(UniqueId.LENGTH); if(b.length != UniqueId.LENGTH) throw new FormatException(); return new MessageId(b); diff --git a/components/net/sf/briar/protocol/MessageReader.java b/components/net/sf/briar/protocol/MessageReader.java index d7fdcab4a..669fa3805 100644 --- a/components/net/sf/briar/protocol/MessageReader.java +++ b/components/net/sf/briar/protocol/MessageReader.java @@ -15,7 +15,7 @@ import net.sf.briar.api.protocol.Group; import net.sf.briar.api.protocol.Message; import net.sf.briar.api.protocol.MessageId; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -47,21 +47,21 @@ class MessageReader implements ObjectReader { r.addConsumer(copying); r.addConsumer(counting); // Read the initial tag - r.readUserDefinedTag(Tags.MESSAGE); + r.readUserDefinedId(Types.MESSAGE); // Read the parent's message ID - r.addObjectReader(Tags.MESSAGE_ID, messageIdReader); - MessageId parent = r.readUserDefined(Tags.MESSAGE_ID, MessageId.class); - r.removeObjectReader(Tags.MESSAGE_ID); + r.addObjectReader(Types.MESSAGE_ID, messageIdReader); + MessageId parent = r.readUserDefined(Types.MESSAGE_ID, MessageId.class); + r.removeObjectReader(Types.MESSAGE_ID); // Read the group - r.addObjectReader(Tags.GROUP, groupReader); - Group group = r.readUserDefined(Tags.GROUP, Group.class); - r.removeObjectReader(Tags.GROUP); + r.addObjectReader(Types.GROUP, groupReader); + Group group = r.readUserDefined(Types.GROUP, Group.class); + r.removeObjectReader(Types.GROUP); // Read the author, if there is one - r.addObjectReader(Tags.AUTHOR, authorReader); + r.addObjectReader(Types.AUTHOR, authorReader); Author author = null; if(r.hasNull()) r.readNull(); - else author = r.readUserDefined(Tags.AUTHOR, Author.class); - r.removeObjectReader(Tags.AUTHOR); + else author = r.readUserDefined(Types.AUTHOR, Author.class); + r.removeObjectReader(Types.AUTHOR); // Read the timestamp long timestamp = r.readInt64(); if(timestamp < 0L) throw new FormatException(); diff --git a/components/net/sf/briar/protocol/OfferReader.java b/components/net/sf/briar/protocol/OfferReader.java index 970b96453..04a15536c 100644 --- a/components/net/sf/briar/protocol/OfferReader.java +++ b/components/net/sf/briar/protocol/OfferReader.java @@ -7,7 +7,7 @@ import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.MessageId; import net.sf.briar.api.protocol.Offer; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Consumer; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -29,12 +29,12 @@ class OfferReader implements ObjectReader { new CountingConsumer(ProtocolConstants.MAX_PACKET_LENGTH); // Read the data r.addConsumer(counting); - r.readUserDefinedTag(Tags.OFFER); - r.addObjectReader(Tags.MESSAGE_ID, messageIdReader); + r.readUserDefinedId(Types.OFFER); + r.addObjectReader(Types.MESSAGE_ID, messageIdReader); Collection messages = r.readList(MessageId.class); if(messages.size() > Offer.MAX_IDS_PER_OFFER) throw new FormatException(); - r.removeObjectReader(Tags.MESSAGE_ID); + r.removeObjectReader(Types.MESSAGE_ID); r.removeConsumer(counting); // Build and return the offer return offerFactory.createOffer(messages); diff --git a/components/net/sf/briar/protocol/ProtocolReaderImpl.java b/components/net/sf/briar/protocol/ProtocolReaderImpl.java index d79d8a4e4..e2c39da0c 100644 --- a/components/net/sf/briar/protocol/ProtocolReaderImpl.java +++ b/components/net/sf/briar/protocol/ProtocolReaderImpl.java @@ -9,7 +9,7 @@ import net.sf.briar.api.protocol.Offer; import net.sf.briar.api.protocol.ProtocolReader; import net.sf.briar.api.protocol.Request; import net.sf.briar.api.protocol.SubscriptionUpdate; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.TransportUpdate; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -26,60 +26,60 @@ class ProtocolReaderImpl implements ProtocolReader { ObjectReader subscriptionReader, ObjectReader transportReader) { reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.ACK, ackReader); - reader.addObjectReader(Tags.BATCH, batchReader); - reader.addObjectReader(Tags.OFFER, offerReader); - reader.addObjectReader(Tags.REQUEST, requestReader); - reader.addObjectReader(Tags.SUBSCRIPTION_UPDATE, subscriptionReader); - reader.addObjectReader(Tags.TRANSPORT_UPDATE, transportReader); + reader.addObjectReader(Types.ACK, ackReader); + reader.addObjectReader(Types.BATCH, batchReader); + reader.addObjectReader(Types.OFFER, offerReader); + reader.addObjectReader(Types.REQUEST, requestReader); + reader.addObjectReader(Types.SUBSCRIPTION_UPDATE, subscriptionReader); + reader.addObjectReader(Types.TRANSPORT_UPDATE, transportReader); } public boolean hasAck() throws IOException { - return reader.hasUserDefined(Tags.ACK); + return reader.hasUserDefined(Types.ACK); } public Ack readAck() throws IOException { - return reader.readUserDefined(Tags.ACK, Ack.class); + return reader.readUserDefined(Types.ACK, Ack.class); } public boolean hasBatch() throws IOException { - return reader.hasUserDefined(Tags.BATCH); + return reader.hasUserDefined(Types.BATCH); } public Batch readBatch() throws IOException { - return reader.readUserDefined(Tags.BATCH, Batch.class); + return reader.readUserDefined(Types.BATCH, Batch.class); } public boolean hasOffer() throws IOException { - return reader.hasUserDefined(Tags.OFFER); + return reader.hasUserDefined(Types.OFFER); } public Offer readOffer() throws IOException { - return reader.readUserDefined(Tags.OFFER, Offer.class); + return reader.readUserDefined(Types.OFFER, Offer.class); } public boolean hasRequest() throws IOException { - return reader.hasUserDefined(Tags.REQUEST); + return reader.hasUserDefined(Types.REQUEST); } public Request readRequest() throws IOException { - return reader.readUserDefined(Tags.REQUEST, Request.class); + return reader.readUserDefined(Types.REQUEST, Request.class); } public boolean hasSubscriptionUpdate() throws IOException { - return reader.hasUserDefined(Tags.SUBSCRIPTION_UPDATE); + return reader.hasUserDefined(Types.SUBSCRIPTION_UPDATE); } public SubscriptionUpdate readSubscriptionUpdate() throws IOException { - return reader.readUserDefined(Tags.SUBSCRIPTION_UPDATE, + return reader.readUserDefined(Types.SUBSCRIPTION_UPDATE, SubscriptionUpdate.class); } public boolean hasTransportUpdate() throws IOException { - return reader.hasUserDefined(Tags.TRANSPORT_UPDATE); + return reader.hasUserDefined(Types.TRANSPORT_UPDATE); } public TransportUpdate readTransportUpdate() throws IOException { - return reader.readUserDefined(Tags.TRANSPORT_UPDATE, TransportUpdate.class); + return reader.readUserDefined(Types.TRANSPORT_UPDATE, TransportUpdate.class); } } diff --git a/components/net/sf/briar/protocol/RequestReader.java b/components/net/sf/briar/protocol/RequestReader.java index 88ebec391..b2edd24cb 100644 --- a/components/net/sf/briar/protocol/RequestReader.java +++ b/components/net/sf/briar/protocol/RequestReader.java @@ -5,7 +5,7 @@ import java.util.BitSet; import net.sf.briar.api.protocol.ProtocolConstants; import net.sf.briar.api.protocol.Request; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Consumer; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -24,7 +24,7 @@ class RequestReader implements ObjectReader { new CountingConsumer(ProtocolConstants.MAX_PACKET_LENGTH); // Read the data r.addConsumer(counting); - r.readUserDefinedTag(Tags.REQUEST); + r.readUserDefinedId(Types.REQUEST); byte[] bitmap = r.readBytes(ProtocolConstants.MAX_PACKET_LENGTH); r.removeConsumer(counting); // Convert the bitmap into a BitSet diff --git a/components/net/sf/briar/protocol/SubscriptionReader.java b/components/net/sf/briar/protocol/SubscriptionReader.java index 7c13d6ffa..40aa96e6a 100644 --- a/components/net/sf/briar/protocol/SubscriptionReader.java +++ b/components/net/sf/briar/protocol/SubscriptionReader.java @@ -6,7 +6,7 @@ import java.util.Map; import net.sf.briar.api.protocol.Group; import net.sf.briar.api.protocol.ProtocolConstants; import net.sf.briar.api.protocol.SubscriptionUpdate; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Consumer; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; @@ -28,10 +28,10 @@ class SubscriptionReader implements ObjectReader { new CountingConsumer(ProtocolConstants.MAX_PACKET_LENGTH); // Read the data r.addConsumer(counting); - r.readUserDefinedTag(Tags.SUBSCRIPTION_UPDATE); - r.addObjectReader(Tags.GROUP, groupReader); + r.readUserDefinedId(Types.SUBSCRIPTION_UPDATE); + r.addObjectReader(Types.GROUP, groupReader); Map subs = r.readMap(Group.class, Long.class); - r.removeObjectReader(Tags.GROUP); + r.removeObjectReader(Types.GROUP); long timestamp = r.readInt64(); r.removeConsumer(counting); // Build and return the subscription update diff --git a/components/net/sf/briar/protocol/TransportReader.java b/components/net/sf/briar/protocol/TransportReader.java index 345acff2b..9cb20e79b 100644 --- a/components/net/sf/briar/protocol/TransportReader.java +++ b/components/net/sf/briar/protocol/TransportReader.java @@ -7,7 +7,7 @@ import java.util.TreeMap; import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.TransportUpdate; import net.sf.briar.api.serial.Consumer; import net.sf.briar.api.serial.ObjectReader; @@ -29,12 +29,12 @@ class TransportReader implements ObjectReader { new CountingConsumer(ProtocolConstants.MAX_PACKET_LENGTH); // Read the data r.addConsumer(counting); - r.readUserDefinedTag(Tags.TRANSPORT_UPDATE); - r.addObjectReader(Tags.TRANSPORT_PROPERTIES, propertiesReader); + r.readUserDefinedId(Types.TRANSPORT_UPDATE); + r.addObjectReader(Types.TRANSPORT_PROPERTIES, propertiesReader); r.setMaxStringLength(ProtocolConstants.MAX_PACKET_LENGTH); List l = r.readList(TransportProperties.class); r.resetMaxStringLength(); - r.removeObjectReader(Tags.TRANSPORT_PROPERTIES); + r.removeObjectReader(Types.TRANSPORT_PROPERTIES); if(l.size() > TransportUpdate.MAX_PLUGINS_PER_UPDATE) throw new FormatException(); Map> transports = @@ -64,7 +64,7 @@ class TransportReader implements ObjectReader { implements ObjectReader { public TransportProperties readObject(Reader r) throws IOException { - r.readUserDefinedTag(Tags.TRANSPORT_PROPERTIES); + r.readUserDefinedId(Types.TRANSPORT_PROPERTIES); String name = r.readString(TransportUpdate.MAX_NAME_LENGTH); r.setMaxStringLength(TransportUpdate.MAX_KEY_OR_VALUE_LENGTH); Map properties = diff --git a/components/net/sf/briar/protocol/writers/AckWriterImpl.java b/components/net/sf/briar/protocol/writers/AckWriterImpl.java index 0fea45d9d..886455753 100644 --- a/components/net/sf/briar/protocol/writers/AckWriterImpl.java +++ b/components/net/sf/briar/protocol/writers/AckWriterImpl.java @@ -5,7 +5,7 @@ import java.io.OutputStream; import net.sf.briar.api.protocol.Ack; import net.sf.briar.api.protocol.BatchId; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.writers.AckWriter; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -25,7 +25,7 @@ class AckWriterImpl implements AckWriter { public boolean writeBatchId(BatchId b) throws IOException { if(!started) { - w.writeUserDefinedTag(Tags.ACK); + w.writeUserDefinedTag(Types.ACK); w.writeListStart(); started = true; } @@ -37,7 +37,7 @@ class AckWriterImpl implements AckWriter { public void finish() throws IOException { if(!started) { - w.writeUserDefinedTag(Tags.ACK); + w.writeUserDefinedTag(Types.ACK); w.writeListStart(); started = true; } diff --git a/components/net/sf/briar/protocol/writers/BatchWriterImpl.java b/components/net/sf/briar/protocol/writers/BatchWriterImpl.java index 5a9a6a2f7..36e84d819 100644 --- a/components/net/sf/briar/protocol/writers/BatchWriterImpl.java +++ b/components/net/sf/briar/protocol/writers/BatchWriterImpl.java @@ -7,7 +7,7 @@ import java.security.MessageDigest; import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.writers.BatchWriter; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -36,7 +36,7 @@ class BatchWriterImpl implements BatchWriter { public boolean writeMessage(byte[] message) throws IOException { if(!started) { messageDigest.reset(); - w.writeUserDefinedTag(Tags.BATCH); + w.writeUserDefinedTag(Types.BATCH); w.writeListStart(); started = true; } @@ -52,7 +52,7 @@ class BatchWriterImpl implements BatchWriter { public BatchId finish() throws IOException { if(!started) { messageDigest.reset(); - w.writeUserDefinedTag(Tags.BATCH); + w.writeUserDefinedTag(Types.BATCH); w.writeListStart(); started = true; } diff --git a/components/net/sf/briar/protocol/writers/OfferWriterImpl.java b/components/net/sf/briar/protocol/writers/OfferWriterImpl.java index f606172ea..c9f0670da 100644 --- a/components/net/sf/briar/protocol/writers/OfferWriterImpl.java +++ b/components/net/sf/briar/protocol/writers/OfferWriterImpl.java @@ -5,7 +5,7 @@ import java.io.OutputStream; import net.sf.briar.api.protocol.MessageId; import net.sf.briar.api.protocol.Offer; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.writers.OfferWriter; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -25,7 +25,7 @@ class OfferWriterImpl implements OfferWriter { public boolean writeMessageId(MessageId m) throws IOException { if(!started) { - w.writeUserDefinedTag(Tags.OFFER); + w.writeUserDefinedTag(Types.OFFER); w.writeListStart(); started = true; } @@ -37,7 +37,7 @@ class OfferWriterImpl implements OfferWriter { public void finish() throws IOException { if(!started) { - w.writeUserDefinedTag(Tags.OFFER); + w.writeUserDefinedTag(Types.OFFER); w.writeListStart(); started = true; } diff --git a/components/net/sf/briar/protocol/writers/RequestWriterImpl.java b/components/net/sf/briar/protocol/writers/RequestWriterImpl.java index 6e6ce137a..a3ceb5e50 100644 --- a/components/net/sf/briar/protocol/writers/RequestWriterImpl.java +++ b/components/net/sf/briar/protocol/writers/RequestWriterImpl.java @@ -4,7 +4,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.BitSet; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.writers.RequestWriter; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -21,7 +21,7 @@ class RequestWriterImpl implements RequestWriter { public void writeRequest(BitSet b, int length) throws IOException { - w.writeUserDefinedTag(Tags.REQUEST); + w.writeUserDefinedTag(Types.REQUEST); // If the number of bits isn't a multiple of 8, round up to a byte int bytes = length % 8 == 0 ? length / 8 : length / 8 + 1; byte[] bitmap = new byte[bytes]; diff --git a/components/net/sf/briar/protocol/writers/SubscriptionWriterImpl.java b/components/net/sf/briar/protocol/writers/SubscriptionWriterImpl.java index ad778ba30..97b2e8aa0 100644 --- a/components/net/sf/briar/protocol/writers/SubscriptionWriterImpl.java +++ b/components/net/sf/briar/protocol/writers/SubscriptionWriterImpl.java @@ -5,7 +5,7 @@ import java.io.OutputStream; import java.util.Map; import net.sf.briar.api.protocol.Group; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.writers.SubscriptionWriter; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -22,7 +22,7 @@ class SubscriptionWriterImpl implements SubscriptionWriter { public void writeSubscriptions(Map subs, long timestamp) throws IOException { - w.writeUserDefinedTag(Tags.SUBSCRIPTION_UPDATE); + w.writeUserDefinedTag(Types.SUBSCRIPTION_UPDATE); w.writeMap(subs); w.writeInt64(timestamp); out.flush(); diff --git a/components/net/sf/briar/protocol/writers/TransportWriterImpl.java b/components/net/sf/briar/protocol/writers/TransportWriterImpl.java index 227a45eec..1d346fdab 100644 --- a/components/net/sf/briar/protocol/writers/TransportWriterImpl.java +++ b/components/net/sf/briar/protocol/writers/TransportWriterImpl.java @@ -5,7 +5,7 @@ import java.io.OutputStream; import java.util.Map; import java.util.Map.Entry; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.writers.TransportWriter; import net.sf.briar.api.serial.Writer; import net.sf.briar.api.serial.WriterFactory; @@ -22,10 +22,10 @@ class TransportWriterImpl implements TransportWriter { public void writeTransports(Map> transports, long timestamp) throws IOException { - w.writeUserDefinedTag(Tags.TRANSPORT_UPDATE); + w.writeUserDefinedTag(Types.TRANSPORT_UPDATE); w.writeListStart(); for(Entry> e : transports.entrySet()) { - w.writeUserDefinedTag(Tags.TRANSPORT_PROPERTIES); + w.writeUserDefinedTag(Types.TRANSPORT_PROPERTIES); w.writeString(e.getKey()); w.writeMap(e.getValue()); } diff --git a/components/net/sf/briar/serial/ReaderImpl.java b/components/net/sf/briar/serial/ReaderImpl.java index 32f56df70..0e9cc495d 100644 --- a/components/net/sf/briar/serial/ReaderImpl.java +++ b/components/net/sf/briar/serial/ReaderImpl.java @@ -110,21 +110,21 @@ class ReaderImpl implements Reader { else throw new IllegalArgumentException(); } - public void addObjectReader(int tag, ObjectReader o) { - if(tag < 0 || tag > 255) throw new IllegalArgumentException(); - if(objectReaders.length < tag + 1) { - ObjectReader[] newObjectReaders = new ObjectReader[tag + 1]; + public void addObjectReader(int id, ObjectReader o) { + if(id < 0 || id > 255) throw new IllegalArgumentException(); + if(objectReaders.length < id + 1) { + ObjectReader[] newObjectReaders = new ObjectReader[id + 1]; System.arraycopy(objectReaders, 0, newObjectReaders, 0, objectReaders.length); objectReaders = newObjectReaders; } - objectReaders[tag] = o; + objectReaders[id] = o; } - public void removeObjectReader(int tag) { - if(tag < 0 || tag > objectReaders.length) + public void removeObjectReader(int id) { + if(id < 0 || id > objectReaders.length) throw new IllegalArgumentException(); - objectReaders[tag] = null; + objectReaders[id] = null; } public boolean hasBoolean() throws IOException { @@ -551,21 +551,21 @@ class ReaderImpl implements Reader { consumeLookahead(); } - public boolean hasUserDefined(int tag) throws IOException { - if(tag < 0 || tag > 255) throw new IllegalArgumentException(); + public boolean hasUserDefined(int id) throws IOException { + if(id < 0 || id > 255) throw new IllegalArgumentException(); if(!hasLookahead) readLookahead(true); if(eof) return false; if(next == Tag.USER) - return tag == (0xFF & nextNext); + return id == (0xFF & nextNext); else if((next & Tag.SHORT_USER_MASK) == Tag.SHORT_USER) - return tag == (0xFF & next ^ Tag.SHORT_USER); + return id == (0xFF & next ^ Tag.SHORT_USER); else return false; } - public T readUserDefined(int tag, Class t) throws IOException { - if(!hasUserDefined(tag)) throw new FormatException(); - if(tag >= objectReaders.length) throw new FormatException(); - ObjectReader o = objectReaders[tag]; + public T readUserDefined(int id, Class t) throws IOException { + if(!hasUserDefined(id)) throw new FormatException(); + if(id >= objectReaders.length) throw new FormatException(); + ObjectReader o = objectReaders[id]; if(o == null) throw new FormatException(); try { return t.cast(o.readObject(this)); @@ -574,8 +574,8 @@ class ReaderImpl implements Reader { } } - public void readUserDefinedTag(int tag) throws IOException { - if(!hasUserDefined(tag)) throw new FormatException(); + public void readUserDefinedId(int id) throws IOException { + if(!hasUserDefined(id)) throw new FormatException(); consumeLookahead(); } } diff --git a/test/net/sf/briar/protocol/AckReaderTest.java b/test/net/sf/briar/protocol/AckReaderTest.java index 42dffb2d0..32ffedd83 100644 --- a/test/net/sf/briar/protocol/AckReaderTest.java +++ b/test/net/sf/briar/protocol/AckReaderTest.java @@ -11,7 +11,7 @@ import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.Ack; import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.protocol.UniqueId; import net.sf.briar.api.serial.Reader; import net.sf.briar.api.serial.ReaderFactory; @@ -48,10 +48,10 @@ public class AckReaderTest extends TestCase { byte[] b = createAck(true); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.ACK, ackReader); + reader.addObjectReader(Types.ACK, ackReader); try { - reader.readUserDefined(Tags.ACK, Ack.class); + reader.readUserDefined(Types.ACK, Ack.class); fail(); } catch(FormatException expected) {} context.assertIsSatisfied(); @@ -71,9 +71,9 @@ public class AckReaderTest extends TestCase { byte[] b = createAck(false); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.ACK, ackReader); + reader.addObjectReader(Types.ACK, ackReader); - assertEquals(ack, reader.readUserDefined(Tags.ACK, Ack.class)); + assertEquals(ack, reader.readUserDefined(Types.ACK, Ack.class)); context.assertIsSatisfied(); } @@ -91,27 +91,27 @@ public class AckReaderTest extends TestCase { byte[] b = createEmptyAck(); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.ACK, ackReader); + reader.addObjectReader(Types.ACK, ackReader); - assertEquals(ack, reader.readUserDefined(Tags.ACK, Ack.class)); + assertEquals(ack, reader.readUserDefined(Types.ACK, Ack.class)); context.assertIsSatisfied(); } private byte[] createAck(boolean tooBig) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer w = writerFactory.createWriter(out); - w.writeUserDefinedTag(Tags.ACK); + w.writeUserDefinedTag(Types.ACK); w.writeListStart(); byte[] b = new byte[UniqueId.LENGTH]; Random random = new Random(); while(out.size() + BatchId.LENGTH + 3 < ProtocolConstants.MAX_PACKET_LENGTH) { - w.writeUserDefinedTag(Tags.BATCH_ID); + w.writeUserDefinedTag(Types.BATCH_ID); random.nextBytes(b); w.writeBytes(b); } if(tooBig) { - w.writeUserDefinedTag(Tags.BATCH_ID); + w.writeUserDefinedTag(Types.BATCH_ID); random.nextBytes(b); w.writeBytes(b); } @@ -123,7 +123,7 @@ public class AckReaderTest extends TestCase { private byte[] createEmptyAck() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer w = writerFactory.createWriter(out); - w.writeUserDefinedTag(Tags.ACK); + w.writeUserDefinedTag(Types.ACK); w.writeListStart(); w.writeListEnd(); return out.toByteArray(); diff --git a/test/net/sf/briar/protocol/BatchReaderTest.java b/test/net/sf/briar/protocol/BatchReaderTest.java index 8306b683e..f96944642 100644 --- a/test/net/sf/briar/protocol/BatchReaderTest.java +++ b/test/net/sf/briar/protocol/BatchReaderTest.java @@ -13,7 +13,7 @@ import net.sf.briar.api.protocol.Batch; import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.Message; import net.sf.briar.api.protocol.ProtocolConstants; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.ObjectReader; import net.sf.briar.api.serial.Reader; import net.sf.briar.api.serial.ReaderFactory; @@ -58,10 +58,10 @@ public class BatchReaderTest extends TestCase { byte[] b = createBatch(ProtocolConstants.MAX_PACKET_LENGTH + 1); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.BATCH, batchReader); + reader.addObjectReader(Types.BATCH, batchReader); try { - reader.readUserDefined(Tags.BATCH, Batch.class); + reader.readUserDefined(Types.BATCH, Batch.class); fail(); } catch(FormatException expected) {} context.assertIsSatisfied(); @@ -83,9 +83,9 @@ public class BatchReaderTest extends TestCase { byte[] b = createBatch(ProtocolConstants.MAX_PACKET_LENGTH); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.BATCH, batchReader); + reader.addObjectReader(Types.BATCH, batchReader); - assertEquals(batch, reader.readUserDefined(Tags.BATCH, Batch.class)); + assertEquals(batch, reader.readUserDefined(Types.BATCH, Batch.class)); context.assertIsSatisfied(); } @@ -112,9 +112,9 @@ public class BatchReaderTest extends TestCase { ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.BATCH, batchReader); + reader.addObjectReader(Types.BATCH, batchReader); - assertEquals(batch, reader.readUserDefined(Tags.BATCH, Batch.class)); + assertEquals(batch, reader.readUserDefined(Types.BATCH, Batch.class)); context.assertIsSatisfied(); } @@ -134,19 +134,19 @@ public class BatchReaderTest extends TestCase { byte[] b = createEmptyBatch(); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.BATCH, batchReader); + reader.addObjectReader(Types.BATCH, batchReader); - assertEquals(batch, reader.readUserDefined(Tags.BATCH, Batch.class)); + assertEquals(batch, reader.readUserDefined(Types.BATCH, Batch.class)); context.assertIsSatisfied(); } private byte[] createBatch(int size) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(size); Writer w = writerFactory.createWriter(out); - w.writeUserDefinedTag(Tags.BATCH); + w.writeUserDefinedTag(Types.BATCH); w.writeListStart(); // We're using a fake message reader, so it's OK to use a fake message - w.writeUserDefinedTag(Tags.MESSAGE); + w.writeUserDefinedTag(Types.MESSAGE); w.writeBytes(new byte[size - 10]); w.writeListEnd(); byte[] b = out.toByteArray(); @@ -157,7 +157,7 @@ public class BatchReaderTest extends TestCase { private byte[] createEmptyBatch() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer w = writerFactory.createWriter(out); - w.writeUserDefinedTag(Tags.BATCH); + w.writeUserDefinedTag(Types.BATCH); w.writeListStart(); w.writeListEnd(); return out.toByteArray(); @@ -166,7 +166,7 @@ public class BatchReaderTest extends TestCase { private class TestMessageReader implements ObjectReader { public Message readObject(Reader r) throws IOException { - r.readUserDefinedTag(Tags.MESSAGE); + r.readUserDefinedId(Types.MESSAGE); r.readBytes(); return message; } diff --git a/test/net/sf/briar/protocol/RequestReaderTest.java b/test/net/sf/briar/protocol/RequestReaderTest.java index d93ec834a..1f4a97fba 100644 --- a/test/net/sf/briar/protocol/RequestReaderTest.java +++ b/test/net/sf/briar/protocol/RequestReaderTest.java @@ -8,7 +8,7 @@ import junit.framework.TestCase; import net.sf.briar.api.FormatException; import net.sf.briar.api.protocol.ProtocolConstants; import net.sf.briar.api.protocol.Request; -import net.sf.briar.api.protocol.Tags; +import net.sf.briar.api.protocol.Types; import net.sf.briar.api.serial.Reader; import net.sf.briar.api.serial.ReaderFactory; import net.sf.briar.api.serial.Writer; @@ -44,10 +44,10 @@ public class RequestReaderTest extends TestCase { byte[] b = createRequest(true); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.REQUEST, requestReader); + reader.addObjectReader(Types.REQUEST, requestReader); try { - reader.readUserDefined(Tags.REQUEST, Request.class); + reader.readUserDefined(Types.REQUEST, Request.class); fail(); } catch(FormatException expected) {} context.assertIsSatisfied(); @@ -67,9 +67,9 @@ public class RequestReaderTest extends TestCase { byte[] b = createRequest(false); ByteArrayInputStream in = new ByteArrayInputStream(b); Reader reader = readerFactory.createReader(in); - reader.addObjectReader(Tags.REQUEST, requestReader); + reader.addObjectReader(Types.REQUEST, requestReader); - assertEquals(request, reader.readUserDefined(Tags.REQUEST, + assertEquals(request, reader.readUserDefined(Types.REQUEST, Request.class)); context.assertIsSatisfied(); } @@ -98,8 +98,8 @@ public class RequestReaderTest extends TestCase { Reader reader = readerFactory.createReader(in); RequestReader requestReader = new RequestReader(new RequestFactoryImpl()); - reader.addObjectReader(Tags.REQUEST, requestReader); - Request r = reader.readUserDefined(Tags.REQUEST, Request.class); + reader.addObjectReader(Types.REQUEST, requestReader); + Request r = reader.readUserDefined(Types.REQUEST, Request.class); BitSet decoded = r.getBitmap(); // Check that the decoded BitSet matches the original - we can't // use equals() because of padding, but the first i bits should @@ -115,7 +115,7 @@ public class RequestReaderTest extends TestCase { private byte[] createRequest(boolean tooBig) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer w = writerFactory.createWriter(out); - w.writeUserDefinedTag(Tags.REQUEST); + w.writeUserDefinedTag(Types.REQUEST); // Allow one byte for the REQUEST tag, one byte for the BYTES tag, // and five bytes for the length as an int32 int size = ProtocolConstants.MAX_PACKET_LENGTH - 7; @@ -128,7 +128,7 @@ public class RequestReaderTest extends TestCase { private byte[] createRequest(byte[] bitmap) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer w = writerFactory.createWriter(out); - w.writeUserDefinedTag(Tags.REQUEST); + w.writeUserDefinedTag(Types.REQUEST); w.writeBytes(bitmap); return out.toByteArray(); } diff --git a/test/net/sf/briar/serial/ReaderImplTest.java b/test/net/sf/briar/serial/ReaderImplTest.java index aa5c0bfb7..982f0f397 100644 --- a/test/net/sf/briar/serial/ReaderImplTest.java +++ b/test/net/sf/briar/serial/ReaderImplTest.java @@ -375,13 +375,13 @@ public class ReaderImplTest extends TestCase { // Add object readers for two user-defined types r.addObjectReader(0, new ObjectReader() { public Foo readObject(Reader r) throws IOException { - r.readUserDefinedTag(0); + r.readUserDefinedId(0); return new Foo(r.readString()); } }); r.addObjectReader(255, new ObjectReader() { public Bar readObject(Reader r) throws IOException { - r.readUserDefinedTag(255); + r.readUserDefinedId(255); return new Bar(r.readString()); } }); @@ -398,13 +398,13 @@ public class ReaderImplTest extends TestCase { // Add object readers for two user-defined types r.addObjectReader(0, new ObjectReader() { public Foo readObject(Reader r) throws IOException { - r.readUserDefinedTag(0); + r.readUserDefinedId(0); return new Foo(r.readString()); } }); r.addObjectReader(255, new ObjectReader() { public Bar readObject(Reader r) throws IOException { - r.readUserDefinedTag(255); + r.readUserDefinedId(255); return new Bar(r.readString()); } }); @@ -451,7 +451,7 @@ public class ReaderImplTest extends TestCase { // Add an object reader for tag 0, class Foo r.addObjectReader(0, new ObjectReader() { public Foo readObject(Reader r) throws IOException { - r.readUserDefinedTag(0); + r.readUserDefinedId(0); return new Foo(r.readString()); } }); @@ -469,7 +469,7 @@ public class ReaderImplTest extends TestCase { // Add an object reader for a user-defined type r.addObjectReader(0, new ObjectReader() { public Foo readObject(Reader r) throws IOException { - r.readUserDefinedTag(0); + r.readUserDefinedId(0); return new Foo(r.readString()); } }); @@ -485,13 +485,13 @@ public class ReaderImplTest extends TestCase { // Add object readers for two user-defined types r.addObjectReader(0, new ObjectReader() { public Foo readObject(Reader r) throws IOException { - r.readUserDefinedTag(0); + r.readUserDefinedId(0); return new Foo(r.readString()); } }); r.addObjectReader(1, new ObjectReader() { public Bar readObject(Reader r) throws IOException { - r.readUserDefinedTag(1); + r.readUserDefinedId(1); return new Bar(r.readString()); } });