mbenson 2005/02/22 10:05:49
Modified: src/main/org/apache/tools/ant/taskdefs PathConvert.java
Log:
More LOC bumming
Revision Changes Path
1.39 +10 -45
ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
Index: PathConvert.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- PathConvert.java 22 Feb 2005 17:54:44 -0000 1.38
+++ PathConvert.java 22 Feb 2005 18:05:48 -0000 1.39
@@ -156,7 +156,7 @@
*/
public static class TargetOs extends EnumeratedAttribute {
/**
- * @return the list of values for this enumerated attribute
+ * @return the list of values for this enumerated attribute.
*/
public String[] getValues() {
return new String[]{"windows", "unix", "netware", "os/2",
"tandem"};
@@ -291,31 +291,21 @@
// If we are a reference, create a Path from the reference
if (isReference()) {
path = new Path(getProject()).createPath();
-
Object obj = refid.getReferencedObject(getProject());
if (obj instanceof Path) {
path.setRefid(refid);
} else if (obj instanceof FileSet) {
- FileSet fs = (FileSet) obj;
-
- path.addFileset(fs);
+ path.addFileset((FileSet) obj);
} else if (obj instanceof DirSet) {
- DirSet ds = (DirSet) obj;
-
- path.addDirset(ds);
+ path.addDirset((DirSet) obj);
} else if (obj instanceof FileList) {
- FileList fl = (FileList) obj;
-
- path.addFilelist(fl);
-
+ path.addFilelist((FileList) obj);
} else {
throw new BuildException("'refid' does not refer to a "
- + "path, fileset, dirset, or "
- + "filelist.");
+ + "path, fileset, dirset, or filelist.");
}
}
-
validateSetup(); // validate our setup
// Currently, we deal with only two path formats: Unix and
Windows
@@ -344,11 +334,8 @@
}
elems = (String[]) ret.toArray(new String[] {});
}
-
for (int i = 0; i < elems.length; i++) {
- String elem = elems[i];
-
- elem = mapElement(elem); // Apply the path prefix map
+ String elem = mapElement(elems[i]); // Apply the path prefix
map
// Now convert the path and file separator characters from
the
// current os to the target os.
@@ -356,35 +343,21 @@
if (i != 0) {
rslt.append(pathSep);
}
-
StringTokenizer stDirectory =
new StringTokenizer(elem, fromDirSep, true);
- String token = null;
while (stDirectory.hasMoreTokens()) {
- token = stDirectory.nextToken();
-
- if (fromDirSep.equals(token)) {
- rslt.append(dirSep);
- } else {
- rslt.append(token);
- }
+ String token = stDirectory.nextToken();
+ rslt.append(fromDirSep.equals(token) ? dirSep : token);
}
}
-
// Place the result into the specified property,
// unless setonempty == false
- String value = rslt.toString();
- if (setonempty) {
+ if (setonempty || rslt.length() > 0) {
+ String value = rslt.toString();
log("Set property " + property + " = " + value,
Project.MSG_VERBOSE);
getProject().setNewProperty(property, value);
- } else {
- if (rslt.length() > 0) {
- log("Set property " + property + " = " + value,
- Project.MSG_VERBOSE);
- getProject().setNewProperty(property, value);
- }
}
} finally {
path = savedPath;
@@ -393,7 +366,6 @@
}
}
-
/**
* Apply the configured map to a path element. The map is used to convert
* between Windows drive letters and Unix paths. If no map is configured,
@@ -424,7 +396,6 @@
}
}
}
-
return elem;
}
@@ -463,18 +434,15 @@
if (path == null) {
throw new BuildException("You must specify a path to convert");
}
-
if (property == null) {
throw new BuildException("You must specify a property");
}
-
// Must either have a target OS or both a dirSep and pathSep
if (targetOS == null && pathSep == null && dirSep == null) {
throw new BuildException("You must specify at least one of "
+ "targetOS, dirSep, or pathSep");
}
-
// Determine the separator strings. The dirsep and pathsep
attributes
// override the targetOS settings.
String dsep = File.separator;
@@ -484,17 +452,14 @@
psep = targetWindows ? ";" : ":";
dsep = targetWindows ? "\\" : "/";
}
-
if (pathSep != null) {
// override with pathsep=
psep = pathSep;
}
-
if (dirSep != null) {
// override with dirsep=
dsep = dirSep;
}
-
pathSep = psep;
dirSep = dsep;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]