JAVA中text类怎么写_Java Text类代码示例

import org.thymeleaf.dom.Text; //导入依赖的package包/类

@Override

protected ProcessorResult doProcessElement(Arguments arguments, Element element, HttpServletRequest request,

HttpServletResponse response, HtmlTable htmlTable) {

if (htmlTable != null) {

HtmlColumn column = null;

String content = null;

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":csv")

|| element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":xml")

|| element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":pdf")

|| element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":xls")

|| element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":xlsx")) {

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":csv")) {

content = AttributeUtils.parseAttribute(arguments, element, DataTablesDialect.DIALECT_PREFIX + ":csv",

String.class);

element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":csv");

column = new HtmlColumn(ReservedFormat.CSV);

column.setContent(new StringBuilder(content));

htmlTable.getLastBodyRow().addColumn(column);

}

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":xml")) {

content = AttributeUtils.parseAttribute(arguments, element, DataTablesDialect.DIALECT_PREFIX + ":xml",

String.class);

element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":xml");

column = new HtmlColumn(ReservedFormat.XML);

column.setContent(new StringBuilder(content));

htmlTable.getLastBodyRow().addColumn(column);

}

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":pdf")) {

content = AttributeUtils.parseAttribute(arguments, element, DataTablesDialect.DIALECT_PREFIX + ":pdf",

String.class);

element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":pdf");

column = new HtmlColumn(ReservedFormat.PDF);

column.setContent(new StringBuilder(content));

htmlTable.getLastBodyRow().addColumn(column);

}

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":xls")) {

content = AttributeUtils.parseAttribute(arguments, element, DataTablesDialect.DIALECT_PREFIX + ":xls",

String.class);

element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":xls");

column = new HtmlColumn(ReservedFormat.XLS);

column.setContent(new StringBuilder(content));

htmlTable.getLastBodyRow().addColumn(column);

}

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":xlsx")) {

content = AttributeUtils.parseAttribute(arguments, element, DataTablesDialect.DIALECT_PREFIX + ":xlsx",

String.class);

element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":xlsx");

column = new HtmlColumn(ReservedFormat.XLSX);

column.setContent(new StringBuilder(content));

htmlTable.getLastBodyRow().addColumn(column);

}

}

// If the element contains a Text node, the content of the text node

// will be displayed in all formats

else if (element.getFirstChild() instanceof Text) {

htmlTable.getLastBodyRow().addColumn(((Text) element.getFirstChild()).getContent().trim());

}

// Otherwise, an empty cell will be displayed

else {

logger.warn("Only cells containing plain text are supported, those containing HTML code are still not!");

htmlTable.getLastBodyRow().addColumn("");

}

}

// Remove internal attribute

if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":data")) {

element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":data");

}

return ProcessorResult.OK;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值