Java 如何在Content Navigator搜索结果中设置contentSize的格式?
我正在编写一个内容导航器响应过滤器,它将格式化搜索结果中的两个字段:Java 如何在Content Navigator搜索结果中设置contentSize的格式?,java,ibm-content-navigator,Java,Ibm Content Navigator,我正在编写一个内容导航器响应过滤器,它将格式化搜索结果中的两个字段: 日期字段 示例:2018-04-03T00:00:00->04-03-2018 内容大小字段: 示例:14859->14.5 kB “日期”字段没有问题-它工作正常 “内容大小”字段不起作用。没有错误或警告-ICN只是没有显示格式化的值 问题可能是ICN将“contentSize”声明为xs:long。。。“长”列不能包含“kB”之类的字母或“.”之类的标点符号 这是我的密码: private void filte
- 日期字段 示例:2018-04-03T00:00:00->04-03-2018
- 内容大小字段: 示例:14859->14.5 kB
xs:long
。。。“长”列不能包含“kB”之类的字母或“.”之类的标点符号
这是我的密码:
private void filterSearch(JSONResultSetResponse jsonResultSetResponse) throws Exception {
// For each document returned by the search...
for (int i = 0; i < jsonResultSetResponse.getRowCount(); i++) {
JSONResultSetRow row = jsonResultSetResponse.getRow(i);
...
// contentSize
Long size = Long.parseLong((String)currentValue);
final String[] units = new String[] { "", "kB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
String formattedSize = new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
// EXAMPLE: change 14859 -> 14.5 kB
row.setAttributeType(symName, "xs:string");
row.setAttributeValue(symName, formattedSize);
...
private void filterSearch(JSONResultSetResponse JSONResultSetResponse)引发异常{
//对于搜索返回的每个文档。。。
对于(int i=0;i14.5 kB
setAttributeType(symName,“xs:string”);
row.setAttributeValue(symName,formattedSize);
...
问:你知道如何在Content Navigator搜索结果中正确设置“long”值的格式吗?使用这个,将格式设置为“fileSize”
对文件大小使用双重类型
row.addAttribute(title, (Double)value, JSONResultSetRow.TYPE_INTEGER, "fileSize", null);