railo.commons.io.res.util
Class ResourceUtilImpl

java.lang.Object
  extended by railo.commons.io.res.util.ResourceUtilImpl
All Implemented Interfaces:
ResourceUtil

public class ResourceUtilImpl
extends Object
implements ResourceUtil


Field Summary
 
Fields inherited from interface railo.runtime.util.ResourceUtil
FILE_ANTI_SEPERATOR, FILE_SEPERATOR, LEVEL_FILE, LEVEL_GRAND_PARENT_FILE, LEVEL_PARENT_FILE, TYPE_DIR, TYPE_FILE
 
Method Summary
 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.
 void checkCreateDirectoryOK(Resource resource, boolean createParentWhenNotExists)
          check if directory creation is ok with the rules for the Resource interface, to not change this rules.
 void checkCreateFileOK(Resource resource, boolean createParentWhenNotExists)
          check if file creating is ok with the rules for the Resource interface, to not change this rules.
 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.
 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.
 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.
 void checkRemoveOK(Resource resource)
          check if removing the file is ok with the rules for the Resource interface, to not change this rules.
 String contractPath(PageContext pc, String path)
           
 void copyRecursive(Resource src, Resource trg)
          copy a file or directory recursive (with his content)
 void copyRecursive(Resource src, Resource trg, ResourceFilter filter)
          copy a file or directory recursive (with his content)
 Resource createResource(Resource res, short level, short type)
          create a file if possible, return file if ok, otherwise return null
 String getExtension(Resource res)
          get the Extension of a file resource
 String getExtension(Resource res, String defaultValue)
          get the Extension of a file resource
 String getExtension(String strFile)
          get the Extension of a file
 String getExtension(String strFile, String defaultValue)
          get the Extension of a file resource
static ResourceUtilImpl getInstance()
           
 String getMimeType(byte[] barr, String defaultValue)
          return the mime type of a byte array
 String getMimeType(Resource res, String defaultValue)
          return the mime type of a file, does not check the extension of the file, it checks the header
 String getPathToChild(Resource file, Resource dir)
          return diffrents of one file to a other if first is child of second otherwise return null
 boolean isChildOf(Resource file, Resource dir)
          check if file is a child of given directory
 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.
 boolean isEmptyDirectory(Resource res)
           
 boolean isEmptyFile(Resource res)
           
 String merge(String parent, String child)
           
 void moveTo(Resource src, Resource dest)
           
 void removeChildren(Resource res)
           
 void removeChildren(Resource res, ResourceFilter filter)
           
 void removeChildren(Resource res, ResourceNameFilter filter)
           
 String removeScheme(String scheme, String path)
           
 void setAttribute(Resource res, String attributes)
          sets a attribute to the resource
 Resource toResourceExisting(PageContext pc, String path)
          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) file must exist otherwise throw exception
 Resource toResourceExistingParent(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) at least parent must exist
 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
 String toString(Resource r, String charset)
           
 String translatePath(String path, boolean slashAdBegin, boolean slashAddEnd)
           
 String[] translatePathName(String path)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ResourceUtilImpl getInstance()

checkCopyToOK

public void checkCopyToOK(Resource source,
                          Resource target)
                   throws IOException
Description copied from interface: ResourceUtil
check if copying a file is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkCopyToOK in interface ResourceUtil
Throws:
IOException

checkCreateDirectoryOK

public void checkCreateDirectoryOK(Resource resource,
                                   boolean createParentWhenNotExists)
                            throws IOException
Description copied from interface: ResourceUtil
check if directory creation is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkCreateDirectoryOK in interface ResourceUtil
Throws:
IOException

checkCreateFileOK

public void checkCreateFileOK(Resource resource,
                              boolean createParentWhenNotExists)
                       throws IOException
Description copied from interface: ResourceUtil
check if file creating is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkCreateFileOK in interface ResourceUtil
Throws:
IOException

checkGetInputStreamOK

public void checkGetInputStreamOK(Resource resource)
                           throws IOException
Description copied from interface: ResourceUtil
check if getting a inputstream of the file is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkGetInputStreamOK in interface ResourceUtil
Throws:
IOException

checkGetOutputStreamOK

public void checkGetOutputStreamOK(Resource resource)
                            throws IOException
Description copied from interface: ResourceUtil
check if getting a outputstream of the file is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkGetOutputStreamOK in interface ResourceUtil
Throws:
IOException

checkMoveToOK

public void checkMoveToOK(Resource source,
                          Resource target)
                   throws IOException
Description copied from interface: ResourceUtil
check if moveing a file is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkMoveToOK in interface ResourceUtil
Throws:
IOException

checkRemoveOK

public void checkRemoveOK(Resource resource)
                   throws IOException
Description copied from interface: ResourceUtil
check if removing the file is ok with the rules for the Resource interface, to not change this rules.

Specified by:
checkRemoveOK in interface ResourceUtil
Throws:
IOException

copyRecursive

public void copyRecursive(Resource src,
                          Resource trg)
                   throws IOException
Description copied from interface: ResourceUtil
copy a file or directory recursive (with his content)

Specified by:
copyRecursive in interface ResourceUtil
Throws:
IOException
FileNotFoundException

copyRecursive

public void copyRecursive(Resource src,
                          Resource trg,
                          ResourceFilter filter)
                   throws IOException
Description copied from interface: ResourceUtil
copy a file or directory recursive (with his content)

Specified by:
copyRecursive in interface ResourceUtil
Throws:
IOException
FileNotFoundException

createResource

