Changeset 28134 for main/trunk/ant-tasks/src
- Timestamp:
- 2013-08-26T17:25:29+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/ant-tasks/src/org/greenstone/anttasks/RegexSearchReplace.java
r21843 r28134 37 37 private String pattern = null; 38 38 private String replacement = null; 39 private int verbosity = 1; 39 40 private int fromLine = -1; 40 41 private int toLine = -1; … … 107 108 108 109 //output greeting 109 System.out.println( "--------------------" ); 110 System.out.println( " RegexSearchReplace " ); 111 System.out.println( "--------------------" ); 112 113 //output replacement(s) 114 System.out.println( "Replacements:" ); 115 if ( pattern != null ) { 110 if (verbosity >= 3) { 111 System.out.println( "--------------------" ); 112 System.out.println( " RegexSearchReplace " ); 113 System.out.println( "--------------------" ); 114 115 116 //output replacement(s) 117 System.out.println( "Replacements:" ); 118 119 if ( pattern != null ) { 116 120 System.out.println( " " + pattern + " -> " + replacement ); 117 } else {121 } else { 118 122 for ( int i=0; i<jobs.size(); i++ ) { 119 123 System.out.println( " " + ((RegexSearchReplaceJob)(jobs.get(i))).getPattern() + " -> " + ((RegexSearchReplaceJob)(jobs.get(i))).getReplacement() ); 120 124 } 121 } 122 System.out.println(); 123 124 //output lines if necessary 125 if ( this.fromLine != -1 || this.toLine != -1 ) { 125 } 126 System.out.println(); 127 128 129 //output lines if necessary 130 if ( this.fromLine != -1 || this.toLine != -1 ) { 126 131 System.out.println( "Lines: " + (this.fromLine==-1?"Start":Integer.toString(this.fromLine)) + " ~ " + (this.toLine==-1?"End":Integer.toString(this.toLine)) ); 127 132 System.out.println(); 128 } 129 130 System.out.println( "Files: " ); 133 } 134 } 135 136 if (verbosity == 1) { 137 System.out.println( "Regex Search and Replace on File(s): " ); 138 } 139 else if (verbosity > 1) { 140 System.out.println( "File(s): " ); 141 } 142 131 143 for ( int fileIndex=0; fileIndex<files.length; fileIndex++ ) { 132 144 … … 134 146 135 147 File inputFile = files[fileIndex]; 136 System.out.println( " " + inputFile ); 148 if (verbosity >= 1) { 149 System.out.println( " " + inputFile ); 150 } 137 151 138 152 //create the output stream … … 250 264 251 265 252 if ( noReplaces == 0 ) { 266 if (verbosity >= 2) { 267 if ( noReplaces == 0 ) { 253 268 System.out.println( " No Changes Made" ); 254 } else if ( noReplaces == 1 ) {269 } else if ( noReplaces == 1 ) { 255 270 System.out.println( " Successfully changed 1 line" ); 256 } else {271 } else { 257 272 System.out.println( " Successfully changed " + noReplaces + " lines" ); 258 } 259 System.out.println(); 273 } 274 System.out.println(); 275 } 260 276 261 277 } … … 297 313 } 298 314 315 public void setVerbosity(String verbosity_str) { 316 317 //trim 318 verbosity_str.replaceAll("\\s",""); 319 320 if (verbosity_str == "" ) { 321 throw new BuildException("Error - no value found in 'verbosity' attribute!"); 322 } 323 324 try { 325 this.verbosity = Integer.parseInt(verbosity_str); 326 } catch( NumberFormatException nfe ) { 327 throw new BuildException("Error - invalid line numbers given in 'verbosity' attribute! '" 328 + verbosity_str + "'" ); 329 } 330 331 } 299 332 300 333 public void setPattern(String pattern) {
Note:
See TracChangeset
for help on using the changeset viewer.