Permalink
Browse files

refactor: remove deprecated Utils' methods (#678)

* refactor: remove deprecated Utils' methods

remove some deprecated methods from Utils class
add @override on some methods in SimpleParameterList and PgConnection classes

* refactor: remove deprecated Utils' methods

fix failure build with JDK 6

* refactor: remove deprecated Utils' methods

revert toCharAyyar
  • Loading branch information...
AlexElin authored and vlsi committed Nov 12, 2016
1 parent c99507b commit 0275d40f6f2b8b30faef8aed31761e1ff7a0ed90
@@ -22,7 +22,7 @@
* Turn a bytearray into a printable form, representing each byte in hex.
*
* @param data the bytearray to stringize
* @return a hex-encoded printable representation of <code>data</code>
* @return a hex-encoded printable representation of {@code data}
*/
public static String toHexString(byte[] data) {
StringBuilder sb = new StringBuilder(data.length * 2);
@@ -43,7 +43,7 @@ public static String toHexString(byte[] data) {
* Encode a string as UTF-8.
*
* @param str the string to encode
* @return the UTF-8 representation of <code>str</code>
* @return the UTF-8 representation of {@code str}
*/
public static byte[] encodeUTF8(String str) {
// See org.postgresql.benchmark.encoding.UTF8Encoding#string_getBytes
@@ -53,28 +53,6 @@ public static String toHexString(byte[] data) {
return str.getBytes(utf8Charset);
}
/**
* Escape the given literal <tt>value</tt> and append it to the string buffer <tt>sbuf</tt>. If
* <tt>sbuf</tt> is <tt>null</tt>, a new StringBuffer will be returned. The argument
* <tt>standardConformingStrings</tt> defines whether the backend expects standard-conforming
* string literals or allows backslash escape sequences.
*
* @param sbuf the string buffer to append to; or <tt>null</tt>
* @param value the string value
* @param standardConformingStrings if standard conforming strings should be used
* @return the sbuf argument; or a new string buffer for sbuf == null
* @throws SQLException if the string contains a <tt>\0</tt> character
* @deprecated use {@link #escapeLiteral(StringBuilder, String, boolean)} instead
*/
public static StringBuffer appendEscapedLiteral(StringBuffer sbuf, String value,
boolean standardConformingStrings) throws SQLException {
if (sbuf == null) {
sbuf = new StringBuffer(value.length() * 11 / 10); // Add 10% for escaping.
}
doAppendEscapedLiteral(sbuf, value, standardConformingStrings);
return sbuf;
}
/**
* Escape the given literal <tt>value</tt> and append it to the string builder <tt>sbuf</tt>. If
* <tt>sbuf</tt> is <tt>null</tt>, a new StringBuilder will be returned. The argument
@@ -97,8 +75,7 @@ public static StringBuilder escapeLiteral(StringBuilder sbuf, String value,
}
/**
* Common part for {@link #appendEscapedLiteral(StringBuffer, String, boolean)} and
* {@link #escapeLiteral(StringBuilder, String, boolean)}
* Common part for {@link #escapeLiteral(StringBuilder, String, boolean)}
*
* @param sbuf Either StringBuffer or StringBuilder as we do not expect any IOException to be
* thrown
@@ -145,27 +122,6 @@ private static void doAppendEscapedLiteral(Appendable sbuf, String value,
}
}
/**
* Escape the given identifier <tt>value</tt> and append it to the string buffer <tt>sbuf</tt>. If
* <tt>sbuf</tt> is <tt>null</tt>, a new StringBuffer will be returned. This method is different
* from appendEscapedLiteral in that it includes the quoting required for the identifier while
* appendEscapedLiteral does not.
*
* @param sbuf the string buffer to append to; or <tt>null</tt>
* @param value the string value
* @return the sbuf argument; or a new string buffer for sbuf == null
* @throws SQLException if the string contains a <tt>\0</tt> character
* @deprecated use {@link #escapeIdentifier(StringBuilder, String)} instead
*/
public static StringBuffer appendEscapedIdentifier(StringBuffer sbuf, String value)
throws SQLException {
if (sbuf == null) {
sbuf = new StringBuffer(2 + value.length() * 11 / 10); // Add 10% for escaping.
}
doAppendEscapedIdentifier(sbuf, value);
return sbuf;
}
/**
* Escape the given identifier <tt>value</tt> and append it to the string builder <tt>sbuf</tt>.
* If <tt>sbuf</tt> is <tt>null</tt>, a new StringBuilder will be returned. This method is
@@ -132,18 +132,22 @@ public void setBinaryParameter(int index, byte[] value, int oid) throws SQLExcep
bind(index, value, oid, BINARY);
}
@Override
public void setBytea(int index, byte[] data, int offset, int length) throws SQLException {
bind(index, new StreamWrapper(data, offset, length), Oid.BYTEA, BINARY);
}
@Override
public void setBytea(int index, InputStream stream, int length) throws SQLException {
bind(index, new StreamWrapper(stream, length), Oid.BYTEA, BINARY);
}
@Override
public void setBytea(int index, InputStream stream) throws SQLException {
bind(index, new StreamWrapper(stream), Oid.BYTEA, BINARY);
}
@Override
public void setNull(int index, int oid) throws SQLException {
byte binaryTransfer = TEXT;
@@ -154,6 +158,7 @@ public void setNull(int index, int oid) throws SQLException {
bind(index, NULL_OBJECT, oid, binaryTransfer);
}
@Override
public String toString(int index, boolean standardConformingStrings) {
--index;
if (paramValues[index] == null) {
@@ -240,6 +245,7 @@ public String toString(int index, boolean standardConformingStrings) {
}
}
@Override
public void checkAllParametersSet() throws SQLException {
for (int i = 0; i < paramTypes.length; ++i) {
if (direction(i) != OUT && paramValues[i] == null) {
@@ -249,6 +255,7 @@ public void checkAllParametersSet() throws SQLException {
}
}
@Override
public void convertFunctionOutParameters() {
for (int i = 0; i < paramTypes.length; ++i) {
if (direction(i) == OUT) {
Oops, something went wrong.

0 comments on commit 0275d40

Please sign in to comment.