Beispiel #1
0
 /**
  * Returns its argument with all file separator characters replaced so that they match the local
  * OS conventions.
  *
  * @param source the path to convert
  * @return the converted path
  */
 public static String translateFile(String source) {
   if (source == null) {
     return "";
   }
   final StringBuffer result = new StringBuffer(source);
   for (int i = 0; i < result.length(); i++) {
     translateFileSep(result, i);
   }
   return result.toString();
 }
Beispiel #2
0
 /**
  * Splits a PATH (with : or ; as separators) into its parts.
  *
  * @param project the project to use
  * @param source a <code>String</code> value
  * @return an array of strings, one for each path element
  */
 public static String[] translatePath(Project project, String source) {
   final Vector<String> result = new Vector<String>();
   if (source == null) {
     return new String[0];
   }
   PathTokenizer tok = new PathTokenizer(source);
   StringBuffer element = new StringBuffer();
   while (tok.hasMoreTokens()) {
     String pathElement = tok.nextToken();
     try {
       element.append(resolveFile(project, pathElement).getPath());
     } catch (BuildException e) {
       project.log(
           "Dropping path element " + pathElement + " as it is not valid relative to the project",
           Project.MSG_VERBOSE);
     }
     for (int i = 0; i < element.length(); i++) {
       translateFileSep(element, i);
     }
     result.addElement(element.toString());
     element = new StringBuffer();
   }
   return result.toArray(new String[result.size()]);
 }