[Jython-checkins] jython: remove a couple java5isms
philip.jenvey
jython-checkins at python.org
Mon Sep 10 21:20:40 CEST 2012
http://hg.python.org/jython/rev/661a6baa10da
changeset: 6865:661a6baa10da
user: Philip Jenvey <pjenvey at underboss.org>
date: Mon Sep 10 12:14:15 2012 -0700
summary:
remove a couple java5isms
files:
src/com/ziclix/python/sql/DataHandler.java | 66 +---------
src/org/python/core/PySystemState.java | 7 +-
2 files changed, 9 insertions(+), 64 deletions(-)
diff --git a/src/com/ziclix/python/sql/DataHandler.java b/src/com/ziclix/python/sql/DataHandler.java
--- a/src/com/ziclix/python/sql/DataHandler.java
+++ b/src/com/ziclix/python/sql/DataHandler.java
@@ -233,14 +233,14 @@
case Types.CHAR:
case Types.VARCHAR:
- case Java6Types.NCHAR:
- case Java6Types.NVARCHAR:
+ case Types.NCHAR:
+ case Types.NVARCHAR:
String string = set.getString(col);
obj = string == null ? Py.None : Py.newUnicode(string);
break;
case Types.LONGVARCHAR:
- case Java6Types.LONGNVARCHAR:
+ case Types.LONGNVARCHAR:
Reader reader = set.getCharacterStream(col);
obj = reader == null ? Py.None : Py.newUnicode(read(reader));
break;
@@ -310,8 +310,8 @@
break;
case Types.CLOB:
- case Java6Types.NCLOB:
- case Java6Types.SQLXML:
+ case Types.NCLOB:
+ case Types.SQLXML:
Clob clob = set.getClob(col);
obj = clob == null ? Py.None : Py.java2py(read(clob.getCharacterStream()));
break;
@@ -325,7 +325,7 @@
throw createUnsupportedTypeSQLException("DISTINCT", col);
case Types.REF:
throw createUnsupportedTypeSQLException("REF", col);
- case Java6Types.ROWID:
+ case Types.ROWID:
throw createUnsupportedTypeSQLException("STRUCT", col);
case Types.STRUCT:
throw createUnsupportedTypeSQLException("STRUCT", col);
@@ -564,60 +564,6 @@
public String toString() {
return getClass().getName();
}
-
- /**
- * This interface can be removed as soon as we target java 6
- */
- private static interface Java6Types{
- /**
- * The constant in the Java programming language, sometimes referred to
- * as a type code, that identifies the generic SQL type <code>ROWID</code>
- *
- * @since 1.6
- *
- */
- public final static int ROWID = -8;
- /**
- * The constant in the Java programming language, sometimes referred to
- * as a type code, that identifies the generic SQL type <code>NCHAR</code>
- *
- * @since 1.6
- */
- public static final int NCHAR = -15;
-
- /**
- * The constant in the Java programming language, sometimes referred to
- * as a type code, that identifies the generic SQL type <code>NVARCHAR</code>.
- *
- * @since 1.6
- */
- public static final int NVARCHAR = -9;
-
- /**
- * The constant in the Java programming language, sometimes referred to
- * as a type code, that identifies the generic SQL type <code>LONGNVARCHAR</code>.
- *
- * @since 1.6
- */
- public static final int LONGNVARCHAR = -16;
-
- /**
- * The constant in the Java programming language, sometimes referred to
- * as a type code, that identifies the generic SQL type <code>NCLOB</code>.
- *
- * @since 1.6
- */
- public static final int NCLOB = 2011;
-
- /**
- * The constant in the Java programming language, sometimes referred to
- * as a type code, that identifies the generic SQL type <code>XML</code>.
- *
- * @since 1.6
- */
- public static final int SQLXML = 2009;
- }
-
}
diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java
--- a/src/org/python/core/PySystemState.java
+++ b/src/org/python/core/PySystemState.java
@@ -2,6 +2,7 @@
package org.python.core;
import java.io.BufferedReader;
+import java.io.Console;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -710,11 +711,9 @@
private static String getConsoleEncoding() {
String encoding = null;
try {
- // the Console class is only present in java 6 - have to use reflection
- Class<?> consoleClass = Class.forName("java.io.Console");
- Method encodingMethod = consoleClass.getDeclaredMethod("encoding");
+ Method encodingMethod = Console.class.getDeclaredMethod("encoding");
encodingMethod.setAccessible(true); // private static method
- encoding = (String)encodingMethod.invoke(consoleClass);
+ encoding = (String)encodingMethod.invoke(Console.class);
} catch (Exception e) {
// ignore any exception
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list