Package org.apache.sling.feature.io
Class IOUtils
- java.lang.Object
-
- org.apache.sling.feature.io.IOUtils
-
public class IOUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_DIRECTORY
The default directory to search for features.static String
DEFAULT_FEATURE_FILE
The default name of the feature file.static String
EXTENSION_FEATURE_ARCHIVE
The extension for a feature file.static String
EXTENSION_FEATURE_FILE
The extension for a feature file.static String
EXTENSION_REF_FILE
The extension for a reference file.
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<String>
getFeatureFiles(File homeDirectory, String... files)
Get the list of feature files.static File
getFileFromURL(URL url, boolean cache, File tmpDir)
Get a File from a local URL (if possible)static JarFile
getJarFileFromURL(URL url, boolean cache, File tmpDir)
Get a JarFile from a local URL (if possible)static List<String>
parseFeatureRefFile(File file)
Parse a feature reference file
-
-
-
Field Detail
-
EXTENSION_REF_FILE
public static final String EXTENSION_REF_FILE
The extension for a reference file.- See Also:
- Constant Field Values
-
EXTENSION_FEATURE_FILE
public static final String EXTENSION_FEATURE_FILE
The extension for a feature file.- See Also:
- Constant Field Values
-
EXTENSION_FEATURE_ARCHIVE
public static final String EXTENSION_FEATURE_ARCHIVE
The extension for a feature file.- See Also:
- Constant Field Values
-
DEFAULT_DIRECTORY
public static final String DEFAULT_DIRECTORY
The default directory to search for features.- See Also:
- Constant Field Values
-
DEFAULT_FEATURE_FILE
public static final String DEFAULT_FEATURE_FILE
The default name of the feature file.- See Also:
- Constant Field Values
-
-
Method Detail
-
parseFeatureRefFile
public static List<String> parseFeatureRefFile(File file) throws IOException
Parse a feature reference file- Parameters:
file
- The file- Returns:
- The referenced features
- Throws:
IOException
- If reading fails
-
getFeatureFiles
public static List<String> getFeatureFiles(File homeDirectory, String... files) throws IOException
Get the list of feature files. If the provided list of files isnull
or an empty array, the default is used. The default checks for the following places, the first one found is used. If none is found an empty list is returned.- A directory named
DEFAULT_DIRECTORY
in the current directory - A file named
DEFAULT_FEATURE_FILE
in the current directory - A directory named
DEFAULT_DIRECTORY
in the home directory - A file named
DEFAULT_FEATURE_FILE
in the home directory
EXTENSION_FEATURE_FILE
orEXTENSION_REF_FILE
of that directory are read. If a file ends inEXTENSION_REF_FILE
the contents is read and every line not starting with the hash sign is considered a reference to a feature artifact.- Parameters:
homeDirectory
- If relative files should be resolved, this is the directory to usefiles
- Optional list of files. If none is provided, a default is used.- Returns:
- The list of files.
- Throws:
IOException
- If an error occurs.
- A directory named
-
getFileFromURL
public static File getFileFromURL(URL url, boolean cache, File tmpDir) throws IOException
Get a File from a local URL (if possible)- Parameters:
url
- a local url (like a file: url or a jar:file: urlcache
- if an attempt should be made to download the content of the url locally if it can not be presented as a file directlytmpDir
- the tmpDir to use (null for default)- Returns:
- the file the url points to (or null if none) - or a tmp file if cache is true and the url could be cached
- Throws:
IOException
- When an IO Exception occurs.
-
getJarFileFromURL
public static JarFile getJarFileFromURL(URL url, boolean cache, File tmpDir) throws IOException
Get a JarFile from a local URL (if possible)- Parameters:
url
- a local url (like a file: url or a jar:file: urlcache
- if an attempt should be made to download the content of the url locally if it can not be presented as a jarfile directlytmpDir
- the tmpDir to use (null for default)- Returns:
- the jarfile the url points to
- Throws:
IOException
- if the url can't be represented as a jarfile
-
-