|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hsqldb.Library
Provides the HSQLDB implementation of standard Open Group SQL CLI Extended Scalar Functions and other public HSQLDB SQL functions.
Field Summary | |
static String[][] |
sNumeric
|
static String[][] |
sString
|
static String[][] |
sSystem
|
static String[][] |
sTimeDate
|
Constructor Summary | |
Library()
|
Method Summary | |
static double |
abs(double d)
Returns the absolute value of the given double value. |
static Integer |
ascii(String s)
Returns the Unicode code value of the leftmost character of s as an int . |
static int |
bitand(int i,
int j)
Returns the bit-wise logical and of the given integer values. |
static Integer |
bitLength(String s)
|
static int |
bitor(int i,
int j)
Returns the bit-wise logical or of the given integer values. |
static String |
character(int code)
Returns the character string corresponding to the given ASCII (or Unicode) value. |
static String |
concat(String s1,
String s2)
Returns a String object that is the result of an
SQL-style concatenation of the given String objects. |
static double |
cot(double d)
Returns the cotangent of the given double value
expressed in radians. |
static Date |
curdate()
Returns the current date as a date value. |
static Time |
curtime()
Returns the current local time as a time value. |
static String |
database(Connection conn)
Returns the name of the database corresponding to this connection. |
static String |
dayname(Date d)
Returns a character string containing the name of the day (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday ) for the day portion of the given java.sql.Date . |
static int |
dayofmonth(Date d)
Returns the day of the month from the given date value, as an integer value in the range of 1-31. |
static int |
dayofweek(Date d)
Returns the day of the week from the given date value, as an integer value in the range 1-7, where 1 represents Sunday. |
static int |
dayofyear(Date d)
Returns the day of the year from the given date value, as an integer value in the range 1-366. |
static int |
difference(String s1,
String s2)
Returns a count of the characters that do not match when comparing the 4 digit numeric SOUNDEX character sequences for the given String objects. |
static boolean |
getAutoCommit(Connection conn)
Retrieves the autocommit status of this connection. |
static int |
getDatabaseMajorVersion()
Retrieves the major version number of this database. |
static int |
getDatabaseMinorVersion()
Retrieves the major version number of this database. |
static String |
getDatabaseProductName()
Retrieves the name of this database product. |
static String |
getDatabaseProductVersion()
Retrieves the version number of this database product. |
static String |
hexToRaw(String s)
Converts a String of hexidecimal digit characters to a raw
binary value, represented as a String . |
static int |
hour(Time t)
Returns the hour from the given time value, as an integer value in the range of 0-23. |
static int |
identity()
Retrieves the last auto-generated integer indentity value used by this connection. |
static String |
insert(String s1,
int start,
int length,
String s2)
Returns a character sequence which is the result of writing the first length number of characters from the second
given String over the first string. |
static boolean |
isReadOnlyConnection(Connection conn)
Retrieves whether this connection is in read-only mode. |
static boolean |
isReadOnlyDatabase(Connection c)
Retrieves whether this database is in read-only mode. |
static boolean |
isReadOnlyDatabaseFiles(Connection c)
Retrieves whether the files of this database are in read-only mode. |
static String |
lcase(String s)
Returns a copy of the given String , with all upper case
characters converted to lower case. |
static String |
left(String s,
int count)
Returns the leftmost count characters from the given
String . |
static Integer |
length(String s)
Returns the number of characters in the given String .
|
static int |
locate(String search,
String s,
Integer start)
Returns the starting position of the first occurrence of the given search String object within
the given String object, s .
|
static double |
log10(double x)
Returns the base 10 logarithm of the given double value. |
static String |
ltrim(String s)
Returns the characters of the given String , with the
leading spaces removed. |
static int |
minute(Time t)
Returns the minute from the given time value, as integer value in the range of 0-59. |
static int |
mod(int i1,
int i2)
Returns the remainder (modulus) of the first given integer divided by the second. |
static int |
month(Date d)
Returns the month from the given date value, as an integer value in the range of 1-12. |
static String |
monthname(Date d)
Returns a character string containing the name of month (January, February, March, April, May, June, July, August, September, October, November, December) for the month portion of the given date value. |
static Timestamp |
now()
Returns the current date and time as a timestamp value. |
static Integer |
octetLength(String s)
Returns the number of bytes in the given String .
|
static double |
pi()
Returns the constant value, pi. |
static int |
position(String search,
String s)
As locate but from start positionl |
static int |
quarter(Date d)
Returns the quarter of the year in the given date value, as an integer value in the range of 1-4. |
static double |
rand(Integer seed)
Returns the next pseudorandom, uniformly distributed double value
between 0.0 and 1.0 from a single, system-wide random number generator's
sequence, optionally re-seeding (and thus resetting) the generator sequence.
|
static String |
rawToHex(String s)
Converts a raw binary value, as represented by the given String , to the equivalent String
of hexidecimal digit characters. |
static String |
repeat(String s,
Integer count)
Returns a String composed of the given String ,
repeated count times. |
static String |
replace(String s,
String replace,
String with)
Replaces all occurrences of replace in s
with the String object: with |
static String |
right(String s,
int count)
Returns the rightmost count characters of the given
String , s .
|
static double |
round(double d,
int p)
Returns the given double value, rounded to the given
int places right of the decimal point. |
static double |
roundMagic(double d)
Retrieves a magically rounded double value produced from the given double value. |
static String |
rtrim(String s)
Returns the characters of the given String , with trailing
spaces removed. |
static int |
second(Time d)
Returns the second of the given time value, as an integer value in the range of 0-59. |
static int |
sign(double d)
Returns an indicator of the sign of the given double
value. |
static String |
soundex(String s)
Returns a four character code representing the sound of the given String . |
static String |
space(int count)
Returns a String consisting of count spaces, or
null if count is less than zero. |
static String |
substring(String s,
int start,
Integer length)
Returns the characters from the given String , starting at
the indicated one-based start position and extending the
(optional) indicated length . |
static String |
trim(String s,
String trimstr,
boolean leading,
boolean trailing)
|
static double |
truncate(double d,
int p)
Returns the given double value, truncated to
the given int places right of the decimal point.
|
static String |
ucase(String s)
Returns a copy of the given String , with all lower case
characters converted to upper case using the default Java method. |
static String |
user(Connection conn)
Returns the user's authorization name (the user's name as known to this database). |
static int |
week(Date d)
Returns the week of the year from the given date value, as an integer value in the range of 1-53. |
static int |
year(Date d)
Returns the year from the given date value, as an integer value in the range of 1-9999. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String[][] sNumeric
public static final String[][] sString
public static final String[][] sTimeDate
public static final String[][] sSystem
Constructor Detail |
public Library()
Method Detail |
public static double rand(Integer seed)
double
value
between 0.0 and 1.0 from a single, system-wide random number generator's
sequence, optionally re-seeding (and thus resetting) the generator sequence.
If the seed value is null
, then the underlying random number
generator retrieves the next value in its current sequence, else the seed
alters the state of the generator object so as to be in exactly the same state
as if it had just been created with the seed value.
seed
- an optional parameter with which to reseed the underlying
pseudorandom number generator
double
value between
0.0 and 1.0public static double abs(double d)
double
value.
d
- the number for which to determine the absolute value
d
, as a double
public static double log10(double x)
double
value.
x
- the value for which to calculate the base 10 logarithm
x
, as a double
public static double roundMagic(double d)
double
value. This method provides special
handling for numbers close to zero and performs rounding only for
numbers within a specific range, returning precisely the given value
if it does not lie in this range. Special handling includes:
String
form length greater than 16 returns
input unchaged
String
form with last four characters of '...000x' where
x != '.' is converted to '...0000'
String
form with last four characters of '...9999' is
converted to '...999999'
java.lang.Double.doubleValue
of the String
form is returned
d
- the double value for which to retrieve the magically
rounded value
public static double cot(double d)
double
value
expressed in radians.
d
- the angle, expressed in radians
public static int mod(int i1, int i2)
i1
- the numeratori2
- the divisor
i1
% i2
, as an int
public static double pi()
double
valuepublic static double round(double d, int p)
double
value, rounded to the given
int
places right of the decimal point. If
the supplied rounding place value is negative, rounding is performed
to the left of the decimal point, using its magnitude (absolute value).
d
- the value to be roundedp
- the rounding place value
d
roundedpublic static int sign(double d)
double
value. If the value is less than zero, -1 is returned. If the value
equals zero, 0 is returned. If the value is greater than zero, 1 is
returned.
d
- the value
d
public static double truncate(double d, int p)
double
value, truncated to
the given int
places right of the decimal point.
If the given place value is negative, the given double
value is truncated to the left of the decimal point, using the
magnitude (aboslute value) of the place value.
d
- the value to truncatep
- the places left or right of the decimal point at which to
truncate
d
, truncatedpublic static int bitand(int i, int j)
i
- the first valuej
- the second value
i
and j
public static int bitor(int i, int j)
i
- the first valuej
- the second value
i
and j
public static Integer ascii(String s)
s
as an int
. This is the same as the
ASCII value if the string contains only ASCII characters.
s
- the String
to evaluate
public static String character(int code)
In some SQL CLI
implementations, a null
is returned if the range is outside 0..255.
In HSQLDB, the corresponding Unicode character is returned
unchecked.
code
- the character code for which to return a String
representation
public static String concat(String s1, String s2)
String
object that is the result of an
SQL-style concatenation of the given String
objects. Note: by SQL-style, it is meant:
String
objects are null
, return
null
null
, return the other
String
objects are non-null, return as a
String
object the character sequence obtained by listing,
in left to right order, the characters of the first string followed by
the characters of the second
s1
- the first String
s2
- the second String
s1
concatentated with s2
public static int difference(String s1, String s2)
String
objects. If either String
object is
null
, zero is returned.
s1
- the first String
s2
- the second String
SOUNDEX
of
s1
and the SOUNDEX
of s2
public static String hexToRaw(String s)
String
of hexidecimal digit characters to a raw
binary value, represented as a String
.
The given String
object must consist of a sequence of
4 digit hexidecimal character substrings.
If its length is not
evenly divisible by 4, null
is returned. If any of
its 4 character subsequences cannot be parsed as a
4 digit, base 16 value, then a NumberFormatException is thrown.
This conversion has the effect of reducing the character count 4:1.
s
- a String
of hexidecimal digit characters
String
public static String insert(String s1, int start, int length, String s2)
length
number of characters from the second
given String
over the first string. The start position
in the first string where the characters are overwritten is given by
start
.Note: In order of precedence, boundry conditions are handled as follows:
String
is null, then the other is
returned; the check starts with the first given String
.
start
is less than one, s1
is returned
length
is less than or equal to zero,
s1
is returned
s2
is zero, s1
is returned
start
is greater than the length of s1
,
s1
is returned
length
is such that, taken together with
start
, the indicated interval extends
beyond the end of s1
, then the insertion is performed
precisely as if upon a copy of s1
extended in length
to just include the indicated interval
s1
- the String
into which to insert s2
start
- the position, with origin one, at which to start the insertionlength
- the number of characters in s1
to replaces2
- the String
to insert into s1
s2
inserted into s1
, as indicated
by start
and length
and adjusted for
boundry conditionspublic static String lcase(String s)
String
, with all upper case
characters converted to lower case. This uses the default Java String
conversion.
s
- the String
from which to produce a lower case
version
s
public static String left(String s, int count)
count
characters from the given
String
. Note: boundry conditions are handled in the following order of precedence:
s
is null
, then null
is returned
count
is less than 1, then a zero-length
String
is returned
count
is greater than the length of s
,
then a copy of s
is returned
s
- the String
from which to retrieve the leftmost
characterscount
- the count of leftmost characters to retrieve
count
characters of s
public static Integer length(String s)
String
.
This includes trailing blanks.
s
- the String
for which to determine length
s
, including trailing blankspublic static Integer octetLength(String s)
String
.
This includes trailing blanks.
s
- the String
for which to determine length
s
, including trailing blankspublic static Integer bitLength(String s)
public static int locate(String search, String s, Integer start)
search
String
object within
the given String
object, s
.
The search for the first occurrence of search
begins with
the first character position in s
, unless the optional
argument, start
, is specified (non-null). If
start
is specified, the search begins with the character
position indicated by the value of start
, where the
first character position in s
is indicated by the value 1.
If search
is not found within s
, the
value 0 is returned.
search
- the String
occurence to find in s
s
- the String
within which to find the first
occurence of search
start
- the optional character position from which to start
looking in s
search
within s
, or 0 if not foundpublic static int position(String search, String s)
search
- the String
occurence to find in s
s
- the String
within which to find the first
occurence of search
search
within s
, or 0 if not foundpublic static String ltrim(String s)
String
, with the
leading spaces removed. Characters such as TAB are not removed.
s
- the String
from which to remove the leading blanks
String
, with the leading
spaces removedpublic static String rawToHex(String s)
String
, to the equivalent String
of hexidecimal digit characters. This conversion has the effect of expanding the character count 1:4.
s
- the raw binary value, as a String
String
of hexidecimal digit characterspublic static String repeat(String s, Integer count)
String
composed of the given String
,
repeated count
times.
s
- the String
to repeatcount
- the number of repetitions
String
, repeated count
timespublic static String replace(String s, String replace, String with)
replace
in s
with the String
object: with
s
- the target for replacementreplace
- the substring(s), if any, in s
to replacewith
- the value to substitute for replace
s
, with all occurences of replace
replaced by with
public static String right(String s, int count)
count
characters of the given
String
, s
.
Note: boundry conditions are handled in the following order of
precedence:
s
is null
, null
is returned
count
is less than one, a zero-length
String
is returned
count
is greater than the length of s
,
a copy of s
is returned
s
- the String
from which to retrieve the rightmost
count
characterscount
- the number of rightmost characters to retrieve
count
characters of s
public static String rtrim(String s)
String
, with trailing
spaces removed.
s
- the String
from which to remove the trailing blanks
String
, with the
trailing spaces removedpublic static String trim(String s, String trimstr, boolean leading, boolean trailing)
public static String soundex(String s)
String
. Non-ASCCI characters in the
input String
are ignored. This method was rewritten for HSQLDB by fredt@users to comply with the description at http://www.nara.gov/genealogy/coding.html.
s
- the String
for which to calculate the 4 character
SOUNDEX
value
SOUNDEX
value for the given
String
public static String space(int count)
String
consisting of count
spaces, or
null
if count
is less than zero.
count
- the number of spaces to produce
String
of count
spacespublic static String substring(String s, int start, Integer length)
String
, starting at
the indicated one-based start
position and extending the
(optional) indicated length
. If length
is not
specified (is null
), the remainder of s
is
implied.
s
- the String
from which to produce the indicated
substringstart
- the starting position of the desired substringlength
- the length of the desired substring
s
.public static String ucase(String s)
String
, with all lower case
characters converted to upper case using the default Java method.
s
- the String
from which to produce an upper case
version
s
public static Date curdate()
public static Time curtime()
public static String dayname(Date d)
java.sql.Date
.
d
- the date value from which to extract the day name
java.sql.Date
public static int dayofmonth(Date d)
d
- the date value from which to extract the day of month
public static int dayofweek(Date d)
d
- the date value from which to extract the day of week
public static int dayofyear(Date d)
d
- the date value from which to extract the day of year
public static int hour(Time t)
t
- the time value from which to extract the hour of day
public static int minute(Time t)
t
- the time value from which to extract the minute value
public static int month(Date d)
The sql_month database property is now obsolete. The function always returns the SQL (1-12) value for month.
d
- the date value from which to extract the month value
public static String monthname(Date d)
d
- the date value from which to extract the month name
public static Timestamp now()
public static int quarter(Date d)
d
- the date value from which to extract the quarter of the year
public static int second(Time d)
d
- the date value from which to extract the second of the hour
public static int week(Date d)
d
- the date value from which to extract the week of the year
public static int year(Date d)
d
- the date value from which to extract the year
public static String database(Connection conn) throws HsqlException
conn
- the connection for which to retrieve the database name
HsqlException
- if a database access error occurspublic static String user(Connection conn) throws HsqlException
conn
- the connection for which to retrieve the user name
HsqlException
- if a database access error occurspublic static int identity() throws HsqlException
HsqlException
- if a database access error occurspublic static boolean getAutoCommit(Connection conn)
conn
- the Connection
object for which to retrieve
the current autocommit status
public static String getDatabaseProductName()
String
objectpublic static String getDatabaseProductVersion()
String
objectpublic static int getDatabaseMajorVersion()
int
valuepublic static int getDatabaseMinorVersion()
int
valuepublic static boolean isReadOnlyConnection(Connection conn)
conn
- the Connection
object for which to retrieve
the current read-only status
true
if connection is read-only and
false
otherwisepublic static boolean isReadOnlyDatabase(Connection c)
c
- the Connection
object for which to retrieve
the current database read-only status
true
if so; false
otherwisepublic static boolean isReadOnlyDatabaseFiles(Connection c)
c
- the Connection
object for which to retrieve
the current database files read-only status
true
if so; false
otherwise
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |