Package org.linphone.core

# Interface Content

public interface Content
This object holds data that can be embedded in a signaling message or IM
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...

## Method Summary

Modifier and Type
Method
Description
`void`
`addContentTypeParameter(String name, String value)`
Adds a parameter to the ContentType header.
`void`
`addCustomHeader(String headerName, String headerValue)`
Adds a custom header in a content.
`Content`
`clone()`
Instantiate a new message content with values from source.
`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.
`Content`
`findPartByHeader(String headerName, String headerValue)`
Find a part from a multipart content looking for a part header with a specified
value.
`byte[]`
`getBuffer()`
Get the content data buffer, usually a string.
`long`
`getCreationTimestamp()`
Returns the creation timestamp if this content is a FileContent (received or
sent by chat).
`String`
`getCustomHeader(String headerName)`
Get a custom header value of a content.
`String`
`getDisposition()`
Get the disposition of the Content, for example "recipient-list".
`String`
`getEncoding()`
Get the encoding of the data buffer, for example "gzip".
`int`
`getFileDuration()`
Gets the file duration in seconds, if information is available.
`String`
`getFilePath()`
Get the file transfer filepath set for this content (replace
linphone_chat_message_get_file_transfer_filepath).
`int`
`getFileSize()`
Get the file size if content is either a FileContent or a FileTransferContent.
`String`
`getKey()`
Get the key associated with a RCS file transfer message if encrypted.
`int`
`getKeySize()`
Get the size of key associated with a RCS file transfer message if encrypted.
`String`
`getName()`
Get the name associated with a RCS file transfer message.
`long`
`getNativePointer()`
Gets the native pointer used by this class to make native method calls.
`Content`
`getPart(int index)`
Get a part from a multipart content according to its index.
`Content[]`
`getParts()`
Get all the parts from a multipart content.
`String`
`getPlainFilePath()`
Deprecated.
`String`
`getRelatedChatMessageId()`
Returns the chat message id for which this content is related to, if any.
`int`
`getSize()`
Get the content data buffer size, excluding null character despite null
character is always set for convenience.
`String`
`getStringBuffer()`
Deprecated.
`String`
`getSubtype()`
Get the mime subtype of the content data.
`String`
`getType()`
Get the mime type of the content data.
`Object`
`getUserData()`
Gets the object stored in this object user's data
`String`
`getUtf8Text()`
Get the string content data buffer.
`boolean`
`isFile()`
Tells whether or not this content contains a file.
`boolean`
`isFileEncrypted()`
Tells whether or not this content contains an encrypted file.
`boolean`
`isFileTransfer()`
Tells whether or not this content is a file transfer.
`boolean`
`isIcalendar()`
Tells whether or not this content contains an icalendar by checking it's
content type.
`boolean`
`isMultipart()`
Tell whether a content is a multipart content.
`boolean`
`isText()`
Tells whether or not this content contains text.
`boolean`
`isVoiceRecording()`
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`
`setFileDuration(int duration)`
Sets the file duration in seconds (useful for media files for example).
`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`
`setName(String name)`
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`
`setStringBuffer(String buffer)`
Deprecated.
`void`
`setSubtype(String subtype)`
Set the mime subtype of the content data.
`void`
`setType(String type)`
Set the mime type of the content data.
`void`
`setUserData(Object data)`
Sets the object to store in this object user's data
`void`
`setUtf8Text(String buffer)`
Get the string content data buffer.
`String`
`toString()`

## Method Details

### getBuffer

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

Returns:
  The content data buffer.

### getCreationTimestamp

long getCreationTimestamp()
Returns the creation timestamp if this content is a FileContent (received or
sent by chat).

Returns:
  The timestamp at which this content was created if available, -1
  otherwise.

### getDisposition

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

Returns:
  The disposition of the Content.

### setDisposition

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

Parameters:
  `disposition` - The disposition of the Content.

### getEncoding

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

Returns:
  The encoding of the data buffer.

### setEncoding

void setEncoding(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.

Returns:
  The duration of the file in milliseconds or -1 if information isn't
  available.

### setFileDuration

void setFileDuration(int duration)
Sets the file duration in seconds (useful for media files for example).

Parameters:
  `duration` - the duration of the file, in milliseconds.

### getFilePath

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(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

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

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(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

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

Returns:
  A A list of `Content` objects. object holding the part if
  found, null otherwise.

### getPlainFilePath

@Deprecated String getPlainFilePath()
Deprecated.
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.
  deprecated: 2022-01-07. Use `exportPlainFile()` instead.

### getRelatedChatMessageId

String getRelatedChatMessageId()
Returns the chat message id for which this content is related to, if any.

Returns:
  The chat message ID if this content is related to a chat message, 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 String getStringBuffer()
Deprecated.
Get the string content data buffer.

Returns:
  The string content data buffer.
  deprecated: 2020-07-01. Use `getUtf8Text()` instead.

### setStringBuffer

@Deprecated void setStringBuffer(String buffer)
Deprecated.
Set the string content data buffer.

Parameters:
  `buffer` - The string content data buffer in UTF8.
  deprecated: 2020-07-01. Use `setUtf8Text(java.lang.String)` instead.

### getSubtype

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

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

### setSubtype

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

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

### getType

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

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

### setType

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

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

### getUtf8Text

String getUtf8Text()
Get the string content data buffer.
Introduced in 01/07/2020

Returns:
  The string content data buffer in UTF8.

### setUtf8Text

void setUtf8Text(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(String name, 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(String headerName, 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.

### clone

Content clone()
Instantiate a new message content with values from source.

Returns:
  The newly created `Content` object.

### 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

Content findPartByHeader(String headerName, 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

String getCustomHeader(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

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(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(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`