Package org.mapfish.print
Class FileUtils
- java.lang.Object
-
- org.mapfish.print.FileUtils
-
public final class FileUtils extends java.lang.Object
Methods for interacting with files. Such things and verifying the files are in the correct directory, Converting URLs to file objects.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertFileIsInConfigDir(Configuration configuration, java.io.File file)
Verify that the file is within the configuration directory.static boolean
assertIsSubDirectory(java.lang.String descriptorOfBase, java.io.File child, java.io.File... baseFiles)
Verify that the file is within the base directory.static java.net.URL
testForLegalFileUrl(Configuration configuration, java.net.URL url)
Check if the url is a file url which is either relative to the configuration directory or refers to a file in the configuration directory.
-
-
-
Method Detail
-
testForLegalFileUrl
public static java.net.URL testForLegalFileUrl(Configuration configuration, java.net.URL url)
Check if the url is a file url which is either relative to the configuration directory or refers to a file in the configuration directory.The correct file url is returned or the original if not a file url. If an illegal file url (one that does not refer to a file within the configuration directory or is relative to the configuration directory) then an exception is thrown.
- Parameters:
url
- the url to testconfiguration
- the configuration to test relativity.
-
assertFileIsInConfigDir
public static void assertFileIsInConfigDir(Configuration configuration, java.io.File file)
Verify that the file is within the configuration directory.- Parameters:
configuration
- the configuration to test relativity.file
- the file to test
-
assertIsSubDirectory
public static boolean assertIsSubDirectory(java.lang.String descriptorOfBase, java.io.File child, java.io.File... baseFiles)
Verify that the file is within the base directory.IllegalFileAccessException
will be thrown if the assertion does not hold.- Parameters:
descriptorOfBase
- a simple description of the base file, for example: configurationchild
- the file to test that is is a child of base.baseFiles
- the directories that can legally contain the child.
-
-