鴻蒙OS PersistablePacMap

2022-09-03 09:54 更新

PersistablePacMap

java.lang.Object

|---ohos.utils.BasePacMap

|---|---ohos.utils.PersistablePacMap

public class PersistablePacMap
extends BasePacMap

擴(kuò)展 BasePacMap 類并使用 JSON 字符串表示永久存儲(chǔ)數(shù)據(jù)。

嵌套類摘要

從接口 ohos.utils.Sequenceable 繼承的嵌套類/接口
Sequenceable.ProducerT

字段摘要

從類 ohos.utils.BasePacMap 繼承的字段
dataMap

構(gòu)造函數(shù)摘要

構(gòu)造函數(shù) 描述
PersistablePacMap() 用于創(chuàng)建空 PersistablePacMap 實(shí)例的構(gòu)造函數(shù)。
PersistablePacMap(int capacity) 用于創(chuàng)建包含容量鍵值對(duì)的空 PersistablePacMap 實(shí)例的構(gòu)造函數(shù)。

方法總結(jié)

修飾符和類型 方法 描述
PersistablePacMap deepCopy() 創(chuàng)建 PersistablePacMap 對(duì)象的深層副本。
static PersistablePacMap fromJsonString(String jsonString) 基于給定的 JSON 字符串創(chuàng)建 PersistablePacMap 對(duì)象。
boolean[] getBooleanValueArray(String key) 覆蓋 BasePacMap#getBooleanValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的布爾數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。
double getDoubleValue(String key) 覆蓋 BasePacMap#getDoubleValue 方法以獲取 unmarshalled PersistablePacMap 對(duì)象中的 double 值,其中 double 已轉(zhuǎn)換為 BigDecimal。
double[] getDoubleValueArray(String key) 覆蓋 BasePacMap#getDoubleValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的雙精度數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。
float getFloatValue(String key) 重寫(xiě) BasePacMap#getFloatValue 方法以獲取未編組的 PersistablePacMap 對(duì)象中的浮點(diǎn)值,其中浮點(diǎn)已轉(zhuǎn)換為 BigDecimal。
float[] getFloatValueArray(String key) 覆蓋 BasePacMap#getFloatValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的浮點(diǎn)數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。
int[] getIntValueArray(String key) 覆蓋 BasePacMap#getIntValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的 int 數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。
long getLongValue(String key) 重寫(xiě) BasePacMap#getLongValue 方法以獲取未編組的 PersistablePacMap 對(duì)象中的 long 值,其中 long 已轉(zhuǎn)換為 Integer。
long[] getLongValueArray(String key) 覆蓋 BasePacMap#getLongValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的長(zhǎng)數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。
PersistablePacMap getPersistablePacMap(String key) 獲取具有指定鍵的 PersistablePacMap 對(duì)象。
short getShortValue(String key) 覆蓋 BasePacMap#getShortValue 方法以獲取未編組的 PersistablePacMap 對(duì)象中的 short 值,其中 short 已轉(zhuǎn)換為 Integer。
short[] getShortValueArray(String key) 覆蓋 BasePacMap#getShortValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的短數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。
static boolean isValidValueType(Object value) 檢查值對(duì)象的類型是否支持對(duì) JSON 字符串進(jìn)行編組和解組。
void putPersistablePacMap(String key, PersistablePacMap value) 將具有指定鍵的 PersistablePacMap 對(duì)象添加到此 PersistablePacMap 對(duì)象中。
String toJsonString() 獲取 PersistablePacMap 對(duì)象的 JSON 字符串表示形式。
從類 ohos.utils.BasePacMap 繼承的方法
clear, clone, equals, getAll, getBooleanValue, getBooleanValue, getByteValue, getByteValue, getByteValueArray, getChar, getChar, getCharArray, getClassLoader, getDimension, getDoubleValue, getFloatDimension, getFloatValue, getIntValue, getIntValue, getKeys, getLongValue, getObjectValue, getObjectValue, getPlainArray, getRemoteObject, getShortValue, getSize, getString, getString, getStringArray, hasFileDescriptor, hashCode, hasKey, isEmpty, marshalling, putAll, putAll, putBooleanValue, putBooleanValueArray, putByteValue, putByteValueArray, putChar, putCharArray, putDimension, putDoubleValue, putDoubleValueArray, putFloatDimension, putFloatValue, putFloatValueArray, putIntValue, putIntValueArray, putLongValue, putLongValueArray, putObjectValue, putPlainArray, putRemoteObject, putShortValue, putShortValueArray, putString, putStringArray, remove, setClassLoader, unmarshalling
從類 java.lang.Object 繼承的方法
finalize, getClass, notify, notifyAll, toString, wait, wait, wait

