List of usage examples for org.apache.wicket.markup.parser XmlPullParser getInput
@Override public final CharSequence getInput(final int fromPos, final int toPos)
From source file:org.wicketstuff.poi.excel.GeneralPurposeExporter.java
License:Apache License
public void exportCell(XmlTag tag, XmlPullParser parser, Cell cell, Component gridComponent) throws ParseException { XmlTag firstMostNestedTag = tag;/*from w w w. java2s . c o m*/ // find the most inner tag value while ((tag = parser.nextTag()).getName().equals("td") == false) { if (tag.isOpen() || tag.isOpenClose()) { firstMostNestedTag = tag; } else { break; } } CharSequence possibleComponentReference = firstMostNestedTag .getAttribute(TableParser.OutputPathBehavior.PATH_ATTRIBUTE); if (possibleComponentReference != null) { Component firstMostNestedComponent = gridComponent.getPage().get(possibleComponentReference.toString()); // exclude auto links if (firstMostNestedComponent.getClass().getName().contains("ResourceReferenceAutolink")) { cell.setCellValue(""); return; } // handle links if (firstMostNestedComponent instanceof Link) { Link<?> link = (Link<?>) firstMostNestedComponent; firstMostNestedComponent = getLinkInnerComponent(link); if (firstMostNestedComponent == null) { cell.setCellValue(""); return; } } Object modelValue = firstMostNestedComponent.getDefaultModelObject(); if (modelValue != null) { if (modelValue instanceof Number) { handleNumber(cell, (Number) modelValue); } else if (modelValue instanceof CharSequence) { cell.setCellValue(modelValue.toString()); } else if (modelValue instanceof CharSequence) { cell.setCellValue(modelValue.toString()); } else if (modelValue instanceof Boolean) { cell.setCellValue((Boolean) modelValue); } else if (modelValue instanceof Calendar) { handleCalendar(cell, (Calendar) modelValue); } else if (modelValue instanceof Date) { handleDate(cell, (Date) modelValue); } else { cell.setCellValue(modelValue.toString()); } } } else { // simply set the first most nested tag value String value = parser .getInput(firstMostNestedTag.getPos() + firstMostNestedTag.getLength(), tag.getPos()) .toString(); cell.setCellValue(value); } }