signature:
public class CellControlsUtility { /** * set object property .
 * @ param obj
 * object .
 * @ param propertyName
 * property name .
 * @ param propertyValue
 * value .
 * @ param ignoreNonExisting
 * true if ignore non exist property . */
public static void setObjectProperty ( final Object obj , final String propertyName , final String propertyValue , final boolean ignoreNonExisting ) { } }

implementation: try { String methodName = "set" + Character . toUpperCase ( propertyName . charAt ( 0 ) ) + propertyName . substring ( 1 ) ; AttributesType parameterType = matchParaMeterOfMethod ( obj , methodName ) ; if ( parameterType != null ) { Method method = obj . getClass ( ) . getMethod ( methodName , new Class [ ] { parameterType . clazz } ) ; method . invoke ( obj , convertToObject ( parameterType , propertyValue ) ) ; } } catch ( Exception e ) { String msg = "failed to set property '" + propertyName + "' to value '" + propertyValue + "' for object " + obj ; if ( ignoreNonExisting ) { LOG . log ( Level . FINE , msg , e ) ; } else { LOG . warning ( msg ) ; throw new IllegalArgumentException ( e ) ; } }


signature:
public class CellControlsUtility { /** * get object property value .
 * @ param obj
 * object .
 * @ param propertyName
 * property name .
 * @ param ignoreNonExisting
 * true ignore no existing .
 * @ return perperty value . */
public static String getObjectPropertyValue ( final Object obj , final String propertyName , final boolean ignoreNonExisting ) { } }

implementation: try { Method method = obj . getClass ( ) . getMethod ( "get" + Character . toUpperCase ( propertyName . charAt ( 0 ) ) + propertyName . substring ( 1 ) ) ; return ( String ) method . invoke ( obj ) ; } catch ( Exception e ) { String msg = "failed to get property '" + propertyName + "' for object " + obj ; if ( ignoreNonExisting ) { LOG . log ( Level . FINE , msg , e ) ; } else { LOG . warning ( msg ) ; throw new IllegalArgumentException ( e ) ; } } return null ;


signature:
public class CellControlsUtility { /** * Setup control attributes .
 * @ param originRowIndex
 * the origin row index
 * @ param fcell
 * the fcell
 * @ param poiCell
 * the poi cell
 * @ param sheetConfig
 * the sheet config
 * @ param cellAttributesMap
 * the cell attributes map */
public static void setupControlAttributes ( final int originRowIndex , final FacesCell fcell , final Cell poiCell , final SheetConfiguration sheetConfig , final CellAttributesMap cellAttributesMap ) { } }

implementation: int rowIndex = originRowIndex ; if ( rowIndex < 0 ) { rowIndex = poiCell . getRowIndex ( ) ; } String skey = poiCell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( poiCell . getColumnIndex ( ) , rowIndex ) ; Map < String , String > commentMap = cellAttributesMap . getTemplateCommentMap ( ) . get ( "$$" ) ; if ( commentMap != null ) { String comment = commentMap . get ( skey ) ; if ( comment != null ) { CommandUtility . createCellComment ( poiCell , comment , sheetConfig . getFinalCommentMap ( ) ) ; } } String widgetType = cellAttributesMap . getCellInputType ( ) . get ( skey ) ; if ( widgetType != null ) { fcell . setControl ( widgetType . toLowerCase ( ) ) ; fcell . setInputAttrs ( cellAttributesMap . getCellInputAttributes ( ) . get ( skey ) ) ; fcell . setSelectItemAttrs ( cellAttributesMap . getCellSelectItemsAttributes ( ) . get ( skey ) ) ; fcell . setDatePattern ( cellAttributesMap . getCellDatePattern ( ) . get ( skey ) ) ; }


signature:
public class CellControlsUtility { /** * Find cell validate attributes .
 * @ param validateMaps
 * validateMaps .
 * @ param originRowIndex
 * original Row Index from facesRow .
 * @ param cell
 * cell .
 * @ return list . */
public static List < CellFormAttributes > findCellValidateAttributes ( final Map < String , List < CellFormAttributes > > validateMaps , final int originRowIndex , final Cell cell ) { } }

implementation: String key = cell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( cell . getColumnIndex ( ) , originRowIndex ) ; return validateMaps . get ( key ) ;


signature:
public class PicturesHelper { /** * Setup faces cell picture charts .
 * @ param sheet1
 * the sheet 1
 * @ param fcell
 * the fcell
 * @ param cell
 * the cell
 * @ param fId
 * the f id */
public final void setupFacesCellPictureCharts ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final String fId ) { } }

implementation: if ( parent . getPicturesMap ( ) != null ) { setupFacesCellPicture ( sheet1 , fcell , cell , fId ) ; } if ( parent . getCharsData ( ) . getChartsMap ( ) != null ) { setupFacesCellCharts ( sheet1 , fcell , cell , fId ) ; }


signature:
public class PicturesHelper { /** * Setup faces cell charts .
 * @ param sheet1
 * the sheet 1
 * @ param fcell
 * the fcell
 * @ param cell
 * the cell
 * @ param fId
 * the f id */
private void setupFacesCellCharts ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final String fId ) { } }

implementation: try { String chartId = parent . getCharsData ( ) . getChartPositionMap ( ) . get ( fId ) ; if ( chartId != null ) { BufferedImage img = parent . getCharsData ( ) . getChartsMap ( ) . get ( chartId ) ; if ( img != null ) { fcell . setContainChart ( true ) ; fcell . setChartId ( chartId ) ; fcell . setChartStyle ( PicturesUtility . generateChartStyle ( sheet1 , fcell , cell , chartId , parent . getCharsData ( ) . getChartAnchorsMap ( ) ) ) ; } } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "setupFacesCell Charts error = " + ex . getMessage ( ) , ex ) ; }


signature:
public class PicturesHelper { /** * Setup faces cell picture .
 * @ param sheet1
 * the sheet 1
 * @ param fcell
 * the fcell
 * @ param cell
 * the cell
 * @ param fId
 * the f id */
private void setupFacesCellPicture ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final String fId ) { } }

