signature:
public class ParserUtility { /** * Parses the widget attributes .
 * @ param cell
 * the cell
 * @ param newComment
 * the new comment
 * @ param cellAttributesMap
 * the cell attributes map */
public static void parseWidgetAttributes ( final Cell cell , final String newComment , final CellAttributesMap cellAttributesMap ) { } }

implementation:
if ( ( newComment == null ) || ( newComment . isEmpty ( ) ) ) { return ; } int widgetStart = newComment . indexOf ( TieConstants . METHOD_WIDGET_PREFIX ) ; int elStart = newComment . indexOf ( TieConstants . EL_START_BRACKET ) ; if ( ( widgetStart < 0 ) || ( widgetStart >= elStart ) ) { return ; } String type = newComment . substring ( widgetStart + TieConstants . METHOD_WIDGET_PREFIX . length ( ) , elStart ) ; String values = getStringBetweenBracket ( newComment ) ; if ( values == null ) { return ; } // map ' s key is sheetName ! $ columnIndex $ rowIndex
String key = getAttributeKeyInMapByCell ( cell ) ; // one cell only has one control widget
cellAttributesMap . getCellInputType ( ) . put ( key , type ) ; List < CellFormAttributes > inputs = cellAttributesMap . getCellInputAttributes ( ) . get ( key ) ; if ( inputs == null ) { inputs = new ArrayList < > ( ) ; cellAttributesMap . getCellInputAttributes ( ) . put ( key , inputs ) ; } parseInputAttributes ( inputs , values ) ; parseSpecialAttributes ( key , type , inputs , cellAttributesMap ) ;


signature:
public class ParserUtility { /** * get attribute key in map by cell .
 * @ param cell
 * input cell .
 * @ return key . */
public static String getAttributeKeyInMapByCell ( final Cell cell ) { } }

implementation:
if ( cell == null ) { return null ; } // map ' s key is sheetName ! $ columnIndex $ rowIndex
return cell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( cell ) ;


signature:
public class ParserUtility { /** * Parses the validate attributes .
 * @ param cell
 * the cell
 * @ param newComment
 * the new comment
 * @ param cellAttributesMap
 * the cell attributes map */
public static void parseValidateAttributes ( final Cell cell , final String newComment , final CellAttributesMap cellAttributesMap ) { } }

implementation:
if ( ( newComment == null ) || ( newComment . isEmpty ( ) ) ) { return ; } if ( ! newComment . startsWith ( TieConstants . METHOD_VALIDATE_PREFIX ) ) { return ; } String values = getStringBetweenBracket ( newComment ) ; if ( values == null ) { return ; } // map ' s key is sheetName ! $ columnIndex $ rowIndex
String key = getAttributeKeyInMapByCell ( cell ) ; List < CellFormAttributes > attrs = cellAttributesMap . getCellValidateAttributes ( ) . get ( key ) ; if ( attrs == null ) { attrs = new ArrayList < > ( ) ; cellAttributesMap . getCellValidateAttributes ( ) . put ( key , attrs ) ; } parseValidateAttributes ( attrs , values ) ;


signature:
public class ParserUtility { /** * get the string between two bracket . . e . g . $ save { employee . name } return
 * employee . name .
 * @ param newComment the new comment
 * @ return return string . */
public static String getStringBetweenBracket ( final String newComment ) { } }

implementation: if ( newComment == null ) { return null ; } int elStart = newComment . indexOf ( TieConstants . EL_START_BRACKET ) ; int elEnd = findPairBracketPosition ( newComment , elStart ) ; if ( elStart >= elEnd ) { return null ; } return newComment . substring ( elStart + 1 , elEnd ) ;


signature:
public class ParserUtility { /** * Find pair bracket position .
 * @ param str the str
 * @ param startPos the start pos
 * @ return the int */
private static int findPairBracketPosition ( final String str , final int startPos ) { } }

implementation: int bracketNum = 0 ; for ( int i = startPos ; i < str . length ( ) ; i ++ ) { char current = str . charAt ( i ) ; if ( current == TieConstants . EL_START_BRACKET ) { bracketNum ++ ; } else if ( current == TieConstants . EL_END ) { bracketNum -- ; if ( bracketNum <= 0 ) { return i ; } } } return - 1 ;


signature:
public class ParserUtility { /** * Parse the attributes from string .
 * @ param attrString
 * command string .
 * @ return attributes map . */
public static Map < String , String > parseCommandAttributes ( final String attrString ) { } }

implementation: Map < String , String > attrMap = new LinkedHashMap < > ( ) ; Matcher attrMatcher = TieConstants . ATTR_REGEX_PATTERN . matcher ( attrString ) ; while ( attrMatcher . find ( ) ) { String attrData = attrMatcher . group ( ) ; int attrNameEndIndex = attrData . indexOf ( '=' ) ; String attrName = attrData . substring ( 0 , attrNameEndIndex ) . trim ( ) ; String attrValuePart = attrData . substring ( attrNameEndIndex + 1 ) . trim ( ) ; String attrValue = attrValuePart . substring ( 1 , attrValuePart . length ( ) - 1 ) ; attrMap . put ( attrName , attrValue ) ; } return attrMap ;


signature:
public class ParserUtility { /** * parse input attributes .
 * @ param clist
 * list of cellformattributes .
 * @ param controlAttrs
 * control attrs . */
public static void parseInputAttributes ( final List < CellFormAttributes > clist , final String controlAttrs ) { } }

implementation:
// only one type control allowed for one cell .
clist . clear ( ) ; if ( controlAttrs != null ) { String [ ] cattrs = controlAttrs . split ( TieConstants . SPLIT_SPACE_SEPERATE_ATTRS_REGX , - 1 ) ; for ( String cattr : cattrs ) { String [ ] details = splitByEualSign ( cattr ) ; if ( details . length > 1 ) { CellFormAttributes attr = new CellFormAttributes ( ) ; attr . setType ( details [ 0 ] . trim ( ) ) ; attr . setValue ( details [ 1 ] . replaceAll ( "\"" , "" ) ) ; clist . add ( attr ) ; } } }


signature:
public class ParserUtility { /** * parse validate attributes .
 * @ param clist
 * list of cellformattributes .
 * @ param controlAttrs
 * control attrs . */
public static void parseValidateAttributes ( final List < CellFormAttributes > clist , final String controlAttrs ) { } }

implementation:
// one cell could have multiple validation rules .
if ( controlAttrs == null ) { return ; } String [ ] cattrs = controlAttrs . split ( TieConstants . SPLIT_SPACE_SEPERATE_ATTRS_REGX , - 1 ) ; CellFormAttributes attr = new CellFormAttributes ( ) ; for ( String cattr : cattrs ) { extractValidationAttributes ( attr , cattr ) ; } if ( ( attr . getValue ( ) != null ) && ( ! attr . getValue ( ) . isEmpty ( ) ) ) { clist . add ( attr ) ; }


signature:
public class ParserUtility { /** * extractValidationAttributes .
 * @ param attr attribute holder .
 * @ param cattr input attributes . */
private static void extractValidationAttributes ( final CellFormAttributes attr , final String cattr ) { } }

implementation: String [ ] details = splitByEualSign ( cattr ) ; if ( details . length > 1 ) { if ( details [ 0 ] . equalsIgnoreCase ( TieConstants . VALIDATION_RULE_TAG ) ) { attr . setValue ( details [ 1 ] . replaceAll ( "\"" , "" ) ) ; } else if ( details [ 0 ] . equalsIgnoreCase ( TieConstants . VALIDATION_ERROR_MSG_TAG ) ) { attr . setMessage ( details [ 1 ] . replaceAll ( "\"" , "" ) ) ; } }


signature:
public class ParserUtility { /** * split string by = sign .
 * @ param attrData
 * string .
 * @ return splitted string array . */
private static String [ ] splitByEualSign ( final String attrData ) { } }

implementation: int attrNameEndIndex = attrData . indexOf ( '=' ) ; if ( attrNameEndIndex < 0 ) { return new String [ 0 ] ; } String attrName = attrData . substring ( 0 , attrNameEndIndex ) . trim ( ) ; String attrValue = attrData . substring ( attrNameEndIndex + 1 ) . trim ( ) ; String [ ] rlist = new String [ 2 ] ; rlist [ 0 ] = attrName ; rlist [ 1 ] = attrValue ; return rlist ;


signature:
public class ParserUtility { /** * parse select item attributes .
 * @ param key
 * key .
 * @ param type
 * type .
 * @ param inputs
 * inputs .
 * @ param cellAttributesMap
 * cellattributesmap . */
public static void parseSpecialAttributes ( final String key , final String type , final List < CellFormAttributes > inputs , final CellAttributesMap cellAttributesMap ) { } }

implementation: SpecialAttributes sAttr = new SpecialAttributes ( ) ; for ( CellFormAttributes attr : inputs ) { gatherSpecialAttributes ( type , sAttr , attr ) ; } if ( sAttr . selectLabels != null ) { processSelectItemAttributes ( key , cellAttributesMap , sAttr ) ; } if ( type . equalsIgnoreCase ( TieConstants . WIDGET_CALENDAR ) ) { processCalendarAttributes ( key , cellAttributesMap , sAttr ) ; }


signature:
public class ParserUtility { /** * Process calendar attributes .
 * @ param key
 * the key
 * @ param cellAttributesMap
 * the cell attributes map
 * @ param sAttr
 * the s attr */
private static void processCalendarAttributes ( final String key , final CellAttributesMap cellAttributesMap , final SpecialAttributes sAttr ) { } }

implementation: cellAttributesMap . getCellDatePattern ( ) . put ( key , sAttr . defaultDatePattern ) ;


signature:
public class ParserUtility { /** * Process select item attributes .
 * @ param key
 * the key
 * @ param cellAttributesMap
 * the cell attributes map
 * @ param sAttr
 * the s attr */
private static void processSelectItemAttributes ( final String key , final CellAttributesMap cellAttributesMap , final SpecialAttributes sAttr ) { } }

implementation: if ( ( sAttr . selectValues == null ) || ( sAttr . selectValues . length != sAttr . selectLabels . length ) ) { sAttr . selectValues = sAttr . selectLabels ; } Map < String , String > smap = cellAttributesMap . getCellSelectItemsAttributes ( ) . get ( key ) ; if ( smap == null ) { smap = new LinkedHashMap < > ( ) ; } smap . clear ( ) ; if ( sAttr . defaultSelectLabel != null ) { smap . put ( sAttr . defaultSelectLabel , sAttr . defaultSelectValue ) ; } for ( int i = 0 ; i < sAttr . selectLabels . length ; i ++ ) { smap . put ( sAttr . selectLabels [ i ] , sAttr . selectValues [ i ] ) ; } cellAttributesMap . getCellSelectItemsAttributes ( ) . put ( key , smap ) ;


signature:
public class ParserUtility { /** * Gather special attributes .
 * @ param type
 * the type
 * @ param sAttr
 * the s attr
 * @ param attr
 * the attr */
private static void gatherSpecialAttributes ( final String type , final SpecialAttributes sAttr , final CellFormAttributes attr ) { } }

implementation: String attrKey = attr . getType ( ) ; if ( attrKey . equalsIgnoreCase ( TieConstants . SELECT_ITEM_LABELS ) ) { sAttr . selectLabels = attr . getValue ( ) . split ( ";" ) ; } if ( attrKey . equalsIgnoreCase ( TieConstants . SELECT_ITEM_VALUES ) ) { sAttr . selectValues = attr . getValue ( ) . split ( ";" ) ; } if ( attrKey . equalsIgnoreCase ( TieConstants . DEFAULT_SELECT_ITEM_LABEL ) ) { sAttr . defaultSelectLabel = attr . getValue ( ) ; } if ( attrKey . equalsIgnoreCase ( TieConstants . DEFAULT_SELECT_ITEM_VALUE ) ) { sAttr . defaultSelectValue = attr . getValue ( ) ; } if ( type . equalsIgnoreCase ( TieConstants . WIDGET_CALENDAR ) && attrKey . equalsIgnoreCase ( TieConstants . WIDGET_ATTR_PATTERN ) ) { sAttr . defaultDatePattern = attr . getValue ( ) ; }


signature:
public class ParserUtility { /** * Parse Comment To Map
 * Normal comment : key $ $ Not Normal comment : key e . g . $ save
 * @ param cellKey
 * cellKey .
 * @ param newComment
 * updated comment .
 * @ param sheetCommentMap
 * the sheet comment map .
 * @ param normalComment
 * the normal comment . */
public static void parseCommentToMap ( final String cellKey , final String newComment , final Map < String , Map < String , String > > sheetCommentMap , final boolean normalComment ) { } }

implementation:
if ( ( newComment != null ) && ( ! newComment . trim ( ) . isEmpty ( ) ) ) { // normal comment key is $ $
String commentKey = TieConstants . NORMAL_COMMENT_KEY_IN_MAP ; if ( ! normalComment ) { // not normal comment . e . g . $ { . . . or $ init { . . . or
// key = $ or key = $ init
commentKey = newComment . substring ( 0 , newComment . indexOf ( TieConstants . EL_START_BRACKET ) ) ; } Map < String , String > map = sheetCommentMap . get ( commentKey ) ; if ( map == null ) { map = new HashMap < > ( ) ; } // inner map ' s key is sheetName ! $ columnIndex $ rowIndex
map . put ( cellKey , newComment ) ; sheetCommentMap . put ( commentKey , map ) ; }


