Record Class DocumentTextContent

java.lang.Object
java.lang.Record
org.exoplatform.documents.model.DocumentTextContent
Record Components:
text - the text of the file, null when none could be obtained
status - where the text came from, or why there is none
truncated - true when the text was cut at the most characters read on the fly, so its end is missing

public record DocumentTextContent(String text, DocumentTextContent.Status status, boolean truncated) extends Record
The text of a document file, together with where it came from or, when there is none, why: the search index when it already holds the file's text, the file itself when it does not, or the reason neither could give any.
  • Constructor Details

    • DocumentTextContent

      public DocumentTextContent(String text, DocumentTextContent.Status status, boolean truncated)
      Creates an instance of a DocumentTextContent record class.
      Parameters:
      text - the value for the text record component
      status - the value for the status record component
      truncated - the value for the truncated record component
  • Method Details

    • of

      public static DocumentTextContent of(String text, DocumentTextContent.Status status)
      Builds the content of a file whose text was found.
      Parameters:
      text - the text of the file
      status - DocumentTextContent.Status.INDEXED or DocumentTextContent.Status.EXTRACTED
      Returns:
      the content holding that text
    • truncated

      public static DocumentTextContent truncated(String text)
      Builds the content of a file whose text was extracted and cut at the most characters read on the fly.
      Parameters:
      text - the beginning of the text of the file
      Returns:
      the content holding that text, marked as cut
    • none

      public static DocumentTextContent none(DocumentTextContent.Status status)
      Builds the content of a file whose text could not be obtained.
      Parameters:
      status - why there is no text
      Returns:
      the content holding no text
    • hasText

      public boolean hasText()
      Whether a non-blank text was obtained.
      Returns:
      true when text() holds something to read
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • status

      public DocumentTextContent.Status status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • truncated

      public boolean truncated()
      Returns the value of the truncated record component.
      Returns:
      the value of the truncated record component