Interface Content


public interface Content
This object holds data that can be embedded in a signaling message.

Use Core.createContent() to create it, and then you should set at least
it's type and subtype and fill the buffer with your data.
A Content can be multipart (contain other contents), have file
information (name, path, size), be encrypted, have custom headers, etc...
It is mainly used to send information through a ChatMessage.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a parameter to the ContentType header.
    void
    addCustomHeader(String headerName, String headerValue)
    Adds a custom header in a content.
    Generates a temporary plain copy of the file and returns its paths The caller
    is responsible to then delete this temporary copy and the returned string.
    findPartByHeader(String headerName, String headerValue)
    Find a part from a multipart content looking for a part header with a specified
    value.
    byte[]
    Get the content data buffer, usually a string.
    getCustomHeader(String headerName)
    Get a custom header value of a content.
    Get the disposition of the Content, for example "recipient-list".
    Get the encoding of the data buffer, for example "gzip".
    int
    Gets the file duration in seconds, if information is available.
    Get the file transfer filepath set for this content (replace
    linphone_chat_message_get_file_transfer_filepath).
    int
    Get the file size if content is either a FileContent or a FileTransferContent.
    Get the key associated with a RCS file transfer message if encrypted.
    int
    Get the size of key associated with a RCS file transfer message if encrypted.
    Get the name associated with a RCS file transfer message.
    long
    Gets the native pointer used by this class to make native method calls.
    getPart(int index)
    Get a part from a multipart content according to its index.
    Get all the parts from a multipart content.
    Deprecated.
    2022-01-07.
    int
    Get the content data buffer size, excluding null character despite null
    character is always set for convenience.
    Deprecated.
    2020-07-01.
    Get the mime subtype of the content data.
    Get the mime type of the content data.
    Gets the object stored in this object user's data
    Get the string content data buffer.
    boolean
    Tells whether or not this content contains a file.
    boolean
    Tells whether or not this content contains an encrypted file.
    boolean
    Tells whether or not this content is a file transfer.
    boolean
    Tells whether or not this content contains an icalendar by checking it's
    content type.
    boolean
    Tell whether a content is a multipart content.
    boolean
    Tells whether or not this content contains text.
    boolean
    Tells whether or not this content contains a voice recording by checking it's
    content type.
    void
    setBuffer(byte[] buffer, int size)
    Set the content data buffer, usually a string.
    void
    setDisposition(String disposition)
    Set the disposition of the Content, for example "recipient-list".
    void
    setEncoding(String encoding)
    Set the encoding of the data buffer, for example "gzip".
    void
    setFilePath(String filePath)
    Set the file transfer filepath for this content (replace
    linphone_chat_message_set_file_transfer_filepath).
    void
    setKey(String key, int keyLength)
    Set the key associated with a RCS file transfer message if encrypted.
    void
    Set the name associated with a RCS file transfer message.
    void
    setSize(int size)
    Set the content data size, excluding null character despite null character is
    always set for convenience.
    void
    Deprecated.
    2020-07-01.
    void
    setSubtype(String subtype)
    Set the mime subtype of the content data.
    void
    Set the mime type of the content data.
    void
    Sets the object to store in this object user's data
    void
    Get the string content data buffer.
     
  • Method Details

    • getBuffer

      @NonNull byte[] getBuffer()
      Get the content data buffer, usually a string.

      Returns:
      The content data buffer.
    • getDisposition

      @Nullable String getDisposition()
      Get the disposition of the Content, for example "recipient-list".

      Returns:
      The disposition of the Content.
    • setDisposition

      void setDisposition(@Nullable String disposition)
      Set the disposition of the Content, for example "recipient-list".

      Parameters:
      disposition - The disposition of the Content.
    • getEncoding

      @Nullable String getEncoding()
      Get the encoding of the data buffer, for example "gzip".

      Returns:
      The encoding of the data buffer.
    • setEncoding

      void setEncoding(@Nullable String encoding)
      Set the encoding of the data buffer, for example "gzip".

      Parameters:
      encoding - The encoding of the data buffer.
    • getFileDuration

      int getFileDuration()
      Gets the file duration in seconds, if information is available.

    • getFilePath

      @Nullable String getFilePath()
      Get the file transfer filepath set for this content (replace
      linphone_chat_message_get_file_transfer_filepath).

      Returns:
      The file path set for this content if it has been set, null otherwise.

    • setFilePath

      void setFilePath(@Nullable String filePath)
      Set the file transfer filepath for this content (replace
      linphone_chat_message_set_file_transfer_filepath).

      Parameters:
      filePath - the file transfer filepath.
    • getFileSize

      int getFileSize()
      Get the file size if content is either a FileContent or a FileTransferContent.

      Returns:
      The represented file size.
    • isFile

      boolean isFile()
      Tells whether or not this content contains a file.

      Returns:
      true if this content contains a file, false otherwise.
    • isFileEncrypted

      boolean isFileEncrypted()
      Tells whether or not this content contains an encrypted file.

      Returns:
      True is this content contains a file and this file is encrypted, false
      otherwise.
    • isFileTransfer

      boolean isFileTransfer()
      Tells whether or not this content is a file transfer.

      Returns:
      true if this content is a file transfer, false otherwise.
    • isIcalendar

      boolean isIcalendar()
      Tells whether or not this content contains an icalendar by checking it's
      content type.

      Returns:
      true if this content type is 'text/calendar;conference-event=yes',
      false otherwise.
    • isMultipart

      boolean isMultipart()
      Tell whether a content is a multipart content.

      Returns:
      A boolean value telling whether the content is multipart or not.
    • isText

      boolean isText()
      Tells whether or not this content contains text.

      Returns:
      true if this content contains plain text, false otherwise.
    • isVoiceRecording

      boolean isVoiceRecording()
      Tells whether or not this content contains a voice recording by checking it's
      content type.

      Returns:
      true if this content type is 'audio/wav;voice-recording=yes', false
      otherwise.
    • getKey

      @Nullable String getKey()
      Get the key associated with a RCS file transfer message if encrypted.

      Returns:
      The key to encrypt/decrypt the file associated to this content.
    • getKeySize

      int getKeySize()
      Get the size of key associated with a RCS file transfer message if encrypted.

      Returns:
      The key size in bytes
    • getName

      @Nullable String getName()
      Get the name associated with a RCS file transfer message.

      It is used to store the original filename of the file to be downloaded from
      server.
      Returns:
      The name of the content.
    • setName

      void setName(@Nullable String name)
      Set the name associated with a RCS file transfer message.

      It is used to store the original filename of the file to be downloaded from
      server.
      Parameters:
      name - The name of the content.
    • getParts

      @NonNull Content[] getParts()
      Get all the parts from a multipart content.

      Returns:
      A object holding the part if found, null otherwise.
    • getPlainFilePath

      @Deprecated String getPlainFilePath()
      Deprecated.
      2022-01-07. Use exportPlainFile() instead.
      Generates a temporary plain copy of the file and returns its paths The caller
      is responsible to then delete this temporary copy and the returned string.

      Returns:
      The file path set for this content if it has been set, null otherwise.

    • getSize

      int getSize()
      Get the content data buffer size, excluding null character despite null
      character is always set for convenience.

      Returns:
      The content data buffer size.
    • setSize

      void setSize(int size)
      Set the content data size, excluding null character despite null character is
      always set for convenience.

      Parameters:
      size - The content data buffer size.
    • getStringBuffer

      @Deprecated @NonNull String getStringBuffer()
      Deprecated.
      2020-07-01. Use getUtf8Text() instead.
      Get the string content data buffer.

      Returns:
      The string content data buffer.
    • setStringBuffer

      @Deprecated void setStringBuffer(@NonNull String buffer)
      Deprecated.
      2020-07-01. Use setUtf8Text(java.lang.String) instead.
      Set the string content data buffer.

      Parameters:
      buffer - The string content data buffer in UTF8.
    • getSubtype

      @NonNull String getSubtype()
      Get the mime subtype of the content data.

      Returns:
      The mime subtype of the content data, for example "html".
    • setSubtype

      void setSubtype(@NonNull String subtype)
      Set the mime subtype of the content data.

      Parameters:
      subtype - The mime subtype of the content data, for example "html".
    • getType

      @NonNull String getType()
      Get the mime type of the content data.

      Returns:
      The mime type of the content data, for example "application".
    • setType

      void setType(@NonNull String type)
      Set the mime type of the content data.

      Parameters:
      type - The mime type of the content data, for example "application".
    • getUtf8Text

      @Nullable String getUtf8Text()
      Get the string content data buffer.

      Introduced in 01/07/2020
      Returns:
      The string content data buffer in UTF8.
    • setUtf8Text

      void setUtf8Text(@Nullable String buffer)
      Get the string content data buffer.

      Introduced in 01/07/2020
      Parameters:
      buffer - The string content data buffer in UTF8.
    • addContentTypeParameter

      void addContentTypeParameter(@NonNull String name, @Nullable String value)
      Adds a parameter to the ContentType header.

      Parameters:
      name - the name of the parameter to add.
      value - the value of the parameter to add.
    • addCustomHeader

      void addCustomHeader(@NonNull String headerName, @NonNull String headerValue)
      Adds a custom header in a content.

      Parameters:
      headerName - The name of the header to add.
      headerValue - The value of the header to add.
    • exportPlainFile

      String exportPlainFile()
      Generates a temporary plain copy of the file and returns its paths The caller
      is responsible to then delete this temporary copy and the returned string.

      Returns:
      The file path set for this content if it has been set, null otherwise.

    • findPartByHeader

      @Nullable Content findPartByHeader(@NonNull String headerName, @NonNull String headerValue)
      Find a part from a multipart content looking for a part header with a specified
      value.

      Parameters:
      headerName - The name of the header to look for.
      headerValue - The value of the header to look for.
      Returns:
      A Content object object the part if found, null otherwise.
    • getCustomHeader

      @Nullable String getCustomHeader(@NonNull String headerName)
      Get a custom header value of a content.

      Parameters:
      headerName - The name of the header to get the value from.
      Returns:
      The value of the header if found, null otherwise.
    • getPart

      @Nullable Content getPart(int index)
      Get a part from a multipart content according to its index.

      Parameters:
      index - The index of the part to get.
      Returns:
      A Content object holding the part if found, null otherwise.
    • setBuffer

      void setBuffer(@NonNull byte[] buffer, int size)
      Set the content data buffer, usually a string.

      Parameters:
      buffer - The content data buffer.
      size - The size of the content data buffer.
    • setKey

      void setKey(@NonNull String key, int keyLength)
      Set the key associated with a RCS file transfer message if encrypted.

      Parameters:
      key - The key to be used to encrypt/decrypt file associated to this
      content.
      keyLength - The lengh of the key.
    • setUserData

      void setUserData(Object data)
      Sets the object to store in this object user's data
      Parameters:
      data - the object to store
    • getUserData

      Object getUserData()
      Gets the object stored in this object user's data
      Returns:
      the object store if any, null otherwise
    • getNativePointer

      long getNativePointer()
      Gets the native pointer used by this class to make native method calls.
      Returns:
      the nativer pointer, as long
    • toString

      String toString()
      Overrides:
      toString in class Object