@ SuppressWarnings ( "index" ) // dependent: os[1] is legal when optionLength(os[0])==2 public static boolean validOptions ( String [ ] @ MinLen ( 1 ) [ ] options , DocErrorReporter reporter ) { boolean hasDocFile = false ; boolean hasOutFile = false ; boolean hasDestDir = false ; boolean hasFormat = false ; boolean inPlace = false ; String docFile = null ; String outFile = null ; for ( int oi = 0 ; oi < options . length ; oi ++ ) { String [ ] os = options [ oi ] ; String opt = os [ 0 ] . toLowerCase ( ) ; if ( opt . equals ( "-docfile" ) ) { if ( hasDocFile ) { reporter . printError ( "-docfile option specified twice" ) ; return false ; } docFile = os [ 1 ] ; File f = new File ( docFile ) ; if ( ! f . exists ( ) ) { reporter . printError ( "-docfile file not found: " + docFile ) ; return false ; } hasDocFile = true ; } if ( opt . equals ( "-outfile" ) ) { if ( hasOutFile ) { reporter . printError ( "-outfile option specified twice" ) ; return false ; } if ( inPlace ) { reporter . printError ( "-i and -outfile can not be used at the same time" ) ; return false ; } outFile = os [ 1 ] ; hasOutFile = true ; } if ( opt . equals ( "-i" ) ) { if ( hasOutFile ) { reporter . printError ( "-i and -outfile can not be used at the same time" ) ; return false ; } inPlace = true ; } if ( opt . equals ( "-format" ) ) { if ( hasFormat ) { reporter . printError ( "-format option specified twice" ) ; return false ; } String format = os [ 1 ] ; if ( ! format . equals ( "javadoc" ) && ! format . equals ( "html" ) ) { reporter . printError ( "unrecognized output format: " + format ) ; return false ; } hasFormat = true ; } if ( opt . equals ( "-d" ) ) { if ( hasDestDir ) { reporter . printError ( "-d specified twice" ) ; return false ; } hasDestDir = true ; } } if ( docFile != null && outFile != null && outFile . equals ( docFile ) ) { reporter . printError ( "docfile must be different from outfile" ) ; return false ; } if ( inPlace && docFile == null ) { reporter . printError ( "-i supplied but -docfile was not" ) ; return false ; } return true ; }
Tests the validity of command - line arguments passed to this doclet . Returns true if the option usage is valid and false otherwise . This method is automatically invoked by Javadoc .