TrueZIP Kernel 7.0-rc1

de.schlichtherle.truezip.io
Class Paths.Normalizer

java.lang.Object
  extended by de.schlichtherle.truezip.io.Paths.Normalizer
Enclosing class:
Paths

public static class Paths.Normalizer
extends Object

A normalizer for path names.


Field Summary
private  StringBuilder buffer
           
private  String path
           
private  char separatorChar
           
 
Constructor Summary
Paths.Normalizer(char separatorChar)
           
 
Method Summary
private  int normalize(int collapse, int end)
          This is a recursive call: The top level call should provide 0 as the skip parameter, the length of the path as the end parameter and an empty string buffer as the result parameter.
 String normalize(String path)
          Removes all redundant separators, dot directories (".") and dot-dot directories ("..") from the path name and returns the result.
private  void slashify()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

separatorChar

private final char separatorChar

path

private String path

buffer

private final StringBuilder buffer
Constructor Detail

Paths.Normalizer

public Paths.Normalizer(char separatorChar)
Method Detail

normalize

public String normalize(String path)
Removes all redundant separators, dot directories (".") and dot-dot directories ("..") from the path name and returns the result. If present, a single trailing separator character is retained, except after a dot-dot directory which couldn't get erased. A resulting single dot-directory is truncated to an empty path.

On Windows, a path may be prefixed by a drive letter followed by a colon. On all platforms, a path may be prefixed by two leading separators to indicate a UNC, although this is currently only supported on Windows.

Parameters:
path - the non-null path name to normalize.
Returns:
path if it was already in normalized form. Otherwise, a new string with the normalized form of the given path name.

normalize

private int normalize(int collapse,
                      int end)
This is a recursive call: The top level call should provide 0 as the skip parameter, the length of the path as the end parameter and an empty string buffer as the result parameter.

Parameters:
collapse - the number of adjacent dir/.. segments in the path to collapse. This value must not be negative.
end - the current position in path. Only the string to the left of this index is considered. If not positive, nothing happens.
Returns:
The number of adjacent segments in the path which have not been collapsed at this position.

slashify

private void slashify()

TrueZIP Kernel 7.0-rc1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.