diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/BaseTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/BaseTypeHandler.java index a3854692..3d5622d0 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/BaseTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/BaseTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ */ public abstract class BaseTypeHandler implements TypeHandler { + @Override public boolean equals(Object object, String string) { if (object == null || string == null) { return object == string; - } else { - Object castedObject = valueOf(string); - return object.equals(castedObject); } + Object castedObject = valueOf(string); + return object.equals(castedObject); } } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/BigDecimalTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/BigDecimalTypeHandler.java index 8dffa92a..7c1a10f4 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/BigDecimalTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/BigDecimalTypeHandler.java @@ -26,37 +26,39 @@ */ public class BigDecimalTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { - ps.setBigDecimal(i, ((BigDecimal) parameter)); + ps.setBigDecimal(i, (BigDecimal) parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object bigdec = rs.getBigDecimal(columnName); if (rs.wasNull()) { return null; - } else { - return bigdec; } + return bigdec; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object bigdec = rs.getBigDecimal(columnIndex); if (rs.wasNull()) { return null; - } else { - return bigdec; } + return bigdec; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object bigdec = cs.getBigDecimal(columnIndex); if (cs.wasNull()) { return null; - } else { - return bigdec; } + return bigdec; } + @Override public Object valueOf(String s) { return java.math.BigDecimal.valueOf(Long.parseLong(s)); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/BlobTypeHandlerCallback.java b/src/main/java/com/ibatis/sqlmap/engine/type/BlobTypeHandlerCallback.java index 94cc5442..0a7687e2 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/BlobTypeHandlerCallback.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/BlobTypeHandlerCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ */ public class BlobTypeHandlerCallback implements TypeHandlerCallback { + @Override public Object getResult(ResultGetter getter) throws SQLException { Blob blob = getter.getBlob(); byte[] returnValue; @@ -40,16 +41,18 @@ public Object getResult(ResultGetter getter) throws SQLException { return returnValue; } + @Override public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { if (null != parameter) { byte[] bytes = (byte[]) parameter; ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - setter.setBinaryStream(bis, (int) (bytes.length)); + setter.setBinaryStream(bis, bytes.length); } else { setter.setNull(Types.BLOB); } } + @Override public Object valueOf(String s) { return s; } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/BooleanTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/BooleanTypeHandler.java index f6ee9729..2856ca02 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/BooleanTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/BooleanTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class BooleanTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setBoolean(i, ((Boolean) parameter).booleanValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { boolean b = rs.getBoolean(columnName); if (rs.wasNull()) { return null; - } else { - return Boolean.valueOf(b); } + return Boolean.valueOf(b); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { boolean b = rs.getBoolean(columnIndex); if (rs.wasNull()) { return null; - } else { - return Boolean.valueOf(b); } + return Boolean.valueOf(b); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { boolean b = cs.getBoolean(columnIndex); if (cs.wasNull()) { return null; - } else { - return Boolean.valueOf(b); } + return Boolean.valueOf(b); } + @Override public Object valueOf(String s) { return Boolean.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ByteArrayTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/ByteArrayTypeHandler.java index f595e1ae..6f45c75c 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ByteArrayTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ByteArrayTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class ByteArrayTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setBytes(i, (byte[]) parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object bytes = rs.getBytes(columnName); if (rs.wasNull()) { return null; - } else { - return bytes; } + return bytes; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object bytes = rs.getBytes(columnIndex); if (rs.wasNull()) { return null; - } else { - return bytes; } + return bytes; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object bytes = cs.getBytes(columnIndex); if (cs.wasNull()) { return null; - } else { - return bytes; } + return bytes; } + @Override public Object valueOf(String s) { return s.getBytes(); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ByteTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/ByteTypeHandler.java index a6235273..f4c2f6e0 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ByteTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ByteTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class ByteTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setByte(i, ((Byte) parameter).byteValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { byte b = rs.getByte(columnName); if (rs.wasNull()) { return null; - } else { - return Byte.valueOf(b); } + return Byte.valueOf(b); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { byte b = rs.getByte(columnIndex); if (rs.wasNull()) { return null; - } else { - return Byte.valueOf(b); } + return Byte.valueOf(b); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { byte b = cs.getByte(columnIndex); if (cs.wasNull()) { return null; - } else { - return Byte.valueOf(b); } + return Byte.valueOf(b); } + @Override public Object valueOf(String s) { return Byte.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/CallableStatementResultSet.java b/src/main/java/com/ibatis/sqlmap/engine/type/CallableStatementResultSet.java index ca2b9cf2..d12e70cc 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/CallableStatementResultSet.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/CallableStatementResultSet.java @@ -19,7 +19,22 @@ import java.io.Reader; import java.math.BigDecimal; import java.net.URL; -import java.sql.*; +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; import java.util.Calendar; import java.util.Map; @@ -41,817 +56,1008 @@ public CallableStatementResultSet(CallableStatement cs) { this.cs = cs; } + @Override public boolean absolute(int row) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void afterLast() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void beforeFirst() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void cancelRowUpdates() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void clearWarnings() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void close() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void deleteRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public int findColumn(String columnName) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean first() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public Array getArray(String colName) throws SQLException { return cs.getArray(colName); } + @Override public Array getArray(int i) throws SQLException { return cs.getArray(i); } + @Override public InputStream getAsciiStream(int columnIndex) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public InputStream getAsciiStream(String columnName) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public BigDecimal getBigDecimal(int columnIndex) throws SQLException { return cs.getBigDecimal(columnIndex); } + @Override public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public BigDecimal getBigDecimal(String columnName) throws SQLException { return cs.getBigDecimal(columnName); } + @Override public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public InputStream getBinaryStream(int columnIndex) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public InputStream getBinaryStream(String columnName) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public Blob getBlob(String colName) throws SQLException { return cs.getBlob(colName); } + @Override public Blob getBlob(int i) throws SQLException { return cs.getBlob(i); } + @Override public boolean getBoolean(int columnIndex) throws SQLException { return cs.getBoolean(columnIndex); } + @Override public boolean getBoolean(String columnName) throws SQLException { return cs.getBoolean(columnName); } + @Override public byte getByte(int columnIndex) throws SQLException { return cs.getByte(columnIndex); } + @Override public byte getByte(String columnName) throws SQLException { return cs.getByte(columnName); } + @Override public byte[] getBytes(int columnIndex) throws SQLException { return cs.getBytes(columnIndex); } + @Override public byte[] getBytes(String columnName) throws SQLException { return cs.getBytes(columnName); } + @Override public Reader getCharacterStream(int columnIndex) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public Reader getCharacterStream(String columnName) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public Clob getClob(String colName) throws SQLException { return cs.getClob(colName); } + @Override public Clob getClob(int i) throws SQLException { return cs.getClob(i); } + @Override public int getConcurrency() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public String getCursorName() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public Date getDate(int columnIndex) throws SQLException { return cs.getDate(columnIndex); } + @Override public Date getDate(int columnIndex, Calendar cal) throws SQLException { return cs.getDate(columnIndex, cal); } + @Override public Date getDate(String columnName) throws SQLException { return cs.getDate(columnName); } + @Override public Date getDate(String columnName, Calendar cal) throws SQLException { return cs.getDate(columnName, cal); } + @Override public double getDouble(int columnIndex) throws SQLException { return cs.getDouble(columnIndex); } + @Override public double getDouble(String columnName) throws SQLException { return cs.getDouble(columnName); } + @Override public int getFetchDirection() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public int getFetchSize() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public float getFloat(int columnIndex) throws SQLException { return cs.getFloat(columnIndex); } + @Override public float getFloat(String columnName) throws SQLException { return cs.getFloat(columnName); } + @Override public int getInt(int columnIndex) throws SQLException { return cs.getInt(columnIndex); } + @Override public int getInt(String columnName) throws SQLException { return cs.getInt(columnName); } + @Override public long getLong(int columnIndex) throws SQLException { return cs.getLong(columnIndex); } + @Override public long getLong(String columnName) throws SQLException { return cs.getLong(columnName); } + @Override public ResultSetMetaData getMetaData() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public Object getObject(String colName, Map map) throws SQLException { return cs.getObject(colName, map); } + @Override public Object getObject(int columnIndex) throws SQLException { return cs.getObject(columnIndex); } + @Override public Object getObject(String columnName) throws SQLException { return cs.getObject(columnName); } + @Override public Object getObject(int i, Map map) throws SQLException { return cs.getObject(i, map); } + @Override public Ref getRef(String colName) throws SQLException { return cs.getRef(colName); } + @Override public Ref getRef(int i) throws SQLException { return cs.getRef(i); } + @Override public int getRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public short getShort(int columnIndex) throws SQLException { return cs.getShort(columnIndex); } + @Override public short getShort(String columnName) throws SQLException { return cs.getShort(columnName); } + @Override public Statement getStatement() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public String getString(int columnIndex) throws SQLException { return cs.getString(columnIndex); } + @Override public String getString(String columnName) throws SQLException { return cs.getString(columnName); } + @Override public Time getTime(int columnIndex) throws SQLException { return cs.getTime(columnIndex); } + @Override public Time getTime(int columnIndex, Calendar cal) throws SQLException { return cs.getTime(columnIndex, cal); } + @Override public Time getTime(String columnName) throws SQLException { return cs.getTime(columnName); } + @Override public Time getTime(String columnName, Calendar cal) throws SQLException { return cs.getTime(columnName, cal); } + @Override public Timestamp getTimestamp(int columnIndex) throws SQLException { return cs.getTimestamp(columnIndex); } + @Override public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { return cs.getTimestamp(columnIndex, cal); } + @Override public Timestamp getTimestamp(String columnName) throws SQLException { return cs.getTimestamp(columnName); } + @Override public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { return cs.getTimestamp(columnName, cal); } + @Override public int getType() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public InputStream getUnicodeStream(int columnIndex) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public InputStream getUnicodeStream(String columnName) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public URL getURL(int columnIndex) throws SQLException { return cs.getURL(columnIndex); } + @Override public URL getURL(String columnName) throws SQLException { return cs.getURL(columnName); } + @Override public SQLWarning getWarnings() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void insertRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean isAfterLast() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean isBeforeFirst() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean isFirst() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean isLast() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean last() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void moveToCurrentRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void moveToInsertRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean next() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean previous() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void refreshRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean relative(int rows) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean rowDeleted() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean rowInserted() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean rowUpdated() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void setFetchDirection(int direction) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void setFetchSize(int rows) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateArray(int columnIndex, Array x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateArray(String columnName, Array x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBlob(int columnIndex, Blob x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBlob(String columnName, Blob x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBoolean(int columnIndex, boolean x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBoolean(String columnName, boolean x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateByte(int columnIndex, byte x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateByte(String columnName, byte x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBytes(int columnIndex, byte[] x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateBytes(String columnName, byte[] x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateCharacterStream(String columnName, Reader reader, int length) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateClob(int columnIndex, Clob x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateClob(String columnName, Clob x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateDate(int columnIndex, Date x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateDate(String columnName, Date x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateDouble(int columnIndex, double x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateDouble(String columnName, double x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateFloat(int columnIndex, float x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateFloat(String columnName, float x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateInt(int columnIndex, int x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateInt(String columnName, int x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateLong(int columnIndex, long x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateLong(String columnName, long x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateNull(int columnIndex) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateNull(String columnName) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateObject(int columnIndex, Object x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateObject(int columnIndex, Object x, int scale) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateObject(String columnName, Object x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateObject(String columnName, Object x, int scale) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateRef(int columnIndex, Ref x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateRef(String columnName, Ref x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateRow() throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateShort(int columnIndex, short x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateShort(String columnName, short x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateString(int columnIndex, String x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateString(String columnName, String x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateTime(int columnIndex, Time x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateTime(String columnName, Time x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public void updateTimestamp(String columnName, Timestamp x) throws SQLException { throw new UnsupportedOperationException("CallableStatement does not support this method."); } + @Override public boolean wasNull() throws SQLException { return cs.wasNull(); } + @Override public T unwrap(Class iface) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public boolean isWrapperFor(Class iface) throws SQLException { // TODO Auto-generated method stub return false; } + @Override public RowId getRowId(int columnIndex) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public RowId getRowId(String columnLabel) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public void updateRowId(int columnIndex, RowId x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateRowId(String columnLabel, RowId x) throws SQLException { // TODO Auto-generated method stub } + @Override public int getHoldability() throws SQLException { // TODO Auto-generated method stub return 0; } + @Override public boolean isClosed() throws SQLException { // TODO Auto-generated method stub return false; } + @Override public void updateNString(int columnIndex, String nString) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNString(String columnLabel, String nString) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNClob(int columnIndex, NClob nClob) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNClob(String columnLabel, NClob nClob) throws SQLException { // TODO Auto-generated method stub } + @Override public NClob getNClob(int columnIndex) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public NClob getNClob(String columnLabel) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public SQLXML getSQLXML(int columnIndex) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public SQLXML getSQLXML(String columnLabel) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { // TODO Auto-generated method stub } + @Override public String getNString(int columnIndex) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public String getNString(String columnLabel) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public Reader getNCharacterStream(int columnIndex) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public Reader getNCharacterStream(String columnLabel) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateClob(int columnIndex, Reader reader) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateClob(String columnLabel, Reader reader) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNClob(int columnIndex, Reader reader) throws SQLException { // TODO Auto-generated method stub } + @Override public void updateNClob(String columnLabel, Reader reader) throws SQLException { // TODO Auto-generated method stub } + @Override public T getObject(int columnIndex, Class type) throws SQLException { // TODO Auto-generated method stub return null; } + @Override public T getObject(String columnLabel, Class type) throws SQLException { // TODO Auto-generated method stub return null; diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ClobTypeHandlerCallback.java b/src/main/java/com/ibatis/sqlmap/engine/type/ClobTypeHandlerCallback.java index 25322f8e..e20e6eb4 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ClobTypeHandlerCallback.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ClobTypeHandlerCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ */ public class ClobTypeHandlerCallback implements TypeHandlerCallback { + @Override public Object getResult(ResultGetter getter) throws SQLException { String value; Clob clob = getter.getClob(); @@ -42,6 +43,7 @@ public Object getResult(ResultGetter getter) throws SQLException { return value; } + @Override public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { String s = (String) parameter; if (s != null) { @@ -52,6 +54,7 @@ public void setParameter(ParameterSetter setter, Object parameter) throws SQLExc } } + @Override public Object valueOf(String s) { return s; } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/CustomTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/CustomTypeHandler.java index e2920bcd..339e8388 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/CustomTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/CustomTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,26 +42,31 @@ public CustomTypeHandler(TypeHandlerCallback callback) { this.callback = callback; } + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ParameterSetter setter = new ParameterSetterImpl(ps, i); callback.setParameter(setter, parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { ResultGetter getter = new ResultGetterImpl(rs, columnName); return callback.getResult(getter); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { ResultGetter getter = new ResultGetterImpl(rs, columnIndex); return callback.getResult(getter); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { ResultGetter getter = new ResultGetterImpl(new CallableStatementResultSet(cs), columnIndex); return callback.getResult(getter); } + @Override public Object valueOf(String s) { return callback.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/DateOnlyTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/DateOnlyTypeHandler.java index b597972f..5075a500 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/DateOnlyTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/DateOnlyTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,37 +29,39 @@ public class DateOnlyTypeHandler extends BaseTypeHandler implements TypeHandler /** The Constant DATE_FORMAT. */ private static final String DATE_FORMAT = "yyyy/MM/dd"; + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setDate(i, new java.sql.Date(((Date) parameter).getTime())); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { java.sql.Date sqlDate = rs.getDate(columnName); if (rs.wasNull()) { return null; - } else { - return new java.util.Date(sqlDate.getTime()); } + return new java.util.Date(sqlDate.getTime()); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { java.sql.Date sqlDate = rs.getDate(columnIndex); if (rs.wasNull()) { return null; - } else { - return new java.util.Date(sqlDate.getTime()); } + return new java.util.Date(sqlDate.getTime()); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { java.sql.Date sqlDate = cs.getDate(columnIndex); if (cs.wasNull()) { return null; - } else { - return new java.util.Date(sqlDate.getTime()); } + return new java.util.Date(sqlDate.getTime()); } + @Override public Object valueOf(String s) { return SimpleDateFormatter.format(DATE_FORMAT, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/DateTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/DateTypeHandler.java index 2ab0bcf7..edaf32be 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/DateTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/DateTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,37 +29,39 @@ public class DateTypeHandler extends BaseTypeHandler implements TypeHandler { /** The Constant DATE_FORMAT. */ private static final String DATE_FORMAT = "yyyy/MM/dd hh:mm:ss"; + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setTimestamp(i, new java.sql.Timestamp(((Date) parameter).getTime())); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnName); if (rs.wasNull()) { return null; - } else { - return new java.util.Date(sqlTimestamp.getTime()); } + return new java.util.Date(sqlTimestamp.getTime()); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnIndex); if (rs.wasNull()) { return null; - } else { - return new java.util.Date(sqlTimestamp.getTime()); } + return new java.util.Date(sqlTimestamp.getTime()); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { java.sql.Timestamp sqlTimestamp = cs.getTimestamp(columnIndex); if (cs.wasNull()) { return null; - } else { - return new java.util.Date(sqlTimestamp.getTime()); } + return new java.util.Date(sqlTimestamp.getTime()); } + @Override public Object valueOf(String s) { return SimpleDateFormatter.format(DATE_FORMAT, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/DoubleTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/DoubleTypeHandler.java index fefe1291..31cb29c2 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/DoubleTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/DoubleTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class DoubleTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setDouble(i, ((Double) parameter).doubleValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { double d = rs.getDouble(columnName); if (rs.wasNull()) { return null; - } else { - return Double.valueOf(d); } + return Double.valueOf(d); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { double d = rs.getDouble(columnIndex); if (rs.wasNull()) { return null; - } else { - return Double.valueOf(d); } + return Double.valueOf(d); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { double d = cs.getDouble(columnIndex); if (cs.wasNull()) { return null; - } else { - return Double.valueOf(d); } + return Double.valueOf(d); } + @Override public Object valueOf(String s) { return Double.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/EnumTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/EnumTypeHandler.java index 634a6aef..43f10e85 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/EnumTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/EnumTypeHandler.java @@ -38,37 +38,39 @@ public EnumTypeHandler(Class type) { this.type = type; } + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setString(i, parameter.toString()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { String s = rs.getString(columnName); if (rs.wasNull()) { return null; - } else { - return Enum.valueOf(type, s); } + return Enum.valueOf(type, s); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { String s = rs.getString(columnIndex); if (rs.wasNull()) { return null; - } else { - return Enum.valueOf(type, s); } + return Enum.valueOf(type, s); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { String s = cs.getString(columnIndex); if (cs.wasNull()) { return null; - } else { - return Enum.valueOf(type, s); } + return Enum.valueOf(type, s); } + @Override public Object valueOf(String s) { return Enum.valueOf(type, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/FloatTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/FloatTypeHandler.java index e2001615..8892c342 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/FloatTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/FloatTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class FloatTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setFloat(i, ((Float) parameter).floatValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { float f = rs.getFloat(columnName); if (rs.wasNull()) { return null; - } else { - return Float.valueOf(f); } + return Float.valueOf(f); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { float f = rs.getFloat(columnIndex); if (rs.wasNull()) { return null; - } else { - return Float.valueOf(f); } + return Float.valueOf(f); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { float f = cs.getFloat(columnIndex); if (cs.wasNull()) { return null; - } else { - return Float.valueOf(f); } + return Float.valueOf(f); } + @Override public Object valueOf(String s) { return Float.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/IntegerTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/IntegerTypeHandler.java index b9e2fef8..9f2fc1d6 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/IntegerTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/IntegerTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class IntegerTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setInt(i, ((Integer) parameter).intValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { int i = rs.getInt(columnName); if (rs.wasNull()) { return null; - } else { - return Integer.valueOf(i); } + return Integer.valueOf(i); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { int i = rs.getInt(columnIndex); if (rs.wasNull()) { return null; - } else { - return Integer.valueOf(i); } + return Integer.valueOf(i); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { int i = cs.getInt(columnIndex); if (cs.wasNull()) { return null; - } else { - return Integer.valueOf(i); } + return Integer.valueOf(i); } + @Override public Object valueOf(String s) { return Integer.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/JdbcTypeRegistry.java b/src/main/java/com/ibatis/sqlmap/engine/type/JdbcTypeRegistry.java index 83631a3e..19c60950 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/JdbcTypeRegistry.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/JdbcTypeRegistry.java @@ -71,14 +71,14 @@ public static void setType(String name, int value) { * @return - the int value (from java.sql.Types) */ public static int getType(String name) { - if (name == null) + if (name == null) { return UNKNOWN_TYPE; + } Integer i = TYPE_MAP.get(name); if (i != null) { return i.intValue(); - } else { - return UNKNOWN_TYPE; } + return UNKNOWN_TYPE; } /** diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/LongTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/LongTypeHandler.java index 3fdfedc5..aa9d270f 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/LongTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/LongTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class LongTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setLong(i, ((Long) parameter).longValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { long l = rs.getLong(columnName); if (rs.wasNull()) { return null; - } else { - return Long.valueOf(l); } + return Long.valueOf(l); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { long l = rs.getLong(columnIndex); if (rs.wasNull()) { return null; - } else { - return Long.valueOf(l); } + return Long.valueOf(l); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { long l = cs.getLong(columnIndex); if (cs.wasNull()) { return null; - } else { - return Long.valueOf(l); } + return Long.valueOf(l); } + @Override public Object valueOf(String s) { return Long.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ObjectTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/ObjectTypeHandler.java index 033249b4..23171427 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ObjectTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ObjectTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class ObjectTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setObject(i, parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object object = rs.getObject(columnName); if (rs.wasNull()) { return null; - } else { - return object; } + return object; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object object = rs.getObject(columnIndex); if (rs.wasNull()) { return null; - } else { - return object; } + return object; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object object = cs.getObject(columnIndex); if (cs.wasNull()) { return null; - } else { - return object; } + return object; } + @Override public Object valueOf(String s) { return s; } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ParameterSetterImpl.java b/src/main/java/com/ibatis/sqlmap/engine/type/ParameterSetterImpl.java index ade8784d..1bbbe24c 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ParameterSetterImpl.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ParameterSetterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,15 @@ import java.io.Reader; import java.math.BigDecimal; import java.net.URL; -import java.sql.*; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.Ref; +import java.sql.SQLException; +import java.sql.Time; +import java.sql.Timestamp; import java.util.Calendar; /** @@ -48,126 +56,157 @@ public ParameterSetterImpl(PreparedStatement statement, int columnIndex) { this.index = columnIndex; } + @Override public void setArray(Array x) throws SQLException { ps.setArray(index, x); } + @Override public void setAsciiStream(InputStream x, int length) throws SQLException { ps.setAsciiStream(index, x, length); } + @Override public void setBigDecimal(BigDecimal x) throws SQLException { ps.setBigDecimal(index, x); } + @Override public void setBinaryStream(InputStream x, int length) throws SQLException { ps.setBinaryStream(index, x, length); } + @Override public void setBlob(Blob x) throws SQLException { ps.setBlob(index, x); } + @Override public void setBoolean(boolean x) throws SQLException { ps.setBoolean(index, x); } + @Override public void setByte(byte x) throws SQLException { ps.setByte(index, x); } + @Override public void setBytes(byte x[]) throws SQLException { ps.setBytes(index, x); } + @Override public void setCharacterStream(Reader reader, int length) throws SQLException { ps.setCharacterStream(index, reader, length); } + @Override public void setClob(Clob x) throws SQLException { ps.setClob(index, x); } + @Override public void setDate(Date x) throws SQLException { ps.setDate(index, x); } + @Override public void setDate(Date x, Calendar cal) throws SQLException { ps.setDate(index, x, cal); } + @Override public void setDouble(double x) throws SQLException { ps.setDouble(index, x); } + @Override public void setFloat(float x) throws SQLException { ps.setFloat(index, x); } + @Override public void setInt(int x) throws SQLException { ps.setInt(index, x); } + @Override public void setLong(long x) throws SQLException { ps.setLong(index, x); } + @Override public void setNull(int sqlType) throws SQLException { ps.setNull(index, sqlType); } + @Override public void setNull(int sqlType, String typeName) throws SQLException { ps.setNull(index, sqlType, typeName); } + @Override public void setObject(Object x) throws SQLException { ps.setObject(index, x); } + @Override public void setObject(Object x, int targetSqlType) throws SQLException { ps.setObject(index, x, targetSqlType); } + @Override public void setObject(Object x, int targetSqlType, int scale) throws SQLException { ps.setObject(index, x, scale); } + @Override public void setRef(Ref x) throws SQLException { ps.setRef(index, x); } + @Override public void setShort(short x) throws SQLException { ps.setShort(index, x); } + @Override public void setString(String x) throws SQLException { ps.setString(index, x); } + @Override public void setTime(Time x) throws SQLException { ps.setTime(index, x); } + @Override public void setTime(Time x, Calendar cal) throws SQLException { ps.setTime(index, x, cal); } + @Override public void setTimestamp(Timestamp x) throws SQLException { ps.setTimestamp(index, x); } + @Override public void setTimestamp(Timestamp x, Calendar cal) throws SQLException { ps.setTimestamp(index, x, cal); } + @Override public void setURL(URL x) throws SQLException { ps.setURL(index, x); } + @Override public PreparedStatement getPreparedStatement() { return ps; } + @Override public int getParameterIndex() { return index; } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ResultGetterImpl.java b/src/main/java/com/ibatis/sqlmap/engine/type/ResultGetterImpl.java index f34b4f55..e0b5600d 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ResultGetterImpl.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ResultGetterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,15 @@ import java.math.BigDecimal; import java.net.URL; -import java.sql.*; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Time; +import java.sql.Timestamp; import java.util.Calendar; import java.util.Map; @@ -63,202 +71,206 @@ public ResultGetterImpl(ResultSet resultSet, String columnName) { this.name = columnName; } + @Override public Array getArray() throws SQLException { if (name != null) { return rs.getArray(name); - } else { - return rs.getArray(index); } + return rs.getArray(index); } + @Override public BigDecimal getBigDecimal() throws SQLException { if (name != null) { return rs.getBigDecimal(name); - } else { - return rs.getBigDecimal(index); } + return rs.getBigDecimal(index); } + @Override public Blob getBlob() throws SQLException { if (name != null) { return rs.getBlob(name); - } else { - return rs.getBlob(index); } + return rs.getBlob(index); } + @Override public boolean getBoolean() throws SQLException { if (name != null) { return rs.getBoolean(name); - } else { - return rs.getBoolean(index); } + return rs.getBoolean(index); } + @Override public byte getByte() throws SQLException { if (name != null) { return rs.getByte(name); - } else { - return rs.getByte(index); } + return rs.getByte(index); } + @Override public byte[] getBytes() throws SQLException { if (name != null) { return rs.getBytes(name); - } else { - return rs.getBytes(index); } + return rs.getBytes(index); } + @Override public Clob getClob() throws SQLException { if (name != null) { return rs.getClob(name); - } else { - return rs.getClob(index); } + return rs.getClob(index); } + @Override public Date getDate() throws SQLException { if (name != null) { return rs.getDate(name); - } else { - return rs.getDate(index); } + return rs.getDate(index); } + @Override public Date getDate(Calendar cal) throws SQLException { if (name != null) { return rs.getDate(name, cal); - } else { - return rs.getDate(index, cal); } + return rs.getDate(index, cal); } + @Override public double getDouble() throws SQLException { if (name != null) { return rs.getDouble(name); - } else { - return rs.getDouble(index); } + return rs.getDouble(index); } + @Override public float getFloat() throws SQLException { if (name != null) { return rs.getFloat(name); - } else { - return rs.getFloat(index); } + return rs.getFloat(index); } + @Override public int getInt() throws SQLException { if (name != null) { return rs.getInt(name); - } else { - return rs.getInt(index); } + return rs.getInt(index); } + @Override public long getLong() throws SQLException { if (name != null) { return rs.getLong(name); - } else { - return rs.getLong(index); } + return rs.getLong(index); } + @Override public Object getObject() throws SQLException { if (name != null) { return rs.getObject(name); - } else { - return rs.getObject(index); } + return rs.getObject(index); } + @Override public Object getObject(Map map) throws SQLException { if (name != null) { return rs.getObject(name, map); - } else { - return rs.getObject(index, map); } + return rs.getObject(index, map); } + @Override public Ref getRef() throws SQLException { if (name != null) { return rs.getRef(name); - } else { - return rs.getRef(index); } + return rs.getRef(index); } + @Override public short getShort() throws SQLException { if (name != null) { return rs.getShort(name); - } else { - return rs.getShort(index); } + return rs.getShort(index); } + @Override public String getString() throws SQLException { if (name != null) { return rs.getString(name); - } else { - return rs.getString(index); } + return rs.getString(index); } + @Override public Time getTime() throws SQLException { if (name != null) { return rs.getTime(name); - } else { - return rs.getTime(index); } + return rs.getTime(index); } + @Override public Time getTime(Calendar cal) throws SQLException { if (name != null) { return rs.getTime(name); - } else { - return rs.getTime(index); } + return rs.getTime(index); } + @Override public Timestamp getTimestamp() throws SQLException { if (name != null) { return rs.getTimestamp(name); - } else { - return rs.getTimestamp(index); } + return rs.getTimestamp(index); } + @Override public Timestamp getTimestamp(Calendar cal) throws SQLException { if (name != null) { return rs.getTimestamp(name, cal); - } else { - return rs.getTimestamp(index, cal); } + return rs.getTimestamp(index, cal); } + @Override public URL getURL() throws SQLException { if (name != null) { return rs.getURL(name); - } else { - return rs.getURL(index); } + return rs.getURL(index); } + @Override public boolean wasNull() throws SQLException { return rs.wasNull(); } + @Override public ResultSet getResultSet() { return rs; } + @Override public int getColumnIndex() { return index; } + @Override public String getColumnName() { return name; } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/ShortTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/ShortTypeHandler.java index 0324d893..555110f3 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/ShortTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/ShortTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class ShortTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setShort(i, ((Short) parameter).shortValue()); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { short s = rs.getShort(columnName); if (rs.wasNull()) { return null; - } else { - return Short.valueOf(s); } + return Short.valueOf(s); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { short s = rs.getShort(columnIndex); if (rs.wasNull()) { return null; - } else { - return Short.valueOf(s); } + return Short.valueOf(s); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { short s = cs.getShort(columnIndex); if (cs.wasNull()) { return null; - } else { - return Short.valueOf(s); } + return Short.valueOf(s); } + @Override public Object valueOf(String s) { return Short.valueOf(s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/SqlDateTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/SqlDateTypeHandler.java index 484150ca..aee15fd0 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/SqlDateTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/SqlDateTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,37 +28,39 @@ public class SqlDateTypeHandler extends BaseTypeHandler implements TypeHandler { /** The Constant DATE_FORMAT. */ private static final String DATE_FORMAT = "yyyy/MM/dd"; + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setDate(i, (java.sql.Date) parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object sqlDate = rs.getDate(columnName); if (rs.wasNull()) { return null; - } else { - return sqlDate; } + return sqlDate; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object sqlDate = rs.getDate(columnIndex); if (rs.wasNull()) { return null; - } else { - return sqlDate; } + return sqlDate; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object sqlDate = cs.getDate(columnIndex); if (cs.wasNull()) { return null; - } else { - return sqlDate; } + return sqlDate; } + @Override public Object valueOf(String s) { return SimpleDateFormatter.format(DATE_FORMAT, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimeTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimeTypeHandler.java index 822bee9d..eb4b6136 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimeTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimeTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,37 +28,39 @@ public class SqlTimeTypeHandler extends BaseTypeHandler implements TypeHandler { /** The Constant DATE_FORMAT. */ private static final String DATE_FORMAT = "hh:mm:ss"; + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setTime(i, (java.sql.Time) parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object sqlTime = rs.getTime(columnName); if (rs.wasNull()) { return null; - } else { - return sqlTime; } + return sqlTime; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object sqlTime = rs.getTime(columnIndex); if (rs.wasNull()) { return null; - } else { - return sqlTime; } + return sqlTime; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object sqlTime = cs.getTime(columnIndex); if (cs.wasNull()) { return null; - } else { - return sqlTime; } + return sqlTime; } + @Override public Object valueOf(String s) { return SimpleDateFormatter.format(DATE_FORMAT, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimestampTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimestampTypeHandler.java index 17ae87ac..66af6d76 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimestampTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/SqlTimestampTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,37 +28,39 @@ public class SqlTimestampTypeHandler extends BaseTypeHandler implements TypeHand /** The Constant DATE_FORMAT. */ private static final String DATE_FORMAT = "yyyy/MM/dd hh:mm:ss"; + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setTimestamp(i, (java.sql.Timestamp) parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object sqlTimestamp = rs.getTimestamp(columnName); if (rs.wasNull()) { return null; - } else { - return sqlTimestamp; } + return sqlTimestamp; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object sqlTimestamp = rs.getTimestamp(columnIndex); if (rs.wasNull()) { return null; - } else { - return sqlTimestamp; } + return sqlTimestamp; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object sqlTimestamp = cs.getTimestamp(columnIndex); if (cs.wasNull()) { return null; - } else { - return sqlTimestamp; } + return sqlTimestamp; } + @Override public Object valueOf(String s) { return SimpleDateFormatter.format(DATE_FORMAT, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/StringTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/StringTypeHandler.java index 937f56d3..0fed2f90 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/StringTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/StringTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,37 +25,39 @@ */ public class StringTypeHandler extends BaseTypeHandler implements TypeHandler { + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { - ps.setString(i, ((String) parameter)); + ps.setString(i, (String) parameter); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object s = rs.getString(columnName); if (rs.wasNull()) { return null; - } else { - return s; } + return s; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object s = rs.getString(columnIndex); if (rs.wasNull()) { return null; - } else { - return s; } + return s; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object s = cs.getString(columnIndex); if (cs.wasNull()) { return null; - } else { - return s; } + return s; } + @Override public Object valueOf(String s) { return s; } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/TimeOnlyTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/TimeOnlyTypeHandler.java index 5e8703bc..af3d540b 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/TimeOnlyTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/TimeOnlyTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,37 +29,39 @@ public class TimeOnlyTypeHandler extends BaseTypeHandler implements TypeHandler /** The Constant DATE_FORMAT. */ private static final String DATE_FORMAT = "hh:mm:ss"; + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { ps.setTime(i, new java.sql.Time(((Date) parameter).getTime())); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { java.sql.Time sqlTime = rs.getTime(columnName); if (rs.wasNull()) { return null; - } else { - return new java.util.Date(sqlTime.getTime()); } + return new java.util.Date(sqlTime.getTime()); } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { java.sql.Time sqlTime = rs.getTime(columnIndex); if (rs.wasNull()) { return null; - } else { - return new java.util.Date(sqlTime.getTime()); } + return new java.util.Date(sqlTime.getTime()); } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { java.sql.Time sqlTime = cs.getTime(columnIndex); if (cs.wasNull()) { return null; - } else { - return new java.util.Date(sqlTime.getTime()); } + return new java.util.Date(sqlTime.getTime()); } + @Override public Object valueOf(String s) { return SimpleDateFormatter.format(DATE_FORMAT, s); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandler.java index 06bf9ad4..b7f956f6 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public interface TypeHandler { * @throws SQLException * if setting the parameter fails */ - public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException; + void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException; /** * Gets a column from a result set. @@ -55,7 +55,7 @@ public interface TypeHandler { * @throws SQLException * if getting the value fails */ - public Object getResult(ResultSet rs, String columnName) throws SQLException; + Object getResult(ResultSet rs, String columnName) throws SQLException; /** * Gets a column from a result set. @@ -70,7 +70,7 @@ public interface TypeHandler { * @throws SQLException * if getting the value fails */ - public Object getResult(ResultSet rs, int columnIndex) throws SQLException; + Object getResult(ResultSet rs, int columnIndex) throws SQLException; /** * Gets a column from a callable statement. @@ -85,7 +85,7 @@ public interface TypeHandler { * @throws SQLException * if getting the value fails */ - public Object getResult(CallableStatement cs, int columnIndex) throws SQLException; + Object getResult(CallableStatement cs, int columnIndex) throws SQLException; /** * Converts the String to the type that this handler deals with. @@ -95,7 +95,7 @@ public interface TypeHandler { * * @return - the converted value */ - public Object valueOf(String s); + Object valueOf(String s); /** * Compares two values (that this handler deals with) for equality. @@ -107,6 +107,6 @@ public interface TypeHandler { * * @return - true if they are equal */ - public boolean equals(Object object, String string); + boolean equals(Object object, String string); } diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java b/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java index e40a5d63..a7f6b04f 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java @@ -18,7 +18,13 @@ import com.ibatis.sqlmap.client.SqlMapException; import java.math.BigDecimal; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** * Not much of a suprise, this is a factory class for TypeHandler objects. @@ -36,6 +42,8 @@ public class TypeHandlerFactory { /** The Constant reversePrimitiveMap. */ private static final Map reversePrimitiveMap = new HashMap<>() { + private static final long serialVersionUID = 1L; + { put(Byte.class, byte.class); put(Short.class, short.class); @@ -53,9 +61,8 @@ public class TypeHandlerFactory { * Default constructor. */ public TypeHandlerFactory() { - TypeHandler handler; + TypeHandler handler = new BooleanTypeHandler(); - handler = new BooleanTypeHandler(); register(Boolean.class, handler); register(boolean.class, handler); @@ -231,8 +238,9 @@ public void register(Class type, String jdbcType, TypeHandler handler) { */ public String resolveAlias(String string) { String key = null; - if (string != null) + if (string != null) { key = string.toLowerCase(); + } String value = null; if (typeAliases.containsKey(key)) { value = typeAliases.get(key); @@ -254,8 +262,9 @@ public String resolveAlias(String string) { */ public void putTypeAlias(String alias, String value) { String key = null; - if (alias != null) + if (alias != null) { key = alias.toLowerCase(); + } if (typeAliases.containsKey(key) && !typeAliases.get(key).equals(value)) { throw new SqlMapException("Error in XmlSqlMapClientBuilder. Alias name conflict occurred. The alias '" + key + "' is already mapped to the value '" + typeAliases.get(alias) + "'."); diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/UnknownTypeHandler.java b/src/main/java/com/ibatis/sqlmap/engine/type/UnknownTypeHandler.java index 06def517..23cfec34 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/UnknownTypeHandler.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/UnknownTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ public UnknownTypeHandler(TypeHandlerFactory factory) { this.factory = factory; } + @Override public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException { Class searchClass = parameter.getClass(); if (searchClass == null) { @@ -47,33 +48,34 @@ public void setParameter(PreparedStatement ps, int i, Object parameter, String j handler.setParameter(ps, i, parameter, jdbcType); } + @Override public Object getResult(ResultSet rs, String columnName) throws SQLException { Object object = rs.getObject(columnName); if (rs.wasNull()) { return null; - } else { - return object; } + return object; } + @Override public Object getResult(ResultSet rs, int columnIndex) throws SQLException { Object object = rs.getObject(columnIndex); if (rs.wasNull()) { return null; - } else { - return object; } + return object; } + @Override public Object getResult(CallableStatement cs, int columnIndex) throws SQLException { Object object = cs.getObject(columnIndex); if (cs.wasNull()) { return null; - } else { - return object; } + return object; } + @Override public Object valueOf(String s) { return s; } @@ -82,11 +84,10 @@ public Object valueOf(String s) { public boolean equals(Object object, String string) { if (object == null || string == null) { return object == string; - } else { - TypeHandler handler = factory.getTypeHandler(object.getClass()); - Object castedObject = handler.valueOf(string); - return object.equals(castedObject); } + TypeHandler handler = factory.getTypeHandler(object.getClass()); + Object castedObject = handler.valueOf(string); + return object.equals(castedObject); } }