implementation: try { Picture pic = parent . getPicturesMap ( ) . get ( fId ) ; if ( pic != null ) { fcell . setContainPic ( true ) ; fcell . setPictureId ( fId ) ; fcell . setPictureStyle ( PicturesUtility . generatePictureStyle ( sheet1 , fcell , cell , pic ) ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "setupFacesCell Picture error = " + ex . getMessage ( ) , ex ) ; }


signature:
public class ChartHelper { /** * initial chart map for specified workbook .
 * @ param wb
 * specified workbook . */
private void initChartsMap ( final Workbook wb ) { } }

implementation: try { if ( wb instanceof XSSFWorkbook ) { initXSSFChartsMap ( ( XSSFWorkbook ) wb , parent . getCharsData ( ) ) ; } } catch ( Exception e ) { LOG . log ( Level . SEVERE , "getChartsMap Error Exception = " + e . getLocalizedMessage ( ) , e ) ; }


signature:
public class ChartHelper { /** * return cell Value for paredCell . ParsedCell contain sheetName / row / col
 * which normally is parsed from String like : Sheet1 ! B2 .
 * @ param pCell
 * parsed cell .
 * @ return cell string value without format . */
public final String getParsedCellValue ( final ParsedCell pCell ) { } }

implementation: String result = "" ; try { Cell poiCell = parent . getWb ( ) . getSheet ( pCell . getSheetName ( ) ) . getRow ( pCell . getRow ( ) ) . getCell ( pCell . getCol ( ) ) ; result = CellUtility . getCellValueWithoutFormat ( poiCell ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "error getParsedCellValue :" + ex . getLocalizedMessage ( ) , ex ) ; } return result ;


signature:
public class ChartHelper { /** * create default category dataset for JfreeChart with giving chartData .
 * @ param chartData
 * contain information gathered from excel chart object .
 * @ return DefaultCategoryDataset for jfreechart . */
private DefaultPieDataset createPieDataset ( final ChartData chartData ) { } }

implementation: DefaultPieDataset dataset = new DefaultPieDataset ( ) ; List < ParsedCell > categoryList = chartData . getCategoryList ( ) ; for ( ChartSeries chartSeries : chartData . getSeriesList ( ) ) { List < ParsedCell > valueList = chartSeries . getValueList ( ) ; for ( int i = 0 ; i < categoryList . size ( ) ; i ++ ) { try { String sCategory = getParsedCellValue ( categoryList . get ( i ) ) ; String sValue = getParsedCellValue ( valueList . get ( i ) ) ; dataset . setValue ( sCategory , Double . parseDouble ( sValue ) ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "error in creatPieDataset : " + ex . getLocalizedMessage ( ) , ex ) ; } } } return dataset ;


signature:
public class ChartHelper { /** * return pie chart title from chartData .
 * @ param chartData
 * ChartData object .
 * @ return title ( String ) . */
private String getPieTitle ( final ChartData chartData ) { } }

implementation: for ( ChartSeries chartSeries : chartData . getSeriesList ( ) ) { if ( chartSeries != null ) { return getParsedCellValue ( chartSeries . getSeriesLabel ( ) ) ; } } return "" ;


signature:
public class ChartHelper { /** * Set color of series .
 * @ param chart
 * JFreeChart .
 * @ param seriesIndex
 * Index of series to set color of ( 0 = first series )
 * @ param style
 * One of STYLE _ xxx . */
public final void setSeriesStyle ( final JFreeChart chart , final int seriesIndex , final String style ) { } }

implementation:
if ( chart != null && style != null ) { BasicStroke stroke = ChartUtility . toStroke ( style ) ; Plot plot = chart . getPlot ( ) ; if ( plot instanceof CategoryPlot ) { CategoryPlot categoryPlot = chart . getCategoryPlot ( ) ; CategoryItemRenderer cir = categoryPlot . getRenderer ( ) ; try { cir . setSeriesStroke ( seriesIndex , stroke ) ; // series line
// style
} catch ( Exception e ) { LOG . log ( Level . SEVERE , "Error setting style '" + style + "' for series '" + Integer . toString ( seriesIndex ) + "' of chart '" + chart . toString ( ) + "': " + e . getLocalizedMessage ( ) , e ) ; } } else if ( plot instanceof XYPlot ) { XYPlot xyPlot = chart . getXYPlot ( ) ; XYItemRenderer xyir = xyPlot . getRenderer ( ) ; try { xyir . setSeriesStroke ( seriesIndex , stroke ) ; // series line
// style
} catch ( Exception e ) { LOG . log ( Level . SEVERE , "Error setting style '" + style + "' for series '" + Integer . toString ( seriesIndex ) + "' of chart '" + chart . toString ( ) + "': " + e . getLocalizedMessage ( ) , e ) ; } } else { LOG . log ( Level . FINE , "setSeriesColor() unsupported plot: {}" , plot . toString ( ) ) ; } }


signature:
public class ChartHelper { /** * Create jfree bar chart .
 * @ param chartData
 * contain information gathered from excel chart object .
 * @ return jfree line chart . */
public JFreeChart createAreaChart ( final ChartData chartData ) { } }

implementation:
PlotOrientation orientation = PlotOrientation . VERTICAL ; // create the chart . . .
final JFreeChart chart = ChartFactory . createAreaChart ( chartData . getTitle ( ) , // chart title
chartData . getCatAx ( ) . getTitle ( ) , // x axis label
chartData . getValAx ( ) . getTitle ( ) , // y axis label
createDataset ( chartData ) , // data
orientation , true , // include legend
false , // tooltips
false // urls
) ; setupStyle ( chart , chartData ) ; return chart ;


signature:
public class ChartHelper { /** * Create jfree bar chart .
 * @ param chartData
 * contain information gathered from excel chart object .
 * @ param vertical
 * chart orientation .
 * @ return jfree line chart . */
public JFreeChart createBarChart ( final ChartData chartData , final boolean vertical ) { } }

implementation:
PlotOrientation orientation = PlotOrientation . VERTICAL ; if ( ! vertical ) { orientation = PlotOrientation . HORIZONTAL ; } // create the chart . . .
final JFreeChart chart = ChartFactory . createBarChart ( chartData . getTitle ( ) , // chart title
chartData . getCatAx ( ) . getTitle ( ) , // x axis label
chartData . getValAx ( ) . getTitle ( ) , // y axis label
createDataset ( chartData ) , // data
orientation , true , // include legend
false , // tooltips
false // urls
) ; setupBarStyle ( chart , chartData ) ; return chart ;


signature:
public class ChartHelper { /** * Create jfree bar chart .
 * @ param chartData
 * contain information gathered from excel chart object .
 * @ return jfree line chart . */
public JFreeChart createPieChart ( final ChartData chartData ) { } }

implementation:
// create the chart . . .
final JFreeChart chart = ChartFactory . createPieChart ( getPieTitle ( chartData ) , // chart title
createPieDataset ( chartData ) , // data
true , // include legend
false , // tooltips
false // urls
) ; setupPieStyle ( chart , chartData ) ; return chart ;


signature:
public class ChartHelper { /** * create pie 3d chart .
 * @ param chartData
 * chart data .
 * @ return jfreechart . */
public JFreeChart createPie3DChart ( final ChartData chartData ) { } }

implementation:
// create the chart . . .
final JFreeChart chart = ChartFactory . createPieChart3D ( getPieTitle ( chartData ) , // chart title
createPieDataset ( chartData ) , // data
true , // include legend
false , // tooltips
false // urls
) ; setupPieStyle ( chart , chartData ) ; return chart ;


signature:
public class ChartHelper { /** * finalize the style for jfreechart . The default setting is different from
 * jfreechart and Excel . We try to minimize the difference .
 * @ param chart
 * jfreechart .
 * @ param chartData
 * contain information gathered from excel chart object . */
private void setupStyle ( final JFreeChart chart , final ChartData chartData ) { } }

implementation:
CategoryPlot plot = ( CategoryPlot ) chart . getPlot ( ) ; List < ChartSeries > seriesList = chartData . getSeriesList ( ) ; BasicStroke bLine = new BasicStroke ( 2.0f ) ; for ( int i = 0 ; i < seriesList . size ( ) ; i ++ ) { Color cColor = ColorUtility . xssfClrToClr ( seriesList . get ( i ) . getSeriesColor ( ) . getXssfColor ( ) ) ; plot . getRenderer ( ) . setSeriesPaint ( i , cColor ) ; plot . getRenderer ( ) . setSeriesStroke ( i , bLine ) ; } plot . setBackgroundPaint ( ColorUtility . xssfClrToClr ( chartData . getBgColor ( ) . getXssfColor ( ) ) ) ; // below are modifications for default setting in excel chart
// to - do : need read setting from xml in future
plot . setOutlineVisible ( false ) ; plot . setRangeGridlinesVisible ( true ) ; plot . setRangeGridlinePaint ( Color . BLACK ) ; plot . setRangeGridlineStroke ( new BasicStroke ( TieConstants . DEFAULT_BASIC_STROKE ) ) ; plot . setRangeAxisLocation ( AxisLocation . BOTTOM_OR_LEFT ) ; chart . setBackgroundPaint ( Color . WHITE ) ; LegendTitle legend = chart . getLegend ( ) ; legend . setPosition ( RectangleEdge . RIGHT ) ; legend . setFrame ( BlockBorder . NONE ) ;


signature:
public class ChartHelper { /** * finalize the style for jfreechart . The default setting is different from
 * jfreechart and Excel . We try to minimize the difference .
 * @ param chart
 * jfreechart .
 * @ param chartData
 * contain information gathered from excel chart object . */
private void setupPieStyle ( final JFreeChart chart , final ChartData chartData ) { } }

implementation:
PiePlot plot = ( PiePlot ) chart . getPlot ( ) ; List < ChartSeries > seriesList = chartData . getSeriesList ( ) ; List < ParsedCell > categoryList = chartData . getCategoryList ( ) ; BasicStroke bLine = new BasicStroke ( 2.0f ) ; for ( int i = 0 ; i < seriesList . size ( ) ; i ++ ) { ChartSeries chartSeries = seriesList . get ( i ) ; List < XColor > valueColorList = chartSeries . getValueColorList ( ) ; for ( int index = 0 ; index < categoryList . size ( ) ; index ++ ) { try { String sCategory = getParsedCellValue ( categoryList . get ( index ) ) ; Color cColor = ColorUtility . xssfClrToClr ( valueColorList . get ( index ) . getXssfColor ( ) ) ; plot . setSectionPaint ( sCategory , cColor ) ; plot . setSectionOutlineStroke ( sCategory , bLine ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "SetupPieStyle error = " + ex . getLocalizedMessage ( ) , ex ) ; } } } plot . setBackgroundPaint ( ColorUtility . xssfClrToClr ( chartData . getBgColor ( ) . getXssfColor ( ) ) ) ; // below are modifications for default setting in excel chart
// to - do : need read setting from xml in future
plot . setOutlineVisible ( false ) ; plot . setLegendItemShape ( new Rectangle ( TieConstants . DEFAULT_LEGENT_ITEM_SHAPE_WIDTH , TieConstants . DEFAULT_LEGENT_ITEM_SHAPE_HEIGHT ) ) ; chart . setBackgroundPaint ( Color . WHITE ) ; LegendTitle legend = chart . getLegend ( ) ; legend . setPosition ( RectangleEdge . RIGHT ) ; legend . setFrame ( BlockBorder . NONE ) ;


signature:
public class ChartHelper { /** * finalize the style for barchart . This will call setupStyle common first .
 * @ param chart
 * jfreechart .
 * @ param chartData
 * contain information gathered from excel chart object . */
private void setupBarStyle ( final JFreeChart chart , final ChartData chartData ) { } }

implementation: setupStyle ( chart , chartData ) ; CategoryPlot plot = ( CategoryPlot ) chart . getPlot ( ) ; BarRenderer renderer = ( BarRenderer ) plot . getRenderer ( ) ; renderer . setBarPainter ( new StandardBarPainter ( ) ) ; renderer . setItemMargin ( TieConstants . DEFAULT_BAR_STYLE_ITEM_MARGIN ) ; plot . setForegroundAlpha ( TieConstants . DEFAULT_BARSTYLE_FOREGROUND_ALPHA ) ;


signature:
public class ChartHelper { /** * create default category dataset for JfreeChart with giving chartData .
 * @ param chartData
 * contain information gathered from excel chart object .
 * @ return DefaultCategoryDataset for jfreechart . */
private DefaultCategoryDataset createDataset ( final ChartData chartData ) { } }

implementation: DefaultCategoryDataset dataset = new DefaultCategoryDataset ( ) ; List < ParsedCell > categoryList = chartData . getCategoryList ( ) ; for ( ChartSeries chartSeries : chartData . getSeriesList ( ) ) { String seriesLabel = getParsedCellValue ( chartSeries . getSeriesLabel ( ) ) ; List < ParsedCell > valueList = chartSeries . getValueList ( ) ; for ( int i = 0 ; i < categoryList . size ( ) ; i ++ ) { try { String sCategory = getParsedCellValue ( categoryList . get ( i ) ) ; String sValue = getParsedCellValue ( valueList . get ( i ) ) ; dataset . addValue ( Double . parseDouble ( sValue ) , seriesLabel , sCategory ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "error in creatDataset : " + ex . getLocalizedMessage ( ) , ex ) ; } } } return dataset ;


signature:
public class ChartHelper { /** * initial chart map for XSSF format file . XSSF file is actually the only
 * format in POI support chart object .
 * @ param wb
 * xssf workbook .
 * @ param chartsData
 * the charts data */
private void initXSSFChartsMap ( final XSSFWorkbook wb , final ChartsData chartsData ) { } }

implementation: initAnchorsMap ( wb , chartsData ) ; Map < String , ClientAnchor > anchorMap = chartsData . getChartAnchorsMap ( ) ; Map < String , BufferedImage > chartMap = chartsData . getChartsMap ( ) ; Map < String , ChartData > chartDataMap = chartsData . getChartDataMap ( ) ; chartMap . clear ( ) ; chartDataMap . clear ( ) ; for ( int i = 0 ; i < wb . getNumberOfSheets ( ) ; i ++ ) { XSSFSheet sheet = wb . getSheetAt ( i ) ; XSSFDrawing drawing = sheet . createDrawingPatriarch ( ) ; List < XSSFChart > charts = drawing . getCharts ( ) ; if ( ( charts != null ) && ( ! charts . isEmpty ( ) ) ) { for ( XSSFChart chart : charts ) { generateSingleXSSFChart ( chart , getChartIdFromParent ( chart , sheet . getSheetName ( ) ) , sheet , anchorMap , chartMap , chartDataMap ) ; } } }


signature:
public class ChartHelper { /** * Gets the chart id from parent .
 * @ param chart
 * the chart
 * @ param sheetName
 * the sheet name
 * @ return the chart id from parent */
private String getChartIdFromParent ( final XSSFChart chart , final String sheetName ) { } }

implementation: if ( chart . getParent ( ) != null ) { for ( RelationPart rp : chart . getParent ( ) . getRelationParts ( ) ) { if ( rp . getDocumentPart ( ) == chart ) { return sheetName + "!" + rp . getRelationship ( ) . getId ( ) ; } } } return null ;


signature:
public class ChartHelper { /** * initial anchors map for specified workbook . Excel put the chart position
 * information in draw . xml instead of chart . xml . anchors map contains the
 * information getting from draw . xml .
 * @ param wb
 * specified workbook .
 * @ param chartsData
 * the charts data */
private void initAnchorsMap ( final Workbook wb , final ChartsData chartsData ) { } }

implementation: try { if ( wb instanceof XSSFWorkbook ) { ChartUtility . initXSSFAnchorsMap ( ( XSSFWorkbook ) wb , chartsData ) ; } } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Web Form getAnchorsMap Error Exception = " + e . getLocalizedMessage ( ) , e ) ; }


signature:
public class ChartHelper { /** * Generate single XSSF chart .
 * @ param chart
 * the chart
 * @ param chartId
 * the chart id
 * @ param sheet
 * the sheet
 * @ param anchorMap
 * the anchor map
 * @ param chartMap
 * the chart map
 * @ param chartDataMap
 * the chart data map */
private void generateSingleXSSFChart ( final XSSFChart chart , final String chartId , final XSSFSheet sheet , final Map < String , ClientAnchor > anchorMap , final Map < String , BufferedImage > chartMap , final Map < String , ChartData > chartDataMap ) { } }

implementation: ClientAnchor anchor ; try { anchor = anchorMap . get ( chartId ) ; if ( anchor != null ) { ChartData chartData = ChartUtility . initChartDataFromXSSFChart ( chartId , chart , ( XSSFWorkbook ) parent . getWb ( ) ) ; chartDataMap . put ( chartId , chartData ) ; JFreeChart jchart = createChart ( chartData ) ; if ( jchart != null ) { AnchorSize anchorSize = PicturesUtility . getAnchorSize ( sheet , null , null , anchor ) ; BufferedImage img = jchart . createBufferedImage ( anchorSize . getWidth ( ) , anchorSize . getHeight ( ) ) ; chartMap . put ( chartId , img ) ; } } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "generate chart for " + chartId + " error = " + ex . getLocalizedMessage ( ) , ex ) ; }


signature:
public class ConfigurationUtility { /** * Transform to collection object .
 * @ param engine
 * the engine
 * @ param collectionName
 * the collection name
 * @ param context
 * the context
 * @ return the collection */
@ SuppressWarnings ( "rawtypes" ) public static Collection transformToCollectionObject ( final ExpressionEngine engine , final String collectionName , final Map < String , Object > context ) { } }

implementation: Object collectionObject = engine . evaluate ( collectionName , context ) ; if ( ! ( collectionObject instanceof Collection ) ) { throw new EvaluationException ( collectionName + " expression is not a collection" ) ; } return ( Collection ) collectionObject ;


signature:
public class ConfigurationUtility { /** * Gets the full name from row .
 * @ param row
 * the row
 * @ return the full name from row */
public static String getFullNameFromRow ( final Row row ) { } }

implementation: if ( row != null ) { Cell cell = row . getCell ( TieConstants . HIDDEN_FULL_NAME_COLUMN ) ; if ( cell != null ) { return cell . getStringCellValue ( ) ; } } return null ;


signature:
public class ConfigurationUtility { /** * Re build upper level formula .
 * @ param configBuildRef
 * the config build ref
 * @ param actionFullName
 * the action full name */
public static void reBuildUpperLevelFormula ( final ConfigBuildRef configBuildRef , final String actionFullName ) { } }

implementation: Map < Cell , String > cachedMap = configBuildRef . getCachedCells ( ) ; Map < String , List < RowsMapping > > rowsMap = new HashMap < > ( ) ; for ( Map . Entry < Cell , String > entry : cachedMap . entrySet ( ) ) { Cell cell = entry . getKey ( ) ; String originFormula = entry . getValue ( ) ; if ( originFormula != null ) { setupUpperLevelFormula ( cell , originFormula , actionFullName , rowsMap , configBuildRef ) ; } }


signature:
public class ConfigurationUtility { /** * Setup upper level formula .
 * @ param cell
 * cell .
 * @ param originFormula
 * originFormula .
 * @ param actionFullName
 * add full name .
 * @ param rowsMap
 * rowsmap .
 * @ param configBuildRef
 * config build ref . */
private static void setupUpperLevelFormula ( final Cell cell , final String originFormula , final String actionFullName , final Map < String , List < RowsMapping > > rowsMap , final ConfigBuildRef configBuildRef ) { } }

implementation:
String fullName = getFullNameFromRow ( cell . getRow ( ) ) ; // check wither it ' s upper level
if ( actionFullName . startsWith ( fullName + ":" ) ) { // get rows mapping for upper level row
List < RowsMapping > currentRowsMappingList = rowsMap . get ( fullName ) ; if ( currentRowsMappingList == null ) { currentRowsMappingList = gatherRowsMappingByFullName ( configBuildRef , fullName ) ; rowsMap . put ( fullName , currentRowsMappingList ) ; } ShiftFormulaRef shiftFormulaRef = new ShiftFormulaRef ( configBuildRef . getWatchList ( ) , currentRowsMappingList ) ; shiftFormulaRef . setFormulaChanged ( 0 ) ; buildCellFormulaForShiftedRows ( configBuildRef . getSheet ( ) , configBuildRef . getWbWrapper ( ) , shiftFormulaRef , cell , originFormula ) ; if ( shiftFormulaRef . getFormulaChanged ( ) > 0 ) { configBuildRef . getCachedCells ( ) . put ( cell , originFormula ) ; } }


