Top Inners Fields Methods
org.apache.sshd.sftp.client

public Interface SftpVersionSelector

Known Direct Implementers
org.apache.sshd.sftp.client.SftpVersionSelector.NamedVersionSelector
Annotations
@FunctionalInterface
Imports
java.util.Collection, .List, .Objects, java.util.stream.Stream, .StreamSupport, org.apache.sshd.client.session.ClientSession, org.apache.sshd.common.NamedResource, org.apache.sshd.common.util.GenericUtils, .NumberUtils, .ValidateUtils

Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
SftpVersionSelector.NamedVersionSelector

Wraps a SftpVersionSelector and assigns it a name

Note

NamedVersionSelector are considered equal if they are assigned the same name - case insensitive

Field Summary

Modifier and TypeField and Description
public static final SftpVersionSelector.NamedVersionSelector
CURRENT

An SftpVersionSelector that returns the current version

public static final SftpVersionSelector.NamedVersionSelector
MAXIMUM

An SftpVersionSelector that returns the maximum available version

public static final SftpVersionSelector.NamedVersionSelector
MINIMUM

An SftpVersionSelector that returns the minimum available version

Method Summary

Modifier and TypeMethod and Description
public static SftpVersionSelector.NamedVersionSelector

Returns:

The NamedVersionSelector wrapping the requested version
fixedVersionSelector
(int
The requested version
version
)

Creates a selector the always returns the requested (fixed version) regardless of what the current or reported available versions are.

public static SftpVersionSelector.NamedVersionSelector

Returns:

A NamedVersionSelector that attempts to select the most preferred version that is also listed as available.
preferredVersionSelector
(int...
The preferred versions in decreasing order of preference (i.e., most preferred is 1st) - may not be null/empty
preferred
)

Selects a version in order of preference - if none of the preferred versions is listed as available then an exception is thrown when the SftpVersionSelector#selectVersion(ClientSession, boolean, int, List) method is invoked

public static SftpVersionSelector.NamedVersionSelector

Returns:

A NamedVersionSelector that attempts to select the most preferred version that is also listed as available.
preferredVersionSelector
(Iterable<? extends Number>
The preferred versions in decreasing order of preference (i.e., most preferred is 1st)
preferred
)

Selects a version in order of preference - if none of the preferred versions is listed as available then an exception is thrown when the SftpVersionSelector#selectVersion(ClientSession, boolean, int, List) method is invoked

public static SftpVersionSelector.NamedVersionSelector

Returns:

Parsed NamedVersionSelector
resolveVersionSelector
(String
The selector value - if null/empty then returns CURRENT
selector
)

Parses the input string to see if it matches one of the "known" selectors names (case insensitive).

public int

Returns:

The new requested version - if same as current, then nothing is done
selectVersion
(ClientSession
The ClientSession through which the SFTP connection is made
session
,
boolean
If true then this is the initial version sent via SSH_FXP_INIT otherwise it is a re-negotiation.
initial
,
int
The current version negotiated with the server
current
,
List<Integer>
Extra versions available - may be empty and/or contain only the current one
available
)

Field Detail

CURRENTback to summary
public static final SftpVersionSelector.NamedVersionSelector CURRENT

An SftpVersionSelector that returns the current version

MAXIMUMback to summary
public static final SftpVersionSelector.NamedVersionSelector MAXIMUM

An SftpVersionSelector that returns the maximum available version

MINIMUMback to summary
public static final SftpVersionSelector.NamedVersionSelector MINIMUM

An SftpVersionSelector that returns the minimum available version

Method Detail

fixedVersionSelectorback to summary
public static SftpVersionSelector.NamedVersionSelector fixedVersionSelector(int version)

Creates a selector the always returns the requested (fixed version) regardless of what the current or reported available versions are. If the requested version is not reported as available then an exception will be eventually thrown by the client during re-negotiation phase.

Parameters
version:int

The requested version

Returns:SftpVersionSelector.NamedVersionSelector

The NamedVersionSelector wrapping the requested version

preferredVersionSelectorback to summary
public static SftpVersionSelector.NamedVersionSelector preferredVersionSelector(int... preferred)