signature:
public class ParserUtility { /** * find first non letterordigit position from string .
 * @ param input input string
 * @ param startPosition startposition
 * @ return first position */
public static int findFirstNonCellNamePosition ( String input , int startPosition ) { } }

implementation: char c ; for ( int i = startPosition ; i < input . length ( ) ; i ++ ) { c = input . charAt ( i ) ; if ( c != '$' && ! Character . isLetterOrDigit ( c ) ) { return i ; } } return - 1 ; // not found


signature:
public class ParserUtility { /** * Removes the chars from string .
 * @ param inputStr the input str
 * @ param start the start
 * @ param end the end
 * @ return the string */
public static String removeCharsFromString ( String inputStr , int start , int end ) { } }

implementation:
StringBuilder sb = new StringBuilder ( inputStr ) ; sb . delete ( start , end ) ; // if ( ( start > 0 ) & & ( inputStr . charAt ( start - 1 ) = = ' ' ) ) {
// / / if end with a space , then remove it as well .
// sb . deleteCharAt ( start - 1 ) ;
return sb . toString ( ) ;


signature:
public class WebSheetUtility { /** * Gets the excel column name .
 * @ param pnumber
 * the number
 * @ return the string */
public static String getExcelColumnName ( final int pnumber ) { } }

implementation:
StringBuilder converted = new StringBuilder ( ) ; // Repeatedly divide the number by 26 and convert the
// remainder into the appropriate letter .
int number = pnumber ; while ( number >= 0 ) { int remainder = number % TieConstants . EXCEL_LETTER_NUMBERS ; converted . insert ( 0 , ( char ) ( remainder + 'A' ) ) ; number = ( number / TieConstants . EXCEL_LETTER_NUMBERS ) - 1 ; } return converted . toString ( ) ;


signature:
public class WebSheetUtility { /** * return full name for cell with sheet name and $ format e . g . Sheet1 $ A $ 1
 * @ param sheet1
 * sheet
 * @ param cell
 * cell
 * @ return String full cell reference name */
public static String getFullCellRefName ( final Sheet sheet1 , final Cell cell ) { } }

implementation: if ( ( sheet1 != null ) && ( cell != null ) ) { return sheet1 . getSheetName ( ) + "!$" + getExcelColumnName ( cell . getColumnIndex ( ) ) + "$" + ( cell . getRowIndex ( ) + 1 ) ; } return null ;


signature:
public class WebSheetUtility { /** * return full name for cell with sheet name and $ format e . g . Sheet1 $ A $ 1
 * @ param sheetName
 * the sheet name
 * @ param rowIndex
 * the row index
 * @ param colIndex
 * the col index
 * @ return String full cell reference name */
public static String getFullCellRefName ( final String sheetName , final int rowIndex , final int colIndex ) { } }

implementation: if ( sheetName != null ) { return sheetName + "!$" + getExcelColumnName ( colIndex ) + "$" + ( rowIndex + 1 ) ; } return null ;


signature:
public class WebSheetUtility { /** * return sheet name from cell full name e . g . return Sheet1 from Sheet1 $ A $ 1
 * @ param fullName
 * the full name
 * @ return String Sheet Name */
public static String getSheetNameFromFullCellRefName ( final String fullName ) { } }

implementation: if ( ( fullName != null ) && ( fullName . contains ( "!" ) ) ) { return fullName . substring ( 0 , fullName . indexOf ( '!' ) ) ; } return null ;


signature:
public class WebSheetUtility { /** * remove sheet name from cell full name e . g . return $ A $ 1 from Sheet1 $ A $ 1
 * @ param fullName
 * the full name
 * @ return remove Sheet Name from full name */
public static String removeSheetNameFromFullCellRefName ( final String fullName ) { } }

implementation: if ( ( fullName != null ) && ( fullName . contains ( "!" ) ) ) { return fullName . substring ( fullName . indexOf ( '!' ) + 1 ) ; } return fullName ;


signature:
public class WebSheetUtility { /** * Convert col to int .
 * @ param col
 * the col
 * @ return the int */
public static int convertColToInt ( final String col ) { } }

implementation: String name = col . toUpperCase ( ) ; int number = 0 ; int pow = 1 ; for ( int i = name . length ( ) - 1 ; i >= 0 ; i -- ) { number += ( name . charAt ( i ) - 'A' + 1 ) * pow ; pow *= TieConstants . EXCEL_LETTER_NUMBERS ; } return number - 1 ;


signature:
public class WebSheetUtility { /** * Gets the cell by reference .
 * @ param cellRef
 * the cell ref
 * @ param sheet
 * the sheet
 * @ return the cell by reference */
public static Cell getCellByReference ( final String cellRef , final Sheet sheet ) { } }

implementation:
Cell c = null ; try { CellReference ref = new CellReference ( cellRef ) ; Row r = sheet . getRow ( ref . getRow ( ) ) ; if ( r != null ) { c = r . getCell ( ref . getCol ( ) , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; } } catch ( Exception ex ) { // use log . debug because mostly it ' s expected
LOG . log ( Level . SEVERE , "WebForm WebFormHelper getCellByReference cellRef = " + cellRef + "; error = " + ex . getLocalizedMessage ( ) , ex ) ; } return c ;


signature:
public class WebSheetUtility { /** * pixel units to excel width units ( units of 1/256th of a character width ) .
 * @ param pxs
 * the pxs
 * @ return the short */
public static short pixel2WidthUnits ( final int pxs ) { } }

implementation: short widthUnits = ( short ) ( EXCEL_COLUMN_WIDTH_FACTOR * ( pxs / UNIT_OFFSET_LENGTH ) ) ; widthUnits += UNIT_OFFSET_MAP [ pxs % UNIT_OFFSET_LENGTH ] ; return widthUnits ;


signature:
public class WebSheetUtility { /** * excel width units ( units of 1/256th of a character width ) to pixel units .
 * @ param widthUnits
 * the width units
 * @ return the int */
public static int widthUnits2Pixel ( final int widthUnits ) { } }

implementation: int pixels = ( widthUnits / EXCEL_COLUMN_WIDTH_FACTOR ) * UNIT_OFFSET_LENGTH ; int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR ; pixels += Math . round ( offsetWidthUnits / ( ( float ) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH ) ) ; return pixels ;


signature:
public class WebSheetUtility { /** * Height units 2 pixel .
 * @ param heightUnits
 * the height units
 * @ return the int */
public static int heightUnits2Pixel ( final short heightUnits ) { } }

implementation: int pixels = heightUnits / EXCEL_ROW_HEIGHT_FACTOR ; int offsetHeightUnits = heightUnits % EXCEL_ROW_HEIGHT_FACTOR ; pixels += Math . round ( ( float ) offsetHeightUnits / ( ( float ) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH / 2 ) ) ; pixels += ( Math . floor ( pixels / PIXEL_HEIGHT_ASPC_ADJUST ) + 1 ) * 4 ; return pixels ;


signature:
public class WebSheetUtility { /** * Checks if is date .
 * @ param s
 * the s
 * @ return true , if is date */
public static boolean isDate ( final String s ) { } }

implementation: Pattern pattern = Pattern . compile ( DATE_REGEX_4_DIGIT_YEAR ) ; String [ ] terms = s . split ( " " ) ; Matcher matcher ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return true ; } } pattern = Pattern . compile ( DATE_REGEX_2_DIGIT_YEAR ) ; terms = s . split ( " " ) ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return true ; } } return false ;


signature:
public class WebSheetUtility { /** * Parses the date .
 * @ param entry
 * the entry
 * @ return the string */
public static String parseDate ( final String entry ) { } }

implementation: Pattern pattern = Pattern . compile ( DATE_REGEX_4_DIGIT_YEAR ) ; String [ ] terms = entry . split ( " " ) ; Matcher matcher ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return matcher . group ( ) ; } } pattern = Pattern . compile ( DATE_REGEX_2_DIGIT_YEAR ) ; terms = entry . split ( " " ) ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return matcher . group ( ) ; } } return "" ;


signature:
public class WebSheetUtility { /** * Checks if is numeric .
 * @ param str
 * the str
 * @ return true , if is numeric */
public static boolean isNumeric ( final String str ) { } }

implementation: String s = str ; if ( s . startsWith ( "-" ) ) { s = s . substring ( 1 ) ; } char c ; int i ; int sLen = s . length ( ) ; ShouldContinueParameter sPara = new ShouldContinueParameter ( false , false , 0 ) ; for ( i = 0 ; i < sLen ; i ++ ) { c = s . charAt ( i ) ; if ( c < '0' || c > '9' ) { if ( ! shouldContinue ( c , sPara ) ) { return false ; } } else { if ( sPara . isCommaHit ( ) ) { sPara . setSinceLastComma ( sPara . getSinceLastComma ( ) + 1 ) ; } } } return true ;


signature:
public class WebSheetUtility { /** * Should continue .
 * @ param c
 * the c
 * @ param para
 * the para
 * @ return true , if successful */
private static boolean shouldContinue ( final char c , final ShouldContinueParameter para ) { } }

implementation: if ( c == '.' && ! para . isDecimalHit ( ) ) { para . setDecimalHit ( true ) ; if ( para . isCommaHit ( ) && para . getSinceLastComma ( ) != 3 ) { return false ; } return true ; } else if ( c == ',' && ! para . isDecimalHit ( ) ) { if ( para . isCommaHit ( ) ) { if ( para . getSinceLastComma ( ) != 3 ) { return false ; } para . setSinceLastComma ( 0 ) ; } para . setCommaHit ( true ) ; return true ; } return false ;


signature:
public class WebSheetUtility { /** * Sets the object property .
 * @ param obj
 * the obj
 * @ param propertyName
 * the property name
 * @ param propertyValue
 * the property value
 * @ param ignoreNonExisting
 * the ignore non existing */
public static void setObjectProperty ( final Object obj , final String propertyName , final String propertyValue , final boolean ignoreNonExisting ) { } }

implementation: try { Method method = obj . getClass ( ) . getMethod ( "set" + Character . toUpperCase ( propertyName . charAt ( 0 ) ) + propertyName . substring ( 1 ) , new Class [ ] { String . class } ) ; method . invoke ( obj , propertyValue ) ; } catch ( Exception e ) { String msg = "failed to set property '" + propertyName + "' to value '" + propertyValue + "' for object " + obj ; if ( ignoreNonExisting ) { LOG . info ( msg ) ; } else { LOG . warning ( msg ) ; throw new IllegalArgumentException ( e ) ; } }


signature:
public class WebSheetUtility { /** * Cell compare to .
 * @ param thisCell
 * the this cell
 * @ param otherCell
 * the other cell
 * @ return the int */
public static int cellCompareTo ( final Cell thisCell , final Cell otherCell ) { } }

implementation: int r = thisCell . getRowIndex ( ) - otherCell . getRowIndex ( ) ; if ( r != 0 ) { return r ; } r = thisCell . getColumnIndex ( ) - otherCell . getColumnIndex ( ) ; if ( r != 0 ) { return r ; } return 0 ;


signature:
public class WebSheetUtility { /** * Inside range .
 * @ param child
 * the child
 * @ param parent
 * the parent
 * @ return true , if successful */
public static boolean insideRange ( final ConfigRange child , final ConfigRange parent ) { } }

implementation: return ( ( cellCompareTo ( child . getFirstRowRef ( ) , parent . getFirstRowRef ( ) ) >= 0 ) && ( cellCompareTo ( child . getLastRowPlusRef ( ) , parent . getLastRowPlusRef ( ) ) <= 0 ) ) ;


signature:
public class WebSheetUtility { /** * return the last column of the sheet .
 * @ param sheet
 * sheet .
 * @ return last column number ( A column will return 0 ) . */
public static int getSheetRightCol ( final Sheet sheet ) { } }

implementation: try { if ( sheet instanceof XSSFSheet ) { XSSFSheet xsheet = ( XSSFSheet ) sheet ; int rightCol = getSheetRightColFromDimension ( xsheet ) ; if ( rightCol > TieConstants . MAX_COLUMNS_IN_SHEET ) { clearHiddenColumns ( sheet ) ; rightCol = getSheetRightColFromDimension ( xsheet ) ; } return rightCol ; } } catch ( Exception e ) { LOG . log ( Level . SEVERE , "error in getSheetRightCol : " + e . getLocalizedMessage ( ) , e ) ; } return - 1 ;


signature:
public class WebSheetUtility { /** * Clear hidden columns .
 * @ param sheet
 * the sheet */
public static void clearHiddenColumns ( final Sheet sheet ) { } }

implementation: for ( Row row : sheet ) { if ( row . getLastCellNum ( ) > TieConstants . MAX_COLUMNS_IN_SHEET ) { deleteHiddenColumnsInRow ( row ) ; } }


signature:
public class WebSheetUtility { /** * Delete hidden columns in row .
 * @ param row
 * the row */
private static void deleteHiddenColumnsInRow ( final Row row ) { } }

implementation: deleteCellFromRow ( row , TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN ) ; deleteCellFromRow ( row , TieConstants . HIDDEN_ORIGIN_ROW_NUMBER_COLUMN ) ; deleteCellFromRow ( row , TieConstants . HIDDEN_FULL_NAME_COLUMN ) ;


