1 4 package com.tc.test; 5 6 import com.tc.util.Assert; 7 8 import java.io.File ; 9 import java.io.IOException ; 10 11 15 public abstract class BaseDirectoryHelper { 16 17 private final Class theClass; 18 private File directoryPath; 19 private File theDirectory; 20 21 protected BaseDirectoryHelper(Class theClass, String directoryPath) { 22 Assert.assertNotNull(theClass); 23 this.theClass = theClass; 24 this.directoryPath = new File (directoryPath).getAbsoluteFile(); 25 } 26 27 public synchronized File getDirectory() throws IOException { 28 if (this.theDirectory == null) { 29 this.theDirectory = fetchDirectory(); 30 } 31 32 return this.theDirectory; 33 } 34 35 public File getFile(String path) throws IOException { 36 return new File (getDirectory(), path); 37 } 38 39 protected abstract File fetchDirectory() throws IOException ; 40 41 protected final File getRoot() { 42 return this.directoryPath; 43 } 44 45 protected final Class getTargetClass() { 46 return this.theClass; 47 } 48 49 } | Popular Tags |