gov.usda.gdpc.database
Class ConstantDatabaseMapping

java.lang.Object
  extended bygov.usda.gdpc.database.AbstractDatabaseMapping
      extended bygov.usda.gdpc.database.ConstantDatabaseMapping
All Implemented Interfaces:
DatabaseMapping

public class ConstantDatabaseMapping
extends AbstractDatabaseMapping

Author:
terryc

Field Summary
protected  java.lang.Object myConstant
           
 
Fields inherited from class gov.usda.gdpc.database.AbstractDatabaseMapping
myProperty
 
Constructor Summary
ConstantDatabaseMapping(Property property, java.lang.Object constant)
          ConstantDatabaseMapping Constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          This determines if two database mapping are equal.
 java.lang.Object getConstant()
          Return the constant.
 SQLStatements getDistinctSQL()
          Returns the SQL statements required to get the distinct values for the property associated with this mapping.
 java.util.List getJavaObjects(java.sql.ResultSet rs, ExtraInfo extraInfo)
          This only uses the result set to determine the number of times to add the constant to the list.
 java.lang.String getSQLSubString(Filter filter, ExtraInfo extraInfo)
          Gets the SQL sub-string based on the given filter.
 java.lang.String toString()
          Returns the string representation of this database mapping.
 
Methods inherited from class gov.usda.gdpc.database.AbstractDatabaseMapping
getProperty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myConstant

protected final java.lang.Object myConstant
Constructor Detail

ConstantDatabaseMapping

public ConstantDatabaseMapping(Property property,
                               java.lang.Object constant)
ConstantDatabaseMapping Constructor. This represents a constant mapping which

Parameters:
property - associated property. null is creating a mapping to use for matching against a property map.
constant - constant
Method Detail

getConstant

public java.lang.Object getConstant()
Return the constant.

Returns:
constant

getSQLSubString

public java.lang.String getSQLSubString(Filter filter,
                                        ExtraInfo extraInfo)
Gets the SQL sub-string based on the given filter. This always returns null since the constant does not need to be retrieved from the database.

Specified by:
getSQLSubString in interface DatabaseMapping
Overrides:
getSQLSubString in class AbstractDatabaseMapping
Parameters:
filter - filter
extraInfo - this is not used by this database mapping
Returns:
null

getJavaObjects

public java.util.List getJavaObjects(java.sql.ResultSet rs,
                                     ExtraInfo extraInfo)
                              throws java.sql.SQLException
This only uses the result set to determine the number of times to add the constant to the list. The constant is added one time for each row in the result set.

Specified by:
getJavaObjects in interface DatabaseMapping
Overrides:
getJavaObjects in class AbstractDatabaseMapping
Parameters:
rs - result set
extraInfo - this is not used by this database mapping
Returns:
list of converted data
Throws:
java.sql.SQLException

getDistinctSQL

public SQLStatements getDistinctSQL()
Returns the SQL statements required to get the distinct values for the property associated with this mapping.

Specified by:
getDistinctSQL in interface DatabaseMapping
Overrides:
getDistinctSQL in class AbstractDatabaseMapping
Returns:
SQL statements and corresponding extra information

equals

public boolean equals(java.lang.Object obj)
This determines if two database mapping are equal. In this case, two constant database mappings are equal if the constant value are the equal according to the equal() method.

Parameters:
obj - object to test
Returns:
true if equal

toString

public java.lang.String toString()
Returns the string representation of this database mapping.

Overrides:
toString in class AbstractDatabaseMapping
Returns:
string representation