Examples of XmlWriter


Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

  }

  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();
    }

  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

  }


  private void writePageDefinition() throws IOException
  {
    final XmlWriter xmlWriter = getXmlWriter();
    final PageDefinition pageDefinition = getReport().getPageDefinition();
    if (pageDefinition instanceof SimplePageDefinition)
    {
      final SimplePageDefinition spdef = (SimplePageDefinition) pageDefinition;
      final AttributeList attr = new AttributeList();
      attr.setAttribute(ExtParserModule.NAMESPACE, "width",
          String.valueOf(spdef.getPageCountHorizontal()));
      attr.setAttribute(ExtParserModule.NAMESPACE, "height",
          String.valueOf(spdef.getPageCountVertical()));
      xmlWriter.writeTag(ExtParserModule.NAMESPACE,
          ReportConfigWriter.SIMPLE_PAGE_DEFINITION_TAG, attr, XmlWriterSupport.OPEN);

      final AttributeList attributes = buildPageFormatProperties(spdef.getPageFormat(0));
      xmlWriter.writeTag(ExtParserModule.NAMESPACE,
          ReportConfigWriter.PAGE_TAG, attributes, XmlWriterSupport.CLOSE);
      xmlWriter.writeCloseTag();
    }
    else
    {
      xmlWriter.writeTag(ExtParserModule.NAMESPACE,
          ReportConfigWriter.PAGE_DEFINITION_TAG, XmlWriterSupport.OPEN);

      final int max = pageDefinition.getPageCount();
      for (int i = 0; i < max; i++)
      {
        final PageFormat fmt = pageDefinition.getPageFormat(i);

        final AttributeList attributes = buildPageFormatProperties(fmt);
        xmlWriter.writeTag(ExtParserModule.NAMESPACE, ReportConfigWriter.PAGE_TAG,
            attributes, XmlWriterSupport.CLOSE);
      }
      xmlWriter.writeCloseTag();
    }
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

    ColorValueConverter colorValueConverter = new ColorValueConverter();
    CellBackgroundProducer cellBackgroundProducer = new CellBackgroundProducer(true, true);
    try
    {
      final XmlWriter writer = new XmlWriter(new OutputStreamWriter(System.out));
      writer.writeComment("Table Layout: ");
      writer.writeComment("Rows: " + sheetLayout.getRowCount());
      writer.writeComment("Columns: " + sheetLayout.getColumnCount());
      final int rows = sheetLayout.getRowCount();
      final int cols = sheetLayout.getColumnCount();
      writer.writeTag(null, "table", XmlWriter.OPEN);
      for (int row = 0; row < rows; row++)
      {
        writer.writeTag(null, "row", XmlWriter.OPEN);
        for (int col = 0; col < cols; col++)
        {
          final int sectionType = tableContentProducer.getSectionType(row, col);
          final CellBackground bg =
              cellBackgroundProducer.getBackgroundAt(logicalPage, sheetLayout, col, row, true, sectionType);
          if (bg == null)
          {
            writer.writeTag(null, "empty-cell", XmlWriter.CLOSE);
            continue;
          }

          if (bg.isOrigin() == false)
          {
            // A spanned cell ..
            writer.writeTag(null, "covered-cell", XmlWriter.CLOSE);
            continue;
          }

          final AttributeList attList = new AttributeList();
          final ReportAttributeMap attrs = bg.getAttributes();
          final Object nameAttr = attrs.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.NAME);
          if (nameAttr instanceof String)
          {
            attList.setAttribute(null, "content-idref",
                (String) nameAttr);
          }

          final String[] anchors = bg.getAnchors();
          if (anchors != null)
          {
            final StringBuffer anchor = new StringBuffer(100);
            for (int i = 0; i < anchors.length; i++)
            {
              if (i != 0)
              {
                anchor.append(", ");
              }
              anchor.append(anchors[i]);

            }
            attList.setAttribute(null, "anchor", anchor.toString());
          }
          if (bg.getBackgroundColor() != null)
          {
            attList.setAttribute(null, "background-color", ColorValueConverter.colorToString(bg.getBackgroundColor()));
          }

//          if (bg.getVerticalAlignment() != null)
//          {
//            attList.setAttribute(null, "vertical-alignment", String.valueOf(bg.getVerticalAlignment()));
//          }
//
          final BorderEdge top = bg.getTop();
          if (top != null)
          {
            attList.setAttribute(null, "border-top-color",
                ColorValueConverter.colorToString(top.getColor()));
            attList.setAttribute(null, "border-top-width",
                String.valueOf(StrictGeomUtility.toExternalValue(top.getWidth())));
            attList.setAttribute(null, "border-top-style",
                String.valueOf(top.getBorderStyle()));
          }

          final BorderEdge left = bg.getLeft();
          if (left != null)
          {
            attList.setAttribute(null, "border-left-color",
                ColorValueConverter.colorToString(left.getColor()));
            attList.setAttribute(null, "border-left-width",
                String.valueOf(StrictGeomUtility.toExternalValue(left.getWidth())));
            attList.setAttribute(null, "border-left-style",
                String.valueOf(left.getBorderStyle()));
          }

          final BorderEdge bottom = bg.getBottom();
          if (bottom != null)
          {
            attList.setAttribute(null, "border-bottom-color",
                ColorValueConverter.colorToString(bottom.getColor()));
            attList.setAttribute(null, "border-bottom-width",
                String.valueOf(StrictGeomUtility.toExternalValue(bottom.getWidth())));
            attList.setAttribute(null, "border-bottom-style",
                String.valueOf(bottom.getBorderStyle()));
          }

          final BorderEdge right = bg.getRight();
          if (right != null)
          {
            attList.setAttribute(null, "border-right-color",
                ColorValueConverter.colorToString(right.getColor()));
            attList.setAttribute(null, "border-right-width",
                String.valueOf(StrictGeomUtility.toExternalValue(right.getWidth())));
            attList.setAttribute(null, "border-right-style",
                String.valueOf(right.getBorderStyle()));
          }

          final BorderCorner topLeft = bg.getTopLeft();
          if (topLeft != null)
          {
            attList.setAttribute(null, "border-top-left-x",
                String.valueOf(StrictGeomUtility.toExternalValue(topLeft.getWidth())));
            attList.setAttribute(null, "border-top-left-y",
                String.valueOf(StrictGeomUtility.toExternalValue(topLeft.getHeight())));
          }


          final BorderCorner topRight = bg.getTopRight();
          if (topRight != null)
          {
            attList.setAttribute(null, "border-top-right-x",
                String.valueOf(StrictGeomUtility.toExternalValue(topRight.getWidth())));
            attList.setAttribute(null, "border-top-right-y",
                String.valueOf(StrictGeomUtility.toExternalValue(topRight.getHeight())));
          }


          final BorderCorner bottomLeft = bg.getBottomLeft();
          if (bottomLeft != null)
          {
            attList.setAttribute(null, "border-bottom-left-x",
                String.valueOf(StrictGeomUtility.toExternalValue(bottomLeft.getWidth())));
            attList.setAttribute(null, "border-bottom-left-y",
                String.valueOf(StrictGeomUtility.toExternalValue(bottomLeft.getHeight())));
          }


          final BorderCorner bottomRight = bg.getBottomRight();
          if (bottomRight != null)
          {
            attList.setAttribute(null, "border-bottom-right-x",
                String.valueOf(StrictGeomUtility.toExternalValue(bottomRight.getWidth())));
            attList.setAttribute(null, "border-bottom-right-y",
                String.valueOf(StrictGeomUtility.toExternalValue(bottomRight.getHeight())));
          }
          writer.writeTag(null, "cell", attList, XmlWriter.CLOSE);
        }
        writer.writeCloseTag();
      }
      writer.writeCloseTag();
      writer.flush();
    }
    catch (IOException ioe)
    {
      // Cannot happen ..
      throw new IllegalStateException("Failure while writing the debug-output");
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

      final DefaultTagDescription tags = new DefaultTagDescription();
      tags.setDefaultNamespace(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE);
      tags.addDefaultDefinition(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, false);
      tags.addTagDefinition(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "attribute", true);

      final XmlWriter w = new XmlWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"), tags);
      w.writeXmlDeclaration("UTF-8");

      final AttributeList rootList = new AttributeList();
      rootList.addNamespaceDeclaration("", DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE);
      w.writeTag(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "drilldown-profiles", rootList, XmlWriter.OPEN);

      final Object[] objects = drillDownProfiles.toArray();
      for (int i = 0; i < objects.length; i++)
      {
        final DrillDownProfile object = (DrillDownProfile) objects[i];

        final AttributeList profileAttrs = new AttributeList();
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "name", object.getName());
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "class", object.getLinkCustomizerType().getName());
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "bundle-name", object.getBundleLocation());
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "expert", String.valueOf(object.isExpert()));
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "hidden", String.valueOf(object.isHidden()));
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "deprecated", String.valueOf(object.isDeprecated()));
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "preferred", String.valueOf(object.isPreferred()));

        w.writeTag(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "drilldown-profile", profileAttrs, XmlWriter.OPEN);

        final String[] attrNames = object.getAttributes();
        for (int j = 0; j < attrNames.length; j++)
        {
          final String attrName = attrNames[j];
          final String attrValue = object.getAttribute(attrName);

          w.writeTag(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "attribute", "name", attrName, XmlWriter.OPEN);
          w.writeTextNormalized(attrValue, false);
          w.writeCloseTag();
        }

        w.writeCloseTag();
      }

      w.writeCloseTag();
      w.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

    final Class[] classes = eqt.getExpressions();

    final DefaultTagDescription dtd = new DefaultTagDescription();
    dtd.addDefaultDefinition(META_NAMESPACE, false);

    final XmlWriter writer = new XmlWriter(new PrintWriter(System.out), dtd);

    final AttributeList attrList = new AttributeList();
    attrList.addNamespaceDeclaration("", META_NAMESPACE);
    writer.writeTag(META_NAMESPACE, "meta-data", attrList, XmlWriter.OPEN);

    for (int i = 0; i < classes.length; i++)
    {
      final Class aClass = classes[i];

      if (OutputFunction.class.isAssignableFrom(aClass))
      {
        // Output functions will not be recognized.
        continue;
      }
      if (aClass.getName().indexOf('$') >= 0)
      {
        // Inner-Classes will not be recognized.
        continue;
      }

      final AttributeList expressionAttrList = new AttributeList();
      expressionAttrList.setAttribute(META_NAMESPACE, "class", aClass.getName());
      expressionAttrList.setAttribute(META_NAMESPACE, "bundle-name", "org.pentaho.reporting.engine.classic.core.metadata.messages");
      expressionAttrList.setAttribute(META_NAMESPACE, "result", "java.lang.Object");
      expressionAttrList.setAttribute(META_NAMESPACE, "expert", "false");
      expressionAttrList.setAttribute(META_NAMESPACE, "hidden", "false");
      expressionAttrList.setAttribute(META_NAMESPACE, "preferred", "false");
      writer.writeTag(META_NAMESPACE, "expression", expressionAttrList, XmlWriter.OPEN);

      final BeanInfo beanInfo = Introspector.getBeanInfo(aClass);
      final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
      for (int j = 0; j < descriptors.length; j++)
      {
        final PropertyDescriptor descriptor = descriptors[j];
        final String key = descriptor.getName();

        if ("runtime".equals(key))
        {
          continue;
        }
        if ("active".equals(key))
        {
          continue;
        }
        if ("preserve".equals(key))
        {
          continue;
        }

        if (descriptor.getReadMethod() == null || descriptor.getWriteMethod() == null)
        {
          continue;
        }

        final AttributeList propAttrList = new AttributeList();
        propAttrList.setAttribute(META_NAMESPACE, "name", descriptor.getName());
        if ("name".equals(key))
        {
          propAttrList.setAttribute(META_NAMESPACE, "mandatory", "true");
          propAttrList.setAttribute(META_NAMESPACE, "preferred", "true");
          propAttrList.setAttribute(META_NAMESPACE, "value-role", "Name");
          propAttrList.setAttribute(META_NAMESPACE, "expert", "false");
        }
        else
        {
          propAttrList.setAttribute(META_NAMESPACE, "mandatory", "false");
          propAttrList.setAttribute(META_NAMESPACE, "preferred", "false");
          propAttrList.setAttribute(META_NAMESPACE, "value-role", "Value");
          if ("dependencyLevel".equals(key))
          {
            propAttrList.setAttribute(META_NAMESPACE, "expert", "true");
          }
          else
          {
            propAttrList.setAttribute(META_NAMESPACE, "expert", "false");
          }
        }
        propAttrList.setAttribute(META_NAMESPACE, "hidden", "false");
        writer.writeTag(META_NAMESPACE, "property", propAttrList, XmlWriter.CLOSE);

      }

      writer.writeCloseTag();
    }

    writer.writeCloseTag();
    writer.flush();
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

      throw new IOException("Unable to generate unique name for the direct Static-Data-Source");
    }
    final OutputStream outputStream = bundle.createEntry(fileName, "text/xml");
    final DefaultTagDescription tagDescription = new DefaultTagDescription(
        ClassicEngineBoot.getInstance().getGlobalConfig(), StaticDataFactoryModule.TAG_DEF_PREFIX);
    final XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outputStream, "UTF-8"), tagDescription, "  ",
        "\n");
    xmlWriter.writeXmlDeclaration("UTF-8");

    final AttributeList rootAttrs = new AttributeList();
    rootAttrs.addNamespaceDeclaration("data", StaticDataFactoryModule.NAMESPACE);
    xmlWriter.writeTag(StaticDataFactoryModule.NAMESPACE, "direct-static-datasource", rootAttrs, XmlWriterSupport.OPEN);

    xmlWriter.writeCloseTag();
    xmlWriter.close();
    return fileName;
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

    }

    final OutputStream outputStream = bundle.createEntry(fileName, "text/xml");
    final DefaultTagDescription tagDescription = new DefaultTagDescription(
        ClassicEngineBoot.getInstance().getGlobalConfig(), StaticDataFactoryModule.TAG_DEF_PREFIX);
    final XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outputStream, "UTF-8"), tagDescription, "  ",
        "\n");
    xmlWriter.writeXmlDeclaration("UTF-8");

    final AttributeList rootAttrs = new AttributeList();
    rootAttrs.addNamespaceDeclaration("data", StaticDataFactoryModule.NAMESPACE);
    xmlWriter.writeTag(StaticDataFactoryModule.NAMESPACE, "static-datasource", rootAttrs, XmlWriterSupport.OPEN);

    final String[] queryNames = staticDataFactory.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final String query = staticDataFactory.getQuery(queryName);
      xmlWriter.writeTag(StaticDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();
    }
    xmlWriter.writeCloseTag();
    xmlWriter.close();
    return fileName;
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

    final OutputStream outputStream = new BufferedOutputStream(bundle.createEntry(contentFileState.getFileName(),
        "text/xml"));
    final Configuration globalConfig = ClassicEngineBoot.getInstance().getGlobalConfig();
    final DefaultTagDescription tagDescription = new DefaultTagDescription(globalConfig,
        BundleXmlModule.TAG_DEF_PREFIX);
    final XmlWriter writer = new XmlWriter
        (new OutputStreamWriter(outputStream, "UTF-8"), tagDescription, "  ", "\n");
    writer.writeXmlDeclaration("UTF-8");

    final AttributeList rootAttributes = new AttributeList();
    rootAttributes.addNamespaceDeclaration("", BundleNamespaces.CONTENT);

    writer.writeTag(BundleNamespaces.CONTENT, "content", rootAttributes, XmlWriterSupport.OPEN);

    writer.writeComment(" The content.xml file remains intentionally empty. This file can be used to ");
    writer.writeComment(" inject global templates later. ");

    writer.writeCloseTag();
    writer.close();
    return contentFileState.getFileName();


  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

    }

    final OutputStream outputStream = new BufferedOutputStream(bundle.createEntry("settings.xml", "text/xml"));
    final DefaultTagDescription tagDescription = new DefaultTagDescription(
        ClassicEngineBoot.getInstance().getGlobalConfig(), BundleXmlModule.TAG_DEF_PREFIX);
    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";
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

    final String encoding = metaData.getConfiguration().getConfigProperty
        ("org.pentaho.reporting.engine.classic.core.modules.output.pageable.xml.Encoding",
            EncodingRegistry.getPlatformDefaultEncoding());

    final Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream, encoding));
    this.xmlWriter = new XmlWriter(writer, td);
    this.xmlWriter.writeXmlDeclaration(null);
    final AttributeList attrs = new AttributeList();
    attrs.addNamespaceDeclaration("", XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE);
    xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "layout-output", attrs, XmlWriter.OPEN);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.