構(gòu)造函數(shù)詳細(xì)信息

PersistablePacMap

public PersistablePacMap()

用于創(chuàng)建空 PersistablePacMap 實(shí)例的構(gòu)造函數(shù)。

PersistablePacMap

public PersistablePacMap(int capacity)

用于創(chuàng)建包含容量鍵值對(duì)的空 PersistablePacMap 實(shí)例的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
capacity 指示 PersistablePacMap 實(shí)例中鍵值對(duì)的數(shù)量。

方法詳情

deepCopy

public PersistablePacMap deepCopy()

創(chuàng)建 PersistablePacMap 對(duì)象的深層副本。

執(zhí)行深拷貝以創(chuàng)建與原始對(duì)象具有相同內(nèi)容的對(duì)象。

返回:

返回 PersistablePacMap 對(duì)象的深層副本。

isValidValueType

public static boolean isValidValueType(Object value)

檢查值對(duì)象的類型是否支持對(duì) JSON 字符串進(jìn)行編組和解組。

參數(shù):

參數(shù)名稱 參數(shù)描述
value 表示要檢查的對(duì)象。

返回:

如果值對(duì)象支持編組和解組,則返回 true; 否則返回 false。

putPersistablePacMap

public void putPersistablePacMap(String key, PersistablePacMap value)

將具有指定鍵的 PersistablePacMap 對(duì)象添加到此 PersistablePacMap 對(duì)象中。

如果指定的鍵已經(jīng)存在,它的值將被替換為值。

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要添加的對(duì)象的鍵。

getPersistablePacMap

public PersistablePacMap getPersistablePacMap(String key)

獲取具有指定鍵的 PersistablePacMap 對(duì)象。

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示用于查詢對(duì)象的鍵。 該值可以為空。

返回:

返回匹配指定鍵的 PersistablePacMap 對(duì)象; 如果匹配的值不是 PersistablePacMap 對(duì)象或未獲得任何值,則返回 null。

getShortValue

public short getShortValue(String key)

覆蓋 BasePacMap#getShortValue 方法以獲取未編組的 PersistablePacMap 對(duì)象中的 short 值,其中 short 已轉(zhuǎn)換為 Integer。

覆蓋:

BasePacMap 類中的 getShortValue

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的短值的key。

返回:

返回與指定鍵匹配的短值。

getLongValue

public long getLongValue(String key)

重寫(xiě) BasePacMap#getLongValue 方法以獲取未編組的 PersistablePacMap 對(duì)象中的 long 值,其中 long 已轉(zhuǎn)換為 Integer。

覆蓋:

類 BasePacMap 中的 getLongValue

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的long值的key。

返回:

返回與指定鍵匹配的長(zhǎng)值。

getDoubleValue

public double getDoubleValue(String key)

覆蓋 BasePacMap#getDoubleValue 方法以獲取 unmarshalled PersistablePacMap 對(duì)象中的 double 值,其中 double 已轉(zhuǎn)換為 BigDecimal。

覆蓋:

BasePacMap 類中的 getDoubleValue

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的double值的key。