signature:
public class ConfigurationUtility { /** * Builds the cell formula for shifted rows .
 * @ param sheet
 * the sheet
 * @ param wbWrapper
 * the wb wrapper
 * @ param shiftFormulaRef
 * the shift formula ref
 * @ param cell
 * the cell
 * @ param originFormula
 * the origin formula */
public static void buildCellFormulaForShiftedRows ( final Sheet sheet , final XSSFEvaluationWorkbook wbWrapper , final ShiftFormulaRef shiftFormulaRef , final Cell cell , final String originFormula ) { } }

implementation:
// only shift when there ' s watchlist exist .
if ( ( shiftFormulaRef . getWatchList ( ) != null ) && ( ! shiftFormulaRef . getWatchList ( ) . isEmpty ( ) ) ) { Ptg [ ] ptgs = FormulaParser . parse ( originFormula , wbWrapper , FormulaType . CELL , sheet . getWorkbook ( ) . getSheetIndex ( sheet ) ) ; Ptg [ ] convertedFormulaPtg = ShiftFormulaUtility . convertSharedFormulas ( ptgs , shiftFormulaRef ) ; if ( shiftFormulaRef . getFormulaChanged ( ) > 0 ) { // only change formula when indicator is true
cell . setCellFormula ( FormulaRenderer . toFormulaString ( wbWrapper , convertedFormulaPtg ) ) ; } }


signature:
public class ConfigurationUtility { /** * Gather rows mapping by full name .
 * @ param configBuildRef
 * the config build ref
 * @ param fullName
 * the full name
 * @ return the list */
public static List < RowsMapping > gatherRowsMappingByFullName ( final ConfigBuildRef configBuildRef , final String fullName ) { } }

implementation: List < RowsMapping > list = new ArrayList < > ( ) ; Map < String , ConfigRangeAttrs > shiftMap = configBuildRef . getShiftMap ( ) ; for ( Map . Entry < String , ConfigRangeAttrs > entry : shiftMap . entrySet ( ) ) { String fname = entry . getKey ( ) ; if ( fname . startsWith ( fullName + ":" ) || fname . equals ( fullName ) ) { ConfigRangeAttrs attrs = entry . getValue ( ) ; list . add ( attrs . getUnitRowsMapping ( ) ) ; } } return list ;


signature:
public class ConfigurationUtility { /** * Increase index number in shift map .
 * @ param shiftMap
 * the shift map
 * @ param changeMap
 * the change map */
public static void changeIndexNumberInShiftMap ( final Map < String , ConfigRangeAttrs > shiftMap , final Map < String , String > changeMap ) { } }

implementation: for ( Map . Entry < String , String > entry : changeMap . entrySet ( ) ) { String key = entry . getKey ( ) ; String newKey = entry . getValue ( ) ; ConfigRangeAttrs attrs = shiftMap . get ( key ) ; if ( attrs != null ) { shiftMap . remove ( key ) ; shiftMap . put ( newKey , attrs ) ; } }


signature:
public class ConfigurationUtility { /** * Increase upper level final length .
 * @ param shiftMap
 * the shift map
 * @ param addedFullName
 * the added full name
 * @ param increasedLength
 * the increased length */
public static void changeUpperLevelFinalLength ( final Map < String , ConfigRangeAttrs > shiftMap , final String addedFullName , final int increasedLength ) { } }

implementation: String [ ] parts = addedFullName . split ( ":" ) ; StringBuilder fname = new StringBuilder ( ) ; for ( int i = 0 ; i < ( parts . length - 1 ) ; i ++ ) { if ( i == 0 ) { fname . append ( parts [ i ] ) ; } else { fname . append ( ":" ) . append ( parts [ i ] ) ; } String sname = fname . toString ( ) ; shiftMap . get ( sname ) . setFinalLength ( shiftMap . get ( sname ) . getFinalLength ( ) + increasedLength ) ; }


signature:
public class ConfigurationUtility { /** * Change index number in hidden column .
 * @ param configBuildRef
 * the config build ref
 * @ param startRowIndex
 * the start row index
 * @ param fullName
 * the full name
 * @ param changeMap
 * the change map
 * @ param steps
 * the steps ( 1 add - 1 delete ) . */
public static void changeIndexNumberInHiddenColumn ( final ConfigBuildRef configBuildRef , final int startRowIndex , final String fullName , final Map < String , String > changeMap , final int steps ) { } }

implementation: String searchName = fullName . substring ( 0 , fullName . lastIndexOf ( '.' ) + 1 ) ; Sheet sheet = configBuildRef . getSheet ( ) ; for ( int i = startRowIndex ; i <= sheet . getLastRowNum ( ) ; i ++ ) { Row row = sheet . getRow ( i ) ; String fname = getFullNameFromRow ( row ) ; if ( ( fname != null ) && ( fname . indexOf ( searchName ) >= 0 ) ) { int sindex = fname . indexOf ( searchName ) ; String snum = fname . substring ( sindex + searchName . length ( ) ) ; int sufindex = snum . indexOf ( ':' ) ; String suffix = "" ; if ( sufindex > 0 ) { snum = snum . substring ( 0 , sufindex ) ; suffix = ":" ; } int increaseNum = Integer . parseInt ( snum ) + steps ; String realFullName = fname . substring ( sindex ) ; String changeName = fname . replace ( searchName + snum + suffix , searchName + increaseNum + suffix ) ; if ( changeMap . get ( realFullName ) == null ) { changeMap . put ( realFullName , changeName . substring ( sindex ) ) ; } setFullNameInHiddenColumn ( row , changeName ) ; } else { return ; } }


signature:
public class ConfigurationUtility { /** * Sets the full name in hidden column .
 * @ param row
 * the row
 * @ param fullName
 * the full name */
public static void setFullNameInHiddenColumn ( final Row row , final String fullName ) { } }

