com.extentech.ExtenXLS.binder
Class CellBinder

java.lang.Object
  extended by com.extentech.ExtenXLS.binder.CellBinder

public class CellBinder
extends Object

The CellBinder maintains arbitrary mappings between
WorkBook CellRanges and external data sources such as a SQL Resultset.


The CellBinder uses an XML mapping file to determine which Cells in the
WorkBook to map to which values in the data source.

Since:
1.3
Version:
1.01
Author:
John McMahon -- Copyright ©2011Extentech Inc.
See Also:
Cell, DataBoundCell

Field Summary
static int CELLBINDER_RUN
           
static int CELLBOUND_TEMPLATE
           
 
Constructor Summary
CellBinder(WorkBook b, DataObject cn, com.extentech.toolkit.LogOutputter lgr)
          The CellBinder is responsible for managing the data bindings of a single connection (JDBC) with the Cells of a single com.extentech.ExtenXLS.WorkBook.
CellBinder(WorkBook b, com.extentech.toolkit.LogOutputter lgr)
          The CellBinder is responsible for managing the data bindings of a single connection (JDBC) with the Cells of a single com.extentech.ExtenXLS.WorkBook.
 
Method Summary
 void bindXMLStream(String workingdir)
          Initializes the binding for stream-based DataBoundCellRanges Cell ranges are stored in a vector within a CellRangeDataObject.
 Connection getCon()
          returns initialized DB Factory connection
 DataObject getConnection()
          Returns connection DataObject for this cellbinder
 List getNewRowTracker()
           
 Map getOffsetTracker()
           
 Collection getRESTEmit()
          RESTEmit is a representation of changes as a JSON array for use in Sheetstr
 boolean getSQLreplaceWithParamName()
           
 void initDataCellBindings(Map paramvals)
          Initializes the binding for database connected DataBoundCellRanges Cell ranges are stored in a vector within a CellRangeDataObject.
 void parseNBindXMLStream(String xmlFile, HashMap cellranges, boolean auto_convert, boolean use_namespaces)
          Given an xml file and a series of cell ranges mapped to an xpath-type string, use XppPullParsing to traverse thru xml, matching the xpath fieldbindings and inputting values to the mapped cell ranges
 void setDebug(boolean d)
           
 void setNewRowTracker(List newRowTracker)
           
 void setOffsetTracker(Map offsetTracker)
           
 void setSQLreplaceWithParamName(boolean b)
           
 String toString()
           
 void updateBeanCells(Map parms)
          update bound Cells with a Hashtable of values
 void updateBeanCells(Map parms, boolean overwriteFormulas)
          update Namedrange bound Cells with a Hashtable of values
 void updateDataCells()
          Updates the Cells in the WorkBook from the values in the bound data source.
 void updateParameterCell(String mapname, Object val)
          Set a single value in the WorkBook based on the XML mapping file.
 void updateParameterCells(Map parms)
          update bound Cells with a Hashtable of values Parameter bound cells are defined with a parambinding node in the RDF file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CELLBOUND_TEMPLATE

public static int CELLBOUND_TEMPLATE

CELLBINDER_RUN

public static int CELLBINDER_RUN
Constructor Detail

CellBinder

public CellBinder(WorkBook b,
                  com.extentech.toolkit.LogOutputter lgr)
The CellBinder is responsible for managing the data bindings of a single connection (JDBC) with the Cells of a single com.extentech.ExtenXLS.WorkBook. There will be as many CellBinders for a com.extentech.ExtenXLS.WorkBook as there are distinct Data sources.


CellBinder

public CellBinder(WorkBook b,
                  DataObject cn,
                  com.extentech.toolkit.LogOutputter lgr)
The CellBinder is responsible for managing the data bindings of a single connection (JDBC) with the Cells of a single com.extentech.ExtenXLS.WorkBook. There will be as many CellBinders for a com.extentech.ExtenXLS.WorkBook as there are distinct Data sources.

Method Detail

toString

