protected void exportGenericElement(JRGenericPrintElement element) throws IOException { GenericElementXmlHandler handler = (GenericElementXmlHandler) GenericElementHandlerEnviroment.getHandler(element.getGenericType(), getExporterKey()); if (handler != null) { handler.exportElement(exporterContext, element); } else { xmlWriter.startElement(JRXmlConstants.ELEMENT_genericElement); exportReportElement(element); JRGenericElementType genericType = element.getGenericType(); xmlWriter.startElement(JRXmlConstants.ELEMENT_genericElementType); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_namespace, genericType.getNamespace()); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, genericType.getName()); xmlWriter.closeElement(); // genericElementType Set<String> names = element.getParameterNames(); for (Iterator<String> it = names.iterator(); it.hasNext(); ) { String name = it.next(); Object value = element.getParameterValue(name); xmlWriter.startElement(JRXmlConstants.ELEMENT_genericElementParameter); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_name, name); if (value != null) { String valueClass = value.getClass().getName(); // check if there's a builtin serializer for the value boolean builtinSerialization = JRValueStringUtils.hasSerializer(valueClass); if (!builtinSerialization) { // try XML handlers, if none works then default back to the builtin serialization builtinSerialization = !XmlValueHandlerUtils.instance().writeToXml(value, this); } if (builtinSerialization) { String data = JRValueStringUtils.serialize(valueClass, value); xmlWriter.startElement(JRXmlConstants.ELEMENT_genericElementParameterValue); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_class, valueClass); xmlWriter.writeCDATA(data); xmlWriter.closeElement(); // genericElementParameterValue } } xmlWriter.closeElement(); // genericElementParameter } xmlWriter.closeElement(); // genericElement } }
protected void exportHyperlinkParameter(JRPrintHyperlinkParameter parameter) throws IOException { xmlWriter.startElement(JRXmlConstants.ELEMENT_hyperlinkParameter); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, parameter.getName()); xmlWriter.addAttribute( JRXmlConstants.ATTRIBUTE_class, parameter.getValueClass(), DEFAULT_OBJECT_TYPE); if (parameter.getValue() != null) { String data = JRValueStringUtils.serialize(parameter.getValueClass(), parameter.getValue()); xmlWriter.writeCDATAElement(JRXmlConstants.ELEMENT_hyperlinkParameterValue, data); } xmlWriter.closeElement(); }