signature:
public class WebSheetUtility { /** * Delete cell from row .
 * @ param row
 * the row
 * @ param cellNum
 * the cell num */
private static void deleteCellFromRow ( final Row row , final int cellNum ) { } }

implementation: Cell cell = row . getCell ( cellNum ) ; if ( cell != null ) { row . removeCell ( cell ) ; }


signature:
public class WebSheetUtility { /** * return the last column of the sheet .
 * @ param xsheet
 * the xsheet
 * @ return last column number ( A column will return 0 ) . */
private static int getSheetRightColFromDimension ( final XSSFSheet xsheet ) { } }

implementation: CTSheetDimension dimension = xsheet . getCTWorksheet ( ) . getDimension ( ) ; String sheetDimensions = dimension . getRef ( ) ; if ( sheetDimensions . indexOf ( ':' ) < 0 ) { return - 1 ; } else { return CellRangeAddress . valueOf ( sheetDimensions ) . getLastColumn ( ) ; }


signature:
public class AreaChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getSeriesLabelFromCTSer ( java . lang . Object ) */
@ Override public final String getSeriesLabelFromCTSer ( final Object ctObjSer ) { } }

implementation: if ( ctObjSer instanceof CTAreaSer ) { return ( ( CTAreaSer ) ctObjSer ) . getTx ( ) . getStrRef ( ) . getF ( ) ; } return null ;


signature:
public class AreaChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getShapePropertiesFromCTSer ( java . lang . Object ) */
@ Override public final CTShapeProperties getShapePropertiesFromCTSer ( final Object ctObjSer ) { } }

implementation: if ( ctObjSer instanceof CTAreaSer ) { return ( ( CTAreaSer ) ctObjSer ) . getSpPr ( ) ; } return null ;


signature:
public class AreaChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getCTNumDataSourceFromCTSer ( java . lang . Object ) */
@ Override public final CTNumDataSource getCTNumDataSourceFromCTSer ( final Object ctObjSer ) { } }

implementation: if ( ctObjSer instanceof CTAreaSer ) { return ( ( CTAreaSer ) ctObjSer ) . getVal ( ) ; } return null ;


signature:
public class PostConstructApplicationEventListener { /** * process event .
 * @ param event
 * systemevent .
 * @ throws AbortProcessingException
 * abort process exception . */
@ Override public final void processEvent ( final SystemEvent event ) { } }

implementation: LOGGER . log ( Level . INFO , "Running on TieFaces {0}" , AppUtils . getBuildVersion ( ) ) ;


signature:
public class ValidationHandler { /** * Refresh after status changed .
 * @ param oldStatus
 * the old status
 * @ param newStatus
 * the new status
 * @ param formRow
 * the form row
 * @ param formCol
 * the form col
 * @ param cell
 * the cell
 * @ param updateGui
 * update gui flag .
 * if true then update gui . */
private void refreshAfterStatusChanged ( final boolean oldStatus , final boolean newStatus , final int formRow , final int formCol , final FacesCell cell , final boolean updateGui ) { } }

implementation: if ( ! newStatus ) { cell . setErrormsg ( "" ) ; } cell . setInvalid ( newStatus ) ; if ( updateGui && ( oldStatus != newStatus ) && ( parent . getWebFormClientId ( ) != null ) ) { RequestContext . getCurrentInstance ( ) . update ( parent . getWebFormClientId ( ) + ":" + ( formRow ) + ":group" + ( formCol ) ) ; }


signature:
public class ValidationHandler { /** * Validate with row col in current page .
 * @ param row
 * the row
 * @ param col
 * the col
 * @ param updateGui
 * if true then update gui .
 * @ return true , if successful */
public boolean validateWithRowColInCurrentPage ( final int row , final int col , boolean updateGui ) { } }

implementation:
// until now passEmptyCheck has one to one relation to submitMode
// e . g . when passEmptyCheck = false , then submitMode = true .
boolean submitMode = parent . getSubmitMode ( ) ; boolean passEmptyCheck = ! submitMode ; int topRow = parent . getCurrent ( ) . getCurrentTopRow ( ) ; int leftCol = parent . getCurrent ( ) . getCurrentLeftColumn ( ) ; boolean pass = true ; FacesRow fRow = CellUtility . getFacesRowFromBodyRow ( row , parent . getBodyRows ( ) , topRow ) ; if ( fRow == null ) { return pass ; } FacesCell cell = CellUtility . getFacesCellFromBodyRow ( row , col , parent . getBodyRows ( ) , topRow , leftCol ) ; if ( cell == null ) { return pass ; } Cell poiCell = parent . getCellHelper ( ) . getPoiCellWithRowColFromCurrentPage ( row , col ) ; boolean oldStatus = cell . isInvalid ( ) ; String value = CellUtility . getCellValueWithoutFormat ( poiCell ) ; if ( value == null ) { value = "" ; } else { value = value . trim ( ) ; } if ( passEmptyCheck && value . isEmpty ( ) ) { refreshAfterStatusChanged ( oldStatus , false , row - topRow , col - leftCol , cell , updateGui ) ; return pass ; } if ( ( ( parent . isOnlyValidateInSubmitMode ( ) && submitMode ) || ! parent . isOnlyValidateInSubmitMode ( ) ) && ! validateByTieWebSheetValidationBean ( poiCell , topRow , leftCol , cell , value , updateGui ) ) { return false ; } SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( parent . getCurrent ( ) . getCurrentTabName ( ) ) ; List < CellFormAttributes > cellAttributes = CellControlsUtility . findCellValidateAttributes ( parent . getCellAttributesMap ( ) . getCellValidateAttributes ( ) , fRow . getOriginRowIndex ( ) , poiCell ) ; if ( parent . isAdvancedContext ( ) && parent . getConfigAdvancedContext ( ) . getErrorSuffix ( ) != null && ! checkErrorMessageFromObjectInContext ( row - topRow , col - leftCol , cell , poiCell , value , sheetConfig , updateGui ) ) { return false ; } if ( cellAttributes != null ) { pass = validateAllRulesForSingleCell ( row - topRow , col - leftCol , cell , poiCell , value , sheetConfig , cellAttributes , updateGui ) ; } if ( pass ) { refreshAfterStatusChanged ( oldStatus , false , row - topRow , col - leftCol , cell , updateGui ) ; } return pass ;


signature:
public class ValidationHandler { /** * Validate by tie web sheet validation bean .
 * @ param poiCell the poi cell
 * @ param topRow the top row
 * @ param leftCol the left col
 * @ param cell the cell
 * @ param value the value
 * @ param updateGui the update gui
 * @ return true , if successful */
private boolean validateByTieWebSheetValidationBean ( final Cell poiCell , final int topRow , final int leftCol , final FacesCell cell , final String value , boolean updateGui ) { } }

implementation: if ( parent . getTieWebSheetValidationBean ( ) != null ) { String errormsg = null ; String fullName = ConfigurationUtility . getFullNameFromRow ( poiCell . getRow ( ) ) ; String saveAttr = SaveAttrsUtility . prepareContextAndAttrsForCell ( poiCell , fullName , parent . getCellHelper ( ) ) ; if ( saveAttr != null ) { int row = poiCell . getRowIndex ( ) ; int col = poiCell . getColumnIndex ( ) ; errormsg = parent . getTieWebSheetValidationBean ( ) . validate ( parent . getSerialDataContext ( ) . getDataContext ( ) , saveAttr , ConfigurationUtility . getFullNameFromRow ( poiCell . getRow ( ) ) , poiCell . getSheet ( ) . getSheetName ( ) , row , col , value ) ; if ( ( errormsg != null ) && ( ! errormsg . isEmpty ( ) ) ) { cell . setErrormsg ( errormsg ) ; refreshAfterStatusChanged ( false , true , row - topRow , col - leftCol , cell , updateGui ) ; return false ; } } } return true ;


signature:
public class ValidationHandler { /** * Check error message from object in context .
 * @ param formRow the form row
 * @ param formCol the form col
 * @ param cell the cell
 * @ param poiCell the poi cell
 * @ param value the value
 * @ param sheetConfig the sheet config
 * @ param updateGui the update gui
 * @ return true , if successful */
private boolean checkErrorMessageFromObjectInContext ( final int formRow , final int formCol , final FacesCell cell , final Cell poiCell , final String value , final SheetConfiguration sheetConfig , boolean updateGui ) { } }

implementation: @ SuppressWarnings ( "unchecked" ) HashMap < String , TieCell > tieCells = ( HashMap < String , TieCell > ) parent . getSerialDataContext ( ) . getDataContext ( ) . get ( "tiecells" ) ; if ( tieCells != null ) { TieCell tieCell = tieCells . get ( CellUtility . getSkeyFromPoiCell ( poiCell ) ) ; if ( tieCell != null && tieCell . getContextObject ( ) != null ) { String errorMethod = tieCell . getMethodStr ( ) + parent . getConfigAdvancedContext ( ) . getErrorSuffix ( ) ; String errorMessage = CellControlsUtility . getObjectPropertyValue ( tieCell . getContextObject ( ) , errorMethod , true ) ; if ( errorMessage != null && ! errorMessage . isEmpty ( ) ) { cell . setErrormsg ( errorMessage ) ; LOG . log ( Level . INFO , "Validation failed for sheet {0} row {1} column {2} : {3}" , new Object [ ] { poiCell . getSheet ( ) . getSheetName ( ) , poiCell . getRowIndex ( ) , poiCell . getColumnIndex ( ) , errorMessage } ) ; refreshAfterStatusChanged ( false , true , formRow , formCol , cell , updateGui ) ; return false ; } } } return true ;


signature:
public class ValidationHandler { /** * Validate all rules for single cell .
 * @ param formRow the form row
 * @ param formCol the form col
 * @ param cell the cell
 * @ param poiCell the poi cell
 * @ param value the value
 * @ param sheetConfig the sheet config
 * @ param cellAttributes the cell attributes
 * @ param updateGui the update gui
 * @ return true , if successful */
private boolean validateAllRulesForSingleCell ( final int formRow , final int formCol , final FacesCell cell , final Cell poiCell , final String value , final SheetConfiguration sheetConfig , final List < CellFormAttributes > cellAttributes , boolean updateGui ) { } }

implementation: Sheet sheet1 = parent . getWb ( ) . getSheet ( sheetConfig . getSheetName ( ) ) ; for ( CellFormAttributes attr : cellAttributes ) { boolean pass = doValidation ( value , attr , poiCell . getRowIndex ( ) , poiCell . getColumnIndex ( ) , sheet1 ) ; if ( ! pass ) { String errmsg = attr . getMessage ( ) ; if ( errmsg == null ) { errmsg = TieConstants . DEFALT_MSG_INVALID_INPUT ; } cell . setErrormsg ( errmsg ) ; LOG . log ( Level . INFO , "Validation failed for sheet {0} row {1} column {2} : {3}" , new Object [ ] { poiCell . getSheet ( ) . getSheetName ( ) , poiCell . getRowIndex ( ) , poiCell . getColumnIndex ( ) , errmsg } ) ; refreshAfterStatusChanged ( false , true , formRow , formCol , cell , updateGui ) ; return false ; } } return true ;


signature:
public class ValidationHandler { /** * Do validation .
 * @ param value the value
 * @ param attr the attr
 * @ param rowIndex the row index
 * @ param colIndex the col index
 * @ param sheet the sheet
 * @ return true , if successful */
private boolean doValidation ( final Object value , final CellFormAttributes attr , final int rowIndex , final int colIndex , final Sheet sheet ) { } }

implementation: boolean pass ; String attrValue = attr . getValue ( ) ; attrValue = attrValue . replace ( "$value" , value . toString ( ) + "" ) . replace ( "$rowIndex" , rowIndex + "" ) . replace ( "$colIndex" , colIndex + "" ) . replace ( "$sheetName" , sheet . getSheetName ( ) ) ; attrValue = ConfigurationUtility . replaceExpressionWithCellValue ( attrValue , rowIndex , sheet ) ; if ( attrValue . contains ( TieConstants . EL_START ) ) { Object returnObj = FacesUtility . evaluateExpression ( attrValue , Object . class ) ; attrValue = returnObj . toString ( ) ; pass = Boolean . parseBoolean ( attrValue ) ; } else { pass = parent . getCellHelper ( ) . evalBoolExpression ( attrValue ) ; } return pass ;


signature:
public class ValidationHandler { /** * Validate cell .
 * @ param target
 * the target
 * @ return true , if successful */
public final boolean validateCell ( final UIComponent target ) { } }

implementation: int [ ] rowcol = CellUtility . getRowColFromComponentAttributes ( target ) ; int row = rowcol [ 0 ] ; int col = rowcol [ 1 ] ; return validateWithRowColInCurrentPage ( row , col , true ) ;


signature:
public class ValidationHandler { /** * Validate current page .
 * @ return true , if successful */
public final boolean validateCurrentPage ( ) { } }

implementation: boolean allpass = true ; int top = parent . getCurrent ( ) . getCurrentTopRow ( ) ; for ( int irow = 0 ; irow < parent . getBodyRows ( ) . size ( ) ; irow ++ ) { if ( ! validateRowInCurrentPage ( irow + top , false ) ) { allpass = false ; } } return allpass ;


signature:
public class ValidationHandler { /** * Validate row in current page .
 * @ param irow the irow
 * @ param updateGui the update gui
 * @ return true , if successful */
public final boolean validateRowInCurrentPage ( final int irow , final boolean updateGui ) { } }

