Example #1
0
 /**
  * Retrieves the {@link Lesto}. If it exists, that instance is returned.
  *
  * @return the lesto annotations class.
  */
 public static synchronized Lesto getInstance() {
   if (lesto == null) {
     lesto = new Lesto(null);
     lesto.gatherInformations();
   }
   return lesto;
 }
Example #2
0
 /**
  * Retrieves the {@link Lesto} for a particular url path.
  *
  * <p><b>When this method is called, the {@link Lesto} instance is reset.</b>
  *
  * <p>Be careful when you use this. This is a workaround needed for eclipse systems, where the url
  * returned by the urlfinder is a bundleresource that would need to be resolved first with rcp
  * tools we do not want to depend on.
  *
  * @return the horton machine annotations class.
  */
 public static Lesto getInstance(URL baseclassUrl) {
   lesto = new Lesto(baseclassUrl);
   lesto.gatherInformations();
   return lesto;
 }
Example #3
0
  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);
    // }

  }