/** * Returns whether or not the first character in the specified String is a slash */ private static boolean isFirstCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(0) == ArchivePath.SEPARATOR; }
/** * Returns whether or not the first character in the specified String is a slash */ private static boolean isFirstCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(0) == ArchivePath.SEPARATOR; }
/** * Returns whether or not the last character in the specified String is a slash */ private static boolean isLastCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(path.length() - 1) == ArchivePath.SEPARATOR; }
/** * Returns whether or not the last character in the specified String is a slash */ private static boolean isLastCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(path.length() - 1) == ArchivePath.SEPARATOR; }
/** * Composes an absolute context from a given base and actual context relative to the base, returning the result. ie. * base of "base" and context of "context" will result in form "/base/context". */ public static String composeAbsoluteContext(final String base, final String context) { // Precondition checks assertSpecified(base); assertSpecified(context); // Compose final String relative = PathUtil.adjustToAbsoluteDirectoryContext(base); final String reformedContext = PathUtil.optionallyRemovePrecedingSlash(context); final String actual = relative + reformedContext; // Return return actual; }
/** * Composes an absolute context from a given base and actual context relative to the base, returning the result. ie. * base of "base" and context of "context" will result in form "/base/context". */ public static String composeAbsoluteContext(final String base, final String context) { // Precondition checks assertSpecified(base); assertSpecified(context); // Compose final String relative = PathUtil.adjustToAbsoluteDirectoryContext(base); final String reformedContext = PathUtil.optionallyRemovePrecedingSlash(context); final String actual = relative + reformedContext; // Return return actual; }
/** * Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyAppendSlash(final String path) { // Precondition check assertSpecified(path); // If the last character is not a slash if (!isLastCharSlash(path)) { // Append return path + ArchivePath.SEPARATOR; } // Return as-is return path; }
/** * Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyRemovePrecedingSlash(final String path) { // Precondition check assertSpecified(path); // Is there's a first character of slash if (isFirstCharSlash(path)) { // Return everything but first char return path.substring(1); } // Return as-is return path; }
/** * Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyRemovePrecedingSlash(final String path) { // Precondition check assertSpecified(path); // Is there's a first character of slash if (isFirstCharSlash(path)) { // Return everything but first char return path.substring(1); } // Return as-is return path; }
/** * Removes, if present, the absolute slash following the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyRemoveFollowingSlash(final String path) { // Precondition check assertSpecified(path); // Is there's a last character of slash if (isLastCharSlash(path)) { // Return everything but last char return path.substring(0, path.length() - 1); } // Return as-is return path; }
/** * Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyAppendSlash(final String path) { // Precondition check assertSpecified(path); // If the last character is not a slash if (!isLastCharSlash(path)) { // Append return path + ArchivePath.SEPARATOR; } // Return as-is return path; }
/** * Removes, if present, the absolute slash following the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyRemoveFollowingSlash(final String path) { // Precondition check assertSpecified(path); // Is there's a last character of slash if (isLastCharSlash(path)) { // Return everything but last char return path.substring(0, path.length() - 1); } // Return as-is return path; }