Beispiel #1
0
  public String helperName() {
    if (pack_name.length() > 0) {
      String s = ScopedName.unPseudoName(pack_name + "." + name);

      return getFullName(s);
    } else {
      return ScopedName.unPseudoName(name);
    }
  }
Beispiel #2
0
  /** prints a constant declaration outside of an enclosing interface into a separate interface */
  public void print(PrintWriter ps) {
    if (contained() || (included && !generateIncluded())) return;

    try {
      String fullName = ScopedName.unPseudoName(full_name());
      String className;
      if (fullName.indexOf('.') > 0) {
        pack_name = fullName.substring(0, fullName.lastIndexOf('.'));
        className = fullName.substring(fullName.lastIndexOf('.') + 1);
      } else {
        pack_name = "";
        className = fullName;
      }

      String path = parser.out_dir + fileSeparator + pack_name.replace('.', fileSeparator);
      File dir = new File(path);
      if (!dir.exists()) {
        if (!dir.mkdirs()) {
          org.jacorb.idl.parser.fatal_error("Unable to create " + path, null);
        }
      }

      String fname = className + ".java";
      File f = new File(dir, fname);

      if (GlobalInputStream.isMoreRecentThan(f)) {
        PrintWriter pw = new PrintWriter(new java.io.FileWriter(f));

        if (logger.isDebugEnabled()) logger.debug("ConstDecl.print " + fname);

        if (!pack_name.equals("")) pw.println("package " + pack_name + ";");

        printClassComment("const", className, pw);

        pw.println("public interface " + className);
        pw.println("{");

        pw.print("\t" + const_type.toString() + " value = ");

        pw.print(getValue());
        pw.println(";");

        pw.println("}");
        pw.close();
      }
    } catch (java.io.IOException i) {
      throw new RuntimeException("File IO error" + i);
    }
  }