提交 8b13914c 编写于 作者: I igerasim

8074657: Missing space on a boundary of concatenated strings

Summary: Added missing spaces, fixed indentation, replaced StringBuffer with StringBuilder
Reviewed-by: martin, rriggs
上级 370fb4a4
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -66,7 +66,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* value of this <code>SerialBlob</code> object.
* @serial
*/
private byte buf[];
private byte[] buf;
/**
* The internal representation of the <code>Blob</code> object on which this
......@@ -102,12 +102,13 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @throws SerialException if an error occurs during serialization
* @throws SQLException if a SQL errors occurs
*/
public SerialBlob(byte[] b) throws SerialException, SQLException {
public SerialBlob(byte[] b)
throws SerialException, SQLException {
len = b.length;
buf = new byte[(int)len];
for(int i = 0; i < len; i++) {
buf[i] = b[i];
buf[i] = b[i];
}
origLen = len;
}
......@@ -132,19 +133,17 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* to this constructor is a <code>null</code>.
* @see java.sql.Blob
*/
public SerialBlob (Blob blob) throws SerialException, SQLException {
public SerialBlob (Blob blob)
throws SerialException, SQLException {
if (blob == null) {
throw new SQLException("Cannot instantiate a SerialBlob " +
"object with a null Blob object");
throw new SQLException(
"Cannot instantiate a SerialBlob object with a null Blob object");
}
len = blob.length();
buf = blob.getBytes(1, (int)len );
this.blob = blob;
//if ( len < 10240000)
// len = 10240000;
origLen = len;
}
......@@ -245,7 +244,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* value from the database
*/
public long position(byte[] pattern, long start)
throws SerialException, SQLException {
throws SerialException, SQLException {
isValid();
if (start < 1 || start > len) {
return -1;
......@@ -290,7 +290,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* value from the database
*/
public long position(Blob pattern, long start)
throws SerialException, SQLException {
throws SerialException, SQLException {
isValid();
return position(pattern.getBytes(1, (int)(pattern.length())), start);
}
......@@ -316,8 +316,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @see #getBytes
*/
public int setBytes(long pos, byte[] bytes)
throws SerialException, SQLException {
return (setBytes(pos, bytes, 0, bytes.length));
throws SerialException, SQLException {
return setBytes(pos, bytes, 0, bytes.length);
}
/**
......@@ -352,7 +352,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @see #getBytes
*/
public int setBytes(long pos, byte[] bytes, int offset, int length)
throws SerialException, SQLException {
throws SerialException, SQLException {
isValid();
if (offset < 0 || offset > bytes.length) {
......@@ -369,7 +369,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
if ((length + offset) > bytes.length) {
throw new SerialException("Invalid OffSet. Cannot have combined offset " +
"and length that is greater that the Blob buffer");
"and length that is greater that the Blob buffer");
}
int i = 0;
......@@ -402,7 +402,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* @see #getBinaryStream
*/
public java.io.OutputStream setBinaryStream(long pos)
throws SerialException, SQLException {
throws SerialException, SQLException {
isValid();
if (this.blob != null) {
return this.blob.setBinaryStream(pos);
......@@ -425,17 +426,16 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
* if {@code free} had previously been called on this object
*/
public void truncate(long length) throws SerialException {
isValid();
if (length > len) {
throw new SerialException
("Length more than what can be truncated");
throw new SerialException(
"Length more than what can be truncated");
} else if((int)length == 0) {
buf = new byte[0];
len = length;
buf = new byte[0];
len = length;
} else {
len = length;
buf = this.getBytes(1, (int)len);
len = length;
buf = this.getBytes(1, (int)len);
}
}
......@@ -466,8 +466,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
throw new SerialException("Invalid position in BLOB object set");
}
if (length < 1 || length > len - pos + 1) {
throw new SerialException("length is < 1 or pos + length >"
+ "total number of bytes");
throw new SerialException(
"length is < 1 or pos + length > total number of bytes");
}
return new ByteArrayInputStream(buf, (int) pos - 1, (int) length);
}
......@@ -536,14 +536,13 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
public Object clone() {
try {
SerialBlob sb = (SerialBlob) super.clone();
sb.buf = (buf != null) ? Arrays.copyOf(buf, (int)len) : null;
sb.buf = (buf != null) ? Arrays.copyOf(buf, (int)len) : null;
sb.blob = null;
return sb;
} catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
/**
......@@ -554,15 +553,15 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
byte[] tmp = (byte[])fields.get("buf", null);
if (tmp == null)
throw new InvalidObjectException("buf is null and should not be!");
buf = tmp.clone();
len = fields.get("len", 0L);
if (buf.length != len)
throw new InvalidObjectException("buf is not the expected size");
origLen = fields.get("origLen", 0L);
blob = (Blob) fields.get("blob", null);
byte[] tmp = (byte[])fields.get("buf", null);
if (tmp == null)
throw new InvalidObjectException("buf is null and should not be!");
buf = tmp.clone();
len = fields.get("len", 0L);
if (buf.length != len)
throw new InvalidObjectException("buf is not the expected size");
origLen = fields.get("origLen", 0L);
blob = (Blob) fields.get("blob", null);
}
/**
......@@ -590,8 +589,8 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
*/
private void isValid() throws SerialException {
if (buf == null) {
throw new SerialException("Error: You cannot call a method on a "
+ "SerialBlob instance once free() has been called.");
throw new SerialException("Error: You cannot call a method on a " +
"SerialBlob instance once free() has been called.");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册