Class RemoteFile

    • 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>
      T
      createRemoteFile​(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>
      T
      createRemoteFile​(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>
      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.
      java.lang.String getName()
      Returns the name of the file (as it is identified by Syncany)
      int hashCode()  
      <T extends RemoteFileAttributes>
      void
      setAttributes​(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.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RemoteFile

        public RemoteFile​(java.lang.String name)
                   throws StorageException
        Creates a new remote file by its name. The name is used by TransferManagers to identify a file on the remote storage.

        The constructor parses and validates the given name using the validateName() method. While RemoteFile 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 the RemoteFile.

        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. While RemoteFile 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 file
        remoteFileClass - 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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object