_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q178600
SaveAttrsUtility.parseSaveAttrString
test
public static String parseSaveAttrString(final String strValue) { if (strValue != null) { int first = strValue.indexOf(TieConstants.METHOD_PREFIX); int last = strValue.lastIndexOf(TieConstants.METHOD_PREFIX); int end = strValue.lastIndexOf(TieConstants.METHOD_END); if ((first >= 0) && (first == last) && (end > 1)) { return strValue.substring(first + 2, end); } } return ""; }
java
{ "resource": "" }
q178601
SaveAttrsUtility.getSaveAttrListFromRow
test
public static String getSaveAttrListFromRow(final Row row) { if (row != null) { Cell cell = row.getCell(TieConstants.HIDDEN_SAVE_OBJECTS_COLUMN); if (cell != null) { String str = cell.getStringCellValue(); if ((str != null) && (!str.isEmpty())) { return str; } } } return null; }
java
{ "resource": "" }
q178602
SaveAttrsUtility.getSaveAttrFromList
test
public static String getSaveAttrFromList(final int columnIndex, final String saveAttrs) { if ((saveAttrs != null) && (!saveAttrs.isEmpty())) { String str = TieConstants.CELL_ADDR_PRE_FIX + columnIndex + "="; int istart = saveAttrs.indexOf(str); if (istart >= 0) { int iend = saveAttrs.indexOf(',', istart); if (iend > istart) { return saveAttrs.substring(istart + str.length(), iend); } } } return null; }
java
{ "resource": "" }
q178603
SaveAttrsUtility.setSaveObjectsInHiddenColumn
test
public static void setSaveObjectsInHiddenColumn(final Row row, final String saveAttr) { Cell cell = row.getCell(TieConstants.HIDDEN_SAVE_OBJECTS_COLUMN, MissingCellPolicy.CREATE_NULL_AS_BLANK); cell.setCellValue(saveAttr); }
java
{ "resource": "" }
q178604
SaveAttrsUtility.setSaveAttrsForSheet
test
public static void setSaveAttrsForSheet(final Sheet sheet, final int minRowNum, final int maxRowNum, final Map<String, String> saveCommentsMap) { for (Row row : sheet) { int rowIndex = row.getRowNum(); if ((rowIndex >= minRowNum) && (rowIndex <= maxRowNum)) { setSaveAttrsForRow(row, saveCommentsMap); } } }
java
{ "resource": "" }
q178605
SaveAttrsUtility.setSaveAttrsForRow
test
public static void setSaveAttrsForRow(final Row row, final Map<String, String> saveCommentsMap) { StringBuilder saveAttr = new StringBuilder(); for (Cell cell : row) { String sAttr = parseSaveAttr(cell, saveCommentsMap); if (!sAttr.isEmpty()) { saveAttr.append(sAttr); } } if (saveAttr.length() > 0) { SaveAttrsUtility.setSaveObjectsInHiddenColumn(row, saveAttr.toString()); } }
java
{ "resource": "" }
q178606
SaveAttrsUtility.prepareContextAndAttrsForCell
test
public static String prepareContextAndAttrsForCell(Cell poiCell, String fullName, CellHelper cellHelper) { if (fullName == null) { return null; } String saveAttrList = SaveAttrsUtility.getSaveAttrListFromRow(poiCell.getRow()); if (saveAttrList != null) { String saveAttr = SaveAttrsUtility.getSaveAttrFromList(poiCell.getColumnIndex(), saveAttrList); if (saveAttr != null) { cellHelper.restoreDataContext(fullName); return saveAttr; } } return null; }
java
{ "resource": "" }
q178607
TieSheetNumberConverter.fmtNumber
test
private String fmtNumber(final double d) { if (Double.compare(d % 1, 0) == 0) { return String.format("%d", (int) d); } else { return String.format("%.2f", d); } }
java
{ "resource": "" }
q178608
ConfigBuildRef.putShiftAttrs
test
public final void putShiftAttrs(final String fullName, final ConfigRangeAttrs attrs, final RowsMapping unitRowsMapping) { attrs.setUnitRowsMapping(unitRowsMapping); this.shiftMap.put(fullName, attrs); }
java
{ "resource": "" }
q178609
TieWebSheetBean.setWb
test
public void setWb(final Workbook pWb) { this.getSerialWb().setWb(pWb); this.wbWrapper = XSSFEvaluationWorkbook.create((XSSFWorkbook) pWb); }
java
{ "resource": "" }
q178610
TieWebSheetBean.getWbWrapper
test
public XSSFEvaluationWorkbook getWbWrapper() { if ((this.wbWrapper == null) && (this.getWb() != null)) { this.wbWrapper = XSSFEvaluationWorkbook .create((XSSFWorkbook) this.getWb()); } return wbWrapper; }
java
{ "resource": "" }
q178611
TieWebSheetBean.getFormulaEvaluator
test
public FormulaEvaluator getFormulaEvaluator() { if ((this.formulaEvaluator == null) && (this.getWb() != null)) { this.formulaEvaluator = this.getWb().getCreationHelper() .createFormulaEvaluator(); } return formulaEvaluator; }
java
{ "resource": "" }
q178612
TieWebSheetBean.reCalcMaxColCounts
test
public void reCalcMaxColCounts() { if ((this.getSheetConfigMap() == null) || (this.getSheetConfigMap().isEmpty())) { this.maxColCounts = 0; return; } int maxColumns = 0; for (SheetConfiguration sheetConfig : this.getSheetConfigMap() .values()) { int counts = sheetConfig.getHeaderCellRange().getRightCol() - sheetConfig.getHeaderCellRange().getLeftCol() + 1; if (maxColumns < counts) { maxColumns = counts; } } this.maxColCounts = maxColumns; }
java
{ "resource": "" }
q178613
TieWebSheetBean.loadWebSheet
test
public int loadWebSheet(final InputStream inputStream, final Map<String, Object> pDataContext) { return this.getHelper().getWebSheetLoader() .loadWorkbook(inputStream, pDataContext); }
java
{ "resource": "" }
q178614
TieWebSheetBean.loadWebSheet
test
public int loadWebSheet(final Workbook pWb, final Map<String, Object> pDataContext) { return this.getHelper().getWebSheetLoader().loadWorkbook(pWb, pDataContext); }
java
{ "resource": "" }
q178615
TieWebSheetBean.loadWorkSheetByTabName
test
public int loadWorkSheetByTabName(final String tabName) { try { int sheetId = this.getHelper().getWebSheetLoader() .findTabIndexWithName(tabName); if ((getSheetConfigMap() != null) && (sheetId < getSheetConfigMap().size())) { this.getHelper().getWebSheetLoader().loadWorkSheet(tabName); setActiveTabIndex(sheetId); } return 1; } catch (Exception ex) { LOG.log(Level.SEVERE, "loadWorkSheetByTabName failed. error = " + ex.getMessage(), ex); } return -1; }
java
{ "resource": "" }
q178616
TieWebSheetBean.doExport
test
public void doExport() { try { String fileName = this.getExportFileName(); ByteArrayOutputStream out = new ByteArrayOutputStream(); this.getWb().write(out); InputStream stream = new BufferedInputStream( new ByteArrayInputStream(out.toByteArray())); exportFile = new DefaultStreamedContent(stream, "application/force-download", fileName); } catch (Exception e) { LOG.log(Level.SEVERE, "Error in export file : " + e.getLocalizedMessage(), e); } return; }
java
{ "resource": "" }
q178617
TieWebSheetBean.doSave
test
public void doSave() { this.setSubmitMde(false); if (!this.getHelper().getValidationHandler().preValidation()) { LOG.fine("Validation failded before saving"); return; } processSave(); this.getHelper().getWebSheetLoader().setUnsavedStatus( RequestContext.getCurrentInstance(), false); }
java
{ "resource": "" }
q178618
TieWebSheetBean.doSubmit
test
public void doSubmit() { this.setSubmitMde(true); // validation may behavior differently depend on the submit mode. // e.g. when submit mode = false, empty fields or value not changed cells // don't need to pass the validation rule. This allow partial save the form. // when submit mode = true, all cells need to pass the validation. if (!this.getHelper().getValidationHandler().preValidation()) { LOG.fine("Validation failed before saving"); return; } processSubmit(); this.getHelper().getWebSheetLoader().setUnsavedStatus( RequestContext.getCurrentInstance(), false); this.setSubmitMde(false); }
java
{ "resource": "" }
q178619
TieWebSheetBean.populateComponent
test
public void populateComponent(final ComponentSystemEvent event) { UIComponent component = event.getComponent(); int[] rowcol = CellUtility .getRowColFromComponentAttributes(component); int row = rowcol[0]; int col = rowcol[1]; FacesCell fcell = CellUtility.getFacesCellFromBodyRow(row, col, this.getBodyRows(), this.getCurrent().getCurrentTopRow(), this.getCurrent().getCurrentLeftColumn()); CellControlsUtility.populateAttributes(component, fcell, this.getCellDefaultControl()); }
java
{ "resource": "" }
q178620
TieWebSheetBean.getCurrentSheetConfig
test
public SheetConfiguration getCurrentSheetConfig() { String currentTabName = this.getCurrent().getCurrentTabName(); if (currentTabName == null) { return null; } return this.getSheetConfigMap().get(currentTabName); }
java
{ "resource": "" }
q178621
TieWebSheetBean.readObject
test
private void readObject(final java.io.ObjectInputStream in) throws IOException { try { in.defaultReadObject(); recover(); } catch (EncryptedDocumentException | ClassNotFoundException e) { LOG.log(Level.SEVERE, " error in readObject of serialWorkbook : " + e.getLocalizedMessage(), e); } }
java
{ "resource": "" }
q178622
DateTimeCustomConverter.getLocale
test
private Locale getLocale(final FacesContext context, final UIComponent component) { String localeStr = (String) component.getAttributes() .get(TieConstants.COMPONENT_ATTR_LOCALE); if (localeStr == null) { return context.getViewRoot().getLocale(); } return Locale.forLanguageTag(localeStr); }
java
{ "resource": "" }
q178623
TieWebSheetPicturesService.getPicture
test
public StreamedContent getPicture() { FacesContext context = FacesContext.getCurrentInstance(); if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) { // So, we're rendering the HTML. Return a stub StreamedContent so // that it will generate right URL. LOG.fine(" return empty picture"); return new DefaultStreamedContent(); } else { // So, browser is requesting the image. Return a real // StreamedContent with the image bytes. String pictureId = context.getExternalContext() .getRequestParameterMap().get("pictureViewId"); PictureData picData = (PictureData) FacesContext .getCurrentInstance().getExternalContext() .getSessionMap().get(pictureId); FacesContext.getCurrentInstance().getExternalContext() .getSessionMap().remove(pictureId); LOG.fine(" return real picture and remove session"); return new DefaultStreamedContent(new ByteArrayInputStream( picData.getData())); } }
java
{ "resource": "" }
q178624
TieWebSheetBeanHelper.getCellHelper
test
public final CellHelper getCellHelper() { if ((this.cellHelper == null) && (this.parent != null)) { this.cellHelper = new CellHelper(parent); } return cellHelper; }
java
{ "resource": "" }
q178625
TieWebSheetBeanHelper.getPicHelper
test
public final PicturesHelper getPicHelper() { if ((this.picHelper == null) && (this.parent != null)) { this.picHelper = new PicturesHelper(parent); } return picHelper; }
java
{ "resource": "" }
q178626
TieWebSheetBeanHelper.getValidationHandler
test
public final ValidationHandler getValidationHandler() { if ((this.validationHandler == null) && (this.parent != null)) { this.validationHandler = new ValidationHandler(parent); } return validationHandler; }
java
{ "resource": "" }
q178627
TieWebSheetBeanHelper.getChartHelper
test
public final ChartHelper getChartHelper() { if ((this.chartHelper == null) && (this.parent != null)) { this.chartHelper = new ChartHelper(parent); } return chartHelper; }
java
{ "resource": "" }
q178628
ShiftFormulaUtility.convertSharedFormulas
test
public static Ptg[] convertSharedFormulas(final Ptg[] ptgs, final ShiftFormulaRef shiftFormulaRef) { List<Ptg> newPtgList = new ArrayList<>(); Object ptg; for (int k = 0; k < ptgs.length; ++k) { ptg = ptgs[k]; newPtgList.addAll(Arrays .asList(convertPtg(ptgs, k, shiftFormulaRef, ptg))); } return newPtgList.toArray(new Ptg[newPtgList.size()]); }
java
{ "resource": "" }
q178629
ShiftFormulaUtility.convertPtg
test
private static Ptg[] convertPtg(final Ptg[] ptgs, final int position, final ShiftFormulaRef shiftFormulaRef, final Object ptg) { byte originalOperandClass = -1; if (!((Ptg) ptg).isBaseToken()) { originalOperandClass = ((Ptg) ptg).getPtgClass(); } int currentRow; currentRow = getFirstSupportedRowNumFromPtg(ptg); if ((currentRow >= 0) && shiftFormulaRef.getWatchList().contains(currentRow)) { return convertPtgForWatchList(ptgs, position, shiftFormulaRef, ptg, originalOperandClass, currentRow); } // no need change ptg if ((ptg instanceof AttrPtg) && (shiftFormulaRef.getFormulaChanged() > 1)) { AttrPtg newPtg = (AttrPtg) ptg; if (newPtg.isSum()) { FuncVarPtg fptg = FuncVarPtg.create("sum", shiftFormulaRef.getFormulaChanged()); return singlePtg(fptg, fptg.getPtgClass(), shiftFormulaRef.getFormulaChanged()); } } return singlePtg(ptg, originalOperandClass, shiftFormulaRef.getFormulaChanged()); }
java
{ "resource": "" }
q178630
ShiftFormulaUtility.convertPtgForWatchList
test
private static Ptg[] convertPtgForWatchList(final Ptg[] ptgs, final int position, final ShiftFormulaRef shiftFormulaRef, final Object ptg, final byte originalOperandClass, final int currentRow) { List<SerialRow> rowlist = getRowsList(currentRow, shiftFormulaRef.getCurrentRowsMappingList()); if ((rowlist == null) || (rowlist.isEmpty())) { // no need change ptg return singlePtg(ptg, originalOperandClass, -1); } shiftFormulaRef.setFormulaChanged(1); // one to one or has no round brackets if ((rowlist.size() == 1) || ((position + 1) >= ptgs.length) || !(ptgs[position + 1] instanceof ParenthesisPtg)) { // change ptg one to one // return changed ptg return singlePtg( fixupRefRelativeRowOneToOne(ptg, rowlist.get(0).getRow()), originalOperandClass, -1); } shiftFormulaRef.setFormulaChanged(rowlist.size()); return fixupRefRelativeRowOneToMany(ptg, originalOperandClass, rowlist, ptgs, position); }
java
{ "resource": "" }
q178631
ShiftFormulaUtility.singlePtg
test
private static Ptg[] singlePtg(final Object ptg, final byte originalOperandClass, final int formulaChanged) { Ptg[] newPtg = new Ptg[1]; if (originalOperandClass != (-1)) { ((Ptg) ptg).setClass(originalOperandClass); } Object ptgAfter = ptg; if (ptg instanceof FuncVarPtg) { FuncVarPtg fptg = (FuncVarPtg) ptg; if ((formulaChanged > 0) && (fptg.getNumberOfOperands() != formulaChanged)) { ptgAfter = FuncVarPtg.create(((FuncVarPtg) ptg).getName(), formulaChanged); } } newPtg[0] = (Ptg) ptgAfter; return newPtg; }
java
{ "resource": "" }
q178632
ShiftFormulaUtility.getRowsList
test
private static List<SerialRow> getRowsList(final int currentRow, final List<RowsMapping> currentRowsMappingList) { List<SerialRow> all = null; int size = currentRowsMappingList.size(); for (RowsMapping rowsmapping : currentRowsMappingList) { List<SerialRow> current = rowsmapping.get(currentRow); if (current != null) { if (size == 1) { return current; } all = assembleRowsListFromRowsMapping(all, current); } } return all; }
java
{ "resource": "" }
q178633
ShiftFormulaUtility.assembleRowsListFromRowsMapping
test
private static List<SerialRow> assembleRowsListFromRowsMapping( final List<SerialRow> all, final List<SerialRow> current) { List<SerialRow> list; if (all == null) { list = new ArrayList<>(); list.addAll(current); } else { list = all; for (SerialRow row : current) { if (!all.contains(row)) { list.add(row); } } } return list; }
java
{ "resource": "" }
q178634
ShiftFormulaUtility.fixupRefRelativeRowOneToOne
test
protected static Object fixupRefRelativeRowOneToOne(final Object ptg, final Row newRow) { if (ptg instanceof RefPtgBase) { if (ptg instanceof Ref3DPxg) { Ref3DPxg ref3dPxg = (Ref3DPxg) ptg; Ref3DPxg new3dpxg = new Ref3DPxg( ref3dPxg.getExternalWorkbookNumber(), new SheetIdentifier(null, new NameIdentifier(ref3dPxg.getSheetName(), false)), new CellReference(newRow.getRowNum(), ref3dPxg.getColumn())); new3dpxg.setClass(ref3dPxg.getPtgClass()); new3dpxg.setColRelative(ref3dPxg.isColRelative()); new3dpxg.setRowRelative(ref3dPxg.isRowRelative()); new3dpxg.setLastSheetName(ref3dPxg.getLastSheetName()); return new3dpxg; } else { RefPtgBase refPtgBase = (RefPtgBase) ptg; return new RefPtg(newRow.getRowNum(), refPtgBase.getColumn(), refPtgBase.isRowRelative(), refPtgBase.isColRelative()); } } else { if (ptg instanceof Area3DPxg) { Area3DPxg area3dPxg = (Area3DPxg) ptg; Area3DPxg new3dpxg = new Area3DPxg( area3dPxg.getExternalWorkbookNumber(), new SheetIdentifier(null, new NameIdentifier(area3dPxg.getSheetName(), false)), area3dPxg.format2DRefAsString()); new3dpxg.setClass(area3dPxg.getPtgClass()); new3dpxg.setFirstColRelative( area3dPxg.isFirstColRelative()); new3dpxg.setLastColRelative(area3dPxg.isLastColRelative()); int shiftRow = newRow.getRowNum() - area3dPxg.getFirstRow(); new3dpxg.setFirstRow(area3dPxg.getFirstRow() + shiftRow); new3dpxg.setLastRow(area3dPxg.getLastRow() + shiftRow); new3dpxg.setFirstRowRelative( area3dPxg.isFirstRowRelative()); new3dpxg.setLastRowRelative(area3dPxg.isLastRowRelative()); new3dpxg.setLastSheetName(area3dPxg.getLastSheetName()); return new3dpxg; } else { AreaPtgBase areaPtgBase = (AreaPtgBase) ptg; int shiftRow = newRow.getRowNum() - areaPtgBase.getFirstRow(); return new AreaPtg(areaPtgBase.getFirstRow() + shiftRow, areaPtgBase.getLastRow() + shiftRow, areaPtgBase.getFirstColumn(), areaPtgBase.getLastColumn(), areaPtgBase.isFirstRowRelative(), areaPtgBase.isLastRowRelative(), areaPtgBase.isFirstColRelative(), areaPtgBase.isLastColRelative()); } } }
java
{ "resource": "" }
q178635
ShiftFormulaUtility.buildDynamicRowForRefPtgBase
test
private static void buildDynamicRowForRefPtgBase(final Object ptg, final byte originalOperandClass, final List<SerialRow> rowList, final Ptg[] newPtg, final boolean includeParenthesis) { RefPtgBase refPtg = (RefPtgBase) ptg; int unitSize = 1; if (includeParenthesis) { unitSize = 2; } for (int i = 0; i < rowList.size(); i++) { Row row = rowList.get(i).getRow(); if (refPtg instanceof Ref3DPxg) { Ref3DPxg ref3dPxg = (Ref3DPxg) refPtg; Ref3DPxg new3dpxg = new Ref3DPxg( ref3dPxg.getExternalWorkbookNumber(), new SheetIdentifier(null, new NameIdentifier(ref3dPxg.getSheetName(), false)), new CellReference(row.getRowNum(), ref3dPxg.getColumn())); new3dpxg.setClass(originalOperandClass); new3dpxg.setColRelative(ref3dPxg.isColRelative()); new3dpxg.setRowRelative(ref3dPxg.isRowRelative()); new3dpxg.setLastSheetName(ref3dPxg.getLastSheetName()); newPtg[i * unitSize] = new3dpxg; } else { RefPtgBase refPtgBase = refPtg; newPtg[i * unitSize] = new RefPtg(row.getRowNum(), refPtgBase.getColumn(), refPtgBase.isRowRelative(), refPtgBase.isColRelative()); } if ((unitSize == 2) && (i < (rowList.size() - 1))) { newPtg[i * unitSize + 1] = ParenthesisPtg.instance; } } }
java
{ "resource": "" }
q178636
ShiftFormulaUtility.buildDynamicRowForAreaPtgBase
test
private static void buildDynamicRowForAreaPtgBase(final Object ptg, final byte originalOperandClass, final List<SerialRow> rowList, final Ptg[] newPtg) { AreaPtgBase areaPtg = (AreaPtgBase) ptg; int originFirstRow = areaPtg.getFirstRow(); int originLastRow = areaPtg.getLastRow(); int unitSize = 2; for (int i = 0; i < rowList.size(); i++) { Row row = rowList.get(i).getRow(); int shiftRow = row.getRowNum() - originFirstRow; if (ptg instanceof Area3DPxg) { Area3DPxg area3dPxg = (Area3DPxg) ptg; Area3DPxg new3dpxg = new Area3DPxg( area3dPxg.getExternalWorkbookNumber(), new SheetIdentifier(null, new NameIdentifier(area3dPxg.getSheetName(), false)), area3dPxg.format2DRefAsString()); new3dpxg.setClass(originalOperandClass); new3dpxg.setFirstColRelative( area3dPxg.isFirstColRelative()); new3dpxg.setLastColRelative(area3dPxg.isLastColRelative()); new3dpxg.setFirstRow(originFirstRow + shiftRow); new3dpxg.setLastRow(originLastRow + shiftRow); new3dpxg.setFirstRowRelative( area3dPxg.isFirstRowRelative()); new3dpxg.setLastRowRelative(area3dPxg.isLastRowRelative()); new3dpxg.setLastSheetName(area3dPxg.getLastSheetName()); newPtg[i * unitSize] = new3dpxg; } else { AreaPtgBase areaPtgBase = (AreaPtgBase) ptg; newPtg[i * unitSize] = new AreaPtg( originFirstRow + shiftRow, originLastRow + shiftRow, areaPtgBase.getFirstColumn(), areaPtgBase.getLastColumn(), areaPtgBase.isFirstRowRelative(), areaPtgBase.isLastRowRelative(), areaPtgBase.isFirstColRelative(), areaPtgBase.isLastColRelative()); } if (i < (rowList.size() - 1)) { newPtg[i * unitSize + 1] = ParenthesisPtg.instance; } } }
java
{ "resource": "" }
q178637
ColorUtility.getBgColor
test
public static XColor getBgColor(final CTPlotArea ctPlot, final ThemesTable themeTable) { CTSolidColorFillProperties colorFill = null; try { colorFill = ctPlot.getSpPr().getSolidFill(); } catch (Exception ex) { LOG.log(Level.FINE, "No entry in bgcolor for solidFill", ex); } XColor xcolor = findAutomaticFillColor(themeTable, colorFill); if (xcolor != null) { return xcolor; } else { return new XColor(new XSSFColor(Color.WHITE)); } }
java
{ "resource": "" }
q178638
ColorUtility.geColorFromSpPr
test
public static XColor geColorFromSpPr(final int index, final CTShapeProperties ctSpPr, final ThemesTable themeTable, final boolean isLineColor) { CTSolidColorFillProperties colorFill = null; try { if (isLineColor) { colorFill = ctSpPr.getLn().getSolidFill(); } else { colorFill = ctSpPr.getSolidFill(); } } catch (Exception ex) { LOG.log(Level.FINE, "No entry for solidFill", ex); } XColor xcolor = findAutomaticFillColor(themeTable, colorFill); if (xcolor != null) { return xcolor; } else { return getXColorWithAutomaticFill(index, themeTable); } }
java
{ "resource": "" }
q178639
ColorUtility.findAutomaticFillColor
test
private static XColor findAutomaticFillColor(final ThemesTable themeTable, final CTSolidColorFillProperties colorFill) { // if there's no solidFill, then use automaticFill color if (colorFill == null) { return null; } CTSchemeColor ctsColor = colorFill.getSchemeClr(); if (ctsColor != null) { return getXColorFromSchemeClr(ctsColor, themeTable); } else { CTSRgbColor ctrColor = colorFill.getSrgbClr(); if (ctrColor != null) { return getXColorFromRgbClr(ctrColor); } } return null; }
java
{ "resource": "" }
q178640
ColorUtility.getXColorFromSchemeClr
test
private static XColor getXColorFromSchemeClr( final CTSchemeColor ctsColor, final ThemesTable themeTable) { if (ctsColor.getVal() != null) { return getXColorWithSchema(ctsColor.getVal().toString(), 0, ctsColor, themeTable); } return null; }
java
{ "resource": "" }
q178641
ColorUtility.getXColorFromRgbClr
test
private static XColor getXColorFromRgbClr(final CTSRgbColor ctrColor) { XSSFColor bcolor = null; try { byte[] rgb = ctrColor.getVal(); bcolor = new XSSFColor(rgb); } catch (Exception ex) { LOG.log(Level.SEVERE, "Cannot get rgb color error = " + ex.getLocalizedMessage(), ex); return null; } int lumOff = 0; int lumMod = 0; int alphaStr = 0; try { lumOff = ctrColor.getLumOffArray(0).getVal(); } catch (Exception ex) { LOG.log(Level.FINE, "No lumOff entry", ex); } try { lumMod = ctrColor.getLumModArray(0).getVal(); } catch (Exception ex) { LOG.log(Level.FINE, "No lumMod entry", ex); } try { alphaStr = ctrColor.getAlphaArray(0).getVal(); } catch (Exception ex) { LOG.log(Level.FINE, "No alpha entry", ex); } return assembleXcolor(bcolor, 0, lumOff, lumMod, alphaStr); }
java
{ "resource": "" }
q178642
ColorUtility.getXColorWithAutomaticFill
test
private static XColor getXColorWithAutomaticFill(final int index, final ThemesTable themeTable) { int reminder = (index + 1) % AUTOCOLORSIZE; if (reminder == 0) { reminder = AUTOCOLORSIZE; } String schema = AUTOCOLORNAME + reminder; double tint = getAutomaticTint(index); return getXColorWithSchema(schema, tint, null, themeTable); }
java
{ "resource": "" }
q178643
ColorUtility.xssfClrToClr
test
public static Color xssfClrToClr(final XSSFColor xssfColor) { short[] rgb = getTripletFromXSSFColor(xssfColor); return new Color(rgb[0], rgb[1], rgb[2]); }
java
{ "resource": "" }
q178644
ColorUtility.getTripletFromXSSFColor
test
public static short[] getTripletFromXSSFColor( final XSSFColor xssfColor) { short[] rgbfix = { RGB8BITS, RGB8BITS, RGB8BITS }; if (xssfColor != null) { byte[] rgb = xssfColor.getRGBWithTint(); if (rgb == null) { rgb = xssfColor.getRGB(); } // Bytes are signed, so values of 128+ are negative! // 0: red, 1: green, 2: blue rgbfix[0] = (short) ((rgb[0] < 0) ? (rgb[0] + RGB8BITS) : rgb[0]); rgbfix[1] = (short) ((rgb[1] < 0) ? (rgb[1] + RGB8BITS) : rgb[1]); rgbfix[2] = (short) ((rgb[2] < 0) ? (rgb[2] + RGB8BITS) : rgb[2]); } return rgbfix; }
java
{ "resource": "" }
q178645
ColorUtility.getBgColorFromCell
test
static String getBgColorFromCell(final Workbook wb, final Cell poiCell, final CellStyle cellStyle) { String style = ""; if (poiCell instanceof HSSFCell) { int bkColorIndex = cellStyle.getFillForegroundColor(); HSSFColor color = HSSFColor.getIndexHash().get(bkColorIndex); if (color != null) { // correct color for customPalette HSSFPalette palette = ((HSSFWorkbook) wb) .getCustomPalette(); HSSFColor color2 = palette.getColor(bkColorIndex); if (!color.getHexString() .equalsIgnoreCase(color2.getHexString())) { color = color2; } style = "background-color:rgb(" + FacesUtility.strJoin(color.getTriplet(), ",") + ");"; } } else if (poiCell instanceof XSSFCell) { XSSFColor color = ((XSSFCell) poiCell).getCellStyle() .getFillForegroundColorColor(); if (color != null) { style = "background-color:rgb(" + FacesUtility.strJoin( getTripletFromXSSFColor(color), ",") + ");"; } } return style; }
java
{ "resource": "" }
q178646
CellControlsUtility.findComponentNameFromClass
test
private static String findComponentNameFromClass( final UIComponent component) { String cname = component.getClass().getSimpleName(); if (supportComponents.contains(cname)) { return cname; } return null; }
java
{ "resource": "" }
q178647
CellControlsUtility.populateAttributes
test
public static void populateAttributes(final UIComponent component, final FacesCell fcell, final Map<String, Map<String, String>> defaultControlMap) { List<CellFormAttributes> inputAttrs = fcell.getInputAttrs(); String cname = findComponentNameFromClass(component); if (cname == null) { return; } Map<String, String> defaultMap = defaultControlMap.get(cname); if (defaultMap == null) { defaultMap = new HashMap<>(); defaultControlMap.put(cname, defaultMap); } for (Map.Entry<String, String> entry : defaultMap.entrySet()) { setObjectProperty(component, entry.getKey(), entry.getValue(), true); } for (CellFormAttributes attr : inputAttrs) { String propertyName = attr.getType(); String propertyValue = attr.getValue(); if (!defaultMap.containsKey(propertyName)) { String defaultValue = getObjectPropertyValue(component, propertyName, true); defaultMap.put(propertyName, defaultValue); } setObjectProperty(component, propertyName, propertyValue, true); } }
java
{ "resource": "" }
q178648
CellControlsUtility.matchParaMeterOfMethod
test
private static AttributesType matchParaMeterOfMethod(final Object obj, final String methodName) { for (AttributesType attr : AttributesType.values()) { try { obj.getClass().getMethod(methodName, new Class[] { attr.clazz }); return attr; } catch (Exception ex) { LOG.log(Level.FINE, " error in matchParaMeterOfMethod = " + ex.getLocalizedMessage(), ex); } } return null; }
java
{ "resource": "" }
q178649
CellControlsUtility.setObjectProperty
test
public static void setObjectProperty(final Object obj, final String propertyName, final String propertyValue, final boolean ignoreNonExisting) { try { String methodName = "set" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); AttributesType parameterType = matchParaMeterOfMethod(obj, methodName); if (parameterType != null) { Method method = obj.getClass().getMethod(methodName, new Class[] { parameterType.clazz }); method.invoke(obj, convertToObject(parameterType, propertyValue)); } } catch (Exception e) { String msg = "failed to set property '" + propertyName + "' to value '" + propertyValue + "' for object " + obj; if (ignoreNonExisting) { LOG.log(Level.FINE, msg, e); } else { LOG.warning(msg); throw new IllegalArgumentException(e); } } }
java
{ "resource": "" }
q178650
CellControlsUtility.getObjectPropertyValue
test
public static String getObjectPropertyValue(final Object obj, final String propertyName, final boolean ignoreNonExisting) { try { Method method = obj.getClass() .getMethod("get" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1)); return (String) method.invoke(obj); } catch (Exception e) { String msg = "failed to get property '" + propertyName + "' for object " + obj; if (ignoreNonExisting) { LOG.log(Level.FINE, msg, e); } else { LOG.warning(msg); throw new IllegalArgumentException(e); } } return null; }
java
{ "resource": "" }
q178651
CellControlsUtility.setupControlAttributes
test
public static void setupControlAttributes(final int originRowIndex, final FacesCell fcell, final Cell poiCell, final SheetConfiguration sheetConfig, final CellAttributesMap cellAttributesMap) { int rowIndex = originRowIndex; if (rowIndex < 0) { rowIndex = poiCell.getRowIndex(); } String skey = poiCell.getSheet().getSheetName() + "!" + CellUtility .getCellIndexNumberKey(poiCell.getColumnIndex(), rowIndex); Map<String, String> commentMap = cellAttributesMap .getTemplateCommentMap().get("$$"); if (commentMap != null) { String comment = commentMap.get(skey); if (comment != null) { CommandUtility.createCellComment(poiCell, comment, sheetConfig.getFinalCommentMap()); } } String widgetType = cellAttributesMap.getCellInputType().get(skey); if (widgetType != null) { fcell.setControl(widgetType.toLowerCase()); fcell.setInputAttrs( cellAttributesMap.getCellInputAttributes().get(skey)); fcell.setSelectItemAttrs(cellAttributesMap .getCellSelectItemsAttributes().get(skey)); fcell.setDatePattern( cellAttributesMap.getCellDatePattern().get(skey)); } }
java
{ "resource": "" }
q178652
CellControlsUtility.findCellValidateAttributes
test
public static List<CellFormAttributes> findCellValidateAttributes( final Map<String, List<CellFormAttributes>> validateMaps, final int originRowIndex, final Cell cell) { String key = cell.getSheet().getSheetName() + "!" + CellUtility .getCellIndexNumberKey(cell.getColumnIndex(), originRowIndex); return validateMaps.get(key); }
java
{ "resource": "" }
q178653
PicturesHelper.setupFacesCellPictureCharts
test
public final void setupFacesCellPictureCharts(final Sheet sheet1, final FacesCell fcell, final Cell cell, final String fId) { if (parent.getPicturesMap() != null) { setupFacesCellPicture(sheet1, fcell, cell, fId); } if (parent.getCharsData().getChartsMap() != null) { setupFacesCellCharts(sheet1, fcell, cell, fId); } }
java
{ "resource": "" }
q178654
PicturesHelper.setupFacesCellCharts
test
private void setupFacesCellCharts(final Sheet sheet1, final FacesCell fcell, final Cell cell, final String fId) { try { String chartId = parent.getCharsData().getChartPositionMap() .get(fId); if (chartId != null) { BufferedImage img = parent.getCharsData().getChartsMap() .get(chartId); if (img != null) { fcell.setContainChart(true); fcell.setChartId(chartId); fcell.setChartStyle(PicturesUtility.generateChartStyle( sheet1, fcell, cell, chartId, parent.getCharsData().getChartAnchorsMap())); } } } catch (Exception ex) { LOG.log(Level.SEVERE, "setupFacesCell Charts error = " + ex.getMessage(), ex); } }
java
{ "resource": "" }
q178655
PicturesHelper.setupFacesCellPicture
test
private void setupFacesCellPicture(final Sheet sheet1, final FacesCell fcell, final Cell cell, final String fId) { try { Picture pic = parent.getPicturesMap().get(fId); if (pic != null) { fcell.setContainPic(true); fcell.setPictureId(fId); fcell.setPictureStyle(PicturesUtility .generatePictureStyle(sheet1, fcell, cell, pic)); } } catch (Exception ex) { LOG.log(Level.SEVERE, "setupFacesCell Picture error = " + ex.getMessage(), ex); } }
java
{ "resource": "" }
q178656
ChartHelper.initChartsMap
test
private void initChartsMap(final Workbook wb) { try { if (wb instanceof XSSFWorkbook) { initXSSFChartsMap((XSSFWorkbook) wb, parent.getCharsData()); } } catch (Exception e) { LOG.log(Level.SEVERE, "getChartsMap Error Exception = " + e.getLocalizedMessage(), e); } }
java
{ "resource": "" }
q178657
ChartHelper.getPieTitle
test
private String getPieTitle(final ChartData chartData) { for (ChartSeries chartSeries : chartData.getSeriesList()) { if (chartSeries != null) { return getParsedCellValue(chartSeries.getSeriesLabel()); } } return ""; }
java
{ "resource": "" }
q178658
ChartHelper.setSeriesStyle
test
public final void setSeriesStyle(final JFreeChart chart, final int seriesIndex, final String style) { if (chart != null && style != null) { BasicStroke stroke = ChartUtility.toStroke(style); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = chart.getCategoryPlot(); CategoryItemRenderer cir = categoryPlot.getRenderer(); try { cir.setSeriesStroke(seriesIndex, stroke); // series line // style } catch (Exception e) { LOG.log(Level.SEVERE, "Error setting style '" + style + "' for series '" + Integer.toString(seriesIndex) + "' of chart '" + chart.toString() + "': " + e.getLocalizedMessage(), e); } } else if (plot instanceof XYPlot) { XYPlot xyPlot = chart.getXYPlot(); XYItemRenderer xyir = xyPlot.getRenderer(); try { xyir.setSeriesStroke(seriesIndex, stroke); // series line // style } catch (Exception e) { LOG.log(Level.SEVERE, "Error setting style '" + style + "' for series '" + Integer.toString(seriesIndex) + "' of chart '" + chart.toString() + "': " + e.getLocalizedMessage(), e); } } else { LOG.log(Level.FINE, "setSeriesColor() unsupported plot: {}", plot.toString()); } } }
java
{ "resource": "" }
q178659
ChartHelper.createPie3DChart
test
public JFreeChart createPie3DChart(final ChartData chartData) { // create the chart... final JFreeChart chart = ChartFactory.createPieChart3D( getPieTitle(chartData), // chart title createPieDataset(chartData), // data true, // include legend false, // tooltips false // urls ); setupPieStyle(chart, chartData); return chart; }
java
{ "resource": "" }
q178660
ChartHelper.setupBarStyle
test
private void setupBarStyle(final JFreeChart chart, final ChartData chartData) { setupStyle(chart, chartData); CategoryPlot plot = (CategoryPlot) chart.getPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setItemMargin(TieConstants.DEFAULT_BAR_STYLE_ITEM_MARGIN); plot.setForegroundAlpha( TieConstants.DEFAULT_BARSTYLE_FOREGROUND_ALPHA); }
java
{ "resource": "" }
q178661
ChartHelper.initXSSFChartsMap
test
private void initXSSFChartsMap(final XSSFWorkbook wb, final ChartsData chartsData) { initAnchorsMap(wb, chartsData); Map<String, ClientAnchor> anchorMap = chartsData .getChartAnchorsMap(); Map<String, BufferedImage> chartMap = chartsData.getChartsMap(); Map<String, ChartData> chartDataMap = chartsData.getChartDataMap(); chartMap.clear(); chartDataMap.clear(); for (int i = 0; i < wb.getNumberOfSheets(); i++) { XSSFSheet sheet = wb.getSheetAt(i); XSSFDrawing drawing = sheet.createDrawingPatriarch(); List<XSSFChart> charts = drawing.getCharts(); if ((charts != null) && (!charts.isEmpty())) { for (XSSFChart chart : charts) { generateSingleXSSFChart(chart, getChartIdFromParent(chart, sheet.getSheetName()), sheet, anchorMap, chartMap, chartDataMap); } } } }
java
{ "resource": "" }
q178662
ChartHelper.getChartIdFromParent
test
private String getChartIdFromParent(final XSSFChart chart, final String sheetName) { if (chart.getParent() != null) { for (RelationPart rp : chart.getParent().getRelationParts()) { if (rp.getDocumentPart() == chart) { return sheetName + "!" + rp.getRelationship().getId(); } } } return null; }
java
{ "resource": "" }
q178663
ChartHelper.initAnchorsMap
test
private void initAnchorsMap(final Workbook wb, final ChartsData chartsData) { try { if (wb instanceof XSSFWorkbook) { ChartUtility.initXSSFAnchorsMap((XSSFWorkbook) wb, chartsData); } } catch (Exception e) { LOG.log(Level.SEVERE, "Web Form getAnchorsMap Error Exception = " + e.getLocalizedMessage(), e); } }
java
{ "resource": "" }
q178664
ChartHelper.generateSingleXSSFChart
test
private void generateSingleXSSFChart(final XSSFChart chart, final String chartId, final XSSFSheet sheet, final Map<String, ClientAnchor> anchorMap, final Map<String, BufferedImage> chartMap, final Map<String, ChartData> chartDataMap) { ClientAnchor anchor; try { anchor = anchorMap.get(chartId); if (anchor != null) { ChartData chartData = ChartUtility .initChartDataFromXSSFChart(chartId, chart, (XSSFWorkbook) parent.getWb()); chartDataMap.put(chartId, chartData); JFreeChart jchart = createChart(chartData); if (jchart != null) { AnchorSize anchorSize = PicturesUtility .getAnchorSize(sheet, null, null, anchor); BufferedImage img = jchart.createBufferedImage( anchorSize.getWidth(), anchorSize.getHeight()); chartMap.put(chartId, img); } } } catch (Exception ex) { LOG.log(Level.SEVERE, "generate chart for " + chartId + " error = " + ex.getLocalizedMessage(), ex); } }
java
{ "resource": "" }
q178665
ConfigurationUtility.transformToCollectionObject
test
@SuppressWarnings("rawtypes") public static Collection transformToCollectionObject( final ExpressionEngine engine, final String collectionName, final Map<String, Object> context) { Object collectionObject = engine.evaluate(collectionName, context); if (!(collectionObject instanceof Collection)) { throw new EvaluationException( collectionName + " expression is not a collection"); } return (Collection) collectionObject; }
java
{ "resource": "" }
q178666
ConfigurationUtility.getFullNameFromRow
test
public static String getFullNameFromRow(final Row row) { if (row != null) { Cell cell = row.getCell(TieConstants.HIDDEN_FULL_NAME_COLUMN); if (cell != null) { return cell.getStringCellValue(); } } return null; }
java
{ "resource": "" }
q178667
ConfigurationUtility.reBuildUpperLevelFormula
test
public static void reBuildUpperLevelFormula( final ConfigBuildRef configBuildRef, final String actionFullName) { Map<Cell, String> cachedMap = configBuildRef.getCachedCells(); Map<String, List<RowsMapping>> rowsMap = new HashMap<>(); for (Map.Entry<Cell, String> entry : cachedMap.entrySet()) { Cell cell = entry.getKey(); String originFormula = entry.getValue(); if (originFormula != null) { setupUpperLevelFormula(cell, originFormula, actionFullName, rowsMap, configBuildRef); } } }
java
{ "resource": "" }
q178668
ConfigurationUtility.setupUpperLevelFormula
test
private static void setupUpperLevelFormula(final Cell cell, final String originFormula, final String actionFullName, final Map<String, List<RowsMapping>> rowsMap, final ConfigBuildRef configBuildRef) { String fullName = getFullNameFromRow(cell.getRow()); // check wither it's upper level if (actionFullName.startsWith(fullName + ":")) { // get rows mapping for upper level row List<RowsMapping> currentRowsMappingList = rowsMap .get(fullName); if (currentRowsMappingList == null) { currentRowsMappingList = gatherRowsMappingByFullName( configBuildRef, fullName); rowsMap.put(fullName, currentRowsMappingList); } ShiftFormulaRef shiftFormulaRef = new ShiftFormulaRef( configBuildRef.getWatchList(), currentRowsMappingList); shiftFormulaRef.setFormulaChanged(0); buildCellFormulaForShiftedRows(configBuildRef.getSheet(), configBuildRef.getWbWrapper(), shiftFormulaRef, cell, originFormula); if (shiftFormulaRef.getFormulaChanged() > 0) { configBuildRef.getCachedCells().put(cell, originFormula); } } }
java
{ "resource": "" }
q178669
ConfigurationUtility.buildCellFormulaForShiftedRows
test
public static void buildCellFormulaForShiftedRows(final Sheet sheet, final XSSFEvaluationWorkbook wbWrapper, final ShiftFormulaRef shiftFormulaRef, final Cell cell, final String originFormula) { // only shift when there's watchlist exist. if ((shiftFormulaRef.getWatchList() != null) && (!shiftFormulaRef.getWatchList().isEmpty())) { Ptg[] ptgs = FormulaParser.parse(originFormula, wbWrapper, FormulaType.CELL, sheet.getWorkbook().getSheetIndex(sheet)); Ptg[] convertedFormulaPtg = ShiftFormulaUtility .convertSharedFormulas(ptgs, shiftFormulaRef); if (shiftFormulaRef.getFormulaChanged() > 0) { // only change formula when indicator is true cell.setCellFormula(FormulaRenderer .toFormulaString(wbWrapper, convertedFormulaPtg)); } } }
java
{ "resource": "" }
q178670
ConfigurationUtility.gatherRowsMappingByFullName
test
public static List<RowsMapping> gatherRowsMappingByFullName( final ConfigBuildRef configBuildRef, final String fullName) { List<RowsMapping> list = new ArrayList<>(); Map<String, ConfigRangeAttrs> shiftMap = configBuildRef .getShiftMap(); for (Map.Entry<String, ConfigRangeAttrs> entry : shiftMap .entrySet()) { String fname = entry.getKey(); if (fname.startsWith(fullName + ":") || fname.equals(fullName)) { ConfigRangeAttrs attrs = entry.getValue(); list.add(attrs.getUnitRowsMapping()); } } return list; }
java
{ "resource": "" }
q178671
ConfigurationUtility.changeIndexNumberInShiftMap
test
public static void changeIndexNumberInShiftMap( final Map<String, ConfigRangeAttrs> shiftMap, final Map<String, String> changeMap) { for (Map.Entry<String, String> entry : changeMap.entrySet()) { String key = entry.getKey(); String newKey = entry.getValue(); ConfigRangeAttrs attrs = shiftMap.get(key); if (attrs != null) { shiftMap.remove(key); shiftMap.put(newKey, attrs); } } }
java
{ "resource": "" }
q178672
ConfigurationUtility.changeUpperLevelFinalLength
test
public static void changeUpperLevelFinalLength( final Map<String, ConfigRangeAttrs> shiftMap, final String addedFullName, final int increasedLength) { String[] parts = addedFullName.split(":"); StringBuilder fname = new StringBuilder(); for (int i = 0; i < (parts.length - 1); i++) { if (i == 0) { fname.append(parts[i]); } else { fname.append(":").append(parts[i]); } String sname = fname.toString(); shiftMap.get(sname).setFinalLength( shiftMap.get(sname).getFinalLength() + increasedLength); } }
java
{ "resource": "" }
q178673
ConfigurationUtility.changeIndexNumberInHiddenColumn
test
public static void changeIndexNumberInHiddenColumn( final ConfigBuildRef configBuildRef, final int startRowIndex, final String fullName, final Map<String, String> changeMap, final int steps) { String searchName = fullName.substring(0, fullName.lastIndexOf('.') + 1); Sheet sheet = configBuildRef.getSheet(); for (int i = startRowIndex; i <= sheet.getLastRowNum(); i++) { Row row = sheet.getRow(i); String fname = getFullNameFromRow(row); if ((fname != null) && (fname.indexOf(searchName) >= 0)) { int sindex = fname.indexOf(searchName); String snum = fname.substring(sindex + searchName.length()); int sufindex = snum.indexOf(':'); String suffix = ""; if (sufindex > 0) { snum = snum.substring(0, sufindex); suffix = ":"; } int increaseNum = Integer.parseInt(snum) + steps; String realFullName = fname.substring(sindex); String changeName = fname.replace( searchName + snum + suffix, searchName + increaseNum + suffix); if (changeMap.get(realFullName) == null) { changeMap.put(realFullName, changeName.substring(sindex)); } setFullNameInHiddenColumn(row, changeName); } else { return; } } }
java
{ "resource": "" }
q178674
ConfigurationUtility.setFullNameInHiddenColumn
test
public static void setFullNameInHiddenColumn(final Row row, final String fullName) { Cell cell = row.getCell(TieConstants.HIDDEN_FULL_NAME_COLUMN, MissingCellPolicy.CREATE_NULL_AS_BLANK); cell.setCellValue(fullName); }
java
{ "resource": "" }
q178675
ConfigurationUtility.getOriginalRowNumInHiddenColumn
test
public static int getOriginalRowNumInHiddenColumn(final Row row) { if (row != null) { Cell cell = row.getCell( TieConstants.HIDDEN_ORIGIN_ROW_NUMBER_COLUMN, MissingCellPolicy.CREATE_NULL_AS_BLANK); String rowNum = cell.getStringCellValue(); try { if ((rowNum != null) && (!rowNum.isEmpty()) && (WebSheetUtility.isNumeric(rowNum))) { return Integer.parseInt(rowNum); } } catch (Exception ex) { LOG.log(Level.SEVERE, "getOriginalRowNumInHiddenColumn rowNum = " + rowNum + " error = " + ex.getLocalizedMessage(), ex); } } return -1; }
java
{ "resource": "" }
q178676
ConfigurationUtility.setOriginalRowNumInHiddenColumn
test
public static void setOriginalRowNumInHiddenColumn(final Row row, final int rowNum) { Cell cell = row.getCell( TieConstants.HIDDEN_ORIGIN_ROW_NUMBER_COLUMN, MissingCellPolicy.CREATE_NULL_AS_BLANK); cell.setCellValue(Integer.toString(rowNum)); cell.setCellType(CellType.STRING); }
java
{ "resource": "" }
q178677
ConfigurationUtility.findParentRowsMappingFromShiftMap
test
public static List<RowsMapping> findParentRowsMappingFromShiftMap( final String[] parts, final Map<String, ConfigRangeAttrs> shiftMap) { StringBuilder fullName = new StringBuilder(); List<RowsMapping> rowsMappingList = new ArrayList<>(); /** * skip first one and last one. first one is line no. last one is it's * self. */ for (int i = 1; i < parts.length - 1; i++) { String part = parts[i]; if (fullName.length() == 0) { fullName.append(part); } else { fullName.append(":" + part); } if (fullName.length() > 0) { ConfigRangeAttrs rangeAttrs = shiftMap .get(fullName.toString()); if (rangeAttrs != null) { rowsMappingList.add(rangeAttrs.getUnitRowsMapping()); } } } return rowsMappingList; }
java
{ "resource": "" }
q178678
ConfigurationUtility.findChildRowsMappingFromShiftMap
test
public static List<RowsMapping> findChildRowsMappingFromShiftMap( final String fullName, final NavigableMap<String, ConfigRangeAttrs> shiftMap) { List<RowsMapping> rowsMappingList = new ArrayList<>(); NavigableMap<String, ConfigRangeAttrs> tailmap = shiftMap .tailMap(fullName, false); for (Map.Entry<String, ConfigRangeAttrs> entry : tailmap .entrySet()) { String key = entry.getKey(); // check it's children if (key.startsWith(fullName)) { rowsMappingList.add(entry.getValue().getUnitRowsMapping()); } else { break; } } return rowsMappingList; }
java
{ "resource": "" }
q178679
ConfigurationUtility.findItemInCollection
test
@SuppressWarnings("rawtypes") public static Object findItemInCollection(final Collection collection, final int index) { if (index >= 0) { if (collection instanceof List) { List list = (List) collection; return list.get(index); } int i = 0; for (Object object : collection) { if (i == index) { return object; } i++; } } return null; }
java
{ "resource": "" }
q178680
ConfigurationUtility.buildCurrentRange
test
public static ConfigRange buildCurrentRange( final ConfigRange sourceConfigRange, final Sheet sheet, final int insertPosition) { ConfigRange current = new ConfigRange(sourceConfigRange); int shiftNum = insertPosition - sourceConfigRange.getFirstRowAddr().getRow(); current.shiftRowRef(sheet, shiftNum); return current; }
java
{ "resource": "" }
q178681
ConfigurationUtility.isStaticRow
test
public static boolean isStaticRow(final ConfigRange sourceConfigRange, final int rowIndex) { if (sourceConfigRange.getCommandList() != null) { for (int i = 0; i < sourceConfigRange.getCommandList() .size(); i++) { Command command = sourceConfigRange.getCommandList().get(i); if ((rowIndex >= command.getConfigRange().getFirstRowAddr() .getRow()) && (rowIndex < (command.getConfigRange() .getLastRowPlusAddr().getRow()))) { return false; } } } return true; }
java
{ "resource": "" }
q178682
ConfigurationUtility.isStaticRowRef
test
public static boolean isStaticRowRef( final ConfigRange sourceConfigRange, final Row row) { if (sourceConfigRange.getCommandList() != null) { for (int i = 0; i < sourceConfigRange.getCommandList() .size(); i++) { Command command = sourceConfigRange.getCommandList().get(i); int rowIndex = row.getRowNum(); if ((rowIndex >= command.getTopRow()) && (rowIndex < (command.getTopRow() + command.getFinalLength()))) { return false; } } } return true; }
java
{ "resource": "" }
q178683
ConfigurationUtility.replaceExpressionWithCellValue
test
public static String replaceExpressionWithCellValue( final String attrValue, final int rowIndex, final Sheet sheet) { int ibegin = 0; int ifind; int inameEnd; String tempStr; String findStr; String replaceStr; String returnStr = attrValue; while ((ifind = attrValue.indexOf(TieConstants.CELL_ADDR_PRE_FIX, ibegin)) > 0) { inameEnd = ParserUtility.findFirstNonCellNamePosition(attrValue, ifind); if (inameEnd > 0) { findStr = attrValue.substring(ifind, inameEnd); } else { findStr = attrValue.substring(ifind); } if (findStr.indexOf(TieConstants.CELL_ADDR_PRE_FIX, 1) < 0) { // only $A tempStr = findStr + TieConstants.CELL_ADDR_PRE_FIX + (rowIndex + 1); } else { tempStr = findStr; } replaceStr = CellUtility.getCellValueWithoutFormat( WebSheetUtility.getCellByReference(tempStr, sheet)); if (replaceStr == null) { replaceStr = ""; } returnStr = attrValue.replace(findStr, replaceStr); ibegin = ifind + 1; } return returnStr; }
java
{ "resource": "" }
q178684
ConfigurationUtility.indexMergedRegion
test
public static Map<String, CellRangeAddress> indexMergedRegion( final Sheet sheet1) { int numRegions = sheet1.getNumMergedRegions(); Map<String, CellRangeAddress> cellRangeMap = new HashMap<>(); for (int i = 0; i < numRegions; i++) { CellRangeAddress caddress = sheet1.getMergedRegion(i); if (caddress != null) { cellRangeMap.put(CellUtility.getCellIndexNumberKey( caddress.getFirstColumn(), caddress.getFirstRow()), caddress); } } return cellRangeMap; }
java
{ "resource": "" }
q178685
ConfigurationUtility.skippedRegionCells
test
public static List<String> skippedRegionCells(final Sheet sheet1) { int numRegions = sheet1.getNumMergedRegions(); List<String> skipCellList = new ArrayList<>(); for (int i = 0; i < numRegions; i++) { CellRangeAddress caddress = sheet1.getMergedRegion(i); if (caddress != null) { addSkipCellToListInTheRegion(skipCellList, caddress); } } return skipCellList; }
java
{ "resource": "" }
q178686
ConfigurationUtility.addSkipCellToListInTheRegion
test
private static void addSkipCellToListInTheRegion( final List<String> skipCellList, final CellRangeAddress caddress) { for (int col = caddress.getFirstColumn(); col <= caddress .getLastColumn(); col++) { for (int row = caddress.getFirstRow(); row <= caddress .getLastRow(); row++) { if ((col == caddress.getFirstColumn()) && (row == caddress.getFirstRow())) { continue; } skipCellList .add(CellUtility.getCellIndexNumberKey(col, row)); } } }
java
{ "resource": "" }
q178687
ConfigurationUtility.buildSheetCommentFromAlias
test
public static void buildSheetCommentFromAlias(Sheet sheet, List<TieCommandAlias> tieCommandAliasList) { if ((tieCommandAliasList == null)||(tieCommandAliasList.isEmpty())) { return; } for (Row row : sheet) { for (Cell cell : row) { buildCellCommentFromalias(tieCommandAliasList, cell); } } }
java
{ "resource": "" }
q178688
ConfigurationUtility.buildCellCommentFromalias
test
private static void buildCellCommentFromalias(List<TieCommandAlias> tieCommandAliasList, Cell cell) { String value = CellUtility.getCellValueWithoutFormat(cell); if ((value!=null)&&(!value.isEmpty())) { for (TieCommandAlias alias : tieCommandAliasList) { Matcher matcher = alias.getPattern().matcher(value); if (matcher.find()) { CellUtility.createOrInsertComment(cell, alias.getCommand()); if (alias.isRemove()) { CellUtility.setCellValue(cell, ParserUtility.removeCharsFromString(value, matcher.start(), matcher.end())); } } } } }
java
{ "resource": "" }
q178689
ConfigurationHandler.buildConfiguration
test
public final Map<String, SheetConfiguration> buildConfiguration() { Map<String, SheetConfiguration> sheetConfigMap = new LinkedHashMap<>(); // in buildsheet, it's possible to add sheets in workbook. // so cache the sheetname first here. List<String> sheetNames = new ArrayList<>(); String sname; for (int i = 0; i < parent.getWb().getNumberOfSheets(); i++) { sname = parent.getWb().getSheetName(i); if (!sname.startsWith(org.tiefaces.common.TieConstants.COPY_SHEET_PREFIX)) { sheetNames.add(sname); } } for (String sheetName : sheetNames) { Sheet sheet = parent.getWb().getSheet(sheetName); ConfigurationUtility.buildSheetCommentFromAlias(sheet, parent.getTieCommandAliasList()); buildSheet(sheet, sheetConfigMap, parent.getCellAttributesMap()); } return sheetConfigMap; }
java
{ "resource": "" }
q178690
ConfigurationHandler.getSheetConfiguration
test
private SheetConfiguration getSheetConfiguration(final Sheet sheet, final String formName, final int sheetRightCol) { SheetConfiguration sheetConfig = new SheetConfiguration(); sheetConfig.setFormName(formName); sheetConfig.setSheetName(sheet.getSheetName()); int leftCol = sheet.getLeftCol(); int lastRow = sheet.getLastRowNum(); int firstRow = sheet.getFirstRowNum(); int rightCol = 0; int maxRow = 0; for (Row row : sheet) { if (row.getRowNum() > TieConstants.TIE_WEB_SHEET_MAX_ROWS) { break; } maxRow = row.getRowNum(); int firstCellNum = row.getFirstCellNum(); if (firstCellNum >= 0 && firstCellNum < leftCol) { leftCol = firstCellNum; } if ((row.getLastCellNum() - 1) > rightCol) { int verifiedcol = verifyLastCell(row, rightCol, sheetRightCol); if (verifiedcol > rightCol) { rightCol = verifiedcol; } } } if (maxRow < lastRow) { lastRow = maxRow; } // header range row set to 0 while column set to first column to // max // column (FF) e.g. $A$0 : $FF$0 String tempStr = TieConstants.CELL_ADDR_PRE_FIX + WebSheetUtility.getExcelColumnName(leftCol) + TieConstants.CELL_ADDR_PRE_FIX + "0 : " + TieConstants.CELL_ADDR_PRE_FIX + WebSheetUtility.getExcelColumnName(rightCol) + TieConstants.CELL_ADDR_PRE_FIX + "0"; sheetConfig.setFormHeaderRange(tempStr); sheetConfig.setHeaderCellRange(new CellRange(tempStr)); // body range row set to first row to last row while column set // to // first column to max column (FF) e.g. $A$1 : $FF$1000 tempStr = TieConstants.CELL_ADDR_PRE_FIX + WebSheetUtility.getExcelColumnName(leftCol) + TieConstants.CELL_ADDR_PRE_FIX + (firstRow + 1) + " : " + TieConstants.CELL_ADDR_PRE_FIX + WebSheetUtility.getExcelColumnName(rightCol) + TieConstants.CELL_ADDR_PRE_FIX + (lastRow + 1); sheetConfig.setFormBodyRange(tempStr); sheetConfig.setBodyCellRange(new CellRange(tempStr)); sheetConfig.setFormBodyType(org.tiefaces.common.TieConstants.FORM_TYPE_FREE); sheetConfig.setCellFormAttributes(new HashMap<String, List<CellFormAttributes>>()); // check it's a hidden sheet int sheetIndex = parent.getWb().getSheetIndex(sheet); if (parent.getWb().isSheetHidden(sheetIndex) || parent.getWb().isSheetVeryHidden(sheetIndex)) { sheetConfig.setHidden(true); } return sheetConfig; }
java
{ "resource": "" }
q178691
ConfigurationHandler.buildFormCommandFromSheetConfig
test
private FormCommand buildFormCommandFromSheetConfig(final SheetConfiguration sheetConfig, final Sheet sheet) { int firstRow = sheetConfig.getBodyCellRange().getTopRow(); int leftCol = sheetConfig.getBodyCellRange().getLeftCol(); int rightCol = sheetConfig.getBodyCellRange().getRightCol(); int lastRow = sheetConfig.getBodyCellRange().getBottomRow(); Cell firstCell = sheet.getRow(firstRow).getCell(leftCol, MissingCellPolicy.CREATE_NULL_AS_BLANK); FormCommand fcommand = new FormCommand(); fcommand.setCommandTypeName(TieConstants.COMMAND_FORM); if (sheetConfig.isHidden()) { fcommand.setHidden(TieConstants.TRUE_STRING); } else { fcommand.setHidden(TieConstants.FALSE_STRING); } fcommand.setName(sheetConfig.getFormName()); fcommand.getConfigRange().setFirstRowRef(firstCell, true); fcommand.getConfigRange().setLastRowPlusRef(sheet, rightCol, lastRow, true); fcommand.setHeaderLength("0"); fcommand.setFooterLength("0"); fcommand.setLength(Integer.toString(lastRow - firstRow + 1)); return fcommand; }
java
{ "resource": "" }
q178692
ConfigurationHandler.verifyLastCell
test
private int verifyLastCell(final Row row, final int stoppoint, final int sheetRightCol) { int lastCol = sheetRightCol; int col; for (col = lastCol; col >= stoppoint; col--) { Cell cell = row.getCell(col); if ((cell != null) && (cell.getCellTypeEnum() != CellType.BLANK)) { break; } } return col; }
java
{ "resource": "" }
q178693
ConfigurationHandler.buildSheet
test
public final void buildSheet(final Sheet sheet, final Map<String, SheetConfiguration> sheetConfigMap, final CellAttributesMap cellAttributesMap) { if ((sheet.getLastRowNum() <= 0) && (sheet.getRow(0) == null)) { // this is a empty sheet. skip it. return; } checkAndRepairLastRow(sheet); int sheetRightCol = WebSheetUtility.getSheetRightCol(sheet); List<ConfigCommand> commandList = buildCommandListFromSheetComment((XSSFSheet) sheet, sheetRightCol, cellAttributesMap); boolean hasEachCommand = hasEachCommandInTheList(commandList); List<String> formList = new ArrayList<>(); buildSheetConfigMapFromFormCommand(sheet, sheetConfigMap, commandList, formList, sheetRightCol); // match parent command matchParentCommand(commandList); // setup save attrs in hidden column in the sheet. // loop command list again to assemble other command list into sheet // configuration matchSheetConfigForm(sheetConfigMap, commandList, formList); initTemplateForCommand(sheet, sheetConfigMap, formList, hasEachCommand); }
java
{ "resource": "" }
q178694
ConfigurationHandler.checkAndRepairLastRow
test
private final void checkAndRepairLastRow(final Sheet sheet) { // repair last row if it's inserted in the configuration generation Row lastrow = sheet.getRow(sheet.getLastRowNum()); // if it's lastrow and all the cells are blank. then remove the lastrow. if (lastrow != null) { for (Cell cell : lastrow) { if ((cell.getCellTypeEnum() != CellType._NONE) && (cell.getCellTypeEnum() != CellType.BLANK)) { return; } } sheet.removeRow(lastrow); } }
java
{ "resource": "" }
q178695
ConfigurationHandler.buildCommandListFromSheetComment
test
private List<ConfigCommand> buildCommandListFromSheetComment(final XSSFSheet sheet, final int sheetRightCol, final CellAttributesMap cellAttributesMap) { List<ConfigCommand> commandList = new ArrayList<>(); // if skip then return empty list. if (parent.isSkipConfiguration()) { return commandList; } Map<CellAddress, ? extends Comment> comments = null; try { // due to a poi bug. null exception throwed if no comments in the // sheet. comments = sheet.getCellComments(); } catch (Exception ex) { LOG.log(Level.FINE, "Null exception throwed when no comment exists: " + ex.getLocalizedMessage(), ex); } if (comments == null) { return commandList; } // not sure the map is sorted. So use tree map to sort it. SortedSet<CellAddress> keys = new TreeSet<>(comments.keySet()); // go through each comments // if found tie command then transfer it to list also remove from // comments. for (CellAddress key : keys) { Cell cell = sheet.getRow(key.getRow()).getCell(key.getColumn(), MissingCellPolicy.CREATE_NULL_AS_BLANK); buildCommandList(sheet, sheetRightCol, cell, commandList, cellAttributesMap); } return commandList; }
java
{ "resource": "" }
q178696
ConfigurationHandler.setParentForChildCommand
test
private void setParentForChildCommand(final List<ConfigCommand> commandList, final int i, final ConfigCommand child) { int matchIndex = -1; ConfigRange matchRange = null; for (int j = 0; j < commandList.size(); j++) { if (j != i) { Command commandParent = commandList.get(j); if (!commandParent.getCommandTypeName().equalsIgnoreCase(TieConstants.COMMAND_FORM) && WebSheetUtility.insideRange(child.getConfigRange(), commandParent.getConfigRange()) && ((matchRange == null) || (WebSheetUtility.insideRange(commandParent.getConfigRange(), matchRange)))) { matchRange = commandParent.getConfigRange(); matchIndex = j; } } } if (matchIndex >= 0) { commandList.get(matchIndex).getConfigRange().addCommand(child); child.setParentFound(true); } }
java
{ "resource": "" }
q178697
ConfigurationHandler.hasEachCommandInTheList
test
private boolean hasEachCommandInTheList(final List<ConfigCommand> commandList) { if (commandList != null) { for (ConfigCommand command : commandList) { if (command.getCommandTypeName().equalsIgnoreCase(TieConstants.COMMAND_EACH)) { return true; } } } return false; }
java
{ "resource": "" }
q178698
ConfigurationHandler.matchCommandToSheetConfigForm
test
private void matchCommandToSheetConfigForm(final Map<String, SheetConfiguration> sheetConfigMap, final List<String> formList, final ConfigCommand command) { for (String formname : formList) { SheetConfiguration sheetConfig = sheetConfigMap.get(formname); if (WebSheetUtility.insideRange(command.getConfigRange(), sheetConfig.getFormCommand().getConfigRange())) { sheetConfig.getFormCommand().getConfigRange().addCommand(command); break; } } }
java
{ "resource": "" }
q178699
ConfigurationHandler.copyTemplateForTieCommands
test
private void copyTemplateForTieCommands(final Sheet sheet) { // if skip configuration. then return. if (parent.isSkipConfiguration()) { return; } Workbook wb = sheet.getWorkbook(); String copyName = TieConstants.COPY_SHEET_PREFIX + sheet.getSheetName(); if (wb.getSheet(copyName) == null) { Sheet newSheet = wb.cloneSheet(wb.getSheetIndex(sheet)); int sheetIndex = wb.getSheetIndex(newSheet); wb.setSheetName(sheetIndex, copyName); wb.setSheetHidden(sheetIndex, Workbook.SHEET_STATE_VERY_HIDDEN); } }
java
{ "resource": "" }