From dab5d770df592db3fa279b0531783628baf00ba1 Mon Sep 17 00:00:00 2001 From: Laszlo Attila Toth Date: Mon, 28 Feb 2022 10:27:57 +0100 Subject: [PATCH] TEZ-4387: reformat code before touching it --- .../javadoc/doclet/ConfigStandardDoclet.java | 329 +++++++++--------- .../tez/tools/javadoc/model/Config.java | 23 +- .../tools/javadoc/model/ConfigProperty.java | 44 ++- .../tez/tools/javadoc/util/HtmlWriter.java | 244 +++++++------ .../apache/tez/tools/javadoc/util/Writer.java | 22 +- .../tez/tools/javadoc/util/XmlWriter.java | 122 +++---- 6 files changed, 378 insertions(+), 406 deletions(-) diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java index 6cc9ced865..1c2bd1a24d 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java @@ -18,10 +18,9 @@ package org.apache.tez.tools.javadoc.doclet; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - +import com.sun.javadoc.*; +import com.sun.javadoc.AnnotationDesc.ElementValuePair; +import com.sun.tools.doclets.standard.Standard; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.classification.InterfaceStability.Unstable; @@ -32,202 +31,194 @@ import org.apache.tez.tools.javadoc.util.HtmlWriter; import org.apache.tez.tools.javadoc.util.XmlWriter; -import com.sun.javadoc.AnnotationDesc; -import com.sun.javadoc.AnnotationDesc.ElementValuePair; -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.DocErrorReporter; -import com.sun.javadoc.FieldDoc; -import com.sun.javadoc.LanguageVersion; -import com.sun.javadoc.RootDoc; -import com.sun.tools.doclets.standard.Standard; +import java.io.IOException; +import java.util.Map; public class ConfigStandardDoclet { - private static final String DEBUG_SWITCH = "-debug"; - private static boolean debugMode = false; + private static final String DEBUG_SWITCH = "-debug"; + private static boolean debugMode = false; - public static LanguageVersion languageVersion() { - return LanguageVersion.JAVA_1_5; - } - - private static void logMessage(String message) { - if (!debugMode) { - return; - } - System.out.println(message); - } - - public static boolean start(RootDoc root) { - //look for debug flag - for (String[] opts : root.options()) { - for (String opt : opts) { - if (opt.equals(DEBUG_SWITCH)) { - debugMode = true; - } - } + public static LanguageVersion languageVersion() { + return LanguageVersion.JAVA_1_5; } - logMessage("Running doclet " + ConfigStandardDoclet.class.getSimpleName()); - ClassDoc[] classes = root.classes(); - for (int i = 0; i < classes.length; ++i) { - processDoc(classes[i]); + private static void logMessage(String message) { + if (!debugMode) { + return; + } + System.out.println(message); } - return true; - } - - private static void processDoc(ClassDoc doc) { - logMessage("Parsing : " + doc); - if (!doc.isClass()) { - logMessage("Ignoring non-class: " + doc); - return; - } + public static boolean start(RootDoc root) { + //look for debug flag + for (String[] opts : root.options()) { + for (String opt : opts) { + if (opt.equals(DEBUG_SWITCH)) { + debugMode = true; + } + } + } - AnnotationDesc[] annotations = doc.annotations(); - boolean isConfigClass = false; - String templateName = null; - for (AnnotationDesc annotation : annotations) { - logMessage("Checking annotation: " + annotation.annotationType()); - if (annotation.annotationType().qualifiedTypeName().equals( - ConfigurationClass.class.getName())) { - isConfigClass = true; - for (ElementValuePair element : annotation.elementValues()) { - if (element.element().name().equals("templateFileName")) { - templateName = stripQuotes(element.value().toString()); - } + logMessage("Running doclet " + ConfigStandardDoclet.class.getSimpleName()); + ClassDoc[] classes = root.classes(); + for (int i = 0; i < classes.length; ++i) { + processDoc(classes[i]); } - break; - } - } - if (!isConfigClass) { - logMessage("Ignoring non-config class: " + doc); - return; + return true; } - logMessage("Processing config class: " + doc); - Config config = new Config(doc.name(), templateName); - Map configProperties = config.configProperties; - - FieldDoc[] fields = doc.fields(); - for (FieldDoc field : fields) { - if (field.isPrivate()) { - logMessage("Skipping private field: " + field); - continue; - } - if (!field.isStatic()) { - logMessage("Skipping non-static field: " + field); - continue; - } - - if (field.name().endsWith("_PREFIX")) { - logMessage("Skipping non-config prefix constant field: " + field); - continue; - } - if (field.name().equals("TEZ_SITE_XML")) { - logMessage("Skipping constant field: " + field); - continue; - } - - if (field.name().endsWith("_DEFAULT")) { - - String name = field.name().substring(0, - field.name().lastIndexOf("_DEFAULT")); - if (!configProperties.containsKey(name)) { - configProperties.put(name, new ConfigProperty()); + private static void processDoc(ClassDoc doc) { + logMessage("Parsing : " + doc); + if (!doc.isClass()) { + logMessage("Ignoring non-class: " + doc); + return; } - ConfigProperty configProperty = configProperties.get(name); - if (field.constantValue() == null) { - logMessage("Got null constant value" - + ", name=" + name - + ", field=" + field.name() - + ", val=" + field.constantValueExpression()); - configProperty.defaultValue = field.constantValueExpression(); - } else { - configProperty.defaultValue = field.constantValue().toString(); + + AnnotationDesc[] annotations = doc.annotations(); + boolean isConfigClass = false; + String templateName = null; + for (AnnotationDesc annotation : annotations) { + logMessage("Checking annotation: " + annotation.annotationType()); + if (annotation.annotationType().qualifiedTypeName().equals( + ConfigurationClass.class.getName())) { + isConfigClass = true; + for (ElementValuePair element : annotation.elementValues()) { + if (element.element().name().equals("templateFileName")) { + templateName = stripQuotes(element.value().toString()); + } + } + break; + } } - configProperty.inferredType = field.type().simpleTypeName(); - if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.defaultValue != null) { - String defaultValue = configProperty.defaultValue; - defaultValue = defaultValue.replace(System.getProperty("user.name"), "${user.name}"); - configProperty.defaultValue = defaultValue; + if (!isConfigClass) { + logMessage("Ignoring non-config class: " + doc); + return; } - continue; - } + logMessage("Processing config class: " + doc); + Config config = new Config(doc.name(), templateName); + Map configProperties = config.configProperties; - String name = field.name(); - if (!configProperties.containsKey(name)) { - configProperties.put(name, new ConfigProperty()); - } - ConfigProperty configProperty = configProperties.get(name); - configProperty.propertyName = field.constantValue().toString(); + FieldDoc[] fields = doc.fields(); + for (FieldDoc field : fields) { + if (field.isPrivate()) { + logMessage("Skipping private field: " + field); + continue; + } + if (!field.isStatic()) { + logMessage("Skipping non-static field: " + field); + continue; + } - AnnotationDesc[] annotationDescs = field.annotations(); + if (field.name().endsWith("_PREFIX")) { + logMessage("Skipping non-config prefix constant field: " + field); + continue; + } + if (field.name().equals("TEZ_SITE_XML")) { + logMessage("Skipping constant field: " + field); + continue; + } - for (AnnotationDesc annotationDesc : annotationDescs) { + if (field.name().endsWith("_DEFAULT")) { + + String name = field.name().substring(0, + field.name().lastIndexOf("_DEFAULT")); + if (!configProperties.containsKey(name)) { + configProperties.put(name, new ConfigProperty()); + } + ConfigProperty configProperty = configProperties.get(name); + if (field.constantValue() == null) { + logMessage("Got null constant value" + + ", name=" + name + + ", field=" + field.name() + + ", val=" + field.constantValueExpression()); + configProperty.defaultValue = field.constantValueExpression(); + } else { + configProperty.defaultValue = field.constantValue().toString(); + } + configProperty.inferredType = field.type().simpleTypeName(); + + if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.defaultValue != null) { + String defaultValue = configProperty.defaultValue; + defaultValue = defaultValue.replace(System.getProperty("user.name"), "${user.name}"); + configProperty.defaultValue = defaultValue; + } + + continue; + } - if (annotationDesc.annotationType().qualifiedTypeName().equals( - Private.class.getCanonicalName())) { - configProperty.isPrivate = true; - } - if (annotationDesc.annotationType().qualifiedTypeName().equals( - Unstable.class.getCanonicalName())) { - configProperty.isUnstable = true; - } - if (annotationDesc.annotationType().qualifiedTypeName().equals( - Evolving.class.getCanonicalName())) { - configProperty.isEvolving = true; - } - if (annotationDesc.annotationType().qualifiedTypeName().equals( - ConfigurationProperty.class.getCanonicalName())) { - configProperty.isValidConfigProp = true; - - boolean foundType = false; - for (ElementValuePair element : annotationDesc.elementValues()) { - if (element.element().name().equals("type")) { - configProperty.type = stripQuotes(element.value().toString()); - foundType = true; - } else { - logMessage("Unhandled annotation property: " + element.element().name()); + String name = field.name(); + if (!configProperties.containsKey(name)) { + configProperties.put(name, new ConfigProperty()); + } + ConfigProperty configProperty = configProperties.get(name); + configProperty.propertyName = field.constantValue().toString(); + + AnnotationDesc[] annotationDescs = field.annotations(); + + for (AnnotationDesc annotationDesc : annotationDescs) { + + if (annotationDesc.annotationType().qualifiedTypeName().equals( + Private.class.getCanonicalName())) { + configProperty.isPrivate = true; + } + if (annotationDesc.annotationType().qualifiedTypeName().equals( + Unstable.class.getCanonicalName())) { + configProperty.isUnstable = true; + } + if (annotationDesc.annotationType().qualifiedTypeName().equals( + Evolving.class.getCanonicalName())) { + configProperty.isEvolving = true; + } + if (annotationDesc.annotationType().qualifiedTypeName().equals( + ConfigurationProperty.class.getCanonicalName())) { + configProperty.isValidConfigProp = true; + + boolean foundType = false; + for (ElementValuePair element : annotationDesc.elementValues()) { + if (element.element().name().equals("type")) { + configProperty.type = stripQuotes(element.value().toString()); + foundType = true; + } else { + logMessage("Unhandled annotation property: " + element.element().name()); + } + } + } } - } + + configProperty.description = field.commentText(); } - } - configProperty.description = field.commentText(); + HtmlWriter writer = new HtmlWriter(); + try { + writer.write(config); + } catch (IOException e) { + throw new RuntimeException(e); + } + XmlWriter xmlWriter = new XmlWriter(); + try { + xmlWriter.write(config); + } catch (IOException e) { + throw new RuntimeException(e); + } } - HtmlWriter writer = new HtmlWriter(); - try { - writer.write(config); - } catch (IOException e) { - throw new RuntimeException(e); + private static String stripQuotes(String s) { + if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') { + return s.substring(1, s.length() - 1); + } + return s; } - XmlWriter xmlWriter = new XmlWriter(); - try { - xmlWriter.write(config); - } catch (IOException e) { - throw new RuntimeException(e); + public static int optionLength(String option) { + return Standard.optionLength(option); } - } - - private static String stripQuotes(String s) { - if (s.charAt(0) == '"' && s.charAt(s.length()-1) == '"') { - return s.substring(1, s.length()-1); + public static boolean validOptions(String options[][], DocErrorReporter reporter) { + return true; } - return s; - } - - public static int optionLength(String option) { - return Standard.optionLength(option); - } - - public static boolean validOptions(String options[][], DocErrorReporter reporter) { - return true; - } } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java index 604d48ac5e..d35dfd38e1 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java @@ -23,18 +23,17 @@ public class Config { - public final String templateName; - public final String configName; - public Map configProperties; + public final String templateName; + public final String configName; + public Map configProperties; - public Config(String configName, String templateName) { - this.configName = configName; - this.templateName = templateName; - this.configProperties = new TreeMap(); - } - - public Config() { - this(null, null); - } + public Config(String configName, String templateName) { + this.configName = configName; + this.templateName = templateName; + this.configProperties = new TreeMap(); + } + public Config() { + this(null, null); + } } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java index 89490c4a51..98ab8ae582 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java @@ -20,28 +20,26 @@ public class ConfigProperty { - public String propertyName; - public String defaultValue; - public String description; - public String type = "string"; - public boolean isPrivate = false; - public boolean isUnstable = false; - public boolean isEvolving = false; - public boolean isValidConfigProp = false; - public String[] validValues; - public String inferredType; + public String propertyName; + public String defaultValue; + public String description; + public String type = "string"; + public boolean isPrivate = false; + public boolean isUnstable = false; + public boolean isEvolving = false; + public boolean isValidConfigProp = false; + public String[] validValues; + public String inferredType; - @Override - public String toString() { - return "name=" + propertyName - + ", defaultValue=" + defaultValue - + ", description=" + description - + ", type=" + type - + ", inferredType=" + inferredType - + ", private=" + isPrivate - + ", validValues=" + (validValues == null ? "null" : validValues) - + ", isConfigProp=" + isValidConfigProp; - } + @Override + public String toString() { + return "name=" + propertyName + + ", defaultValue=" + defaultValue + + ", description=" + description + + ", type=" + type + + ", inferredType=" + inferredType + + ", private=" + isPrivate + + ", validValues=" + (validValues == null ? "null" : validValues) + + ", isConfigProp=" + isValidConfigProp; + } } - - diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java index 4b531e87e5..1586e51439 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java @@ -18,144 +18,136 @@ package org.apache.tez.tools.javadoc.util; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - -import org.apache.tez.dag.api.TezException; import org.apache.tez.tools.javadoc.model.Config; import org.apache.tez.tools.javadoc.model.ConfigProperty; +import java.io.*; + public class HtmlWriter extends Writer { - private static final String DEFAULT_STYLESHEET = "default-stylesheet.css"; + private static final String DEFAULT_STYLESHEET = "default-stylesheet.css"; - public void write(Config config) throws IOException { - PrintWriter out = null; + public void write(Config config) throws IOException { + PrintWriter out = null; - if (config.configName == null || config.configName.isEmpty()) { - throw new RuntimeException("Config Name is null or empty"); - } + if (config.configName == null || config.configName.isEmpty()) { + throw new RuntimeException("Config Name is null or empty"); + } - try { - File file = new File(config.configName + ".html"); - out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + try { + File file = new File(config.configName + ".html"); + out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); - out.println(""); - out.println(""); + out.println(""); + out.println(""); - out.println(""); + out.println(""); - out.println(""); - out.println(""); - out.println(""+ config.configName +""); + out.println(""); + out.println(""); + out.println("" + config.configName + ""); // out.println(""); - out.println(""); - - out.println(""); - - out.println(""); - - out.println("
"); - out.println("
"); - - out.println("

"+ config.configName +"

"); - out.println("
"); - - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - // out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - - for (ConfigProperty configProperty : config.configProperties.values()) { - if (!isValidConfigProperty(configProperty)) { - continue; + out.println(""); + + out.println(""); + + out.println(""); + + out.println("
"); + out.println("
"); + + out.println("

" + config.configName + "

"); + out.println("
"); + + out.println("
" + "Property Name" + "" + "Default Value" + "" + "Description" + "" + "Type" + "" + "Valid Values" + "" + "Is Private?" + "" + "Is Unstable?" + "" + "Is Evolving?" + "
"); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + // out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + + for (ConfigProperty configProperty : config.configProperties.values()) { + if (!isValidConfigProperty(configProperty)) { + continue; + } + + String altClass = ""; + if (configProperty.isPrivate) { + altClass = "class=\"tr_private\""; + } else if (configProperty.isEvolving || configProperty.isUnstable) { + altClass = "class=\"tr_evolve_unstable\""; + } + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + // Re-enable after adding values + // out.println(""); + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + + out.println("
" + "Property Name" + "" + "Default Value" + "" + "Description" + "" + "Type" + "" + "Valid Values" + "" + "Is Private?" + "" + "Is Unstable?" + "" + "Is Evolving?" + "
" + configProperty.propertyName + "" + configProperty.defaultValue + "" + configProperty.description + "" + configProperty.type + "" + configProperty.validValues + "" + configProperty.isPrivate + "" + configProperty.isEvolving + "" + configProperty.isUnstable + "
"); + + out.println("
"); + out.println("
"); + out.println(""); + out.println(""); + } finally { + if (out != null) { + out.close(); + } } - - String altClass = ""; - if (configProperty.isPrivate) { - altClass = "class=\"tr_private\""; - } else if (configProperty.isEvolving || configProperty.isUnstable) { - altClass = "class=\"tr_evolve_unstable\""; - } - - out.println(""); - out.println("" + configProperty.propertyName + ""); - out.println("" + configProperty.defaultValue + ""); - out.println("" + configProperty.description + ""); - out.println("" + configProperty.type + ""); - // Re-enable after adding values - // out.println("" + configProperty.validValues + ""); - - out.println("" + configProperty.isPrivate + ""); - out.println("" + configProperty.isEvolving + ""); - out.println("" + configProperty.isUnstable + ""); - out.println(""); - } - - out.println(""); - - out.println(""); - out.println(""); - out.println(""); - out.println(""); - - } finally { - if (out != null) { - out.close(); - } } - } - } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java index cfb0c92738..6b9bcf9b20 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java @@ -18,22 +18,22 @@ package org.apache.tez.tools.javadoc.util; -import java.io.IOException; - import org.apache.tez.tools.javadoc.model.Config; import org.apache.tez.tools.javadoc.model.ConfigProperty; +import java.io.IOException; + public abstract class Writer { - public abstract void write(Config config) throws IOException; + public abstract void write(Config config) throws IOException; - public boolean isValidConfigProperty(ConfigProperty configProperty) { - if (!configProperty.isValidConfigProp) { - return false; - } - if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) { - return false; + public boolean isValidConfigProperty(ConfigProperty configProperty) { + if (!configProperty.isValidConfigProp) { + return false; + } + if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) { + return false; + } + return true; } - return true; - } } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java index 1c4b735451..a6b1c06e87 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java @@ -18,82 +18,74 @@ package org.apache.tez.tools.javadoc.util; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; import org.apache.tez.tools.javadoc.model.Config; import org.apache.tez.tools.javadoc.model.ConfigProperty; -public class XmlWriter extends Writer { - - public void write(Config config) throws IOException { - PrintWriter out = null; - - if (config.configName == null || config.configName.isEmpty()) { - throw new RuntimeException("Config Name is null or empty"); - } +import java.io.*; - String fileName = config.templateName == null || - config.templateName.isEmpty() ? config.configName : config.templateName; - if (!fileName.endsWith(".xml")) { - fileName += ".xml"; - } - - try { - File file = new File(fileName); - out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); +public class XmlWriter extends Writer { - out.println(""); - out.println(""); - out.println(); - out.println(""); - out.println(); - out.println(""); + public void write(Config config) throws IOException { + PrintWriter out = null; - for (ConfigProperty configProperty : config.configProperties.values()) { - if (!isValidConfigProperty(configProperty)) { - continue; - } - out.println(); - out.println(" "); - out.println(" " + configProperty.propertyName + ""); - if (configProperty.defaultValue != null && !configProperty.defaultValue.isEmpty()) { - out.println(" " + configProperty.defaultValue + ""); + if (config.configName == null || config.configName.isEmpty()) { + throw new RuntimeException("Config Name is null or empty"); } - if (configProperty.description != null && !configProperty.description.isEmpty()) { - out.println(" " + StringEscapeUtils.escapeXml(configProperty.description) - + ""); - } - if (configProperty.type != null && !configProperty.type.isEmpty()) { - out.println(" " + configProperty.type + ""); - } - if (configProperty.isUnstable) { - out.println(" true"); - } - if (configProperty.isEvolving) { - out.println(" true"); - } - if (configProperty.isPrivate) { - out.println(" true"); + + String fileName = config.templateName == null || + config.templateName.isEmpty() ? config.configName : config.templateName; + if (!fileName.endsWith(".xml")) { + fileName += ".xml"; } - out.println(" "); - } - out.println(); - out.println(""); + try { + File file = new File(fileName); + out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); - } finally { - if (out != null) { - out.close(); - } - } - } + out.println(""); + out.println(""); + out.println(); + out.println(""); + out.println(); + out.println(""); + for (ConfigProperty configProperty : config.configProperties.values()) { + if (!isValidConfigProperty(configProperty)) { + continue; + } + out.println(); + out.println(" "); + out.println(" " + configProperty.propertyName + ""); + if (configProperty.defaultValue != null && !configProperty.defaultValue.isEmpty()) { + out.println(" " + configProperty.defaultValue + ""); + } + if (configProperty.description != null && !configProperty.description.isEmpty()) { + out.println(" " + StringEscapeUtils.escapeXml(configProperty.description) + + ""); + } + if (configProperty.type != null && !configProperty.type.isEmpty()) { + out.println(" " + configProperty.type + ""); + } + if (configProperty.isUnstable) { + out.println(" true"); + } + if (configProperty.isEvolving) { + out.println(" true"); + } + if (configProperty.isPrivate) { + out.println(" true"); + } + out.println(" "); + } + out.println(); + out.println(""); + } finally { + if (out != null) { + out.close(); + } + } + } }