Package org.apache.sshd.scp.common
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.- Author:
- Apache MINA SSHD Project
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static charHOST_PART_SEPARATORstatic StringSCHEMEstatic charUSERNAME_PART_SEPARATOR
-
Constructor Summary
Constructors Constructor Description ScpLocation()ScpLocation(String locSpec)ScpLocation(String username, String host, int port, String path)ScpLocation(String username, String host, String path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ScpLocationclone()booleanequals(Object obj)StringgetHost()StringgetPath()intgetPort()StringgetUsername()inthashCode()booleanisLocal()static ScpLocationparse(String locSpec)Parses a local or remote SCP location in the format "user@host:path" or "scp://[user@]host[:port][/path]"intresolvePort()StringresolveUsername()Resolves the effective username to use for a remote location.voidsetHost(String host)voidsetPath(String path)voidsetPort(int port)voidsetUsername(String username)StringtoString()static <L extends ScpLocation>
Lupdate(String spec, L location)Parses a local or remote SCP location in the format "user@host:path" or "scp://[user@]host[:port][/path]"
-
-
-
Field Detail
-
SCHEME
public static final String SCHEME
- See Also:
- Constant Field Values
-
HOST_PART_SEPARATOR
public static final char HOST_PART_SEPARATOR
- See Also:
- Constant Field Values
-
USERNAME_PART_SEPARATOR
public static final char USERNAME_PART_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ScpLocation
public ScpLocation()
-
ScpLocation
public ScpLocation(String locSpec)
- Parameters:
locSpec- The location specification - ignored ifnull/empty- Throws:
IllegalArgumentException- if invalid specification- See Also:
update(String, ScpLocation)
-
-
Method Detail
-
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:
getUsernamein interfaceUsernameHolder
-
setUsername
public void setUsername(String username)
- Specified by:
setUsernamein interfaceMutableUserHolder
-
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:
getUsername(),OsUtils.getCurrentUser()
-
getPath
public String getPath()
-
setPath
public void setPath(String path)
-
clone
public ScpLocation clone()
-
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 ifnull/empty- Returns:
- The
ScpLocationornullif no specification provider - Throws:
IllegalArgumentException- if invalid specification- See Also:
update(String, ScpLocation)
-
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 ofScpLocationbeing updated- Parameters:
spec- The location specification - ignored ifnull/emptylocation- TheScpLocationto update - nevernull- Returns:
- The updated location (unless no specification)
- Throws:
IllegalArgumentException- if invalid specification
-
-