Class ScpLocation

java.lang.Object
org.apache.sshd.scp.common.ScpLocation
All Implemented Interfaces:
Serializable, Cloneable, MutableUserHolder, UsernameHolder

public class ScpLocation extends Object implements MutableUserHolder, Serializable, Cloneable
Represents a local or remote SCP location in the format "user@host:path" or "scp://[user@]host[:port][/path]" for a remote path and a simple path for a local one. If user is omitted for a remote path then current user is used.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getHost

      public String getHost()
    • setHost

      public void setHost(String host)
    • isLocal

      public boolean isLocal()
    • getPort

      public int getPort()
    • setPort

      public void setPort(int port)
    • resolvePort

      public int resolvePort()
    • getUsername

      public String getUsername()
      Specified by:
      getUsername in interface UsernameHolder
      Returns:
      The attached username - may be null/empty if holder not yet initialized
    • setUsername

      public void setUsername(String username)
      Specified by:
      setUsername in interface MutableUserHolder
    • resolveUsername

      public String resolveUsername()
      Resolves the effective username to use for a remote location. If username not set then uses the current username
      Returns:
      The resolved username
      See Also:
    • getPath

      public String getPath()
    • setPath

      public void setPath(String path)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • clone

      public ScpLocation clone()
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parse

      public static ScpLocation parse(String locSpec)
      Parses a local or remote SCP location in the format "user@host:path" or "scp://[user@]host[:port][/path]"
      Parameters:
      locSpec - The location specification - ignored if null/empty
      Returns:
      The ScpLocation or null if no specification provider
      Throws:
      IllegalArgumentException - if invalid specification
      See Also:
    • update

      public static <L extends ScpLocation> L update(String spec, L location)
      Parses a local or remote SCP location in the format "user@host:path" or "scp://[user@]host[:port][/path]"
      Type Parameters:
      L - Type of ScpLocation being updated
      Parameters:
      spec - The location specification - ignored if null/empty
      location - The ScpLocation to update - never null
      Returns:
      The updated location (unless no specification)
      Throws:
      IllegalArgumentException - if invalid specification