Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.diffmergetool

public Class FileElement

extends Object
Class Inheritance
Imports
java.io.File, .FileNotFoundException, .FileOutputStream, .IOException, .InputStream, .OutputStream, java.util.Map, org.eclipse.jgit.diff.DiffEntry

The element used as left or right file for compare.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
FileElement.Type

The file element type.

Field Summary

Modifier and TypeField and Description
private final String
private InputStream
private File
private final FileElement.Type
private final File

Constructor Summary

AccessConstructor and Description
public
FileElement(String
the file path
path
,
FileElement.Type
the element type
type
)

Creates file element for path.

public
FileElement(String
the file path
path
,
FileElement.Type
the element type
type
,
File
the working directory of the path (can be null, then current working dir is used)
workDir
)

Creates file element for path.

public
FileElement(String
the file path
path
,
FileElement.Type
the element type
type
,
File
the working directory of the path (can be null, then current working dir is used)
workDir
,
InputStream
the object stream to load and write on demand, @see getFile(), to tempFile once (can be null)
stream
)

Create file element

Method Summary

Modifier and TypeMethod and Description
public void
addToEnv(Map<String, String>
the environment where this element should be added
env
)

Add variable to environment map.

public void
cleanTemporaries()

Delete and invalidate temporary file if necessary.

private static void
copyFromStream(final File file, final InputStream stream)

public File

Returns:

temporary file in directory or in the system temporary directory
createTempFile
(File
the directory for the file (can be null); if null system temporary directory is used
directory
)

Create temporary file in given or system temporary directory.

public File

Returns:

the object stream
getFile
()

Get file

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 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!
public String

Returns:

the file path
getPath
()

Get path

private static File
getTempFile(final File file, final String midName, final File workingDir)

public FileElement.Type

Returns:

the element type
getType
()

Get type

public boolean

Returns:

true if path is "/dev/null"
isNullPath
()

Check if path id "/dev/null"

public String

Returns:

the replaced input string
replaceVariable
(String
the input string
input
)

Replace variable in input.

private static String[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pathback to summary
private final String path
streamback to summary
private InputStream stream
tempFileback to summary
private File tempFile
typeback to summary
private final FileElement.Type type
workDirback to summary
private final File workDir

Constructor Detail

FileElementback to summary
public FileElement(String path, FileElement.Type type)

Creates file element for path.

Parameters
path:String

the file path

type:FileElement.Type

the element type

FileElementback to summary
public FileElement(String path, FileElement.Type type, File workDir)

Creates file element for path.

Parameters
path:String

the file path

type:FileElement.Type

the element type

workDir:File

the working directory of the path (can be null, then current working dir is used)

FileElementback to summary
public FileElement(String path, FileElement.Type type, File workDir, InputStream stream)

Create file element

Parameters
path:String

the file path

type:FileElement.Type

the element type

workDir:File

the working directory of the path (can be null, then current working dir is used)

stream:InputStream

the object stream to load and write on demand, @see getFile(), to tempFile once (can be null)

Method Detail

addToEnvback to summary
public void addToEnv(Map<String, String> env) throws IOException

Add variable to environment map.

Parameters
env:Map<String, String>

the environment where this element should be added

Exceptions
IOException:
if an IO error occurred
cleanTemporariesback to summary
public void cleanTemporaries()

Delete and invalidate temporary file if necessary.

copyFromStreamback to summary
private static void copyFromStream(final File file, final InputStream stream) throws IOException, FileNotFoundException
createTempFileback to summary
public File createTempFile(File directory) throws IOException

Create temporary file in given or system temporary directory.

Parameters
directory:File

the directory for the file (can be null); if null system temporary directory is used

Returns:File

temporary file in directory or in the system temporary directory

Exceptions
IOException:
if an IO error occurred
getFileback to summary
public File getFile() throws IOException

Get file

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 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:File

the object stream

Exceptions
IOException:
if an IO error occurred
getPathback to summary
public String getPath()

Get path

Returns:String

the file path

getTempFileback to summary
private static File getTempFile(final File file, final String midName, final File workingDir) throws IOException
getTypeback to summary
public FileElement.Type getType()

Get type

Returns:FileElement.Type

the element type

isNullPathback to summary
public boolean isNullPath()

Check if path id "/dev/null"

Returns:boolean

true if path is "/dev/null"

replaceVariableback to summary
public String replaceVariable(String input) throws IOException

Replace variable in input.

Parameters
input:String

the input string

Returns:String

the replaced input string

Exceptions
IOException:
if an IO error occurred
splitBaseFileNameAndExtensionback to summary
private static String[] splitBaseFileNameAndExtension(File file)
org.eclipse.jgit.internal.diffmergetool back to summary

public final Enum FileElement.Type

extends Enum<FileElement.Type>
Class Inheritance

The file element type.

Field Summary

Modifier and TypeField and Description
public static final FileElement.Type
BACKUP

The backup file element (copy of merged / conflicted).

public static final FileElement.Type
BASE

The base file element (of ours and theirs).

public static final FileElement.Type
LOCAL

The local file element (ours).

public static final FileElement.Type
MERGED

The merged file element (path in worktree).

public static final FileElement.Type
REMOTE

The remote file element (theirs).

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static FileElement.Type
public static FileElement.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BACKUPback to summary
public static final FileElement.Type BACKUP

The backup file element (copy of merged / conflicted).

BASEback to summary
public static final FileElement.Type BASE

The base file element (of ours and theirs).

LOCALback to summary
public static final FileElement.Type LOCAL

The local file element (ours).

MERGEDback to summary
public static final FileElement.Type MERGED

The merged file element (path in worktree).

REMOTEback to summary
public static final FileElement.Type REMOTE

The remote file element (theirs).

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static FileElement.Type valueOf(String name)
valuesback to summary
public static FileElement.Type[] values()