Java Code Examples for org.springframework.shell.support.util.FileUtils#denotesAbsolutePath()
The following examples show how to use
org.springframework.shell.support.util.FileUtils#denotesAbsolutePath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirConverter.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private String convertCompletionBackIntoUserInputStyle( final String originalUserInput, final String completion) { if (FileUtils.denotesAbsolutePath(originalUserInput)) { // Input was originally as a fully-qualified path, so we just keep the // completion in that form return completion; } if (originalUserInput.startsWith(HOME_DIRECTORY_SYMBOL)) { // Input originally started with this symbol, so replace the user's home // directory with it again Assert.notNull(home, "Home directory could not be determined from system properties"); return HOME_DIRECTORY_SYMBOL + completion.substring(home.length()); } // The path was working directory specific, so strip the working directory // given the user never typed it return completion.substring(getWorkingDirectoryAsString().length()); }
Example 2
Source File: DirConverter.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * If the user input starts with a tilde character (~), replace the tilde * character with the user's home directory. If the user input does not start * with a tilde, simply return the original user input without any changes if * the input specifies an absolute path, or return an absolute path based on * the working directory if the input specifies a relative path. * * @param userInput * the user input, which may commence with a tilde (required) * @return a string that is guaranteed to no longer contain a tilde as the * first character (never null) */ private String convertUserInputIntoAFullyQualifiedPath(final String userInput) { if (FileUtils.denotesAbsolutePath(userInput)) { // Input is already in a fully-qualified path form return userInput; } if (userInput.startsWith(HOME_DIRECTORY_SYMBOL)) { // Replace this symbol with the user's actual home directory Assert.notNull(home, "Home directory could not be determined from system properties"); if (userInput.length() > 1) { return home + userInput.substring(1); } } // The path is working directory specific, so prepend the working directory String fullPath = getWorkingDirectoryAsString() + userInput; return fullPath; }
Example 3
Source File: DirConverter.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private String convertCompletionBackIntoUserInputStyle( final String originalUserInput, final String completion) { if (FileUtils.denotesAbsolutePath(originalUserInput)) { // Input was originally as a fully-qualified path, so we just keep the // completion in that form return completion; } if (originalUserInput.startsWith(HOME_DIRECTORY_SYMBOL)) { // Input originally started with this symbol, so replace the user's home // directory with it again Assert.notNull(home, "Home directory could not be determined from system properties"); return HOME_DIRECTORY_SYMBOL + completion.substring(home.length()); } // The path was working directory specific, so strip the working directory // given the user never typed it return completion.substring(getWorkingDirectoryAsString().length()); }
Example 4
Source File: DirConverter.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * If the user input starts with a tilde character (~), replace the tilde * character with the user's home directory. If the user input does not start * with a tilde, simply return the original user input without any changes if * the input specifies an absolute path, or return an absolute path based on * the working directory if the input specifies a relative path. * * @param userInput * the user input, which may commence with a tilde (required) * @return a string that is guaranteed to no longer contain a tilde as the * first character (never null) */ private String convertUserInputIntoAFullyQualifiedPath(final String userInput) { if (FileUtils.denotesAbsolutePath(userInput)) { // Input is already in a fully-qualified path form return userInput; } if (userInput.startsWith(HOME_DIRECTORY_SYMBOL)) { // Replace this symbol with the user's actual home directory Assert.notNull(home, "Home directory could not be determined from system properties"); if (userInput.length() > 1) { return home + userInput.substring(1); } } // The path is working directory specific, so prepend the working directory String fullPath = getWorkingDirectoryAsString() + userInput; return fullPath; }