Package org.apache.sshd.sftp.client
Interface SftpVersionSelector
-
- All Known Implementing Classes:
SftpVersionSelector.NamedVersionSelector
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface SftpVersionSelector
- Author:
- Apache MINA SSHD Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSftpVersionSelector.NamedVersionSelectorWraps aSftpVersionSelectorand assigns it a name.
-
Field Summary
Fields Modifier and Type Field Description static SftpVersionSelector.NamedVersionSelectorCURRENTAnSftpVersionSelectorthat returns the current versionstatic SftpVersionSelector.NamedVersionSelectorMAXIMUMAnSftpVersionSelectorthat returns the maximum available versionstatic SftpVersionSelector.NamedVersionSelectorMINIMUMAnSftpVersionSelectorthat returns the minimum available version
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static SftpVersionSelector.NamedVersionSelectorfixedVersionSelector(int version)Creates a selector the always returns the requested (fixed version) regardless of what the current or reported available versions are.static SftpVersionSelector.NamedVersionSelectorpreferredVersionSelector(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 theselectVersion(ClientSession, boolean, int, List)method is invokedstatic SftpVersionSelector.NamedVersionSelectorpreferredVersionSelector(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 theselectVersion(ClientSession, boolean, int, List)method is invokedstatic SftpVersionSelector.NamedVersionSelectorresolveVersionSelector(String selector)Parses the input string to see if it matches one of the "known" selectors names (case insensitive).intselectVersion(ClientSession session, boolean initial, int current, List<Integer> available)
-
-
-
Field Detail
-
CURRENT
static final SftpVersionSelector.NamedVersionSelector CURRENT
AnSftpVersionSelectorthat returns the current version
-
MAXIMUM
static final SftpVersionSelector.NamedVersionSelector MAXIMUM
AnSftpVersionSelectorthat returns the maximum available version
-
MINIMUM
static final SftpVersionSelector.NamedVersionSelector MINIMUM
AnSftpVersionSelectorthat returns the minimum available version
-
-
Method Detail
-
selectVersion
int selectVersion(ClientSession session, boolean initial, int current, List<Integer> available)
- Parameters:
session- TheClientSessionthrough which the SFTP connection is madeinitial- Iftruethen this is the initial version sent viaSSH_FXP_INITotherwise it is a re-negotiation.current- The current version negotiated with the serveravailable- Extra versions available - may be empty and/or contain only the current one- Returns:
- The new requested version - if same as current, then nothing is done
-
fixedVersionSelector
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- The requested version- Returns:
- The
SftpVersionSelector.NamedVersionSelectorwrapping the requested version
-
preferredVersionSelector
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 theselectVersion(ClientSession, boolean, int, List)method is invoked- Parameters:
preferred- The preferred versions in decreasing order of preference (i.e., most preferred is 1st) - may not benull/empty- Returns:
- A
SftpVersionSelector.NamedVersionSelectorthat attempts to select the most preferred version that is also listed as available.
-
preferredVersionSelector
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 theselectVersion(ClientSession, boolean, int, List)method is invoked- Parameters:
preferred- The preferred versions in decreasing order of preference (i.e., most preferred is 1st)- Returns:
- A
SftpVersionSelector.NamedVersionSelectorthat attempts to select the most preferred version that is also listed as available.
-
resolveVersionSelector
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 afixedversion. Otherwise, assumes a comma separated list of versions in preferred order.- Parameters:
selector- The selector value - ifnull/empty then returnsCURRENT- Returns:
- Parsed
SftpVersionSelector.NamedVersionSelector
-
-