public void close() throws IOException { // close all .. xmlWriter.writeCloseTag(); xmlWriter.close(); }
protected void writeRuntimeInformation( final BundleWriterState state, final XmlWriter writer ) throws IOException { if ( state == null ) { throw new NullPointerException(); } if ( writer == null ) { throw new NullPointerException(); } writer.writeTag( BundleNamespaces.SETTINGS, "runtime", XmlWriterSupport.OPEN ); writer.writeCloseTag(); }
public void close() throws IOException { // close all .. xmlWriter.writeCloseTag(); xmlWriter.close(); }
private void finishBox() { try { xmlWriter.writeCloseTag(); } catch ( IOException e ) { throw new InvalidReportStateException( e.getMessage(), e ); } }
private void finishBox() { try { xmlWriter.writeCloseTag(); } catch ( IOException e ) { throw new InvalidReportStateException( e.getMessage(), e ); } }
private void writeReportConfig( final Configuration config ) throws IOException { final XmlWriter writer = getXmlWriter(); final Enumeration properties = config.getConfigProperties(); if ( properties.hasMoreElements() ) { writer.writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.CONFIGURATION_TAG, XmlWriterSupport.OPEN ); while ( properties.hasMoreElements() ) { final String key = (String) properties.nextElement(); final String value = config.getConfigProperty( key ); if ( value != null ) { writer.writeTag( ExtParserModule.NAMESPACE, "property", "name", key, XmlWriterSupport.OPEN ); writer.writeTextNormalized( value, false ); writer.writeCloseTag(); } } writer.writeCloseTag(); } }
public void finishBox( final InstanceID box, final ReportAttributeMap<Object> attributes ) { try { if ( processStack.isWrittenTag() ) { xmlWriter.writeCloseTag(); } processStack = processStack.getParent(); if ( firstElement != box ) { final Object rawFooterContent = attributes.getAttribute( AttributeNames.Html.NAMESPACE, AttributeNames.Html.EXTRA_RAW_FOOTER_CONTENT ); if ( rawFooterContent != null ) { xmlWriter.writeText( String.valueOf( rawFooterContent ) ); } } if ( processStack.isWrittenTag() ) { xmlWriter.writeCloseTag(); } processStack = processStack.getParent(); } catch ( IOException e ) { throw new HtmlOutputProcessingException( "Failed to perform IO", e ); } }
public String writeReport( final WriteableDocumentBundle bundle, final BundleWriterState state ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } final OutputStream outputStream = new BufferedOutputStream( bundle.createEntry( "settings.xml", "text/xml" ) ); final DefaultTagDescription tagDescription = BundleWriterHandlerRegistry.getInstance().createWriterTagDescription(); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); writer.writeXmlDeclaration( "UTF-8" ); final AttributeList rootAttributes = new AttributeList(); rootAttributes.addNamespaceDeclaration( "", BundleNamespaces.SETTINGS ); writer.writeTag( BundleNamespaces.SETTINGS, "settings", rootAttributes, XmlWriterSupport.OPEN ); writeConfiguration( state, writer ); writeRuntimeInformation( state, writer ); writer.writeCloseTag(); writer.close(); return "settings.xml"; }
public void writeExpressionParameter( final XmlWriter writer, final BeanUtility beanUtility, final String propertyName, final String namespaceUri ) throws IOException, BeanException { // filter some of the standard properties. These are system-properties // and are set elsewhere final Object property = beanUtility.getProperty( propertyName ); final Class propertyType = beanUtility.getPropertyType( propertyName ); final String value = beanUtility.getPropertyAsString( propertyName ); if ( value != null && property != null ) { final AttributeList attList = new AttributeList(); attList.setAttribute( namespaceUri, "name", propertyName ); if ( BeanUtility.isSameType( propertyType, property.getClass() ) == false ) { attList.setAttribute( namespaceUri, "class", property.getClass().getName() ); } writer.writeTag( namespaceUri, "property", attList, XmlWriterSupport.OPEN ); writer.writeTextNormalized( value, false ); writer.writeCloseTag(); } }
private void writeStyleInfo( final Element band ) throws IOException, ReportWriterException { final XmlWriter writer = getXmlWriter(); final ElementStyleSheet styleSheet = band.getStyle(); if ( isStyleSheetEmpty( styleSheet ) == false ) { writer.writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.STYLE_TAG, XmlWriterSupport.OPEN ); final StyleWriter styleWriter = new StyleWriter( getReportWriter(), band.getStyle(), writer ); styleWriter.write(); writer.writeCloseTag(); } final Map<StyleKey, Expression> styleExpressions = band.getStyleExpressions(); if ( styleExpressions.isEmpty() == false ) { final FunctionsWriter fnWriter = new FunctionsWriter( getReportWriter(), writer ); for ( final Map.Entry<StyleKey, Expression> entry : styleExpressions.entrySet() ) { final StyleKey key = entry.getKey(); final Expression ex = entry.getValue(); fnWriter.writeStyleExpression( ex, key ); } } }
private static void writeStyleRule( final XmlWriter writer, final ElementStyleRule styleRule ) throws IOException { if ( styleRule.getSelectorCount() == 0 && styleRule.getDefinedPropertyNamesArray().length == 0 ) { return; } writer.writeTag( BundleNamespaces.STYLE, "rule", XmlWriter.OPEN ); final NamespaceCollection collection = StyleSheetParserUtil.getInstance().getNamespaceCollection(); for ( int i = 0; i < styleRule.getSelectorCount(); i += 1 ) { writer.writeTag( BundleNamespaces.STYLE, "selector", XmlWriter.OPEN ); writer.writeTextNormalized( styleRule.getSelector( i ).print( collection ), false ); writer.writeCloseTag(); } StyleWriterUtility.writeStyleRule( BundleNamespaces.STYLE, "styles", writer, styleRule ); writer.writeCloseTag(); }
/** * Writes the functions to XML. * * @throws IOException * if there is an I/O problem. * @throws ReportWriterException * if the report function definition could not be written. */ public void write() throws IOException, ReportWriterException { if ( shouldWriteFunctions() ) { final XmlWriter writer = getXmlWriter(); writer.writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.FUNCTIONS_TAG, XmlWriterSupport.OPEN ); writeExpressions( getReport().getExpressions() ); writer.writeCloseTag(); } }
/** * Writes an element to a character stream writer. * * @param element * the element. * @throws IOException * if there is an I/O problem. * @throws ReportWriterException * if there is a problem writing the report. */ private void writeElement( final Element element ) throws IOException, ReportWriterException { final AttributeList attList = new AttributeList(); if ( element.getName().startsWith( Element.ANONYMOUS_ELEMENT_PREFIX ) == false ) { attList.setAttribute( ExtParserModule.NAMESPACE, "name", element.getName() ); } final XmlWriter writer = getXmlWriter(); writer.writeTag( ExtParserModule.NAMESPACE, ReportDescriptionWriter.ELEMENT_TAG, attList, XmlWriterSupport.OPEN ); writeStyleInfo( element ); writeDataSourceForElement( element ); writer.writeCloseTag(); }
public void write( final IDatabaseConnection[] connections, final OutputStream out ) throws IOException { DefaultTagDescription tagDescription = new DefaultTagDescription(); tagDescription.setDefaultNamespace( ConnectionModule.NAMESPACE ); tagDescription.setNamespaceHasCData( ConnectionModule.NAMESPACE, false ); tagDescription.setElementHasCData( ConnectionModule.NAMESPACE, "attribute", true ); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( out, "UTF-8" ), tagDescription ); writer.writeXmlDeclaration( "UTF-8" ); final AttributeList rootList = new AttributeList(); rootList.addNamespaceDeclaration( null, ConnectionModule.NAMESPACE ); writer.writeTag( ConnectionModule.NAMESPACE, "connections", rootList, XmlWriter.OPEN ); for ( int i = 0; i < connections.length; i++ ) { final IDatabaseConnection connection = connections[i]; write( connection, writer ); } writer.writeCloseTag(); writer.flush(); }
public static void writeStyleDefinition( final XmlWriter writer, final ElementStyleDefinition styleDefinition ) throws IOException { final int styleSheetCount = styleDefinition.getStyleSheetCount(); for ( int s = 0; s < styleSheetCount; s += 1 ) { final ElementStyleDefinition child = styleDefinition.getStyleSheet( s ); writer.writeTag( BundleNamespaces.STYLE, "style-definition", XmlWriter.OPEN ); writeStyleDefinition( writer, child ); writer.writeCloseTag(); } final int ruleCount = styleDefinition.getRuleCount(); for ( int r = 0; r < ruleCount; r += 1 ) { final ElementStyleSheet rule = styleDefinition.getRule( r ); if ( rule instanceof ElementStyleRule ) { final ElementStyleRule styleRule = (ElementStyleRule) rule; writeStyleRule( writer, styleRule ); } } }
private void writeImageTag( final StyleSheet styleSheet, final long width, final long height, final long contentWidth, final long contentHeight, AttributeList attrList ) throws IOException { final StyleBuilder imgStyle = produceImageStyle( styleSheet, width, height, contentWidth, contentHeight ); if ( imgStyle == null ) { final AttributeList clipAttrList = new AttributeList(); final StyleBuilder divStyle = produceClipStyle( width, height ); tagHelper.getStyleManager().updateStyle( divStyle, clipAttrList ); xmlWriter.writeTag( HtmlPrinter.XHTML_NAMESPACE, DIV_TAG, clipAttrList, XmlWriterSupport.OPEN ); xmlWriter.writeTag( HtmlPrinter.XHTML_NAMESPACE, IMG_TAG, attrList, XmlWriterSupport.CLOSE ); xmlWriter.writeCloseTag(); } else { tagHelper.getStyleManager().updateStyle( imgStyle, attrList ); xmlWriter.writeTag( HtmlPrinter.XHTML_NAMESPACE, IMG_TAG, attrList, XmlWriterSupport.CLOSE ); } }
/** * Writes the report configuration element. * * @throws java.io.IOException * if there is an I/O problem. */ public void write() throws IOException, ReportWriterException { final XmlWriter xmlWriter = getXmlWriter(); xmlWriter .writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.REPORT_CONFIG_TAG, XmlWriterSupport.OPEN ); final AbstractReportDefinition report = getReport(); if ( report instanceof MasterReport ) { final MasterReport masterReport = (MasterReport) report; final DataFactoryWriter writer = new DataFactoryWriter( getReportWriter(), getXmlWriter() ); writer.write(); writePageDefinition(); writeReportConfig( masterReport.getConfiguration() ); } xmlWriter.writeCloseTag(); }
public void processLogicalPage( final LogicalPageKey key, final LogicalPageBox logicalPage ) throws IOException { final float width = (float) StrictGeomUtility.toExternalValue( logicalPage.getPageWidth() ); final float height = (float) StrictGeomUtility.toExternalValue( logicalPage.getPageHeight() ); final AttributeList pageAttributes = new AttributeList(); pageAttributes.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "logical-page-number", pointIntConverter .format( key.getPosition() ) ); pageAttributes.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "width", pointConverter.format( width ) ); pageAttributes.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "height", pointConverter.format( height ) ); xmlWriter.writeTag( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "logical-page", pageAttributes, XmlWriter.OPEN ); // and now process the box .. drawArea = new StrictBounds( 0, 0, logicalPage.getPageWidth(), logicalPage.getPageHeight() ); processPage( logicalPage ); xmlWriter.writeCloseTag(); }
/** * Writes a report description element to a character stream writer. * * @throws IOException * if there is an I/O problem. * @throws ReportWriterException * if there is a problem writing the report. */ public void write() throws IOException, ReportWriterException { final XmlWriter writer = getXmlWriter(); writer.writeTag( ExtParserModule.NAMESPACE, ReportDescriptionWriter.REPORT_DESCRIPTION_TAG, XmlWriterSupport.OPEN ); writeRootBand( ReportDescriptionWriter.REPORT_HEADER_TAG, getReport().getReportHeader() ); writeRootBand( ReportDescriptionWriter.REPORT_FOOTER_TAG, getReport().getReportFooter() ); writeRootBand( ReportDescriptionWriter.PAGE_HEADER_TAG, getReport().getPageHeader() ); writeRootBand( ReportDescriptionWriter.PAGE_FOOTER_TAG, getReport().getPageFooter() ); writeRootBand( ReportDescriptionWriter.WATERMARK_TAG, getReport().getWatermark() ); writeGroups(); final GroupDataBody dataBody = (GroupDataBody) getReport().getChildElementByType( GroupDataBodyType.INSTANCE ); if ( dataBody != null ) { writeRootBand( ReportDescriptionWriter.ITEMBAND_TAG, dataBody.getItemBand() ); writeRootBand( ReportDescriptionWriter.NO_DATA_BAND_TAG, dataBody.getNoDataBand() ); } writer.writeCloseTag(); }
/** * Writes the XML. * * @throws java.io.IOException * if there is an I/O problem. */ public void write() throws IOException { final XmlWriter xmlWriter = getXmlWriter(); xmlWriter .writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.PARSER_CONFIG_TAG, XmlWriterSupport.OPEN ); writeFactory( ParserConfigWriter.OBJECT_FACTORY_TAG, filterFactories( getReportWriter().getClassFactoryCollector() .getFactories() ) ); writeFactory( ParserConfigWriter.ELEMENT_FACTORY_TAG, filterFactories( getReportWriter() .getElementFactoryCollector().getFactories() ) ); writeFactory( ParserConfigWriter.STYLEKEY_FACTORY_TAG, filterFactories( getReportWriter() .getStyleKeyFactoryCollector().getFactories() ) ); writeFactory( ParserConfigWriter.TEMPLATE_FACTORY_TAG, filterFactories( getReportWriter().getTemplateCollector() .getFactories() ) ); writeFactory( ParserConfigWriter.DATASOURCE_FACTORY_TAG, filterFactories( getReportWriter() .getDataSourceCollector().getFactories() ) ); xmlWriter.writeCloseTag(); }