Blob.java

Index Score
org.apache.derby.client.am
Apache Derby

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
LINE_COMMENTNumber of line comments
BLOCKSNumber of blocks
EXEC_COMMENTSComments in executable code
SIZESize of the file in bytes
RETURNSNumber of return points from functions
INTERFACE_COMPLEXITYInterface complexity
JAVA0264JAVA0264 Integer math in long context - check for overflow
CYCLOMATICCyclomatic complexity
LOCLines of code
OPERATORSNumber of operators
ELOCEffective lines of code
LINESNumber of lines in the source file
PROGRAM_LENGTHHalstead program length
COMPARISONSNumber of comparison operators
JAVA0177JAVA0177 Variable declaration missing initializer
PARAMSNumber of formal parameter declarations
OPERANDSNumber of operands
JAVA0034JAVA0034 Missing braces in if statement
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0067JAVA0067 Array descriptor on identifier name
COMMENTSComment lines
LOGICAL_LINESNumber of statements
UNIQUE_OPERATORSNumber of unique operators
PROGRAM_VOLUMEHalstead program volume
PROGRAM_VOCABHalstead program vocabulary
DECL_COMMENTSComments in declarations
JAVA0136JAVA0136 N methods defined in class (maximum: M)
EXITSProcedure exits
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
FUNCTIONSNumber of function declarations
UNIQUE_OPERANDSNumber of unique operands
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
LOOPSNumber of loops
NEST_DEPTHMaximum nesting depth
JAVA0145JAVA0145 Tab character used in source file
/* Derby - Class org.apache.derby.client.am.Blob Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.apache.derby.client.am; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.sql.SQLException; import org.apache.derby.shared.common.reference.SQLState; public class Blob extends Lob implements java.sql.Blob { //-----------------------------state------------------------------------------ byte[] binaryString_ = null; // Only used for input purposes. For output, each getBinaryStream call // must generate an independent stream. java.io.InputStream binaryStream_ = null; int dataOffset_; //---------------------constructors/finalizer--------------------------------- public Blob(byte[] binaryString, Agent agent, int dataOffset) { super(agent, false); binaryString_ = binaryString; dataType_ |= BINARY_STRING; setSqlLength(binaryString.length - dataOffset); dataOffset_ = dataOffset; } // CTOR for input: public Blob(Agent agent, java.io.InputStream binaryStream, int length) { super(agent, false); binaryStream_ = binaryStream; dataType_ |= BINARY_STREAM; setSqlLength(length); } /** * Create a new <code>Blob</code> from a stream with unknown length. * <em>Important:</em> This constructor is a temporary solution for * implementing lengthless overloads in the JDBC4 API. Before a proper * solution can be implemented, we need to enable streaming without having * to know the stream length in the DRDA protocol. See Jira DERBY-1471 and * DERBY-1417 for more details. * * <em>Shortcomings:</em> This constructor will cause the <em>whole stream * to be materialized</em> to determine its length. If the stream is big * enough, the client will fail with an OutOfMemoryError. Since this is a * temporary solution, state checking is not added to all methods as it * would clutter up the class severely. After using the constructor, the * <code>length</code>-method must be called, which will materialize the * stream and determine the length. <em>Do not pass a Blob object created * with this constructor to the user!</em> * * @param agent * @param binaryStream the stream to get data from */ public Blob(Agent agent, java.io.InputStream binaryStream) { super(agent, isLayerBStreamingPossible(agent)); binaryStream_ = binaryStream; dataType_ |= BINARY_STREAM; } /** * Create a <code>Blob</code> object for a Blob value stored * on the server and indentified by <code>locator</code>. * @param agent context for this Blob object (incl. connection) * @param locator reference id to Blob value on server */ public Blob(Agent agent, int locator) { super(agent, false); locator_ = locator; dataType_ |= LOCATOR; } // ---------------------------jdbc 2------------------------------------------ public long length() throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "length"); } checkForClosedConnection(); long retVal = super.sqlLength(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "length", retVal); } return retVal; } } catch ( SqlException se ) { throw se.getSQLException(); } } /** * Get the length in bytes of the <code>Blob</code> value represented by * this locator based <Blob> object. * * A stored procedure call will be made to get it from the server. * @throws org.apache.derby.client.am.SqlException * @return length of Blob in bytes */ long getLocatorLength() throws SqlException { return agent_.connection_.locatorProcedureCall() .blobGetLength(locator_); } /** * Returns as an array of bytes part or all of the <code>BLOB</code> * value that this <code>Blob</code> object designates. The byte * array contains up to <code>length</code> consecutive bytes * starting at position <code>pos</code>. * The starting position must be between 1 and the length * of the BLOB plus 1. This allows for zero-length BLOB values, from * which only zero-length byte arrays can be returned. * If a larger length is requested than there are bytes available, * characters from the start position to the end of the BLOB are returned. * @param pos the ordinal position of the first byte in the * <code>BLOB</code> value to be extracted; the first byte is at * position 1 * @param length is the number of consecutive bytes to be copied * @return a byte array containing up to <code>length</code> * consecutive bytes from the <code>BLOB</code> value designated * by this <code>Blob</code> object, starting with the * byte at position <code>startPos</code>. * @exception SQLException if there is an error accessing the * <code>BLOB</code> * NOTE: If the starting position is the length of the BLOB plus 1, * zero bytess are returned regardless of the length requested. */ public byte[] getBytes(long pos, int length) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getBytes", (int) pos, length); } if (pos <= 0) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_BAD_POSITION), new Long(pos)); } if (pos > sqlLength() + 1) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos)); } if (length < 0) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_NONPOSITIVE_LENGTH), new Integer(length)); } byte[] retVal = getBytesX(pos, length); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getBytes", retVal); } return retVal; } } catch ( SqlException se ) { throw se.getSQLException(); } } private byte[] getBytesX(long pos, int length) throws SqlException { checkForClosedConnection(); long actualLength; // actual length is the lesser of the number of bytes requested // and the number of bytes available from pos to the end actualLength = Math.min(sqlLength() - pos + 1, (long) length); byte[] retVal; if (isLocator()) { retVal = agent_.connection_.locatorProcedureCall() .blobGetBytes(locator_, pos, (int )actualLength); } else { retVal = new byte[(int) actualLength]; System.arraycopy(binaryString_, (int) pos + dataOffset_ - 1, retVal, 0, (int) actualLength); } return retVal; } public java.io.InputStream getBinaryStream() throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getBinaryStream"); } java.io.InputStream retVal = getBinaryStreamX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getBinaryStream", retVal); } return retVal; } } catch ( SqlException se ) { throw se.getSQLException(); } } java.io.InputStream getBinaryStreamX() throws SqlException { checkForClosedConnection(); if (isBinaryStream()) // this Lob is used for input { return binaryStream_; } else if (isLocator()) { //The Blob is locator enabled. Return a instance of the //UpdateSensitive stream which wraps inside it a //Buffered Locator stream. The wrapper watches out //for updates. return new UpdateSensitiveBlobLocatorInputStream (agent_.connection_, this); } else { // binary string return new java.io.ByteArrayInputStream(binaryString_, dataOffset_, binaryString_.length - dataOffset_); } } public long position(byte[] pattern, long start) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "position(byte[], long)", pattern, start); } if (pattern == null) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_NULL_PATTERN_OR_SEARCH_STR)); } if (start < 1) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_BAD_POSITION), new Long(start)); } long pos = positionX(pattern, start); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "position(byte[], long)", pos); } return pos; } } catch ( SqlException se ) { throw se.getSQLException(); } } private long positionX(byte[] pattern, long start) throws SqlException { checkForClosedConnection(); if (isLocator()) { return agent_.connection_.locatorProcedureCall() .blobGetPositionFromBytes(locator_, pattern, start); } else { return binaryStringPosition(pattern, start); } } public long position(java.sql.Blob pattern, long start) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "position(Blob, long)", pattern, start); } if (pattern == null) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_NULL_PATTERN_OR_SEARCH_STR)); } if (start < 1) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_BAD_POSITION), new Long(start)); } long pos = positionX(pattern, start); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "position(Blob, long)", pos); } return pos; } } catch ( SqlException se ) { throw se.getSQLException(); } } private long positionX(java.sql.Blob pattern, long start) throws SqlException { checkForClosedConnection(); try { if (isLocator()) { if ((pattern instanceof Blob) && ((Blob )pattern).isLocator()) { // Send locator for pattern to server return agent_.connection_.locatorProcedureCall() .blobGetPositionFromLocator(locator_, ((Blob )pattern).getLocator(), start); } else { // Convert pattern to byte array before sending to server return agent_.connection_.locatorProcedureCall() .blobGetPositionFromBytes(locator_, pattern.getBytes(1L, (int )pattern.length()), start); } } else { return binaryStringPosition( pattern.getBytes(1L, (int )pattern.length()), start); } } catch (java.sql.SQLException e) { throw new SqlException(e); } } // -------------------------- JDBC 3.0 ----------------------------------- public int setBytes(long pos, byte[] bytes) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBytes", (int) pos, bytes); } int length = setBytesX(pos, bytes, 0, bytes.length); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "setBytes", length); } return length; } } catch ( SqlException se ) { throw se.getSQLException(); } } public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBytes", (int) pos, bytes, offset, len); } int length = setBytesX(pos, bytes, offset, len); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "setBytes", length); } return length; } } catch ( SqlException se ) { throw se.getSQLException(); } } public int setBytesX(long pos, byte[] bytes, int offset, int len) throws SqlException { int length = 0; /* Check if position is less than 0 and if true raise an exception */ if (pos <= 0L) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_BAD_POSITION), new Long(pos)); } /* Currently only 2G-1 bytes can be inserted in a single Blob column hence check corresponding position value */ if (pos >= Integer.MAX_VALUE) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos)); } if (pos - 1 > sqlLength()) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos)); } if ((offset < 0) || offset > bytes.length ) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_INVALID_OFFSET), new Integer(offset)); } if ( len < 0 ) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_NONPOSITIVE_LENGTH), new Integer(length)); } if (len == 0) { return 0; } length = Math.min((bytes.length - offset), len); if (isLocator()) { byte[] ba = bytes; if ((offset > 0) || (length < bytes.length)) { // Copy the part we will use into a new array ba = new byte[length]; System.arraycopy(bytes, offset, ba, 0, length); } agent_.connection_.locatorProcedureCall() .blobSetBytes(locator_, pos, length, ba); if (pos+length-1 > sqlLength()) { // Wrote beyond the old end // Update length setSqlLength(pos + length - 1); } //The Blob value has been //modified. Increment the //updateCount to reflect the //change. incrementUpdateCount(); } else { if ((binaryString_.length - dataOffset_ - (int)pos + 1) < length) { byte newbuf[] = new byte[(int) pos + length + dataOffset_ - 1]; System.arraycopy(binaryString_, 0, newbuf, 0, binaryString_.length); binaryString_ = newbuf; } System.arraycopy(bytes, offset, binaryString_, (int) pos + dataOffset_ - 1, length); binaryStream_ = new java.io.ByteArrayInputStream(binaryString_); setSqlLength(binaryString_.length - dataOffset_); } return length; } public java.io.OutputStream setBinaryStream(long pos) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBinaryStream", (int) pos); } if (pos < 1) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_BAD_POSITION), new Long(pos)); } OutputStream outStream; if (isLocator()) { outStream = new BlobLocatorOutputStream(agent_.connection_, this, pos); } else { outStream = new BlobOutputStream(this, pos); } if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "setBinaryStream", outStream); } return outStream; } } catch ( SqlException se ) { throw se.getSQLException(); } } public void truncate(long len) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, " truncate", (int) len); } if (len < 0 || len > sqlLength()) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.INVALID_API_PARAMETER), new Long(len), "len", "Blob.truncate()"); } if (len == this.sqlLength()) { return; } if (isLocator()) { agent_.connection_.locatorProcedureCall() .blobTruncate(locator_, len); setSqlLength(len); //The Blob value has been //updated Increment the //update count to reflect //the change. incrementUpdateCount(); } else { long newLength = (int) len + dataOffset_; byte newbuf[] = new byte[(int) len + dataOffset_]; System.arraycopy(binaryString_, 0, newbuf, 0, (int) newLength); binaryString_ = newbuf; binaryStream_ = new java.io.ByteArrayInputStream(binaryString_); setSqlLength(binaryString_.length - dataOffset_); } } } catch ( SqlException se ) { throw se.getSQLException(); } } // -------------------------- JDBC 4.0 ----------------------------------- /** * This method frees the <code>Blob</code> object and releases the resources that * it holds. The object is invalid once the <code>free</code> * method is called. If <code>free</code> is called multiple times, the subsequent * calls to <code>free</code> are treated as a no-op. * * @throws SQLException if an error occurs releasing * the Blob's resources */ public void free() throws SQLException { //calling free() on a already freed object is treated as a no-op if (!isValid_) return; //now that free has been called the Blob object is no longer //valid isValid_ = false; try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "free"); } if (isBinaryStream()) { try { binaryStream_.close(); } catch(IOException ioe) { throw new SqlException(null, new ClientMessageId( SQLState.IO_ERROR_UPON_LOB_FREE)); } } else if (isLocator()) { agent_.connection_.locatorProcedureCall() .blobReleaseLocator(locator_); } else { binaryString_ = null; } } } catch (SqlException se) { throw se.getSQLException(); } } /** * Returns an <code>InputStream</code> object that contains a partial <code> * Blob</code> value, starting with the byte specified by pos, * which is length bytes in length. * * @param pos the offset to the first byte of the partial value to * be retrieved. The first byte in the <code>Blob</code> is at position 1. * @param length the length in bytes of the partial value to be retrieved * @return <code>InputStream</code> through which the partial * <code>Blob</code> value can be read. * @throws SQLException if pos is less than 1 or if pos is greater than * the number of bytes in the <code>Blob</code> or if pos + length is * greater than the number of bytes in the <code>Blob</code> */ public InputStream getBinaryStream(long pos, long length) throws SQLException { //call checkValidity to exit by throwing a SQLException if //the Blob object has been freed by calling free() on it checkValidity(); try { synchronized (agent_.connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getBinaryStream", (int) pos, length); } checkPosAndLength(pos, length); InputStream retVal; if (isLocator()) { //The Blob is locator enabled. Return an //instance of the update sensitive stream //that wraps inside it a Buffered InputStream. //The wrapper watches out for updates to the //underlying Blob. retVal = new UpdateSensitiveBlobLocatorInputStream (agent_.connection_, this, pos, length); } else { // binary string retVal = new java.io.ByteArrayInputStream (binaryString_, (int)(dataOffset_ + pos - 1), (int)length); } if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getBinaryStream", retVal); } return retVal; } } catch ( SqlException se ) { throw se.getSQLException(); } } //------------------ Material layer event callback methods ------------------- //---------------------------- helper methods -------------------------------- public boolean isBinaryString() { return ((dataType_ & BINARY_STRING) == BINARY_STRING); } public boolean isBinaryStream() { return ((dataType_ & BINARY_STREAM) == BINARY_STREAM); } public byte[] getBinaryString() { return binaryString_; } protected long binaryStringPosition(byte[] pattern, long start) { // perform a local byte string search, starting at start // check that the range of comparison is valid int index = (int) start + dataOffset_ - 1; // api start begins at 1 while (index + pattern.length <= binaryString_.length) { if (isSubString(pattern, index)) { return (long) (index - dataOffset_ + 1); // readjust for api indexing } index++; } return -1L; // not found } // precondition: binaryString_ is long enough for the comparison protected boolean isSubString(byte[] pattern, int index) { for (int i = 0; i < pattern.length; i++, index++) { if (pattern[i] != binaryString_[index]) { return false; } } return true; } /** * Materialize the stream used for input to the database. * * @throws SqlException */ protected void materializeStream() throws SqlException { binaryStream_ = super.materializeStream(binaryStream_, "java.sql.Blob"); } }

