Top Description Fields Constructors Methods
org.jabref.model.entry

public Class LinkedFile

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@AllowedToUseLogic:Uses FileUtil from logic
@NullMarked
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.net.URL, java.nio.file.Files, .InvalidPathException, .Path, java.util.List, .Objects, .Optional, java.util.regex.Pattern, javafx.beans.Observable, javafx.beans.property.SimpleStringProperty, .StringProperty, org.jabref.architecture.AllowedToUseLogic, org.jabref.gui.DialogService, org.jabref.gui.fieldeditors.LinkedFileViewModel, org.jabref.gui.util.TaskExecutor, org.jabref.logic.util.FileType, org.jabref.logic.util.io.FileUtil, org.jabref.model.database.BibDatabaseContext, org.jabref.model.strings.StringUtil, org.jabref.preferences.FilePreferences, .PreferencesService, org.jspecify.annotations.NullMarked, .Nullable

Represents the link to an external file (e.g. associated PDF file). This class is Serializable which is needed for drag and drop in gui

Field Summary

Modifier and TypeField and Description
private transient StringProperty
private transient StringProperty
private transient StringProperty
private static final LinkedFile
private static final String
private transient StringProperty
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
LinkedFile(String description, Path link, String fileType)

public
LinkedFile(String description, Path link, String fileType, String sourceUrl)

public
LinkedFile(String description, String link, FileType fileType)

public
LinkedFile(String description, String link, String fileType, String sourceUrl)

Constructor can also be used for non-valid paths.

public
LinkedFile(String description, String link, String fileType)

public
LinkedFile(URL link, String fileType)

public
LinkedFile(String description, URL link, String fileType)

public
LinkedFile(String description, URL link, String fileType, String sourceUrl)

Method Summary

Modifier and TypeMethod and Description
public StringProperty
public boolean
equals(@Nullable Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public StringProperty
public Optional<Path>
findIn(BibDatabaseContext databaseContext, FilePreferences filePreferences)

public Optional<Path>
findIn(List<Path> directories)

Tries to find the file in the given directories and returns the path to the file (if found).

public String
public String
public Observable[]
public String
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public StringProperty
private void
readObject(ObjectInputStream in)

Reads serialized object from ObjectInputStream, automatically called

public void
setDescription(String description)

public void
setFileType(String fileType)

public void
public void
public StringProperty
public LinkedFileViewModel
toModel(BibEntry entry, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, DialogService dialogService, PreferencesService preferencesService)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
writeObject(ObjectOutputStream out)

Writes serialized object to ObjectOutputStream, automatically called

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

descriptionback to summary
private transient StringProperty description
fileTypeback to summary
private transient StringProperty fileType
NULL_OBJECTback to summary
private static final LinkedFile NULL_OBJECT
REGEX_URLback to summary
private static final String REGEX_URL
sourceURLback to summary
private transient StringProperty sourceURL
URL_PATTERNback to summary
private static final Pattern URL_PATTERN

Constructor Detail

LinkedFileback to summary
public LinkedFile(String description, Path link, String fileType)
LinkedFileback to summary
public LinkedFile(String description, Path link, String fileType, String sourceUrl)
LinkedFileback to summary
public LinkedFile(String description, String link, FileType fileType)
LinkedFileback to summary
public LinkedFile(String description, String link, String fileType, String sourceUrl)

Constructor can also be used for non-valid paths. We need to parse them, because the GUI needs to render it.

LinkedFileback to summary
public LinkedFile(String description, String link, String fileType)
LinkedFileback to summary
public LinkedFile(URL link, String fileType)
LinkedFileback to summary
public LinkedFile(String description, URL link, String fileType)
LinkedFileback to summary
public LinkedFile(String description, URL link, String fileType, String sourceUrl)

Method Detail

descriptionPropertyback to summary
public StringProperty descriptionProperty()
equalsback to summary
public boolean equals(@Nullable Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:@Nullable Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fileTypePropertyback to summary
public StringProperty fileTypeProperty()
findInback to summary
public Optional<Path> findIn(BibDatabaseContext databaseContext, FilePreferences filePreferences)
findInback to summary
public Optional<Path> findIn(List<Path> directories)

Tries to find the file in the given directories and returns the path to the file (if found). Returns an empty optional if the file cannot be found.

getDescriptionback to summary
public String getDescription()
getFileTypeback to summary
public String getFileType()
getObservablesback to summary
public Observable[] getObservables()
getSourceUrlback to summary
public String getSourceUrl()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()
linkPropertyback to summary
public StringProperty linkProperty()
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException

Reads serialized object from ObjectInputStream, automatically called

setDescriptionback to summary
public void setDescription(String description)
setFileTypeback to summary
public void setFileType(String fileType)
setFileTypeback to summary
public void setFileType(FileType fileType)
setSourceURLback to summary
public void setSourceURL(String url)
sourceUrlPropertyback to summary
public StringProperty sourceUrlProperty()
toModelback to summary
public LinkedFileViewModel toModel(BibEntry entry, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, DialogService dialogService, PreferencesService preferencesService)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException

Writes serialized object to ObjectOutputStream, automatically called