Record Class IndexableAttachment

java.lang.Object
java.lang.Record
com.atlassian.confluence.pages.IndexableAttachment
All Implemented Interfaces:
Searchable, SearchableAttachment

public record IndexableAttachment(Attachment attachment) extends Record implements SearchableAttachment
A wrapper around an Attachment that implements the SearchableAttachment interface.
Since:
9.3
  • Constructor Details

    • IndexableAttachment

      public IndexableAttachment(Attachment attachment)
      Creates an instance of a IndexableAttachment record class.
      Parameters:
      attachment - the value for the attachment record component
  • Method Details

    • of

      public static IndexableAttachment of(Attachment attachment)
    • getContentType

      public String getContentType()
      Description copied from interface: SearchableAttachment
      Gets the MIME content-type of this attachment. If there is no content-type, return "application/x-unknown". Should never return null.
      Specified by:
      getContentType in interface SearchableAttachment
      Returns:
      the MIME content-type of the attachment, or "application/x-unknown" if the MIME type is unknown
    • getFileName

      public String getFileName()
      Description copied from interface: SearchableAttachment
      Gets the filename of this attachment. If there is no filename, return the empty string. This method should never return null.
      Specified by:
      getFileName in interface SearchableAttachment
      Returns:
      the filename of this attachment, or the empty string if there is no filename
    • getContentsAsStream

      public InputStream getContentsAsStream()
      Description copied from interface: SearchableAttachment
      Return the contents of the attachment as an InputStream
      Specified by:
      getContentsAsStream in interface SearchableAttachment
      Returns:
      an InputStream set at the start of the attachment's contents.
    • getContentsAsStream

      public InputStream getContentsAsStream(AttachmentManager attachmentManager)
    • getComment

      public String getComment()
      Description copied from interface: SearchableAttachment
      Return any comment associated with this attachment
      Specified by:
      getComment in interface SearchableAttachment
    • getNiceType

      public String getNiceType()
      Specified by:
      getNiceType in interface SearchableAttachment
    • getDescriptionForMimeType

      public static String getDescriptionForMimeType(String mimeType, String fileExtension)
      Parameters:
      mimeType - the mime type to be described. Should not be null
      fileExtension - the file extension to help with the deriving of the description.
      Returns:
      A more displayable description for the supplied mime type. If a blank String is supplied then null will be returned.
    • getNiceFileSize

      public String getNiceFileSize()
      Specified by:
      getNiceFileSize in interface SearchableAttachment
    • getDownloadPath

      public String getDownloadPath()
      Specified by:
      getDownloadPath in interface SearchableAttachment
    • getId

      public long getId()
      Specified by:
      getId in interface Searchable
    • getSearchableDependants

      public Collection<Searchable> getSearchableDependants()
      Description copied from interface: Searchable
      When we un-index something (say, a page), we also need to un-index everything contained within that page (comments, attachments), because presumably they're all about to go away.
      Specified by:
      getSearchableDependants in interface Searchable
    • isIndexable

      public boolean isIndexable()
      Description copied from interface: Searchable
      Allows an object to tell the search indexer that it is not allowed to be indexed
      Specified by:
      isIndexable in interface Searchable
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • attachment

      public Attachment attachment()
      Returns the value of the attachment record component.
      Returns:
      the value of the attachment record component