The table below shows all metrics for Blob.java.

MetricValueDescription
BLOCKS129.00Number of blocks
BLOCK_COMMENT29.00Number of block comment lines
COMMENTS173.00Comment lines
COMMENT_DENSITY 0.47Comment density
COMPARISONS62.00Number of comparison operators
CYCLOMATIC100.00Cyclomatic complexity
DECL_COMMENTS18.00Comments in declarations
DOC_COMMENT85.00Number of javadoc comment lines
ELOC367.00Effective lines of code
EXEC_COMMENTS24.00Comments in executable code
EXITS44.00Procedure exits
FUNCTIONS27.00Number of function declarations
HALSTEAD_DIFFICULTY119.90Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY118.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 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.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 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 1.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 0.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 2.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 0.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 0.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 0.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.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 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 8.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.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 0.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 0.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 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.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 4.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 1.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 5.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 0.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 0.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
LINES745.00Number of lines in the source file
LINE_COMMENT59.00Number of line comments
LOC501.00Lines of code
LOGICAL_LINES168.00Number of statements
LOOPS 2.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS897.00Number of operands
OPERATORS2043.00Number of operators
PARAMS40.00Number of formal parameter declarations
PROGRAM_LENGTH2940.00Halstead program length
PROGRAM_VOCAB256.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS78.00Number of return points from functions
SIZE28645.00Size of the file in bytes
UNIQUE_OPERANDS202.00Number of unique operands
UNIQUE_OPERATORS54.00Number of unique operators
WHITESPACE71.00Number of whitespace lines