All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.doclets.html.HtmlGenerator Maven / Gradle / Ivy

package org.infinispan.doclets.html;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.List;

/**
 * Generates HTML documents
 *
 * @author Manik Surtani
 * @since 4.0
 */
public abstract class HtmlGenerator {
   String encoding, title, bottom, footer, header, metaDescription;
   List metaKeywords;

   public HtmlGenerator(String encoding, String title, String bottom, String footer, String header, String metaDescription, List metaKeywords) {
      this.encoding = encoding;
      this.title = title;
      this.footer = footer;
      this.header = header;
      this.bottom = bottom;
      this.metaDescription = metaDescription;
      this.metaKeywords = metaKeywords;
   }

   public void generateHtml(String fileName) throws IOException {
      generateHtml(fileName, "stylesheet.css");
   }

   public void generateHtml(String fileName, String styleSheetName) throws IOException {
      FileOutputStream fos = new FileOutputStream(fileName);
      OutputStreamWriter osw = isValid(encoding) ? new OutputStreamWriter(fos, encoding) : new OutputStreamWriter(fos);
      PrintWriter writer = new PrintWriter(osw);
      try {
         writer.println("");
         writer.println("");
         writer.println("");
         if (isValid(metaDescription))
            writer.println("");
         if (metaKeywords != null && !metaKeywords.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            sb.append("");
         }
         writer.println("");
         writer.println(title);
         writer.println("");
         writer.println("");

         writer.println("");
         writer.println("");

         if (isValid(header)) {
            writer.println(header);
            writer.println("
"); } writer.println(generateContents()); if (isValid(bottom)) { writer.println("
"); writer.println(bottom); } if (isValid(footer)) writer.println(footer); writer.println(""); writer.println(""); } finally { writer.close(); osw.close(); fos.close(); } } protected abstract String generateContents(); protected boolean isValid(String s) { return s != null && s.trim().length() != 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy