Commit 7139d1ef authored by Tamir Duberstein's avatar Tamir Duberstein

Whitespace

parent 8d9e51cf
...@@ -507,7 +507,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable { ...@@ -507,7 +507,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
/** /**
* Internal (package private) implementation of * Internal (package private) implementation of
* {@link #copyTo(byte[],int,int,int)}. * {@link #copyTo(byte[],int,int,int)}.
* It assumes that all error checking has already been performed and that * It assumes that all error checking has already been performed and that
* {@code numberToCopy > 0}. * {@code numberToCopy > 0}.
*/ */
protected abstract void copyToInternal(byte[] target, int sourceOffset, protected abstract void copyToInternal(byte[] target, int sourceOffset,
...@@ -546,7 +546,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable { ...@@ -546,7 +546,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
public abstract void writeTo(OutputStream out) throws IOException; public abstract void writeTo(OutputStream out) throws IOException;
/** /**
* Writes a specified part of this byte string to an output stream. * Writes a specified part of this byte string to an output stream.
* *
...@@ -572,7 +572,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable { ...@@ -572,7 +572,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
if (numberToWrite > 0) { if (numberToWrite > 0) {
writeToInternal(out, sourceOffset, numberToWrite); writeToInternal(out, sourceOffset, numberToWrite);
} }
} }
/** /**
...@@ -599,7 +599,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable { ...@@ -599,7 +599,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
* <p> * <p>
* By returning a list, implementations of this method may be able to avoid * By returning a list, implementations of this method may be able to avoid
* copying even when there are multiple backing arrays. * copying even when there are multiple backing arrays.
* *
* @return a list of wrapped bytes * @return a list of wrapped bytes
*/ */
public abstract List<ByteBuffer> asReadOnlyByteBufferList(); public abstract List<ByteBuffer> asReadOnlyByteBufferList();
...@@ -831,7 +831,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable { ...@@ -831,7 +831,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
flushLastBuffer(); flushLastBuffer();
return ByteString.copyFrom(flushedBuffers); return ByteString.copyFrom(flushedBuffers);
} }
/** /**
* Implement java.util.Arrays.copyOf() for jdk 1.5. * Implement java.util.Arrays.copyOf() for jdk 1.5.
*/ */
......
...@@ -144,7 +144,7 @@ public final class CodedOutputStream { ...@@ -144,7 +144,7 @@ public final class CodedOutputStream {
int bufferSize) { int bufferSize) {
return newInstance(new ByteBufferOutputStream(byteBuffer), bufferSize); return newInstance(new ByteBufferOutputStream(byteBuffer), bufferSize);
} }
private static class ByteBufferOutputStream extends OutputStream { private static class ByteBufferOutputStream extends OutputStream {
private final ByteBuffer byteBuffer; private final ByteBuffer byteBuffer;
public ByteBufferOutputStream(ByteBuffer byteBuffer) { public ByteBufferOutputStream(ByteBuffer byteBuffer) {
...@@ -750,7 +750,7 @@ public final class CodedOutputStream { ...@@ -750,7 +750,7 @@ public final class CodedOutputStream {
computeUInt32Size(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber) + computeUInt32Size(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber) +
computeLazyFieldSize(WireFormat.MESSAGE_SET_MESSAGE, value); computeLazyFieldSize(WireFormat.MESSAGE_SET_MESSAGE, value);
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------
/** /**
......
...@@ -256,7 +256,7 @@ public final class Descriptors { ...@@ -256,7 +256,7 @@ public final class Descriptors {
throws DescriptorValidationException { throws DescriptorValidationException {
return buildFrom(proto, dependencies, false); return buildFrom(proto, dependencies, false);
} }
/** /**
* Construct a {@code FileDescriptor}. * Construct a {@code FileDescriptor}.
...@@ -495,9 +495,9 @@ public final class Descriptors { ...@@ -495,9 +495,9 @@ public final class Descriptors {
proto.getExtension(i), this, null, i, true); proto.getExtension(i), this, null, i, true);
} }
} }
/** /**
* Create a placeholder FileDescriptor for a message Descriptor. * Create a placeholder FileDescriptor for a message Descriptor.
*/ */
FileDescriptor(String packageName, Descriptor message) FileDescriptor(String packageName, Descriptor message)
throws DescriptorValidationException { throws DescriptorValidationException {
...@@ -561,7 +561,7 @@ public final class Descriptors { ...@@ -561,7 +561,7 @@ public final class Descriptors {
extensions[i].setProto(proto.getExtension(i)); extensions[i].setProto(proto.getExtension(i));
} }
} }
boolean supportsUnknownEnumValue() { boolean supportsUnknownEnumValue() {
return getSyntax() == Syntax.PROTO3; return getSyntax() == Syntax.PROTO3;
} }
...@@ -745,7 +745,7 @@ public final class Descriptors { ...@@ -745,7 +745,7 @@ public final class Descriptors {
this.fields = new FieldDescriptor[0]; this.fields = new FieldDescriptor[0];
this.extensions = new FieldDescriptor[0]; this.extensions = new FieldDescriptor[0];
this.oneofs = new OneofDescriptor[0]; this.oneofs = new OneofDescriptor[0];
// Create a placeholder FileDescriptor to hold this message. // Create a placeholder FileDescriptor to hold this message.
this.file = new FileDescriptor(packageName, this); this.file = new FileDescriptor(packageName, this);
} }
...@@ -1333,8 +1333,8 @@ public final class Descriptors { ...@@ -1333,8 +1333,8 @@ public final class Descriptors {
"Message type had default value."); "Message type had default value.");
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new DescriptorValidationException(this, throw new DescriptorValidationException(this,
"Could not parse default value: \"" + "Could not parse default value: \"" +
proto.getDefaultValue() + '\"', e); proto.getDefaultValue() + '\"', e);
} }
} else { } else {
...@@ -1456,7 +1456,7 @@ public final class Descriptors { ...@@ -1456,7 +1456,7 @@ public final class Descriptors {
return file.pool.enumValuesByNumber.get( return file.pool.enumValuesByNumber.get(
new DescriptorPool.DescriptorIntPair(this, number)); new DescriptorPool.DescriptorIntPair(this, number));
} }
/** /**
* Get the enum value for a number. If no enum value has this number, * Get the enum value for a number. If no enum value has this number,
* construct an EnumValueDescriptor for it. * construct an EnumValueDescriptor for it.
...@@ -1494,7 +1494,7 @@ public final class Descriptors { ...@@ -1494,7 +1494,7 @@ public final class Descriptors {
// then remove the whole entry. This way unknown descriptors will // then remove the whole entry. This way unknown descriptors will
// be freed automatically and we don't need to do anything to // be freed automatically and we don't need to do anything to
// clean-up unused map entries. // clean-up unused map entries.
// Note: We must use "new Integer(number)" here because we don't want // Note: We must use "new Integer(number)" here because we don't want
// these Integer objects to be cached. // these Integer objects to be cached.
Integer key = new Integer(number); Integer key = new Integer(number);
...@@ -1509,7 +1509,7 @@ public final class Descriptors { ...@@ -1509,7 +1509,7 @@ public final class Descriptors {
} }
return result; return result;
} }
// Used in tests only. // Used in tests only.
int getUnknownEnumValueDescriptorCount() { int getUnknownEnumValueDescriptorCount() {
return unknownValues.size(); return unknownValues.size();
...@@ -1585,7 +1585,7 @@ public final class Descriptors { ...@@ -1585,7 +1585,7 @@ public final class Descriptors {
/** Get the value's number. */ /** Get the value's number. */
public int getNumber() { return proto.getNumber(); } public int getNumber() { return proto.getNumber(); }
@Override @Override
public String toString() { return proto.getName(); } public String toString() { return proto.getName(); }
...@@ -1627,7 +1627,7 @@ public final class Descriptors { ...@@ -1627,7 +1627,7 @@ public final class Descriptors {
file.pool.addSymbol(this); file.pool.addSymbol(this);
file.pool.addEnumValueByNumber(this); file.pool.addEnumValueByNumber(this);
} }
private Integer number; private Integer number;
// Create an unknown enum value. // Create an unknown enum value.
private EnumValueDescriptor( private EnumValueDescriptor(
...@@ -1643,7 +1643,7 @@ public final class Descriptors { ...@@ -1643,7 +1643,7 @@ public final class Descriptors {
this.type = parent; this.type = parent;
this.fullName = parent.getFullName() + '.' + proto.getName(); this.fullName = parent.getFullName() + '.' + proto.getName();
this.number = number; this.number = number;
// Don't add this descriptor into pool. // Don't add this descriptor into pool.
} }
...@@ -1930,13 +1930,13 @@ public final class Descriptors { ...@@ -1930,13 +1930,13 @@ public final class Descriptors {
* descriptors defined in a particular file. * descriptors defined in a particular file.
*/ */
private static final class DescriptorPool { private static final class DescriptorPool {
/** Defines what subclass of descriptors to search in the descriptor pool. /** Defines what subclass of descriptors to search in the descriptor pool.
*/ */
enum SearchFilter { enum SearchFilter {
TYPES_ONLY, AGGREGATES_ONLY, ALL_SYMBOLS TYPES_ONLY, AGGREGATES_ONLY, ALL_SYMBOLS
} }
DescriptorPool(final FileDescriptor[] dependencies, DescriptorPool(final FileDescriptor[] dependencies,
boolean allowUnknownDependencies) { boolean allowUnknownDependencies) {
this.dependencies = new HashSet<FileDescriptor>(); this.dependencies = new HashSet<FileDescriptor>();
...@@ -1982,9 +1982,9 @@ public final class Descriptors { ...@@ -1982,9 +1982,9 @@ public final class Descriptors {
GenericDescriptor findSymbol(final String fullName) { GenericDescriptor findSymbol(final String fullName) {
return findSymbol(fullName, SearchFilter.ALL_SYMBOLS); return findSymbol(fullName, SearchFilter.ALL_SYMBOLS);
} }
/** Find a descriptor by fully-qualified name and given option to only /** Find a descriptor by fully-qualified name and given option to only
* search valid field type descriptors. * search valid field type descriptors.
*/ */
GenericDescriptor findSymbol(final String fullName, GenericDescriptor findSymbol(final String fullName,
final SearchFilter filter) { final SearchFilter filter) {
...@@ -2013,18 +2013,18 @@ public final class Descriptors { ...@@ -2013,18 +2013,18 @@ public final class Descriptors {
/** Checks if the descriptor is a valid type for a message field. */ /** Checks if the descriptor is a valid type for a message field. */
boolean isType(GenericDescriptor descriptor) { boolean isType(GenericDescriptor descriptor) {
return (descriptor instanceof Descriptor) || return (descriptor instanceof Descriptor) ||
(descriptor instanceof EnumDescriptor); (descriptor instanceof EnumDescriptor);
} }
/** Checks if the descriptor is a valid namespace type. */ /** Checks if the descriptor is a valid namespace type. */
boolean isAggregate(GenericDescriptor descriptor) { boolean isAggregate(GenericDescriptor descriptor) {
return (descriptor instanceof Descriptor) || return (descriptor instanceof Descriptor) ||
(descriptor instanceof EnumDescriptor) || (descriptor instanceof EnumDescriptor) ||
(descriptor instanceof PackageDescriptor) || (descriptor instanceof PackageDescriptor) ||
(descriptor instanceof ServiceDescriptor); (descriptor instanceof ServiceDescriptor);
} }
/** /**
* Look up a type descriptor by name, relative to some other descriptor. * Look up a type descriptor by name, relative to some other descriptor.
* The name may be fully-qualified (with a leading '.'), * The name may be fully-qualified (with a leading '.'),
...@@ -2082,7 +2082,7 @@ public final class Descriptors { ...@@ -2082,7 +2082,7 @@ public final class Descriptors {
// Append firstPart and try to find // Append firstPart and try to find
scopeToTry.append(firstPart); scopeToTry.append(firstPart);
result = findSymbol(scopeToTry.toString(), result = findSymbol(scopeToTry.toString(),
DescriptorPool.SearchFilter.AGGREGATES_ONLY); DescriptorPool.SearchFilter.AGGREGATES_ONLY);
if (result != null) { if (result != null) {
......
...@@ -112,7 +112,7 @@ public class Internal { ...@@ -112,7 +112,7 @@ public class Internal {
* Helper called by generated code to construct default values for bytes * Helper called by generated code to construct default values for bytes
* fields. * fields.
* <p> * <p>
* This is like {@link #bytesDefaultValue}, but returns a byte array. * This is like {@link #bytesDefaultValue}, but returns a byte array.
*/ */
public static byte[] byteArrayDefaultValue(String bytes) { public static byte[] byteArrayDefaultValue(String bytes) {
try { try {
...@@ -129,7 +129,7 @@ public class Internal { ...@@ -129,7 +129,7 @@ public class Internal {
* Helper called by generated code to construct default values for bytes * Helper called by generated code to construct default values for bytes
* fields. * fields.
* <p> * <p>
* This is like {@link #bytesDefaultValue}, but returns a ByteBuffer. * This is like {@link #bytesDefaultValue}, but returns a ByteBuffer.
*/ */
public static ByteBuffer byteBufferDefaultValue(String bytes) { public static ByteBuffer byteBufferDefaultValue(String bytes) {
return ByteBuffer.wrap(byteArrayDefaultValue(bytes)); return ByteBuffer.wrap(byteArrayDefaultValue(bytes));
...@@ -185,7 +185,7 @@ public class Internal { ...@@ -185,7 +185,7 @@ public class Internal {
public static boolean isValidUtf8(ByteString byteString) { public static boolean isValidUtf8(ByteString byteString) {
return byteString.isValidUtf8(); return byteString.isValidUtf8();
} }
/** /**
* Like {@link #isValidUtf8(ByteString)} but for byte arrays. * Like {@link #isValidUtf8(ByteString)} but for byte arrays.
*/ */
...@@ -203,7 +203,7 @@ public class Internal { ...@@ -203,7 +203,7 @@ public class Internal {
throw new RuntimeException("UTF-8 not supported?", e); throw new RuntimeException("UTF-8 not supported?", e);
} }
} }
/** /**
* Helper method to convert a byte array to a string using UTF-8 encoding. * Helper method to convert a byte array to a string using UTF-8 encoding.
*/ */
...@@ -274,7 +274,7 @@ public class Internal { ...@@ -274,7 +274,7 @@ public class Internal {
} }
return hash; return hash;
} }
/** /**
* Helper method for implementing {@link Message#equals(Object)} for bytes field. * Helper method for implementing {@link Message#equals(Object)} for bytes field.
*/ */
...@@ -298,7 +298,7 @@ public class Internal { ...@@ -298,7 +298,7 @@ public class Internal {
} }
return hash; return hash;
} }
/** /**
* Helper method for implementing {@link Message#hashCode()} for bytes field. * Helper method for implementing {@link Message#hashCode()} for bytes field.
*/ */
...@@ -309,7 +309,7 @@ public class Internal { ...@@ -309,7 +309,7 @@ public class Internal {
// based hashCode() method. // based hashCode() method.
return LiteralByteString.hashCode(bytes); return LiteralByteString.hashCode(bytes);
} }
/** /**
* Helper method for implementing {@link Message#equals(Object)} for bytes * Helper method for implementing {@link Message#equals(Object)} for bytes
* field. * field.
...@@ -322,7 +322,7 @@ public class Internal { ...@@ -322,7 +322,7 @@ public class Internal {
// compare all the content. // compare all the content.
return a.duplicate().clear().equals(b.duplicate().clear()); return a.duplicate().clear().equals(b.duplicate().clear());
} }
/** /**
* Helper method for implementing {@link Message#equals(Object)} for bytes * Helper method for implementing {@link Message#equals(Object)} for bytes
* field. * field.
...@@ -351,9 +351,9 @@ public class Internal { ...@@ -351,9 +351,9 @@ public class Internal {
} }
return hash; return hash;
} }
private static final int DEFAULT_BUFFER_SIZE = 4096; private static final int DEFAULT_BUFFER_SIZE = 4096;
/** /**
* Helper method for implementing {@link Message#hashCode()} for bytes * Helper method for implementing {@link Message#hashCode()} for bytes
* field. * field.
...@@ -382,18 +382,18 @@ public class Internal { ...@@ -382,18 +382,18 @@ public class Internal {
return h == 0 ? 1 : h; return h == 0 ? 1 : h;
} }
} }
/** /**
* An empty byte array constant used in generated code. * An empty byte array constant used in generated code.
*/ */
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
/** /**
* An empty byte array constant used in generated code. * An empty byte array constant used in generated code.
*/ */
public static final ByteBuffer EMPTY_BYTE_BUFFER = public static final ByteBuffer EMPTY_BYTE_BUFFER =
ByteBuffer.wrap(EMPTY_BYTE_ARRAY); ByteBuffer.wrap(EMPTY_BYTE_ARRAY);
/** An empty coded input stream constant used in generated code. */ /** An empty coded input stream constant used in generated code. */
public static final CodedInputStream EMPTY_CODED_INPUT_STREAM = public static final CodedInputStream EMPTY_CODED_INPUT_STREAM =
CodedInputStream.newInstance(EMPTY_BYTE_ARRAY); CodedInputStream.newInstance(EMPTY_BYTE_ARRAY);
...@@ -458,13 +458,13 @@ public class Internal { ...@@ -458,13 +458,13 @@ public class Internal {
private final Map<K, RealValue> realMap; private final Map<K, RealValue> realMap;
private final Converter<RealValue, V> valueConverter; private final Converter<RealValue, V> valueConverter;
public MapAdapter(Map<K, RealValue> realMap, public MapAdapter(Map<K, RealValue> realMap,
Converter<RealValue, V> valueConverter) { Converter<RealValue, V> valueConverter) {
this.realMap = realMap; this.realMap = realMap;
this.valueConverter = valueConverter; this.valueConverter = valueConverter;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public V get(Object key) { public V get(Object key) {
...@@ -474,7 +474,7 @@ public class Internal { ...@@ -474,7 +474,7 @@ public class Internal {
} }
return valueConverter.doForward(result); return valueConverter.doForward(result);
} }
@Override @Override
public V put(K key, V value) { public V put(K key, V value) {
RealValue oldValue = realMap.put(key, valueConverter.doBackward(value)); RealValue oldValue = realMap.put(key, valueConverter.doBackward(value));
...@@ -488,13 +488,13 @@ public class Internal { ...@@ -488,13 +488,13 @@ public class Internal {
public Set<java.util.Map.Entry<K, V>> entrySet() { public Set<java.util.Map.Entry<K, V>> entrySet() {
return new SetAdapter(realMap.entrySet()); return new SetAdapter(realMap.entrySet());
} }
private class SetAdapter extends AbstractSet<Map.Entry<K, V>> { private class SetAdapter extends AbstractSet<Map.Entry<K, V>> {
private final Set<Map.Entry<K, RealValue>> realSet; private final Set<Map.Entry<K, RealValue>> realSet;
public SetAdapter(Set<Map.Entry<K, RealValue>> realSet) { public SetAdapter(Set<Map.Entry<K, RealValue>> realSet) {
this.realSet = realSet; this.realSet = realSet;
} }
@Override @Override
public Iterator<java.util.Map.Entry<K, V>> iterator() { public Iterator<java.util.Map.Entry<K, V>> iterator() {
return new IteratorAdapter(realSet.iterator()); return new IteratorAdapter(realSet.iterator());
...@@ -503,17 +503,17 @@ public class Internal { ...@@ -503,17 +503,17 @@ public class Internal {
@Override @Override
public int size() { public int size() {
return realSet.size(); return realSet.size();
} }
} }
private class IteratorAdapter implements Iterator<Map.Entry<K, V>> { private class IteratorAdapter implements Iterator<Map.Entry<K, V>> {
private final Iterator<Map.Entry<K, RealValue>> realIterator; private final Iterator<Map.Entry<K, RealValue>> realIterator;
public IteratorAdapter( public IteratorAdapter(
Iterator<Map.Entry<K, RealValue>> realIterator) { Iterator<Map.Entry<K, RealValue>> realIterator) {
this.realIterator = realIterator; this.realIterator = realIterator;
} }
@Override @Override
public boolean hasNext() { public boolean hasNext() {
return realIterator.hasNext(); return realIterator.hasNext();
...@@ -529,14 +529,14 @@ public class Internal { ...@@ -529,14 +529,14 @@ public class Internal {
realIterator.remove(); realIterator.remove();
} }
} }
private class EntryAdapter implements Map.Entry<K, V> { private class EntryAdapter implements Map.Entry<K, V> {
private final Map.Entry<K, RealValue> realEntry; private final Map.Entry<K, RealValue> realEntry;
public EntryAdapter(Map.Entry<K, RealValue> realEntry) { public EntryAdapter(Map.Entry<K, RealValue> realEntry) {
this.realEntry = realEntry; this.realEntry = realEntry;
} }
@Override @Override
public K getKey() { public K getKey() {
return realEntry.getKey(); return realEntry.getKey();
......
...@@ -112,7 +112,7 @@ class LiteralByteString extends ByteString { ...@@ -112,7 +112,7 @@ class LiteralByteString extends ByteString {
// ByteString -> byte[] // ByteString -> byte[]
@Override @Override
protected void copyToInternal(byte[] target, int sourceOffset, protected void copyToInternal(byte[] target, int sourceOffset,
int targetOffset, int numberToCopy) { int targetOffset, int numberToCopy) {
// Optimized form, not for subclasses, since we don't call // Optimized form, not for subclasses, since we don't call
// getOffsetIntoBytes() or check the 'numberToCopy' parameter. // getOffsetIntoBytes() or check the 'numberToCopy' parameter.
...@@ -199,12 +199,12 @@ class LiteralByteString extends ByteString { ...@@ -199,12 +199,12 @@ class LiteralByteString extends ByteString {
LiteralByteString otherAsLiteral = (LiteralByteString) other; LiteralByteString otherAsLiteral = (LiteralByteString) other;
// If we know the hash codes and they are not equal, we know the byte // If we know the hash codes and they are not equal, we know the byte
// strings are not equal. // strings are not equal.
if (hash != 0 if (hash != 0
&& otherAsLiteral.hash != 0 && otherAsLiteral.hash != 0
&& hash != otherAsLiteral.hash) { && hash != otherAsLiteral.hash) {
return false; return false;
} }
return equalsRange((LiteralByteString) other, 0, size()); return equalsRange((LiteralByteString) other, 0, size());
} else if (other instanceof RopeByteString) { } else if (other instanceof RopeByteString) {
return other.equals(this); return other.equals(this);
...@@ -285,14 +285,14 @@ class LiteralByteString extends ByteString { ...@@ -285,14 +285,14 @@ class LiteralByteString extends ByteString {
protected int partialHash(int h, int offset, int length) { protected int partialHash(int h, int offset, int length) {
return hashCode(h, bytes, getOffsetIntoBytes() + offset, length); return hashCode(h, bytes, getOffsetIntoBytes() + offset, length);
} }
static int hashCode(int h, byte[] bytes, int offset, int length) { static int hashCode(int h, byte[] bytes, int offset, int length) {
for (int i = offset; i < offset + length; i++) { for (int i = offset; i < offset + length; i++) {
h = h * 31 + bytes[i]; h = h * 31 + bytes[i];
} }
return h; return h;
} }
static int hashCode(byte[] bytes) { static int hashCode(byte[] bytes) {
int h = hashCode(bytes.length, bytes, 0, bytes.length); int h = hashCode(bytes.length, bytes, 0, bytes.length);
return h == 0 ? 1 : h; return h == 0 ? 1 : h;
......
...@@ -380,7 +380,7 @@ public class ByteStringTest extends TestCase { ...@@ -380,7 +380,7 @@ public class ByteStringTest extends TestCase {
return -1; return -1;
} }
} }
// A stream which exposes the byte array passed into write(byte[], int, int). // A stream which exposes the byte array passed into write(byte[], int, int).
private static class EvilOutputStream extends OutputStream { private static class EvilOutputStream extends OutputStream {
public byte[] capturedArray = null; public byte[] capturedArray = null;
...@@ -492,13 +492,13 @@ public class ByteStringTest extends TestCase { ...@@ -492,13 +492,13 @@ public class ByteStringTest extends TestCase {
isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length)); isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length));
} }
} }
public void testNewOutputEmpty() throws IOException { public void testNewOutputEmpty() throws IOException {
// Make sure newOutput() correctly builds empty byte strings // Make sure newOutput() correctly builds empty byte strings
ByteString byteString = ByteString.newOutput().toByteString(); ByteString byteString = ByteString.newOutput().toByteString();
assertEquals(ByteString.EMPTY, byteString); assertEquals(ByteString.EMPTY, byteString);
} }
public void testNewOutput_Mutating() throws IOException { public void testNewOutput_Mutating() throws IOException {
Output os = ByteString.newOutput(5); Output os = ByteString.newOutput(5);
os.write(new byte[] {1, 2, 3, 4, 5}); os.write(new byte[] {1, 2, 3, 4, 5});
...@@ -705,14 +705,14 @@ public class ByteStringTest extends TestCase { ...@@ -705,14 +705,14 @@ public class ByteStringTest extends TestCase {
} }
return pieces; return pieces;
} }
private byte[] substringUsingWriteTo( private byte[] substringUsingWriteTo(
ByteString data, int offset, int length) throws IOException { ByteString data, int offset, int length) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();
data.writeTo(output, offset, length); data.writeTo(output, offset, length);
return output.toByteArray(); return output.toByteArray();
} }
public void testWriteToOutputStream() throws Exception { public void testWriteToOutputStream() throws Exception {
// Choose a size large enough so when two ByteStrings are concatenated they // Choose a size large enough so when two ByteStrings are concatenated they
// won't be merged into one byte array due to some optimizations. // won't be merged into one byte array due to some optimizations.
...@@ -727,7 +727,7 @@ public class ByteStringTest extends TestCase { ...@@ -727,7 +727,7 @@ public class ByteStringTest extends TestCase {
byte[] result = substringUsingWriteTo(left, 1, 1); byte[] result = substringUsingWriteTo(left, 1, 1);
assertEquals(1, result.length); assertEquals(1, result.length);
assertEquals((byte) 11, result[0]); assertEquals((byte) 11, result[0]);
byte[] data2 = new byte[dataSize]; byte[] data2 = new byte[dataSize];
for (int i = 0; i < data1.length; i++) { for (int i = 0; i < data1.length; i++) {
data2[i] = (byte) 2; data2[i] = (byte) 2;
......
...@@ -330,7 +330,7 @@ public class CodedOutputStreamTest extends TestCase { ...@@ -330,7 +330,7 @@ public class CodedOutputStreamTest extends TestCase {
assertTrue(codedStream.getTotalBytesWritten() > BUFFER_SIZE); assertTrue(codedStream.getTotalBytesWritten() > BUFFER_SIZE);
assertEquals(value.length * 1024, codedStream.getTotalBytesWritten()); assertEquals(value.length * 1024, codedStream.getTotalBytesWritten());
} }
public void testWriteToByteBuffer() throws Exception { public void testWriteToByteBuffer() throws Exception {
final int bufferSize = 16 * 1024; final int bufferSize = 16 * 1024;
ByteBuffer buffer = ByteBuffer.allocate(bufferSize); ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
...@@ -351,7 +351,7 @@ public class CodedOutputStreamTest extends TestCase { ...@@ -351,7 +351,7 @@ public class CodedOutputStreamTest extends TestCase {
codedStream.writeRawByte((byte) 3); codedStream.writeRawByte((byte) 3);
} }
codedStream.flush(); codedStream.flush();
// Check that data is correctly written to the ByteBuffer. // Check that data is correctly written to the ByteBuffer.
assertEquals(0, buffer.remaining()); assertEquals(0, buffer.remaining());
buffer.flip(); buffer.flip();
...@@ -365,7 +365,7 @@ public class CodedOutputStreamTest extends TestCase { ...@@ -365,7 +365,7 @@ public class CodedOutputStreamTest extends TestCase {
assertEquals((byte) 3, buffer.get()); assertEquals((byte) 3, buffer.get());
} }
} }
public void testWriteByteBuffer() throws Exception { public void testWriteByteBuffer() throws Exception {
byte[] value = "abcde".getBytes("UTF-8"); byte[] value = "abcde".getBytes("UTF-8");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
...@@ -377,10 +377,10 @@ public class CodedOutputStreamTest extends TestCase { ...@@ -377,10 +377,10 @@ public class CodedOutputStreamTest extends TestCase {
// The above call shouldn't affect the ByteBuffer's state. // The above call shouldn't affect the ByteBuffer's state.
assertEquals(0, byteBuffer.position()); assertEquals(0, byteBuffer.position());
assertEquals(1, byteBuffer.limit()); assertEquals(1, byteBuffer.limit());
// The correct way to write part of an array using ByteBuffer. // The correct way to write part of an array using ByteBuffer.
codedStream.writeRawBytes(ByteBuffer.wrap(value, 2, 1).slice()); codedStream.writeRawBytes(ByteBuffer.wrap(value, 2, 1).slice());
codedStream.flush(); codedStream.flush();
byte[] result = outputStream.toByteArray(); byte[] result = outputStream.toByteArray();
assertEquals(6, result.length); assertEquals(6, result.length);
......
...@@ -497,7 +497,7 @@ public class DescriptorsTest extends TestCase { ...@@ -497,7 +497,7 @@ public class DescriptorsTest extends TestCase {
.build(); .build();
// translate and crosslink // translate and crosslink
FileDescriptor file = FileDescriptor file =
Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, Descriptors.FileDescriptor.buildFrom(fileDescriptorProto,
new FileDescriptor[0]); new FileDescriptor[0]);
// verify resulting descriptors // verify resulting descriptors
assertNotNull(file); assertNotNull(file);
...@@ -518,7 +518,7 @@ public class DescriptorsTest extends TestCase { ...@@ -518,7 +518,7 @@ public class DescriptorsTest extends TestCase {
} }
assertTrue(barFound); assertTrue(barFound);
} }
public void testDependencyOrder() throws Exception { public void testDependencyOrder() throws Exception {
FileDescriptorProto fooProto = FileDescriptorProto.newBuilder() FileDescriptorProto fooProto = FileDescriptorProto.newBuilder()
.setName("foo.proto").build(); .setName("foo.proto").build();
...@@ -537,14 +537,14 @@ public class DescriptorsTest extends TestCase { ...@@ -537,14 +537,14 @@ public class DescriptorsTest extends TestCase {
new FileDescriptor[0]); new FileDescriptor[0]);
FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(barProto, FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(barProto,
new FileDescriptor[] {fooFile}); new FileDescriptor[] {fooFile});
// Items in the FileDescriptor array can be in any order. // Items in the FileDescriptor array can be in any order.
Descriptors.FileDescriptor.buildFrom(bazProto, Descriptors.FileDescriptor.buildFrom(bazProto,
new FileDescriptor[] {fooFile, barFile}); new FileDescriptor[] {fooFile, barFile});
Descriptors.FileDescriptor.buildFrom(bazProto, Descriptors.FileDescriptor.buildFrom(bazProto,
new FileDescriptor[] {barFile, fooFile}); new FileDescriptor[] {barFile, fooFile});
} }
public void testInvalidPublicDependency() throws Exception { public void testInvalidPublicDependency() throws Exception {
FileDescriptorProto fooProto = FileDescriptorProto.newBuilder() FileDescriptorProto fooProto = FileDescriptorProto.newBuilder()
.setName("foo.proto").build(); .setName("foo.proto").build();
...@@ -628,7 +628,7 @@ public class DescriptorsTest extends TestCase { ...@@ -628,7 +628,7 @@ public class DescriptorsTest extends TestCase {
Descriptors.FileDescriptor.buildFrom( Descriptors.FileDescriptor.buildFrom(
fooProto, new FileDescriptor[] {forwardFile}); fooProto, new FileDescriptor[] {forwardFile});
} }
/** /**
* Tests the translate/crosslink for an example with a more complex namespace * Tests the translate/crosslink for an example with a more complex namespace
* referencing. * referencing.
...@@ -677,7 +677,7 @@ public class DescriptorsTest extends TestCase { ...@@ -677,7 +677,7 @@ public class DescriptorsTest extends TestCase {
assertTrue(field.getEnumType().getFile().getName().equals("bar.proto")); assertTrue(field.getEnumType().getFile().getName().equals("bar.proto"));
assertTrue(field.getEnumType().getFile().getPackage().equals( assertTrue(field.getEnumType().getFile().getPackage().equals(
"a.b.c.d.bar.shared")); "a.b.c.d.bar.shared"));
} }
} }
public void testOneofDescriptor() throws Exception { public void testOneofDescriptor() throws Exception {
......
...@@ -248,7 +248,7 @@ public class LiteralByteStringTest extends TestCase { ...@@ -248,7 +248,7 @@ public class LiteralByteStringTest extends TestCase {
assertTrue(classUnderTest + ".writeTo() must give back the same bytes", assertTrue(classUnderTest + ".writeTo() must give back the same bytes",
Arrays.equals(referenceBytes, roundTripBytes)); Arrays.equals(referenceBytes, roundTripBytes));
} }
public void testWriteTo_mutating() throws IOException { public void testWriteTo_mutating() throws IOException {
OutputStream os = new OutputStream() { OutputStream os = new OutputStream() {
@Override @Override
......
...@@ -35,7 +35,7 @@ import java.util.Iterator; ...@@ -35,7 +35,7 @@ import java.util.Iterator;
/** /**
* This class tests {@link RopeByteString#substring(int, int)} by inheriting the tests from * This class tests {@link RopeByteString#substring(int, int)} by inheriting the tests from
* {@link LiteralByteStringTest}. Only a couple of methods are overridden. * {@link LiteralByteStringTest}. Only a couple of methods are overridden.
* *
* @author carlanton@google.com (Carl Haverl) * @author carlanton@google.com (Carl Haverl)
*/ */
......
...@@ -42,7 +42,7 @@ import java.util.Iterator; ...@@ -42,7 +42,7 @@ import java.util.Iterator;
/** /**
* This class tests {@link RopeByteString} by inheriting the tests from * This class tests {@link RopeByteString} by inheriting the tests from
* {@link LiteralByteStringTest}. Only a couple of methods are overridden. * {@link LiteralByteStringTest}. Only a couple of methods are overridden.
* *
* <p>A full test of the result of {@link RopeByteString#substring(int, int)} is found in the * <p>A full test of the result of {@link RopeByteString#substring(int, int)} is found in the
* separate class {@link RopeByteStringSubstringTest}. * separate class {@link RopeByteStringSubstringTest}.
* *
......
...@@ -863,7 +863,7 @@ public class TextFormatTest extends TestCase { ...@@ -863,7 +863,7 @@ public class TextFormatTest extends TestCase {
TextFormat.merge(TextFormat.printToUnicodeString(message), builder); TextFormat.merge(TextFormat.printToUnicodeString(message), builder);
assertEquals(message.getOptionalString(), builder.getOptionalString()); assertEquals(message.getOptionalString(), builder.getOptionalString());
} }
public void testPrintToUnicodeStringWithNewlines() throws Exception { public void testPrintToUnicodeStringWithNewlines() throws Exception {
// No newlines at start and end // No newlines at start and end
assertEquals("optional_string: \"test newlines\\n\\nin\\nstring\"\n", assertEquals("optional_string: \"test newlines\\n\\nin\\nstring\"\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment