org.clazzes.jdbc2xml.deserialization.impl
Class AbstractSbDeserializationHandler

java.lang.Object
  extended by org.clazzes.jdbc2xml.deserialization.impl.AbstractSbDeserializationHandler
All Implemented Interfaces:
DeserializationHandler
Direct Known Subclasses:
BigDecimalDeserializationHandler, BinaryDeserializationHandler, BooleanDeserializationHandler, DateDeserializationHandler, DoubleDeserializationHandler, FloatDeserializationHandler, IntegerDeserializationHandler, StringDeserializationHandler, TimestampDeserializationHandler

public abstract class AbstractSbDeserializationHandler
extends Object
implements DeserializationHandler

A base class for all DeserializationHandlers, which are setting a String value to a database column.

Author:
wglas

Field Summary
protected  int type
           
 
Constructor Summary
AbstractSbDeserializationHandler(int type)
          Default constructor.
 
Method Summary
 void addCharacters(char[] ch, int start, int length)
          Push characters received by ContentHandler.characters(char[], int, int) to the field content.
 void fillColumn(PreparedStatement ps, int column)
          Fill the column of the given prepared statement with the data received so far.
protected abstract  void fillColumnValue(PreparedStatement ps, int column, String value)
          Fill in a column value into the given PreparedStatment.
 void startCharacters()
          Start receiving data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected final int type
Constructor Detail

AbstractSbDeserializationHandler

public AbstractSbDeserializationHandler(int type)
Default constructor.

Method Detail

fillColumnValue

protected abstract void fillColumnValue(PreparedStatement ps,
                                        int column,
                                        String value)
                                 throws SQLException
Fill in a column value into the given PreparedStatment.

Parameters:
ps - The statement to fill.
column - The number of the column to fill.
value - The string value to set or null, if the column has to be nulled.
Throws:
SQLException

addCharacters

public void addCharacters(char[] ch,
                          int start,
                          int length)
Description copied from interface: DeserializationHandler
Push characters received by ContentHandler.characters(char[], int, int) to the field content. This method throws an exception, DeserializationHandler.startCharacters() has not been called before.

Specified by:
addCharacters in interface DeserializationHandler
Parameters:
ch - The character array.
start - The start index of the data to push.
length - The length of the data to push.

fillColumn

public void fillColumn(PreparedStatement ps,
                       int column)
                throws SQLException
Description copied from interface: DeserializationHandler
Fill the column of the given prepared statement with the data received so far. If no data has been received, i.e. DeserializationHandler.startCharacters() has not been called before, set the column to an SQL null value. This call resets the state of this handler, so DeserializationHandler.startCharacters() may be called again.

Specified by:
fillColumn in interface DeserializationHandler
Parameters:
ps - The PreparedStatement to fill.
column - The number of the column to set.
Throws:
SQLException

startCharacters

public void startCharacters()
Description copied from interface: DeserializationHandler
Start receiving data. This is called as part of an ContentHandler.startElement(String, String, String, org.xml.sax.Attributes) operation.

Specified by:
startCharacters in interface DeserializationHandler


Copyright © 2012. All Rights Reserved.