Package org.osgi.service.indexer.impl.util

Examples of org.osgi.service.indexer.impl.util.Indent


  public void index(Set<File> files, OutputStream out, Map<String, String> config) throws Exception {
    if (config == null)
      config = new HashMap<String, String>(0);
   
    Indent indent;
    PrintWriter pw;
    if (config.get(ResourceIndexer.PRETTY) != null) {
      indent = Indent.PRETTY;
      pw = new PrintWriter(out);
    } else {
      indent = Indent.NONE;
      pw = new PrintWriter(new GZIPOutputStream(out, Deflater.BEST_COMPRESSION));
    }
   
    pw.print(Schema.XML_PROCESSING_INSTRUCTION);
    Tag repoTag = new Tag(Schema.ELEM_REPOSITORY);
   
    String repoName = config.get(REPOSITORY_NAME);
    if (repoName == null)
      repoName = REPOSITORYNAME_DEFAULT;
    repoTag.addAttribute(Schema.ATTR_NAME, repoName);
   
    String increment = config.get(REPOSITORY_INCREMENT_OVERRIDE);
    if (increment == null)
      increment = Long.toString(System.currentTimeMillis());
    repoTag.addAttribute(Schema.ATTR_INCREMENT, increment);
   
    repoTag.addAttribute(Schema.ATTR_XML_NAMESPACE, Schema.NAMESPACE);
   
    repoTag.printOpen(indent, pw, false);
    for (File file : files) {
      Tag resourceTag = generateResource(file, config);
      resourceTag.print(indent.next(), pw);
    }
    repoTag.printClose(indent, pw);
    pw.flush(); pw.close();
  }
View Full Code Here


  public void index(Set<File> files, OutputStream out, Map<String, String> config) throws Exception {
    if (config == null)
      config = new HashMap<String, String>(0);
   
    Indent indent;
    PrintWriter pw;
    if (config.get(ResourceIndexer.PRETTY) != null) {
      indent = Indent.PRETTY;
      pw = new PrintWriter(out);
    } else {
      indent = Indent.NONE;
      pw = new PrintWriter(new GZIPOutputStream(out, Deflater.BEST_COMPRESSION));
    }
   
    pw.print(Schema.XML_PROCESSING_INSTRUCTION);
    Tag repoTag = new Tag(Schema.ELEM_REPOSITORY);
   
    String repoName = config.get(REPOSITORY_NAME);
    if (repoName == null)
      repoName = REPOSITORYNAME_DEFAULT;
    repoTag.addAttribute(Schema.ATTR_NAME, repoName);
   
    String increment = config.get(REPOSITORY_INCREMENT_OVERRIDE);
    if (increment == null)
      increment = Long.toString(System.currentTimeMillis());
    repoTag.addAttribute(Schema.ATTR_INCREMENT, increment);
   
    repoTag.addAttribute(Schema.ATTR_XML_NAMESPACE, Schema.NAMESPACE);
   
    repoTag.printOpen(indent, pw, false);
    for (File file : files) {
      Tag resourceTag = generateResource(file, config);
      resourceTag.print(indent.next(), pw);
    }
    repoTag.printClose(indent, pw);
    pw.flush(); pw.close();
  }
View Full Code Here

  public void index(Set<File> files, OutputStream out, Map<String, String> config) throws Exception {
    if (config == null)
      config = new HashMap<String, String>(0);
   
    Indent indent;
    PrintWriter pw;
    if (config.get(ResourceIndexer.PRETTY) != null) {
      indent = Indent.PRETTY;
      pw = new PrintWriter(out);
    } else {
      indent = Indent.NONE;
      pw = new PrintWriter(new GZIPOutputStream(out, Deflater.BEST_COMPRESSION));
    }
   
    pw.print(Schema.XML_PROCESSING_INSTRUCTION);
    Tag repoTag = new Tag(Schema.ELEM_REPOSITORY);
   
    String repoName = config.get(REPOSITORY_NAME);
    if (repoName == null)
      repoName = REPOSITORYNAME_DEFAULT;
    repoTag.addAttribute(Schema.ATTR_NAME, repoName);
   
    String increment = config.get(REPOSITORY_INCREMENT_OVERRIDE);
    if (increment == null)
      increment = Long.toString(System.currentTimeMillis());
    repoTag.addAttribute(Schema.ATTR_INCREMENT, increment);
   
    repoTag.addAttribute(Schema.ATTR_XML_NAMESPACE, Schema.NAMESPACE);
   
    repoTag.printOpen(indent, pw, false);
    for (File file : files) {
      Tag resourceTag = generateResource(file, config);
      resourceTag.print(indent.next(), pw);
    }
    repoTag.printClose(indent, pw);
    pw.flush(); pw.close();
  }
