FileDocCategorySizeDatePackage
CSUtil.javaAPI DocAndroid 1.5 API1829Wed May 06 22:41:10 BST 2009org.clearsilver

CSUtil

public class CSUtil extends Object
Utility class containing helper methods
author
smarti@google.com (Sergio Marti)

Fields Summary
public static final String
HDF_LOADPATHS
Constructors Summary
private CSUtil()

 
Methods Summary
public static java.util.ListgetLoadPaths(HDF hdf)
Helper function that returns a concatenation of the loadpaths in the provided HDF.

param
hdf an HDF structure containing load paths.
return
A list of loadpaths in order in which to search.
throws
NullPointerException if no loadpaths are found.


                                            
       
    List<String> list = new LinkedList<String>();
    HDF loadpathsHdf = hdf.getObj(HDF_LOADPATHS);
    if (loadpathsHdf == null) {
      throw new NullPointerException("No HDF loadpaths located in the specified"
          + " HDF structure");
    }
    for (HDF lpHdf = loadpathsHdf.objChild(); lpHdf != null;
        lpHdf = lpHdf.objNext()) {
      list.add(lpHdf.objValue());
    }
    return list;
  
public static java.io.FilelocateFile(java.util.List loadpaths, java.lang.String filename)
Given an ordered list of directories to look in, locate the specified file. Returns null if file not found.

param
loadpaths the ordered list of paths to search.
param
filename the name of the file.
return
a File object corresponding to the file. null if file not found.

    if (filename == null) {
      throw new NullPointerException("No filename provided");
    }
    if (loadpaths == null) {
      throw new NullPointerException("No loadpaths provided.");
    }
    for (String path : loadpaths) {
      File file = new File(path, filename);
      if (file.exists()) {
        return file;
      }
    }
    return null;