java.lang.Object
one.jpro.platform.file.FileSource
- Direct Known Subclasses:
NativeFileSource,WebFileSource
Represents an abstract source for file operations, offering a unified interface
for interacting with files that may originate from different platforms or locations
(e.g., local file system, web-based storage).
This class encapsulates common file attributes such as name, size, and object URL, as well as actions like uploading. It employs the Property pattern for these attributes, allowing for easy binding and observation in a JavaFX application.
This is a sealed class, which can only be subclassed by specific types (NativeFileSource,
WebFileSource), ensuring a controlled set of implementations. This makes it easier to handle
file operations consistently across various types of file sources.
The class provides both synchronous and asynchronous methods for file uploading, allowing flexibility in how file operations are handled.
- Author:
- Besmir Beqiri
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.ReadOnlyStringPropertyReturns the name property of the file.abstract javafx.beans.property.ReadOnlyDoublePropertyReturns a read-only double property representing the current upload progress.final javafx.beans.property.ReadOnlyLongPropertyReturns the size property of the file.abstract javafx.beans.property.ReadOnlyObjectProperty<File> Returns a read-only object property representing the uploaded file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetName()Returns the name of the file.Returns the platform-specific file object.abstract doubleGets the current upload progress.final longgetSize()Returns the size of the file.abstract FileRetrieves the File object representing the uploaded file.final javafx.beans.property.ReadOnlyStringPropertyReturns the name property of the file.abstract javafx.beans.property.ReadOnlyDoublePropertyReturns a read-only double property representing the current upload progress.final javafx.beans.property.ReadOnlyLongPropertyReturns the size property of the file.abstract javafx.beans.property.ReadOnlyObjectProperty<File> Returns a read-only object property representing the uploaded file.abstract voidInitiates the file upload process synchronously.abstract CompletableFuture<File> Initiates the file upload process asynchronously.
-
Property Details
-
name
public final javafx.beans.property.ReadOnlyStringProperty namePropertyReturns the name property of the file.- See Also:
-
size
public final javafx.beans.property.ReadOnlyLongProperty sizePropertyReturns the size property of the file.- See Also:
-
progress
public abstract javafx.beans.property.ReadOnlyDoubleProperty progressPropertyReturns a read-only double property representing the current upload progress.- See Also:
-
uploadedFile
Returns a read-only object property representing the uploaded file.- See Also:
-
-
Constructor Details
-
FileSource
Constructor to initialize the FileSource.- Parameters:
platformFile- the platform-specific file object
-
-
Method Details
-
getPlatformFile
Returns the platform-specific file object.- Returns:
- the platform-specific file object
-
getName
Returns the name of the file.- Returns:
- the name of the file
-
nameProperty
public final javafx.beans.property.ReadOnlyStringProperty nameProperty()Returns the name property of the file.- Returns:
- the ReadOnlyStringProperty for name
- See Also:
-
getSize
public final long getSize()Returns the size of the file.- Returns:
- the size of the file
-
sizeProperty
public final javafx.beans.property.ReadOnlyLongProperty sizeProperty()Returns the size property of the file.- Returns:
- the ReadOnlyLongProperty for size
- See Also:
-
getProgress
public abstract double getProgress()Gets the current upload progress.- Returns:
- the current upload progress as a double value between 0.0 and 1.0
-
progressProperty
public abstract javafx.beans.property.ReadOnlyDoubleProperty progressProperty()Returns a read-only double property representing the current upload progress.- Returns:
- the ReadOnlyDoubleProperty for the upload progress
- See Also:
-
getUploadedFile
Retrieves the File object representing the uploaded file.- Returns:
- the uploaded File object, or null if the file has not been uploaded yet
-
uploadedFileProperty
Returns a read-only object property representing the uploaded file.- Returns:
- the ReadOnlyObjectProperty for the uploaded file
- See Also:
-
uploadFile
public abstract void uploadFile()Initiates the file upload process synchronously.This method will start the upload operation and should be called to begin the upload.
-
uploadFileAsync
Initiates the file upload process asynchronously.- Returns:
- a CompletableFuture representing the result of the asynchronous upload operation, which will complete with the uploaded File object
-