Sequenceablepublic class PasteData extends Object implements Sequenceable
This class provides data records defined by PasteData.Record,
and data properties defined by PasteData.DataProperty.
PasteData.Record contains complex data which is created and added using SystemPasteboard
by an application. Data in a Record can be a description of plain text, HTML text, an intent, or a URI.
A PasteData object contains one Record instance or a limited number of them.
A PasteData object contains one Record instance or a combination of them.
The size of the pasted data transferred each time within a device cannot exceed 500 KB. Data transferred among devices each time cannot exceed 64 KB, and the data must be in the text format.
DataProperty describes properties of pasted data, such as MIME types and storage timestamp.
SystemPasteboard can transfer objects through data URIs, and a recipient uses
DataAbilityHelper to read the object identified by the URI. This transfers complex
binary objects between applications, such as images and media files.
SystemCapability.Miscservices#PASTEBOARD| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
PasteData.DataProperty |
This class defines properties of
PasteData on the system pasteboard, including the timestamp,
MIME types, and additional property data. |
static class |
PasteData.Record |
This class defines single pasted data as
Record, which can be plain text, HTML text, URIs, and intents. |
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
MAX_RECORD_NUM |
Indicates the maximum number of records allowed in a
PasteData object. |
static String |
MIMETYPE_TEXT_HTML |
Indicates MIME types of HTML text.
|
static String |
MIMETYPE_TEXT_INTENT |
Indicates MIME types of intents.
|
static String |
MIMETYPE_TEXT_PLAIN |
Indicates MIME types of plain text.
|
static String |
MIMETYPE_TEXT_URI |
Indicates MIME types of URIs.
|
| 构造器 | 说明 |
|---|---|
PasteData() |
A constructor used to create an empty
PasteData object. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addHtmlRecord(String htmlText) |
Adds a
Record for HTML text to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. |
void |
addIntentRecord(Intent intent) |
Adds an intent
Record to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_INTENT in DataProperty. |
void |
addRecord(PasteData.Record record) |
Adds a
PasteRecord to a PasteData object and updates MIME types in DataProperty. |
void |
addTextRecord(CharSequence text) |
Adds a
Record for plain text to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. |
void |
addUriRecord(Uri uri) |
Adds a URI
Record to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. |
static PasteData |
creatHtmlData(String htmlText) |
Creates a
PasteData object for PasteData#MIMETYPE_TEXT_HTML. |
static PasteData |
creatIntentData(Intent intent) |
Creates a
PasteData object for PasteData#MIMETYPE_TEXT_INTENT. |
static PasteData |
creatPlainTextData(CharSequence text) |
Creates a
PasteData object for PasteData#MIMETYPE_TEXT_PLAIN. |
static PasteData |
creatUriData(Uri uri) |
Creates a
PasteData object for PasteData#MIMETYPE_TEXT_URI. |
List<String> |
getMimeTypes() |
Obtains MIME types of all content on the pasteboard.
|
String |
getPrimaryHtml() |
Obtains HTML text of the primary record in a
PasteData object. |
Intent |
getPrimaryIntent() |
Obtains the intent of the primary record in a
PasteData object. |
String |
getPrimaryMimeType() |
Obtains the MIME type of the primary record in a
PasteData object. |
CharSequence |
getPrimaryText() |
Obtains the plain text of the primary record in a
PasteData object. |
Uri |
getPrimaryUri() |
Obtains the URI of the primary record in a
PasteData object. |
PasteData.DataProperty |
getProperty() |
Obtains
DataProperty of a PasteData object. |
PasteData.Record |
getRecordAt(int index) |
Obtains a
Record based on a specified index. |
int |
getRecordCount() |
Obtains the number of records in a
PasteData object. |
CharSequence |
getTag() |
Obtains the user-defined tag of a
PasteData object. |
boolean |
hasMimeType(String mimeType) |
Checks whether there is a specified MIME type of data in
DataProperty. |
boolean |
marshalling(Parcel parcel) |
Marshals a
PasteData object into a Parcel. |
boolean |
removeRecordAt(int index) |
Removes a
Record based on a specified index. |
boolean |
replaceRecordAt(int index,
PasteData.Record record) |
Replaces a specified record with a new one.
|
boolean |
unmarshalling(Parcel parcel) |
Unmarshals a
PasteData object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasFileDescriptorpublic static final int MAX_RECORD_NUM
PasteData object.public static final String MIMETYPE_TEXT_HTML
public static final String MIMETYPE_TEXT_INTENT
public static final String MIMETYPE_TEXT_PLAIN
public PasteData()
PasteData object.public static PasteData creatPlainTextData(CharSequence text)
PasteData object for PasteData#MIMETYPE_TEXT_PLAIN.text - Indicates the plain text to store.PasteData object if created;
returns null if the input parameter is null.public static PasteData creatHtmlData(String htmlText)
PasteData object for PasteData#MIMETYPE_TEXT_HTML.htmlText - Indicates the HTML text to store.PasteData object if created;
returns null if the input parameter is null.public static PasteData creatUriData(Uri uri)
PasteData object for PasteData#MIMETYPE_TEXT_URI.uri - Indicates an URI to store.PasteData object if created;
returns null if the input parameter is null.public static PasteData creatIntentData(Intent intent)
PasteData object for PasteData#MIMETYPE_TEXT_INTENT.intent - Indicates an intent to store.PasteData object if created;
returns null if the input parameter is null.public String getPrimaryMimeType()
PasteData object.public CharSequence getPrimaryText()
PasteData object.null if there is no record.public String getPrimaryHtml()
PasteData object.null if there is no record.public Uri getPrimaryUri()
PasteData object.null if there is no record.public Intent getPrimaryIntent()
PasteData object.null if there is no record.public void addTextRecord(CharSequence text)
Record for plain text to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty.
Note that after the maximum number of records allowed in the PasteData object
has been reached, the addition will be invalid.
text - Indicates the plain text to add.
This parameter cannot be null. Otherwise, the addition will fail.public void addHtmlRecord(String htmlText)
Record for HTML text to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty.
Note that after the maximum number of records allowed in the PasteData object
has been reached, the addition will be invalid.
htmlText - Indicates HTML text to add.
This parameter cannot be null. Otherwise, the addition will fail.public void addUriRecord(Uri uri)
Record to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty.
Note that after the maximum number of records allowed in the PasteData object
has been reached, the addition will be invalid.
uri - Indicates the URI to add.
This parameter cannot be null. Otherwise, the addition will fail.public void addIntentRecord(Intent intent)
Record to a PasteData object,
and updates the MIME type to PasteData#MIMETYPE_TEXT_INTENT in DataProperty.
Note that after the maximum number of records allowed in the PasteData object
has been reached, the addition will be invalid.
intent - Indicates the intent to add.
This parameter cannot be null. Otherwise, the addition will fail.public void addRecord(PasteData.Record record)
PasteRecord to a PasteData object and updates MIME types in DataProperty.
Note that after the maximum number of records allowed in the PasteData object has been reached,
the addition will be invalid.
record - Indicates the Record object to add.
This parameter cannot be null. Otherwise, the addition will fail.public int getRecordCount()
PasteData object.PasteData.public PasteData.Record getRecordAt(int index)
Record based on a specified index.index - Indicates the index of the record to obtain, which ranges from 0 to getRecordCount()-1.null if no record matching the index.public boolean removeRecordAt(int index)
Record based on a specified index.index - Indicates the index of the record to remove, which ranges from 0 to getRecordCount()-1.true if the record is removed; returns false otherwise.public boolean replaceRecordAt(int index,
PasteData.Record record)
The record index ranges from 0 to getRecordCount()-1.
index - Indicates the index of the record to be replaced,
which ranges from 0 to getRecordCount()-1.record - Indicates the new record.true if the replacement is successful; returns false otherwise.public List<String> getMimeTypes()
DataProperty;
returns an empty list if there is no data.public boolean hasMimeType(String mimeType)
DataProperty.mimeType - Indicates a MIME type to search.true if DataProperty contains the MIME type; returns false otherwise.public PasteData.DataProperty getProperty()
DataProperty of a PasteData object.DataProperty of this PasteData.public CharSequence getTag()
PasteData object.public boolean marshalling(Parcel parcel)
PasteData object into a Parcel.marshalling 在接口中 Sequenceableparcel - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel parcel)
PasteData object from a Parcel.unmarshalling 在接口中 Sequenceableparcel - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.