Class DocumentName

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

public final class DocumentName extends Object implements Comparable<DocumentName>
A collection of names for a document. All names in the set are either Rat (Linux like) or native (OS specific).
  • Field Details

    • FS_IS_CASE_SENSITIVE

      public static final boolean FS_IS_CASE_SENSITIVE
      True if the file system on which we are operating is case-sensitive
  • Constructor Details

    • DocumentName

      public DocumentName(String name, String baseName, String dirSeparator, boolean isCaseSensitive)
      Creates a Document name.
      Parameters:
      name - the name of the document
      baseName - the base name of the document.
      dirSeparator - the directory separator used in the name.
      isCaseSensitive - true if the name is case-sensitive.
    • DocumentName

      public DocumentName(File file, DocumentName baseName)
      Creates a document name with the name of the file and the same basename as the baseName document.
      Parameters:
      file - the file to name the document from.
      baseName - the DocumentName to provide the baseName.
    • DocumentName

      public DocumentName(File file)
      Creates a document name with the name and basename equal to the file name
      Parameters:
      file - the file name to use.
  • Method Details

    • resolve

      public DocumentName resolve(String child)
      Creates a new document name by adding the child to the current name.
      Parameters:
      child - the child to add (must use directory separator from this document name).
      Returns:
      the new document name with the same base name, directory separator and case sensitivity as this one.
    • getName

      public String getName()
      Gets the fully qualified name of the document.
      Returns:
      the fully qualified name of the document.
    • getBaseName

      public String getBaseName()
      Gets the fully qualified basename of the document.
      Returns:
      the fully qualified basename of the document.
    • getBaseDocumentName

      public DocumentName getBaseDocumentName()
      Gets the DocumentName for the basename of this document name.
      Returns:
      the DocumentName for the basename of this document name.
    • getDirectorySeparator

      public String getDirectorySeparator()
      Returns the directory separator.
      Returns:
      the directory separator.
    • localized

      public String localized()
      Gets the portion of the name that is not part of the base name. The resulting name will always start with the directory separator.
      Returns:
      the portion of the name that is not part of the base name.
    • localized

      public String localized(String dirSeparator)
      Gets the portion of the name that is not part of the base name. The resulting name will always start with the directory separator.
      Parameters:
      dirSeparator - The character to use to separate directories in the result.
      Returns:
      the portion of the name that is not part of the base name.
    • tokenize

      public String[] tokenize(String source)
      Tokenizes the string based on the dirSeparator
      Parameters:
      source - the source to tokenize
      Returns:
      the array of tokenized strings.
    • getShortName

      public String getShortName()
      Gets the last segment of the name. This is the part after the last directory separator.
      Returns:
      the last segment of the name.
    • isCaseSensitive

      public boolean isCaseSensitive()
      Gets the case sensitivity flag.
      Returns:
      true if the name is case-sensitive.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

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

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

      public int hashCode()
      Overrides:
      hashCode in class Object