|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrailo.commons.io.res.util.ResourceUtil
public final class ResourceUtil
Field Summary | |
---|---|
static char |
FILE_ANTI_SEPERATOR
Field FILE_ANTI_SEPERATOR |
static char |
FILE_SEPERATOR
Field FILE_SEPERATOR |
static short |
LEVEL_FILE
Field LEVEL_FILE |
static short |
LEVEL_GRAND_PARENT_FILE
Field LEVEL_GRAND_PARENT_FILE |
static short |
LEVEL_PARENT_FILE
Field LEVEL_PARENT_FILE |
static int |
MIMETYPE_CHECK_EXTENSION
|
static int |
MIMETYPE_CHECK_HEADER
|
static short |
TYPE_DIR
Field TYPE_DIR |
static short |
TYPE_FILE
Field TYPE_FILE |
Constructor Summary | |
---|---|
ResourceUtil()
|
Method Summary | |
---|---|
static void |
_deleteContent(Resource src,
ResourceFilter filter,
boolean deleteDirectories)
|
static boolean |
canRW(Resource res)
check if file is read and writable |
static Resource |
changeExtension(Resource file,
String newExtension)
change extesnion of file and return new file |
static void |
checkCopyToOK(Resource source,
Resource target)
check if copying a file is ok with the rules for the Resource interface, to not change this rules. |
static void |
checkCreateDirectoryOK(Resource resource,
boolean createParentWhenNotExists)
check if directory creation is ok with the rules for the Resource interface, to not change this rules. |
static void |
checkCreateFileOK(Resource resource,
boolean createParentWhenNotExists)
check if file creating is ok with the rules for the Resource interface, to not change this rules. |
static void |
checkGetInputStreamOK(Resource resource)
check if getting a inputstream of the file is ok with the rules for the Resource interface, to not change this rules. |
static void |
checkGetOutputStreamOK(Resource resource)
check if getting a outputstream of the file is ok with the rules for the Resource interface, to not change this rules. |
static void |
checkMoveToOK(Resource source,
Resource target)
check if moveing a file is ok with the rules for the Resource interface, to not change this rules. |
static void |
checkRemoveOK(Resource resource)
check if removing the file is ok with the rules for the Resource interface, to not change this rules. |
static void |
clear(Resource res)
|
static void |
copy(Resource src,
Resource trg)
|
static void |
copyRecursive(Resource src,
Resource trg)
copy a file or directory recursive (with his content) |
static void |
copyRecursive(Resource src,
Resource trg,
ResourceFilter filter)
copy a file or directory recursive (with his content) |
static void |
createDirectoryEL(Resource res,
boolean force)
|
static void |
createFileEL(Resource res,
boolean force)
|
static boolean |
createNewResourceEL(Resource res)
creates a new File |
static Resource |
createResource(Resource res,
short level,
short type)
create a file if possible, return file if ok, otherwise return null |
static void |
deleteContent(Resource src,
ResourceFilter filter)
|
static void |
deleteEmptyFolders(Resource res)
|
static void |
deleteFileOlderThan(Resource res,
long date,
ExtensionResourceFilter filter)
|
static int |
directrySize(Resource dir,
ResourceFilter filter)
|
static int |
directrySize(Resource dir,
ResourceNameFilter filter)
|
static boolean |
exists(Resource res)
|
static String |
getCanonicalPathEL(Resource res)
Returns the canonical form of this abstract pathname. |
static Resource |
getCanonicalResourceEL(Resource res)
Returns the canonical form of this abstract pathname. |
static ContentType |
getContentType(Resource resource)
|
static String |
getExtension(Resource res,
String defaultValue)
get the Extension of a file |
static String |
getExtension(String strFile,
String defaultValue)
get the Extension of a file |
static String |
getMimeType(Resource res,
int checkingType,
String defaultValue)
|
static String |
getMimeType(Resource res,
String defaultValue)
return the mime type of a file, dont check extension |
static String |
getName(String strFileName)
|
static String |
getPathToChild(Resource file,
Resource dir)
return diffrents of one file to a other if first is child of second otherwise return null |
static long |
getRealSize(Resource res)
return the size of the Resource, other than method length of Resource this mthod return the size of all files in a directory |
static long |
getRealSize(Resource res,
ResourceFilter filter)
return the size of the Resource, other than method length of Resource this mthod return the size of all files in a directory |
static Resource |
getResource(PageContext pc,
PageSource ps)
Deprecated. use instead PageSource.getResourceTranslated(PageContext) |
static Resource |
getResource(PageContext pc,
PageSource ps,
Resource defaultValue)
|
static boolean |
isChildOf(Resource file,
Resource dir)
check if file is a child of given directory |
static boolean |
isEmpty(Resource res)
return if Resource is empty, means is directory and has no children or a empty file, if not exist return false. |
static boolean |
isEmptyDirectory(Resource res)
|
static boolean |
isEmptyFile(Resource res)
|
static boolean |
isUNCPath(String path)
|
static Resource[] |
listResources(Resource[] resources,
ResourceFilter filter)
list childrn of all given resources |
static Resource[] |
listResources(Resource res,
ResourceFilter filter)
|
static Resource[] |
merge(Resource[] srcs,
Resource[] trgs)
|
static String |
merge(String parent,
String child)
merge to path parts to one |
static void |
moveTo(Resource src,
Resource dest)
|
static String[] |
names(Resource[] resources)
|
static String |
prettifyPath(String path)
|
static void |
removeChildren(Resource res)
|
static void |
removeChildren(Resource res,
ResourceFilter filter)
|
static void |
removeChildren(Resource res,
ResourceNameFilter filter)
|
static void |
removeChildrenEL(Resource res)
|
static void |
removeChildrenEL(Resource res,
ResourceFilter filter)
|
static void |
removeChildrenEL(Resource res,
ResourceNameFilter filter)
|
static void |
removeEL(Resource res,
boolean force)
|
static String |
removeScheme(String scheme,
String path)
|
static void |
setAttribute(Resource res,
String attributes)
|
static String[] |
splitFileName(String fileName)
split a FileName in Parts |
static Resource |
toExactResource(Resource res)
transalte the path of the file to a existing file path by changing case of letters Works only on Linux, becasue Example Unix: we have a existing file with path "/usr/virtual/myFile.txt" now you call this method with path "/Usr/Virtual/myfile.txt" the result of the method will be "/usr/virtual/myFile.txt" if there are more file with rhe same name but different cases Example: /usr/virtual/myFile.txt /usr/virtual/myfile.txt /Usr/Virtual/myFile.txt the nearest case wil returned |
static Resource |
toResource(File file)
|
static Resource |
toResourceExisting(Config config,
String path)
|
static Resource |
toResourceExisting(PageContext pc,
String path)
cast a String (argumet destination) to a File Object, if destination is not a absolute, file object will be relative to current position (get from PageContext) file must exist otherwise throw exception |
static Resource |
toResourceExisting(PageContext pc,
String path,
boolean allowRealpath)
|
static Resource |
toResourceExistingParent(PageContext pc,
String destination)
cast a String (argumet destination) to a File Object, if destination is not a absolute, file object will be relative to current position (get from PageContext) at least parent must exist |
static Resource |
toResourceExistingParent(PageContext pc,
String destination,
boolean allowRealpath)
|
static Resource |
toResourceNotExisting(Config config,
String path)
|
static Resource |
toResourceNotExisting(PageContext pc,
String destination)
cast a String (argument destination) to a File Object, if destination is not a absolute, file object will be relative to current position (get from PageContext) existing file is prefered but dont must exist |
static Resource |
toResourceNotExisting(PageContext pc,
String destination,
boolean allowRealpath)
|
static void |
touch(Resource res)
similat to linux bash fuction toch, create file if not exist oherwise change last modified date |
static String |
translateAttribute(String attributes)
sets attributes of a file on Windows system |
static String |
translatePath(String path,
boolean slashAdBegin,
boolean slashAddEnd)
|
static String[] |
translatePathName(String path)
transalte a path in a proper form and cut name away example susi\petere -> /susi/ and peter |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MIMETYPE_CHECK_EXTENSION
public static final int MIMETYPE_CHECK_HEADER
public static final char FILE_SEPERATOR
FILE_SEPERATOR
public static final char FILE_ANTI_SEPERATOR
FILE_ANTI_SEPERATOR
public static final short TYPE_DIR
TYPE_DIR
public static final short TYPE_FILE
TYPE_FILE
public static final short LEVEL_FILE
LEVEL_FILE
public static final short LEVEL_PARENT_FILE
LEVEL_PARENT_FILE
public static final short LEVEL_GRAND_PARENT_FILE
LEVEL_GRAND_PARENT_FILE
Constructor Detail |
---|
public ResourceUtil()
Method Detail |
---|
public static Resource toResourceExisting(PageContext pc, String path) throws ExpressionException
pc
- Page Context to et actuell position in filesystempath
- relative or absolute path for file object
ExpressionException
public static Resource toResourceExisting(PageContext pc, String path, boolean allowRealpath) throws ExpressionException
ExpressionException
public static Resource toResourceExisting(Config config, String path) throws ExpressionException
ExpressionException
public static Resource toResourceNotExisting(Config config, String path)
public static Resource toResourceExistingParent(PageContext pc, String destination) throws ExpressionException
pc
- Page Context to et actuell position in filesystemdestination
- relative or absolute path for file object
ExpressionException
public static Resource toResourceExistingParent(PageContext pc, String destination, boolean allowRealpath) throws ExpressionException
ExpressionException
public static Resource toResourceNotExisting(PageContext pc, String destination)
pc
- Page Context to et actuell position in filesystemdestination
- relative or absolute path for file object
public static Resource toResourceNotExisting(PageContext pc, String destination, boolean allowRealpath)
public static boolean isUNCPath(String path)
public static Resource toExactResource(Resource res)
res
-
public static Resource createResource(Resource res, short level, short type)
res
- file to touchlevel
- touch also parent and grand parenttype
- is file or directory
public static void setAttribute(Resource res, String attributes) throws IOException
IOException
public static String translateAttribute(String attributes) throws IOException
res
- attributes
-
PageException
IOException
public static String translatePath(String path, boolean slashAdBegin, boolean slashAddEnd)
public static String[] translatePathName(String path)
path
-
public static String prettifyPath(String path)
public static String removeScheme(String scheme, String path)
public static String merge(String parent, String child)
parent
- child
-
public static String getCanonicalPathEL(Resource res)
res
- file to get canoncial form from it
SecurityException
- If a required system property value cannot be accessed.public static Resource getCanonicalResourceEL(Resource res)
res
- file to get canoncial form from it
SecurityException
- If a required system property value cannot be accessed.public static boolean createNewResourceEL(Resource res)
res
-
public static boolean exists(Resource res)
public static boolean canRW(Resource res)
res
-
public static void touch(Resource res) throws IOException
res
-
IOException
public static void clear(Resource res) throws IOException
IOException
public static String getMimeType(Resource res, String defaultValue)
res
- defaultValue
-
public static String getMimeType(Resource res, int checkingType, String defaultValue)
public static boolean isChildOf(Resource file, Resource dir)
file
- file to searchdir
- directory to search
public static String getPathToChild(Resource file, Resource dir)
file
- file to searchdir
- directory to searchpublic static String getExtension(Resource res, String defaultValue)
res
-
public static String getExtension(String strFile, String defaultValue)
strFile
-
public static String getName(String strFileName)
public static String[] splitFileName(String fileName)
fileName
-
public static Resource changeExtension(Resource file, String newExtension)
file
- newExtension
-
public static void deleteContent(Resource src, ResourceFilter filter)
res
- delete the content of a directorypublic static void _deleteContent(Resource src, ResourceFilter filter, boolean deleteDirectories)
public static void copyRecursive(Resource src, Resource trg) throws IOException
res
- file or directory to delete
IOException
FileNotFoundException
public static void copyRecursive(Resource src, Resource trg, ResourceFilter filter) throws IOException
src
- trg
- filter
-
IOException
FileNotFoundException
public static void copy(Resource src, Resource trg) throws IOException
IOException
public static void removeChildren(Resource res) throws IOException
IOException
public static void removeChildren(Resource res, ResourceNameFilter filter) throws IOException
IOException
public static void removeChildren(Resource res, ResourceFilter filter) throws IOException
IOException
public static void removeChildrenEL(Resource res, ResourceNameFilter filter)
public static void removeChildrenEL(Resource res, ResourceFilter filter)
public static void removeChildrenEL(Resource res)
public static void removeEL(Resource res, boolean force)
public static void createFileEL(Resource res, boolean force)
public static void createDirectoryEL(Resource res, boolean force)
public static ContentType getContentType(Resource resource)
public static void moveTo(Resource src, Resource dest) throws IOException
IOException
public static long getRealSize(Resource res)
collectionDir
-
public static long getRealSize(Resource res, ResourceFilter filter)
collectionDir
-
public static boolean isEmpty(Resource res)
res
-
public static boolean isEmptyDirectory(Resource res)
public static boolean isEmptyFile(Resource res)
public static Resource toResource(File file)
public static Resource[] listResources(Resource[] resources, ResourceFilter filter)
resources
-
public static Resource[] listResources(Resource res, ResourceFilter filter)
public static void deleteFileOlderThan(Resource res, long date, ExtensionResourceFilter filter)
public static void checkCreateDirectoryOK(Resource resource, boolean createParentWhenNotExists) throws IOException
resource
- createParentWhenNotExists
-
IOException
public static void checkCreateFileOK(Resource resource, boolean createParentWhenNotExists) throws IOException
resource
- createParentWhenNotExists
-
IOException
public static void checkCopyToOK(Resource source, Resource target) throws IOException
source
- target
-
IOException
public static void checkMoveToOK(Resource source, Resource target) throws IOException
source
- target
-
IOException
public static void checkGetInputStreamOK(Resource resource) throws IOException
resource
-
IOException
public static void checkGetOutputStreamOK(Resource resource) throws IOException
resource
-
IOException
public static void checkRemoveOK(Resource resource) throws IOException
resource
-
IOException
public static void deleteEmptyFolders(Resource res) throws IOException
IOException
public static Resource getResource(PageContext pc, PageSource ps) throws PageException
PageSource.getResourceTranslated(PageContext)
pc
- the Page Context Object
PageException
public static Resource getResource(PageContext pc, PageSource ps, Resource defaultValue)
public static int directrySize(Resource dir, ResourceFilter filter)
public static int directrySize(Resource dir, ResourceNameFilter filter)
public static String[] names(Resource[] resources)
public static Resource[] merge(Resource[] srcs, Resource[] trgs)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |