org.afcs.warts.handlers
Class NullHandler

java.lang.Object
  extended byorg.afcs.warts.handlers.DataHandlerSupport
      extended byorg.afcs.warts.handlers.NullHandler
All Implemented Interfaces:
DataHandler

public final class NullHandler
extends DataHandlerSupport
implements DataHandler

The NullHandler class can be used to handle datatypes that don't have a registered handler yet.

LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.

Version:
Last Modified 20 August 2003
Author:
Warren Hedley ( whedley at sdsc dot edu )

Constructor Summary
NullHandler(TableDescription tableDescription, ColumnDescription columnDescription)
          Constructs a new instance on behalf of subclasses that will handle data values for the specified column in the specified table.
 
Method Summary
 void bindNonNullValue(java.sql.PreparedStatement statement, int variableIndex, java.lang.Object value)
          This method always binds a null of the appropriate type to the specified variable in the specified statement, regardless of the value received.
 boolean isNullHandler()
          This is the "null handler", so we return true.
 java.lang.Object loadValue(java.sql.ResultSet resultSet, int columnIndex)
          This method will always return null, without even attempting to load any data from the specified column of the specified result set.
 java.lang.String printNonNullValue(java.lang.Object value)
          This method returns the string "[unknown]", indicating that there is no good data handler for the specified value.
 
Methods inherited from class org.afcs.warts.handlers.DataHandlerSupport
getColumnDescription, getNullType, getTableDescription, isCharacterData, loadBytesFromStream, logWrongValueTypeWarning, postProcessBind, requiresBindPostProcessing, requiresStreamedLoading, toString, verifyObjectIsString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.afcs.warts.handlers.DataHandler
getNullType, isCharacterData, postProcessBind, requiresBindPostProcessing, requiresStreamedLoading
 

Constructor Detail

NullHandler

public NullHandler(TableDescription tableDescription,
                   ColumnDescription columnDescription)
Constructs a new instance on behalf of subclasses that will handle data values for the specified column in the specified table.

Parameters:
tableDescription - The table that the handler will be handling data for.
columnDescription - The column that this class will be processing data for.
Method Detail

bindNonNullValue

public void bindNonNullValue(java.sql.PreparedStatement statement,
                             int variableIndex,
                             java.lang.Object value)
                      throws java.sql.SQLException
This method always binds a null of the appropriate type to the specified variable in the specified statement, regardless of the value received.

Specified by:
bindNonNullValue in interface DataHandler
Parameters:
statement - The statement to bind the value in.
variableIndex - The index of the variable to bind.
value - The value to bind to the statement (always ignored).
Throws:
java.sql.SQLException - If a SQL error occurs during binding.

isNullHandler

public boolean isNullHandler()
This is the "null handler", so we return true. The null handler should not be the handler returned by DataHandlerFactory for primary key columns, as this would make rows indistinguisable.

Specified by:
isNullHandler in interface DataHandler
Overrides:
isNullHandler in class DataHandlerSupport
Returns:
Always true.

loadValue

public java.lang.Object loadValue(java.sql.ResultSet resultSet,
                                  int columnIndex)
                           throws java.sql.SQLException
This method will always return null, without even attempting to load any data from the specified column of the specified result set.

Specified by:
loadValue in interface DataHandler
Parameters:
resultSet - The result set to load data from.
columnIndex - The index of the column to load data from.
Returns:
Null ... always.
Throws:
java.sql.SQLException - If a SQL exception occurs while loading data.

printNonNullValue

public java.lang.String printNonNullValue(java.lang.Object value)
This method returns the string "[unknown]", indicating that there is no good data handler for the specified value.

Specified by:
printNonNullValue in interface DataHandler
Parameters:
value - The object value to print (always ignored).
Returns:
The string "[unknown]".