Package org.apache.rat.testhelpers
Class TestingDocument
java.lang.Object
org.apache.rat.api.Document
org.apache.rat.testhelpers.TestingDocument
- All Implemented Interfaces:
Comparable<Document>
A Document for testing. The document is guaranteed to have a name and may have content (specified in the constructor).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.rat.api.Document
Document.Type -
Field Summary
Fields inherited from class org.apache.rat.api.Document
name, nameMatcher -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a TestingDocument with the name"name"and no content.TestingDocument(Reader reader, String name) Constructs a TestingDocument with the name"name"and the content provided by the reader.TestingDocument(String name) Constructs a TestingDocument with the specified"name", no content and will not have an associated document name matcher.TestingDocument(String name, DocumentNameMatcher matcher) Constructs a TestingDocument with the specified"name", no content and the specified DocumentNameMatcher associated with it.TestingDocument(org.apache.commons.io.function.IOSupplier<InputStream> inputSupplier, String name) Constructs a TestingDocument with the name"name"and the content provided by the input stream.TestingDocument(DocumentName documentName) Constructs a TestingDocument with the specified DocumentName, no content and theDocumentNameMatcher.MATCHES_ALLname matcher associated with it. -
Method Summary
Modifier and TypeMethodDescriptionReturns the input stream if it was provided in the constructor.booleanReturnsfalseas a document is no directory.A document does not have any children.reader()Gets the reader for the document content.Methods inherited from class org.apache.rat.api.Document
compareTo, equals, getMetaData, getName, getNameMatcher, hashCode, isIgnored, toString
-
Constructor Details
-
TestingDocument
public TestingDocument()Constructs a TestingDocument with the name"name"and no content. -
TestingDocument
Constructs a TestingDocument with the specified"name", no content and will not have an associated document name matcher.- Parameters:
name- the name of the document.
-
TestingDocument
Constructs a TestingDocument with the specified DocumentName, no content and theDocumentNameMatcher.MATCHES_ALLname matcher associated with it.- Parameters:
documentName- the document name.
-
TestingDocument
Constructs a TestingDocument with the specified"name", no content and the specified DocumentNameMatcher associated with it.- Parameters:
name- the document name.matcher- the associated document name matcher.
-
TestingDocument
Constructs a TestingDocument with the name"name"and the content provided by the reader.- Parameters:
reader- the reader that provides content for the document.name- the name of the document.
-
TestingDocument
public TestingDocument(org.apache.commons.io.function.IOSupplier<InputStream> inputSupplier, String name) Constructs a TestingDocument with the name"name"and the content provided by the input stream.- Parameters:
inputSupplier- the input supplier that provides content for the document as an input stream.name- the name of the document.
-
-
Method Details
-
reader
Gets the reader for the document content.- Overrides:
readerin classDocument- Returns:
- the reader for the contents.
- Throws:
IOException- on IO error when reading from input stream.NullPointerException- if neither the reader nor the input stream were provided.
-
isDirectory
public boolean isDirectory()Returnsfalseas a document is no directory.- Specified by:
isDirectoryin classDocument- Returns:
- always returns
false.
-
listChildren
A document does not have any children.- Specified by:
listChildrenin classDocument- Returns:
- always returns an empty set.
-
inputStream
Returns the input stream if it was provided in the constructor.- Specified by:
inputStreamin classDocument- Returns:
- the input stream if it was provided in the constructor.
- Throws:
IOException- if the input stream can not be retrieved.UnsupportedOperationException- if the input stream was not provided.
-