ch.sahits.codegen.sql.generator
Class BasicDataManipulator

java.lang.Object
  extended by ch.sahits.codegen.sql.generator.BasicDataManipulator
Direct Known Subclasses:
CountryChanger

public class BasicDataManipulator
extends java.lang.Object

This class provides the basic interface for data manupulation. Using this class the data is not manipulated. The input data is pased through to the output data.
This class is intended to subclass in the context of the extension point ch.sahits.codegen.sql.manipulation.
The data maipulator is invoced during the insert script generation.
Database fields that should be convertable must implement the interface IConvertableField

Since:
1.1.0
Author:
Andi Hotz

Constructor Summary
BasicDataManipulator()
          Default constructor initializing the record with null
BasicDataManipulator(ICurrentRecordSet record)
          Constructor initializing a record
 
Method Summary
 java.lang.String convert(java.lang.String fieldName)
          Convert the field with the given name.
 java.util.List<IField> fields()
          Retrieve the list of field value pairs registerd wit this record
 java.lang.String getOwner()
          This method retrieves the schema of the output data.
 java.lang.String getTableName()
          This method retrieves the table name of the output data.
 boolean hasSchemaAndTableName()
          Test if the table name and owner are valid
 boolean hasSchemaName()
          Test if the owner is valid
 boolean hasTableName()
          Test if the table name is valid
protected  void init()
          The init method should be overridden by subclasses to register all the convertors
 void registerConverter(java.lang.String fieldName, IFieldValueConverter converter)
          Register a convertor for the field.
 void setRecord(ICurrentRecordSet record)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicDataManipulator

public BasicDataManipulator(ICurrentRecordSet record)
Constructor initializing a record

Parameters:
record -

BasicDataManipulator

public BasicDataManipulator()
Default constructor initializing the record with null

Method Detail

setRecord

public final void setRecord(ICurrentRecordSet record)
Parameters:
record - the record to set

getOwner

public final java.lang.String getOwner()
This method retrieves the schema of the output data. This implementation passes the schema value through

Returns:
schema of the input data

getTableName

public final java.lang.String getTableName()
This method retrieves the table name of the output data. This implementation passes the table name through

Returns:
table name of the input data

registerConverter

public final void registerConverter(java.lang.String fieldName,
                                    IFieldValueConverter converter)
Register a convertor for the field. The convertor can be passed as an anonymous class:
 ...
 manipulator.registerConverter("NAME", new IFieldValueConverter(){
        //  Convert the input to capitalized lowercase
        public String convert(Object input) {
                String name = (String)input;
                name = name.substring(0, 1).toUpperCase()+name.substring(1).toLowerCase();
                return name;
         }
 });
 ...
 

Parameters:
fieldName - name of the field to be converted
converter - instance of a converter

fields

public final java.util.List<IField> fields()
Retrieve the list of field value pairs registerd wit this record

Returns:
List of fields

init

protected void init()
The init method should be overridden by subclasses to register all the convertors


convert

public final java.lang.String convert(java.lang.String fieldName)
Convert the field with the given name. If the field is not an instance of IConvertableField the original value is returend. If the field is not found null is returned

Parameters:
fieldName - name of the field
Returns:
converted value of the field

hasTableName

public final boolean hasTableName()
Test if the table name is valid

Returns:
true if the table name is NOT ''
Since:
1.1.1

hasSchemaName

public final boolean hasSchemaName()
Test if the owner is valid

Returns:
true if the owner is NOT ''
Since:
1.1.1

hasSchemaAndTableName

public final boolean hasSchemaAndTableName()
Test if the table name and owner are valid

Returns:
true if the table name and owner are NOT ''
Since:
1.1.1
See Also:
CurrentRecordSet#hasTableName(), CurrentRecordSet#hasSchemaName()