提交 694c2474 authored 作者: Philippe Marschall's avatar Philippe Marschall

Fix doc generation

In order to make the doc generation for #476 working I had to fix some
errors in existing files. These cover

 - lines which are too long
 - incorrect indentation
 - invalid markup
 - missing javadoc
上级 28ed78eb
...@@ -1699,7 +1699,7 @@ It is possible to extend the type system of the database by providing your own i ...@@ -1699,7 +1699,7 @@ It is possible to extend the type system of the database by providing your own i
of minimal required API basically consisting of type identification and conversion routines. of minimal required API basically consisting of type identification and conversion routines.
</p> </p>
<p> <p>
In order to enable this feature, set the system property <code>h2.customDataTypesHandler</code> (default: null) to the fully qualified name of the class providing <a href="../javadoc/org/h2/api/CustomDataTypesHandler.html">CustomDataTypesHandler</a> interface implementation. <br> In order to enable this feature, set the system property <code>h2.customDataTypesHandler</code> (default: null) to the fully qualified name of the class providing <a href="../javadoc/org/h2/api/CustomDataTypesHandler.html">CustomDataTypesHandler</a> interface implementation. <br />
The instance of that class will be created by H2 and used to: The instance of that class will be created by H2 and used to:
<ul> <ul>
<li>resolve the names and identifiers of extrinsic data types. <li>resolve the names and identifiers of extrinsic data types.
......
...@@ -84,8 +84,8 @@ public interface CustomDataTypesHandler { ...@@ -84,8 +84,8 @@ public interface CustomDataTypesHandler {
* Converts {@link org.h2.value.Value} object * Converts {@link org.h2.value.Value} object
* to the specified class. * to the specified class.
* *
* @param value * @param value the value to convert
* @param cls * @param cls the target class
* @return result * @return result
*/ */
Object getObject(Value value, Class<?> cls); Object getObject(Value value, Class<?> cls);
......
...@@ -608,9 +608,11 @@ public class ValueDataType implements DataType { ...@@ -608,9 +608,11 @@ public class ValueDataType implements DataType {
int len = readVarInt(buff); int len = readVarInt(buff);
byte[] b = DataUtils.newBytes(len); byte[] b = DataUtils.newBytes(len);
buff.get(b, 0, len); buff.get(b, 0, len);
return JdbcUtils.customDataTypesHandler.convert(ValueBytes.getNoCopy(b), customType); return JdbcUtils.customDataTypesHandler.convert(
ValueBytes.getNoCopy(b), customType);
} }
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1, "No CustomDataTypesHandler has been set up"); throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1,
"No CustomDataTypesHandler has been set up");
} }
default: default:
if (type >= INT_0_15 && type < INT_0_15 + 16) { if (type >= INT_0_15 && type < INT_0_15 + 16) {
......
...@@ -127,7 +127,8 @@ public class JdbcUtils { ...@@ -127,7 +127,8 @@ public class JdbcUtils {
String customTypeHandlerClass = SysProperties.CUSTOM_DATA_TYPES_HANDLER; String customTypeHandlerClass = SysProperties.CUSTOM_DATA_TYPES_HANDLER;
if (customTypeHandlerClass != null) { if (customTypeHandlerClass != null) {
try { try {
customDataTypesHandler = (CustomDataTypesHandler) loadUserClass(customTypeHandlerClass).newInstance(); customDataTypesHandler = (CustomDataTypesHandler)
loadUserClass(customTypeHandlerClass).newInstance();
} catch (Exception e) { } catch (Exception e) {
throw DbException.convert(e); throw DbException.convert(e);
} }
......
...@@ -1109,7 +1109,8 @@ public class DataType { ...@@ -1109,7 +1109,8 @@ public class DataType {
return LocalDateTimeUtils.offsetDateTimeToValue(x); return LocalDateTimeUtils.offsetDateTimeToValue(x);
} else { } else {
if (JdbcUtils.customDataTypesHandler != null) { if (JdbcUtils.customDataTypesHandler != null) {
return JdbcUtils.customDataTypesHandler.getValue(type, x, session.getDataHandler()); return JdbcUtils.customDataTypesHandler.getValue(type, x,
session.getDataHandler());
} }
return ValueJavaObject.getNoCopy(x, null, session.getDataHandler()); return ValueJavaObject.getNoCopy(x, null, session.getDataHandler());
} }
......
...@@ -711,7 +711,8 @@ public class Transfer { ...@@ -711,7 +711,8 @@ public class Transfer {
return ValueGeometry.get(readString()); return ValueGeometry.get(readString());
default: default:
if (JdbcUtils.customDataTypesHandler != null) { if (JdbcUtils.customDataTypesHandler != null) {
return JdbcUtils.customDataTypesHandler.convert(ValueBytes.getNoCopy(readBytes()), type); return JdbcUtils.customDataTypesHandler.convert(
ValueBytes.getNoCopy(readBytes()), type);
} }
throw DbException.get(ErrorCode.CONNECTION_BROKEN_1, "type=" + type); throw DbException.get(ErrorCode.CONNECTION_BROKEN_1, "type=" + type);
} }
......
...@@ -84,7 +84,8 @@ public class TestCustomDataTypesHandler extends TestBase { ...@@ -84,7 +84,8 @@ public class TestCustomDataTypesHandler extends TestBase {
assertEquals(ComplexNumber.class.getName(), rs.getMetaData().getColumnClassName(1)); assertEquals(ComplexNumber.class.getName(), rs.getMetaData().getColumnClassName(1));
//Test insert //Test insert
PreparedStatement stmt = conn.prepareStatement("insert into t(id, val) values (0, '1.0+1.0i'), (1, ?), (2, ?), (3, ?)"); PreparedStatement stmt = conn.prepareStatement(
"insert into t(id, val) values (0, '1.0+1.0i'), (1, ?), (2, ?), (3, ?)");
stmt.setObject(1, new ComplexNumber(1, -1)); stmt.setObject(1, new ComplexNumber(1, -1));
stmt.setObject(2, "5.0+2.0i"); stmt.setObject(2, "5.0+2.0i");
stmt.setObject(3, 100.1); stmt.setObject(3, 100.1);
...@@ -98,7 +99,8 @@ public class TestCustomDataTypesHandler extends TestBase { ...@@ -98,7 +99,8 @@ public class TestCustomDataTypesHandler extends TestBase {
expected[3] = new ComplexNumber(100.1, 0); expected[3] = new ComplexNumber(100.1, 0);
for (int id = 0; id < expected.length; ++id) { for (int id = 0; id < expected.length; ++id) {
PreparedStatement prepStat = conn.prepareStatement("select val from t where id = ?"); PreparedStatement prepStat =conn.prepareStatement(
"select val from t where id = ?");
prepStat.setInt(1, id); prepStat.setInt(1, id);
rs = prepStat.executeQuery(); rs = prepStat.executeQuery();
assertTrue(rs.next()); assertTrue(rs.next());
...@@ -106,7 +108,8 @@ public class TestCustomDataTypesHandler extends TestBase { ...@@ -106,7 +108,8 @@ public class TestCustomDataTypesHandler extends TestBase {
} }
for (int id = 0; id < expected.length; ++id) { for (int id = 0; id < expected.length; ++id) {
PreparedStatement prepStat = conn.prepareStatement("select id from t where val = ?"); PreparedStatement prepStat = conn.prepareStatement(
"select id from t where val = ?");
prepStat.setObject(1, expected[id]); prepStat.setObject(1, expected[id]);
rs = prepStat.executeQuery(); rs = prepStat.executeQuery();
assertTrue(rs.next()); assertTrue(rs.next());
...@@ -117,7 +120,8 @@ public class TestCustomDataTypesHandler extends TestBase { ...@@ -117,7 +120,8 @@ public class TestCustomDataTypesHandler extends TestBase {
stat.execute("create index val_idx on t(val)"); stat.execute("create index val_idx on t(val)");
for (int id = 0; id < expected.length; ++id) { for (int id = 0; id < expected.length; ++id) {
PreparedStatement prepStat = conn.prepareStatement("select id from t where val = ?"); PreparedStatement prepStat = conn.prepareStatement(
"select id from t where val = ?");
prepStat.setObject(1, expected[id]); prepStat.setObject(1, expected[id]);
rs = prepStat.executeQuery(); rs = prepStat.executeQuery();
assertTrue(rs.next()); assertTrue(rs.next());
...@@ -130,7 +134,8 @@ public class TestCustomDataTypesHandler extends TestBase { ...@@ -130,7 +134,8 @@ public class TestCustomDataTypesHandler extends TestBase {
assertTrue(rs.getObject(1).equals(new ComplexNumber(107.1, 2))); assertTrue(rs.getObject(1).equals(new ComplexNumber(107.1, 2)));
// user function // user function
stat.execute("create alias complex_mod for \""+ getClass().getName() + ".complexMod\""); stat.execute("create alias complex_mod for \""
+ getClass().getName() + ".complexMod\"");
rs = stat.executeQuery("select complex_mod(val) from t where id=2"); rs = stat.executeQuery("select complex_mod(val) from t where id=2");
rs.next(); rs.next();
assertEquals(complexMod(expected[2]), rs.getDouble(1)); assertEquals(complexMod(expected[2]), rs.getDouble(1));
...@@ -221,15 +226,18 @@ public class TestCustomDataTypesHandler extends TestBase { ...@@ -221,15 +226,18 @@ public class TestCustomDataTypesHandler extends TestBase {
switch (source.getType()) { switch (source.getType()) {
case Value.JAVA_OBJECT: { case Value.JAVA_OBJECT: {
assert source instanceof ValueJavaObject; assert source instanceof ValueJavaObject;
return ValueComplex.get((ComplexNumber)JdbcUtils.deserialize(source.getBytesNoCopy(), null)); return ValueComplex.get((ComplexNumber)
JdbcUtils.deserialize(source.getBytesNoCopy(), null));
} }
case Value.STRING: { case Value.STRING: {
assert source instanceof ValueString; assert source instanceof ValueString;
return ValueComplex.get(ComplexNumber.parseComplexNumber(source.getString())); return ValueComplex.get(
ComplexNumber.parseComplexNumber(source.getString()));
} }
case Value.BYTES: { case Value.BYTES: {
assert source instanceof ValueBytes; assert source instanceof ValueBytes;
return ValueComplex.get((ComplexNumber)JdbcUtils.deserialize(source.getBytesNoCopy(), null)); return ValueComplex.get((ComplexNumber)
JdbcUtils.deserialize(source.getBytesNoCopy(), null));
} }
case Value.DOUBLE: { case Value.DOUBLE: {
assert source instanceof ValueDouble; assert source instanceof ValueDouble;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论