You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2017/08/27 14:48:29 UTC
svn commit: r1806372 - in
/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util:
DBTypeConversion.java DbTools.java ORowSetValue.java
Author: damjan
Date: Sun Aug 27 14:48:28 2017
New Revision: 1806372
URL: http://svn.apache.org/viewvc?rev=1806372&view=rev
Log:
Port some Javadoc to helper classes.
Don't use Java 8 only methods.
Patch by: me
Modified:
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ORowSetValue.java
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java?rev=1806372&r1=1806371&r2=1806372&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java Sun Aug 27 14:48:28 2017
@@ -21,6 +21,7 @@
package com.sun.star.sdbcx.comp.postgresql.util;
+import java.math.BigInteger;
import java.util.StringTokenizer;
import com.sun.star.util.Date;
@@ -80,6 +81,22 @@ public class DBTypeConversion {
}
return d;
}
+
+ public static int toUnsignedInt(byte value) {
+ return value & 0xff;
+ }
+
+ public static int toUnsignedInt(short value) {
+ return value & 0xffff;
+ }
+
+ public static String toUnsignedString(int value) {
+ return Long.toString(value & 0xffffFFFFL);
+ }
+
+ public static String toUnsignedString(long value) {
+ return new BigInteger(Long.toHexString(value), 16).toString();
+ }
public static void addDays(int nDays, Date _rDate) {
int nTempDays = implRelativeToAbsoluteNull( _rDate );
@@ -399,28 +416,31 @@ public class DBTypeConversion {
return new Time(nHundredthSeconds,nSecond,nMinute,nHour);
}
+ /// Return the date in the format %04d-%02d-%02d.
public static String toDateString(Date date) {
return String.format("%04d-%02d-%02d",
- Short.toUnsignedInt(date.Year),
- Short.toUnsignedInt(date.Month),
- Short.toUnsignedInt(date.Day));
+ toUnsignedInt(date.Year),
+ toUnsignedInt(date.Month),
+ toUnsignedInt(date.Day));
}
+ /// Return the time in the format %02d:%02d:%02d.
public static String toTimeString(Time time) {
return String.format("%02d:%02d:%02d",
- Short.toUnsignedInt(time.Hours),
- Short.toUnsignedInt(time.Minutes),
- Short.toUnsignedInt(time.Seconds));
+ toUnsignedInt(time.Hours),
+ toUnsignedInt(time.Minutes),
+ toUnsignedInt(time.Seconds));
}
+ /// Return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d.%d.
public static String toDateTimeString(DateTime dateTime) {
return String.format("%04d-%02d-%02d %02d:%02d:%02d.%d",
- Short.toUnsignedInt(dateTime.Year),
- Short.toUnsignedInt(dateTime.Month),
- Short.toUnsignedInt(dateTime.Day),
- Short.toUnsignedInt(dateTime.Hours),
- Short.toUnsignedInt(dateTime.Minutes),
- Short.toUnsignedInt(dateTime.Seconds),
- Short.toUnsignedInt(dateTime.HundredthSeconds));
+ toUnsignedInt(dateTime.Year),
+ toUnsignedInt(dateTime.Month),
+ toUnsignedInt(dateTime.Day),
+ toUnsignedInt(dateTime.Hours),
+ toUnsignedInt(dateTime.Minutes),
+ toUnsignedInt(dateTime.Seconds),
+ toUnsignedInt(dateTime.HundredthSeconds));
}
}
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java?rev=1806372&r1=1806371&r2=1806372&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java Sun Aug 27 14:48:28 2017
@@ -604,6 +604,7 @@ public class DbTools {
return sql.toString();
}
+ /// We need some more information about the column.
public static Map<String,ExtraColumnInfo> collectColumnInformation(XConnection connection, String composedName, String columnName) throws SQLException {
String sql = String.format("SELECT %s FROM %s WHERE 0 = 1", columnName, composedName);
XStatement statement = null;
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ORowSetValue.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ORowSetValue.java?rev=1806372&r1=1806371&r2=1806372&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ORowSetValue.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ORowSetValue.java Sun Aug 27 14:48:28 2017
@@ -886,7 +886,7 @@ public class ORowSetValue {
aRet = (String)value;
break;
case DataType.BIGINT:
- aRet = isSigned() ? Long.toString((long)value) : Long.toUnsignedString((long)value);
+ aRet = isSigned() ? Long.toString((long)value) : DBTypeConversion.toUnsignedString((long)value);
break;
case DataType.FLOAT:
aRet = ((Float)value).toString();
@@ -911,7 +911,7 @@ public class ORowSetValue {
StringBuilder sVal = new StringBuilder("0x");
byte[] sSeq = getSequence();
for (byte b : sSeq) {
- sVal.append(String.format("%02x", Byte.toUnsignedInt(b)));
+ sVal.append(String.format("%02x", DBTypeConversion.toUnsignedInt(b)));
}
aRet = sVal.toString();
}
@@ -921,13 +921,13 @@ public class ORowSetValue {
aRet = ((Boolean)value).toString();
break;
case DataType.TINYINT:
- aRet = isSigned() ? Integer.toString((byte)value) : Integer.toUnsignedString(0xff & (byte)value);
+ aRet = isSigned() ? Integer.toString((byte)value) : DBTypeConversion.toUnsignedString(0xff & (byte)value);
break;
case DataType.SMALLINT:
- aRet = isSigned() ? Integer.toString((short)value) : Integer.toUnsignedString(0xffff & (short)value);
+ aRet = isSigned() ? Integer.toString((short)value) : DBTypeConversion.toUnsignedString(0xffff & (short)value);
break;
case DataType.INTEGER:
- aRet = isSigned() ? Integer.toString((int)value) : Integer.toUnsignedString((int)value);
+ aRet = isSigned() ? Integer.toString((int)value) : DBTypeConversion.toUnsignedString((int)value);
break;
case DataType.CLOB:
if (AnyConverter.isObject(value)) {