org.deegree.commons.tom.sql
Class DefaultPrimitiveConverter

java.lang.Object
  extended by org.deegree.commons.tom.sql.DefaultPrimitiveConverter
All Implemented Interfaces:
ParticleConverter<PrimitiveValue>, PrimitiveParticleConverter
Direct Known Subclasses:
OraclePrimitiveConverter

public class DefaultPrimitiveConverter
extends Object
implements PrimitiveParticleConverter

Implementations convert between PrimitiveValue particles and SQL column values.

Version:
$Revision: 31820 $, $Date: 2011-09-08 18:37:18 +0200 (Thu, 08 Sep 2011) $
Author:
Markus Schneider, last edited by: $Author: mschneider $

Field Summary
protected  BaseType bt
           
protected  String column
           
protected  PrimitiveType pt
           
 
Constructor Summary
DefaultPrimitiveConverter(PrimitiveType pt, String column)
           
DefaultPrimitiveConverter(PrimitiveType pt, String column, boolean isConcatenated)
           
 
Method Summary
 String getSelectSnippet(String tableAlias)
          Returns an SQL fragment for SELECTing the particle value from the associated database table.
 String getSetSnippet(PrimitiveValue particle)
          Returns a PreparedStatement fragment for setting the given particle value in an SQL statement.
 PrimitiveType getType()
          Returns the primitive type that this converter converts.
 boolean isConcatenated()
           
 void setParticle(PreparedStatement stmt, PrimitiveValue particle, int colIndex)
          Converts the given particle and sets the designated SQL parameter in the given PreparedStatement.
protected  PrimitiveValue toBooleanParticle(Object sqlValue)
           
protected  PrimitiveValue toDateParticle(Object sqlValue)
           
protected  PrimitiveValue toDateTimeParticle(Object sqlValue)
           
protected  PrimitiveValue toDecimalParticle(Object sqlValue)
           
protected  PrimitiveValue toDoubleParticle(Object sqlValue)
           
protected  PrimitiveValue toIntegerParticle(Object sqlValue)
           
 PrimitiveValue toParticle(ResultSet rs, int colIndex)
          Builds a particle from the specified column of the current row of the given ResultSet.
protected  PrimitiveValue toStringParticle(Object sqlValue)
           
protected  PrimitiveValue toTimeParticle(Object sqlValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pt

protected final PrimitiveType pt

bt

protected BaseType bt

column

protected final String column
Constructor Detail

DefaultPrimitiveConverter

public DefaultPrimitiveConverter(PrimitiveType pt,
                                 String column)

DefaultPrimitiveConverter

public DefaultPrimitiveConverter(PrimitiveType pt,
                                 String column,
                                 boolean isConcatenated)
Method Detail

getSelectSnippet

public String getSelectSnippet(String tableAlias)
Description copied from interface: ParticleConverter
Returns an SQL fragment for SELECTing the particle value from the associated database table.

Specified by:
getSelectSnippet in interface ParticleConverter<PrimitiveValue>
Parameters:
tableAlias - alias that's used for disambiguating the table, may be null
Returns:
SQL fragment (e.g. X1.columname), may be null

getSetSnippet

public String getSetSnippet(PrimitiveValue particle)
Description copied from interface: ParticleConverter
Returns a PreparedStatement fragment for setting the given particle value in an SQL statement.

The value may be set in a literal SQL fashion (e.g. '2007-08-09') or as a PreparedStatement placeholder ('?').

Specified by:
getSetSnippet in interface ParticleConverter<PrimitiveValue>
Parameters:
particle - particle value, can be null
Returns:
SQL fragment (e.g. ?), may be null

toParticle

public PrimitiveValue toParticle(ResultSet rs,
                                 int colIndex)
                          throws SQLException
Description copied from interface: ParticleConverter
Builds a particle from the specified column of the current row of the given ResultSet.

Specified by:
toParticle in interface ParticleConverter<PrimitiveValue>
Parameters:
rs - result set, never null
colIndex - index of the column in the result set
Returns:
particle, may be null
Throws:
SQLException

getType

public PrimitiveType getType()
Description copied from interface: PrimitiveParticleConverter
Returns the primitive type that this converter converts.

Specified by:
getType in interface PrimitiveParticleConverter
Returns:
the primitive type, never null

toBooleanParticle

protected PrimitiveValue toBooleanParticle(Object sqlValue)

toDateParticle

protected PrimitiveValue toDateParticle(Object sqlValue)

toDateTimeParticle

protected PrimitiveValue toDateTimeParticle(Object sqlValue)

toTimeParticle

protected PrimitiveValue toTimeParticle(Object sqlValue)

toDecimalParticle

protected PrimitiveValue toDecimalParticle(Object sqlValue)
                                    throws NumberFormatException
Throws:
NumberFormatException

toDoubleParticle

protected PrimitiveValue toDoubleParticle(Object sqlValue)
                                   throws NumberFormatException
Throws:
NumberFormatException

toIntegerParticle

protected PrimitiveValue toIntegerParticle(Object sqlValue)
                                    throws NumberFormatException
Throws:
NumberFormatException

toStringParticle

protected PrimitiveValue toStringParticle(Object sqlValue)

setParticle

public void setParticle(PreparedStatement stmt,
                        PrimitiveValue particle,
                        int colIndex)
                 throws SQLException
Description copied from interface: ParticleConverter
Converts the given particle and sets the designated SQL parameter in the given PreparedStatement.

Specified by:
setParticle in interface ParticleConverter<PrimitiveValue>
Parameters:
stmt - prepared statement, never null
particle - particle value, can be null
colIndex - index of the SQL parameter in the statement
Throws:
SQLException

isConcatenated

public boolean isConcatenated()
Specified by:
isConcatenated in interface PrimitiveParticleConverter


Copyright © 2011. All Rights Reserved.