Session.java

Index Score
org.hsqldb
HSQL Database Engine

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
DECL_COMMENTSComments in declarations
RETURNSNumber of return points from functions
LINE_COMMENTNumber of line comments
BLOCKSNumber of blocks
SIZESize of the file in bytes
EXITSProcedure exits
CYCLOMATICCyclomatic complexity
LINESNumber of lines in the source file
INTERFACE_COMPLEXITYInterface complexity
FUNCTIONSNumber of function declarations
ELOCEffective lines of code
LOCLines of code
COMMENTSComment lines
LOGICAL_LINESNumber of statements
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
UNIQUE_OPERANDSNumber of unique operands
WHITESPACENumber of whitespace lines
PROGRAM_VOCABHalstead program vocabulary
OPERANDSNumber of operands
JAVA0031JAVA0031 Case statement not properly closed
DOC_COMMENTNumber of javadoc comment lines
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0166JAVA0166 Generic exception caught
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0170JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0032JAVA0032 Switch statement missing default
PARAMSNumber of formal parameter declarations
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0034JAVA0034 Missing braces in if statement
JAVA0160JAVA0160 Method does not throw specified exception
JAVA0008JAVA0008 Empty catch block
JAVA0007JAVA0007 Should not declare public field
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0116JAVA0116 Missing javadoc: field 'field'
JAVA0040JAVA0040 Switch statement contains N cases (maximum: M)
COMPARISONSNumber of comparison operators
UNIQUE_OPERATORSNumber of unique operators
EXEC_COMMENTSComments in executable code
JAVA0143JAVA0143 Synchronized method
BLOCK_COMMENTNumber of block comment lines
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0285JAVA0285 Dereference of potentially null variable
JAVA0112JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0145JAVA0145 Tab character used in source file
/* Copyright (c) 1995-2000, The Hypersonic SQL Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the Hypersonic SQL Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP, * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals * on behalf of the Hypersonic SQL Group. * * * For work added by the HSQL Development Group: * * Copyright (c) 2001-2007, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.hsqldb; import java.io.DataInput; import java.sql.Date; import java.sql.Timestamp; import org.hsqldb.HsqlNameManager.HsqlName; import org.hsqldb.jdbc.jdbcConnection; import org.hsqldb.lib.ArrayUtil; import org.hsqldb.lib.HashMappedList; import org.hsqldb.lib.HsqlArrayList; import org.hsqldb.lib.SimpleLog; import org.hsqldb.lib.java.JavaSystem; import org.hsqldb.navigator.ClientRowSetNavigator; import org.hsqldb.navigator.RowSetNavigator; import org.hsqldb.result.Result; import org.hsqldb.result.ResultConstants; import org.hsqldb.result.ResultLob; import org.hsqldb.result.ResultMetaData; import org.hsqldb.store.ValuePool; import org.hsqldb.types.BlobData; import org.hsqldb.types.ClobData; import org.hsqldb.types.TimeData; import org.hsqldb.rights.User; import org.hsqldb.rights.Grantee; // fredt@users 20020320 - doc 1.7.0 - update // fredt@users 20020315 - patch 1.7.0 - switch for scripting // fredt@users 20020130 - patch 476694 by velichko - transaction savepoints // additions in different parts to support savepoint transactions // fredt@users 20020910 - patch 1.7.1 by fredt - database readonly enforcement // fredt@users 20020912 - patch 1.7.1 by fredt - permanent internal connection // boucherb@users 20030512 - patch 1.7.2 - compiled statements // - session becomes execution hub // boucherb@users 20050510 - patch 1.7.2 - generalized Result packet passing // based command execution // - batch execution handling // fredt@users 20030628 - patch 1.7.2 - session proxy support // fredt@users 20040509 - patch 1.7.2 - SQL conformance for CURRENT_TIMESTAMP and other datetime functions /** * Implementation of a user session with the database. In 1.7.2, Session * becomes the public interface to an HSQLDB database, accessed locally or * remotely via SessionInterface. * * When a Session is closed, all references to internal engine objects are * set to null. But the session id and scripting mode may still be used for * scripting * * New class based on original Hypersonic code.<p> * Extensively rewritten and extended in successive versions of HSQLDB. * * @author Thomas Mueller (Hypersonic SQL Group) * @version 1.8.0 * @since 1.7.0 */ public class Session implements SessionInterface { // private volatile boolean isAutoCommit; private volatile boolean isReadOnly; private volatile boolean isClosed; // public Database database; private User user; // transaction support int isolationMode = SessionInterface.TX_READ_COMMITTED; int actionIndex; long actionTimestamp; long transactionTimestamp; HsqlArrayList rowActionList; boolean rollbackNestedTransaction; HashMappedList savepoints; // private int currentMaxRows; private int sessionMaxRows; private Number lastIdentity = ValuePool.getInt(0); private final long sessionId; private boolean script; private CommandParser parser; // private jdbcConnection intConnection; // schema public HsqlName currentSchema; public HsqlName loggedSchema; private HsqlName oldSchema; // query processing boolean isProcessingScript; boolean isProcessingLog; public CompiledStatementExecutor compiledStatementExecutor; boolean isNetwork; int resultMaxMemoryRows; public SessionData sessionData; /** @todo fredt - clarify in which circumstances Session has to disconnect */ Session getSession() { return this; } /** * Constructs a new Session object. * * @param db the database to which this represents a connection * @param user the initial user * @param autocommit the initial autocommit value * @param readonly the initial readonly value * @param id the session identifier, as known to the database */ Session(Database db, User user, boolean autocommit, boolean readonly, long id) { sessionId = id; database = db; this.user = user; rowActionList = new HsqlArrayList(true); savepoints = new HashMappedList(4); isAutoCommit = autocommit; isReadOnly = readonly; compiledStatementExecutor = new CompiledStatementExecutor(this); parser = new CommandParser(this, new Tokenizer()); resultMaxMemoryRows = database.getResultMaxMemoryRows(); resetSchema(); sessionData = new SessionData(database, this); } void resetSchema() { HsqlName initialSchema = user.getInitialSchema(); currentSchema = initialSchema == null ? database.schemaManager.getDefaultSchemaHsqlName() : initialSchema; } /** * Retrieves the session identifier for this Session. * * @return the session identifier for this Session */ public long getId() { return sessionId; } /** * Closes this Session. */ public void close() { if (isClosed) { return; } synchronized (database) { // test again inside block if (isClosed) { return; } database.sessionManager.removeSession(this); rollback(); try { database.logger.writeToLog(this, Token.T_DISCONNECT); } catch (HsqlException e) {} sessionData.clearIndexRoots(); sessionData.clearIndexRootsKeep(); sessionData.closeAllNavigators(); sessionData.closeResultCache(); database.compiledStatementManager.removeSession(sessionId); database.closeIfLast(); database = null; user = null; rowActionList = null; savepoints = null; intConnection = null; compiledStatementExecutor = null; lastIdentity = null; isClosed = true; } } /** * Retrieves whether this Session is closed. * * @return true if this Session is closed */ public boolean isClosed() { return isClosed; } public void setIsolation(int level) throws HsqlException { isolationMode = level; } public int getIsolation() throws HsqlException { return isolationMode; } /** * Setter for iLastIdentity attribute. * * @param i the new value */ void setLastIdentity(Number i) { lastIdentity = i; } /** * Getter for iLastIdentity attribute. * * @return the current value */ public Object getLastIdentity() { return lastIdentity; } /** * Retrieves the Database instance to which this * Session represents a connection. * * @return the Database object to which this Session is connected */ public Database getDatabase() { return database; } /** * Retrieves the name, as known to the database, of the * user currently controlling this Session. * * @return the name of the user currently connected within this Session */ public String getUsername() { return user.getName(); } /** * Retrieves the User object representing the user currently controlling * this Session. * * @return this Session's User object */ public User getUser() { return user; } public User getGrantee() { return user; } /** * Sets this Session's User object to the one specified by the * user argument. * * @param user the new User object for this session */ void setUser(User user) { this.user = user; } int getMaxRows() { return currentMaxRows; } public int getSQLMaxRows() { return sessionMaxRows; } /** * The SQL command SET MAXROWS n will override the Statement.setMaxRows(n) * until SET MAXROWS 0 is issued. * * NB this is dedicated to the SET MAXROWS sql statement and should not * otherwise be called. (fredt@users) */ void setSQLMaxRows(int rows) { currentMaxRows = sessionMaxRows = rows; } /** * Checks whether this Session's current User has the privileges of * the ADMIN role. * * @throws HsqlException if this Session's User does not have the * privileges of the ADMIN role. */ void checkAdmin() throws HsqlException { user.checkAdmin(); } /** * This is used for reading - writing to existing tables. * @throws HsqlException */ void checkReadWrite() throws HsqlException { if (isReadOnly) { throw Trace.error(Trace.DATABASE_IS_READONLY); } } /** * This is used for creating new database objects such as tables. * @throws HsqlException */ void checkDDLWrite() throws HsqlException { if (database.isFilesReadOnly()) { throw Trace.error(Trace.DATABASE_IS_READONLY); } checkReadWrite(); } /** * Adds a delete ation to the action list. * * @param table the table of the row * @param row the deleted row * @throws HsqlException */ void addDeleteAction(Table table, Row row) throws HsqlException { Transaction t = new Transaction(true, table, row, actionTimestamp); rowActionList.add(t); database.txManager.addTransaction(this, t); } /** * Adds a row insert action to the action list. * * @param table the table into which the row was inserted * @param row the inserted row * @throws HsqlException */ void addInsertAction(Table table, Row row) throws HsqlException { Transaction t = new Transaction(false, table, row, actionTimestamp); rowActionList.add(t); database.txManager.addTransaction(this, t); } /** * Setter for the autocommit attribute. * * @param autocommit the new value * @throws HsqlException */ public void setAutoCommit(boolean autocommit) { if (isClosed) { return; } synchronized (database) { if (autocommit != isAutoCommit) { commit(); isAutoCommit = autocommit; } } } public void beginAction() throws HsqlException { actionIndex = rowActionList.size(); } public void endAction(Result r) throws HsqlException { if (r.isError()) { database.txManager.rollbackNested(this); } if (isAutoCommit) { commit(); } } public void startPhasedTransaction() throws HsqlException {} public void prepareCommit() throws HsqlException {} /** * Commits any uncommited transaction this Session may have open * * @throws HsqlException */ public void commit() { if (isClosed) { return; } synchronized (database) { if (!rowActionList.isEmpty()) { try { database.logger.writeCommitStatement(this); } catch (HsqlException e) {} } database.txManager.commit(this); sessionData.clearIndexRoots(); } } /** * Rolls back any uncommited transaction this Session may have open. * * @throws HsqlException */ public void rollback() { if (isClosed) { return; } synchronized (database) { if (rowActionList.size() != 0) { try { database.logger.writeToLog(this, Token.T_ROLLBACK); } catch (HsqlException e) {} } database.txManager.rollback(this); sessionData.clearIndexRoots(); } } /** * No-op in this implementation */ public void resetSession() throws HsqlException { throw new HsqlException("", "", 0); } /** * Registers a transaction SAVEPOINT. A new SAVEPOINT with the * name of an existing one replaces the old SAVEPOINT. * * @param name name of the savepoint * @throws HsqlException if there is no current transaction */ public void savepoint(String name) throws HsqlException { savepoints.remove(name); savepoints.add(name, ValuePool.getInt(rowActionList.size())); try { database.logger.writeToLog(this, DatabaseScript.getSavepointDDL(name)); } catch (HsqlException e) {} } /** * Performs a partial transaction ROLLBACK to savepoint. * * @param name name of savepoint * @throws HsqlException */ public void rollbackToSavepoint(String name) throws HsqlException { if (isClosed) { return; } try { database.logger.writeToLog( this, DatabaseScript.getSavepointRollbackDDL(name)); } catch (HsqlException e) {} database.txManager.rollbackSavepoint(this, name); } /** * Releases a savepoint * * @param name name of savepoint * @throws HsqlException if name does not correspond to a savepoint */ public void releaseSavepoint(String name) throws HsqlException { // remove this and all later savepoints int index = savepoints.getIndex(name); Trace.check(index >= 0, Trace.SAVEPOINT_NOT_FOUND, name); while (savepoints.size() > index) { savepoints.remove(savepoints.size() - 1); } } /** * Setter for readonly attribute. * * @param readonly the new value */ public void setReadOnly(boolean readonly) throws HsqlException { if (!readonly && database.databaseReadOnly) { throw Trace.error(Trace.DATABASE_IS_READONLY); } isReadOnly = readonly; } /** * Getter for readonly attribute. * * @return the current value */ public boolean isReadOnly() { return isReadOnly; } /** * Getter for autoCommit attribute. * * @return the current value */ public boolean isAutoCommit() { return isAutoCommit; } /** * A switch to set scripting on the basis of type of statement executed. * Afterwards the method reponsible for logging uses * isScripting() to determine if logging is required for the executed * statement. (fredt@users) * * @param script The new scripting value */ void setScripting(boolean script) { this.script = script; } /** * Getter for scripting attribute. * * @return scripting for the last statement. */ boolean isScripting() { return script; } /** * Retrieves an internal Connection object equivalent to the one * that created this Session. * * @return internal connection. */ jdbcConnection getInternalConnection() throws HsqlException { if (intConnection == null) { intConnection = new jdbcConnection(this); } return intConnection; } // boucherb@users 20020810 metadata 1.7.2 //---------------------------------------------------------------- private final long connectTime = System.currentTimeMillis(); // more effecient for MetaData concerns than checkAdmin /** * Getter for admin attribute. * * @ return the current value */ public boolean isAdmin() { return user.isAdmin(); } /** * Getter for connectTime attribute. * * @return the value */ public long getConnectTime() { return connectTime; } /** * Getter for transactionSise attribute. * * @return the current value */ public int getTransactionSize() { return rowActionList.size(); } CompiledStatement compileStatement(String sql) throws HsqlException { parser.reset(sql); CompiledStatement cs = parser.compileStatement(currentSchema); cs.sql = sql; return cs; } /** * Executes the command encapsulated by the cmd argument. * * @param cmd the command to execute * @return the result of executing the command */ public Result execute(Result cmd) { try { if (isClosed) { Trace.check(false, Trace.ACCESS_IS_DENIED, Trace.getMessage(Trace.Session_execute)); } } catch (Throwable t) { return Result.newErrorResult(t, null); } synchronized (database) { int type = cmd.getType(); if (sessionMaxRows == 0) { currentMaxRows = cmd.getUpdateCount(); } // we simply get the next system change number - no matter what type of query actionTimestamp = database.txManager.nextActionTimestamp(); JavaSystem.gc(); switch (type) { case ResultConstants.LARGE_OBJECT_OP : { return performLOBOperation((ResultLob) cmd); } case ResultConstants.EXECUTE : { Result result = executeCompiledStatement(cmd); result = performPostExecute(cmd, result); return result; } case ResultConstants.BATCHEXECUTE : { Result result = executeCompiledBatchStatement(cmd); result = performPostExecute(cmd, result); return result; } case ResultConstants.EXECDIRECT : { Result result = executeDirectStatement(cmd.getMainString()); result = performPostExecute(cmd, result); return result; } case ResultConstants.BATCHEXECDIRECT : { Result result = executeDirectBatchStatement(cmd); result = performPostExecute(cmd, result); return result; } case ResultConstants.PREPARE : { CompiledStatement cs; try { cs = database.compiledStatementManager.compile(this, cmd.getMainString()); } catch (Throwable t) { return Result.newErrorResult(t, cmd.getMainString()); } cs.setGeneratedColumnInfo( cmd.getGeneratedResultType(), cmd.getGeneratedResultMetaData()); ResultMetaData rmd = cs.getResultMetaData(); ResultMetaData pmd = cs.getParametersMetaData(); return Result.newPrepareResponse(cs.id, cs.type, rmd, pmd); } case ResultConstants.CLOSE_RESULT : { closeNavigator(cmd.getResultId()); return Result.updateZeroResult; } case ResultConstants.FREESTMT : { database.compiledStatementManager.freeStatement( cmd.getStatementID(), sessionId, false); return Result.updateZeroResult; } case ResultConstants.GETSESSIONATTR : { return getAttributes(); } case ResultConstants.SETSESSIONATTR : { return setAttributes(cmd); } case ResultConstants.ENDTRAN : { switch (cmd.getEndTranType()) { case ResultConstants.COMMIT : commit(); break; case ResultConstants.ROLLBACK : rollback(); break; case ResultConstants.SAVEPOINT_NAME_RELEASE : try { String name = cmd.getMainString(); releaseSavepoint(name); } catch (Throwable t) { return Result.newErrorResult(t, null); } break; case ResultConstants.SAVEPOINT_NAME_ROLLBACK : try { rollbackToSavepoint(cmd.getMainString()); } catch (Throwable t) { return Result.newErrorResult(t, null); } break; // not yet // case ResultConstants.COMMIT_AND_CHAIN : // case ResultConstants.ROLLBACK_AND_CHAIN : } return Result.updateZeroResult; } case ResultConstants.SETCONNECTATTR : { switch (cmd.getConnectionAttrType()) { case ResultConstants.SQL_ATTR_SAVEPOINT_NAME : try { savepoint(cmd.getMainString()); } catch (Throwable t) { return Result.newErrorResult(t, null); } // case ResultConstants.SQL_ATTR_AUTO_IPD // - always true // default: throw - case never happens } return Result.updateZeroResult; } case ResultConstants.REQUESTDATA : { return sessionData.getDataResultSlice(cmd.getResultId(), cmd.getUpdateCount(), cmd.getFetchSize()); } case ResultConstants.DISCONNECT : { close(); return Result.updateZeroResult; } default : { return Result.newErrorResult( Trace.runtimeError( Trace.UNSUPPORTED_INTERNAL_OPERATION, "Session.execute()"), null); } } } } private Result performPostExecute(Result command, Result result) { try { if (database != null) { database.schemaManager.logSequences(this, database.logger); if (isAutoCommit) { database.logger.synchLog(); } } if (result.isData()) { sessionData.getDataResultHead(command, result, isNetwork); } return result; } catch (Exception e) { return Result.newErrorResult(e, null); } finally { if (database != null && database.logger.needsCheckpoint()) { try { database.logger.checkpoint(false); } catch (HsqlException e) { database.logger.appLog.logContext( SimpleLog.LOG_ERROR, "checkpoint did not complete"); } } } } public ClientRowSetNavigator getRows(long navigatorId, int offset, int blockSize) throws HsqlException { return sessionData.getRowSetSlice(navigatorId, offset, blockSize); } public void closeNavigator(long id) { sessionData.closeNavigator(id); } /* public Result sqlExecuteDirectNoPreChecks(String sql) { synchronized (database) { return dbCommandInterpreter.execute(sql); } } */ public Result executeDirectStatement(String sql) { synchronized (database) { return parser.execute(sql); } } Result executeCompiledStatement(CompiledStatement cs, Object[] pvals) { Result r; try { beginAction(); } catch (HsqlException e) { return Result.newErrorResult(e, null); } // tempActionHistory.add("sql execute " + cs.sql + " " + actionTimestamp + " " + rowActionList.size()); r = compiledStatementExecutor.execute(cs, pvals); // tempActionHistory.add("sql execute end " + actionTimestamp + " " + rowActionList.size()); try { endAction(r); } catch (HsqlException e) { return Result.newErrorResult(e, null); } return r; } private Result executeCompiledBatchStatement(Result cmd) { int csid; CompiledStatement cs; int[] updateCounts; int count; csid = cmd.getStatementID(); cs = database.compiledStatementManager.getStatement(this, csid); if (cs == null) { // invalid sql has been removed already return Result.newErrorResult( Trace.runtimeError(Trace.INVALID_PREPARED_STATEMENT, null), null); } count = 0; RowSetNavigator nav = cmd.initialiseNavigator(); updateCounts = new int[nav.getSize()]; Result generatedResult = null; if (cs.hasGeneratedColumns()) { generatedResult = Result.newDataResult(cs.generatedResultMetaData); } Result error = null; while (nav.hasNext()) { Object[] pvals = (Object[]) nav.getNext(); Result in = executeCompiledStatement(cs, pvals); // On the client side, iterate over the vals and throw // a BatchUpdateException if a batch status value of // esultConstants.EXECUTE_FAILED is encountered in the result if (in.isUpdateCount()) { if (cs.hasGeneratedColumns()) { Object generatedRow = in.getNavigator().getNext(); generatedResult.getNavigator().add(generatedRow); } updateCounts[count++] = in.getUpdateCount(); } else if (in.isData()) { // FIXME: we don't have what it takes yet // to differentiate between things like // stored procedure calls to methods with // void return type and select statements with // a single row/column containg null updateCounts[count++] = ResultConstants.SUCCESS_NO_INFO; } else if (in.isError()) { updateCounts = ArrayUtil.arraySlice(updateCounts, 0, count); error = in; break; } else { throw Trace.runtimeError(Trace.UNSUPPORTED_INTERNAL_OPERATION, "Session"); } } return Result.newBatchedExecuteResponse(updateCounts, generatedResult, error); } private Result executeDirectBatchStatement(Result cmd) { int[] updateCounts; int count; count = 0; RowSetNavigator nav = cmd.initialiseNavigator(); updateCounts = new int[nav.getSize()]; Result error = null; while (nav.hasNext()) { Result in; Object[] data = (Object[]) nav.getNext(); String sql = (String) data[0]; try { in = executeDirectStatement(sql); } catch (Throwable t) { in = Result.newErrorResult(t, null); // if (t instanceof OutOfMemoryError) { // System.gc(); // } // "in" alread equals "err" // maybe test for OOME and do a gc() ? // t.printStackTrace(); } if (in.isUpdateCount()) { updateCounts[count++] = in.getUpdateCount(); } else if (in.isData()) { // FIXME: we don't have what it takes yet // to differentiate between things like // stored procedure calls to methods with // void return type and select statements with // a single row/column containg null updateCounts[count++] = ResultConstants.SUCCESS_NO_INFO; } else if (in.isError()) { updateCounts = ArrayUtil.arraySlice(updateCounts, 0, count); error = in; break; } else { throw Trace.runtimeError(Trace.UNSUPPORTED_INTERNAL_OPERATION, "Session"); } } return Result.newBatchedExecuteResponse(updateCounts, null, error); } /** * Retrieves the result of executing the prepared statement whose csid * and parameter values/types are encapsulated by the cmd argument. * * @return the result of executing the statement */ private Result executeCompiledStatement(Result cmd) { int csid = cmd.getStatementID(); CompiledStatement cs = database.compiledStatementManager.getStatement(this, csid); if (cs == null) { // invalid sql has been removed already return Result.newErrorResult( Trace.runtimeError(Trace.INVALID_PREPARED_STATEMENT, null), null); } Object[] pvals = cmd.getParameterData(); return executeCompiledStatement(cs, pvals); } // session DATETIME functions long currentDateTimeSCN; long currentMillis; private Date currentDate; private TimeData currentTime; private Timestamp currentTimestamp; /** * Returns the current date, unchanged for the duration of the current * execution unit (statement).<p> * * SQL standards require that CURRENT_DATE, CURRENT_TIME and * CURRENT_TIMESTAMP are all evaluated at the same point of * time in the duration of each SQL statement, no matter how long the * SQL statement takes to complete.<p> * * When this method or a corresponding method for CURRENT_TIME or * CURRENT_TIMESTAMP is first called in the scope of a system change * number, currentMillis is set to the current system time. All further * CURRENT_XXXX calls in this scope will use this millisecond value. * (fredt@users) */ public Date getCurrentDate() { if (currentDateTimeSCN != actionTimestamp) { currentDateTimeSCN = actionTimestamp; currentMillis = System.currentTimeMillis(); currentDate = HsqlDateTime.getCurrentDate(currentMillis); currentTime = null; currentTimestamp = null; } else if (currentDate == null) { currentDate = HsqlDateTime.getCurrentDate(currentMillis); } return currentDate; } /** * Returns the current time, unchanged for the duration of the current * execution unit (statement) */ TimeData getCurrentTime() { if (currentDateTimeSCN != actionTimestamp) { currentDateTimeSCN = actionTimestamp; currentMillis = System.currentTimeMillis(); currentDate = null; currentTime = new TimeData(HsqlDateTime.getNormalisedTime(currentMillis)); currentTimestamp = null; } else if (currentTime == null) { currentTime = new TimeData(HsqlDateTime.getNormalisedTime(currentMillis)); } return currentTime; } /** * Returns the current timestamp, unchanged for the duration of the current * execution unit (statement) */ Timestamp getCurrentTimestamp() { if (currentDateTimeSCN != actionTimestamp) { currentDateTimeSCN = actionTimestamp; currentMillis = System.currentTimeMillis(); currentDate = null; currentTime = null; currentTimestamp = HsqlDateTime.getTimestamp(currentMillis); } else if (currentTimestamp == null) { currentTimestamp = HsqlDateTime.getTimestamp(currentMillis); } return currentTimestamp; } Result getAttributes() { Result r = Result.newSessionAttributesResult(); Object[] data = new Object[] { database.getURI(), getUsername(), ValuePool.getLong(sessionId), ValuePool.getInt(isolationMode), ValuePool.getBoolean(isAutoCommit), ValuePool.getBoolean(database.databaseReadOnly), ValuePool.getBoolean(isReadOnly) }; r.setSessionAttributes(data); return r; } Result setAttributes(Result r) { Object[] row = r.getSessionAttributes(); for (int i = 0; i < row.length; i++) { Object value = row[i]; if (value == null) { continue; } try { switch (i) { case SessionInterface.INFO_AUTOCOMMIT : { this.setAutoCommit(((Boolean) value).booleanValue()); break; } case SessionInterface.INFO_CONNECTION_READONLY : this.setReadOnly(((Boolean) value).booleanValue()); break; } } catch (HsqlException e) { return Result.newErrorResult(e, null); } } return Result.updateZeroResult; } Result performLOBOperation(ResultLob cmd) { long id = cmd.getLobID(); int operation = cmd.getSubType(); switch (operation) { case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : return ResultLob.newLobCreateBlobResponse(id); case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : return ResultLob.newLobCreateClobResponse(id); } Object lob = database.lobManager.getLob(id); if (lob == null) { return Result.newErrorResult( Trace.error(Trace.BLOB_IS_NO_LONGER_VALID), null); } switch (operation) { case ResultLob.LobResultTypes.REQUEST_OPEN : case ResultLob.LobResultTypes.REQUEST_CLOSE : { throw Trace.runtimeError(Trace.UNSUPPORTED_INTERNAL_OPERATION, "Session"); } case ResultLob.LobResultTypes.REQUEST_GET_BYTES : { try { byte[] bytes = ((BlobData) lob).getBytes(cmd.getOffset(), (int) cmd.getBlockLength()); return ResultLob.newLobGetBytesResponse(id, cmd.getOffset(), bytes); } catch (HsqlException e) { return Result.newErrorResult(e, "blob operation"); } } case ResultLob.LobResultTypes.REQUEST_SET_BYTES : { try { ((BlobData) lob).setBytes(cmd.getOffset(), cmd.getByteArray()); return ResultLob.newLobSetBytesResponse(id); } catch (HsqlException e) { return Result.newErrorResult(e, null); } } case ResultLob.LobResultTypes.REQUEST_GET_CHARS : { try { char[] chars = ((ClobData) lob).getChars(cmd.getOffset(), (int) cmd.getBlockLength()); return ResultLob.newLobGetCharsResponse(id, cmd.getOffset(), chars); } catch (HsqlException e) { return Result.newErrorResult(e, "blob operation"); } } case ResultLob.LobResultTypes.REQUEST_SET_CHARS : { try { char[] chars = cmd.getCharArray(); ((ClobData) lob).setChars(cmd.getOffset(), chars, 0, chars.length); return ResultLob.newLobSetCharsResponse(id); } catch (HsqlException e) { return Result.newErrorResult(e, null); } } case ResultLob.LobResultTypes.REQUEST_GET_BYTE_PATTERN_POSITION : case ResultLob.LobResultTypes.REQUEST_GET_CHAR_PATTERN_POSITION : { throw Trace.runtimeError(Trace.UNSUPPORTED_INTERNAL_OPERATION, "Session"); } default : { throw Trace.runtimeError(Trace.UNSUPPORTED_INTERNAL_OPERATION, "Session"); } } } // DatabaseMetaData.getURL should work as specified for // internal connections too. public String getInternalConnectionURL() { return DatabaseURL.S_URL_PREFIX + database.getURI(); } boolean isProcessingScript() { return isProcessingScript; } boolean isProcessingLog() { return isProcessingLog; } // schema processing boolean isSchemaDefintion() { return oldSchema != null; } void startSchemaDefinition(String schema) throws HsqlException { if (isProcessingScript) { setSchema(schema); return; } oldSchema = currentSchema; setSchema(schema); } void endSchemaDefinition() throws HsqlException { if (oldSchema == null) { return; } currentSchema = oldSchema; oldSchema = null; database.logger.writeToLog(this, DatabaseScript.getSetSchemaDDL(database, currentSchema)); } // schema object methods public void setSchema(String schema) throws HsqlException { currentSchema = database.schemaManager.getSchemaHsqlName(schema); } /** * If schemaName is null, return the current schema name, else return * the HsqlName object for the schema. If schemaName does not exist, * throw. */ HsqlName getSchemaHsqlName(String name) throws HsqlException { return name == null ? currentSchema : database.schemaManager.getSchemaHsqlName(name); } /** * Same as above, but return string */ public String getSchemaName(String name) throws HsqlException { return name == null ? currentSchema.name : database.schemaManager.getSchemaName(name); } public HsqlName getCurrentSchemaHsqlName() { return currentSchema; } // session tables Table[] transitionTables = new Table[0]; public void setSessionTables(Table[] tables) { transitionTables = tables; } public Table findSessionTable(String name) { for (int i = 0; i < transitionTables.length; i++) { if (name.equals(transitionTables[i].getName().name)) { return transitionTables[i]; } } return null; } // public int getResultMemoryRowCount() { return resultMaxMemoryRows; } public void setResultMemoryRowCount(int count) { if (database.getTempDirectoryPath() != null) { resultMaxMemoryRows = count; } } // warnings HsqlArrayList sqlWarnings; public void addWarning(HsqlException warning) { if (sqlWarnings == null) { sqlWarnings = new HsqlArrayList(true); } sqlWarnings.add(warning); } public HsqlException[] getAndClearWarnings() { if (sqlWarnings == null) { return new HsqlException[0]; } HsqlException[] array = new HsqlException[sqlWarnings.size()]; sqlWarnings.toArray(array); sqlWarnings.clear(); return array; } // logs public synchronized long getLobId() { return database.lobManager.getNewLobId(); } public void registerResultLobs(Result result) throws HsqlException { sessionData.registerLobForResult(result); } public void allocateResultLob(ResultLob result, DataInput dataInput) throws HsqlException { sessionData.allocateLobForResult(result, dataInput); } }

The table below shows all metrics for Session.java.

MetricValueDescription
BLOCKS200.00Number of blocks
BLOCK_COMMENT72.00Number of block comment lines
COMMENTS375.00Comment lines
COMMENT_DENSITY 0.60Comment density
COMPARISONS49.00Number of comparison operators
CYCLOMATIC186.00Cyclomatic complexity
DECL_COMMENTS74.00Comments in declarations
DOC_COMMENT239.00Number of javadoc comment lines
ELOC624.00Effective lines of code
EXEC_COMMENTS13.00Comments in executable code
EXITS146.00Procedure exits
FUNCTIONS78.00Number of function declarations
HALSTEAD_DIFFICULTY87.70Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY193.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 5.00JAVA0007 Should not declare public field
JAVA0008 5.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 5.00JAVA0031 Case statement not properly closed
JAVA0032 4.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 0.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 1.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 1.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 4.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 7.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 3.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 5.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 5.00JAVA0116 Missing javadoc: field 'field'
JAVA011714.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 1.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 3.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 7.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 6.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 9.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 1.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 1.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 1.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1432.00Number of lines in the source file
LINE_COMMENT64.00Number of line comments
LOC794.00Lines of code
LOGICAL_LINES362.00Number of statements
LOOPS 5.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1474.00Number of operands
OPERATORS2999.00Number of operators
PARAMS47.00Number of formal parameter declarations
PROGRAM_LENGTH4473.00Halstead program length
PROGRAM_VOCAB536.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS146.00Number of return points from functions
SIZE44689.00Size of the file in bytes
UNIQUE_OPERANDS479.00Number of unique operands
UNIQUE_OPERATORS57.00Number of unique operators
WHITESPACE263.00Number of whitespace lines