Package org.pentaho.reporting.libraries.xmlns.writer

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


    dwriter.writeXmlDeclaration(encoding);
    dwriter.writeTag(ConfigEditorBoot.NAMESPACE,
        "config-description", attList, XmlWriterSupport.OPEN); //$NON-NLS-1$

    final CharacterEntityParser parser = CharacterEntityParser.createXMLEntityParser();
    for (int i = 0; i < getSize(); i++)
    {
      final ConfigDescriptionEntry entry = get(i);
      final AttributeList p = new AttributeList();
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "name", entry.getKeyName()); //$NON-NLS-1$
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "global", String.valueOf(entry.isGlobal())); //$NON-NLS-1$
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "hidden", String.valueOf(entry.isHidden())); //$NON-NLS-1$
      dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "key", p, XmlWriterSupport.OPEN); //$NON-NLS-1$
      if (entry.getDescription() != null)
      {
        dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "description", XmlWriterSupport.OPEN); //$NON-NLS-1$
        writer.write(parser.encodeEntities(entry.getDescription()));
        dwriter.writeCloseTag();
      }
      if (entry instanceof ClassConfigDescriptionEntry)
      {
        final ClassConfigDescriptionEntry ce = (ClassConfigDescriptionEntry) entry;
View Full Code Here


   */
  public static synchronized CharacterEntityParser getEntityParser()
  {
    if (entityParser == null)
    {
      entityParser = new CharacterEntityParser(new HtmlCharacterEntities());
    }
    return entityParser;
  }
View Full Code Here

    if (text.length() == 0)
    {
      return;
    }

    final CharacterEntityParser entityParser = HtmlCharacterEntities.getEntityParser();
    final BreakIterator instance = BreakIterator.getLineInstance();
    instance.setText(text);

    int start = instance.first();
    int end = instance.next();

    boolean flagStart = true;
    while (end != BreakIterator.DONE)
    {
      final String readLine = text.substring(start, end);
      start = end;
      end = instance.next();

      if (flagStart == true)
      {
        flagStart = false;
      }
      else
      {
        if (useXHTML)
        {
          pout.println("<br />");
        }
        else
        {
          pout.println("<br>");
        }
      }

      // for now, convert all leading white spaces (mostly tab and space
      // characters) to non-break-spaces.
      int whitespaceCounter = 0;
      while ((whitespaceCounter < readLine.length()) &&
          Character.isWhitespace(readLine.charAt(whitespaceCounter)))
      {
        pout.print("&nbsp;");
        whitespaceCounter += 1;
      }

      final String printResult;
      if (whitespaceCounter > 0)
      {
        printResult = readLine.substring(whitespaceCounter);
      }
      else
      {
        printResult = readLine;
      }

      pout.print(entityParser.encodeEntities(printResult));
    }

  }
View Full Code Here

  public void testEncode () throws Exception
  {
    final String testNative = "Test is a \u00e4\u00f6\u00fc<&> && test";
    final String testEncoded = "Test is a &auml;&ouml;&uuml;&lt;&amp;&gt; &amp;&amp; test";
    final CharacterEntityParser ep = new CharacterEntityParser (new HtmlCharacterEntities());
    //Log.debug (ep.decodeEntities(testEncoded));
    assertEquals(testNative, ep.decodeEntities(testEncoded));
    assertEquals(testEncoded, ep.encodeEntities(testNative));
  }
