dataset的数据-自己常用的方法原创
3人赞赏了该文章
4,719次浏览
编辑于2021年07月26日 16:35:02
kd.cd.sczclt.biz.utilkd.bos.algo.DataSetkd.bos.algo.Fieldkd.bos.algo.Rowkd.bos.algo.RowMetajava.math.BigDecimaljava.math.BigIntegerjava.util.*java.util.stream.Collectorskd.cd.sczclt.common.util.CommonUtils.DataSetHelper { List<Object> (DataSet dataSetO) { DataSet dataSet = dataSetO.copy()RowMeta rowMeta = dataSet.getRowMeta()length = dataSet.getRowMeta().getDataTypes().List<Object> objectsList = ArrayList<>()List<Object> objectNameList = ArrayList<>()(i = i < lengthi++) { objectNameList.add(rowMeta.getField(i).getName())} System..println(objectNameList.toString().replaceAll().replaceAll().replaceAll())objectsList.add(objectNameList)(Row row : dataSet) { List<Object> objectList = ArrayList<>()(i = i < lengthi++) { objectList.add(row.get(i))} objectsList.add(objectList)System..println(objectList.toString().replaceAll().replaceAll().replaceAll() )} objectsList} List<Map<StringObject>> (DataSet dataSetO) { DataSet dataSet = dataSetO.copy()RowMeta rowMeta = dataSet.getRowMeta()length = dataSet.getRowMeta().getDataTypes().List<Object> objectsList = ArrayList<>()List<Object> objectNameList = ArrayList<>()(i = i < lengthi++) { objectNameList.add(rowMeta.getField(i).getName())} (Row row : dataSet) { List<Object> objectList = ArrayList<>()(i = i < lengthi++) { objectList.add(row.get(i))} objectsList.add(objectList)} List<Map<StringObject>> result = ArrayList<>()(Object object : objectsList) { List<Object> objects = (List<Object>) objectMap<StringObject> o = HashMap<>()(i = i < objectNameList.size()i++) { o.put(objectNameList.get(i).toString()objects.get(i))} result.add(o)} result} List<Object> (DataSet dataSetOString filed) { DataSet dataSet = dataSetO.copy()(dataSetfiled)List<Object> objectsList = ArrayList<>()(Row row : dataSet) { objectsList.add(row.get(filed))} objectsList} (DataSet dataSetOString filed){ Field[] fields = dataSetO.copy().getRowMeta().getFields()List<String> collect = Arrays.(fields).map(a -> a.getName()).collect(Collectors.())(!collect.contains(filed)){ { i = /}(Exception e){ e} } } List<Long> (DataSet dataSetOString filed) { DataSet dataSet = dataSetO.copy()(dataSetfiled)List<Long> longList = ArrayList<>()(Row row : dataSet) { longList.add(row.getLong(filed))} longList} List<String> (DataSet dataSetOString filed) { DataSet dataSet = dataSetO.copy()(dataSetfiled)List<String> stringList = ArrayList<>()(Row row : dataSet) { stringList.add(row.getString(filed))} stringList} List<BigDecimal> (DataSet dataSetOString filed) { DataSet dataSet = dataSetO.copy()(dataSetfiled)List<BigDecimal> bigDecimalListList = ArrayList<>()(Row row : dataSet) { bigDecimalListList.add(row.getBigDecimal(filed))} bigDecimalListList} List<Double> (DataSet dataSetOString filed) { DataSet dataSet = dataSetO.copy()(dataSetfiled)List<Double> objectsList = ArrayList<>()(Row row : dataSet) { objectsList.add(row.getDouble(filed))} objectsList} Double (DataSet dataSetOString filed) { DataSet dataSet = dataSetO.copy()(dataSetfiled)Double data=dataSet=dataSet.addField().groupBy(String[]{}).sum(filed).finish()(Row row : dataSet) { data=row.getDouble()} data} String (String bill){ DataSet dataSet = (+ bill+)List<Object> ftabname = (dataSet)ftabname.get()==?:ftabname.get().toString()} BigDecimal (Object value) { BigDecimal ret = (value != ) { (value BigDecimal) { ret = (BigDecimal) value} (value String) { ret = BigDecimal((String) value)} (value BigInteger) { ret = BigDecimal((BigInteger) value)} (value Number) { ret = BigDecimal(((Number) value).toString())} { ClassCastException(+ value + + value.getClass() + )} } ret} BigDecimal (Object valuei) { BigDecimal ret = (value != ) { (value BigDecimal) { ret = (BigDecimal) value} (value String) { ret = BigDecimal((String) value)} (value BigInteger) { ret = BigDecimal((BigInteger) value)} (value Number) { ret = BigDecimal(((Number) value).toString())} { ClassCastException(+ value + + value.getClass() + )} } ret.setScale(iBigDecimal.)} }
赞 3
3人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!