View Full Code Here

  public void index(Set<File> files, OutputStream out, Map<String, String> config) throws Exception {
    if (config == null)
      config = new HashMap<String, String>(0);
   
    Indent indent;
    PrintWriter pw;
    if (config.get(ResourceIndexer.PRETTY) != null) {
      indent = Indent.PRETTY;
      pw = new PrintWriter(out);
    } else {
      indent = Indent.NONE;
      pw = new PrintWriter(new GZIPOutputStream(out, Deflater.BEST_COMPRESSION));
    }
   
    pw.print(Schema.XML_PROCESSING_INSTRUCTION);
    Tag repoTag = new Tag(Schema.ELEM_REPOSITORY);
   
    String repoName = config.get(REPOSITORY_NAME);
    if (repoName == null)
      repoName = REPOSITORYNAME_DEFAULT;
    repoTag.addAttribute(Schema.ATTR_NAME, repoName);
   
    String increment = config.get(REPOSITORY_INCREMENT_OVERRIDE);
    if (increment == null)
      increment = Long.toString(System.currentTimeMillis());
    repoTag.addAttribute(Schema.ATTR_INCREMENT, increment);
   
    repoTag.addAttribute(Schema.ATTR_XML_NAMESPACE, Schema.NAMESPACE);
   
    repoTag.printOpen(indent, pw, false);
    for (File file : files) {
      Tag resourceTag = generateResource(file, config);
      resourceTag.print(indent.next(), pw);
    }
    repoTag.printClose(indent, pw);
    pw.flush(); pw.close();
  }
View Full Code Here

    Set<File> filesToIndex = new TreeSet<File>();
    if (files != null && !files.isEmpty()) {
      resolveDirectories(files, filesToIndex);
    }

    Indent indent;
    PrintWriter pw = null;
    try {
      String prettySetting = config.get(ResourceIndexer.PRETTY);
      String compressedSetting = config.get(ResourceIndexer.COMPRESSED);
      /**
       * <pre>
       * pretty   compressed         out-pretty     out-compressed
       *   null         null        Indent.NONE               true*
       *   null        false        Indent.NONE              false
       *   null         true        Indent.NONE               true
       *  false         null      Indent.PRETTY              false*
       *  false        false        Indent.NONE              false
       *  false         true        Indent.NONE               true
       *   true         null      Indent.PRETTY              false*
       *   true        false      Indent.PRETTY              false
       *   true         true      Indent.PRETTY               true
       *  
       *   * = original behaviour, before compressed was introduced
       * </pre>
       */
      indent = (prettySetting == null || (!Boolean.parseBoolean(prettySetting) && compressedSetting != null)) ? Indent.NONE : Indent.PRETTY;
      boolean compressed = (prettySetting == null && compressedSetting == null) || Boolean.parseBoolean(compressedSetting);
      if (!compressed) {
        pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
      } else {
        pw = new PrintWriter(new GZIPOutputStream(out, Deflater.BEST_COMPRESSION));
      }

      pw.print(Schema.XML_PROCESSING_INSTRUCTION);
      Tag repoTag = new Tag(Schema.ELEM_REPOSITORY);

      String repoName = config.get(REPOSITORY_NAME);
      if (repoName == null)
        repoName = REPOSITORYNAME_DEFAULT;
      repoTag.addAttribute(Schema.ATTR_NAME, repoName);

      String increment = config.get(REPOSITORY_INCREMENT_OVERRIDE);
      if (increment == null)
        increment = Long.toString(System.currentTimeMillis());
      repoTag.addAttribute(Schema.ATTR_INCREMENT, increment);

      repoTag.addAttribute(Schema.ATTR_XML_NAMESPACE, Schema.NAMESPACE);

      repoTag.printOpen(indent, pw, false);
      for (File file : filesToIndex) {
        try {
          Tag resourceTag = generateResource(file, config);
          resourceTag.print(indent.next(), pw);
        } catch (Exception e) {
          log(LogService.LOG_WARNING, MessageFormat.format("Could not index {0}, skipped ({1}).", file, e.getMessage()), null);
        }
      }
      repoTag.printClose(indent, pw);
View Full Code Here

   */
  public void index(Set<File> files, OutputStream out, Map<String, String> config) throws Exception {
    if (config == null)
      config = new HashMap<String, String>(0);

    Indent indent;
    PrintWriter pw;
    if (config.get(ResourceIndexer.PRETTY) != null) {
      indent = Indent.PRETTY;
      pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
    } else {
      indent = Indent.NONE;
      pw = new PrintWriter(new GZIPOutputStream(out, Deflater.BEST_COMPRESSION));
    }

    pw.print(Schema.XML_PROCESSING_INSTRUCTION);
    Tag repoTag = new Tag(Schema.ELEM_REPOSITORY);

    String repoName = config.get(REPOSITORY_NAME);
    if (repoName == null)
      repoName = REPOSITORYNAME_DEFAULT;
    repoTag.addAttribute(Schema.ATTR_NAME, repoName);

    String increment = config.get(REPOSITORY_INCREMENT_OVERRIDE);
    if (increment == null)
      increment = Long.toString(System.currentTimeMillis());
    repoTag.addAttribute(Schema.ATTR_INCREMENT, increment);

    repoTag.addAttribute(Schema.ATTR_XML_NAMESPACE, Schema.NAMESPACE);

    repoTag.printOpen(indent, pw, false);
    for (File file : files) {
      Tag resourceTag = generateResource(file, config);
      resourceTag.print(indent.next(), pw);
    }
    repoTag.printClose(indent, pw);
    pw.flush();
    pw.close();
  }
View Full Code Here

TOP

Related Classes of org.osgi.service.indexer.impl.util.Indent

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.