public Resource createResource(Resource res,
                               short level,
                               short type)
Description copied from interface: ResourceUtil
create a file if possible, return file if ok, otherwise return null

Specified by:
createResource in interface ResourceUtil
Parameters:
res - file to touch
level - touch also parent and grand parent
type - is file or directory
Returns:
file if exists, otherwise null

getExtension

public String getExtension(Resource res)
Description copied from interface: ResourceUtil
get the Extension of a file resource

Specified by:
getExtension in interface ResourceUtil
Returns:
extension of file

getExtension

public String getExtension(Resource res,
                           String defaultValue)
Description copied from interface: ResourceUtil
get the Extension of a file resource

Specified by:
getExtension in interface ResourceUtil
Returns:
extension of file

getExtension

public String getExtension(String strFile)
Description copied from interface: ResourceUtil
get the Extension of a file

Specified by:
getExtension in interface ResourceUtil
Returns:
extension of file

getExtension

public String getExtension(String strFile,
                           String defaultValue)
Description copied from interface: ResourceUtil
get the Extension of a file resource

Specified by:
getExtension in interface ResourceUtil
Returns:
extension of file

getMimeType

public String getMimeType(Resource res,
                          String defaultValue)
Description copied from interface: ResourceUtil
return the mime type of a file, does not check the extension of the file, it checks the header

Specified by:
getMimeType in interface ResourceUtil
Returns:
mime type of the file

getMimeType

public String getMimeType(byte[] barr,
                          String defaultValue)
Description copied from interface: ResourceUtil
return the mime type of a byte array

Specified by:
getMimeType in interface ResourceUtil
Returns:
mime type of the file

getPathToChild

public String getPathToChild(Resource file,
                             Resource dir)
Description copied from interface: ResourceUtil
return diffrents of one file to a other if first is child of second otherwise return null

Specified by:
getPathToChild in interface ResourceUtil
Parameters:
file - file to search
dir - directory to search

isChildOf

public boolean isChildOf(Resource file,
                         Resource dir)
Description copied from interface: ResourceUtil
check if file is a child of given directory

Specified by:
isChildOf in interface ResourceUtil
Parameters:
file - file to search
dir - directory to search
Returns:
is inside or not

isEmpty

public boolean isEmpty(Resource res)
Description copied from interface: ResourceUtil
return if Resource is empty, means is directory and has no children or a empty file, if not exist return false.

Specified by:
isEmpty in interface ResourceUtil

isEmptyDirectory

public boolean isEmptyDirectory(Resource res)
Specified by:
isEmptyDirectory in interface ResourceUtil

isEmptyFile

public boolean isEmptyFile(Resource res)
Specified by:
isEmptyFile in interface ResourceUtil

merge

public String merge(String parent,
                    String child)
Specified by:
merge in interface ResourceUtil

moveTo

public void moveTo(Resource src,
                   Resource dest)
            throws IOException
Specified by:
moveTo in interface ResourceUtil
Throws:
IOException

removeChildren

public void removeChildren(Resource res)
                    throws IOException
Specified by:
removeChildren in interface ResourceUtil
Throws:
IOException

removeChildren

public void removeChildren(Resource res,
                           ResourceNameFilter filter)
                    throws IOException
Specified by:
removeChildren in interface ResourceUtil
Throws:
IOException

removeChildren

public void removeChildren(Resource res,
                           ResourceFilter filter)
                    throws IOException
Specified by:
removeChildren in interface ResourceUtil
Throws:
IOException

removeScheme

public String removeScheme(String scheme,
                           String path)
Specified by:
removeScheme in interface ResourceUtil

setAttribute

public void setAttribute(Resource res,
                         String attributes)
                  throws IOException
Description copied from interface: ResourceUtil
sets a attribute to the resource

Specified by:
setAttribute in interface ResourceUtil
Throws:
IOException

toResourceExisting

public Resource toResourceExisting(PageContext pc,
                                   String path)
                            throws PageException
Description copied from interface: ResourceUtil
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) file must exist otherwise throw exception

Specified by:
toResourceExisting in interface ResourceUtil
Parameters:
pc - Page Context to et actuell position in filesystem
path - relative or absolute path for file object
Returns:
file object from destination
Throws:
PageException

toResourceExistingParent

public Resource toResourceExistingParent(PageContext pc,
                                         String destination)
                                  throws PageException
Description copied from interface: ResourceUtil
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) at least parent must exist

Specified by:
toResourceExistingParent in interface ResourceUtil
Parameters:
pc - Page Context to et actuell position in filesystem
destination - relative or absolute path for file object
Returns:
file object from destination
Throws:
PageException

toResourceNotExisting

public Resource toResourceNotExisting(PageContext pc,
                                      String destination)
Description copied from interface: ResourceUtil
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

Specified by:
toResourceNotExisting in interface ResourceUtil
Parameters:
pc - Page Context to et actuell position in filesystem
destination - relative or absolute path for file object
Returns:
file object from destination

translatePath

public String translatePath(String path,
                            boolean slashAdBegin,
                            boolean slashAddEnd)
Specified by:
translatePath in interface ResourceUtil

translatePathName

public String[] translatePathName(String path)
Specified by:
translatePathName in interface ResourceUtil

toString

public String toString(Resource r,
                       String charset)
                throws IOException
Specified by:
toString in interface ResourceUtil
Throws:
IOException

contractPath

public String contractPath(PageContext pc,
                           String path)
Specified by:
contractPath in interface ResourceUtil


Copyright © 2012 Railo