Skip to content
Permalink
Browse files

refactor: use varargs

use varargs instead of new Object[]{..}
delete "final" from "private static" methods (fix warnings from #586)

fixes #681
  • Loading branch information
AlexElin authored and vlsi committed Nov 12, 2016
1 parent f4a067c commit 50b7fe0fe901ee24160615bebd4b86603b960b86
@@ -10,27 +10,27 @@
import java.io.IOException;

class UTF8Encoding extends Encoding {
UTF8Encoding(String jvmEncoding) {
super(jvmEncoding);
}

private static final int MIN_2_BYTES = 0x80;
private static final int MIN_3_BYTES = 0x800;
private static final int MIN_4_BYTES = 0x10000;
private static final int MAX_CODE_POINT = 0x10ffff;

private char[] decoderArray = new char[1024];

UTF8Encoding(String jvmEncoding) {
super(jvmEncoding);
}

// helper for decode
private final static void checkByte(int ch, int pos, int len) throws IOException {
private static void checkByte(int ch, int pos, int len) throws IOException {
if ((ch & 0xc0) != 0x80) {
throw new IOException(
GT.tr("Illegal UTF-8 sequence: byte {0} of {1} byte sequence is not 10xxxxxx: {2}",
new Object[]{pos, len, ch}));
pos, len, ch));
}
}

private final static void checkMinimal(int ch, int minValue) throws IOException {
private static void checkMinimal(int ch, int minValue) throws IOException {
if (ch >= minValue) {
return;
}
@@ -64,7 +64,7 @@ private final static void checkMinimal(int ch, int minValue) throws IOException

throw new IOException(
GT.tr("Illegal UTF-8 sequence: {0} bytes used to encode a {1} byte value: {2}",
new Object[]{actualLen, expectedLen, ch}));
actualLen, expectedLen, ch));
}

/**
@@ -74,11 +74,12 @@ private final static void checkMinimal(int ch, int minValue) throws IOException
* databases out there.
*
* @param data the array containing UTF8-encoded data
* @param offset the offset of the first byte in <code>data</code> to decode from
* @param offset the offset of the first byte in {@code data} to decode from
* @param length the number of bytes to decode
* @return a decoded string
* @throws IOException if something goes wrong
*/
@Override
public synchronized String decode(byte[] data, int offset, int length) throws IOException {
char[] cdata = decoderArray;
if (cdata.length < length) {
@@ -99,7 +100,7 @@ public synchronized String decode(byte[] data, int offset, int length) throws IO
} else if (ch < 0xc0) {
// 10xxxxxx -- illegal!
throw new IOException(GT.tr("Illegal UTF-8 sequence: initial byte is {0}: {1}",
new Object[]{"10xxxxxx", ch}));
"10xxxxxx", ch));
} else if (ch < 0xe0) {
// 110xxxxx 10xxxxxx
ch = ((ch & 0x1f) << 6);
@@ -126,7 +127,7 @@ public synchronized String decode(byte[] data, int offset, int length) throws IO
checkMinimal(ch, MIN_4_BYTES);
} else {
throw new IOException(GT.tr("Illegal UTF-8 sequence: initial byte is {0}: {1}",
new Object[]{"11111xxx", ch}));
"11111xxx", ch));
}

if (ch > MAX_CODE_POINT) {
@@ -203,7 +203,7 @@ public String toString() {
String l_routine = m_mesgParts.get(ROUTINE);
if (l_file != null || l_line != null || l_routine != null) {
l_totalMessage.append("\n ").append(GT.tr("Location: File: {0}, Routine: {1}, Line: {2}",
new Object[]{l_file, l_routine, l_line}));
l_file, l_routine, l_line));
}
l_message = m_mesgParts.get(SQLSTATE);
if (l_message != null) {

0 comments on commit 50b7fe0

Please sign in to comment.
You can’t perform that action at this time.