Class DocumentName.FSInfo

java.lang.Object
org.apache.rat.document.DocumentName.FSInfo
All Implemented Interfaces:
Comparable<DocumentName.FSInfo>
Enclosing class:
DocumentName

public static final class DocumentName.FSInfo extends Object implements Comparable<DocumentName.FSInfo>
The file system information needed to process document names.
  • Constructor Details

    • FSInfo

      public FSInfo(FileSystem fileSystem)
      Constructor. Extracts the necessary data from the file system.
      Parameters:
      fileSystem - the file system to extract data from.
  • Method Details

    • getDefault

      public static DocumentName.FSInfo getDefault()
      Gets the FSInfo for the default file system. If the System property FSInfo is set, the FSInfo stored there is used, otherwise the FileSystem returned from FileSystems.getDefault() is used.
      Returns:
      the FSInfo for the default file system.
    • toString

      public String toString()
      Gets the common name for the underlying file system.
      Overrides:
      toString in class Object
      Returns:
      the common file system name.
    • dirSeparator

      public String dirSeparator()
      Gets the directory separator.
      Returns:
      The directory separator.
    • isCaseSensitive

      public boolean isCaseSensitive()
      Gets the case-sensitivity flag.
      Returns:
      the case-sensitivity flag.
    • rootFor

      public Optional<String> rootFor(String name)
      Retrieves the root extracted from the name.
      Parameters:
      name - the name to extract the root from
      Returns:
      an optional containing the root or empty.
    • roots

      public String[] roots()
      Gets the array of roots for this file system.
      Returns:
      an array of roots for this file system.
    • tokenize

      public String[] tokenize(String source)
      Tokenizes the string based on the directory separator of this DocumentName.
      Parameters:
      source - the source to tokenize.
      Returns:
      the array of tokenized strings.
    • normalize

      public String normalize(String pattern)
      Removes . and .. from filenames.
      Parameters:
      pattern - the file name pattern
      Returns:
      the normalized file name.
    • mkPath

      public String mkPath(String... segments)
      Creates a path separated by the directory separator. Starting with an empty string will cause the directory separator to appear at the beginning.
      Parameters:
      segments - the segments that make up the path.
      Returns:
      the path string.
    • startsWithRootOrSeparator

      public boolean startsWithRootOrSeparator(String candidate)
      Determines if the candidate string starts with a root or directory separator as defined in this FSInfo.
      Parameters:
      candidate - the candidate string to test.
      Returns:
      true if the candidate starts with a root or a directory separator.
    • compareTo

      public int compareTo(DocumentName.FSInfo other)
      Specified by:
      compareTo in interface Comparable<DocumentName.FSInfo>
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object