Class DatabaseRemoteFile
- java.lang.Object
-
- org.syncany.plugins.transfer.files.RemoteFile
-
- org.syncany.plugins.transfer.files.DatabaseRemoteFile
-
- All Implemented Interfaces:
java.lang.Comparable<DatabaseRemoteFile>
public class DatabaseRemoteFile extends RemoteFile implements java.lang.Comparable<DatabaseRemoteFile>
The database file represents a delta database.Name pattern: The name pattern of a database file is db-<clientname>-<clientversion>. Initializing an instance with a non-matching name will throw an exception.
Note: The class implements a
Comparableinterface and can be sorted by name and client version.
-
-
Constructor Summary
Constructors Constructor Description DatabaseRemoteFile(java.lang.String name)Initializes a new database file, given a name.DatabaseRemoteFile(java.lang.String clientName, long version)Initializes a new database file, given a client name and version
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(DatabaseRemoteFile r2)booleanequals(java.lang.Object obj)java.lang.StringgetClientName()Returns the client namelonggetClientVersion()Returns the client versioninthashCode()protected java.lang.StringvalidateName(java.lang.String name)Parses the name of the file and validates it against the classes name pattern.-
Methods inherited from class org.syncany.plugins.transfer.files.RemoteFile
createRemoteFile, createRemoteFile, getAttributes, getName, setAttributes, toString
-
-
-
-
Constructor Detail
-
DatabaseRemoteFile
public DatabaseRemoteFile(java.lang.String name) throws StorageException
Initializes a new database file, given a name. This constructor might be called by thecreateRemoteFile()method of theRemoteFile.If the pattern matches, the client name and the client version are set, and can be queried by
getClientName()andgetClientVersion().- Parameters:
name- Database file name; must always match theNAME_PATTERN- Throws:
StorageException- If the name is not match the name pattern
-
DatabaseRemoteFile
public DatabaseRemoteFile(java.lang.String clientName, long version) throws StorageException
Initializes a new database file, given a client name and version- Parameters:
clientName- The name of the client/machine for this delta database fileversion- The client version for this delta database file- Throws:
StorageException- Never throws an exception
-
-
Method Detail
-
getClientName
public java.lang.String getClientName()
Returns the client name
-
getClientVersion
public long getClientVersion()
Returns the client version
-
validateName
protected java.lang.String validateName(java.lang.String name) throws StorageException
Description copied from class:RemoteFileParses 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.- Overrides:
validateNamein classRemoteFile- 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.
-
compareTo
public int compareTo(DatabaseRemoteFile r2)
- Specified by:
compareToin interfacejava.lang.Comparable<DatabaseRemoteFile>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classRemoteFile
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classRemoteFile
-
-