use of oms3.annotations.Documentation in project hortonmachine by TheHortonMachine.
the class SpatialToolboxUtils method collectParameters.
// /**
// * Get the path for a module doc html.
// *
// * @param moduleClassName the name of the module to get the path for.
// * @return the path to the html file.
// * @throws Exception
// */
// public static String getModuleDocumentationPath( String moduleClassName ) throws Exception {
// File configurationsFolder = SpatialToolboxSessionPluginSingleton.getInstance().getConfigurationsFolder();
// File htmlDocsFolder = new File(configurationsFolder, STAGEHTMLDOCS);
// File htmlDocs = new File(htmlDocsFolder, moduleClassName + ".html");
// if (!htmlDocs.exists()) {
// htmlDocs = new File(htmlDocsFolder, "Oms" + moduleClassName + ".html");
// if (!htmlDocs.exists()) {
// return NO_DOCUMENTATION_AVAILABLE;
// }
// }
// return htmlDocs.getAbsolutePath();
// }
// /**
// * Porge the html docs folder.
// *
// * @throws Exception
// */
// public static void cleanModuleDocumentation() throws Exception {
// File configurationsFolder = SpatialToolboxSessionPluginSingleton.getInstance().getConfigurationsFolder();
// File htmlDocsFolder = new File(configurationsFolder, STAGEHTMLDOCS);
// if (htmlDocsFolder.exists()) {
// FileUtilities.deleteFileOrDir(htmlDocsFolder);
// }
// }
//
// /**
// * Generate the module documentation in the configuration area.
// *
// * @param moduleClassName the class for which to generate the doc.
// * @throws Exception
// */
// @SuppressWarnings("nls")
// public static void generateModuleDocumentation( String moduleClassName ) throws Exception {
//
// Class< ? > moduleClass = StageModulesManager.getInstance().getModulesClass(moduleClassName);
//
// StringBuilder sb = new StringBuilder();
// sb.append("<html><body>\n");
//
// // modules documentation
// Documentation documentation = moduleClass.getAnnotation(Documentation.class);
// String documentationStr = null;
// if (documentation != null) {
// documentationStr = AnnotationUtilities.getLocalizedDocumentation(documentation);
// if (documentationStr.length() == 0) {
// documentationStr = null;
// } else if (documentationStr.equals(" - ")) {
// documentationStr = null;
// }
// }
// if (documentation != null && documentationStr != null) {
// if (documentationStr.endsWith(DOCSSUFFIX)) {
// // have to get the file
// String modulePackage = moduleClassName.substring(0, moduleClassName.lastIndexOf('.'));
// String path = modulePackage.replaceAll("\\.", "/") + "/" + documentationStr;
// InputStream inStream = StageModulesManager.getInstance().getResourceAsStream(path);
// // InputStream inStream = moduleClass.getResourceAsStream(documentationStr);
// if (inStream != null) {
// BufferedReader br = null;
// try {
// br = new BufferedReader(new InputStreamReader(inStream));
// StringBuilder tmpSb = new StringBuilder();
// String line = "";
// while( (line = br.readLine()) != null ) {
// tmpSb.append(line).append(NEWLINE);
// }
// documentationStr = tmpSb.toString();
// } finally {
// if (br != null)
// br.close();
// }
// }
// }
// sb.append("<h2>Description</h2>").append(NEWLINE);
// sb.append(NEWLINE);
// sb.append("<blockquote>");
// sb.append(documentationStr);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// sb.append(NEWLINE);
// } else {
// // try with module description
// Description description = moduleClass.getAnnotation(Description.class);
// String descriptionStr = AnnotationUtilities.getLocalizedDescription(description);
// if (description != null) {
// sb.append("<h2>Description</h2>").append(NEWLINE);
// sb.append(NEWLINE);
// sb.append("<blockquote>");
// sb.append(descriptionStr);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// sb.append(NEWLINE);
// }
// }
// // general info
// sb.append("<h2>General Information</h2>").append(NEWLINE);
// sb.append(NEWLINE);
// // general info: status
// Status status = moduleClass.getAnnotation(Status.class);
// if (status != null) {
// sb.append("<blockquote>");
// sb.append("Module status: " + getStatusString(status.value())).append(NEWLINE);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// }
//
// // general info: script name
// Name name = moduleClass.getAnnotation(Name.class);
// String nameStr = AnnotationUtilities.getLocalizedName(name);
// if (name != null) {
// sb.append("<blockquote>");
// sb.append(" Name to use in a script: <b>" + nameStr + "</b>").append(NEWLINE);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// }
// // general info: authors
// Author author = moduleClass.getAnnotation(Author.class);
// if (author != null) {
// String authorNameStr = author.name();
// String[] authorNameSplit = authorNameStr.split(",");
//
// String authorContactStr = author.contact();
// String[] authorContactSplit = authorContactStr.split(",");
//
// sb.append("<blockquote>");
// sb.append(" Authors ").append(NEWLINE);
// sb.append(HTMLNEWLINE);
// sb.append("<ul>").append(NEWLINE);
// for( String authorName : authorNameSplit ) {
// sb.append("<li>").append(authorName.trim());
// }
// sb.append("</li>").append(NEWLINE);
// sb.append("</ul>").append(NEWLINE);
// sb.append(NEWLINE);
// sb.append(HTMLNEWLINE);
// sb.append(HTMLNEWLINE);
// // if (authorContactStr.startsWith("http")) {
// // authorContactStr = "<a href=\"" + authorContactStr + "\">" + authorContactStr +
// // "</a>";
// // }
// sb.append(" Contacts: ").append(NEWLINE);
// sb.append(HTMLNEWLINE);
// sb.append("<ul>").append(NEWLINE);
// for( String authorContact : authorContactSplit ) {
// sb.append("<li>").append(authorContact.trim());
// }
// sb.append("</li>").append(NEWLINE);
// sb.append("</ul>").append(NEWLINE);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// }
// // general info: license
// License license = moduleClass.getAnnotation(License.class);
// if (license != null) {
// String licenseStr = AnnotationUtilities.getLocalizedLicense(license);
// sb.append("<blockquote>");
// sb.append(" License: " + licenseStr).append(NEWLINE);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// }
// // general info: keywords
// Keywords keywords = moduleClass.getAnnotation(Keywords.class);
// if (keywords != null) {
// String keywordsStr = AnnotationUtilities.getLocalizedKeywords(keywords);
// sb.append("<blockquote>");
// sb.append(" Keywords: " + keywordsStr).append(NEWLINE);
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// }
// sb.append(NEWLINE);
//
// // gather input fields
// Object annotatedObject = moduleClass.newInstance();
// ComponentAccess cA = new ComponentAccess(annotatedObject);
//
// // parameters
// sb.append("<h2>Parameters</h2>").append(NEWLINE);
// sb.append(NEWLINE);
// sb.append("<blockquote>");
// // parameters: fields
// Collection<Access> inputs = cA.inputs();
// StringBuilder sbTmp = new StringBuilder();
// collectParameters(sbTmp, inputs);
// toTable(sb, sbTmp, "Input parameters");
// sb.append(NEWLINE);
// Collection<Access> outputs = cA.outputs();
// sbTmp = new StringBuilder();
// collectParameters(sbTmp, outputs);
// toTable(sb, sbTmp, "Output parameters");
// sb.append("</blockquote>");
// sb.append(NEWLINE);
// sb.append(NEWLINE);
//
// sb.append("</body></html>");
//
// File configurationsFolder = SpatialToolboxSessionPluginSingleton.getInstance().getConfigurationsFolder();
// File htmlDocsFolder = new File(configurationsFolder, STAGEHTMLDOCS);
// if (!htmlDocsFolder.exists()) {
// if (!htmlDocsFolder.mkdir()) {
// throw new RuntimeException();
// }
// }
//
// File htmlDocs = new File(htmlDocsFolder, moduleClassName + ".html");
// FileUtilities.writeFile(sb.toString(), htmlDocs);
// }
private static void collectParameters(StringBuilder sbTmp, Collection<Access> accessList) throws Exception {
for (Access access : accessList) {
Field field = access.getField();
String fieldName = field.getName();
Description descriptionAnnot = field.getAnnotation(Description.class);
if (fieldName.equals("pm")) {
// ignore progress monitor
continue;
}
String fieldDescription = " - ";
if (descriptionAnnot != null) {
fieldDescription = AnnotationUtilities.getLocalizedDescription(descriptionAnnot);
if (fieldDescription == null) {
fieldDescription = " - ";
}
Unit unitAnn = field.getAnnotation(Unit.class);
if (unitAnn != null) {
fieldDescription = fieldDescription + " [" + unitAnn.value() + "]";
}
}
sbTmp.append("<tr>").append(NEWLINE);
sbTmp.append("<td width=\"40%\"> <b>").append(fieldName).append("</b> </td><td width=\"60%\"> ");
sbTmp.append(fieldDescription).append(" </td>").append(NEWLINE);
sbTmp.append("</tr>").append(NEWLINE);
}
}
use of oms3.annotations.Documentation in project hortonmachine by TheHortonMachine.
the class HortonMachine method main.
public static void main(String[] args) throws IOException {
HortonMachine hm = HortonMachine.getInstance();
Set<Entry<String, Class<?>>> cls = hm.moduleName2Class.entrySet();
for (Entry<String, Class<?>> cl : cls) {
System.out.println(cl.getValue().getCanonicalName());
}
if (true)
return;
LinkedHashMap<String, List<ClassField>> moduleName2Fields = hm.moduleName2Fields;
LinkedHashMap<String, Class<?>> moduleName2Class = hm.moduleName2Class;
Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
for (Entry<String, List<ClassField>> entry : entrySet) {
String moduleName = entry.getKey();
StringBuilder sb = new StringBuilder();
Class<?> moduleClass = moduleName2Class.get(moduleName);
Description description = moduleClass.getAnnotation(Description.class);
sb.append("public static final String " + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + "\";\n");
Documentation documentation = moduleClass.getAnnotation(Documentation.class);
String doc;
if (documentation == null) {
doc = "";
} else {
doc = documentation.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + "\";\n");
Keywords keywords = moduleClass.getAnnotation(Keywords.class);
String k;
if (keywords == null) {
k = "";
} else {
k = keywords.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + "\";\n");
Label label = moduleClass.getAnnotation(Label.class);
String lab;
if (label == null) {
lab = "";
} else {
lab = label.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_LABEL = \"" + lab + "\";\n");
Name name = moduleClass.getAnnotation(Name.class);
String n;
if (name == null) {
n = "";
} else {
n = name.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_NAME = \"" + n + "\";\n");
Status status = moduleClass.getAnnotation(Status.class);
// String st = "";
// switch( status.value() ) {
// case 5:
// st = "EXPERIMENTAL";
// break;
// case 10:
// st = "DRAFT";
// break;
// case 20:
// st = "TESTED";
// break;
// case 30:
// st = "VALIDATED";
// break;
// case 40:
// st = "CERTIFIED";
// break;
// default:
// st = "DRAFT";
// break;
// }
sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
License license = moduleClass.getAnnotation(License.class);
sb.append("public static final String " + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + "\";\n");
Author author = moduleClass.getAnnotation(Author.class);
String authorName = author.name();
sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + "\";\n");
String authorContact = author.contact();
sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + "\";\n");
UI ui = moduleClass.getAnnotation(UI.class);
if (ui != null) {
sb.append("public static final String " + moduleName.toUpperCase() + "_UI = \"" + ui.value() + "\";\n");
}
List<ClassField> value = entry.getValue();
for (ClassField classField : value) {
String fieldName = classField.fieldName;
if (fieldName.equals("pm")) {
continue;
}
String fieldDescription = classField.fieldDescription;
String str = "public static final String " + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + "\";\n";
sb.append(str);
}
System.out.println(sb.toString());
System.out.println();
}
// for( String className : hm.allClasses ) {
// System.out.println(className);
// }
// for( String fieldName : hm.allFields ) {
// System.out.println(fieldName);
// }
}
use of oms3.annotations.Documentation in project hortonmachine by TheHortonMachine.
the class WikiModulesCreator method dump.
private static void dump(Map<String, List<ClassField>> modulesMap, Map<String, Class<?>> modulesClassesMap, String imagesBaseurl, String testcasesBaseurl, String testcasesHmBasepackage) throws Exception {
Set<String> nameSet = modulesClassesMap.keySet();
for (String moduleName : nameSet) {
StringBuilder sb = new StringBuilder();
Class<?> abClass = modulesClassesMap.get(moduleName);
// summary line
Description description = abClass.getAnnotation(Description.class);
String descriptionStr = description.value();
sb.append("#summary " + descriptionStr);
sb.append(NEWLINE);
sb.append(NEWLINE);
// modules documentation
sb.append("<h2>Description</h2>").append(NEWLINE);
sb.append(NEWLINE);
Documentation documentation = abClass.getAnnotation(Documentation.class);
if (documentation == null) {
System.out.println("Jumping " + moduleName);
continue;
}
String documentationStr = documentation.value();
if (documentationStr.endsWith(DOCSSUFFIX)) {
// have to get the file
URL resource = abClass.getResource(documentationStr);
try {
File resourceFile = new File(resource.toURI());
documentationStr = FileUtilities.readFile(resourceFile);
} catch (Exception e) {
System.err.println("Error in: " + moduleName);
}
}
sb.append(documentationStr);
// general info
sb.append(NEWLINE);
sb.append(NEWLINE);
String parentClassStatus = "not defined";
List<ClassField> fieldsList = modulesMap.get(moduleName);
if (fieldsList.size() > 0) {
ClassField tmp = fieldsList.get(0);
parentClassStatus = tmp.parentClassStatus;
}
sb.append("<h2>General Information</h2>").append(NEWLINE);
sb.append(NEWLINE);
// general info: status
sb.append(" Module status: " + parentClassStatus).append(NEWLINE);
sb.append(NEWLINE);
// general info: script name
Name name = abClass.getAnnotation(Name.class);
if (name != null) {
String nameStr = name.value();
sb.append(" Name to use in a script: <b>" + nameStr + "</b>").append(NEWLINE);
sb.append(NEWLINE);
}
// general info: authors
Author author = abClass.getAnnotation(Author.class);
if (author != null) {
String authorNameStr = author.name();
String authorContactStr = author.contact();
sb.append(" Authors: " + authorNameStr).append(NEWLINE);
sb.append(NEWLINE);
sb.append(" Contacts: " + authorContactStr).append(NEWLINE);
sb.append(NEWLINE);
}
// general info: license
License license = abClass.getAnnotation(License.class);
if (license != null) {
String licenseStr = license.value();
sb.append(" License: " + licenseStr).append(NEWLINE);
sb.append(NEWLINE);
}
// general info: keywords
Keywords keywords = abClass.getAnnotation(Keywords.class);
if (keywords != null) {
String keywordsStr = keywords.value();
sb.append(" Keywords: " + keywordsStr).append(NEWLINE);
sb.append(NEWLINE);
}
sb.append(NEWLINE);
// parameters
sb.append("<h2>Parameters</h2>").append(NEWLINE);
sb.append(NEWLINE);
// parameters: input
StringBuilder sbTmp = new StringBuilder();
for (ClassField classField : fieldsList) {
if (classField.isOut || classField.fieldName.equals("pm")) {
// ignore progress monitor
continue;
}
Unit unitAnn = abClass.getField(classField.fieldName).getAnnotation(Unit.class);
String fieldDescription = classField.fieldDescription;
if (unitAnn != null) {
fieldDescription = fieldDescription + " [" + unitAnn.value() + "]";
}
sbTmp.append("<tr>").append(NEWLINE);
sbTmp.append("<td width=\"50%\"> <b>").append(classField.fieldName).append("</b> </td><td width=\"50%\"> ");
sbTmp.append(fieldDescription).append(" </td>").append(NEWLINE);
sbTmp.append("</tr>").append(NEWLINE);
}
toTable(sb, sbTmp, "Input parameters");
sb.append(NEWLINE);
// parameters: output data
sbTmp = new StringBuilder();
for (ClassField classField : fieldsList) {
if (classField.isIn) {
// ignore progress monitor
continue;
}
Unit unitAnn = abClass.getField(classField.fieldName).getAnnotation(Unit.class);
String fieldDescription = classField.fieldDescription;
if (unitAnn != null) {
fieldDescription = fieldDescription + " [" + unitAnn.value() + "]";
}
sbTmp.append("<tr>").append(NEWLINE);
sbTmp.append("<td width=\"50%\"> <b>").append(classField.fieldName).append("</b> </td><td width=\"50%\"> ");
sbTmp.append(fieldDescription).append(" </td>").append(NEWLINE);
sbTmp.append("</tr>").append(NEWLINE);
}
toTable(sb, sbTmp, "Output parameters");
sb.append(NEWLINE);
// example result
if (imagesBaseurl != null) {
sb.append("<h2>Example result</h2>").append(NEWLINE);
sb.append(NEWLINE);
sb.append("<img src=\"" + imagesBaseurl + moduleName.toLowerCase() + ".png" + "\" alt=\"" + moduleName + "\"/>").append(NEWLINE);
sb.append("<br>").append(NEWLINE);
}
// developer example
String testName = "Test" + moduleName + ".java";
String testClassName = testcasesHmBasepackage + "Test" + moduleName;
boolean doTest = false;
try {
Class.forName(testClassName);
doTest = true;
} catch (Exception e) {
// ignore if no testcase
System.err.println("TESTCASE missign for: " + testName);
}
if (doTest) {
sb.append("<h2>Developer example</h2>").append(NEWLINE);
sb.append(NEWLINE);
sb.append("An example usage of the algorithm can be found in the testcases suite: ").append(NEWLINE);
sb.append("[");
sb.append(testcasesBaseurl).append(testName);
sb.append(" ").append(moduleName).append("]");
}
FileUtilities.writeFile(sb.toString(), new File(outputWikiFolder, moduleName + ".wiki"));
}
}
use of oms3.annotations.Documentation in project hortonmachine by TheHortonMachine.
the class Lesto method main.
public static void main(String[] args) throws IOException {
Lesto hm = Lesto.getInstance();
Set<Entry<String, Class<?>>> cls = hm.moduleName2Class.entrySet();
for (Entry<String, Class<?>> cl : cls) {
System.out.println(cl.getValue().getCanonicalName());
}
if (true)
return;
LinkedHashMap<String, List<ClassField>> moduleName2Fields = hm.moduleName2Fields;
LinkedHashMap<String, Class<?>> moduleName2Class = hm.moduleName2Class;
Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
for (Entry<String, List<ClassField>> entry : entrySet) {
String moduleName = entry.getKey();
StringBuilder sb = new StringBuilder();
Class<?> moduleClass = moduleName2Class.get(moduleName);
Description description = moduleClass.getAnnotation(Description.class);
sb.append("public static final String " + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + "\";\n");
Documentation documentation = moduleClass.getAnnotation(Documentation.class);
String doc;
if (documentation == null) {
doc = "";
} else {
doc = documentation.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + "\";\n");
Keywords keywords = moduleClass.getAnnotation(Keywords.class);
String k;
if (keywords == null) {
k = "";
} else {
k = keywords.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + "\";\n");
Label label = moduleClass.getAnnotation(Label.class);
String lab;
if (label == null) {
lab = "";
} else {
lab = label.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_LABEL = \"" + lab + "\";\n");
Name name = moduleClass.getAnnotation(Name.class);
String n;
if (name == null) {
n = "";
} else {
n = name.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_NAME = \"" + n + "\";\n");
Status status = moduleClass.getAnnotation(Status.class);
// String st = "";
// switch( status.value() ) {
// case 5:
// st = "EXPERIMENTAL";
// break;
// case 10:
// st = "DRAFT";
// break;
// case 20:
// st = "TESTED";
// break;
// case 30:
// st = "VALIDATED";
// break;
// case 40:
// st = "CERTIFIED";
// break;
// default:
// st = "DRAFT";
// break;
// }
sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
License license = moduleClass.getAnnotation(License.class);
sb.append("public static final String " + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + "\";\n");
Author author = moduleClass.getAnnotation(Author.class);
String authorName = author.name();
sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + "\";\n");
String authorContact = author.contact();
sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + "\";\n");
UI ui = moduleClass.getAnnotation(UI.class);
if (ui != null) {
sb.append("public static final String " + moduleName.toUpperCase() + "_UI = \"" + ui.value() + "\";\n");
}
List<ClassField> value = entry.getValue();
for (ClassField classField : value) {
String fieldName = classField.fieldName;
if (fieldName.equals("pm")) {
continue;
}
String fieldDescription = classField.fieldDescription;
String str = "public static final String " + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + "\";\n";
sb.append(str);
}
System.out.println(sb.toString());
System.out.println();
}
// for( String className : hm.allClasses ) {
// System.out.println(className);
// }
// for( String fieldName : hm.allFields ) {
// System.out.println(fieldName);
// }
}
use of oms3.annotations.Documentation in project hortonmachine by TheHortonMachine.
the class Modules method main.
public static void main(String[] args) throws IOException {
Modules mod = getInstance();
Set<Entry<String, Class<?>>> cls = mod.moduleName2Class.entrySet();
for (Entry<String, Class<?>> cl : cls) {
System.out.println(cl.getValue().getCanonicalName());
}
if (true)
return;
LinkedHashMap<String, List<ClassField>> moduleName2Fields = mod.moduleName2Fields;
LinkedHashMap<String, Class<?>> moduleName2Class = mod.moduleName2Class;
Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
for (Entry<String, List<ClassField>> entry : entrySet) {
String moduleName = entry.getKey();
StringBuilder sb = new StringBuilder();
Class<?> moduleClass = moduleName2Class.get(moduleName);
Description description = moduleClass.getAnnotation(Description.class);
sb.append("public static final String " + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + "\";\n");
Documentation documentation = moduleClass.getAnnotation(Documentation.class);
String doc;
if (documentation == null) {
doc = "";
} else {
doc = documentation.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + "\";\n");
Keywords keywords = moduleClass.getAnnotation(Keywords.class);
String k;
if (keywords == null) {
k = "";
} else {
k = keywords.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + "\";\n");
Label label = moduleClass.getAnnotation(Label.class);
String lab;
if (label == null) {
lab = "";
} else {
lab = label.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_LABEL = \"" + lab + "\";\n");
Name name = moduleClass.getAnnotation(Name.class);
String n;
if (name == null) {
n = "";
} else {
n = name.value();
}
sb.append("public static final String " + moduleName.toUpperCase() + "_NAME = \"" + n + "\";\n");
Status status = moduleClass.getAnnotation(Status.class);
// String st = "";
// switch( status.value() ) {
// case 5:
// st = "EXPERIMENTAL";
// break;
// case 10:
// st = "DRAFT";
// break;
// case 20:
// st = "TESTED";
// break;
// case 30:
// st = "VALIDATED";
// break;
// case 40:
// st = "CERTIFIED";
// break;
// default:
// st = "DRAFT";
// break;
// }
sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
License license = moduleClass.getAnnotation(License.class);
sb.append("public static final String " + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + "\";\n");
Author author = moduleClass.getAnnotation(Author.class);
String authorName = author.name();
sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + "\";\n");
String authorContact = author.contact();
sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + "\";\n");
UI ui = moduleClass.getAnnotation(UI.class);
if (ui != null) {
sb.append("public static final String " + moduleName.toUpperCase() + "_UI = \"" + ui.value() + "\";\n");
}
List<ClassField> value = entry.getValue();
for (ClassField classField : value) {
String fieldName = classField.fieldName;
if (fieldName.equals("pm")) {
continue;
}
String fieldDescription = classField.fieldDescription;
String str = "public static final String " + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + "\";\n";
sb.append(str);
}
System.out.println(sb.toString());
System.out.println();
}
// for( String className : jgr.allClasses ) {
// System.out.println(className);
// }
// for( String fieldName : jgr.allFields ) {
// System.out.println(fieldName);
// }
}
Aggregations