public class FileDocument extends java.lang.Object implements Document
File
.Modifier and Type | Field and Description |
---|---|
protected @Nullable java.lang.String |
content
The content of this document.
|
protected @NotNull java.io.File |
file
The file of this file document.
|
Constructor and Description |
---|
FileDocument(@NotNull java.io.File file)
Construct a new document for the given
file . |
FileDocument(@NotNull java.lang.String filename)
Construct a new document for the file with the given
filename . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(@Nullable java.lang.Object object)
Determines if the given
object equals this document or not. |
int |
hashCode()
Calculate the hash code of this document.
|
static @NotNull Document[] |
hierarchy(@NotNull java.io.File file)
Return an array of all the document in the hierarchy of the given
file
(including itself). |
static @NotNull java.util.Set<Document> |
hierarchySet(@NotNull java.io.File file)
Return a set of all the document in the hierarchy of the given
file
(including itself). |
@NotNull java.io.InputStream |
openInputStream()
Open a new input-stream that reads the content of this document.
|
@NotNull java.io.Reader |
openReader()
Open a new reader that reads the content of this document.
|
@NotNull java.lang.CharSequence |
read()
Read the content of this document.
|
@NotNull java.lang.String |
toString()
Returns a string representation of this document.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
openInputStream, openReader, read
@NotNull protected final @NotNull java.io.File file
@Nullable protected @Nullable java.lang.String content
public FileDocument(@NotNull @NotNull java.lang.String filename)
filename
.filename
- the name of the file for the constructed document.java.lang.NullPointerException
- if the given filename
is null.public FileDocument(@NotNull @NotNull java.io.File file)
file
.file
- the file for the constructed document.java.lang.NullPointerException
- if the given file
is null.@NotNull @Contract(value="_->new", pure=true) public static @NotNull Document[] hierarchy(@NotNull @NotNull java.io.File file)
file
(including itself).file
- the file to collect the documents in its hierarchy (including itself).file
.java.lang.NullPointerException
- if the given file
is null.@NotNull @Contract(value="_->new", pure=true) public static @NotNull java.util.Set<Document> hierarchySet(@NotNull @NotNull java.io.File file)
file
(including itself).file
- the file to collect the documents in its hierarchy (including itself).file
.java.lang.NullPointerException
- if the given file
is null.public boolean equals(@Nullable @Nullable java.lang.Object object)
Document
object
equals this document or not. An object
equals a document when that object is pointing to the same source as this document.
(regardless of its content, assuming the user is honest and does not provide two
documents with same source but from different origins or have different content)
equals = object instanceof Document && this.toString().equals(object.toString())
public int hashCode()
Document
hashCode = <SourceUniqIdentifiers>
@NotNull public @NotNull java.io.InputStream openInputStream() throws java.io.FileNotFoundException, DocumentNotFoundException
Document
openInputStream
in interface Document
DocumentNotFoundException
- if this document is not available for reading.java.io.FileNotFoundException
@NotNull public @NotNull java.io.Reader openReader() throws java.io.FileNotFoundException, DocumentNotFoundException
Document
openReader
in interface Document
DocumentNotFoundException
- if this document is not available for reading.java.io.FileNotFoundException
@NotNull public @NotNull java.lang.CharSequence read()
Document
@NotNull public @NotNull java.lang.String toString()
Document
toString = <SourceUniqName>