返回:

返回與指定鍵匹配的雙精度值。

getFloatValue

public float getFloatValue(String key)

重寫(xiě) BasePacMap#getFloatValue 方法以獲取未編組的 PersistablePacMap 對(duì)象中的浮點(diǎn)值,其中浮點(diǎn)已轉(zhuǎn)換為 BigDecimal。

覆蓋:

BasePacMap 類中的 getFloatValue

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的浮點(diǎn)值的鍵。

返回:

返回與指定鍵匹配的浮點(diǎn)值。

getIntValueArray

public int[] getIntValueArray(String key)

覆蓋 BasePacMap#getIntValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的 int 數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。

覆蓋:

類 BasePacMap 中的 getIntValueArray

參數(shù):

參數(shù)名稱 參數(shù)描述
key 指示要獲取的 int 數(shù)組的鍵。

返回:

返回與指定鍵匹配的 int 數(shù)組。

getShortValueArray

public short[] getShortValueArray(String key)

覆蓋 BasePacMap#getShortValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的短數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。

覆蓋:

BasePacMap 類中的 getShortValueArray

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的短數(shù)組的key。

返回:

返回與指定鍵匹配的短數(shù)組。

getLongValueArray

public long[] getLongValueArray(String key)

覆蓋 BasePacMap#getLongValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的長(zhǎng)數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。

覆蓋:

BasePacMap 類中的 getLongValueArray

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的長(zhǎng)數(shù)組的key。

返回:

返回與指定鍵匹配的長(zhǎng)數(shù)組。

getBooleanValueArray

public boolean[] getBooleanValueArray(String key)

覆蓋 BasePacMap#getBooleanValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的布爾數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。

覆蓋:

類 BasePacMap 中的 getBooleanValueArray

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的布爾數(shù)組的鍵。

返回:

返回與指定鍵匹配的布爾數(shù)組; 如果未編組的 PersistablePacMap 對(duì)象中的 JsonArray 值無(wú)法轉(zhuǎn)換為布爾數(shù)組,則返回 null。

getDoubleValueArray

public double[] getDoubleValueArray(String key)

覆蓋 BasePacMap#getDoubleValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的雙精度數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。

覆蓋:

類 BasePacMap 中的 getDoubleValueArray

參數(shù):

參數(shù)名稱 參數(shù)描述
key 表示要獲取的雙精度數(shù)組的鍵。

返回:

返回與指定鍵匹配的雙精度數(shù)組。

getFloatValueArray

public float[] getFloatValueArray(String key)

覆蓋 BasePacMap#getFloatValueArray 方法以獲取未編組的 PersistablePacMap 對(duì)象中的浮點(diǎn)數(shù)組,其中數(shù)組已轉(zhuǎn)換為 JsonArray。

覆蓋:

類 BasePacMap 中的 getFloatValueArray

參數(shù):

參數(shù)名稱 參數(shù)描述
key 指示要獲取的浮點(diǎn)數(shù)組的鍵。

返回:

返回與指定鍵匹配的浮點(diǎn)數(shù)組。

fromJsonString

public static PersistablePacMap fromJsonString(String jsonString)

基于給定的 JSON 字符串創(chuàng)建 PersistablePacMap 對(duì)象。

參數(shù):

參數(shù)名稱 參數(shù)描述
jsonString 指示用于創(chuàng)建 PersistablePacMap 對(duì)象的 JSON 字符串。

返回:

返回一個(gè) PersistablePacMap 對(duì)象; 如果 JSON 字符串無(wú)效,則返回 null。

toJsonString

public String toJsonString()

獲取 PersistablePacMap 對(duì)象的 JSON 字符串表示形式。 可以將此 JSON 字符串寫(xiě)入文件以進(jìn)行持久數(shù)據(jù)存儲(chǔ)。

返回:

返回 PersistablePacMap 對(duì)象的 JSON 字符串表示。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)