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 allowTransferManagers to upload/download local files.Transfer manager operations take either
RemoteFileinstances, 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
RemoteFileAttributesin 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 constructorthat takes aStringargument. 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.booleanequals(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.StringgetName()Returns the name of the file (as it is identified by Syncany)inthashCode()<T extends RemoteFileAttributes>
voidsetAttributes(T remoteFileAttributes)Sets remote file attributes to this remote file class.java.lang.StringtoString()protected java.lang.StringvalidateName(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 byTransferManagers to identify a file on the remote storage.The constructor parses and validates the given name using the
validateName()method. WhileRemoteFilehas no name pattern (and never throws an exception), sub-classes might.Important: Sub-classes must also implement a one-parameter constructor that takes a
Stringargument. 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:RemoteFiledoes 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. WhileRemoteFilehas 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:RemoteFiledoes 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,RemoteFileor 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-