/** * Initializes the current path with the given string. */ private Path initialize(String path) { assert path != null; path = collapseSlashes(path); int len = path.length(); // compute the separators array if (len < 2) { if (len == 1 && path.charAt(0) == SEPARATOR) { separators = HAS_LEADING; } else { separators = 0; } } else { boolean hasLeading = path.charAt(0) == SEPARATOR; boolean hasTrailing = path.charAt(len - 1) == SEPARATOR; separators = hasLeading ? HAS_LEADING : 0; if (hasTrailing) { separators |= HAS_TRAILING; } } // compute segments and ensure canonical form segments = computeSegments(path); if (!canonicalize()) { // compute hash now because canonicalize didn't need to do it separators = (separators & ALL_SEPARATORS) | (computeHashCode() << USED_BITS); } return this; }