1 7 8 package org.jboss.util; 9 10 import java.io.File ; 11 12 19 public class DirectoryBuilder 20 { 21 protected File root; 22 23 public DirectoryBuilder() { 24 } 26 27 public DirectoryBuilder(final File root) { 28 this.root = root; 29 } 30 31 public DirectoryBuilder(final File root, final File child) { 32 this(root); 33 cd(child); 34 } 35 36 public DirectoryBuilder(final String rootname) { 37 this(new File (rootname)); 38 } 39 40 public DirectoryBuilder(final String rootname, final String childname) { 41 this(new File (rootname), new File (childname)); 42 } 43 44 public DirectoryBuilder cd(final File child) { 45 if (child.isAbsolute()) { 46 root = child; 47 } 48 else { 49 root = new File (root, child.getPath()); 50 } 51 return this; 52 } 53 54 public DirectoryBuilder cd(final String childname) { 55 return cd(new File (childname)); 56 } 57 58 public File get() { 59 return root; 60 } 61 62 public String toString() { 63 return root.toString(); 64 } 65 } 66 | Popular Tags |