implementation: SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( parent . getCurrent ( ) . getCurrentTabName ( ) ) ; return this . validateRow ( irow , sheetConfig , updateGui ) ;


signature:
public class ValidationHandler { /** * Validate row .
 * @ param irow the irow
 * @ param sheetConfig the sheet config
 * @ param updateGui the update gui
 * @ return true , if successful */
private boolean validateRow ( final int irow , final SheetConfiguration sheetConfig , boolean updateGui ) { } }

implementation: boolean pass = true ; if ( sheetConfig == null ) { return pass ; } int top = sheetConfig . getBodyCellRange ( ) . getTopRow ( ) ; List < FacesCell > cellRow = parent . getBodyRows ( ) . get ( irow - top ) . getCells ( ) ; for ( int index = 0 ; index < cellRow . size ( ) ; index ++ ) { FacesCell fcell = cellRow . get ( index ) ; if ( ( fcell != null ) && ( ! validateWithRowColInCurrentPage ( irow , fcell . getColumnIndex ( ) , updateGui ) ) ) { pass = false ; } } return pass ;


signature:
public class ValidationHandler { /** * Triggered when value in cells changed . e . g . user edit cell .
 * @ param event
 * ajax event . */
public void valueChangeEvent ( final AjaxBehaviorEvent event ) { } }

