/** * Destructively converts this path to its canonical form. * <p> * In its canonical form, a path does not have any "." segments, and parent references ("..") are collapsed where * possible. * * @return true if the path was modified, and false otherwise. */ private boolean canonicalize() { // look for segments that need canonicalizing for (int i = 0, max = segments.length; i < max; i++) { String segment = segments[i]; if (segment.charAt(0) == '.' && (segment.equals("..") || segment.equals("."))) { //$NON-NLS-1$ //$NON-NLS-2$ // path needs to be canonicalized collapseParentReferences(); // paths of length 0 have no trailing separator if (segments.length == 0) { separators &= HAS_LEADING; } // recompute hash because canonicalize affects hash separators = (separators & ALL_SEPARATORS) | (computeHashCode() << USED_BITS); return true; } } return false; }