Selects a version in order of preference - if none of the preferred versions is listed as available then an exception is thrown when the SftpVersionSelector#selectVersion(ClientSession, boolean, int, List) method is invoked

Parameters
preferred:int[]

The preferred versions in decreasing order of preference (i.e., most preferred is 1st) - may not be null/empty

Returns:SftpVersionSelector.NamedVersionSelector

A NamedVersionSelector that attempts to select the most preferred version that is also listed as available.

preferredVersionSelectorback to summary
public static SftpVersionSelector.NamedVersionSelector preferredVersionSelector(Iterable<? extends Number> preferred)

Selects a version in order of preference - if none of the preferred versions is listed as available then an exception is thrown when the SftpVersionSelector#selectVersion(ClientSession, boolean, int, List) method is invoked

Parameters
preferred:Iterable<? extends Number>

The preferred versions in decreasing order of preference (i.e., most preferred is 1st)

Returns:SftpVersionSelector.NamedVersionSelector

A NamedVersionSelector that attempts to select the most preferred version that is also listed as available.

resolveVersionSelectorback to summary
public static SftpVersionSelector.NamedVersionSelector resolveVersionSelector(String selector)

Parses the input string to see if it matches one of the "known" selectors names (case insensitive). If not, then checks if it is a single number and uses it as a fixed version. Otherwise, assumes a comma separated list of versions in preferred order.

Parameters
selector:String

The selector value - if null/empty then returns CURRENT

Returns:SftpVersionSelector.NamedVersionSelector

Parsed NamedVersionSelector

selectVersionback to summary
public int selectVersion(ClientSession session, boolean initial, int current, List<Integer> available)
Parameters
session:ClientSession

The ClientSession through which the SFTP connection is made

initial:boolean

If true then this is the initial version sent via SSH_FXP_INIT otherwise it is a re-negotiation.

current:int

The current version negotiated with the server

available:List<Integer>

Extra versions available - may be empty and/or contain only the current one

Returns:int

The new requested version - if same as current, then nothing is done

org.apache.sshd.sftp.client back to summary

public Class SftpVersionSelector.NamedVersionSelector

extends Object
implements SftpVersionSelector, NamedResource
Class Inheritance
  • java.lang.Object
  • org.apache.sshd.sftp.client.SftpVersionSelector.NamedVersionSelector
All Implemented Interfaces
org.apache.sshd.common.NamedResource, org.apache.sshd.sftp.client.SftpVersionSelector

Wraps a SftpVersionSelector and assigns it a name

Note

NamedVersionSelector are considered equal if they are assigned the same name - case insensitive

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final String
protected final SftpVersionSelector

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public int
selectVersion(ClientSession
The ClientSession through which the SFTP connection is made
session
,
boolean
If true then this is the initial version sent via SSH_FXP_INIT otherwise it is a re-negotiation.
initial
,
int
The current version negotiated with the server
current
,
List<Integer>
Extra versions available - may be empty and/or contain only the current one
available
)

Implements org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
private final String name
selectorback to summary
protected final SftpVersionSelector selector

Constructor Detail

NamedVersionSelectorback to summary
public NamedVersionSelector(String name, SftpVersionSelector selector)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getNameback to summary
public String getName()

Implements org.apache.sshd.common.NamedResource.getName.

Returns:String

Doc from org.apache.sshd.common.NamedResource.getName.

The resource name

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
selectVersionback to summary
public int selectVersion(ClientSession session, boolean initial, int current, List<Integer> available)

Implements org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

Parameters
session:ClientSession

Doc from org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

The ClientSession through which the SFTP connection is made

initial:boolean

Doc from org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

If true then this is the initial version sent via SSH_FXP_INIT otherwise it is a re-negotiation.

current:int

Doc from org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

The current version negotiated with the server

available:List<Integer>

Doc from org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

Extra versions available - may be empty and/or contain only the current one

Returns:int

Doc from org.apache.sshd.sftp.client.SftpVersionSelector.selectVersion.

The new requested version - if same as current, then nothing is done

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override