implementation:
try { FacesContext facesContext = FacesContext . getCurrentInstance ( ) ; String tblName = parent . getWebFormClientId ( ) ; UIComponent target = event . getComponent ( ) ; boolean pass = validateCell ( target ) ; if ( pass ) { // to improve performance , re - validate current row only
// page validation take times . will happen when change tab ( page )
// or
// reload page .
int [ ] rowcol = CellUtility . getRowColFromComponentAttributes ( target ) ; validateRowInCurrentPage ( rowcol [ 0 ] , true ) ; refreshCachedCellsInCurrentPage ( facesContext , tblName ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Validation error:" + ex . getLocalizedMessage ( ) , ex ) ; }


signature:
public class ValidationHandler { /** * Refresh cached cells in current page .
 * @ param facesContext
 * the faces context
 * @ param tblName
 * the tbl name */
private void refreshCachedCellsInCurrentPage ( final FacesContext facesContext , final String tblName ) { } }

implementation:
// refresh current page calculation fields
UIComponent s = facesContext . getViewRoot ( ) . findComponent ( tblName ) ; if ( s == null ) { return ; } DataTable webDataTable = ( DataTable ) s ; int first = webDataTable . getFirst ( ) ; int rowsToRender = webDataTable . getRowsToRender ( ) ; int rowCounts = webDataTable . getRowCount ( ) ; int top = parent . getCurrent ( ) . getCurrentTopRow ( ) ; int left = parent . getCurrent ( ) . getCurrentLeftColumn ( ) ; for ( int i = first ; i <= ( first + rowsToRender ) ; i ++ ) { if ( i < rowCounts ) { refreshCachedCellsInRow ( tblName , top , left , i ) ; } }


signature:
public class ValidationHandler { /** * Refresh cached cells in row .
 * @ param tblName
 * the tbl name
 * @ param top
 * the top
 * @ param left
 * the left
 * @ param i
 * the i */
private void refreshCachedCellsInRow ( final String tblName , final int top , final int left , final int i ) { } }

implementation: FacesRow dataRow = parent . getBodyRows ( ) . get ( i ) ; int isize = dataRow . getCells ( ) . size ( ) ; for ( int index = 0 ; index < isize ; index ++ ) { FacesCell fcell = dataRow . getCells ( ) . get ( index ) ; Cell poiCell = parent . getCellHelper ( ) . getPoiCellWithRowColFromCurrentPage ( i + top , index + left ) ; if ( poiCell != null ) { parent . getHelper ( ) . getWebSheetLoader ( ) . refreshCachedCell ( tblName , i , index , poiCell , fcell ) ; } }


signature:
public class ValidationHandler { /** * set submit mode flag with javascript for holding in client side .
 * @ param fullflag
 * true or false */
public void setSubmitModeInView ( final Boolean fullflag ) { } }

implementation: if ( FacesContext . getCurrentInstance ( ) != null ) { Map < String , Object > viewMap = FacesContext . getCurrentInstance ( ) . getViewRoot ( ) . getViewMap ( ) ; if ( viewMap != null ) { Boolean flag = ( Boolean ) viewMap . get ( TieConstants . SUBMITMODE ) ; if ( ( flag == null ) || ( ! flag . equals ( fullflag ) ) ) { viewMap . put ( TieConstants . SUBMITMODE , fullflag ) ; } } }


signature:
public class ValidationHandler { /** * triggered validation process before actions like save or submit .
 * @ return true ( pass ) false ( failed ) */
public boolean preValidation ( ) { } }

implementation:
String currentTabName = parent . getCurrent ( ) . getCurrentTabName ( ) ; String tabName = null ; String firstInvalidTabName = null ; boolean reload = false ; for ( Map . Entry < String , SheetConfiguration > entry : parent . getSheetConfigMap ( ) . entrySet ( ) ) { tabName = entry . getKey ( ) ; // if not reload and tabname = = current then skip reloading .
if ( reload || ( ! tabName . equals ( currentTabName ) ) ) { parent . getWebSheetLoader ( ) . prepareWorkShee ( tabName ) ; reload = true ; } if ( ! parent . getValidationHandler ( ) . validateCurrentPage ( ) && ( firstInvalidTabName == null ) ) { firstInvalidTabName = tabName ; } } if ( firstInvalidTabName != null ) { if ( ! tabName . equals ( firstInvalidTabName ) ) { parent . getHelper ( ) . getWebSheetLoader ( ) . loadWorkSheet ( firstInvalidTabName ) ; } return false ; } return true ;


signature:
public class CellAttributesMap { /** * clear all the related maps . */
public final void clear ( ) { } }

implementation: if ( this . templateCommentMap != null ) { this . templateCommentMap . clear ( ) ; } if ( this . cellDatePattern != null ) { this . cellDatePattern . clear ( ) ; } if ( this . cellInputAttributes != null ) { this . cellInputAttributes . clear ( ) ; } if ( this . cellInputType != null ) { this . cellInputType . clear ( ) ; } if ( this . cellSelectItemsAttributes != null ) { this . cellSelectItemsAttributes . clear ( ) ; }


signature:
public class WebSheetLoader { /** * Load header rows .
 * @ param sheetConfig
 * the sheet config
 * @ param cellRangeMap
 * the cell range map
 * @ param skippedRegionCells
 * the skipped region cells */
private void loadHeaderRows ( final SheetConfiguration sheetConfig , final Map < String , CellRangeAddress > cellRangeMap , final List < String > skippedRegionCells ) { } }

implementation:
int top = sheetConfig . getHeaderCellRange ( ) . getTopRow ( ) ; int bottom = sheetConfig . getHeaderCellRange ( ) . getBottomRow ( ) ; int left = sheetConfig . getHeaderCellRange ( ) . getLeftCol ( ) ; int right = sheetConfig . getHeaderCellRange ( ) . getRightCol ( ) ; String sheetName = sheetConfig . getSheetName ( ) ; Sheet sheet1 = parent . getWb ( ) . getSheet ( sheetName ) ; int totalWidth = CellStyleUtility . calcTotalWidth ( sheet1 , left , right , WebSheetUtility . pixel2WidthUnits ( parent . getLineNumberColumnWidth ( ) + parent . getAddRowColumnWidth ( ) ) ) ; RangeBuildRef rangeBuildRef = new RangeBuildRef ( left , right , totalWidth , sheet1 ) ; if ( sheetConfig . isFixedWidthStyle ( ) ) { parent . setTableWidthStyle ( "table-layout: fixed; width:" + WebSheetUtility . widthUnits2Pixel ( totalWidth ) + "px;" ) ; } parent . setLineNumberColumnWidthStyle ( getWidthStyle ( WebSheetUtility . pixel2WidthUnits ( parent . getLineNumberColumnWidth ( ) ) , totalWidth ) ) ; parent . setAddRowColumnWidthStyle ( "width:" + parent . getAddRowColumnWidth ( ) + "px;" ) ; parent . getHeaderRows ( ) . clear ( ) ; if ( top < 0 ) { // this is blank configuration . set column letter as header
parent . getHeaderRows ( ) . add ( loadHeaderRowWithoutConfigurationTab ( rangeBuildRef , true ) ) ; // set showlinenumber to true as default
parent . setShowLineNumber ( true ) ; } else { parent . getHeaderRows ( ) . add ( loadHeaderRowWithoutConfigurationTab ( rangeBuildRef , false ) ) ; for ( int i = top ; i <= bottom ; i ++ ) { parent . getHeaderRows ( ) . add ( loadHeaderRowWithConfigurationTab ( sheetConfig , rangeBuildRef , i , cellRangeMap , skippedRegionCells ) ) ; } // set showlinenumber to false as default
parent . setShowLineNumber ( false ) ; }


signature:
public class WebSheetLoader { /** * Load header row without configuration tab .
 * @ param rangeBuildRef
 * the range build ref
 * @ param rendered
 * the rendered
 * @ return the list */
private List < HeaderCell > loadHeaderRowWithoutConfigurationTab ( final RangeBuildRef rangeBuildRef , final boolean rendered ) { } }

implementation: int firstCol = rangeBuildRef . getLeft ( ) ; int lastCol = rangeBuildRef . getRight ( ) ; double totalWidth = ( double ) rangeBuildRef . getTotalWidth ( ) ; Sheet sheet1 = rangeBuildRef . getSheet ( ) ; List < HeaderCell > headercells = new ArrayList < > ( ) ; for ( int i = firstCol ; i <= lastCol ; i ++ ) { if ( ! sheet1 . isColumnHidden ( i ) ) { String style = getHeaderColumnStyle ( parent . getWb ( ) , null , sheet1 . getColumnWidth ( i ) , totalWidth ) ; headercells . add ( new HeaderCell ( "1" , "1" , style , style , WebSheetUtility . getExcelColumnName ( i ) , rendered , true ) ) ; } } fillToMaxColumns ( headercells ) ; return headercells ;


signature:
public class WebSheetLoader { /** * Fill to max columns .
 * @ param headercells
 * the headercells */
private void fillToMaxColumns ( final List < HeaderCell > headercells ) { } }

implementation: if ( headercells . size ( ) < parent . getMaxColCounts ( ) ) { int fills = parent . getMaxColCounts ( ) - headercells . size ( ) ; for ( int s = 0 ; s < fills ; s ++ ) { headercells . add ( new HeaderCell ( "1" , "1" , "" , "" , "" , false , false ) ) ; } }


signature:
public class WebSheetLoader { /** * Gets the header column style .
 * @ param wb
 * the wb
 * @ param cell
 * the cell
 * @ param colWidth
 * the col width
 * @ param totalWidth
 * the total width
 * @ return the header column style */
private String getHeaderColumnStyle ( final Workbook wb , final Cell cell , final double colWidth , final double totalWidth ) { } }

implementation: String columnstyle = "" ; if ( cell != null ) { columnstyle += CellStyleUtility . getCellStyle ( wb , cell , "" ) + CellStyleUtility . getCellFontStyle ( wb , cell ) ; } columnstyle = columnstyle + getWidthStyle ( colWidth , totalWidth ) ; return columnstyle ;


signature:
public class WebSheetLoader { /** * Gets the width style .
 * @ param colWidth
 * the col width
 * @ param totalWidth
 * the total width
 * @ return the width style */
private String getWidthStyle ( final double colWidth , final double totalWidth ) { } }

implementation: double percentage = FacesUtility . round ( TieConstants . CELL_FORMAT_PERCENTAGE_VALUE * colWidth / totalWidth , 2 ) ; return "width:" + percentage + TieConstants . CELL_FORMAT_PERCENTAGE_SYMBOL + ";" ;


signature:
public class WebSheetLoader { /** * Load header row with configuration tab .
 * @ param sheetConfig
 * the sheet config
 * @ param rangeBuildRef
 * the range build ref
 * @ param currentRow
 * the current row
 * @ param cellRangeMap
 * the cell range map
 * @ param skippedRegionCells
 * the skipped region cells
 * @ return the list */
private List < HeaderCell > loadHeaderRowWithConfigurationTab ( final SheetConfiguration sheetConfig , final RangeBuildRef rangeBuildRef , final int currentRow , final Map < String , CellRangeAddress > cellRangeMap , final List < String > skippedRegionCells ) { } }

implementation: Sheet sheet1 = rangeBuildRef . getSheet ( ) ; int left = rangeBuildRef . getLeft ( ) ; int right = rangeBuildRef . getRight ( ) ; double totalWidth = ( double ) rangeBuildRef . getTotalWidth ( ) ; Row row = sheet1 . getRow ( currentRow ) ; List < HeaderCell > headercells = new ArrayList < > ( ) ; for ( int cindex = left ; cindex <= right ; cindex ++ ) { String cellindex = CellUtility . getCellIndexNumberKey ( cindex , currentRow ) ; if ( ! skippedRegionCells . contains ( cellindex ) && ! sheet1 . isColumnHidden ( cindex ) ) { Cell cell = null ; if ( row != null ) { cell = row . getCell ( cindex , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; } int originRowIndex = ConfigurationUtility . getOriginalRowNumInHiddenColumn ( row ) ; if ( cell != null ) { FacesCell fcell = new FacesCell ( ) ; CellUtility . convertCell ( sheetConfig , fcell , cell , cellRangeMap , originRowIndex , parent . getCellAttributesMap ( ) , null ) ; parent . getPicHelper ( ) . setupFacesCellPictureCharts ( sheet1 , fcell , cell , WebSheetUtility . getFullCellRefName ( sheet1 , cell ) ) ; CellStyleUtility . setupCellStyle ( parent . getWb ( ) , fcell , cell , row . getHeightInPoints ( ) ) ; fcell . setColumnStyle ( fcell . getColumnStyle ( ) + getColumnWidthStyle ( sheet1 , cellRangeMap , cellindex , cindex , totalWidth ) ) ; fcell . setColumnIndex ( cindex ) ; headercells . add ( new HeaderCell ( Integer . toString ( fcell . getRowspan ( ) ) , Integer . toString ( fcell . getColspan ( ) ) , fcell . getStyle ( ) , fcell . getColumnStyle ( ) , CellUtility . getCellValueWithFormat ( cell , parent . getFormulaEvaluator ( ) , parent . getDataFormatter ( ) ) , true , true ) ) ; } } } fillToMaxColumns ( headercells ) ; return headercells ;


signature:
public class WebSheetLoader { /** * Gets the column width style .
 * @ param sheet1
 * the sheet 1
 * @ param cellRangeMap
 * the cell range map
 * @ param cellindex
 * the cellindex
 * @ param cindex
 * the cindex
 * @ param totalWidth
 * the total width
 * @ return the column width style */
private String getColumnWidthStyle ( final Sheet sheet1 , final Map < String , CellRangeAddress > cellRangeMap , final String cellindex , final int cindex , final double totalWidth ) { } }

implementation:
CellRangeAddress caddress = cellRangeMap . get ( cellindex ) ; double colWidth ; // check whether the cell has rowspan or colspan
if ( caddress != null ) { colWidth = CellStyleUtility . calcTotalWidth ( sheet1 , caddress . getFirstColumn ( ) , caddress . getLastColumn ( ) , 0 ) ; } else { colWidth = sheet1 . getColumnWidth ( cindex ) ; } return getWidthStyle ( colWidth , totalWidth ) ;


signature:
public class WebSheetLoader { /** * Clear workbook . */
private void clearWorkbook ( ) { } }

implementation: parent . setFormulaEvaluator ( null ) ; parent . setDataFormatter ( null ) ; parent . setSheetConfigMap ( null ) ; parent . setTabs ( null ) ; parent . getSerialDataContext ( ) . setDataContext ( null ) ; parent . setPicturesMap ( null ) ; parent . setHeaderRows ( null ) ; parent . setBodyRows ( null ) ; parent . setWb ( null ) ; parent . getHeaderRows ( ) . clear ( ) ; parent . getBodyRows ( ) . clear ( ) ; parent . getCharsData ( ) . getChartsMap ( ) . clear ( ) ; parent . getCharsData ( ) . getChartDataMap ( ) . clear ( ) ; parent . getCharsData ( ) . getChartAnchorsMap ( ) . clear ( ) ; parent . getCharsData ( ) . getChartPositionMap ( ) . clear ( ) ; parent . getCellAttributesMap ( ) . clear ( ) ;


signature:
public class WebSheetLoader { /** * Load workbook .
 * @ param fis
 * the fis
 * @ param dataContext
 * the data context
 * @ return the int */
public final int loadWorkbook ( final InputStream fis , final Map < String , Object > dataContext ) { } }

implementation: try { Workbook wb = WorkbookFactory . create ( fis ) ; int ireturn = loadWorkbook ( wb , dataContext ) ; fis . close ( ) ; return ireturn ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Web Form loadWorkbook Error Exception = " + e . getLocalizedMessage ( ) , e ) ; return - 1 ; }


signature:
public class WebSheetLoader { /** * Load workbook .
 * @ param wb
 * the wb
 * @ param dataContext
 * the data context
 * @ return the int */
public final int loadWorkbook ( final Workbook wb , final Map < String , Object > dataContext ) { } }

implementation:
try { clearWorkbook ( ) ; // only support xssf workbook now since 2016 July
if ( ! ( wb instanceof XSSFWorkbook ) ) { LOG . fine ( "Error: WebSheet only support xlsx template." ) ; return - 1 ; } LOG . fine ( "Begin load work book..." ) ; parent . setWb ( wb ) ; parent . getSerialDataContext ( ) . setDataContext ( dataContext ) ; parent . setSheetConfigMap ( new ConfigurationHandler ( parent ) . buildConfiguration ( ) ) ; parent . reCalcMaxColCounts ( ) ; parent . getChartHelper ( ) . loadChartsMap ( ) ; parent . getPicHelper ( ) . loadPicturesMap ( ) ; initSheet ( ) ; initTabs ( ) ; if ( ! parent . getTabs ( ) . isEmpty ( ) ) { loadWorkSheet ( parent . getTabs ( ) . get ( 0 ) . getTitle ( ) ) ; } } catch ( Exception e ) { LOG . log ( Level . FINE , "Web Form loadWorkbook Error Exception = " + e . getLocalizedMessage ( ) , e ) ; return - 1 ; } return 1 ;


signature:
public class WebSheetLoader { /** * Inits the tabs . */
private void initTabs ( ) { } }

implementation: parent . setTabs ( new ArrayList < TabModel > ( ) ) ; if ( parent . getSheetConfigMap ( ) != null ) { for ( String key : parent . getSheetConfigMap ( ) . keySet ( ) ) { parent . getTabs ( ) . add ( new TabModel ( "form_" + key , key , "form" ) ) ; } }


signature:
public class WebSheetLoader { /** * load data process . unfinished . */
private void loadData ( ) { } }

implementation:
if ( parent . getSerialDataContext ( ) . getDataContext ( ) == null ) { // no data objects available .
return ; } if ( parent . isAdvancedContext ( ) ) { parent . getSerialDataContext ( ) . getDataContext ( ) . put ( "tiecells" , new HashMap < String , TieCell > ( ) ) ; } for ( SheetConfiguration sheetConfig : parent . getSheetConfigMap ( ) . values ( ) ) { List < RowsMapping > currentRowsMappingList = null ; ConfigBuildRef configBuildRef = new ConfigBuildRef ( parent . getWbWrapper ( ) , parent . getWb ( ) . getSheet ( sheetConfig . getSheetName ( ) ) , parent . getExpEngine ( ) , parent . getCellHelper ( ) , sheetConfig . getCachedCells ( ) , parent . getCellAttributesMap ( ) , sheetConfig . getFinalCommentMap ( ) ) ; int length = sheetConfig . getFormCommand ( ) . buildAt ( null , configBuildRef , sheetConfig . getFormCommand ( ) . getTopRow ( ) , parent . getSerialDataContext ( ) . getDataContext ( ) , currentRowsMappingList ) ; sheetConfig . setShiftMap ( configBuildRef . getShiftMap ( ) ) ; sheetConfig . setCollectionObjNameMap ( configBuildRef . getCollectionObjNameMap ( ) ) ; sheetConfig . setCommandIndexMap ( configBuildRef . getCommandIndexMap ( ) ) ; sheetConfig . setWatchList ( configBuildRef . getWatchList ( ) ) ; sheetConfig . setBodyAllowAddRows ( configBuildRef . isBodyAllowAdd ( ) ) ; sheetConfig . getBodyCellRange ( ) . setBottomRow ( sheetConfig . getFormCommand ( ) . getTopRow ( ) + length - 1 ) ; sheetConfig . setBodyPopulated ( true ) ; } parent . getCellHelper ( ) . reCalc ( ) ;


signature:
public class WebSheetLoader { /** * Refresh data . */
public void refreshData ( ) { } }

implementation:
if ( parent . getSerialDataContext ( ) . getDataContext ( ) == null ) { // no data objects available .
return ; } for ( SheetConfiguration sheetConfig : parent . getSheetConfigMap ( ) . values ( ) ) { for ( int irow = sheetConfig . getFormCommand ( ) . getTopRow ( ) ; irow < sheetConfig . getFormCommand ( ) . getLastRow ( ) ; irow ++ ) { refreshDataForRow ( parent . getWb ( ) . getSheet ( sheetConfig . getSheetName ( ) ) . getRow ( irow ) ) ; } } parent . getCellHelper ( ) . reCalc ( ) ;


signature:
public class WebSheetLoader { /** * Refresh data for row .
 * @ param row the row */
private void refreshDataForRow ( Row row ) { } }

implementation: if ( row == null ) { return ; } String saveAttrList = SaveAttrsUtility . getSaveAttrListFromRow ( row ) ; if ( saveAttrList != null ) { String [ ] saveAttrs = saveAttrList . split ( "," ) ; for ( String fullSaveAttr : saveAttrs ) { refreshDataForCell ( row , fullSaveAttr ) ; } }


signature:
public class WebSheetLoader { /** * refresh data for single cell .
 * @ param row row .
 * @ param fullSaveAttr fullSaveAttr . */
private void refreshDataForCell ( Row row , String fullSaveAttr ) { } }

implementation: if ( fullSaveAttr != null ) { try { String fullName = ConfigurationUtility . getFullNameFromRow ( row ) ; if ( fullName != null ) { parent . getCellHelper ( ) . restoreDataContext ( fullName ) ; SaveAttrsUtility . refreshSheetRowFromContext ( parent . getSerialDataContext ( ) . getDataContext ( ) , fullSaveAttr , row , parent . getExpEngine ( ) ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "refreshDataForCell with fullAaveAttr =" + fullSaveAttr + " error = " + ex . getMessage ( ) , ex ) ; } }


signature:
public class WebSheetLoader { /** * Find tab index with name .
 * @ param tabname
 * the tabname
 * @ return the int */
public final int findTabIndexWithName ( final String tabname ) { } }

implementation: for ( int i = 0 ; i < parent . getTabs ( ) . size ( ) ; i ++ ) { if ( parent . getTabs ( ) . get ( i ) . getTitle ( ) . equalsIgnoreCase ( tabname ) ) { return i ; } } return - 1 ;


signature:
public class WebSheetLoader { /** * Load work sheet .
 * @ param tabName
 * the tab name */
public final void loadWorkSheet ( final String tabName ) { } }

implementation:
prepareWorkShee ( tabName ) ; parent . getValidationHandler ( ) . validateCurrentPage ( ) ; createDynamicColumns ( tabName ) ; // reset datatable current page to 1
setDataTablePage ( 0 ) ; parent . getCurrent ( ) . setCurrentDataContextName ( null ) ; saveObjs ( ) ; if ( ( RequestContext . getCurrentInstance ( ) != null ) && ( parent . getClientId ( ) != null ) ) { RequestContext . getCurrentInstance ( ) . update ( parent . getClientId ( ) + ":websheettab" ) ; }


signature:
public class WebSheetLoader { /** * prepare worksheet for loading .
 * this only load at backend without refresh gui .
 * @ param tabName the tab name */
public final void prepareWorkShee ( final String tabName ) { } }

implementation:
int tabIndex = findTabIndexWithName ( tabName ) ; if ( parent . getWebFormTabView ( ) != null ) { parent . getWebFormTabView ( ) . setActiveIndex ( tabIndex ) ; } parent . getCurrent ( ) . setCurrentTabName ( tabName ) ; String sheetName = parent . getSheetConfigMap ( ) . get ( tabName ) . getSheetName ( ) ; Sheet sheet1 = parent . getWb ( ) . getSheet ( sheetName ) ; parent . getWb ( ) . setActiveSheet ( parent . getWb ( ) . getSheetIndex ( sheet1 ) ) ; SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( tabName ) ; parent . setMaxRowsPerPage ( parent . getSheetConfigMap ( ) . get ( tabName ) . getMaxRowPerPage ( ) ) ; parent . setBodyAllowAddRows ( parent . getSheetConfigMap ( ) . get ( tabName ) . isBodyAllowAddRows ( ) ) ; // populate repeat rows before setup cell range map
Map < String , CellRangeAddress > cellRangeMap = ConfigurationUtility . indexMergedRegion ( sheet1 ) ; List < String > skippedRegionCells = ConfigurationUtility . skippedRegionCells ( sheet1 ) ; loadHeaderRows ( sheetConfig , cellRangeMap , skippedRegionCells ) ; loadBodyRows ( sheetConfig , cellRangeMap , skippedRegionCells ) ;


signature:
public class WebSheetLoader { /** * Sets the data table page .
 * @ param first
 * the new data table page */
private void setDataTablePage ( final int first ) { } }

implementation: if ( parent . getWebFormClientId ( ) != null ) { final DataTable d = ( DataTable ) FacesContext . getCurrentInstance ( ) . getViewRoot ( ) . findComponent ( parent . getWebFormClientId ( ) ) ; if ( d != null ) { d . setFirst ( first ) ; } }


signature:
public class WebSheetLoader { /** * Save objs . */
private void saveObjs ( ) { } }

implementation: try { if ( FacesContext . getCurrentInstance ( ) != null ) { Map < String , Object > viewMap = FacesContext . getCurrentInstance ( ) . getViewRoot ( ) . getViewMap ( ) ; viewMap . put ( "currentTabName" , parent . getCurrent ( ) . getCurrentTabName ( ) ) ; viewMap . put ( TieConstants . SUBMITMODE , parent . getSubmitMode ( ) ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "saveobjs in viewMap error = " + ex . getMessage ( ) , ex ) ; }


signature:
public class WebSheetLoader { /** * Setup row info .
 * @ param facesRow
 * the faces row
 * @ param sheet1
 * the sheet 1
 * @ param row
 * the row
 * @ param rowIndex
 * the row index
 * @ param allowAdd
 * the allow add */
private void setupRowInfo ( final FacesRow facesRow , final Sheet sheet1 , final Row row , final int rowIndex , final boolean allowAdd ) { } }

implementation: facesRow . setAllowAdd ( allowAdd ) ; if ( row != null ) { facesRow . setRendered ( ! row . getZeroHeight ( ) ) ; facesRow . setRowheight ( row . getHeight ( ) ) ; int rowNum = ConfigurationUtility . getOriginalRowNumInHiddenColumn ( row ) ; facesRow . setOriginRowIndex ( rowNum ) ; } else { facesRow . setRendered ( true ) ; facesRow . setRowheight ( sheet1 . getDefaultRowHeight ( ) ) ; facesRow . setOriginRowIndex ( rowIndex ) ; }


signature:
public class WebSheetLoader { /** * Load body rows .
 * @ param sheetConfig
 * the sheet config
 * @ param cellRangeMap
 * the cell range map
 * @ param skippedRegionCells
 * the skipped region cells */
private void loadBodyRows ( final SheetConfiguration sheetConfig , final Map < String , CellRangeAddress > cellRangeMap , final List < String > skippedRegionCells ) { } }

implementation: int top = sheetConfig . getBodyCellRange ( ) . getTopRow ( ) ; int bottom = CellUtility . getBodyBottomFromConfig ( sheetConfig ) ; int left = sheetConfig . getBodyCellRange ( ) . getLeftCol ( ) ; int right = sheetConfig . getBodyCellRange ( ) . getRightCol ( ) ; String sheetName = sheetConfig . getSheetName ( ) ; Sheet sheet1 = parent . getWb ( ) . getSheet ( sheetName ) ; parent . getBodyRows ( ) . clear ( ) ; clearCache ( ) ; for ( int i = top ; i <= bottom ; i ++ ) { parent . getBodyRows ( ) . add ( assembleFacesBodyRow ( i , sheet1 , left , right , sheetConfig , cellRangeMap , skippedRegionCells ) ) ; } sheetConfig . setBodyPopulated ( true ) ; parent . getCurrent ( ) . setCurrentTopRow ( top ) ; parent . getCurrent ( ) . setCurrentLeftColumn ( left ) ;


signature:
public class WebSheetLoader { /** * Assemble faces body row .
 * @ param rowIndex
 * the row index
 * @ param sheet1
 * the sheet 1
 * @ param left
 * the left
 * @ param right
 * the right
 * @ param sheetConfig
 * the sheet config
 * @ param cellRangeMap
 * the cell range map
 * @ param skippedRegionCells
 * the skipped region cells
 * @ return the faces row */
private FacesRow assembleFacesBodyRow ( final int rowIndex , final Sheet sheet1 , final int left , final int right , final SheetConfiguration sheetConfig , final Map < String , CellRangeAddress > cellRangeMap , final List < String > skippedRegionCells ) { } }

implementation: FacesRow facesRow = new FacesRow ( rowIndex ) ; Row row = sheet1 . getRow ( rowIndex ) ; setupRowInfo ( facesRow , sheet1 , row , rowIndex , CommandUtility . isRowAllowAdd ( row , sheetConfig ) ) ; String saveAttrList = SaveAttrsUtility . getSaveAttrListFromRow ( row ) ; List < FacesCell > bodycells = new ArrayList < > ( ) ; for ( int cindex = left ; cindex <= right ; cindex ++ ) { String cellindex = CellUtility . getCellIndexNumberKey ( cindex , rowIndex ) ; if ( ! skippedRegionCells . contains ( cellindex ) && ! sheet1 . isColumnHidden ( cindex ) ) { Cell cell = null ; if ( row != null ) { cell = row . getCell ( cindex , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; } if ( cell != null ) { FacesCell fcell = new FacesCell ( ) ; CellUtility . convertCell ( sheetConfig , fcell , cell , cellRangeMap , facesRow . getOriginRowIndex ( ) , parent . getCellAttributesMap ( ) , saveAttrList ) ; parent . getPicHelper ( ) . setupFacesCellPictureCharts ( sheet1 , fcell , cell , WebSheetUtility . getFullCellRefName ( sheet1 , cell ) ) ; CellStyleUtility . setupCellStyle ( parent . getWb ( ) , fcell , cell , row . getHeightInPoints ( ) ) ; fcell . setColumnIndex ( cindex ) ; bodycells . add ( fcell ) ; addCache ( cell ) ; } else { bodycells . add ( null ) ; } } else { bodycells . add ( null ) ; } } facesRow . setCells ( bodycells ) ; return facesRow ;


signature:
public class WebSheetLoader { /** * Refresh cached cell .
 * @ param tblName
 * the tbl name
 * @ param i
 * the i
 * @ param index
 * the index
 * @ param cell
 * the cell
 * @ param fcell
 * the fcell */
public final void refreshCachedCell ( final String tblName , final int i , final int index , final Cell cell , final FacesCell fcell ) { } }

implementation: if ( ( cell != null ) && ( cell . getCellTypeEnum ( ) == CellType . FORMULA ) && ( tblName != null ) ) { try { processRefreshCell ( tblName , i , index , cell , fcell ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "refresh Cached Cell error : " + ex . getLocalizedMessage ( ) , ex ) ; } }


signature:
public class WebSheetLoader { /** * Process refresh cell .
 * @ param tblName
 * the tbl name
 * @ param i
 * the i
 * @ param index
 * the index
 * @ param cell
 * the cell
 * @ param fcell
 * the fcell */
private void processRefreshCell ( final String tblName , final int i , final int index , final Cell cell , final FacesCell fcell ) { } }

implementation: String newValue = CellUtility . getCellValueWithFormat ( cell , parent . getFormulaEvaluator ( ) , parent . getDataFormatter ( ) ) ; if ( parent . getCachedCells ( ) . isValueChanged ( cell , newValue ) ) { if ( fcell . isHasSaveAttr ( ) ) { parent . getCellHelper ( ) . saveDataInContext ( cell , newValue ) ; } RequestContext . getCurrentInstance ( ) . update ( tblName + ":" + i + ":cocalc" + index ) ; parent . getCachedCells ( ) . put ( cell , CellType . FORMULA ) ; }


signature:
public class WebSheetLoader { /** * Creates the dynamic columns .
 * @ param tabName
 * the tab name */
private void createDynamicColumns ( final String tabName ) { } }

implementation: SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( tabName ) ; int left = sheetConfig . getBodyCellRange ( ) . getLeftCol ( ) ; int right = sheetConfig . getBodyCellRange ( ) . getRightCol ( ) ; parent . getColumns ( ) . clear ( ) ; for ( int i = left ; i <= right ; i ++ ) { parent . getColumns ( ) . add ( "column" + ( i - left ) ) ; }


signature:
public class WebSheetLoader { /** * Adds the repeat row .
 * @ param rowIndex
 * the row index */
public final void addRepeatRow ( final int rowIndex ) { } }

implementation:
try { SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( parent . getCurrent ( ) . getCurrentTabName ( ) ) ; Sheet sheet = parent . getWb ( ) . getSheet ( sheetConfig . getSheetName ( ) ) ; ConfigBuildRef configBuildRef = new ConfigBuildRef ( parent . getWbWrapper ( ) , sheet , parent . getExpEngine ( ) , parent . getCellHelper ( ) , sheetConfig . getCachedCells ( ) , parent . getCellAttributesMap ( ) , sheetConfig . getFinalCommentMap ( ) ) ; // set add mode
configBuildRef . setAddMode ( true ) ; configBuildRef . setCollectionObjNameMap ( sheetConfig . getCollectionObjNameMap ( ) ) ; configBuildRef . setCommandIndexMap ( sheetConfig . getCommandIndexMap ( ) ) ; configBuildRef . setShiftMap ( sheetConfig . getShiftMap ( ) ) ; configBuildRef . setWatchList ( sheetConfig . getWatchList ( ) ) ; int length = CommandUtility . addRow ( configBuildRef , rowIndex , parent . getSerialDataContext ( ) . getDataContext ( ) ) ; refreshBodyRowsInRange ( configBuildRef . getInsertPosition ( ) , length , sheet , sheetConfig ) ; parent . getCellHelper ( ) . reCalc ( ) ; } catch ( AddRowException e ) { FacesContext . getCurrentInstance ( ) . addMessage ( null , new FacesMessage ( FacesMessage . SEVERITY_ERROR , "Add Row Error" , e . getMessage ( ) ) ) ; LOG . log ( Level . SEVERE , "Add row error = " + e . getLocalizedMessage ( ) , e ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Add row error = " + ex . getLocalizedMessage ( ) , ex ) ; }


signature:
public class WebSheetLoader { /** * Refresh body rows in range .
 * @ param insertPosition
 * the insert position
 * @ param length
 * the length
 * @ param sheet
 * the sheet
 * @ param sheetConfig
 * the sheet config */
private void refreshBodyRowsInRange ( final int insertPosition , final int length , final Sheet sheet , final SheetConfiguration sheetConfig ) { } }

implementation: Map < String , CellRangeAddress > cellRangeMap = ConfigurationUtility . indexMergedRegion ( sheet ) ; List < String > skippedRegionCells = ConfigurationUtility . skippedRegionCells ( sheet ) ; int top = sheetConfig . getBodyCellRange ( ) . getTopRow ( ) ; int left = sheetConfig . getBodyCellRange ( ) . getLeftCol ( ) ; int right = sheetConfig . getBodyCellRange ( ) . getRightCol ( ) ; for ( int irow = insertPosition ; irow < ( insertPosition + length ) ; irow ++ ) { parent . getBodyRows ( ) . add ( irow - top , assembleFacesBodyRow ( irow , sheet , left , right , sheetConfig , cellRangeMap , skippedRegionCells ) ) ; } for ( int irow = insertPosition + length - top ; irow < parent . getBodyRows ( ) . size ( ) ; irow ++ ) { FacesRow facesrow = parent . getBodyRows ( ) . get ( irow ) ; facesrow . setRowIndex ( facesrow . getRowIndex ( ) + length ) ; }


signature:
public class WebSheetLoader { /** * Sets the unsaved status .
 * @ param requestContext
 * the request context
 * @ param statusFlag
 * the status flag */
public void setUnsavedStatus ( final RequestContext requestContext , final Boolean statusFlag ) { } }

implementation:
// in client js should have setUnsavedState method
if ( requestContext != null ) { LOG . log ( Level . FINE , "run setUnsavedState( {} )" , statusFlag . toString ( ) ) ; requestContext . execute ( "setUnsavedState(" + statusFlag . toString ( ) + ")" ) ; }


signature:
public class WebSheetLoader { /** * Checks if is unsaved status .
 * @ return the boolean */
public final Boolean isUnsavedStatus ( ) { } }

implementation: Map < String , Object > viewMap = FacesContext . getCurrentInstance ( ) . getViewRoot ( ) . getViewMap ( ) ; Boolean flag = ( Boolean ) viewMap . get ( TieConstants . UNSAVEDSTATE ) ; if ( flag == null ) { return false ; } return flag ;


signature:
public class ConfigRangeAttrs { /** * recover by using it ' s address .
 * @ param sheet
 * sheet . */
public final void recover ( final Sheet sheet ) { } }

implementation: this . getSerialFirstRowRef ( ) . recover ( sheet ) ; this . getSerialLastRowPlusRef ( ) . recover ( sheet ) ; if ( this . getUnitRowsMapping ( ) != null ) { this . getUnitRowsMapping ( ) . recover ( sheet ) ; }


signature:
public class CEFParser { /** * Converts a CEF formatted String into a { @ link CommonEvent } object with exposed control over strict validation .
 * All CEF extension fields containing Dates are processed with the { @ link Locale Locale . ENGLISH } .
 * @ param cefString String containing the CEF message to be parsed
 * @ param validate Boolean if parser should validate values beyond type compatibility ( e . g . Values within acceptable lengths , value lists , etc )
 * @ return CommonEvent */
public CommonEvent parse ( String cefString , final boolean validate ) { } }

implementation: return this . parse ( cefString , validate , Locale . ENGLISH ) ;


signature:
public class CEFParser { /** * Converts a CEF formatted String into a { @ link CommonEvent } object with exposed control over validation and the
 * { @ link Locale } used to parse fields containing { @ link Date Dates }
 * @ param cefString String containing the CEF message to be parsed
 * @ param validate Boolean if parser should validate values beyond type compatibility ( e . g . Values within acceptable lengths , value lists , etc )
 * @ param locale The locale to be used when parsing dates ( so that parser can handle both jul ( en _ US ) and juil . ( fr _ FR )
 * @ return CommonEvent */
public CommonEvent parse ( String cefString , final boolean validate , Locale locale ) { } }

implementation:
int cefHeaderSize = 7 ; CommonEvent cefEvent = new CefRev23 ( locale ) ; // Note how split number of splits is cefHeaderSize + 1 . This is because the final split
// should be the body of the CEF message
// Compiled pattern is equivalent to " ( ? < ! \ \ \ \ ) " + Pattern . quote ( " | " )
final String [ ] extractedMessage = cefString . split ( "(?<!\\\\)" + Pattern . quote ( "|" ) , cefHeaderSize + 1 ) ; // CEF header misses values
if ( extractedMessage . length < cefHeaderSize ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "CEF message failed validation" ) ; } return null ; } final HashMap < String , Object > headers = new HashMap < String , Object > ( ) ; headers . put ( "version" , Integer . valueOf ( extractedMessage [ 0 ] . substring ( extractedMessage [ 0 ] . length ( ) - 1 ) ) ) ; headers . put ( "deviceVendor" , extractedMessage [ 1 ] ) ; headers . put ( "deviceProduct" , extractedMessage [ 2 ] ) ; headers . put ( "deviceVersion" , extractedMessage [ 3 ] ) ; headers . put ( "deviceEventClassId" , extractedMessage [ 4 ] ) ; headers . put ( "name" , extractedMessage [ 5 ] ) ; headers . put ( "severity" , extractedMessage [ 6 ] ) ; final HashMap < String , String > extensions = new HashMap < String , String > ( ) ; final String ext = extractedMessage [ 7 ] ; // Compiled pattern is equivalent to String extensionRegex = " ( ? < ! \ \ \ \ ) " + Pattern . quote ( " = " ) ;
final Matcher matcher = extensionPattern . matcher ( ext ) ; final Matcher valueMatcher = extensionPattern . matcher ( ext ) ; int index = 0 ; while ( matcher . find ( ) ) { String key = ext . substring ( index , matcher . end ( ) - 1 ) . replace ( " " , "" ) ; // Capture the start of the value ( first char after delimiter match ) ;
int valueStart = matcher . end ( ) ; // Handle all but last extension
if ( valueMatcher . find ( valueStart ) ) { // FInd the next match to determine the maximum length of the value
int nextMatch = valueMatcher . start ( ) ; // Find the last space prior to next match ( i . e . last char before next key )
int lastSpace = ext . lastIndexOf ( " " , nextMatch ) ; // Copy the value between the value start ( i . e . this match )
// and the lastSpace ( i . e . last char prior to next key )
String value = ext . substring ( valueStart , lastSpace ) ; // Put to map .
extensions . put ( key , value ) ; // Update index to the last character before the next key
index = lastSpace + 1 ; // Treat the last KV ( if match is true )
} else if ( valueMatcher . find ( valueStart - 1 ) ) { // We are handling the final character , value end if newline at the
// end of string
int valueEnd = ext . length ( ) ; String value = ext . substring ( valueStart , valueEnd ) ; extensions . put ( key , value ) ; // Update the index to the end of the string so no matches are possible
index = valueEnd ; } } try { cefEvent . setHeader ( headers ) ; cefEvent . setExtension ( extensions ) ; } catch ( CEFHandlingException e ) { logger . error ( e . toString ( ) ) ; return null ; } if ( validate ) { if ( validator == null ) { // Since the validator wasn ' t initiated previously , create a new one ;
this . validator = Validation . buildDefaultValidatorFactory ( ) . getValidator ( ) ; ; } Set < ConstraintViolation < CommonEvent > > validationResult = validator . validate ( cefEvent ) ; if ( validationResult . size ( ) > 0 ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "CEF message failed validation" ) ; } return null ; } else { return cefEvent ; } } else { return cefEvent ; }


signature:
public class DefaultScopes { /** * By convention { @ link Scope # disk ( File ) } create names starting with
 * { @ code disk : } followed by the path to the folder of the scope . This can
 * be used to extract the directory in this { @ link Supplier } to bind the
 * particular { @ link DiskScope } for that directory . */
@ Override public Scope supply ( Dependency < ? super Scope > dep , Injector injector ) throws UnresolvableDependency { } }

implementation: String disk = dep . instance . name . toString ( ) ; File dir = new File ( disk . substring ( 5 ) ) ; return new DiskScope ( injector . resolve ( Config . class ) , dir , DependencyScope :: instanceName ) ;


signature:
public class Resource { /** * Does this resource provide the instance wanted by the given
 * { @ link Dependency } ' s { @ link Name } */
public boolean isNameCompatibleWith ( Dependency < ? super T > dependency ) { } }

implementation: return instance . name . isCompatibleWith ( dependency . instance . name ) ;


signature:
public class Binding { /** * Removes those bindings that are ambiguous but also do not clash because
 * of different { @ link DeclarationType } s that replace each other . */
public static Binding < ? > [ ] disambiguate ( Binding < ? > [ ] bindings ) { } }

implementation: if ( bindings . length <= 1 ) { return bindings ; } List < Binding < ? > > uniques = new ArrayList < > ( bindings . length ) ; Arrays . sort ( bindings ) ; uniques . add ( bindings [ 0 ] ) ; int lastUniqueIndex = 0 ; Set < Type < ? > > required = new HashSet < > ( ) ; List < Binding < ? > > dropped = new ArrayList < > ( ) ; for ( int i = 1 ; i < bindings . length ; i ++ ) { Binding < ? > b_d = bindings [ lastUniqueIndex ] ; Binding < ? > b_i = bindings [ i ] ; final boolean equalResource = b_d . resource . equalTo ( b_i . resource ) ; DeclarationType t_d = b_d . source . declarationType ; DeclarationType t_i = b_i . source . declarationType ; if ( equalResource && t_d . clashesWith ( t_i ) ) { throw new InconsistentBinding ( "Duplicate binds:\n" + b_d + "\n" + b_i ) ; } if ( t_i == DeclarationType . REQUIRED ) { required . add ( b_i . resource . type ( ) ) ; } else if ( equalResource && t_d . droppedWith ( t_i ) ) { if ( i - 1 == lastUniqueIndex ) { dropped . add ( uniques . remove ( uniques . size ( ) - 1 ) ) ; } dropped . add ( b_i ) ; } else if ( ! equalResource || ! t_i . replacedBy ( t_d ) ) { uniques . add ( b_i ) ; lastUniqueIndex = i ; } } return withoutProvidedThatAreNotRequiredIn ( uniques , required , dropped ) ;


signature:
public class ConcurrentEventProcessor { /** * as long as there is a clear contract : namely that failure is always indicated by a EventEception */
@ Override public < E , T > T compute ( Event < E , T > event ) throws Throwable { } }

implementation: return unwrapGet ( event , submit ( event , ( ) -> doProcess ( event ) ) ) ;


signature:
public class EventModule { /** * Registers the given event type so that it is handled by the
 * { @ link EventProcessor } system .
 * That means classes implementing the given event interface " automatically "
 * receive calls to any of the interface methods . When The event interface
 * should be injected to signal / call one of its methods a
 * { @ link EventProcessor # getProxy ( Class ) } is injected .
 * @ param event the type of the event / listener ( must be an interface ) */
protected < T > void handle ( Class < T > event ) { } }

implementation: if ( ! event . isInterface ( ) ) throw new IllegalArgumentException ( "Event type has to be an interface but was: " + event ) ; initbind ( event ) . to ( ( Initialiser < T > ) ( listener , injector ) -> injector . resolve ( EventProcessor . class ) . register ( event , listener ) ) ; bind ( event ) . toSupplier ( ( dep , injector ) -> injector . resolve ( EventProcessor . class ) . getProxy ( event ) ) ;


signature:
public class Bindings { /** * Add ( accumulate ) a binding described by the 4 - tuple given . */
public < T > void add ( Binding < T > complete ) { } }

implementation:
if ( ! complete . isComplete ( ) ) { throw new InconsistentBinding ( "Incomplete binding added: " + complete ) ; } // NB . # 64 here we can inform post binding that about the new binding
bindings . add ( complete ) ;


signature:
public class Macros { /** * Uses the given { @ link Macro } and derives the { @ link # with ( Class , Macro ) }
 * type from its declaration . This is a utility method that can be used as
 * long as the { @ link Macro } implementation is not generic .
 * @ param macro No generic macro class ( e . g . decorators )
 * @ return A set of { @ link Macros } containing the given one for the type
 * derived from its type declaration . */
@ SuppressWarnings ( "unchecked" ) public < T > Macros with ( Macro < T > macro ) { } }

implementation: Class < ? > type = Type . supertype ( Macro . class , Type . raw ( macro . getClass ( ) ) ) . parameter ( 0 ) . rawType ; return with ( ( Class < ? super T > ) type , macro ) ;


signature:
public class Macros { /** * Uses the given { @ link Macro } for the given exact ( no super - types ! ) type
 * of values .
 * @ param type The type of value that should be passed to the { @ link Macro }
 * as value
 * @ param macro The { @ link Macro } expanding the type of value
 * @ return A set of { @ link Macros } containing the given one */
public < T > Macros with ( Class < T > type , Macro < ? extends T > macro ) { } }

implementation: int index = index ( type ) ; if ( index >= 0 ) { Macro < ? > [ ] tmp = macros . clone ( ) ; tmp [ index ] = macro ; return new Macros ( types , tmp ) ; } return new Macros ( arrayPrepand ( type , types ) , arrayPrepand ( macro , macros ) ) ;


signature:
public class Macros { /** * A generic version of { @ link Macro # expand ( Object , Binding , Bindings ) } that
 * uses the matching predefined { @ link Macro } for the actual type of the
 * value and expands it .
 * @ param binding The usually incomplete binding to expand ( and add to
 * { @ link Bindings } )
 * @ param value Non - null value to expand via matching { @ link Macro }
 * @ throws InconsistentBinding In case no { @ link Macro } had been declared
 * for the type of value argument */
@ SuppressWarnings ( "unchecked" ) public < T , V > void expandInto ( Bindings bindings , Binding < T > binding , V value ) { } }

implementation: macroForValueOf ( ( Class < ? super V > ) value . getClass ( ) ) . expand ( value , binding , bindings ) ;


signature:
public class Type { /** * Example - < i > typeOf < / i >
 * < pre >
 * Map & lt ; String , String & gt ; = & gt ; Map & lt ; ? extends String , ? extends String & gt ;
 * < / pre >
 * @ return A { @ link Type } having all its type arguments
 * { @ link # asUpperBound ( ) } s . Use this to model & lt ; ? & gt ; wildcard
 * generic . */
public Type < T > parametizedAsUpperBounds ( ) { } }

implementation: if ( ! isParameterized ( ) ) return isRawType ( ) ? parametized ( wildcards ( rawType . getTypeParameters ( ) ) ) : this ; if ( areAllTypeParametersAreUpperBounds ( ) ) return this ; return new Type < > ( upperBound , rawType , arrayMap ( params , Type :: asUpperBound ) ) ;


signature:
public class Utils { /** * / * Arrays */
public static < A > A [ ] arrayFilter ( A [ ] arr , Predicate < A > accept ) { } }

implementation: if ( arr == null || arr . length == 0 ) return arr ; A [ ] accepted = newArray ( arr , arr . length ) ; int j = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) if ( accept . test ( arr [ i ] ) ) accepted [ j ++ ] = arr [ i ] ; return j == arr . length ? arr : copyOf ( accepted , j ) ;


signature:
public class Utils { /** * This is a special form of flatmap where the mapping does not return zero
 * to n Bs but always returns a B . If { @ code null } is returned this means
 * " zero " or remove the B . So length of { @ code B [ ] } is always { @ code < = }
 * length of { @ code A [ ] } . */
public static < A , B > B [ ] arrayFlatmap ( A [ ] as , Class < B > to , Function < A , B > flatmapOp ) { } }

implementation: B [ ] bs = newArray ( to , as . length ) ; int j = 0 ; for ( int i = 0 ; i < as . length ; i ++ ) { B b = flatmapOp . apply ( as [ i ] ) ; if ( b != null ) bs [ j ++ ] = b ; } return j == as . length ? bs : copyOf ( bs , j ) ;


signature:
public class Utils { /** * / * Annotations */
public static Method annotationPropertyByType ( Class < ? > type , Class < ? extends Annotation > annotation ) { } }

implementation: return arrayFindFirst ( annotation . getDeclaredMethods ( ) , m -> m . getReturnType ( ) == type ) ;


signature:
public class Utils { /** * @ return A { @ link Class } counts as " virtual " when it is known that its not
 * a type handled by an { @ link Injector } context , either because it
 * cannot be constructed at all or it does not make sense to let the
 * { @ link Injector } take care of it . This includes value types ,
 * enums , collection types ( including arrays ) or any type than
 * cannot be instantiated by its nature ( abstract types ) .
 * Note that this method just covers JRE types . */
public static boolean isClassVirtual ( Class < ? > cls ) { } }

implementation: return cls == null || cls . isInterface ( ) || cls . isEnum ( ) || cls . isAnnotation ( ) || cls . isAnonymousClass ( ) || cls . isPrimitive ( ) || cls . isArray ( ) || Modifier . isAbstract ( cls . getModifiers ( ) ) || cls == String . class || Number . class . isAssignableFrom ( cls ) || cls == Boolean . class || cls == Void . class || cls == Class . class || Collection . class . isAssignableFrom ( cls ) || Map . class . isAssignableFrom ( cls ) ;


signature:
public class Utils { /** * @ return A { @ link Class } is monomodal if it there is just a single
 * possible initial state . All newly created instances can just have
 * this similar initial state but due to internal state they could
 * ( not necessarily must ) develop ( behave ) different later on .
 * The opposite of monomodal is multimodal . */
public static boolean isClassMonomodal ( Class < ? > cls ) { } }

implementation:
if ( cls . isInterface ( ) ) return false ; if ( cls == Object . class ) return true ; for ( Field f : cls . getDeclaredFields ( ) ) if ( ! Modifier . isStatic ( f . getModifiers ( ) ) ) return false ; for ( Constructor < ? > c : cls . getDeclaredConstructors ( ) ) // maybe arguments are passed to super - type so we check it too
if ( c . getParameterTypes ( ) . length > 0 ) return isClassMonomodal ( cls . getSuperclass ( ) ) ; return true ;


signature:
public class Utils { /** * / * Members */
public static < T extends Member > T moreVisible ( T a , T b ) { } }

implementation: int am = a . getModifiers ( ) ; int bm = b . getModifiers ( ) ; if ( isPublic ( am ) ) return a ; if ( isPublic ( bm ) ) return b ; if ( isProtected ( am ) ) return a ; if ( isProtected ( bm ) ) return b ; if ( isPrivate ( bm ) ) return a ; if ( isPrivate ( am ) ) return b ; return a ; // same


signature:
public class Utils { /** * Returns the constructor with most visible visibility and longest argument
 * list . Self - referencing constructors are ignored .
 * @ param type constructed type
 * @ return The highest visibility constructor with the most parameters that
 * does not have the declaring class itself as parameter type ( some
 * compiler seam to generate such a synthetic constructor )
 * @ throws NoMethodForDependency in case the type is not constructible ( has
 * no constructors at all ) */
public static < T > Constructor < T > commonConstructor ( Class < T > type ) throws NoMethodForDependency { } }

implementation:
Constructor < ? > [ ] cs = type . getDeclaredConstructors ( ) ; if ( cs . length == 0 ) throw new NoMethodForDependency ( raw ( type ) ) ; Constructor < ? > mostParamsConstructor = null ; for ( Constructor < ? > c : cs ) { if ( ! arrayContains ( c . getParameterTypes ( ) , type , ( a , b ) -> a == b ) // avoid self referencing constructors ( synthetic ) as they cause endless loop
&& ( mostParamsConstructor == null || ( moreVisible ( c , mostParamsConstructor ) == c && ( moreVisible ( mostParamsConstructor , c ) == c || c . getParameterCount ( ) > mostParamsConstructor . getParameterCount ( ) ) ) ) ) { mostParamsConstructor = c ; } } if ( mostParamsConstructor == null ) throw new NoMethodForDependency ( raw ( type ) ) ; @ SuppressWarnings ( "unchecked" ) Constructor < T > c = ( Constructor < T > ) mostParamsConstructor ; return c ;


signature:
public class Utils { /** * / * Sequences */
public static boolean seqRegionEquals ( CharSequence s1 , CharSequence s2 , int length ) { } }

implementation: if ( s1 . length ( ) < length || s2 . length ( ) < length ) return false ; if ( s1 == s2 ) return true ; for ( int i = length - 1 ; i > 0 ; i -- ) if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) return false ; return true ;


signature:
public class Utils { /** * / * Exception Handling */
public static < T > T orElse ( T defaultValue , Provider < T > src ) { } }

implementation: try { return src . provide ( ) ; } catch ( UnresolvableDependency e ) { return defaultValue ; }


signature:
public class Packages { /** * < pre >
 * foo . bar . baz - > foo . bar
 * foo . bar . - > foo .
 * < / pre > */
private static String parent ( String root ) { } }

implementation: return root . substring ( 0 , root . lastIndexOf ( '.' , root . length ( ) - 2 ) + ( root . endsWith ( "." ) ? 1 : 0 ) ) ;


signature:
public class Dependency { /** * TODO maybe extract a Plugins Extension */
public static < T > Dependency < T > dependency ( Class < T > type ) { } }

implementation: return dependency ( raw ( type ) ) ;


signature:
public class BinaryData { /** * Utility method for transferring input stream to output .
 * @ param context application context ( needed to retrieve a buffers pool )
 * @ param source input stream
 * @ param output output stream
 * @ throws IOException if I / O error happens */
protected static void writeInputStreamToOutput ( final Context context , final InputStream source , final OutputStream output ) throws IOException { } }

implementation: BuffersPool pool = BeansManager . get ( context ) . getContainer ( ) . getBean ( BuffersPool . class ) ; IoUtils . transfer ( source , output , pool ) ;


signature:
public class CacheEntry { /** * Write next line as a long .
 * @ param writer output writer
 * @ param value integer value
 * @ throws IOException if error happens */
protected static void writeLong ( final Writer writer , final long value ) throws IOException { } }

implementation: writer . write ( new StringBuilder ( ) . append ( value ) . append ( '\n' ) . toString ( ) ) ;


signature:
public class CacheEntry { /** * Write next line to the output .
 * @ param writer output writer
 * @ param line line to write ( if null just a new empty line is inserted )
 * @ throws IOException if error happens */
protected final void writeString ( final Writer writer , final String line ) throws IOException { } }

implementation: if ( line != null ) { writer . write ( line + '\n' ) ; } else { writer . write ( '\n' ) ; }


signature:
public class PayloadPostConverter { /** * Make workarounds for POST requests via { @ link URLConnection } on older Android versions .
 * Override this method in order to disable them .
 * @ param connection connection object instance */
protected void doSendWorkarounds ( final URLConnection connection ) { } }

implementation: if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . GINGERBREAD && connection instanceof HttpURLConnection ) { try { Field resHeaderField = connection . getClass ( ) . getDeclaredField ( "resHeader" ) ; resHeaderField . setAccessible ( true ) ; resHeaderField . set ( connection , null ) ; } catch ( Exception e ) { Log . w ( "Workaround" , "Failed to make a wrokaround for Android 2.2" , e ) ; } }


signature:
public class PoolableBufferedOutputStream { /** * Writes { @ code count } bytes from the byte array { @ code buffer } starting at
 * { @ code offset } to this stream . If there is room in the buffer to hold the
 * bytes , they are copied in . If not , the buffered bytes plus the bytes in
 * { @ code buffer } are written to the target stream , the target is flushed ,
 * and the buffer is cleared .
 * @ param buffer
 * the buffer to be written .
 * @ param offset
 * the start position in { @ code buffer } from where to get bytes .
 * @ param length
 * the number of bytes from { @ code buffer } to write to this
 * stream .
 * @ throws IndexOutOfBoundsException
 * if { @ code offset < 0 } or { @ code length < 0 } , or if
 * { @ code offset + length } is greater than the size of
 * { @ code buffer } .
 * @ throws IOException
 * if an error occurs attempting to write to this stream .
 * @ throws NullPointerException
 * if { @ code buffer } is { @ code null } .
 * @ throws ArrayIndexOutOfBoundsException
 * If offset or count is outside of bounds . */
@ Override public synchronized void write ( final byte [ ] buffer , final int offset , final int length ) throws IOException { } }

implementation:
checkNotClosed ( ) ; if ( buffer == null ) { throw new NullPointerException ( "buffer == null" ) ; } final byte [ ] internalBuffer = buf ; if ( length >= internalBuffer . length ) { flushInternal ( ) ; out . write ( buffer , offset , length ) ; return ; } if ( ( offset | length ) < 0 || offset > buffer . length || buffer . length - offset < length ) { throw new ArrayIndexOutOfBoundsException ( "length=" + buffer . length + "; regionStart=" + offset + "; regionLength=" + length ) ; } // flush the internal buffer first if we have not enough space left
if ( length > ( internalBuffer . length - count ) ) { flushInternal ( ) ; } System . arraycopy ( buffer , offset , internalBuffer , count , length ) ; count += length ;


signature:
public class PoolableBufferedOutputStream { /** * Writes one byte to this stream . Only the low order byte of the integer
 * { @ code oneByte } is written . If there is room in the buffer , the byte is
 * copied into the buffer and the count incremented . Otherwise , the buffer
 * plus { @ code oneByte } are written to the target stream , the target is
 * flushed , and the buffer is reset .
 * @ param oneByte
 * the byte to be written .
 * @ throws IOException
 * if an error occurs attempting to write to this stream . */
@ Override public synchronized void write ( final int oneByte ) throws IOException { } }

implementation: checkNotClosed ( ) ; if ( count == buf . length ) { out . write ( buf , 0 , count ) ; count = 0 ; } buf [ count ++ ] = ( byte ) oneByte ;


signature:
public class BaseRequestBuilder { /** * Set network stats tag . Converts string tag to integer one .
 * @ param tag string tag */
protected void setConvertedTrafficStatsTag ( final String tag ) { } }

implementation: result . statsTag = Utils . getTrafficStatsTag ( tag ) ; if ( config . isDebugRest ( ) ) { Log . d ( TAG , "TrafficStats tag <" + tag + ">=" + Integer . toHexString ( result . statsTag ) ) ; }


signature:
public class BaseRequestBuilder { /** * Setup binary content with the local file .
 * @ param name parameter name
 * @ param data content URI
 * @ param contentType content MIME - type */
protected void addBinaryContent ( final String name , final Uri data , final String contentType ) { } }

implementation: String contentName = RequestDescription . BINARY_NAME_DEFAULT ; if ( ContentResolver . SCHEME_FILE . equals ( data . getScheme ( ) ) ) { try { contentName = new File ( new URI ( data . toString ( ) ) ) . getName ( ) ; } catch ( final URISyntaxException e ) { Log . e ( TAG , "Bad file URI: " + data , e ) ; } } addBinaryContent ( name , contentName , data , contentType ) ;


signature:
public class BaseRequestBuilder { /** * Setup binary content with the local file .
 * @ param name parameter name
 * @ param contentName content name
 * @ param data content URI
 * @ param contentType content MIME - type */
protected void addBinaryContent ( final String name , final String contentName , final Uri data , final String contentType ) { } }

implementation: final ContentUriBinaryData bdata = new ContentUriBinaryData ( ) ; bdata . setName ( name ) ; bdata . setContentUri ( data , contentName ) ; bdata . setContentType ( contentType ) ; result . addBinaryData ( bdata ) ;


signature:
public class BaseRequestBuilder { /** * Setup binary content with the bitmap .
 * @ param name parameter name
 * @ param bitmap bitmap object
 * @ param fileName file name */
protected void addBitmap ( final String name , final Bitmap bitmap , final String fileName ) { } }

implementation: final BitmapBinaryData bdata = new BitmapBinaryData ( ) ; bdata . setName ( name ) ; bdata . setContentName ( fileName ) ; bdata . setBitmap ( bitmap ) ; result . addBinaryData ( bdata ) ;


signature:
public class BaseRequestBuilder { /** * Setup binary content with the file descriptor .
 * @ param name parameter name
 * @ param fd file descriptor
 * @ param contentType content MIME - type
 * @ param fileName file name */
protected void addFileDescriptor ( final String name , final AssetFileDescriptor fd , final String contentType , final String fileName ) { } }

implementation: final AssetFdBinaryData bdata = new AssetFdBinaryData ( ) ; bdata . setFileDescriptor ( fileName , fd ) ; bdata . setName ( name ) ; bdata . setContentType ( contentType ) ; result . addBinaryData ( bdata ) ;


signature:
public class BaseRequestBuilder { /** * Remove parameter with the specified name from request description .
 * @ param name parameter name
 * @ return removed parameter instance , null if no parameter was found */
protected Parameter removeParameter ( final String name ) { } }

implementation: if ( name == null ) { throw new IllegalArgumentException ( "Parameter name cannot be null" ) ; } final Iterator < Parameter > iter = result . simpleParameters . getChildren ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { final Parameter p = iter . next ( ) ; if ( name . equals ( p . name ) ) { iter . remove ( ) ; return p ; } } return null ;


signature:
public class BaseRequestBuilder { /** * Add header to request description .
 * @ param name header name
 * @ param value header value
 * @ return this for chaining */
protected BaseRequestBuilder < MT > addHeader ( final String name , final String value ) { } }

implementation: result . addHeader ( name , value ) ; return this ;


signature:
public class BaseRequestBuilder { /** * Clear the builder . */
public void clear ( ) { } }

implementation: final RequestDescription result = this . result ; result . simpleParameters . children . clear ( ) ; result . clearBinaryData ( ) ; result . contentType = null ; result . clearHeaders ( ) ;


signature:
public class StreamingPlaybackController { /** * Play the track . */
protected void callPlay ( final Uri uri , final int volume , final Bundle params ) { } }

implementation: playing = true ; paused = false ; context . startService ( createPlayIntent ( ) . setData ( uri ) . putExtra ( StreamingPlaybackService . EXTRA_VOLUME , volume ) . putExtra ( StreamingPlaybackService . EXTRA_TRACK_INFO , params ) ) ; bind ( ) ; onPlayingChanged ( ) ; preparing = true ; onPreparingChanged ( ) ;


signature:
public class StreamingPlaybackController { /** * Stop playback . */
protected void callStop ( ) { } }

implementation: playing = false ; paused = false ; context . startService ( createStopIntent ( ) ) ; onPlayingChanged ( ) ; preparing = false ; onPreparingChanged ( ) ;