public class ScpLocation extends java.lang.Object implements MutableUserHolder, java.io.Serializable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
host |
static char |
HOST_PART_SEPARATOR |
private java.lang.String |
path |
private int |
port |
static java.lang.String |
SCHEME |
private static long |
serialVersionUID |
private java.lang.String |
username |
static char |
USERNAME_PART_SEPARATOR |
Constructor and Description |
---|
ScpLocation() |
ScpLocation(java.lang.String locSpec) |
ScpLocation(java.lang.String username,
java.lang.String host,
int port,
java.lang.String path) |
ScpLocation(java.lang.String username,
java.lang.String host,
java.lang.String path) |
Modifier and Type | Method and Description |
---|---|
ScpLocation |
clone() |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getHost() |
java.lang.String |
getPath() |
int |
getPort() |
java.lang.String |
getUsername() |
int |
hashCode() |
boolean |
isLocal() |
static ScpLocation |
parse(java.lang.String locSpec)
Parses a local or remote SCP location in the format "user@host:path" or
"scp://[user@]host[:port][/path]"
|
int |
resolvePort() |
java.lang.String |
resolveUsername()
Resolves the effective username to use for a remote location.
|
void |
setHost(java.lang.String host) |
void |
setPath(java.lang.String path) |
void |
setPort(int port) |
void |
setUsername(java.lang.String username) |
java.lang.String |
toString() |
static <L extends ScpLocation> |
update(java.lang.String spec,
L location)
Parses a local or remote SCP location in the format "user@host:path" or
"scp://[user@]host[:port][/path]"
|
public static final java.lang.String SCHEME
public static final char HOST_PART_SEPARATOR
public static final char USERNAME_PART_SEPARATOR
private static final long serialVersionUID
private java.lang.String host
private java.lang.String username
private java.lang.String path
private int port
public ScpLocation()
public ScpLocation(java.lang.String locSpec)
locSpec
- The location specification - ignored if null
/emptyjava.lang.IllegalArgumentException
- if invalid specificationupdate(String, ScpLocation)
public ScpLocation(java.lang.String username, java.lang.String host, java.lang.String path)
public ScpLocation(java.lang.String username, java.lang.String host, int port, java.lang.String path)
public java.lang.String getHost()
public void setHost(java.lang.String host)
public boolean isLocal()
public int getPort()
public void setPort(int port)
public int resolvePort()
public java.lang.String getUsername()
getUsername
in interface UsernameHolder
null
/empty if holder not yet initializedpublic void setUsername(java.lang.String username)
setUsername
in interface MutableUserHolder
public java.lang.String resolveUsername()
getUsername()
,
OsUtils.getCurrentUser()
public java.lang.String getPath()
public void setPath(java.lang.String path)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public ScpLocation clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static ScpLocation parse(java.lang.String locSpec)
locSpec
- The location specification - ignored if null
/emptyScpLocation
or null
if no specification providerjava.lang.IllegalArgumentException
- if invalid specificationupdate(String, ScpLocation)
public static <L extends ScpLocation> L update(java.lang.String spec, L location)
L
- Type of ScpLocation
being updatedspec
- The location specification - ignored if null
/emptylocation
- The ScpLocation
to update - never null
java.lang.IllegalArgumentException
- if invalid specification