Class RemoteFile
- java.lang.Object
-
- org.syncany.plugins.transfer.files.RemoteFile
-
- Direct Known Subclasses:
ActionRemoteFile
,CleanupRemoteFile
,DatabaseRemoteFile
,MasterRemoteFile
,MultichunkRemoteFile
,SyncanyRemoteFile
,TempRemoteFile
,TransactionRemoteFile
public abstract class RemoteFile extends java.lang.Object
A remote file represents a file object on a remote storage. Its purpose is to identify a file and allowTransferManager
s to upload/download local files.Transfer manager operations take either
RemoteFile
instances, or classes that extend this class. Depending on the type of the sub-class, they might store the files at a different location or in a different format to optimize performance.Remote files can be extended with
RemoteFileAttributes
in certain situations, e.g. to add additional information about the sub-path. The attributes can be added set and read viasetAttributes(RemoteFileAttributes)
andgetAttributes(Class)
.Important: Sub-classes must offer a
one-parameter constructor
that takes aString
argument. This constructor is required by theRemoteFile
.
-
-
Constructor Summary
Constructors Constructor Description RemoteFile(java.lang.String name)
Creates a new remote file by its name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T extends RemoteFile>
TcreateRemoteFile(java.lang.String name)
Creates a remote file based on a name and derives the class name using the file name.static <T extends RemoteFile>
TcreateRemoteFile(java.lang.String name, java.lang.Class<T> remoteFileClass)
Creates a remote file based on a name and a class name.boolean
equals(java.lang.Object obj)
<T extends RemoteFileAttributes>
TgetAttributes(java.lang.Class<T> remoteFileAttributesClass)
Returns a list of attributes for a given file, or null if there is no attribute with the given class.java.lang.String
getName()
Returns the name of the file (as it is identified by Syncany)int
hashCode()
<T extends RemoteFileAttributes>
voidsetAttributes(T remoteFileAttributes)
Sets remote file attributes to this remote file class.java.lang.String
toString()
protected java.lang.String
validateName(java.lang.String name)
Parses the name of the file and validates it against the classes name pattern.
-
-
-
Constructor Detail
-
RemoteFile
public RemoteFile(java.lang.String name) throws StorageException
Creates a new remote file by its name. The name is used byTransferManager
s to identify a file on the remote storage.The constructor parses and validates the given name using the
validateName()
method. WhileRemoteFile
has no name pattern (and never throws an exception), sub-classes might.Important: Sub-classes must also implement a one-parameter constructor that takes a
String
argument. This constructor is required by theRemoteFile
.- Parameters:
name
- The name of the file (as it is identified by Syncany)- Throws:
StorageException
- If the name does not match the name pattern defined by the class.
Note:RemoteFile
does never throw this exceptions, however, subclasses might.
-
-
Method Detail
-
getName
public final java.lang.String getName()
Returns the name of the file (as it is identified by Syncany)
-
setAttributes
public final <T extends RemoteFileAttributes> void setAttributes(T remoteFileAttributes)
Sets remote file attributes to this remote file class. Attributes can extend the parameters of this class without actually having to extend it.
-
getAttributes
public final <T extends RemoteFileAttributes> T getAttributes(java.lang.Class<T> remoteFileAttributesClass)
Returns a list of attributes for a given file, or null if there is no attribute with the given class.
-
validateName
protected java.lang.String validateName(java.lang.String name) throws StorageException
Parses the name of the file and validates it against the classes name pattern. WhileRemoteFile
has no name pattern (and never throws an exception), sub-classes might by overriding this method.- Parameters:
name
- The name of the file (as it is identified by Syncany)- Returns:
- Returns a (potentially changed) name, after validating the name
- Throws:
StorageException
- If the name does not match the name pattern defined by the class.
Note:RemoteFile
does never throw this exceptions, however, subclasses might.
-
createRemoteFile
public static <T extends RemoteFile> T createRemoteFile(java.lang.String name, java.lang.Class<T> remoteFileClass) throws StorageException
Creates a remote file based on a name and a class name.The name must match the corresponding name pattern, and the class name can either be
RemoteFile
, or a sub-class thereof.- Parameters:
name
- The name of the remote fileremoteFileClass
- Class name of the object to instantiate,RemoteFile
or a sub-class thereof- Returns:
- Returns a new object of the given class
- Throws:
StorageException
-
createRemoteFile
public static <T extends RemoteFile> T createRemoteFile(java.lang.String name) throws StorageException
Creates a remote file based on a name and derives the class name using the file name.The name must match the corresponding name pattern (nameprefix-...), and the derived class can either be
RemoteFile
, or a sub-class thereof.- Parameters:
name
- The name of the remote file- Returns:
- Returns a new object of the given class
- Throws:
StorageException
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-