- java.lang.Object
-
- org.eclipse.jgit.internal.diffmergetool.FileElement
-
public class FileElement extends Object
The element used as left or right file for compare.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileElement.TypeThe file element type.
-
Constructor Summary
Constructors Constructor Description FileElement(String path, FileElement.Type type)Creates file element for path.FileElement(String path, FileElement.Type type, File workDir)Creates file element for path.FileElement(String path, FileElement.Type type, File workDir, InputStream stream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToEnv(Map<String,String> env)Add variable to environment map.voidcleanTemporaries()Delete and invalidate temporary file if necessary.FilecreateTempFile(File directory)Create temporary file in given or system temporary directory.FilegetFile()Return a temporary file if already created and stream is not valid OR a real file from work tree: if no temp file was created (@see createTempFile()) and if no stream was set OR an empty temporary file if path is "/dev/null" OR a temporary file with stream content if stream is valid (not null); stream is closed and invalidated (set to null) after write to temp file, so stream is used only once during first call!StringgetPath()FileElement.TypegetType()booleanisNullPath()Check if path id "/dev/null"StringreplaceVariable(String input)Replace variable in input.
-
-
-
Constructor Detail
-
FileElement
public FileElement(String path, FileElement.Type type)
Creates file element for path.- Parameters:
path- the file pathtype- the element type
-
FileElement
public FileElement(String path, FileElement.Type type, File workDir)
Creates file element for path.- Parameters:
path- the file pathtype- the element typeworkDir- the working directory of the path (can be null, then current working dir is used)
-
FileElement
public FileElement(String path, FileElement.Type type, File workDir, InputStream stream)
- Parameters:
path- the file pathtype- the element typeworkDir- the working directory of the path (can be null, then current working dir is used)stream- the object stream to load and write on demand, @see getFile(), to tempFile once (can be null)
-
-
Method Detail
-
getPath
public String getPath()
- Returns:
- the file path
-
getType
public FileElement.Type getType()
- Returns:
- the element type
-
getFile
public File getFile() throws IOException
Return- a temporary file if already created and stream is not valid
- OR a real file from work tree: if no temp file was created (@see createTempFile()) and if no stream was set
- OR an empty temporary file if path is "/dev/null"
- OR a temporary file with stream content if stream is valid (not null); stream is closed and invalidated (set to null) after write to temp file, so stream is used only once during first call!
- Returns:
- the object stream
- Throws:
IOException
-
isNullPath
public boolean isNullPath()
Check if path id "/dev/null"- Returns:
- true if path is "/dev/null"
-
createTempFile
public File createTempFile(File directory) throws IOException
Create temporary file in given or system temporary directory.- Parameters:
directory- the directory for the file (can be null); if null system temporary directory is used- Returns:
- temporary file in directory or in the system temporary directory
- Throws:
IOException
-
cleanTemporaries
public void cleanTemporaries()
Delete and invalidate temporary file if necessary.
-
replaceVariable
public String replaceVariable(String input) throws IOException
Replace variable in input.- Parameters:
input- the input string- Returns:
- the replaced input string
- Throws:
IOException
-
addToEnv
public void addToEnv(Map<String,String> env) throws IOException
Add variable to environment map.- Parameters:
env- the environment where this element should be added- Throws:
IOException
-
-