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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSftpVersionSelector.NamedVersionSelector
-
Field Summary
Fields Modifier and Type Field Description static SftpVersionSelectorCURRENTAnSftpVersionSelectorthat returns the current versionstatic SftpVersionSelectorMAXIMUMAnSftpVersionSelectorthat returns the maximum available versionstatic SftpVersionSelectorMINIMUMAnSftpVersionSelectorthat returns the maximum available version
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static SftpVersionSelectorfixedVersionSelector(int version)Creates a selector the always returns the requested (fixed version) regardless of what the current or reported available versions are.static SftpVersionSelectorpreferredVersionSelector(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, int, List)method is invokedstatic SftpVersionSelectorpreferredVersionSelector(java.lang.Iterable<? extends java.lang.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, int, List)method is invokedintselectVersion(ClientSession session, int current, java.util.List<java.lang.Integer> available)
-
-
-
Field Detail
-
CURRENT
static final SftpVersionSelector CURRENT
AnSftpVersionSelectorthat returns the current version
-
MAXIMUM
static final SftpVersionSelector MAXIMUM
AnSftpVersionSelectorthat returns the maximum available version
-
MINIMUM
static final SftpVersionSelector MINIMUM
AnSftpVersionSelectorthat returns the maximum available version
-
-
Method Detail
-
selectVersion
int selectVersion(ClientSession session, int current, java.util.List<java.lang.Integer> available)
- Parameters:
session- TheClientSessionthrough which the SFTP connection is madecurrent- 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 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
-
preferredVersionSelector
static SftpVersionSelector 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, 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
SftpVersionSelectorthat attempts to select the most preferred version that is also listed as available.
-
preferredVersionSelector
static SftpVersionSelector preferredVersionSelector(java.lang.Iterable<? extends java.lang.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, int, List)method is invoked- Parameters:
preferred- The preferred versions in decreasing order of preference (i.e., most preferred is 1st)- Returns:
- A
SftpVersionSelectorthat attempts to select the most preferred version that is also listed as available.
-
-