"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hsqldb/src/org/hsqldb/types/CharacterType.java" between
hsqldb-2.7.1.zip and hsqldb-2.7.2.zip

About: HSQLDB (HyperSQL DataBase) is a SQL relational database engine written in Java. It supports nearly full ANSI-92 SQL (BNF format) and full core SQL:2008.

CharacterType.java  (hsqldb-2.7.1):CharacterType.java  (hsqldb-2.7.2)
/* Copyright (c) 2001-2022, The HSQL Development Group /* Copyright (c) 2001-2023, The HSQL Development Group
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright notice, * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
skipping to change at line 49 skipping to change at line 49
import org.hsqldb.error.Error; import org.hsqldb.error.Error;
import org.hsqldb.error.ErrorCode; import org.hsqldb.error.ErrorCode;
import org.hsqldb.lib.ArrayUtil; import org.hsqldb.lib.ArrayUtil;
import org.hsqldb.lib.StringConverter; import org.hsqldb.lib.StringConverter;
import org.hsqldb.lib.StringUtil; import org.hsqldb.lib.StringUtil;
/** /**
* Type subclass for CHARACTER, VARCHAR, etc.<p> * Type subclass for CHARACTER, VARCHAR, etc.<p>
* *
* @author Fred Toussi (fredt@users dot sourceforge.net) * @author Fred Toussi (fredt@users dot sourceforge.net)
* @version 2.7.0 * @version 2.7.2
* @since 1.9.0 * @since 1.9.0
*/ */
public class CharacterType extends Type { public class CharacterType extends Type {
static final int defaultCharPrecision = 256; static final int defaultCharPrecision = 256;
static final int defaultVarcharPrecision = 32 * 1024; static final int defaultVarcharPrecision = 32 * 1024;
public static final long maxCharPrecision = Integer.MAX_VALUE; public static final long maxCharPrecision = Integer.MAX_VALUE;
final Collation collation; final Collation collation;
final Charset charset; final Charset charset;
final String nameString; final String nameString;
skipping to change at line 652 skipping to change at line 652
} else if (a instanceof java.sql.Time) { } else if (a instanceof java.sql.Time) {
s = a.toString(); s = a.toString();
} else if (a instanceof java.sql.Timestamp) { } else if (a instanceof java.sql.Timestamp) {
s = a.toString(); s = a.toString();
} else if (a instanceof java.util.Date) { } else if (a instanceof java.util.Date) {
a = new java.sql.Timestamp(((java.util.Date) a).getTime()); a = new java.sql.Timestamp(((java.util.Date) a).getTime());
s = a.toString(); s = a.toString();
} else if (a instanceof java.util.UUID) { } else if (a instanceof java.util.UUID) {
s = a.toString(); s = a.toString();
} else { } else {
s = convertJavaDateTimeObject(a); s = DateTimeType.convertJavaDateTimeObjectToString(a);
if (s == null) { if (s == null) {
throw Error.error(ErrorCode.X_42561); throw Error.error(ErrorCode.X_42561);
} }
} }
return s; return s;
} }
//#ifdef JAVA8
String convertJavaDateTimeObject(Object a) {
switch(a.getClass().getName()){
case "java.time.LocalDate":
case "java.time.LocalTime":
return a.toString();
case "java.time.LocalDateTime":
case "java.time.OffsetDateTime":
case "java.time.OffsetTime":
return a.toString().replace('T', ' ');
}
return null;
}
//#else
/*
String convertJavaDateTimeObject(Object a) {
return null;
}
*/
//#endif JAVA8
public Object convertJavaToSQL(SessionInterface session, Object a) { public Object convertJavaToSQL(SessionInterface session, Object a) {
return convertToDefaultType(session, a); return convertToDefaultType(session, a);
} }
public String convertToString(Object a) { public String convertToString(Object a) {
if (a == null) { if (a == null) {
return null; return null;
} }
skipping to change at line 902 skipping to change at line 878
LongPair segment = substringParams(dataLength, offset, length, LongPair segment = substringParams(dataLength, offset, length,
hasLength); hasLength);
offset = segment.a; offset = segment.a;
length = segment.b; length = segment.b;
if (data instanceof String) { if (data instanceof String) {
return ((String) data).substring((int) offset, return ((String) data).substring((int) offset,
(int) (offset + length)); (int) (offset + length));
} else if (data instanceof ClobData) { } else if (data instanceof ClobData) {
ClobData clob = ((ClobData) data).getClob(session, offset, length);
if (length > Integer.MAX_VALUE) {
throw Error.error(ErrorCode.X_22001);
}
/* @todo - change to support long strings */
String result = ((ClobData) data).getSubString(session, offset,
(int) length);
ClobData clob = session.createClob(length);
clob.setString(session, 0, result);
return clob; return clob;
} else { } else {
throw Error.runtimeError(ErrorCode.U_S0500, "CharacterType"); throw Error.runtimeError(ErrorCode.U_S0500, "CharacterType");
} }
} }
/** /**
* Memory limits apply to Upper and Lower implementations with Clob data * Memory limits apply to Upper and Lower implementations with Clob data
*/ */
 End of changes. 5 change blocks. 
28 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)