From 7139d1eff739682a088ea2c2dbdfef2f108321f8 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 31 Mar 2015 10:29:58 -0700 Subject: Whitespace --- .../main/java/com/google/protobuf/ByteString.java | 10 ++--- .../com/google/protobuf/CodedOutputStream.java | 4 +- .../main/java/com/google/protobuf/Descriptors.java | 52 +++++++++++----------- .../main/java/com/google/protobuf/Internal.java | 50 ++++++++++----------- .../com/google/protobuf/LiteralByteString.java | 12 ++--- .../java/com/google/protobuf/ByteStringTest.java | 12 ++--- .../com/google/protobuf/CodedOutputStreamTest.java | 10 ++--- .../java/com/google/protobuf/DescriptorsTest.java | 14 +++--- .../com/google/protobuf/LiteralByteStringTest.java | 2 +- .../protobuf/RopeByteStringSubstringTest.java | 2 +- .../com/google/protobuf/RopeByteStringTest.java | 2 +- .../java/com/google/protobuf/TextFormatTest.java | 2 +- 12 files changed, 86 insertions(+), 86 deletions(-) (limited to 'java/src') diff --git a/java/src/main/java/com/google/protobuf/ByteString.java b/java/src/main/java/com/google/protobuf/ByteString.java index 9b0a524b..637df5f4 100644 --- a/java/src/main/java/com/google/protobuf/ByteString.java +++ b/java/src/main/java/com/google/protobuf/ByteString.java @@ -507,7 +507,7 @@ public abstract class ByteString implements Iterable, Serializable { /** * Internal (package private) implementation of * {@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}. */ protected abstract void copyToInternal(byte[] target, int sourceOffset, @@ -546,7 +546,7 @@ public abstract class ByteString implements Iterable, Serializable { * @throws IOException if an I/O error occurs. */ public abstract void writeTo(OutputStream out) throws IOException; - + /** * Writes a specified part of this byte string to an output stream. * @@ -572,7 +572,7 @@ public abstract class ByteString implements Iterable, Serializable { if (numberToWrite > 0) { writeToInternal(out, sourceOffset, numberToWrite); } - + } /** @@ -599,7 +599,7 @@ public abstract class ByteString implements Iterable, Serializable { *

* By returning a list, implementations of this method may be able to avoid * copying even when there are multiple backing arrays. - * + * * @return a list of wrapped bytes */ public abstract List asReadOnlyByteBufferList(); @@ -831,7 +831,7 @@ public abstract class ByteString implements Iterable, Serializable { flushLastBuffer(); return ByteString.copyFrom(flushedBuffers); } - + /** * Implement java.util.Arrays.copyOf() for jdk 1.5. */ diff --git a/java/src/main/java/com/google/protobuf/CodedOutputStream.java b/java/src/main/java/com/google/protobuf/CodedOutputStream.java index fafe0356..cb318480 100644 --- a/java/src/main/java/com/google/protobuf/CodedOutputStream.java +++ b/java/src/main/java/com/google/protobuf/CodedOutputStream.java @@ -144,7 +144,7 @@ public final class CodedOutputStream { int bufferSize) { return newInstance(new ByteBufferOutputStream(byteBuffer), bufferSize); } - + private static class ByteBufferOutputStream extends OutputStream { private final ByteBuffer byteBuffer; public ByteBufferOutputStream(ByteBuffer byteBuffer) { @@ -750,7 +750,7 @@ public final class CodedOutputStream { computeUInt32Size(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber) + computeLazyFieldSize(WireFormat.MESSAGE_SET_MESSAGE, value); } - + // ----------------------------------------------------------------- /** diff --git a/java/src/main/java/com/google/protobuf/Descriptors.java b/java/src/main/java/com/google/protobuf/Descriptors.java index 806f46c1..d819a8ad 100644 --- a/java/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/src/main/java/com/google/protobuf/Descriptors.java @@ -256,7 +256,7 @@ public final class Descriptors { throws DescriptorValidationException { return buildFrom(proto, dependencies, false); } - + /** * Construct a {@code FileDescriptor}. @@ -495,9 +495,9 @@ public final class Descriptors { 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) throws DescriptorValidationException { @@ -561,7 +561,7 @@ public final class Descriptors { extensions[i].setProto(proto.getExtension(i)); } } - + boolean supportsUnknownEnumValue() { return getSyntax() == Syntax.PROTO3; } @@ -745,7 +745,7 @@ public final class Descriptors { this.fields = new FieldDescriptor[0]; this.extensions = new FieldDescriptor[0]; this.oneofs = new OneofDescriptor[0]; - + // Create a placeholder FileDescriptor to hold this message. this.file = new FileDescriptor(packageName, this); } @@ -1333,8 +1333,8 @@ public final class Descriptors { "Message type had default value."); } } catch (NumberFormatException e) { - throw new DescriptorValidationException(this, - "Could not parse default value: \"" + + throw new DescriptorValidationException(this, + "Could not parse default value: \"" + proto.getDefaultValue() + '\"', e); } } else { @@ -1456,7 +1456,7 @@ public final class Descriptors { return file.pool.enumValuesByNumber.get( new DescriptorPool.DescriptorIntPair(this, number)); } - + /** * Get the enum value for a number. If no enum value has this number, * construct an EnumValueDescriptor for it. @@ -1494,7 +1494,7 @@ public final class Descriptors { // then remove the whole entry. This way unknown descriptors will // be freed automatically and we don't need to do anything to // clean-up unused map entries. - + // Note: We must use "new Integer(number)" here because we don't want // these Integer objects to be cached. Integer key = new Integer(number); @@ -1509,7 +1509,7 @@ public final class Descriptors { } return result; } - + // Used in tests only. int getUnknownEnumValueDescriptorCount() { return unknownValues.size(); @@ -1585,7 +1585,7 @@ public final class Descriptors { /** Get the value's number. */ public int getNumber() { return proto.getNumber(); } - + @Override public String toString() { return proto.getName(); } @@ -1627,7 +1627,7 @@ public final class Descriptors { file.pool.addSymbol(this); file.pool.addEnumValueByNumber(this); } - + private Integer number; // Create an unknown enum value. private EnumValueDescriptor( @@ -1643,7 +1643,7 @@ public final class Descriptors { this.type = parent; this.fullName = parent.getFullName() + '.' + proto.getName(); this.number = number; - + // Don't add this descriptor into pool. } @@ -1930,13 +1930,13 @@ public final class Descriptors { * descriptors defined in a particular file. */ 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 { TYPES_ONLY, AGGREGATES_ONLY, ALL_SYMBOLS } - + DescriptorPool(final FileDescriptor[] dependencies, boolean allowUnknownDependencies) { this.dependencies = new HashSet(); @@ -1982,9 +1982,9 @@ public final class Descriptors { GenericDescriptor findSymbol(final String fullName) { return findSymbol(fullName, SearchFilter.ALL_SYMBOLS); } - - /** Find a descriptor by fully-qualified name and given option to only - * search valid field type descriptors. + + /** Find a descriptor by fully-qualified name and given option to only + * search valid field type descriptors. */ GenericDescriptor findSymbol(final String fullName, final SearchFilter filter) { @@ -2013,18 +2013,18 @@ public final class Descriptors { /** Checks if the descriptor is a valid type for a message field. */ boolean isType(GenericDescriptor descriptor) { - return (descriptor instanceof Descriptor) || + return (descriptor instanceof Descriptor) || (descriptor instanceof EnumDescriptor); } - + /** Checks if the descriptor is a valid namespace type. */ boolean isAggregate(GenericDescriptor descriptor) { - return (descriptor instanceof Descriptor) || - (descriptor instanceof EnumDescriptor) || - (descriptor instanceof PackageDescriptor) || + return (descriptor instanceof Descriptor) || + (descriptor instanceof EnumDescriptor) || + (descriptor instanceof PackageDescriptor) || (descriptor instanceof ServiceDescriptor); } - + /** * Look up a type descriptor by name, relative to some other descriptor. * The name may be fully-qualified (with a leading '.'), @@ -2082,7 +2082,7 @@ public final class Descriptors { // Append firstPart and try to find scopeToTry.append(firstPart); - result = findSymbol(scopeToTry.toString(), + result = findSymbol(scopeToTry.toString(), DescriptorPool.SearchFilter.AGGREGATES_ONLY); if (result != null) { diff --git a/java/src/main/java/com/google/protobuf/Internal.java b/java/src/main/java/com/google/protobuf/Internal.java index 5a0de6d1..b9a8a994 100644 --- a/java/src/main/java/com/google/protobuf/Internal.java +++ b/java/src/main/java/com/google/protobuf/Internal.java @@ -112,7 +112,7 @@ public class Internal { * Helper called by generated code to construct default values for bytes * fields. *

- * 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) { try { @@ -129,7 +129,7 @@ public class Internal { * Helper called by generated code to construct default values for bytes * fields. *

- * This is like {@link #bytesDefaultValue}, but returns a ByteBuffer. + * This is like {@link #bytesDefaultValue}, but returns a ByteBuffer. */ public static ByteBuffer byteBufferDefaultValue(String bytes) { return ByteBuffer.wrap(byteArrayDefaultValue(bytes)); @@ -185,7 +185,7 @@ public class Internal { public static boolean isValidUtf8(ByteString byteString) { return byteString.isValidUtf8(); } - + /** * Like {@link #isValidUtf8(ByteString)} but for byte arrays. */ @@ -203,7 +203,7 @@ public class Internal { throw new RuntimeException("UTF-8 not supported?", e); } } - + /** * Helper method to convert a byte array to a string using UTF-8 encoding. */ @@ -274,7 +274,7 @@ public class Internal { } return hash; } - + /** * Helper method for implementing {@link Message#equals(Object)} for bytes field. */ @@ -298,7 +298,7 @@ public class Internal { } return hash; } - + /** * Helper method for implementing {@link Message#hashCode()} for bytes field. */ @@ -309,7 +309,7 @@ public class Internal { // based hashCode() method. return LiteralByteString.hashCode(bytes); } - + /** * Helper method for implementing {@link Message#equals(Object)} for bytes * field. @@ -322,7 +322,7 @@ public class Internal { // compare all the content. return a.duplicate().clear().equals(b.duplicate().clear()); } - + /** * Helper method for implementing {@link Message#equals(Object)} for bytes * field. @@ -351,9 +351,9 @@ public class Internal { } return hash; } - + private static final int DEFAULT_BUFFER_SIZE = 4096; - + /** * Helper method for implementing {@link Message#hashCode()} for bytes * field. @@ -382,18 +382,18 @@ public class Internal { return h == 0 ? 1 : h; } } - + /** * An empty byte array constant used in generated code. */ public static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; - + /** * An empty byte array constant used in generated code. */ public static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.wrap(EMPTY_BYTE_ARRAY); - + /** An empty coded input stream constant used in generated code. */ public static final CodedInputStream EMPTY_CODED_INPUT_STREAM = CodedInputStream.newInstance(EMPTY_BYTE_ARRAY); @@ -458,13 +458,13 @@ public class Internal { private final Map realMap; private final Converter valueConverter; - + public MapAdapter(Map realMap, Converter valueConverter) { this.realMap = realMap; this.valueConverter = valueConverter; } - + @SuppressWarnings("unchecked") @Override public V get(Object key) { @@ -474,7 +474,7 @@ public class Internal { } return valueConverter.doForward(result); } - + @Override public V put(K key, V value) { RealValue oldValue = realMap.put(key, valueConverter.doBackward(value)); @@ -488,13 +488,13 @@ public class Internal { public Set> entrySet() { return new SetAdapter(realMap.entrySet()); } - + private class SetAdapter extends AbstractSet> { private final Set> realSet; public SetAdapter(Set> realSet) { this.realSet = realSet; } - + @Override public Iterator> iterator() { return new IteratorAdapter(realSet.iterator()); @@ -503,17 +503,17 @@ public class Internal { @Override public int size() { return realSet.size(); - } + } } - + private class IteratorAdapter implements Iterator> { private final Iterator> realIterator; - + public IteratorAdapter( Iterator> realIterator) { this.realIterator = realIterator; } - + @Override public boolean hasNext() { return realIterator.hasNext(); @@ -529,14 +529,14 @@ public class Internal { realIterator.remove(); } } - + private class EntryAdapter implements Map.Entry { private final Map.Entry realEntry; - + public EntryAdapter(Map.Entry realEntry) { this.realEntry = realEntry; } - + @Override public K getKey() { return realEntry.getKey(); diff --git a/java/src/main/java/com/google/protobuf/LiteralByteString.java b/java/src/main/java/com/google/protobuf/LiteralByteString.java index 6893ddf1..81d8e74b 100644 --- a/java/src/main/java/com/google/protobuf/LiteralByteString.java +++ b/java/src/main/java/com/google/protobuf/LiteralByteString.java @@ -112,7 +112,7 @@ class LiteralByteString extends ByteString { // ByteString -> byte[] @Override - protected void copyToInternal(byte[] target, int sourceOffset, + protected void copyToInternal(byte[] target, int sourceOffset, int targetOffset, int numberToCopy) { // Optimized form, not for subclasses, since we don't call // getOffsetIntoBytes() or check the 'numberToCopy' parameter. @@ -199,12 +199,12 @@ class LiteralByteString extends ByteString { LiteralByteString otherAsLiteral = (LiteralByteString) other; // If we know the hash codes and they are not equal, we know the byte // strings are not equal. - if (hash != 0 - && otherAsLiteral.hash != 0 + if (hash != 0 + && otherAsLiteral.hash != 0 && hash != otherAsLiteral.hash) { return false; } - + return equalsRange((LiteralByteString) other, 0, size()); } else if (other instanceof RopeByteString) { return other.equals(this); @@ -285,14 +285,14 @@ class LiteralByteString extends ByteString { protected int partialHash(int h, int offset, int length) { return hashCode(h, bytes, getOffsetIntoBytes() + offset, length); } - + static int hashCode(int h, byte[] bytes, int offset, int length) { for (int i = offset; i < offset + length; i++) { h = h * 31 + bytes[i]; } return h; } - + static int hashCode(byte[] bytes) { int h = hashCode(bytes.length, bytes, 0, bytes.length); return h == 0 ? 1 : h; diff --git a/java/src/test/java/com/google/protobuf/ByteStringTest.java b/java/src/test/java/com/google/protobuf/ByteStringTest.java index 15de17cd..8d026190 100644 --- a/java/src/test/java/com/google/protobuf/ByteStringTest.java +++ b/java/src/test/java/com/google/protobuf/ByteStringTest.java @@ -380,7 +380,7 @@ public class ByteStringTest extends TestCase { return -1; } } - + // A stream which exposes the byte array passed into write(byte[], int, int). private static class EvilOutputStream extends OutputStream { public byte[] capturedArray = null; @@ -492,13 +492,13 @@ public class ByteStringTest extends TestCase { isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length)); } } - + public void testNewOutputEmpty() throws IOException { // Make sure newOutput() correctly builds empty byte strings ByteString byteString = ByteString.newOutput().toByteString(); assertEquals(ByteString.EMPTY, byteString); } - + public void testNewOutput_Mutating() throws IOException { Output os = ByteString.newOutput(5); os.write(new byte[] {1, 2, 3, 4, 5}); @@ -705,14 +705,14 @@ public class ByteStringTest extends TestCase { } return pieces; } - + private byte[] substringUsingWriteTo( ByteString data, int offset, int length) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); data.writeTo(output, offset, length); return output.toByteArray(); } - + public void testWriteToOutputStream() throws Exception { // Choose a size large enough so when two ByteStrings are concatenated they // won't be merged into one byte array due to some optimizations. @@ -727,7 +727,7 @@ public class ByteStringTest extends TestCase { byte[] result = substringUsingWriteTo(left, 1, 1); assertEquals(1, result.length); assertEquals((byte) 11, result[0]); - + byte[] data2 = new byte[dataSize]; for (int i = 0; i < data1.length; i++) { data2[i] = (byte) 2; diff --git a/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java b/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java index 0785cc91..ec0c3e1c 100644 --- a/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java +++ b/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java @@ -330,7 +330,7 @@ public class CodedOutputStreamTest extends TestCase { assertTrue(codedStream.getTotalBytesWritten() > BUFFER_SIZE); assertEquals(value.length * 1024, codedStream.getTotalBytesWritten()); } - + public void testWriteToByteBuffer() throws Exception { final int bufferSize = 16 * 1024; ByteBuffer buffer = ByteBuffer.allocate(bufferSize); @@ -351,7 +351,7 @@ public class CodedOutputStreamTest extends TestCase { codedStream.writeRawByte((byte) 3); } codedStream.flush(); - + // Check that data is correctly written to the ByteBuffer. assertEquals(0, buffer.remaining()); buffer.flip(); @@ -365,7 +365,7 @@ public class CodedOutputStreamTest extends TestCase { assertEquals((byte) 3, buffer.get()); } } - + public void testWriteByteBuffer() throws Exception { byte[] value = "abcde".getBytes("UTF-8"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); @@ -377,10 +377,10 @@ public class CodedOutputStreamTest extends TestCase { // The above call shouldn't affect the ByteBuffer's state. assertEquals(0, byteBuffer.position()); assertEquals(1, byteBuffer.limit()); - + // The correct way to write part of an array using ByteBuffer. codedStream.writeRawBytes(ByteBuffer.wrap(value, 2, 1).slice()); - + codedStream.flush(); byte[] result = outputStream.toByteArray(); assertEquals(6, result.length); diff --git a/java/src/test/java/com/google/protobuf/DescriptorsTest.java b/java/src/test/java/com/google/protobuf/DescriptorsTest.java index 05832a12..0fe883bb 100644 --- a/java/src/test/java/com/google/protobuf/DescriptorsTest.java +++ b/java/src/test/java/com/google/protobuf/DescriptorsTest.java @@ -497,7 +497,7 @@ public class DescriptorsTest extends TestCase { .build(); // translate and crosslink FileDescriptor file = - Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, + Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, new FileDescriptor[0]); // verify resulting descriptors assertNotNull(file); @@ -518,7 +518,7 @@ public class DescriptorsTest extends TestCase { } assertTrue(barFound); } - + public void testDependencyOrder() throws Exception { FileDescriptorProto fooProto = FileDescriptorProto.newBuilder() .setName("foo.proto").build(); @@ -537,14 +537,14 @@ public class DescriptorsTest extends TestCase { new FileDescriptor[0]); FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(barProto, 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, new FileDescriptor[] {fooFile, barFile}); Descriptors.FileDescriptor.buildFrom(bazProto, new FileDescriptor[] {barFile, fooFile}); } - + public void testInvalidPublicDependency() throws Exception { FileDescriptorProto fooProto = FileDescriptorProto.newBuilder() .setName("foo.proto").build(); @@ -628,7 +628,7 @@ public class DescriptorsTest extends TestCase { Descriptors.FileDescriptor.buildFrom( fooProto, new FileDescriptor[] {forwardFile}); } - + /** * Tests the translate/crosslink for an example with a more complex namespace * referencing. @@ -677,7 +677,7 @@ public class DescriptorsTest extends TestCase { assertTrue(field.getEnumType().getFile().getName().equals("bar.proto")); assertTrue(field.getEnumType().getFile().getPackage().equals( "a.b.c.d.bar.shared")); - } + } } public void testOneofDescriptor() throws Exception { diff --git a/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java b/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java index 046832de..f3ad774f 100644 --- a/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java +++ b/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java @@ -248,7 +248,7 @@ public class LiteralByteStringTest extends TestCase { assertTrue(classUnderTest + ".writeTo() must give back the same bytes", Arrays.equals(referenceBytes, roundTripBytes)); } - + public void testWriteTo_mutating() throws IOException { OutputStream os = new OutputStream() { @Override diff --git a/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java b/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java index 212f8d68..8106201d 100644 --- a/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java +++ b/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java @@ -35,7 +35,7 @@ import java.util.Iterator; /** * 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) */ diff --git a/java/src/test/java/com/google/protobuf/RopeByteStringTest.java b/java/src/test/java/com/google/protobuf/RopeByteStringTest.java index 0f2344d6..4775f03a 100644 --- a/java/src/test/java/com/google/protobuf/RopeByteStringTest.java +++ b/java/src/test/java/com/google/protobuf/RopeByteStringTest.java @@ -42,7 +42,7 @@ import java.util.Iterator; /** * This class tests {@link RopeByteString} by inheriting the tests from * {@link LiteralByteStringTest}. Only a couple of methods are overridden. - * + * *

A full test of the result of {@link RopeByteString#substring(int, int)} is found in the * separate class {@link RopeByteStringSubstringTest}. * diff --git a/java/src/test/java/com/google/protobuf/TextFormatTest.java b/java/src/test/java/com/google/protobuf/TextFormatTest.java index eba06ca0..07c2b833 100644 --- a/java/src/test/java/com/google/protobuf/TextFormatTest.java +++ b/java/src/test/java/com/google/protobuf/TextFormatTest.java @@ -863,7 +863,7 @@ public class TextFormatTest extends TestCase { TextFormat.merge(TextFormat.printToUnicodeString(message), builder); assertEquals(message.getOptionalString(), builder.getOptionalString()); } - + public void testPrintToUnicodeStringWithNewlines() throws Exception { // No newlines at start and end assertEquals("optional_string: \"test newlines\\n\\nin\\nstring\"\n", -- cgit v1.2.3