From: <pj...@us...> - 2009-07-31 05:02:13
|
Revision: 6611 http://jython.svn.sourceforge.net/jython/?rev=6611&view=rev Author: pjenvey Date: 2009-07-31 05:01:54 +0000 (Fri, 31 Jul 2009) Log Message: ----------- quiet warnings, some coding standards Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/Fetch.java trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java trunk/jython/src/com/ziclix/python/sql/util/Queue.java Modified: trunk/jython/src/com/ziclix/python/sql/Fetch.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Fetch.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/Fetch.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -79,7 +79,7 @@ /** * A list of warning listeners. */ - private List listeners; + private List<WarningListener> listeners; /** * Constructor Fetch @@ -92,7 +92,7 @@ this.rownumber = -1; this.description = Py.None; this.datahandler = datahandler; - this.listeners = new ArrayList(3); + this.listeners = new ArrayList<WarningListener>(3); } /** @@ -142,7 +142,7 @@ * @param resultSet * @param skipCols JDBC-indexed set of columns to be skipped */ - abstract public void add(ResultSet resultSet, Set skipCols); + abstract public void add(ResultSet resultSet, Set<Integer> skipCols); /** * Method add @@ -151,7 +151,8 @@ * @param procedure * @param params */ - abstract public void add(CallableStatement callableStatement, Procedure procedure, PyObject params); + abstract public void add(CallableStatement callableStatement, Procedure procedure, + PyObject params); /** * Fetch the next row of a query result set, returning a single sequence, @@ -253,7 +254,6 @@ * precision and scale are only available for numeric types */ protected PyObject createDescription(ResultSetMetaData meta) throws SQLException { - PyObject metadata = new PyList(); for (int i = 1; i <= meta.getColumnCount(); i++) { @@ -265,7 +265,6 @@ a[3] = Py.None; switch (meta.getColumnType(i)) { - case Types.BIGINT: case Types.BIT: case Types.DECIMAL: @@ -284,7 +283,6 @@ } a[6] = Py.newInteger(meta.isNullable(i)); - ((PyList) metadata).append(new PyTuple(a)); } @@ -299,7 +297,6 @@ * precision and scale are only available for numeric types */ protected PyObject createDescription(Procedure procedure) throws SQLException { - PyObject metadata = new PyList(); for (int i = 0, len = procedure.columns.__len__(); i < len; i++) { @@ -307,7 +304,6 @@ int colType = column.__getitem__(Procedure.COLUMN_TYPE).asInt(); switch (colType) { - case DatabaseMetaData.procedureColumnReturn: PyObject[] a = new PyObject[7]; @@ -317,7 +313,6 @@ a[3] = column.__getitem__(Procedure.LENGTH); switch (a[1].asInt()) { - case Types.BIGINT: case Types.BIT: case Types.DECIMAL: @@ -336,9 +331,7 @@ } int nullable = column.__getitem__(Procedure.NULLABLE).asInt(); - a[6] = (nullable == DatabaseMetaData.procedureNullable) ? Py.One : Py.Zero; - ((PyList) metadata).append(new PyTuple(a)); break; } @@ -356,8 +349,8 @@ * @return PyObject * @throws SQLException */ - protected PyObject createResults(CallableStatement callableStatement, Procedure procedure, PyObject params) throws SQLException { - + protected PyObject createResults(CallableStatement callableStatement, Procedure procedure, + PyObject params) throws SQLException { PyList results = new PyList(); for (int i = 0, j = 0, len = procedure.columns.__len__(); i < len; i++) { @@ -367,7 +360,6 @@ int dataType = column.__getitem__(Procedure.DATA_TYPE).asInt(); switch (colType) { - case DatabaseMetaData.procedureColumnIn: j++; break; @@ -399,9 +391,7 @@ } PyList ret = new PyList(); - ret.append(PyTuple.fromIterable(results)); - return ret; } @@ -413,13 +403,12 @@ * @return a list of tuples of the results * @throws SQLException */ - protected PyList createResults(ResultSet set, Set skipCols, PyObject metaData) throws SQLException { - + protected PyList createResults(ResultSet set, Set<Integer> skipCols, PyObject metaData) + throws SQLException { PyList res = new PyList(); while (set.next()) { PyObject tuple = createResult(set, skipCols, metaData); - res.append(tuple); } @@ -434,40 +423,36 @@ * @return a tuple of the results * @throws SQLException */ - protected PyTuple createResult(ResultSet set, Set skipCols, PyObject metaData) throws SQLException { - + protected PyTuple createResult(ResultSet set, Set<Integer> skipCols, PyObject metaData) + throws SQLException { int descriptionLength = metaData.__len__(); PyObject[] row = new PyObject[descriptionLength]; for (int i = 0; i < descriptionLength; i++) { - if ((skipCols != null) && skipCols.contains(new Integer(i + 1))) { + if (skipCols != null && skipCols.contains(i + 1)) { row[i] = Py.None; } else { int type = ((PyInteger) metaData.__getitem__(i).__getitem__(1)).getValue(); - row[i] = datahandler.getPyObject(set, i + 1, type); } } SQLWarning warning = set.getWarnings(); - if (warning != null) { fireWarning(warning); } - PyTuple tuple = new PyTuple(row); - - return tuple; + return new PyTuple(row); } protected void fireWarning(SQLWarning warning) { - WarningEvent event = new WarningEvent(this, warning); - for (int i = listeners.size() - 1; i >= 0; i--) { + for (WarningListener listener : listeners) { try { - ((WarningListener) listeners.get(i)).warning(event); + listener.warning(event); } catch (Throwable t) { + // ok } } } @@ -493,23 +478,21 @@ /** * Field results */ - protected List results; + protected List<PyObject> results; /** * Field descriptions */ - protected List descriptions; + protected List<PyObject> descriptions; /** * Construct a static fetch. The entire result set is iterated as it * is added and the result set is immediately closed. */ public StaticFetch(DataHandler datahandler) { - super(datahandler); - - this.results = new LinkedList(); - this.descriptions = new LinkedList(); + this.results = new LinkedList<PyObject>(); + this.descriptions = new LinkedList<PyObject>(); } /** @@ -517,6 +500,7 @@ * * @param resultSet */ + @Override public void add(ResultSet resultSet) { this.add(resultSet, null); } @@ -527,10 +511,10 @@ * @param resultSet * @param skipCols */ - public void add(ResultSet resultSet, Set skipCols) { - + @Override + public void add(ResultSet resultSet, Set<Integer> skipCols) { try { - if ((resultSet != null) && (resultSet.getMetaData() != null)) { + if (resultSet != null && resultSet.getMetaData() != null) { PyObject metadata = this.createDescription(resultSet.getMetaData()); PyObject result = this.createResults(resultSet, skipCols, metadata); @@ -538,10 +522,10 @@ this.descriptions.add(metadata); // we want the rowcount of the first result set - this.rowcount = ((PyObject) this.results.get(0)).__len__(); + this.rowcount = this.results.get(0).__len__(); // we want the description of the first result set - this.description = ((PyObject) this.descriptions.get(0)); + this.description = this.descriptions.get(0); // set the current rownumber this.rownumber = 0; @@ -565,8 +549,8 @@ * @param procedure * @param params */ + @Override public void add(CallableStatement callableStatement, Procedure procedure, PyObject params) { - try { PyObject result = this.createResults(callableStatement, procedure, params); @@ -575,10 +559,10 @@ this.descriptions.add(this.createDescription(procedure)); // we want the rowcount of the first result set - this.rowcount = ((PyObject) this.results.get(0)).__len__(); + this.rowcount = this.results.get(0).__len__(); // we want the description of the first result set - this.description = ((PyObject) this.descriptions.get(0)); + this.description = this.descriptions.get(0); // set the current rownumber this.rownumber = 0; @@ -601,6 +585,7 @@ * @return a sequence of sequences from the result set, or an empty sequence when * no more data is available */ + @Override public PyObject fetchall() { return fetchmany(this.rowcount); } @@ -627,21 +612,22 @@ * @return a sequence of sequences from the result set, or an empty sequence when * no more data is available */ + @Override public PyObject fetchmany(int size) { - - if ((results == null) || (results.size() == 0)) { + if (results == null || results.size() == 0) { throw zxJDBC.makeException(zxJDBC.DatabaseError, "no results"); } PyObject res = new PyList(); - PyObject current = (PyObject) results.get(0); + PyObject current = results.get(0); if (size <= 0) { size = this.rowcount; } if (this.rownumber < this.rowcount) { - res = current.__getslice__(Py.newInteger(this.rownumber), Py.newInteger(this.rownumber + size), Py.One); + res = current.__getslice__(Py.newInteger(this.rownumber), + Py.newInteger(this.rownumber + size), Py.One); this.rownumber += size; } @@ -654,8 +640,8 @@ * @param value * @param mode 'relative' or 'absolute' */ + @Override public void scroll(int value, String mode) { - int pos; if ("relative".equals(mode)) { @@ -663,10 +649,11 @@ } else if ("absolute".equals(mode)) { pos = value; } else { - throw zxJDBC.makeException(zxJDBC.ProgrammingError, "invalid cursor scroll mode [" + mode + "]"); + throw zxJDBC.makeException(zxJDBC.ProgrammingError, "invalid cursor scroll mode [" + + mode + "]"); } - if ((pos >= 0) && (pos < this.rowcount)) { + if (pos >= 0 && pos < this.rowcount) { this.rownumber = pos; } else { throw zxJDBC.makeException(Py.IndexError, "cursor index [" + pos + "] out of range"); @@ -678,32 +665,30 @@ * * @return true if more sets exist, else None */ + @Override public PyObject nextset() { - PyObject next = Py.None; - if ((results != null) && (results.size() > 1)) { + if (results != null && results.size() > 1) { this.results.remove(0); this.descriptions.remove(0); - next = (PyObject) this.results.get(0); - this.description = (PyObject) this.descriptions.get(0); + next = this.results.get(0); + this.description = this.descriptions.get(0); this.rowcount = next.__len__(); this.rownumber = 0; } - return (next == Py.None) ? Py.None : Py.One; + return next == Py.None ? Py.None : Py.One; } /** * Remove the results. */ + @Override public void close() throws SQLException { - super.close(); - this.rownumber = -1; - this.results.clear(); } } @@ -720,7 +705,7 @@ /** * Field skipCols */ - protected Set skipCols; + protected Set<Integer> skipCols; /** * Field resultSet @@ -741,6 +726,7 @@ * at any one time. Since this is a dynamic iteration, it precludes * the addition of more than one result set. */ + @Override public void add(ResultSet resultSet) { add(resultSet, null); } @@ -752,14 +738,14 @@ * at any one time. Since this is a dynamic iteration, it precludes * the addition of more than one result set. */ - public void add(ResultSet resultSet, Set skipCols) { - + @Override + public void add(ResultSet resultSet, Set<Integer> skipCols) { if (this.resultSet != null) { throw zxJDBC.makeException(zxJDBC.getString("onlyOneResultSet")); } try { - if ((resultSet != null) && (resultSet.getMetaData() != null)) { + if (resultSet != null && resultSet.getMetaData() != null) { if (this.description == Py.None) { this.description = this.createDescription(resultSet.getMetaData()); } @@ -787,13 +773,16 @@ * @param procedure * @param params */ + @Override public void add(CallableStatement callableStatement, Procedure procedure, PyObject params) { - throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nocallprocsupport")); + throw zxJDBC.makeException(zxJDBC.NotSupportedError, + zxJDBC.getString("nocallprocsupport")); } /** * Iterate the remaining contents of the ResultSet and return. */ + @Override public PyObject fetchall() { return fetch(0, true); } @@ -801,6 +790,7 @@ /** * Iterate up to size rows remaining in the ResultSet and return. */ + @Override public PyObject fetchmany(int size) { return fetch(size, false); } @@ -812,7 +802,6 @@ * the set. */ private PyObject fetch(int size, boolean all) { - PyList res = new PyList(); if (this.resultSet == null) { @@ -822,14 +811,15 @@ try { all = (size < 0) ? true : all; - while (((size-- > 0) || all) && this.resultSet.next()) { + while ((size-- > 0 || all) && this.resultSet.next()) { PyTuple tuple = createResult(this.resultSet, this.skipCols, this.description); res.append(tuple); this.rowcount++; this.rownumber = this.resultSet.getRow(); } } catch (AbstractMethodError e) { - throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nodynamiccursors")); + throw zxJDBC.makeException(zxJDBC.NotSupportedError, + zxJDBC.getString("nodynamiccursors")); } catch (PyException e) { throw e; } catch (Throwable e) { @@ -842,6 +832,7 @@ /** * Always returns None. */ + @Override public PyObject nextset() { return Py.None; } @@ -852,12 +843,12 @@ * @param value * @param mode */ + @Override public void scroll(int value, String mode) { - try { int type = this.resultSet.getType(); - if ((type != ResultSet.TYPE_FORWARD_ONLY) || (value > 0)) { + if (type != ResultSet.TYPE_FORWARD_ONLY || value > 0) { if ("relative".equals(mode)) { if (value < 0) { value = Math.abs(this.rownumber + value); @@ -866,29 +857,33 @@ } } else if ("absolute".equals(mode)) { if (value < 0) { - throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + "] out of range"); + throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + + "] out of range"); } } else { - throw zxJDBC.makeException(zxJDBC.ProgrammingError, "invalid cursor scroll mode [" + mode + "]"); + throw zxJDBC.makeException(zxJDBC.ProgrammingError, + "invalid cursor scroll mode [" + mode + "]"); } if (value == 0) { this.resultSet.beforeFirst(); } else { if (!this.resultSet.absolute(value)) { - throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + "] out of range"); + throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + + "] out of range"); } } // since .rownumber is the *next* row, then the JDBC value suits us fine this.rownumber = this.resultSet.getRow(); } else { - String msg = "dynamic result set of type [" + type + "] does not support scrolling"; - + String msg = "dynamic result set of type [" + type + + "] does not support scrolling"; throw zxJDBC.makeException(zxJDBC.NotSupportedError, msg); } } catch (AbstractMethodError e) { - throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nodynamiccursors")); + throw zxJDBC.makeException(zxJDBC.NotSupportedError, + zxJDBC.getString("nodynamiccursors")); } catch (SQLException e) { throw zxJDBC.makeException(e); } catch (Throwable t) { @@ -899,8 +894,8 @@ /** * Close the underlying ResultSet. */ + @Override public void close() throws SQLException { - super.close(); if (this.resultSet == null) { Modified: trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -14,7 +14,6 @@ import java.util.Set; import org.python.core.Py; import org.python.core.PyBuiltinMethodSet; -import org.python.core.PyClass; import org.python.core.PyList; import org.python.core.PyObject; import org.python.core.PyString; @@ -86,7 +85,8 @@ * @param rsType * @param rsConcur */ - PyExtendedCursor(PyConnection connection, boolean dynamicFetch, PyObject rsType, PyObject rsConcur) { + PyExtendedCursor(PyConnection connection, boolean dynamicFetch, PyObject rsType, + PyObject rsConcur) { super(connection, dynamicFetch, rsType, rsConcur); } @@ -95,6 +95,7 @@ * * @return a string representation of the object. */ + @Override public String toString() { return "<PyExtendedCursor object instance at " + Py.id(this) + ">"; } @@ -105,7 +106,6 @@ * @param dict */ static public void classDictInit(PyObject dict) { - PyCursor.classDictInit(dict); dict.__setitem__("__version__", Py.newString("$Revision$").__getslice__(Py.newInteger(11), Py.newInteger(-2), null)); dict.__setitem__("tables", new ExtendedCursorFunc("tables", 100, 4, 4, "query for table information")); @@ -131,8 +131,8 @@ * @param name the name of the attribute of interest * @return the value for the attribute of the specified name */ + @Override public PyObject __findattr_ex__(String name) { - if ("__methods__".equals(name)) { return __methods__; } else if ("__members__".equals(name)) { @@ -153,7 +153,6 @@ * @param type */ protected void tables(PyObject qualifier, PyObject owner, PyObject table, PyObject type) { - clear(); String q = getMetaDataName(qualifier); @@ -197,7 +196,6 @@ * @param column */ protected void columns(PyObject qualifier, PyObject owner, PyObject table, PyObject column) { - clear(); String q = getMetaDataName(qualifier); @@ -220,7 +218,6 @@ * @param procedure */ protected void procedures(PyObject qualifier, PyObject owner, PyObject procedure) { - clear(); String q = getMetaDataName(qualifier); @@ -242,8 +239,8 @@ * @param procedure * @param column */ - protected void procedurecolumns(PyObject qualifier, PyObject owner, PyObject procedure, PyObject column) { - + protected void procedurecolumns(PyObject qualifier, PyObject owner, PyObject procedure, + PyObject column) { clear(); String q = getMetaDataName(qualifier); @@ -296,8 +293,9 @@ * @param foreignOwner * @param foreignTable */ - protected void foreignkeys(PyObject primaryQualifier, PyObject primaryOwner, PyObject primaryTable, PyObject foreignQualifier, PyObject foreignOwner, PyObject foreignTable) { - + protected void foreignkeys(PyObject primaryQualifier, PyObject primaryOwner, + PyObject primaryTable, PyObject foreignQualifier, + PyObject foreignOwner, PyObject foreignTable) { clear(); String pq = getMetaDataName(primaryQualifier); @@ -324,14 +322,13 @@ * @param unique * @param accuracy */ - protected void statistics(PyObject qualifier, PyObject owner, PyObject table, PyObject unique, PyObject accuracy) { - + protected void statistics(PyObject qualifier, PyObject owner, PyObject table, PyObject unique, + PyObject accuracy) { clear(); - Set skipCols = new HashSet(); + Set<Integer> skipCols = new HashSet<Integer>(); + skipCols.add(12); - skipCols.add(new Integer(12)); - String q = getMetaDataName(qualifier); String o = getMetaDataName(owner); String t = getMetaDataName(table); @@ -351,14 +348,12 @@ * @param type data type for which to provide information */ protected void typeinfo(PyObject type) { - clear(); - Set skipCols = new HashSet(); + Set<Integer> skipCols = new HashSet<Integer>(); + skipCols.add(16); + skipCols.add(17); - skipCols.add(new Integer(16)); - skipCols.add(new Integer(17)); - try { this.fetch.add(getMetaData().getTypeInfo(), skipCols); } catch (SQLException e) { @@ -384,7 +379,6 @@ * Gets a description of possible table types. */ protected void tabletypeinfo() { - clear(); try { @@ -403,7 +397,6 @@ * @param table */ protected void bestrow(PyObject qualifier, PyObject owner, PyObject table) { - clear(); String c = getMetaDataName(qualifier); @@ -428,7 +421,6 @@ * @param table a table name */ protected void versioncolumns(PyObject qualifier, PyObject owner, PyObject table) { - clear(); String q = getMetaDataName(qualifier); @@ -449,7 +441,6 @@ * @return String */ protected String getMetaDataName(PyObject name) { - if (name == Py.None) { return null; } @@ -481,20 +472,17 @@ super(name, index, minargs, maxargs, doc, PyExtendedCursor.class); } + @Override public PyObject __call__() { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 107: cursor.typeinfo(Py.None); - return Py.None; case 108: cursor.tabletypeinfo(); - return Py.None; default : @@ -502,15 +490,13 @@ } } + @Override public PyObject __call__(PyObject arga) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 107: cursor.typeinfo(arga); - return Py.None; default : @@ -518,80 +504,68 @@ } } + @Override public PyObject __call__(PyObject arga, PyObject argb, PyObject argc) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 102: cursor.primarykeys(arga, argb, argc); - return Py.None; case 104: cursor.procedures(arga, argb, argc); - return Py.None; case 109: cursor.bestrow(arga, argb, argc); - return Py.None; case 110: cursor.versioncolumns(arga, argb, argc); - return Py.None; - default : + default: throw info.unexpectedCall(3, false); } } + @Override public PyObject fancyCall(PyObject[] args) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 103: cursor.foreignkeys(args[0], args[1], args[2], args[3], args[4], args[5]); - return Py.None; case 106: cursor.statistics(args[0], args[1], args[2], args[3], args[4]); - return Py.None; - default : + default: throw info.unexpectedCall(args.length, true); } } + @Override public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3, PyObject arg4) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 100: cursor.tables(arg1, arg2, arg3, arg4); - return Py.None; case 101: cursor.columns(arg1, arg2, arg3, arg4); - return Py.None; case 105: cursor.procedurecolumns(arg1, arg2, arg3, arg4); - return Py.None; - default : + default: throw info.unexpectedCall(4, false); } } Modified: trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -22,24 +22,18 @@ */ public class PyArgParser extends Object { - /** - * Field keywords - */ - protected Map keywords; + /** Field keywords. */ + protected Map<String, PyObject> keywords; - /** - * Field arguments - */ + /** Field arguments. */ protected PyObject[] arguments; /** * Construct a parser with the arguments and keywords. */ public PyArgParser(PyObject[] args, String[] kws) { - - this.keywords = new HashMap(); - this.arguments = null; - + keywords = new HashMap<String, PyObject>(); + arguments = null; parse(args, kws); } @@ -50,33 +44,31 @@ * @param kws */ protected void parse(PyObject[] args, String[] kws) { - // walk backwards through the kws and build the map int largs = args.length; if (kws != null) { - for (int i = kws.length - 1; i >= 0; i--) { - keywords.put(kws[i], args[--largs]); + for (String kw: kws) { + keywords.put(kw, args[--largs]); } } - this.arguments = new PyObject[largs]; - - System.arraycopy(args, 0, this.arguments, 0, largs); + arguments = new PyObject[largs]; + System.arraycopy(args, 0, arguments, 0, largs); } /** * How many keywords? */ public int numKw() { - return this.keywords.keySet().size(); + return keywords.keySet().size(); } /** * Does the keyword exist? */ public boolean hasKw(String kw) { - return this.keywords.containsKey(kw); + return keywords.containsKey(kw); } /** @@ -84,12 +76,11 @@ * not exist. */ public PyObject kw(String kw) { - if (!hasKw(kw)) { throw Py.KeyError(kw); } - return (PyObject) this.keywords.get(kw); + return keywords.get(kw); } /** @@ -97,35 +88,33 @@ * not exist. */ public PyObject kw(String kw, PyObject def) { - if (!hasKw(kw)) { return def; } - return (PyObject) this.keywords.get(kw); + return keywords.get(kw); } /** * Get the array of keywords. */ public String[] kws() { - return (String[]) this.keywords.keySet().toArray(new String[0]); + return keywords.keySet().toArray(new String[0]); } /** * Get the number of arguments. */ public int numArg() { - return this.arguments.length; + return arguments.length; } /** * Return the argument at the given index, raise an IndexError if out of range. */ public PyObject arg(int index) { - - if ((index >= 0) && (index <= this.arguments.length - 1)) { - return this.arguments[index]; + if (index >= 0 && index <= arguments.length - 1) { + return arguments[index]; } throw Py.IndexError("index out of range"); @@ -135,9 +124,8 @@ * Return the argument at the given index, or the default if the index is out of range. */ public PyObject arg(int index, PyObject def) { - - if ((index >= 0) && (index <= this.arguments.length - 1)) { - return this.arguments[index]; + if (index >= 0 && index <= arguments.length - 1) { + return arguments[index]; } return def; Modified: trunk/jython/src/com/ziclix/python/sql/util/Queue.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/util/Queue.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/util/Queue.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -28,7 +28,7 @@ /** * Field queue */ - protected LinkedList queue; + protected LinkedList<Object> queue; /** * Field capacity, threshold @@ -49,7 +49,7 @@ this.closed = false; this.capacity = capacity; - this.queue = new LinkedList(); + this.queue = new LinkedList<Object>(); this.threshold = (int) (this.capacity * 0.75f); } @@ -57,7 +57,6 @@ * Enqueue an object and notify all waiting Threads. */ public synchronized void enqueue(Object element) throws InterruptedException { - if (closed) { throw new QueueClosedException(); } @@ -81,7 +80,6 @@ * Blocks until an object is dequeued or the queue is closed. */ public synchronized Object dequeue() throws InterruptedException { - while (this.queue.size() <= 0) { this.wait(); @@ -104,9 +102,7 @@ * Close the queue and notify all waiting Threads. */ public synchronized void close() { - this.closed = true; - this.notifyAll(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |