Class Document

java.lang.Object
org.apache.rat.api.Document
All Implemented Interfaces:
Comparable<Document>
Direct Known Subclasses:
ArchiveEntryDocument, FileDocument, IgnoredDocument

public abstract class Document extends Object implements Comparable<Document>
The representation of a document being scanned.
  • Field Details

    • nameMatcher

      protected final DocumentNameMatcher nameMatcher
      The path matcher used by this document
    • name

      protected final DocumentName name
      The fully qualified name of this document
  • Constructor Details

    • Document

      protected Document(DocumentName name, DocumentNameMatcher nameMatcher)
      Creates an instance.
      Parameters:
      name - the native NameSet of the resource.
      nameMatcher - the document name matcher to filter directories/files.
  • Method Details

    • getName

      public final DocumentName getName()
      Gets the name of the current document.
      Returns:
      the name of the current document.
    • getNameMatcher

      public final DocumentNameMatcher getNameMatcher()
      Gets the file filter this document was created with.
      Returns:
      the file filter this document was created with.
    • compareTo

      public int compareTo(Document doc)
      Specified by:
      compareTo in interface Comparable<Document>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • reader

      public Reader reader() throws IOException
      Reads the contents of this document.
      Returns:
      Reader not null
      Throws:
      IOException - if this document cannot be read.
    • inputStream

      public abstract InputStream inputStream() throws IOException
      Streams the document's contents.
      Returns:
      a non-null input stream of the document.
      Throws:
      IOException - when stream could not be opened.
    • getMetaData

      public final MetaData getMetaData()
      Gets data describing this resource.
      Returns:
      a non-null MetaData object.
    • isIgnored

      public final boolean isIgnored()
      Checks if document is ignored or not.
      Returns:
      true if the document is of type IGNORED.
    • toString

      public String toString()
      Representations suitable for logging.
      Overrides:
      toString in class Object
      Returns:
      a String representation of this object.
    • isDirectory

      public abstract boolean isDirectory()
      Determines if this document is a directory type.
      Returns:
      true if this is a directory.
    • listChildren

      public abstract SortedSet<Document> listChildren()
      Gets a sorted set of documents that are children of this document.
      Returns:
      A sorted set of child Documents. May be empty.