Class PathEnvironment
- java.lang.Object
-
- net.ssehub.easy.producer.core.persistence.datatypes.PathEnvironment
-
public class PathEnvironment extends java.lang.ObjectAn environment for transparently making paths relative and absolute. All paths to be persisted shall be relative, all paths to be used within EASy shall be absolute. Basically, this class makes locations absolute and relative with respect to a given base folder (typically the workspace folder). Further, sets of paths may be given along with an identifying symbolic name, such as "classpath" and external classpath entires as path. In that case, the external folder will be stripped and replaced by "classpath:" while making a location relative and while making it absolute the local classpath will be considered (to map to a different user / machine). However, currently we only consider the file name in such mapping paths so that also the names of the files within one mapping must be unique.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classPathEnvironment.EntryDefines a mapping entry consisting of an unique symbolic name and a set of paths.
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilebaseFolderprivate java.util.List<PathEnvironment.Entry>mappingstatic java.lang.StringNAME_SEPARATOR
-
Constructor Summary
Constructors Constructor Description PathEnvironment(java.io.File baseFolder)Creates a new path environment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapping(java.lang.String name, java.lang.String... paths)Adds a set ofpathsto be made relative with the givenname.voidclear()Clears the mappings.java.io.FilegetBaseFolder()Returns the base folder.java.io.FilemakeAbsolute(java.lang.String location)Makes a file location absolute with respect to the known paths in this instance.java.lang.StringmakeRelative(java.io.File location)Makes a file location relative with respect to the known paths in this instance.voidremoveMapping(java.lang.String name)Removes a specific mapping.
-
-
-
Field Detail
-
NAME_SEPARATOR
public static final java.lang.String NAME_SEPARATOR
- See Also:
- Constant Field Values
-
baseFolder
private java.io.File baseFolder
-
mapping
private java.util.List<PathEnvironment.Entry> mapping
-
-
Method Detail
-
addMapping
public void addMapping(java.lang.String name, java.lang.String... paths)Adds a set ofpathsto be made relative with the givenname.- Parameters:
name- the name representing the pathspaths- the paths to be made relative
-
removeMapping
public void removeMapping(java.lang.String name)
Removes a specific mapping.- Parameters:
name- the name of the mapping to remove
-
clear
public void clear()
Clears the mappings.
-
getBaseFolder
public java.io.File getBaseFolder()
Returns the base folder.- Returns:
- the base folder
-
makeRelative
public java.lang.String makeRelative(java.io.File location)
Makes a file location relative with respect to the known paths in this instance.- Parameters:
location- the location to be turned into a relative location- Returns:
- the relative location
-
makeAbsolute
public java.io.File makeAbsolute(java.lang.String location)
Makes a file location absolute with respect to the known paths in this instance.- Parameters:
location- the location to be turned into an absolute location- Returns:
- the absolute location
-
-