Declare members of PackOutputStream final

These methods cannot be sanely overridden anywhere. Most methods
are package visible only, or are private. A few public methods do
exist but there is no useful way to override them since creation
of PackOutputStream is managed by PackWriter and cannot be delegated.

Change-Id: I12cd3326b78d497c1f9751014d04d1460b46e0b0
This commit is contained in:
Shawn Pearce 2013-04-10 09:37:19 -07:00
parent 2be6927d8e
commit 66192817cd
1 changed files with 10 additions and 9 deletions

View File

@ -96,14 +96,14 @@ public PackOutputStream(final ProgressMonitor writeMonitor,
}
@Override
public void write(final int b) throws IOException {
public final void write(final int b) throws IOException {
count++;
out.write(b);
md.update((byte) b);
}
@Override
public void write(final byte[] b, int off, int len)
public final void write(final byte[] b, int off, int len)
throws IOException {
while (0 < len) {
final int n = Math.min(len, BYTES_TO_WRITE_BEFORE_CANCEL_CHECK);
@ -130,7 +130,8 @@ public void flush() throws IOException {
out.flush();
}
void writeFileHeader(int version, long objectCount) throws IOException {
final void writeFileHeader(int version, long objectCount)
throws IOException {
System.arraycopy(Constants.PACK_SIGNATURE, 0, headerBuffer, 0, 4);
NB.encodeInt32(headerBuffer, 4, version);
NB.encodeInt32(headerBuffer, 8, (int) objectCount);
@ -152,7 +153,7 @@ void writeFileHeader(int version, long objectCount) throws IOException {
* examine the type of exception and possibly its message to
* distinguish between these cases.
*/
public void writeObject(ObjectToPack otp) throws IOException {
public final void writeObject(ObjectToPack otp) throws IOException {
packWriter.writeObject(this, otp);
}
@ -172,7 +173,7 @@ public void writeObject(ObjectToPack otp) throws IOException {
* @throws IOException
* the underlying stream refused to accept the header.
*/
public void writeHeader(ObjectToPack otp, long rawLength)
public final void writeHeader(ObjectToPack otp, long rawLength)
throws IOException {
if (otp.isDeltaRepresentation()) {
if (packWriter.isDeltaBaseAsOffset()) {
@ -201,7 +202,7 @@ public void writeHeader(ObjectToPack otp, long rawLength)
}
}
private int encodeTypeSize(int type, long rawLength) {
private final int encodeTypeSize(int type, long rawLength) {
long nextLength = rawLength >>> 4;
headerBuffer[0] = (byte) ((nextLength > 0 ? 0x80 : 0x00) | (type << 4) | (rawLength & 0x0F));
rawLength = nextLength;
@ -215,7 +216,7 @@ private int encodeTypeSize(int type, long rawLength) {
}
/** @return a temporary buffer writers can use to copy data with. */
public byte[] getCopyBuffer() {
public final byte[] getCopyBuffer() {
return copyBuffer;
}
@ -224,12 +225,12 @@ void endObject() {
}
/** @return total number of bytes written since stream start. */
public long length() {
public final long length() {
return count;
}
/** @return obtain the current SHA-1 digest. */
byte[] getDigest() {
final byte[] getDigest() {
return md.digest();
}
}