implementation: Cell cell = row . getCell ( TieConstants . HIDDEN_FULL_NAME_COLUMN , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; cell . setCellValue ( fullName ) ;


signature:
public class ConfigurationUtility { /** * Gets the original row num in hidden column .
 * @ param row
 * the row
 * @ return the original row num in hidden column */
public static int getOriginalRowNumInHiddenColumn ( final Row row ) { } }

implementation: if ( row != null ) { Cell cell = row . getCell ( TieConstants . HIDDEN_ORIGIN_ROW_NUMBER_COLUMN , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; String rowNum = cell . getStringCellValue ( ) ; try { if ( ( rowNum != null ) && ( ! rowNum . isEmpty ( ) ) && ( WebSheetUtility . isNumeric ( rowNum ) ) ) { return Integer . parseInt ( rowNum ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "getOriginalRowNumInHiddenColumn rowNum = " + rowNum + " error = " + ex . getLocalizedMessage ( ) , ex ) ; } } return - 1 ;


signature:
public class ConfigurationUtility { /** * Sets the original row num in hidden column .
 * @ param row
 * the row .
 * @ param rowNum
 * row number . */
public static void setOriginalRowNumInHiddenColumn ( final Row row , final int rowNum ) { } }

implementation: Cell cell = row . getCell ( TieConstants . HIDDEN_ORIGIN_ROW_NUMBER_COLUMN , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; cell . setCellValue ( Integer . toString ( rowNum ) ) ; cell . setCellType ( CellType . STRING ) ;


signature:
public class ConfigurationUtility { /** * Find child rows mapping from shift map .
 * @ param fullName
 * the full name
 * @ param shiftMap
 * the shift map
 * @ return the list */
public static List < RowsMapping > findChildRowsMappingFromShiftMap ( final String fullName , final NavigableMap < String , ConfigRangeAttrs > shiftMap ) { } }

implementation:
List < RowsMapping > rowsMappingList = new ArrayList < > ( ) ; NavigableMap < String , ConfigRangeAttrs > tailmap = shiftMap . tailMap ( fullName , false ) ; for ( Map . Entry < String , ConfigRangeAttrs > entry : tailmap . entrySet ( ) ) { String key = entry . getKey ( ) ; // check it ' s children
if ( key . startsWith ( fullName ) ) { rowsMappingList . add ( entry . getValue ( ) . getUnitRowsMapping ( ) ) ; } else { break ; } } return rowsMappingList ;


signature:
public class ConfigurationUtility { /** * Find item in collection .
 * @ param collection
 * the collection
 * @ param index
 * the index
 * @ return the object */
@ SuppressWarnings ( "rawtypes" ) public static Object findItemInCollection ( final Collection collection , final int index ) { } }

implementation: if ( index >= 0 ) { if ( collection instanceof List ) { List list = ( List ) collection ; return list . get ( index ) ; } int i = 0 ; for ( Object object : collection ) { if ( i == index ) { return object ; } i ++ ; } } return null ;


signature:
public class ConfigurationUtility { /** * Builds the current range .
 * @ param sourceConfigRange
 * the source config range
 * @ param sheet
 * the sheet
 * @ param insertPosition
 * the insert position
 * @ return the config range */
public static ConfigRange buildCurrentRange ( final ConfigRange sourceConfigRange , final Sheet sheet , final int insertPosition ) { } }

implementation: ConfigRange current = new ConfigRange ( sourceConfigRange ) ; int shiftNum = insertPosition - sourceConfigRange . getFirstRowAddr ( ) . getRow ( ) ; current . shiftRowRef ( sheet , shiftNum ) ; return current ;


signature:
public class ConfigurationUtility { /** * Whether the row is static . This only check rowIndex against original
 * template .
 * @ param sourceConfigRange
 * the source config range
 * @ param rowIndex
 * the row index
 * @ return true is static false is not . */
public static boolean isStaticRow ( final ConfigRange sourceConfigRange , final int rowIndex ) { } }

implementation: if ( sourceConfigRange . getCommandList ( ) != null ) { for ( int i = 0 ; i < sourceConfigRange . getCommandList ( ) . size ( ) ; i ++ ) { Command command = sourceConfigRange . getCommandList ( ) . get ( i ) ; if ( ( rowIndex >= command . getConfigRange ( ) . getFirstRowAddr ( ) . getRow ( ) ) && ( rowIndex < ( command . getConfigRange ( ) . getLastRowPlusAddr ( ) . getRow ( ) ) ) ) { return false ; } } } return true ;


signature:
public class ConfigurationUtility { /** * Whether the row is static . This check row after shifted .
 * @ param sourceConfigRange
 * the source config range
 * @ param row
 * the row for check .
 * @ return true is static false is not . */
public static boolean isStaticRowRef ( final ConfigRange sourceConfigRange , final Row row ) { } }

implementation: if ( sourceConfigRange . getCommandList ( ) != null ) { for ( int i = 0 ; i < sourceConfigRange . getCommandList ( ) . size ( ) ; i ++ ) { Command command = sourceConfigRange . getCommandList ( ) . get ( i ) ; int rowIndex = row . getRowNum ( ) ; if ( ( rowIndex >= command . getTopRow ( ) ) && ( rowIndex < ( command . getTopRow ( ) + command . getFinalLength ( ) ) ) ) { return false ; } } } return true ;


signature:
public class ConfigurationUtility { /** * Remove last each command index from full name . e . g . for
 * F . departments : E . department . 1 : E . employee . 2 will return
 * F . departments : E . department . 1 : E . employee
 * Reason for this is for last layer collection . e . g . E . employee . 1 and
 * E . employee . 2 The E . emloyee is the same . *
 * @ param fullName
 * the full name
 * @ return the full data collect name from full name */
public static String getFullDataCollectNameFromFullName ( final String fullName ) { } }

implementation: if ( fullName == null ) { return "" ; } int lastEachCommandPos = fullName . lastIndexOf ( TieConstants . EACH_COMMAND_FULL_NAME_PREFIX ) ; if ( lastEachCommandPos < 0 ) { return "" ; } int lastEachCommandIndexPos = fullName . indexOf ( '.' , lastEachCommandPos + TieConstants . EACH_COMMAND_FULL_NAME_PREFIX . length ( ) ) ; if ( lastEachCommandIndexPos < 0 ) { return fullName ; } return fullName . substring ( 0 , lastEachCommandIndexPos ) ;


signature:
public class ConfigurationUtility { /** * 100 > = 80 */
public static String replaceExpressionWithCellValue ( final String attrValue , final int rowIndex , final Sheet sheet ) { } }

implementation:
int ibegin = 0 ; int ifind ; int inameEnd ; String tempStr ; String findStr ; String replaceStr ; String returnStr = attrValue ; while ( ( ifind = attrValue . indexOf ( TieConstants . CELL_ADDR_PRE_FIX , ibegin ) ) > 0 ) { inameEnd = ParserUtility . findFirstNonCellNamePosition ( attrValue , ifind ) ; if ( inameEnd > 0 ) { findStr = attrValue . substring ( ifind , inameEnd ) ; } else { findStr = attrValue . substring ( ifind ) ; } if ( findStr . indexOf ( TieConstants . CELL_ADDR_PRE_FIX , 1 ) < 0 ) { // only $ A
tempStr = findStr + TieConstants . CELL_ADDR_PRE_FIX + ( rowIndex + 1 ) ; } else { tempStr = findStr ; } replaceStr = CellUtility . getCellValueWithoutFormat ( WebSheetUtility . getCellByReference ( tempStr , sheet ) ) ; if ( replaceStr == null ) { replaceStr = "" ; } returnStr = attrValue . replace ( findStr , replaceStr ) ; ibegin = ifind + 1 ; } return returnStr ;


signature:
public class ConfigurationUtility { /** * Index merged region .
 * @ param sheet1
 * the sheet 1
 * @ return the map */
public static Map < String , CellRangeAddress > indexMergedRegion ( final Sheet sheet1 ) { } }

implementation: int numRegions = sheet1 . getNumMergedRegions ( ) ; Map < String , CellRangeAddress > cellRangeMap = new HashMap < > ( ) ; for ( int i = 0 ; i < numRegions ; i ++ ) { CellRangeAddress caddress = sheet1 . getMergedRegion ( i ) ; if ( caddress != null ) { cellRangeMap . put ( CellUtility . getCellIndexNumberKey ( caddress . getFirstColumn ( ) , caddress . getFirstRow ( ) ) , caddress ) ; } } return cellRangeMap ;


signature:
public class ConfigurationUtility { /** * Skipped region cells .
 * @ param sheet1
 * the sheet 1
 * @ return the list */
public static List < String > skippedRegionCells ( final Sheet sheet1 ) { } }

implementation: int numRegions = sheet1 . getNumMergedRegions ( ) ; List < String > skipCellList = new ArrayList < > ( ) ; for ( int i = 0 ; i < numRegions ; i ++ ) { CellRangeAddress caddress = sheet1 . getMergedRegion ( i ) ; if ( caddress != null ) { addSkipCellToListInTheRegion ( skipCellList , caddress ) ; } } return skipCellList ;


signature:
public class ConfigurationUtility { /** * Add skipped cell into the list of a region .
 * @ param skipCellList
 * list .
 * @ param caddress
 * region . */
private static void addSkipCellToListInTheRegion ( final List < String > skipCellList , final CellRangeAddress caddress ) { } }

implementation: for ( int col = caddress . getFirstColumn ( ) ; col <= caddress . getLastColumn ( ) ; col ++ ) { for ( int row = caddress . getFirstRow ( ) ; row <= caddress . getLastRow ( ) ; row ++ ) { if ( ( col == caddress . getFirstColumn ( ) ) && ( row == caddress . getFirstRow ( ) ) ) { continue ; } skipCellList . add ( CellUtility . getCellIndexNumberKey ( col , row ) ) ; } }


signature:
public class ConfigurationUtility { /** * Build Sheet Comment From command alias .
 * @ param sheet sheet .
 * @ param tieCommandAliasList list of ommand alias */
public static void buildSheetCommentFromAlias ( Sheet sheet , List < TieCommandAlias > tieCommandAliasList ) { } }

implementation: if ( ( tieCommandAliasList == null ) || ( tieCommandAliasList . isEmpty ( ) ) ) { return ; } for ( Row row : sheet ) { for ( Cell cell : row ) { buildCellCommentFromalias ( tieCommandAliasList , cell ) ; } }


signature:
public class ConfigurationUtility { /** * Builds the cell comment fromalias .
 * @ param tieCommandAliasList the tie command alias list
 * @ param cell the cell */
private static void buildCellCommentFromalias ( List < TieCommandAlias > tieCommandAliasList , Cell cell ) { } }

implementation: String value = CellUtility . getCellValueWithoutFormat ( cell ) ; if ( ( value != null ) && ( ! value . isEmpty ( ) ) ) { for ( TieCommandAlias alias : tieCommandAliasList ) { Matcher matcher = alias . getPattern ( ) . matcher ( value ) ; if ( matcher . find ( ) ) { CellUtility . createOrInsertComment ( cell , alias . getCommand ( ) ) ; if ( alias . isRemove ( ) ) { CellUtility . setCellValue ( cell , ParserUtility . removeCharsFromString ( value , matcher . start ( ) , matcher . end ( ) ) ) ; } } } }


signature:
public class ConfigurationHandler { /** * Builds the configuration .
 * @ return the map */
public final Map < String , SheetConfiguration > buildConfiguration ( ) { } }

implementation:
Map < String , SheetConfiguration > sheetConfigMap = new LinkedHashMap < > ( ) ; // in buildsheet , it ' s possible to add sheets in workbook .
// so cache the sheetname first here .
List < String > sheetNames = new ArrayList < > ( ) ; String sname ; for ( int i = 0 ; i < parent . getWb ( ) . getNumberOfSheets ( ) ; i ++ ) { sname = parent . getWb ( ) . getSheetName ( i ) ; if ( ! sname . startsWith ( org . tiefaces . common . TieConstants . COPY_SHEET_PREFIX ) ) { sheetNames . add ( sname ) ; } } for ( String sheetName : sheetNames ) { Sheet sheet = parent . getWb ( ) . getSheet ( sheetName ) ; ConfigurationUtility . buildSheetCommentFromAlias ( sheet , parent . getTieCommandAliasList ( ) ) ; buildSheet ( sheet , sheetConfigMap , parent . getCellAttributesMap ( ) ) ; } return sheetConfigMap ;


signature:
public class ConfigurationHandler { /** * Gets the sheet configuration .
 * @ param sheet
 * the sheet
 * @ param formName
 * the form name
 * @ param sheetRightCol
 * the sheet right col
 * @ return the sheet configuration */
private SheetConfiguration getSheetConfiguration ( final Sheet sheet , final String formName , final int sheetRightCol ) { } }

implementation:
SheetConfiguration sheetConfig = new SheetConfiguration ( ) ; sheetConfig . setFormName ( formName ) ; sheetConfig . setSheetName ( sheet . getSheetName ( ) ) ; int leftCol = sheet . getLeftCol ( ) ; int lastRow = sheet . getLastRowNum ( ) ; int firstRow = sheet . getFirstRowNum ( ) ; int rightCol = 0 ; int maxRow = 0 ; for ( Row row : sheet ) { if ( row . getRowNum ( ) > TieConstants . TIE_WEB_SHEET_MAX_ROWS ) { break ; } maxRow = row . getRowNum ( ) ; int firstCellNum = row . getFirstCellNum ( ) ; if ( firstCellNum >= 0 && firstCellNum < leftCol ) { leftCol = firstCellNum ; } if ( ( row . getLastCellNum ( ) - 1 ) > rightCol ) { int verifiedcol = verifyLastCell ( row , rightCol , sheetRightCol ) ; if ( verifiedcol > rightCol ) { rightCol = verifiedcol ; } } } if ( maxRow < lastRow ) { lastRow = maxRow ; } // header range row set to 0 while column set to first column to
// max
// column ( FF ) e . g . $ A $ 0 : $ FF $ 0
String tempStr = TieConstants . CELL_ADDR_PRE_FIX + WebSheetUtility . getExcelColumnName ( leftCol ) + TieConstants . CELL_ADDR_PRE_FIX + "0 : " + TieConstants . CELL_ADDR_PRE_FIX + WebSheetUtility . getExcelColumnName ( rightCol ) + TieConstants . CELL_ADDR_PRE_FIX + "0" ; sheetConfig . setFormHeaderRange ( tempStr ) ; sheetConfig . setHeaderCellRange ( new CellRange ( tempStr ) ) ; // body range row set to first row to last row while column set
// to
// first column to max column ( FF ) e . g . $ A $ 1 : $ FF $ 1000
tempStr = TieConstants . CELL_ADDR_PRE_FIX + WebSheetUtility . getExcelColumnName ( leftCol ) + TieConstants . CELL_ADDR_PRE_FIX + ( firstRow + 1 ) + " : " + TieConstants . CELL_ADDR_PRE_FIX + WebSheetUtility . getExcelColumnName ( rightCol ) + TieConstants . CELL_ADDR_PRE_FIX + ( lastRow + 1 ) ; sheetConfig . setFormBodyRange ( tempStr ) ; sheetConfig . setBodyCellRange ( new CellRange ( tempStr ) ) ; sheetConfig . setFormBodyType ( org . tiefaces . common . TieConstants . FORM_TYPE_FREE ) ; sheetConfig . setCellFormAttributes ( new HashMap < String , List < CellFormAttributes > > ( ) ) ; // check it ' s a hidden sheet
int sheetIndex = parent . getWb ( ) . getSheetIndex ( sheet ) ; if ( parent . getWb ( ) . isSheetHidden ( sheetIndex ) || parent . getWb ( ) . isSheetVeryHidden ( sheetIndex ) ) { sheetConfig . setHidden ( true ) ; } return sheetConfig ;


signature:
public class ConfigurationHandler { /** * Builds the form command from sheet config .
 * @ param sheetConfig
 * the sheet config
 * @ param sheet
 * the sheet
 * @ return the form command */
private FormCommand buildFormCommandFromSheetConfig ( final SheetConfiguration sheetConfig , final Sheet sheet ) { } }

implementation: int firstRow = sheetConfig . getBodyCellRange ( ) . getTopRow ( ) ; int leftCol = sheetConfig . getBodyCellRange ( ) . getLeftCol ( ) ; int rightCol = sheetConfig . getBodyCellRange ( ) . getRightCol ( ) ; int lastRow = sheetConfig . getBodyCellRange ( ) . getBottomRow ( ) ; Cell firstCell = sheet . getRow ( firstRow ) . getCell ( leftCol , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; FormCommand fcommand = new FormCommand ( ) ; fcommand . setCommandTypeName ( TieConstants . COMMAND_FORM ) ; if ( sheetConfig . isHidden ( ) ) { fcommand . setHidden ( TieConstants . TRUE_STRING ) ; } else { fcommand . setHidden ( TieConstants . FALSE_STRING ) ; } fcommand . setName ( sheetConfig . getFormName ( ) ) ; fcommand . getConfigRange ( ) . setFirstRowRef ( firstCell , true ) ; fcommand . getConfigRange ( ) . setLastRowPlusRef ( sheet , rightCol , lastRow , true ) ; fcommand . setHeaderLength ( "0" ) ; fcommand . setFooterLength ( "0" ) ; fcommand . setLength ( Integer . toString ( lastRow - firstRow + 1 ) ) ; return fcommand ;


signature:
public class ConfigurationHandler { /** * check last column . if it ' s blank then treat it as null cell .
 * @ param row
 * row object .
 * @ param stoppoint
 * the left cell we want to stop check .
 * @ param sheetRightCol
 * the sheet right col
 * @ return integer . the last column without blank cell . */
private int verifyLastCell ( final Row row , final int stoppoint , final int sheetRightCol ) { } }

implementation: int lastCol = sheetRightCol ; int col ; for ( col = lastCol ; col >= stoppoint ; col -- ) { Cell cell = row . getCell ( col ) ; if ( ( cell != null ) && ( cell . getCellTypeEnum ( ) != CellType . BLANK ) ) { break ; } } return col ;


signature:
public class ConfigurationHandler { /** * build a sheet for configuration map .
 * @ param sheet
 * sheet .
 * @ param sheetConfigMap
 * sheetConfiguration map .
 * @ param cellAttributesMap
 * the cell attributes map */
public final void buildSheet ( final Sheet sheet , final Map < String , SheetConfiguration > sheetConfigMap , final CellAttributesMap cellAttributesMap ) { } }

implementation:
if ( ( sheet . getLastRowNum ( ) <= 0 ) && ( sheet . getRow ( 0 ) == null ) ) { // this is a empty sheet . skip it .
return ; } checkAndRepairLastRow ( sheet ) ; int sheetRightCol = WebSheetUtility . getSheetRightCol ( sheet ) ; List < ConfigCommand > commandList = buildCommandListFromSheetComment ( ( XSSFSheet ) sheet , sheetRightCol , cellAttributesMap ) ; boolean hasEachCommand = hasEachCommandInTheList ( commandList ) ; List < String > formList = new ArrayList < > ( ) ; buildSheetConfigMapFromFormCommand ( sheet , sheetConfigMap , commandList , formList , sheetRightCol ) ; // match parent command
matchParentCommand ( commandList ) ; // setup save attrs in hidden column in the sheet .
// loop command list again to assemble other command list into sheet
// configuration
matchSheetConfigForm ( sheetConfigMap , commandList , formList ) ; initTemplateForCommand ( sheet , sheetConfigMap , formList , hasEachCommand ) ;


signature:
public class ConfigurationHandler { /** * check and repair the sheet ' s lastrow . If the row is blank then remove it .
 * @ param sheet
 * the sheet */
private final void checkAndRepairLastRow ( final Sheet sheet ) { } }

implementation:
// repair last row if it ' s inserted in the configuration generation
Row lastrow = sheet . getRow ( sheet . getLastRowNum ( ) ) ; // if it ' s lastrow and all the cells are blank . then remove the lastrow .
if ( lastrow != null ) { for ( Cell cell : lastrow ) { if ( ( cell . getCellTypeEnum ( ) != CellType . _NONE ) && ( cell . getCellTypeEnum ( ) != CellType . BLANK ) ) { return ; } } sheet . removeRow ( lastrow ) ; }


signature:
public class ConfigurationHandler { /** * Initialize template for command to use . e . g . set origin row number and copy
 * template if there ' s each command . create missing row as row require
 * sequenced .
 * @ param sheet
 * sheet .
 * @ param sheetConfigMap
 * sheet config map .
 * @ param formList
 * list of form .
 * @ param hasEachCommand
 * whether has each command . */
private void initTemplateForCommand ( final Sheet sheet , final Map < String , SheetConfiguration > sheetConfigMap , final List < String > formList , final boolean hasEachCommand ) { } }

implementation: for ( String formname : formList ) { SheetConfiguration sheetConfig = sheetConfigMap . get ( formname ) ; CellRange range = sheetConfig . getBodyCellRange ( ) ; for ( int index = range . getTopRow ( ) ; index <= range . getBottomRow ( ) ; index ++ ) { Row row = sheet . getRow ( index ) ; if ( row == null ) { row = sheet . createRow ( index ) ; } if ( hasEachCommand ) { ConfigurationUtility . setOriginalRowNumInHiddenColumn ( row , index ) ; } } } if ( hasEachCommand ) { copyTemplateForTieCommands ( sheet ) ; }


signature:
public class ConfigurationHandler { /** * build command list from comments . after transfer the comment to command ,
 * remove it from comments .
 * @ param sheet
 * sheet .
 * @ param sheetRightCol
 * the sheet right col
 * @ param cellAttributesMap
 * the cell attributes map
 * @ return command list . */
private List < ConfigCommand > buildCommandListFromSheetComment ( final XSSFSheet sheet , final int sheetRightCol , final CellAttributesMap cellAttributesMap ) { } }

implementation:
List < ConfigCommand > commandList = new ArrayList < > ( ) ; // if skip then return empty list .
if ( parent . isSkipConfiguration ( ) ) { return commandList ; } Map < CellAddress , ? extends Comment > comments = null ; try { // due to a poi bug . null exception throwed if no comments in the
// sheet .
comments = sheet . getCellComments ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "Null exception throwed when no comment exists: " + ex . getLocalizedMessage ( ) , ex ) ; } if ( comments == null ) { return commandList ; } // not sure the map is sorted . So use tree map to sort it .
SortedSet < CellAddress > keys = new TreeSet < > ( comments . keySet ( ) ) ; // go through each comments
// if found tie command then transfer it to list also remove from
// comments .
for ( CellAddress key : keys ) { Cell cell = sheet . getRow ( key . getRow ( ) ) . getCell ( key . getColumn ( ) , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; buildCommandList ( sheet , sheetRightCol , cell , commandList , cellAttributesMap ) ; } return commandList ;


signature:
public class ConfigurationHandler { /** * build top level configuration map from command list . User can either put
 * tie : form command in the comments ( which will transfer to sheetConfig ) , Or
 * just ignore it , then use whole sheet as one form .
 * @ param sheet
 * sheet .
 * @ param sheetConfigMap
 * sheetConfigMap .
 * @ param commandList
 * command list .
 * @ param formList
 * form list .
 * @ param sheetRightCol
 * the sheet right col */
private void buildSheetConfigMapFromFormCommand ( final Sheet sheet , final Map < String , SheetConfiguration > sheetConfigMap , final List < ConfigCommand > commandList , final List < String > formList , final int sheetRightCol ) { } }

implementation:
boolean foundForm = false ; int minRowNum = sheet . getLastRowNum ( ) ; int maxRowNum = sheet . getFirstRowNum ( ) ; for ( Command command : commandList ) { // check whether is form command
if ( command . getCommandTypeName ( ) . equalsIgnoreCase ( TieConstants . COMMAND_FORM ) ) { foundForm = true ; FormCommand fcommand = ( FormCommand ) command ; sheetConfigMap . put ( fcommand . getName ( ) , getSheetConfigurationFromConfigCommand ( sheet , fcommand , sheetRightCol ) ) ; formList . add ( fcommand . getName ( ) ) ; if ( fcommand . getTopRow ( ) < minRowNum ) { minRowNum = fcommand . getTopRow ( ) ; } if ( fcommand . getLastRow ( ) > maxRowNum ) { maxRowNum = fcommand . getLastRow ( ) ; } } } // if no form found , then use the whole sheet as form
if ( ! foundForm ) { WebSheetUtility . clearHiddenColumns ( sheet ) ; String formName = sheet . getSheetName ( ) ; SheetConfiguration sheetConfig = getSheetConfiguration ( sheet , formName , sheetRightCol ) ; FormCommand fcommand = buildFormCommandFromSheetConfig ( sheetConfig , sheet ) ; commandList . add ( fcommand ) ; sheetConfig . setFormCommand ( fcommand ) ; sheetConfigMap . put ( formName , sheetConfig ) ; formList . add ( formName ) ; minRowNum = sheet . getFirstRowNum ( ) ; maxRowNum = sheet . getLastRowNum ( ) ; } // if skip config then return .
if ( parent . isSkipConfiguration ( ) ) { return ; } SaveAttrsUtility . setSaveAttrsForSheet ( sheet , minRowNum , maxRowNum , parent . getCellAttributesMap ( ) . getTemplateCommentMap ( ) . get ( TieConstants . SAVE_COMMENT_KEY_IN_MAP ) ) ;


signature:
public class ConfigurationHandler { /** * Set up parent attribute for each command ( exclude form command ) . The top
 * level commands have no parent .
 * @ param commandList
 * the command list */
private void matchParentCommand ( final List < ConfigCommand > commandList ) { } }

implementation: if ( commandList == null ) { return ; } for ( int i = 0 ; i < commandList . size ( ) ; i ++ ) { ConfigCommand child = commandList . get ( i ) ; if ( ! child . getCommandTypeName ( ) . equalsIgnoreCase ( TieConstants . COMMAND_FORM ) ) { setParentForChildCommand ( commandList , i , child ) ; } }


signature:
public class ConfigurationHandler { /** * Sets the parent for child command .
 * @ param commandList
 * the command list
 * @ param i
 * the i
 * @ param child
 * the child */
private void setParentForChildCommand ( final List < ConfigCommand > commandList , final int i , final ConfigCommand child ) { } }

implementation: int matchIndex = - 1 ; ConfigRange matchRange = null ; for ( int j = 0 ; j < commandList . size ( ) ; j ++ ) { if ( j != i ) { Command commandParent = commandList . get ( j ) ; if ( ! commandParent . getCommandTypeName ( ) . equalsIgnoreCase ( TieConstants . COMMAND_FORM ) && WebSheetUtility . insideRange ( child . getConfigRange ( ) , commandParent . getConfigRange ( ) ) && ( ( matchRange == null ) || ( WebSheetUtility . insideRange ( commandParent . getConfigRange ( ) , matchRange ) ) ) ) { matchRange = commandParent . getConfigRange ( ) ; matchIndex = j ; } } } if ( matchIndex >= 0 ) { commandList . get ( matchIndex ) . getConfigRange ( ) . addCommand ( child ) ; child . setParentFound ( true ) ; }


signature:
public class ConfigurationHandler { /** * check whether contain each command in the list .
 * @ param commandList
 * command list .
 * @ return true if contain each command . */
private boolean hasEachCommandInTheList ( final List < ConfigCommand > commandList ) { } }

implementation: if ( commandList != null ) { for ( ConfigCommand command : commandList ) { if ( command . getCommandTypeName ( ) . equalsIgnoreCase ( TieConstants . COMMAND_EACH ) ) { return true ; } } } return false ;


signature:
public class ConfigurationHandler { /** * Assemble top level command to sheetConfiguration ( form ) . top level commands
 * are those haven ' t matched from matchParentCommand function .
 * @ param sheetConfigMap
 * sheet configuration map .
 * @ param commandList
 * command list .
 * @ param formList
 * form list . */
private void matchSheetConfigForm ( final Map < String , SheetConfiguration > sheetConfigMap , final List < ConfigCommand > commandList , final List < String > formList ) { } }

implementation:
for ( ConfigCommand command : commandList ) { // check weather it ' s form command
if ( ! command . getCommandTypeName ( ) . equalsIgnoreCase ( TieConstants . COMMAND_FORM ) && ( ! command . isParentFound ( ) ) ) { matchCommandToSheetConfigForm ( sheetConfigMap , formList , command ) ; } }


signature:
public class ConfigurationHandler { /** * Match command to sheet config form .
 * @ param sheetConfigMap
 * the sheet config map
 * @ param formList
 * the form list
 * @ param command
 * the command */
private void matchCommandToSheetConfigForm ( final Map < String , SheetConfiguration > sheetConfigMap , final List < String > formList , final ConfigCommand command ) { } }

implementation: for ( String formname : formList ) { SheetConfiguration sheetConfig = sheetConfigMap . get ( formname ) ; if ( WebSheetUtility . insideRange ( command . getConfigRange ( ) , sheetConfig . getFormCommand ( ) . getConfigRange ( ) ) ) { sheetConfig . getFormCommand ( ) . getConfigRange ( ) . addCommand ( command ) ; break ; } }


signature:
public class ConfigurationHandler { /** * Copy the each command area to seperated sheet . As it will be used for
 * iteration .
 * @ param sheet
 * sheet . */
private void copyTemplateForTieCommands ( final Sheet sheet ) { } }

implementation:
// if skip configuration . then return .
if ( parent . isSkipConfiguration ( ) ) { return ; } Workbook wb = sheet . getWorkbook ( ) ; String copyName = TieConstants . COPY_SHEET_PREFIX + sheet . getSheetName ( ) ; if ( wb . getSheet ( copyName ) == null ) { Sheet newSheet = wb . cloneSheet ( wb . getSheetIndex ( sheet ) ) ; int sheetIndex = wb . getSheetIndex ( newSheet ) ; wb . setSheetName ( sheetIndex , copyName ) ; wb . setSheetHidden ( sheetIndex , Workbook . SHEET_STATE_VERY_HIDDEN ) ; }


signature:
public class ConfigurationHandler { /** * build command list from comment .
 * @ param sheet
 * sheet .
 * @ param sheetRightCol
 * sheet right column .
 * @ param cell
 * the cell
 * @ param cList
 * command list .
 * @ param cellAttributesMap
 * the cell attributes map
 * @ return command list . */
private List < ConfigCommand > buildCommandList ( final Sheet sheet , final int sheetRightCol , final Cell cell , final List < ConfigCommand > cList , final CellAttributesMap cellAttributesMap ) { } }

implementation:
Comment comment = cell . getCellComment ( ) ; String text = comment . getString ( ) . getString ( ) ; String [ ] commentLines = text . split ( "\\n" ) ; StringBuilder newComment = new StringBuilder ( ) ; boolean changed = false ; for ( String commentLine : commentLines ) { String line = commentLine . trim ( ) ; if ( ParserUtility . isCommandString ( line ) ) { processCommandLine ( sheet , cell , line , cList , sheetRightCol ) ; changed = true ; } else if ( ParserUtility . isEmptyMethodString ( line ) || ParserUtility . isMethodString ( line ) ) { processMethodLine ( cell , line , cellAttributesMap ) ; changed = true ; } else { if ( newComment . length ( ) > 0 ) { newComment . append ( "\\n" + commentLine ) ; } else { newComment . append ( commentLine ) ; } } } if ( ! changed ) { moveCommentToMap ( cell , text , cellAttributesMap . getTemplateCommentMap ( ) , true ) ; } else { // reset comment string if changed
if ( newComment . length ( ) > 0 ) { moveCommentToMap ( cell , newComment . toString ( ) , cellAttributesMap . getTemplateCommentMap ( ) , true ) ; CreationHelper factory = sheet . getWorkbook ( ) . getCreationHelper ( ) ; RichTextString str = factory . createRichTextString ( newComment . toString ( ) ) ; comment . setString ( str ) ; } else { // remove cell comment if new comment become empty .
cell . removeCellComment ( ) ; } } return cList ;


signature:
public class ConfigurationHandler { /** * Process method line .
 * @ param cell
 * the cell
 * @ param line
 * the line
 * @ param cellAttributesMap
 * the cell attributes map */
private void processMethodLine ( final Cell cell , final String line , final CellAttributesMap cellAttributesMap ) { } }

implementation: if ( ParserUtility . isWidgetMethodString ( line ) ) { ParserUtility . parseWidgetAttributes ( cell , line , cellAttributesMap ) ; } else if ( ParserUtility . isValidateMethodString ( line ) ) { ParserUtility . parseValidateAttributes ( cell , line , cellAttributesMap ) ; } else { moveCommentToMap ( cell , line , cellAttributesMap . getTemplateCommentMap ( ) , false ) ; }


signature:
public class ConfigurationHandler { /** * Process command line .
 * @ param sheet
 * the sheet
 * @ param cell
 * the cell
 * @ param line
 * the line
 * @ param cList
 * the c list
 * @ param sheetRightCol
 * the sheet right col */
private void processCommandLine ( final Sheet sheet , final Cell cell , final String line , final List < ConfigCommand > cList , final int sheetRightCol ) { } }

implementation: int nameEndIndex = line . indexOf ( TieConstants . ATTR_PREFIX , TieConstants . COMMAND_PREFIX . length ( ) ) ; if ( nameEndIndex < 0 ) { String errMsg = "Failed to parse command line [" + line + "]. Expected '" + TieConstants . ATTR_PREFIX + "' symbol." ; LOG . severe ( errMsg ) ; throw new IllegalStateException ( errMsg ) ; } String commandName = line . substring ( TieConstants . COMMAND_PREFIX . length ( ) , nameEndIndex ) . trim ( ) ; Map < String , String > attrMap = buildAttrMap ( line , nameEndIndex ) ; ConfigCommand configCommand = createConfigCommand ( sheet , cell , sheetRightCol , commandName , attrMap ) ; if ( configCommand != null ) { cList . add ( configCommand ) ; }


signature:
public class ConfigurationHandler { /** * change the comment .
 * @ param cell
 * the cell
 * @ param newComment
 * updated comment .
 * @ param sheetCommentMap
 * the sheet comment map
 * @ param normalComment
 * the normal comment */
private void moveCommentToMap ( final Cell cell , final String newComment , final Map < String , Map < String , String > > sheetCommentMap , final boolean normalComment ) { } }

implementation: String cellKey = cell . getSheet ( ) . getSheetName ( ) + "!$" + cell . getColumnIndex ( ) + "$" + cell . getRowIndex ( ) ; ParserUtility . parseCommentToMap ( cellKey , newComment , sheetCommentMap , normalComment ) ;


signature:
public class ConfigurationHandler { /** * create configuration command .
 * @ param sheet
 * sheet .
 * @ param firstCell
 * first cell .
 * @ param sheetRightCol
 * sheet right col .
 * @ param commandName
 * command name .
 * @ param attrMap
 * attibutes map .
 * @ return configuration command . */
private ConfigCommand createConfigCommand ( final Sheet sheet , final Cell firstCell , final int sheetRightCol , final String commandName , final Map < String , String > attrMap ) { } }

implementation: @ SuppressWarnings ( "rawtypes" ) Class clas = commandMap . get ( commandName ) ; if ( clas == null ) { LOG . log ( Level . WARNING , "Cannot find command class for {} " , commandName ) ; return null ; } try { ConfigCommand command = ( ConfigCommand ) clas . newInstance ( ) ; command . setCommandTypeName ( commandName ) ; for ( Map . Entry < String , String > attr : attrMap . entrySet ( ) ) { WebSheetUtility . setObjectProperty ( command , attr . getKey ( ) , attr . getValue ( ) , true ) ; } command . getConfigRange ( ) . setFirstRowRef ( firstCell , true ) ; command . getConfigRange ( ) . setLastRowPlusRef ( sheet , sheetRightCol , command . getLastRow ( ) , true ) ; return command ; } catch ( Exception e ) { LOG . log ( Level . WARNING , "Failed to initialize command class " + clas . getName ( ) + " for command" + commandName , e ) ; return null ; }


signature:
public class ConfigurationHandler { /** * Build the attributes map .
 * @ param commandLine
 * command line from comment .
 * @ param nameEndIndex
 * index of command name ' s end .
 * @ return attributes map . */
private Map < String , String > buildAttrMap ( final String commandLine , final int nameEndIndex ) { } }

implementation: int paramsEndIndex = commandLine . lastIndexOf ( TieConstants . ATTR_SUFFIX ) ; if ( paramsEndIndex < 0 ) { String errMsg = "Failed to parse command line [" + commandLine + "]. Expected '" + TieConstants . ATTR_SUFFIX + "' symbol." ; throw new IllegalArgumentException ( errMsg ) ; } String attrString = commandLine . substring ( nameEndIndex + 1 , paramsEndIndex ) . trim ( ) ; return ParserUtility . parseCommandAttributes ( attrString ) ;


signature:
public class ConfigurationHandler { /** * Create sheet configuration from form command .
 * @ param sheet
 * sheet .
 * @ param fcommand
 * form command .
 * @ param sheetRightCol
 * the sheet right col
 * @ return sheet configuration . */
private SheetConfiguration getSheetConfigurationFromConfigCommand ( final Sheet sheet , final FormCommand fcommand , final int sheetRightCol ) { } }

implementation:
SheetConfiguration sheetConfig = new SheetConfiguration ( ) ; sheetConfig . setFormName ( fcommand . getName ( ) ) ; sheetConfig . setSheetName ( sheet . getSheetName ( ) ) ; int leftCol = fcommand . getLeftCol ( ) ; int lastRow = fcommand . getLastRow ( ) ; int rightCol = 0 ; int maxRow = 0 ; for ( Row row : sheet ) { if ( row . getRowNum ( ) > TieConstants . TIE_WEB_SHEET_MAX_ROWS ) { break ; } maxRow = row . getRowNum ( ) ; if ( ( row . getLastCellNum ( ) - 1 ) > rightCol ) { int verifiedcol = verifyLastCell ( row , rightCol , sheetRightCol ) ; if ( verifiedcol > rightCol ) { rightCol = verifiedcol ; } } } if ( maxRow < lastRow ) { lastRow = maxRow ; } // header range row set to 0 while column set to first column to
// max
// column ( FF ) e . g . $ A $ 0 : $ FF $ 0
setHeaderOfSheetConfiguration ( fcommand , sheetConfig , leftCol , rightCol ) ; // body range row set to first row to last row while column set
// to
// first column to max column ( FF ) e . g . $ A $ 1 : $ FF $ 1000
setBodyOfSheetConfiguration ( fcommand , sheetConfig , leftCol , lastRow , rightCol ) ; // footer range row set to 0 while column set to first column to
// max
// column ( FF ) e . g . $ A $ 0 : $ FF $ 0
setFooterOfSheetConfiguration ( fcommand , sheetConfig , leftCol , rightCol ) ; String hidden = fcommand . getHidden ( ) ; if ( ( hidden != null ) && ( Boolean . parseBoolean ( hidden ) ) ) { sheetConfig . setHidden ( true ) ; } String fixedWidthStyle = fcommand . getFixedWidthStyle ( ) ; if ( ( fixedWidthStyle != null ) && ( Boolean . parseBoolean ( fixedWidthStyle ) ) ) { sheetConfig . setFixedWidthStyle ( true ) ; } sheetConfig . setFormCommand ( fcommand ) ; return sheetConfig ;


signature:
public class ConfigurationHandler { /** * Sets the footer of sheet configuration .
 * @ param fcommand
 * the fcommand
 * @ param sheetConfig
 * the sheet config
 * @ param leftCol
 * the left col
 * @ param rightCol
 * the right col */
private void setFooterOfSheetConfiguration ( final FormCommand fcommand , final SheetConfiguration sheetConfig , final int leftCol , final int rightCol ) { } }

implementation: String tempStr ; if ( fcommand . calcFooterLength ( ) == 0 ) { tempStr = CellUtility . getCellIndexLetterKey ( leftCol , 0 ) + " : " + CellUtility . getCellIndexLetterKey ( rightCol , 0 ) ; } else { tempStr = CellUtility . getCellIndexLetterKey ( leftCol , fcommand . getTopRow ( ) + fcommand . calcHeaderLength ( ) + fcommand . calcBodyLength ( ) ) + " : " + CellUtility . getCellIndexLetterKey ( rightCol , fcommand . getTopRow ( ) + fcommand . calcHeaderLength ( ) ) ; } sheetConfig . setFormFooterRange ( tempStr ) ; sheetConfig . setFooterCellRange ( new CellRange ( tempStr ) ) ;


signature:
public class ConfigurationHandler { /** * Sets the body of sheet configuration .
 * @ param fcommand
 * the fcommand
 * @ param sheetConfig
 * the sheet config
 * @ param leftCol
 * the left col
 * @ param lastRow
 * the last row
 * @ param rightCol
 * the right col */
private void setBodyOfSheetConfiguration ( final FormCommand fcommand , final SheetConfiguration sheetConfig , final int leftCol , final int lastRow , final int rightCol ) { } }

implementation: String tempStr ; tempStr = CellUtility . getCellIndexLetterKey ( leftCol , fcommand . getTopRow ( ) + fcommand . calcHeaderLength ( ) + 1 ) + " : " + CellUtility . getCellIndexLetterKey ( rightCol , lastRow + 1 ) ; sheetConfig . setFormBodyRange ( tempStr ) ; sheetConfig . setBodyCellRange ( new CellRange ( tempStr ) ) ; sheetConfig . setFormBodyType ( TieConstants . FORM_TYPE_FREE ) ; sheetConfig . setCellFormAttributes ( new HashMap < String , List < CellFormAttributes > > ( ) ) ;


signature:
public class ConfigurationHandler { /** * Sets the header of sheet configuration .
 * @ param fcommand
 * the fcommand
 * @ param sheetConfig
 * the sheet config
 * @ param leftCol
 * the left col
 * @ param rightCol
 * the right col */
private void setHeaderOfSheetConfiguration ( final FormCommand fcommand , final SheetConfiguration sheetConfig , final int leftCol , final int rightCol ) { } }

implementation: String tempStr ; if ( fcommand . calcHeaderLength ( ) == 0 ) { tempStr = CellUtility . getCellIndexLetterKey ( leftCol , 0 ) + " : " + CellUtility . getCellIndexLetterKey ( rightCol , 0 ) ; } else { tempStr = CellUtility . getCellIndexLetterKey ( leftCol , fcommand . getTopRow ( ) + 1 ) + " : " + CellUtility . getCellIndexLetterKey ( rightCol , fcommand . getTopRow ( ) + fcommand . calcHeaderLength ( ) ) ; } sheetConfig . setFormHeaderRange ( tempStr ) ; sheetConfig . setHeaderCellRange ( new CellRange ( tempStr ) ) ;


signature:
public class CommandUtility { /** * Adds the row .
 * @ param configBuildRef
 * the config build ref
 * @ param rowIndex
 * the row index
 * @ param dataContext
 * the data context
 * @ return the int */
@ SuppressWarnings ( { } }

implementation:
"rawtypes" } ) public static int addRow ( final ConfigBuildRef configBuildRef , final int rowIndex , final Map < String , Object > dataContext ) { // replace the lastCollection .
// since here ' s add one row .
// Then we should insert one empty object in the list .
// The collection must be a list to support add / delete function .
// and the object must support empty constructor .
String fullName = ConfigurationUtility . getFullNameFromRow ( configBuildRef . getSheet ( ) . getRow ( rowIndex ) ) ; String [ ] parts = fullName . split ( ":" ) ; configBuildRef . getCellHelper ( ) . restoreDataContext ( fullName ) ; CollectionObject collect = configBuildRef . getCellHelper ( ) . getLastCollect ( fullName ) ; Collection lastCollection = collect . getLastCollection ( ) ; int lastCollectionIndex = collect . getLastCollectionIndex ( ) ; EachCommand eachCommand = collect . getEachCommand ( ) ; if ( lastCollectionIndex < 0 ) { // no each command in the loop .
throw new AddRowException ( "No each command found." ) ; } String unitFullName = CommandUtility . insertEmptyObjectInContext ( fullName , lastCollection , eachCommand , lastCollectionIndex , dataContext ) ; RowsMapping unitRowsMapping = new RowsMapping ( ) ; ConfigRangeAttrs savedRangeAttrs = configBuildRef . getShiftMap ( ) . get ( fullName ) ; int insertPosition = savedRangeAttrs . getFirstRowRef ( ) . getRowIndex ( ) + savedRangeAttrs . getFinalLength ( ) ; configBuildRef . setInsertPosition ( insertPosition ) ; CommandUtility . insertEachTemplate ( eachCommand . getConfigRange ( ) , configBuildRef , lastCollectionIndex + 1 , insertPosition , unitRowsMapping ) ; ConfigRange currentRange = ConfigurationUtility . buildCurrentRange ( eachCommand . getConfigRange ( ) , configBuildRef . getSheet ( ) , insertPosition ) ; List < RowsMapping > currentRowsMappingList = ConfigurationUtility . findParentRowsMappingFromShiftMap ( parts , configBuildRef . getShiftMap ( ) ) ; currentRowsMappingList . add ( unitRowsMapping ) ; currentRange . getAttrs ( ) . setAllowAdd ( true ) ; configBuildRef . setBodyAllowAdd ( true ) ; // reverse order of changeMap .
Map < String , String > changeMap = new TreeMap < > ( Collections . reverseOrder ( ) ) ; ConfigurationUtility . changeIndexNumberInHiddenColumn ( configBuildRef , currentRange . getAttrs ( ) . getLastRowPlusRef ( ) . getRowIndex ( ) , fullName , changeMap , 1 ) ; ConfigurationUtility . changeIndexNumberInShiftMap ( configBuildRef . getShiftMap ( ) , changeMap ) ; configBuildRef . putShiftAttrs ( unitFullName , currentRange . getAttrs ( ) , unitRowsMapping ) ; int length = currentRange . buildAt ( unitFullName , configBuildRef , insertPosition , dataContext , currentRowsMappingList ) ; currentRange . getAttrs ( ) . setFinalLength ( length ) ; ConfigurationUtility . reBuildUpperLevelFormula ( configBuildRef , fullName ) ; ConfigurationUtility . changeUpperLevelFinalLength ( configBuildRef . getShiftMap ( ) , fullName , length ) ; currentRowsMappingList . remove ( unitRowsMapping ) ; dataContext . remove ( eachCommand . getVar ( ) ) ; return length ;


signature:
public class CommandUtility { /** * Delete row .
 * @ param configBuildRef
 * the config build ref
 * @ param rowIndex
 * the row index
 * @ param dataContext
 * the data context
 * @ param sheetConfig
 * the sheet config
 * @ param bodyRows
 * the body rows
 * @ return the int
 * @ throws DeleteRowException
 * the delete row exception */
@ SuppressWarnings ( { } }

implementation:
"rawtypes" } ) public static int deleteRow ( final ConfigBuildRef configBuildRef , final int rowIndex , final Map < String , Object > dataContext , final SheetConfiguration sheetConfig , final List < FacesRow > bodyRows ) { String fullName = ConfigurationUtility . getFullNameFromRow ( configBuildRef . getSheet ( ) . getRow ( rowIndex ) ) ; configBuildRef . getCellHelper ( ) . restoreDataContext ( fullName ) ; CollectionObject collect = configBuildRef . getCellHelper ( ) . getLastCollect ( fullName ) ; Collection lastCollection = collect . getLastCollection ( ) ; int lastCollectionIndex = collect . getLastCollectionIndex ( ) ; EachCommand eachCommand = collect . getEachCommand ( ) ; if ( lastCollectionIndex < 0 ) { // no each command in the loop .
throw new DeleteRowException ( "No each command found." ) ; } if ( lastCollection . size ( ) <= 1 ) { // this is the last record and no parent left .
throw new DeleteRowException ( "Cannot delete the last record in the group." ) ; } CommandUtility . deleteObjectInContext ( lastCollection , eachCommand , lastCollectionIndex , dataContext ) ; // find range from shiftmap .
ConfigRangeAttrs currentRangeAttrs = configBuildRef . getShiftMap ( ) . get ( fullName ) ; if ( currentRangeAttrs == null ) { throw new DeleteRowException ( "Cannot find delete range." ) ; } // The lastRowRef is wrong in rangeAttrs . So use length to recalc it .
int startRow = currentRangeAttrs . getFirstRowIndex ( ) ; int length = currentRangeAttrs . getFinalLength ( ) ; int endRow = startRow + length - 1 ; List < String > removeFullNameList = findRemoveFullNameList ( configBuildRef . getSheet ( ) , startRow , endRow ) ; // remove range from shiftmap .
removeRangesFromShiftMap ( configBuildRef . getShiftMap ( ) , removeFullNameList ) ; // 1 . remove ranged rows from sheet
String var = eachCommand . getVar ( ) ; CommandUtility . removeRowsInSheet ( configBuildRef . getSheet ( ) , startRow , endRow , configBuildRef . getCachedCells ( ) ) ; // 2 . reset FacesRow row index .
CommandUtility . removeRowsInBody ( sheetConfig , bodyRows , startRow , endRow ) ; // 3 . decrease index number in hidden column
Map < String , String > changeMap = new TreeMap < > ( ) ; ConfigurationUtility . changeIndexNumberInHiddenColumn ( configBuildRef , startRow , fullName , changeMap , - 1 ) ; // 4 . decrease index number in shift map
ConfigurationUtility . changeIndexNumberInShiftMap ( configBuildRef . getShiftMap ( ) , changeMap ) ; // 5 . rebuild upper level formula
ConfigurationUtility . reBuildUpperLevelFormula ( configBuildRef , fullName ) ; // 6 . decrease upper level final length
ConfigurationUtility . changeUpperLevelFinalLength ( configBuildRef . getShiftMap ( ) , fullName , - length ) ; dataContext . remove ( var ) ; return length ;


signature:
public class CommandUtility { /** * Removes the ranges from shift map .
 * @ param shiftMap
 * the shift map
 * @ param removeFullNameList
 * the remove full name list */
private static void removeRangesFromShiftMap ( final NavigableMap < String , ConfigRangeAttrs > shiftMap , final List < String > removeFullNameList ) { } }

implementation: for ( String fname : removeFullNameList ) { shiftMap . remove ( fname ) ; }


signature:
public class CommandUtility { /** * Find remove full name list .
 * @ param sheet
 * the sheet
 * @ param startRow
 * the start row
 * @ param endRow
 * the end row
 * @ return the list */
private static List < String > findRemoveFullNameList ( final Sheet sheet , final int startRow , final int endRow ) { } }

implementation: List < String > list = new ArrayList < > ( ) ; for ( int rowIndex = startRow ; rowIndex <= endRow ; rowIndex ++ ) { String fullName = ConfigurationUtility . getFullNameFromRow ( sheet . getRow ( rowIndex ) ) ; if ( ! list . contains ( fullName ) ) { list . add ( fullName ) ; } } return list ;


signature:
public class CommandUtility { /** * Gets the each command from parts name .
 * @ param commandIndexMap
 * the command index map
 * @ param varparts
 * the varparts
 * @ return the each command from parts name */
public static EachCommand getEachCommandFromPartsName ( final Map < String , Command > commandIndexMap , final String [ ] varparts ) { } }

implementation: if ( varparts . length == TieConstants . DEFAULT_COMMAND_PART_LENGTH ) { return ( EachCommand ) commandIndexMap . get ( TieConstants . EACH_COMMAND_FULL_NAME_PREFIX + varparts [ 1 ] ) ; } return null ;


signature:
public class CommandUtility { /** * Insert empty object in context .
 * @ param fullName
 * the full name
 * @ param lastCollection
 * the last collection
 * @ param eachCommand
 * the each command
 * @ param lastCollectionIndex
 * the last collection index
 * @ param dataContext
 * the data context
 * @ return the string
 * @ throws EvaluationException
 * the evaluation exception */
@ SuppressWarnings ( { } }

implementation:
"rawtypes" , "unchecked" } ) private static String insertEmptyObjectInContext ( final String fullName , final Collection lastCollection , final EachCommand eachCommand , final int lastCollectionIndex , final Map < String , Object > dataContext ) { if ( ! ( lastCollection instanceof List ) ) { throw new EvaluationException ( "Collection must be list in order to insert/delete." ) ; } List collectionList = ( List ) lastCollection ; // the object must support empty constructor .
Object currentObj = collectionList . get ( lastCollectionIndex ) ; Object insertObj ; try { insertObj = currentObj . getClass ( ) . newInstance ( ) ; collectionList . add ( lastCollectionIndex + 1 , insertObj ) ; dataContext . put ( eachCommand . getVar ( ) , insertObj ) ; return fullName . substring ( 0 , fullName . lastIndexOf ( '.' ) + 1 ) + ( lastCollectionIndex + 1 ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new EvaluationException ( e ) ; }


signature:
public class CommandUtility { /** * Delete object in context .
 * @ param lastCollection
 * the last collection
 * @ param eachCommand
 * the each command
 * @ param lastCollectionIndex
 * the last collection index
 * @ param dataContext
 * the data context */
@ SuppressWarnings ( { } }

implementation:
"rawtypes" } ) private static void deleteObjectInContext ( final Collection lastCollection , final EachCommand eachCommand , final int lastCollectionIndex , final Map < String , Object > dataContext ) { if ( ! ( lastCollection instanceof List ) ) { throw new EvaluationException ( eachCommand . getVar ( ) + TieConstants . EACH_COMMAND_INVALID_MSG ) ; } List collectionList = ( List ) lastCollection ; // the object must support empty constructor .
collectionList . remove ( lastCollectionIndex ) ; dataContext . remove ( eachCommand . getVar ( ) ) ;


signature:
public class CommandUtility { /** * Prepare collection data in context .
 * @ param varparts
 * the varparts
 * @ param collection
 * the collection
 * @ param dataContext
 * the data context
 * @ return the int */
@ SuppressWarnings ( "rawtypes" ) public static int prepareCollectionDataInContext ( final String [ ] varparts , final Collection collection , final Map < String , Object > dataContext ) { } }

implementation: if ( varparts . length == TieConstants . DEFAULT_COMMAND_PART_LENGTH ) { int collectionIndex = Integer . parseInt ( varparts [ 2 ] ) ; Object obj = ConfigurationUtility . findItemInCollection ( collection , collectionIndex ) ; if ( obj != null ) { dataContext . put ( varparts [ 1 ] , obj ) ; return collectionIndex ; } } return - 1 ;


signature:
public class CommandUtility { /** * Index command range .
 * @ param sourceConfigRange
 * the source config range
 * @ param indexMap
 * the index map */
public static void indexCommandRange ( final ConfigRange sourceConfigRange , final Map < String , Command > indexMap ) { } }

implementation: if ( sourceConfigRange . getCommandList ( ) != null ) { for ( int i = 0 ; i < sourceConfigRange . getCommandList ( ) . size ( ) ; i ++ ) { Command command = sourceConfigRange . getCommandList ( ) . get ( i ) ; indexMap . put ( command . getCommandName ( ) , command ) ; command . getConfigRange ( ) . indexCommandRange ( indexMap ) ; } }


signature:
public class CommandUtility { /** * Checks if is row allow add .
 * @ param row
 * the row
 * @ param sheetConfig
 * the sheet config
 * @ return true , if is row allow add */
public static boolean isRowAllowAdd ( final Row row , final SheetConfiguration sheetConfig ) { } }

implementation: String fullName = ConfigurationUtility . getFullNameFromRow ( row ) ; if ( fullName != null ) { ConfigRangeAttrs attrs = sheetConfig . getShiftMap ( ) . get ( fullName ) ; if ( ( attrs != null ) && ( attrs . isAllowAdd ( ) ) && ( row . getRowNum ( ) == attrs . getFirstRowRef ( ) . getRowIndex ( ) ) ) { return true ; } } return false ;


signature:
public class CommandUtility { /** * Insert each template .
 * @ param sourceConfigRange
 * the source config range
 * @ param configBuildRef
 * the config build ref
 * @ param index
 * the index
 * @ param insertPosition
 * the insert position
 * @ param unitRowsMapping
 * the unit rows mapping */
public static void insertEachTemplate ( final ConfigRange sourceConfigRange , final ConfigBuildRef configBuildRef , final int index , final int insertPosition , final RowsMapping unitRowsMapping ) { } }

implementation:
int srcStartRow = sourceConfigRange . getFirstRowAddr ( ) . getRow ( ) ; int srcEndRow = sourceConfigRange . getLastRowPlusAddr ( ) . getRow ( ) - 1 ; Sheet sheet = configBuildRef . getSheet ( ) ; Workbook wb = sheet . getWorkbook ( ) ; // excel sheet name has limit 31 chars
String copyName = TieConstants . COPY_SHEET_PREFIX + sheet . getSheetName ( ) ; if ( copyName . length ( ) > TieConstants . EXCEL_SHEET_NAME_LIMIT ) { copyName = copyName . substring ( 0 , TieConstants . EXCEL_SHEET_NAME_LIMIT ) ; } Sheet srcSheet = wb . getSheet ( copyName ) ; if ( index > 0 ) { CellUtility . copyRows ( srcSheet , sheet , srcStartRow , srcEndRow , insertPosition , false , true ) ; } for ( int rowIndex = srcStartRow ; rowIndex <= srcEndRow ; rowIndex ++ ) { if ( configBuildRef . getWatchList ( ) . contains ( rowIndex ) && ( ConfigurationUtility . isStaticRow ( sourceConfigRange , rowIndex ) ) ) { unitRowsMapping . addRow ( rowIndex , sheet . getRow ( insertPosition + rowIndex - srcStartRow ) ) ; } }


signature:
public class CommandUtility { /** * Evaluate .
 * @ param context
 * the context
 * @ param cell
 * the cell
 * @ param engine
 * the engine */
@ SuppressWarnings ( "deprecation" ) public static void evaluate ( final Map < String , Object > context , final Cell cell , final ExpressionEngine engine ) { } }

implementation: if ( ( cell != null ) && ( cell . getCellTypeEnum ( ) == CellType . STRING ) ) { String strValue = cell . getStringCellValue ( ) ; if ( isUserFormula ( strValue ) ) { evaluateUserFormula ( cell , strValue ) ; } else { evaluateNormalCells ( cell , strValue , context , engine ) ; } }


signature:
public class CommandUtility { /** * Evaluate normal cells .
 * @ param cell
 * cell .
 * @ param strValue
 * string value .
 * @ param context
 * context .
 * @ param engine
 * engine . */
public static void evaluateNormalCells ( final Cell cell , final String strValue , final Map < String , Object > context , final ExpressionEngine engine ) { } }

implementation: if ( strValue . contains ( TieConstants . METHOD_PREFIX ) ) { Object evaluationResult = evaluate ( strValue , context , engine ) ; if ( evaluationResult == null ) { evaluationResult = "" ; } CellUtility . setCellValue ( cell , evaluationResult . toString ( ) ) ; createTieCell ( cell , context , engine ) ; }


signature:
public class CommandUtility { /** * Evaluate user formula .
 * @ param cell
 * the cell
 * @ param strValue
 * the str value */
private static void evaluateUserFormula ( final Cell cell , final String strValue ) { } }

implementation: String formulaStr = strValue . substring ( 2 , strValue . length ( ) - 1 ) ; if ( ( formulaStr != null ) && ( ! formulaStr . isEmpty ( ) ) ) { cell . setCellFormula ( formulaStr ) ; }


signature:
public class CommandUtility { /** * Checks if is user formula .
 * @ param str
 * the str
 * @ return true , if is user formula */
private static boolean isUserFormula ( final String str ) { } }

implementation: return str . startsWith ( TieConstants . USER_FORMULA_PREFIX ) && str . endsWith ( TieConstants . USER_FORMULA_SUFFIX ) ;


signature:
public class CommandUtility { /** * Evaluate .
 * @ param strValue
 * the str value
 * @ param context
 * the context
 * @ param engine
 * the engine
 * @ return the object */
public static Object evaluate ( final String strValue , final Map < String , Object > context , final ExpressionEngine engine ) { } }

implementation: StringBuffer sb = new StringBuffer ( ) ; int beginExpressionLength = TieConstants . METHOD_PREFIX . length ( ) ; int endExpressionLength = TieConstants . METHOD_END . length ( ) ; Matcher exprMatcher = TieConstants . EXPRESSION_NOTATION_PATTERN . matcher ( strValue ) ; String matchedString ; String expression ; Object lastMatchEvalResult = null ; int matchCount = 0 ; int endOffset = 0 ; while ( exprMatcher . find ( ) ) { endOffset = exprMatcher . end ( ) ; matchCount ++ ; matchedString = exprMatcher . group ( ) ; expression = matchedString . substring ( beginExpressionLength , matchedString . length ( ) - endExpressionLength ) ; lastMatchEvalResult = engine . evaluate ( expression , context ) ; exprMatcher . appendReplacement ( sb , Matcher . quoteReplacement ( lastMatchEvalResult != null ? lastMatchEvalResult . toString ( ) : "" ) ) ; } String lastStringResult = lastMatchEvalResult != null ? lastMatchEvalResult . toString ( ) : "" ; boolean isAppendTail = matchCount == 1 && endOffset < strValue . length ( ) ; Object evaluationResult = null ; if ( matchCount > 1 || isAppendTail ) { exprMatcher . appendTail ( sb ) ; evaluationResult = sb . toString ( ) ; } else if ( matchCount == 1 ) { if ( sb . length ( ) > lastStringResult . length ( ) ) { evaluationResult = sb . toString ( ) ; } else { evaluationResult = lastMatchEvalResult ; } } else if ( matchCount == 0 ) { evaluationResult = strValue ; } return evaluationResult ;


signature:
public class CommandUtility { /** * Creates the cell comment .
 * @ param cell
 * the cell
 * @ param newComment
 * the new comment
 * @ param finalCommentMap
 * the final comment map */
public static void createCellComment ( final Cell cell , final String newComment , final Map < Cell , String > finalCommentMap ) { } }

implementation:
// due to poi ' s bug . the comment must be set in sorted order ( row first
// then column ) ,
// otherwise poi will mess up .
// workaround solution is to save all comments into a map ,
// and output them together when download workbook .
if ( newComment != null ) { finalCommentMap . put ( cell , newComment ) ; }


signature:
public class CommandUtility { /** * evaluate boolean express .
 * @ param expEngine
 * expression engine .
 * @ param pscript
 * script .
 * @ return true ( express is true ) false ( express is false or invalid ) . */
public static boolean evalBoolExpression ( final ExpressionEngine expEngine , final String pscript ) { } }

implementation: Object result = null ; String script = "( " + pscript + " )" ; script = script . toUpperCase ( ) . replace ( "AND" , "&&" ) ; script = script . toUpperCase ( ) . replace ( "OR" , "||" ) ; try { result = expEngine . evaluate ( script ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "WebForm WebFormHelper evalBoolExpression script = " + script + "; error = " + e . getLocalizedMessage ( ) , e ) ; } if ( result != null ) { return ( ( Boolean ) result ) . booleanValue ( ) ; } else { return false ; }


signature:
public class CommandUtility { /** * Remove the rows .
 * @ param sheet
 * the sheet
 * @ param rowIndexStart
 * start row index .
 * @ param rowIndexEnd
 * end row index .
 * @ param cachedMap
 * the cached map */
public static void removeRowsInSheet ( final Sheet sheet , final int rowIndexStart , final int rowIndexEnd , final Map < Cell , String > cachedMap ) { } }

implementation:
for ( int irow = rowIndexStart ; irow <= rowIndexEnd ; irow ++ ) { removeCachedCellForRow ( sheet , irow , cachedMap ) ; } int irows = rowIndexEnd - rowIndexStart + 1 ; if ( ( irows < 1 ) || ( rowIndexStart < 0 ) ) { return ; } int lastRowNum = sheet . getLastRowNum ( ) ; if ( rowIndexEnd < lastRowNum ) { sheet . shiftRows ( rowIndexEnd + 1 , lastRowNum , - irows ) ; } if ( rowIndexEnd == lastRowNum ) { // reverse order to delete rows .
for ( int i = rowIndexEnd ; i >= rowIndexStart ; i -- ) { removeSingleRowInSheet ( sheet , rowIndexStart ) ; } }


signature:
public class CommandUtility { /** * Removes the single row in sheet .
 * @ param sheet
 * the sheet
 * @ param rowIndexStart
 * the row index start */
private static void removeSingleRowInSheet ( final Sheet sheet , final int rowIndexStart ) { } }

implementation: Row removingRow = sheet . getRow ( rowIndexStart ) ; if ( removingRow != null ) { sheet . removeRow ( removingRow ) ; }


signature:
public class CommandUtility { /** * Removes the cached cell for row .
 * @ param sheet
 * the sheet
 * @ param rowIndexStart
 * the row index start
 * @ param cachedMap
 * the cached map */
private static void removeCachedCellForRow ( final Sheet sheet , final int rowIndexStart , final Map < Cell , String > cachedMap ) { } }

implementation:
Row removingRow = sheet . getRow ( rowIndexStart ) ; if ( removingRow != null ) { // remove cached cell .
for ( Cell cell : removingRow ) { cachedMap . remove ( cell ) ; } }


signature:
public class CommandUtility { /** * Removes the rows in body .
 * @ param sheetConfig
 * the sheet config
 * @ param bodyRows
 * the body rows
 * @ param rowIndexStart
 * the row index start
 * @ param rowIndexEnd
 * the row index end */
public static void removeRowsInBody ( final SheetConfiguration sheetConfig , final List < FacesRow > bodyRows , final int rowIndexStart , final int rowIndexEnd ) { } }

implementation: int top = sheetConfig . getBodyCellRange ( ) . getTopRow ( ) ; if ( ( rowIndexEnd < rowIndexStart ) || ( rowIndexStart < top ) ) { return ; } int irows = rowIndexEnd - rowIndexStart + 1 ; for ( int rowIndex = rowIndexEnd ; rowIndex >= rowIndexStart ; rowIndex -- ) { bodyRows . remove ( rowIndex - top ) ; } for ( int irow = rowIndexStart - top ; irow < bodyRows . size ( ) ; irow ++ ) { FacesRow facesrow = bodyRows . get ( irow ) ; facesrow . setRowIndex ( facesrow . getRowIndex ( ) - irows ) ; }


signature:
public class CellMap { /** * Put picture image to session map and return the key to web .
 * @ param rowIndex
 * the row index of the cell which contains picture .
 * @ param colIndex
 * the column index of the cell which contains picture .
 * @ return the key of the picture image in the session map . */
private String loadPicture ( final int rowIndex , final int colIndex ) { } }

implementation: FacesCell facesCell = parent . getCellHelper ( ) . getFacesCellWithRowColFromCurrentPage ( rowIndex , colIndex ) ; if ( facesCell != null && facesCell . isContainPic ( ) ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; String pictureId = facesCell . getPictureId ( ) ; String pictureViewId = Integer . toHexString ( System . identityHashCode ( parent . getWb ( ) ) ) + pictureId ; Map < String , Object > sessionMap = context . getExternalContext ( ) . getSessionMap ( ) ; if ( sessionMap . get ( pictureViewId ) == null ) { sessionMap . put ( pictureViewId , parent . getPicturesMap ( ) . get ( pictureId ) . getPictureData ( ) ) ; } return pictureViewId ; } else { return null ; }


signature:
public class CellMap { /** * Put chart image to session map and return the key to web .
 * @ param rowIndex
 * the row index of the cell which contains picture .
 * @ param colIndex
 * the column index of the cell which contains picture .
 * @ return the key of the picture image in the session map . */
private String loadChart ( final int rowIndex , final int colIndex ) { } }

implementation: FacesCell facesCell = parent . getCellHelper ( ) . getFacesCellWithRowColFromCurrentPage ( rowIndex , colIndex ) ; if ( facesCell != null && facesCell . isContainChart ( ) ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; String chartId = facesCell . getChartId ( ) ; String chartViewId = Integer . toHexString ( System . identityHashCode ( parent . getWb ( ) ) ) + chartId ; if ( context != null ) { Map < String , Object > sessionMap = context . getExternalContext ( ) . getSessionMap ( ) ; if ( sessionMap . get ( chartViewId ) == null ) { sessionMap . put ( chartViewId , parent . getCharsData ( ) . getChartsMap ( ) . get ( chartId ) ) ; } } return chartViewId ; } else { return null ; }


signature:
public class CellMap { /** * ( non - Javadoc )
 * @ see java . util . Map # get ( java . lang . Object ) */
@ Override public final Object get ( final Object key ) { } }

implementation:
Object result = "" ; try { CellMapKey mkey = new CellMapKey ( ( String ) key ) ; if ( ! mkey . isParseSuccess ( ) ) { return result ; } Cell poiCell = parent . getCellHelper ( ) . getPoiCellWithRowColFromCurrentPage ( mkey . getRowIndex ( ) , mkey . getColIndex ( ) ) ; if ( poiCell == null ) { return result ; } if ( mkey . isCharted ( ) ) { result = loadChart ( mkey . getRowIndex ( ) , mkey . getColIndex ( ) ) ; } else if ( mkey . isPictured ( ) ) { result = loadPicture ( mkey . getRowIndex ( ) , mkey . getColIndex ( ) ) ; } else if ( mkey . isFormatted ( ) ) { result = CellUtility . getCellValueWithFormat ( poiCell , parent . getFormulaEvaluator ( ) , parent . getDataFormatter ( ) ) ; } else { result = CellUtility . getCellValueWithoutFormat ( poiCell ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Web Form CellMap get value error=" + ex . getLocalizedMessage ( ) , ex ) ; } // return blank if null
return result ;


signature:
public class CellMap { /** * ( non - Javadoc )
 * @ see java . util . Map # put ( java . lang . Object , java . lang . Object ) */
@ Override public final Object put ( final Object key , final Object value ) { } }

implementation:
try { CellMapKey mkey = new CellMapKey ( ( String ) key ) ; if ( ! mkey . isParseSuccess ( ) ) { return null ; } Cell poiCell = parent . getCellHelper ( ) . getPoiCellWithRowColFromCurrentPage ( mkey . getRowIndex ( ) , mkey . getColIndex ( ) ) ; if ( poiCell == null ) { return null ; } String oldValue = CellUtility . getCellValueWithoutFormat ( poiCell ) ; FacesCell facesCell = parent . getCellHelper ( ) . getFacesCellWithRowColFromCurrentPage ( mkey . getRowIndex ( ) , mkey . getColIndex ( ) ) ; String newValue = assembleNewValue ( value , facesCell ) ; if ( newValue != null && ! newValue . equals ( oldValue ) ) { CellUtility . setCellValue ( poiCell , newValue ) ; if ( facesCell . isHasSaveAttr ( ) ) { parent . getCellHelper ( ) . saveDataInContext ( poiCell , newValue ) ; } // patch to avoid not updated downloaded file
CellUtility . copyCell ( poiCell . getSheet ( ) , poiCell . getRow ( ) , poiCell . getRow ( ) , poiCell . getColumnIndex ( ) , false ) ; parent . getCellHelper ( ) . reCalc ( ) ; } return value ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Save cell data error : " + ex . getLocalizedMessage ( ) , ex ) ; } return null ;


signature:
public class CellMap { /** * Assemble new value .
 * @ param value
 * the value
 * @ param facesCell
 * the faces cell
 * @ return the string */
private String assembleNewValue ( final Object value , final FacesCell facesCell ) { } }

implementation:
String newValue ; if ( value instanceof java . util . Date ) { String datePattern = facesCell . getDatePattern ( ) ; if ( datePattern == null || datePattern . isEmpty ( ) ) { datePattern = parent . getDefaultDatePattern ( ) ; } Format formatter = new SimpleDateFormat ( datePattern ) ; newValue = formatter . format ( value ) ; } else { newValue = ( String ) value ; } if ( "textarea" . equalsIgnoreCase ( facesCell . getInputType ( ) ) && ( newValue != null ) ) { // remove " \ r " because excel issue
newValue = newValue . replace ( "\r\n" , "\n" ) ; } return newValue ;


signature:
public class CellUtility { /** * return cell value with format .
 * @ param poiCell
 * cell .
 * @ param formulaEvaluator
 * formula evaluator .
 * @ param dataFormatter
 * data formatter .
 * @ return cell string value with format . */
@ SuppressWarnings ( "deprecation" ) public static String getCellValueWithFormat ( final Cell poiCell , final FormulaEvaluator formulaEvaluator , final DataFormatter dataFormatter ) { } }

implementation: if ( poiCell == null ) { return null ; } String result ; try { CellType cellType = poiCell . getCellTypeEnum ( ) ; if ( cellType == CellType . FORMULA ) { cellType = formulaEvaluator . evaluate ( poiCell ) . getCellTypeEnum ( ) ; } if ( cellType == CellType . ERROR ) { result = "" ; } else { result = dataFormatter . formatCellValue ( poiCell , formulaEvaluator ) ; } } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Web Form WebFormHelper getCellValue Error row = " + poiCell . getRowIndex ( ) + " column = " + poiCell . getColumnIndex ( ) + " error = " + e . getLocalizedMessage ( ) + "; Change return result to blank" , e ) ; result = "" ; } return result ;


signature:
public class CellUtility { /** * get input cell value . none input return blank
 * @ param poiCell
 * cell .
 * @ return String cell value . */
@ SuppressWarnings ( "deprecation" ) public static String getCellValueWithoutFormat ( final Cell poiCell ) { } }

implementation: if ( poiCell == null ) { return null ; } if ( poiCell . getCellTypeEnum ( ) == CellType . FORMULA ) { return getCellStringValueWithType ( poiCell , poiCell . getCachedFormulaResultTypeEnum ( ) ) ; } else { return getCellStringValueWithType ( poiCell , poiCell . getCellTypeEnum ( ) ) ; }


signature:
public class CellUtility { /** * Get cell value as string but with giving type .
 * @ param poiCell
 * cell .
 * @ param cellType
 * cell type .
 * @ return Sting cell value . */
private static String getCellStringValueWithType ( final Cell poiCell , final CellType cellType ) { } }

implementation: switch ( cellType ) { case BOOLEAN : return getCellStringValueWithBooleanType ( poiCell ) ; case NUMERIC : return getCellStringValueWithNumberType ( poiCell ) ; case STRING : return poiCell . getStringCellValue ( ) ; default : return "" ; } // switch