Changeset 17349 for other-projects
- Timestamp:
- 2008-09-19T13:50:50+12:00 (16 years ago)
- Location:
- other-projects/trunk/anttasks
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/anttasks
- Property svn:ignore
-
old new 1 1 classes 2 2 lib 3 test 3 4
-
- Property svn:ignore
-
other-projects/trunk/anttasks/build.xml
r17295 r17349 33 33 </target> 34 34 35 <target name="test-setup"> 36 <path id="test.classpath"> 37 <pathelement path="lib/anttasks.jar"/> 38 <pathelement path="${crypt.jar}"/> 39 </path> 40 <typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="test.classpath"/> 41 <typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="test.classpath"/> 42 <mkdir dir="test"/> 43 </target> 44 45 <target name="test" depends="test-setup"> 46 <antcall target="test-rsr"/> 47 </target> 48 49 <target name="test-rsr" depends="test-setup"> 50 51 <echo file="test/rsr1.txt">This is a test of the rsr task 52 To see if it can replace things with other things 53 Or if those things 54 Stay the same things 55 56 Or not 57 58 Replace with a path 59 @path@ 60 61 Replace with a path, with winPath on 62 @path-with-winpath@ 63 64 65 </echo> 66 <copy file="test/rsr1.txt" tofile="test/rsr2.txt"/> 67 <copy file="test/rsr1.txt" tofile="test/rsr3.txt"/> 68 <copy file="test/rsr1.txt" tofile="test/rsr4.txt"/> 69 70 <rsr file="test/rsr1.txt" pattern="things" replacement="strings"/> 71 72 <rsr file="test/rsr2.txt"> 73 <job pattern="things" replacement="objects"/> 74 <job pattern="Or" replacement="And"/> 75 </rsr> 76 77 <rsr file="test/rsr3.txt" pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/> 78 <rsr file="test/rsr3.txt" pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/> 79 80 <rsr file="test/rsr4.txt"> 81 <job pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/> 82 <job pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/> 83 </rsr> 84 85 </target> 86 87 <target name="test-clean"> 88 <delete dir="test"/> 89 </target> 90 91 92 93 35 94 36 95 -
other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplace.java
r17303 r17349 130 130 String oldLine = line; 131 131 if ( pattern != null ) { 132 line = line.replaceAll((String)pattern, (String)replacement); 132 String rp = replacement; 133 if ( winPath ) { 134 rp = rp.replaceAll("\\\\","\\\\\\\\"); 135 } 136 line = line.replaceAll((String)pattern, (String)rp); 133 137 } else { 134 138 for ( int i=0; i<jobs.size(); i++ ) { 135 139 String rp = ((RegexSearchReplaceJob)(jobs.get(i))).getReplacement(); 136 if ( winPath) {140 if ( ((RegexSearchReplaceJob)(jobs.get(i))).getWinPath() ) { 137 141 rp = rp.replaceAll("\\\\","\\\\\\\\"); 138 142 } … … 211 215 public void setReplacement(String replacement) { 212 216 replacement = replacement.replaceAll( "\\\\", "\\\\\\\\" ); 213 if ( winPath ) {214 replacement = replacement.replaceAll("\\\\","\\\\\\\\");215 }216 217 this.replacement = replacement; 217 218 } -
other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplaceJob.java
r17295 r17349 2 2 public class RegexSearchReplaceJob extends org.apache.tools.ant.types.DataType { 3 3 4 public String pattern = null; 5 public String replacement = null; 4 String pattern = null; 5 String replacement = null; 6 boolean winPath = false; 6 7 7 8 public void setPattern(String pattern) { … … 14 15 } 15 16 17 public void setWinPath( boolean winPath ) { 18 this.winPath = winPath; 19 } 20 16 21 public String getPattern() { 17 22 return pattern; … … 20 25 return replacement; 21 26 } 27 public boolean getWinPath() { 28 return winPath; 29 } 22 30 23 31 }
Note:
See TracChangeset
for help on using the changeset viewer.