| java.lang.Object com.methodhead.res.ResUtils
ResUtils | public class ResUtils (Code) | | A collection of utility methods used in the
com.methodhead.res package.
|
Method Summary | |
public static String | cleanPath(String path) Replaces any consecutive file separators with a single file separator. | public static void | copyFile(File from, File to) Copies from to to; if from is a directory, it
is recursively copied. | public static void | deleteFile(File file) Deletes file; if file is a directory, it is recursively
deleted. | public static File | getFile(HttpServlet servlet, String path, String fileName) Returns a file by combining path and fileName and using
it as a path relative to the webapp. | public static FileManager | getFileManager(ResPolicy policy, HttpServletRequest request) NOT UNIT TESTED Returns the file manager in the request, creating and
initializing one if necessary. | public static FileTree | getFileTree(ResPolicy policy, HttpServletRequest request) Returns the file tree from the session, creating and initializing it if
necessary. | public static ResPolicy | getPolicy(ActionMapping mapping) NOT UNIT TESTED Instantiates the ResPolicy for defined in
mapping's parameter. | public static boolean | isPathDescendent(String parentPath, String path) Returns true if path is contained by parentPath
at some level. | public static boolean | isSafeFileName(String name) Returns true if name has an unsafe file extension
(.jsp to .do). | public static boolean | isValidFileName(String name) Returns true if name doesn't contain any invalid
characters (\, /). | public static boolean | isValidPath(String path) Returns true if path doesn't contain any invalid
characters sequences (..). | public static String[] | nodesToFileNames(List nodes) NOT UNIT TESTED Converts a list of FoldingTreeNodes (as created
in
ResForm.reset ResForm.reset() ) to an array of filenames. | public static String | trimPath(String path) Trims any leading or trailing spaces and separator characters from
path. |
cleanPath | public static String cleanPath(String path)(Code) | | Replaces any consecutive file separators with a single file separator.
|
copyFile | public static void copyFile(File from, File to) throws ResException, IOException(Code) | | Copies from to to; if from is a directory, it
is recursively copied. If to is exists and is not a directory,
it is overwritten. If to is exists and is a directory, the
contents of from are copied over the contents of to. If
to exists, but is a directory when from is not (or vice
versa), an exception is thrown. NOT UNIT TESTED
|
deleteFile | public static void deleteFile(File file)(Code) | | Deletes file; if file is a directory, it is recursively
deleted.
|
getFile | public static File getFile(HttpServlet servlet, String path, String fileName)(Code) | | Returns a file by combining path and fileName and using
it as a path relative to the webapp.
|
getPolicy | public static ResPolicy getPolicy(ActionMapping mapping)(Code) | | NOT UNIT TESTED Instantiates the ResPolicy for defined in
mapping's parameter.
|
isPathDescendent | public static boolean isPathDescendent(String parentPath, String path)(Code) | | Returns true if path is contained by parentPath
at some level. If path equals parentPath this method
will also return true. This method is strictly a string
operation; no files are actually accessed. The path separator is always
assumed to be a forward slash (/). Any leading or trailing
spaces and separator characters are trimmed from both paths before any
tests are performed.
|
isSafeFileName | public static boolean isSafeFileName(String name)(Code) | | Returns true if name has an unsafe file extension
(.jsp to .do).
|
isValidFileName | public static boolean isValidFileName(String name)(Code) | | Returns true if name doesn't contain any invalid
characters (\, /).
|
isValidPath | public static boolean isValidPath(String path)(Code) | | Returns true if path doesn't contain any invalid
characters sequences (..).
|
nodesToFileNames | public static String[] nodesToFileNames(List nodes)(Code) | | NOT UNIT TESTED Converts a list of FoldingTreeNodes (as created
in
ResForm.reset ResForm.reset() ) to an array of filenames.
|
trimPath | public static String trimPath(String path)(Code) | | Trims any leading or trailing spaces and separator characters from
path.
|
|
|