Package org.apache.calcite.avatica
Class AvaticaUtils
java.lang.Object
org.apache.calcite.avatica.AvaticaUtils
Avatica utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassReturns the boxed class.static StringcamelToUpper(String name) Converts a camelCase name into an upper-case underscore-separated name.static voidDoes nothing with its argument.static long[]executeLargeBatch(Statement statement) InvokesStatement#executeLargeBatch, falling back onStatement.executeBatch()if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.static longgetLargeMaxRows(Statement statement) InvokesStatement#getLargeMaxRows, falling back onStatement.getMaxRows()if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.static longgetLargeUpdateCount(Statement statement) InvokesStatement#getLargeUpdateCount, falling back onStatement.getUpdateCount()if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.static <T> TinstantiatePlugin(Class<T> pluginClass, String className) Creates an instance of a plugin class.static List<?>primitiveList(Object array) Adapts a primitive array into aList.static StringreadFully(InputStream inputStream) Reads the contents of an input stream and returns as a string.static StringreadFully(InputStream inputStream, UnsynchronizedBuffer buffer) Reads the contents of an input stream and returns as a string.static byte[]readFullyToBytes(InputStream inputStream) Reads the contents of an input stream and returns as a string.static byte[]readFullyToBytes(InputStream inputStream, UnsynchronizedBuffer buffer) Reads the contents of an input stream and returns as a string.static <T> Tremark(T remark) Use this method to flag temporary code.static voidsetLargeMaxRows(Statement statement, long n) InvokesStatement#setLargeMaxRows, falling back onStatement.setMaxRows(int)if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.static voidskipFully(InputStream inputStream) Reads and discards all data available on the InputStream.static StringtoCamelCase(String name) Converts an underscore-separated name into a camelCase name.static long[]toLongs(int[] ints) Converts an array ofintvalues to an array oflongvalues.static inttoSaturatedInt(long value) Converts alongtoint, rounding as little as possible if the value is outside the legal range for anint.static int[]toSaturatedInts(long[] longs) Converts an array oflongvalues to an array ofintvalues, truncating values outside the legal range for aninttoInteger.MIN_VALUEorInteger.MAX_VALUE.static StringGenerates a string that is unique in the execution of the JVM.static booleanUse this method to flag code that should be re-visited after upgrading a component.
-
Method Details
-
discard
Does nothing with its argument. Call this method when you have a value you are not interested in, but you don't want the compiler to warn that you are not using it. -
remark
public static <T> T remark(T remark) Use this method to flag temporary code.Example #1:
if (AvaticaUtils.remark("baz fixed") == null) { baz(); }Example #2:
/** @see AvaticaUtils#remark Remove before checking in */ void uselessMethod() {} -
upgrade
Use this method to flag code that should be re-visited after upgrading a component.If the intended change is that a class or member be removed, flag instead using a
Deprecatedannotation followed by a comment such as "to be removed before 2.0". -
primitiveList
Adapts a primitive array into aList. For example,asList(new double[2])returns aList<Double>. -
camelToUpper
Converts a camelCase name into an upper-case underscore-separated name. For example,camelToUpper("myJdbcDriver")returns "MY_JDBC_DRIVER". -
toCamelCase
Converts an underscore-separated name into a camelCase name. For example,uncamel("MY_JDBC_DRIVER")returns "myJdbcDriver". -
box
Returns the boxed class. For example,box(int.class)returnsjava.lang.Integer. -
instantiatePlugin
Creates an instance of a plugin class. First looks for a static member called INSTANCE, then calls a public default constructor.If className contains a "#" instead looks for a static field.
- Type Parameters:
T- Class- Parameters:
pluginClass- Class (or interface) to instantiateclassName- Name of implementing class- Returns:
- Plugin instance
-
readFully
Reads the contents of an input stream and returns as a string.- Throws:
IOException
-
readFully
public static String readFully(InputStream inputStream, UnsynchronizedBuffer buffer) throws IOException Reads the contents of an input stream and returns as a string.- Throws:
IOException
-
readFullyToBytes
Reads the contents of an input stream and returns as a string.- Throws:
IOException
-
readFullyToBytes
public static byte[] readFullyToBytes(InputStream inputStream, UnsynchronizedBuffer buffer) throws IOException Reads the contents of an input stream and returns as a string.- Throws:
IOException
-
skipFully
Reads and discards all data available on the InputStream.- Throws:
IOException
-
setLargeMaxRows
InvokesStatement#setLargeMaxRows, falling back onStatement.setMaxRows(int)if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.- Throws:
SQLException
-
getLargeMaxRows
InvokesStatement#getLargeMaxRows, falling back onStatement.getMaxRows()if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.- Throws:
SQLException
-
getLargeUpdateCount
InvokesStatement#getLargeUpdateCount, falling back onStatement.getUpdateCount()if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.- Throws:
SQLException
-
executeLargeBatch
InvokesStatement#executeLargeBatch, falling back onStatement.executeBatch()if the method does not exist (before JDK 1.8) or throwsUnsupportedOperationException.- Throws:
SQLException
-
unique
Generates a string that is unique in the execution of the JVM. It is used by tests to ensure that they create distinct temporary tables. The strings are never thrown away, so don't put too much in there! Thread safe. -
toSaturatedInt
public static int toSaturatedInt(long value) Converts alongtoint, rounding as little as possible if the value is outside the legal range for anint. -
toSaturatedInts
public static int[] toSaturatedInts(long[] longs) Converts an array oflongvalues to an array ofintvalues, truncating values outside the legal range for aninttoInteger.MIN_VALUEorInteger.MAX_VALUE.- Parameters:
longs- An array oflongs- Returns:
- An array of
ints
-
toLongs
public static long[] toLongs(int[] ints) Converts an array ofintvalues to an array oflongvalues.
-