Skip to content

Commit

Permalink
[misc] code cleaning
Browse files Browse the repository at this point in the history
(cherry picked from commit 1daec80)
  • Loading branch information
rusher committed Feb 5, 2019
1 parent 613fa7d commit 7cc47a1
Show file tree
Hide file tree
Showing 236 changed files with 20,110 additions and 19,519 deletions.
278 changes: 135 additions & 143 deletions src/main/java/org/mariadb/jdbc/BasePrepareStatement.java

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions src/main/java/org/mariadb/jdbc/BlobOutputStream.java
Expand Up @@ -60,51 +60,51 @@
*/
class BlobOutputStream extends OutputStream {

private int pos;
private final MariaDbBlob blob;
private final MariaDbBlob blob;
private int pos;

public BlobOutputStream(MariaDbBlob blob, int pos) {
this.blob = blob;
this.pos = pos;
}
public BlobOutputStream(MariaDbBlob blob, int pos) {
this.blob = blob;
this.pos = pos;
}

@Override
public void write(int bit) throws IOException {
@Override
public void write(int bit) throws IOException {

if (this.pos >= blob.length) {
byte[] tmp = new byte[2 * blob.length + 1];
System.arraycopy(blob.data, blob.offset, tmp, 0, blob.length);
blob.data = tmp;
pos -= blob.offset;
blob.offset = 0;
blob.length++;
}
blob.data[pos] = (byte) bit;
pos++;
if (this.pos >= blob.length) {
byte[] tmp = new byte[2 * blob.length + 1];
System.arraycopy(blob.data, blob.offset, tmp, 0, blob.length);
blob.data = tmp;
pos -= blob.offset;
blob.offset = 0;
blob.length++;
}
blob.data[pos] = (byte) bit;
pos++;
}

@Override
public void write(byte[] buf, int off, int len) throws IOException {
if (off < 0) {
throw new IOException("Invalid offset " + off);
}
int realLen = Math.min(buf.length - off, len);
if (pos + realLen >= blob.length) {
int newLen = 2 * blob.length + realLen;
byte[] tmp = new byte[newLen];
System.arraycopy(blob.data, blob.offset, tmp, 0, blob.length);
blob.data = tmp;
pos -= blob.offset;
blob.offset = 0;
blob.length = pos + realLen;
}
System.arraycopy(buf, off, blob.data, pos, realLen);
pos += realLen;
@Override
public void write(byte[] buf, int off, int len) throws IOException {
if (off < 0) {
throw new IOException("Invalid offset " + off);
}

@Override
public void write(byte[] buf) throws IOException {
write(buf, 0, buf.length);
int realLen = Math.min(buf.length - off, len);
if (pos + realLen >= blob.length) {
int newLen = 2 * blob.length + realLen;
byte[] tmp = new byte[newLen];
System.arraycopy(blob.data, blob.offset, tmp, 0, blob.length);
blob.data = tmp;
pos -= blob.offset;
blob.offset = 0;
blob.length = pos + realLen;
}
System.arraycopy(buf, off, blob.data, pos, realLen);
pos += realLen;
}

@Override
public void write(byte[] buf) throws IOException {
write(buf, 0, buf.length);
}
}

208 changes: 104 additions & 104 deletions src/main/java/org/mariadb/jdbc/CallParameter.java
Expand Up @@ -59,108 +59,108 @@
*/
class CallParameter {

private boolean isInput;
private boolean isOutput;
private int sqlType;
private int outputSqlType;
private int scale;
private String typeName;
private boolean isSigned;
private int canBeNull;
private int precision;
private String className;
private String name;

public CallParameter() {
sqlType = Types.OTHER;
outputSqlType = Types.OTHER;
}

public boolean isInput() {
return isInput;
}

public void setInput(boolean input) {
isInput = input;
}

public boolean isOutput() {
return isOutput;
}

public void setOutput(boolean output) {
isOutput = output;
}

public int getSqlType() {
return sqlType;
}

public void setSqlType(int sqlType) {
this.sqlType = sqlType;
}

public int getOutputSqlType() {
return outputSqlType;
}

public void setOutputSqlType(int outputSqlType) {
this.outputSqlType = outputSqlType;
}

public int getScale() {
return scale;
}

public void setScale(int scale) {
this.scale = scale;
}

public String getTypeName() {
return typeName;
}

public void setTypeName(String typeName) {
this.typeName = typeName;
}

public boolean isSigned() {
return isSigned;
}

public void setSigned(boolean signed) {
isSigned = signed;
}

public int getCanBeNull() {
return canBeNull;
}

public void setCanBeNull(int canBeNull) {
this.canBeNull = canBeNull;
}

public int getPrecision() {
return precision;
}

public void setPrecision(int precision) {
this.precision = precision;
}

public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
private boolean isInput;
private boolean isOutput;
private int sqlType;
private int outputSqlType;
private int scale;
private String typeName;
private boolean isSigned;
private int canBeNull;
private int precision;
private String className;
private String name;

public CallParameter() {
sqlType = Types.OTHER;
outputSqlType = Types.OTHER;
}

public boolean isInput() {
return isInput;
}

public void setInput(boolean input) {
isInput = input;
}

public boolean isOutput() {
return isOutput;
}

public void setOutput(boolean output) {
isOutput = output;
}

public int getSqlType() {
return sqlType;
}

public void setSqlType(int sqlType) {
this.sqlType = sqlType;
}

public int getOutputSqlType() {
return outputSqlType;
}

public void setOutputSqlType(int outputSqlType) {
this.outputSqlType = outputSqlType;
}

public int getScale() {
return scale;
}

public void setScale(int scale) {
this.scale = scale;
}

public String getTypeName() {
return typeName;
}

public void setTypeName(String typeName) {
this.typeName = typeName;
}

public boolean isSigned() {
return isSigned;
}

public void setSigned(boolean signed) {
isSigned = signed;
}

public int getCanBeNull() {
return canBeNull;
}

public void setCanBeNull(int canBeNull) {
this.canBeNull = canBeNull;
}

public int getPrecision() {
return precision;
}

public void setPrecision(int precision) {
this.precision = precision;
}

public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
14 changes: 7 additions & 7 deletions src/main/java/org/mariadb/jdbc/CallableFunctionStatement.java
Expand Up @@ -101,7 +101,7 @@ public abstract class CallableFunctionStatement extends ClientSidePreparedStatem
* @throws SQLException if clientPrepareStatement creation throw an exception
*/
public CallableFunctionStatement(MariaDbConnection connection, String sql, int resultSetType,
final int resultSetConcurrency) throws SQLException {
final int resultSetConcurrency) throws SQLException {
super(connection, sql, resultSetType, resultSetConcurrency, Statement.NO_GENERATED_KEYS);
}

Expand Down Expand Up @@ -540,9 +540,9 @@ public Reader getCharacterStream(String parameterName) throws SQLException {
* @param parameterIndex the first parameter is 1, the second is 2,...
* @param sqlType a value from {@link Types}
* @param typeName the fully-qualified name of an SQL structured type
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @see Types
*/
public void registerOutParameter(int parameterIndex, int sqlType, String typeName)
Expand Down Expand Up @@ -573,9 +573,9 @@ public void registerOutParameter(int parameterIndex, int sqlType) throws SQLExce
* @param sqlType the SQL type code defined by <code>java.sql.Types</code>.
* @param scale the desired number of digits to the right of the decimal point. It must
* be greater than or equal to zero.
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @see Types
*/
@Override
Expand Down
Expand Up @@ -89,7 +89,7 @@ public class CallableParameterMetaData implements ParameterMetaData {
* @param isFunction is it a function
*/
public CallableParameterMetaData(MariaDbConnection con, String database, String name,
boolean isFunction) {
boolean isFunction) {
this.params = null;
this.con = con;
if (database != null) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java
Expand Up @@ -105,7 +105,7 @@ public abstract class CallableProcedureStatement extends ServerSidePreparedState
* @throws SQLException is prepareStatement connection throw any error
*/
public CallableProcedureStatement(MariaDbConnection connection, String sql,
int resultSetScrollType, int resultSetConcurrency)
int resultSetScrollType, int resultSetConcurrency)
throws SQLException {
super(connection, sql, resultSetScrollType, resultSetConcurrency, Statement.NO_GENERATED_KEYS);
}
Expand Down Expand Up @@ -561,9 +561,9 @@ public Reader getCharacterStream(String parameterName) throws SQLException {
* @param parameterIndex the first parameter is 1, the second is 2,...
* @param sqlType a value from {@link Types}
* @param typeName the fully-qualified name of an SQL structured type
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @see Types
*/
public void registerOutParameter(int parameterIndex, int sqlType, String typeName)
Expand Down Expand Up @@ -594,9 +594,9 @@ public void registerOutParameter(int parameterIndex, int sqlType) throws SQLExce
* @param sqlType the SQL type code defined by <code>java.sql.Types</code>.
* @param scale the desired number of digits to the right of the decimal point. It must
* be greater than or equal to zero.
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @throws SQLException if the parameterIndex is not valid; if a database
* access error occurs or this method is called on a
* closed <code>CallableStatement</code>
* @see Types
*/
@Override
Expand Down

0 comments on commit 7cc47a1

Please sign in to comment.