View Full Code Here

  }

  @SuppressWarnings({"HardcodedLineSeparator"})
  private String getSystemInformationAsHTML()
  {
    final CharacterEntityParser cep = HtmlCharacterEntities.getEntityParser();
    final StringBuilder sb = new StringBuilder(10000);
    sb.append("<html><body>\n");//NON-NLS

    sb.append("<h1>");//NON-NLS
    sb.append(cep.encodeEntities(UtilMessages.getInstance().getString("SystemInformationDialog.SystemProperties.Title")));
    sb.append("</h1>");//NON-NLS
    formatMap(cep, sb, new TreeMap(System.getProperties()));
    sb.append("<br>");//NON-NLS

    //environment
    sb.append("<h1>");//NON-NLS
    sb.append(cep.encodeEntities(UtilMessages.getInstance().getString("SystemInformationDialog.Environment.Title")));
    sb.append("</h1>");//NON-NLS
    formatMap(cep, sb, new TreeMap<String, String>(System.getenv()));
    sb.append("<br>");//NON-NLS

    //other
    sb.append("<h1>");//NON-NLS
    sb.append(cep.encodeEntities(UtilMessages.getInstance().getString("SystemInformationDialog.Other.Title")));
    sb.append("</h1>");//NON-NLS
    formatMap(cep, sb, SystemInformation.getOtherProperties());


    sb.append("</body></html>\n");//NON-NLS
View Full Code Here

  }

  @SuppressWarnings({"HardcodedLineSeparator"})
  private String getSystemInformationAsText()
  {
    final CharacterEntityParser cep = HtmlCharacterEntities.getEntityParser();
    final StringBuilder sb = new StringBuilder(10000);

    final String sysPropTitle = UtilMessages.getInstance().getString("SystemInformationDialog.SystemProperties.Title");
    sb.append(sysPropTitle);
    sb.append("\n");//NON-NLS
View Full Code Here

    dwriter.writeXmlDeclaration(encoding);
    dwriter.writeTag(ConfigEditorBoot.NAMESPACE,
        "config-description", attList, XmlWriterSupport.OPEN); //$NON-NLS-1$

    final CharacterEntityParser parser = CharacterEntityParser.createXMLEntityParser();
    for (int i = 0; i < getSize(); i++)
    {
      final ConfigDescriptionEntry entry = get(i);
      final AttributeList p = new AttributeList();
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "name", entry.getKeyName()); //$NON-NLS-1$
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "global", String.valueOf(entry.isGlobal())); //$NON-NLS-1$
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "hidden", String.valueOf(entry.isHidden())); //$NON-NLS-1$
      dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "key", p, XmlWriterSupport.OPEN); //$NON-NLS-1$
      if (entry.getDescription() != null)
      {
        dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "description", XmlWriterSupport.OPEN); //$NON-NLS-1$
        writer.write(parser.encodeEntities(entry.getDescription()));
        dwriter.writeCloseTag();
      }
      if (entry instanceof ClassConfigDescriptionEntry)
      {
        final ClassConfigDescriptionEntry ce = (ClassConfigDescriptionEntry) entry;
View Full Code Here

   */
  public static synchronized CharacterEntityParser getEntityParser()
  {
    if (entityParser == null)
    {
      entityParser = new CharacterEntityParser(new HtmlCharacterEntities());
    }
    return entityParser;
  }
View Full Code Here


  @SuppressWarnings({"HardcodedLineSeparator"})
  private String getSystemInformationAsHTML()
  {
    final CharacterEntityParser cep = HtmlCharacterEntities.getEntityParser();
    final StringBuilder sb = new StringBuilder(10000);
    sb.append("<html><body>\n");//NON-NLS

    sb.append("<h1>");//NON-NLS
    sb.append(cep.encodeEntities(UtilMessages.getInstance().getString("SystemInformationDialog.SystemProperties.Title")));
    sb.append("</h1>");//NON-NLS
    sb.append("<table>\n");//NON-NLS
    final Map properties = new TreeMap(System.getProperties());
    final Set<Object> enumeration = properties.keySet();
    for (final Object key : enumeration)
    {
      String value = (String) properties.get(key.toString());
      if (value != null)
      {
        value = cep.encodeEntities(value);
        value = value.replace("\n", "\\n");//NON-NLS
        value = value.replace("\f", "\\f");//NON-NLS
        value = value.replace("\r", "\\r");//NON-NLS
        if (value.length() > 80)
        {
          value = value.replace(File.pathSeparator, File.pathSeparator + "<br>\n");//NON-NLS
        }
      }
      sb.append("<tr valign=\"top\"><td>");//NON-NLS
      sb.append(cep.encodeEntities(key.toString()));
      sb.append("</td><td>");//NON-NLS
      sb.append(value);
      sb.append("</td></tr>\n");//NON-NLS
    }
    sb.append("</table>");//NON-NLS


    sb.append("<br>");//NON-NLS

    //environment
    sb.append("<h1>");//NON-NLS
    sb.append(cep.encodeEntities(UtilMessages.getInstance().getString("SystemInformationDialog.Environment.Title")));
    sb.append("</h1>");//NON-NLS
    sb.append("<table>\n");//NON-NLS
    final Map<String, String> environmentMap = new TreeMap<String, String>(System.getenv());
    for (final String key : environmentMap.keySet())
    {
      String value = environmentMap.get(key);
      if (value != null)
      {
        value = cep.encodeEntities(value);
        value = value.replace("\n", "\\n");//NON-NLS
        value = value.replace("\f", "\\f");//NON-NLS
        value = value.replace("\r", "\\r");//NON-NLS
        if (value.length() > 80)
        {
          value = value.replace(File.pathSeparator, File.pathSeparator + "<br>\n");//NON-NLS
        }
      }
      sb.append("<tr valign=\"top\"><td>");//NON-NLS
      sb.append(cep.encodeEntities(key));
      sb.append("</td><td>");//NON-NLS
      sb.append(value);
      sb.append("</td></tr>\n");//NON-NLS
    }

    sb.append("</table>");//NON-NLS


    sb.append("<br>");//NON-NLS

    //other
    sb.append("<h1>");//NON-NLS
    sb.append(cep.encodeEntities(UtilMessages.getInstance().getString("SystemInformationDialog.Other.Title")));
    sb.append("</h1>");//NON-NLS
    sb.append("<table>\n");//NON-NLS

    final Map<String, String> otherProperties = getOtherProperties();
    for (final String key : otherProperties.keySet())
    {
      String value = otherProperties.get(key);
      if (value != null)
      {
        value = cep.encodeEntities(value);
        value = value.replace("\n", "\\n");//NON-NLS
        value = value.replace("\f", "\\f");//NON-NLS
        value = value.replace("\r", "\\r");//NON-NLS
        if (value.length() > 80)
        {
          value = value.replace(File.pathSeparator, File.pathSeparator + "<br>\n");//NON-NLS
        }
      }
      sb.append("<tr valign=\"top\"><td>");//NON-NLS
      sb.append(cep.encodeEntities(key));
      sb.append("</td><td>");//NON-NLS
      sb.append(value).append("</td></tr>\n");//NON-NLS
    }

    sb.append("</table>");//NON-NLS
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.xmlns.writer.CharacterEntityParser

Copyright © 2018 www.massapicom. 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.