public String toString()
Overrides:
toString in class Object

setDebug

public void setDebug(boolean d)

updateParameterCell

public void updateParameterCell(String mapname,
                                Object val)
Set a single value in the WorkBook based on the XML mapping file. The mapname is the parambinding value from the XML file, and the val is the new value for the Cell.

Parameters:
String - the parambinding name
Object - the new Cell value

updateParameterCells

public void updateParameterCells(Map parms)
update bound Cells with a Hashtable of values Parameter bound cells are defined with a parambinding node in the RDF file.

Parameters:
parms - a hashtable of values to match with parameter-bound cells

updateBeanCells

public void updateBeanCells(Map parms)
                     throws DataAccessException
update bound Cells with a Hashtable of values

Parameters:
parms - a hashtable of values to match with parameter-bound cells
Throws:
DataAccessException

updateBeanCells

public void updateBeanCells(Map parms,
                            boolean overwriteFormulas)
                     throws DataAccessException
update Namedrange bound Cells with a Hashtable of values

Parameters:
parms - a hashtable of values to match with parameter-bound cells
overwriteFormulas - - whether to override formula cells by writing values rather than extending the formula range
Throws:
DataAccessException

initDataCellBindings

public void initDataCellBindings(Map paramvals)
Initializes the binding for database connected DataBoundCellRanges Cell ranges are stored in a vector within a CellRangeDataObject. This allows us to change the sql and have it affect all the cell ranges associated with it. /* 20060320 KSC: changed RDF element for cellrange was (with example): now: and/or:

Parameters:
Hashtable - paramvals contains SQL filter parameters for data bound Cells these are NOT the same as the values for parameter-bound Cells

bindXMLStream

public void bindXMLStream(String workingdir)
Initializes the binding for stream-based DataBoundCellRanges Cell ranges are stored in a vector within a CellRangeDataObject. This allows us to change the sql and have it affect all the cell ranges associated with it.

Parameters:
Map - xmldatastreams (name, filename) 20070226 KSC: Major rewrite

updateDataCells

public void updateDataCells()
                     throws Exception
Updates the Cells in the WorkBook from the values in the bound data source.

Throws:
Exception

getSQLreplaceWithParamName

public boolean getSQLreplaceWithParamName()
Returns:

setSQLreplaceWithParamName

public void setSQLreplaceWithParamName(boolean b)
Parameters:
b -

getNewRowTracker

public List getNewRowTracker()
Returns:
Returns the newRowTracker.

setNewRowTracker

public void setNewRowTracker(List newRowTracker)
Parameters:
newRowTracker - The newRowTracker to set.

getOffsetTracker

public Map getOffsetTracker()
Returns:
Returns the offsetTracker.

setOffsetTracker

public void setOffsetTracker(Map offsetTracker)
Parameters:
offsetTracker - The offsetTracker to set.

getConnection

public DataObject getConnection()
Returns connection DataObject for this cellbinder


getCon

public Connection getCon()
returns initialized DB Factory connection

Returns:

parseNBindXMLStream

public void parseNBindXMLStream(String xmlFile,
                                HashMap cellranges,
                                boolean auto_convert,
                                boolean use_namespaces)
Given an xml file and a series of cell ranges mapped to an xpath-type string, use XppPullParsing to traverse thru xml, matching the xpath fieldbindings and inputting values to the mapped cell ranges

Parameters:
xmlFile - string xml filename
cellranges - HashMap of fieldbindings=>range|source|shiftcols|type
auto_convert - automatic_conversions from RDF datastream element, truth of "do not use explicitly named type to convert xml data"
use_namespaces - namespaces from RDF datastream element, truth of "fieldbindings contain namespaces in their xpaths"
See Also:
bindXMLStream

getRESTEmit

public Collection getRESTEmit()
RESTEmit is a representation of changes as a JSON array for use in Sheetstr

Returns:
Returns the rESTEmit.


Copyright © 2011 Extentech Inc. All Rights Reserved.