Ejemplo n.º 1
0
  public static boolean validOptions(String options[][], DocErrorReporter reporter) {
    boolean foundDirOption = false;
    for (int i = 0; i < options.length; i++) {
      String[] opt = options[i];
      if (opt[0].equals("-d")) {
        if (foundDirOption) {
          reporter.printError("Only one -d option allowed.");
          return false;
        } else {
          foundDirOption = true;
        }
      } else if (opt[0].equals("-overwrite")) {

      }
    }
    if (!foundDirOption) {
      reporter.printError(
          "Usage: javadoc -d outputDir " + "-doclet in.kp.doclet.sample.ListClass " + "... ");
    }
    return foundDirOption;
  }
Ejemplo n.º 2
0
 /**
  * This checks for the validity of the options used by the user. This works exactly like {@link
  * bluej.doclet.Doclet#validOptions(String[][], DocErrorReporter)}. This will validate the options
  * which are shared by our doclets. For example, this method will flag an error using the
  * DocErrorReporter if user has used "-nohelp" and "-helpfile" option together.
  *
  * @param options options used on the command line.
  * @param reporter used to report errors.
  * @return true if all the options are valid.
  */
 public boolean generalValidOptions(String options[][], DocErrorReporter reporter) {
   boolean docencodingfound = false;
   String encoding = "";
   for (int oi = 0; oi < options.length; oi++) {
     String[] os = options[oi];
     String opt = os[0].toLowerCase();
     if (opt.equals("-d")) {
       String destdirname = addTrailingFileSep(os[1]);
       File destDir = new File(destdirname);
       if (!destDir.exists()) {
         // Create the output directory (in case it doesn't exist yet)
         reporter.printNotice(getText("doclet.dest_dir_create", destdirname));
         (new File(destdirname)).mkdirs();
       } else if (!destDir.isDirectory()) {
         reporter.printError(
             getText("doclet.destination_directory_not_directory_0", destDir.getPath()));
         return false;
       } else if (!destDir.canWrite()) {
         reporter.printError(
             getText("doclet.destination_directory_not_writable_0", destDir.getPath()));
         return false;
       }
     } else if (opt.equals("-docencoding")) {
       docencodingfound = true;
       if (!checkOutputFileEncoding(os[1], reporter)) {
         return false;
       }
     } else if (opt.equals("-encoding")) {
       encoding = os[1];
     }
   }
   if (!docencodingfound && encoding.length() > 0) {
     if (!checkOutputFileEncoding(encoding, reporter)) {
       return false;
     }
   }
   return true;
 }
Ejemplo n.º 3
0
  public static boolean validOptions(String[][] options, DocErrorReporter r) {
    for (String[] a : options) {
      if (a[0].equals("-error") || a[0].equals("-warning") || a[0].equals("-hide")) {
        try {
          Integer.parseInt(a[1]);
        } catch (NumberFormatException e) {
          r.printError("bad -" + a[0] + " value must be a number: " + a[1]);
          return false;
        }
      }
    }

    return true;
  }
Ejemplo n.º 4
0
 /**
  * Check the validity of the given Source or Output File encoding on this platform.
  *
  * @param docencoding output file encoding.
  * @param reporter used to report errors.
  */
 private boolean checkOutputFileEncoding(String docencoding, DocErrorReporter reporter) {
   OutputStream ost = new ByteArrayOutputStream();
   OutputStreamWriter osw = null;
   try {
     osw = new OutputStreamWriter(ost, docencoding);
   } catch (UnsupportedEncodingException exc) {
     reporter.printError(getText("doclet.Encoding_not_supported", docencoding));
     return false;
   } finally {
     try {
       if (osw != null) {
         osw.close();
       }
     } catch (IOException exc) {
     }
   }
   return true;
 }