提交 c4847dd0 编写于 作者: G Gloria

Update docs against 10952+11279+10936

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 4223d843
......@@ -15,8 +15,54 @@ import convertxml from '@ohos.convertxml';
## ConvertXML
### convertToJSObject<sup>9+</sup>
### convert
convertToJSObject(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes | XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No | Options for conversion. |
**Return value**
| Type | Description |
| ------ | ---------------------------- |
| Object | JavaScript object.|
**Example**
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.convertToJSObject();
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result);
// Output (non-compact)
// {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}
```
### convert<sup>(deprecated)</sup>
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject9+](#converttojsobject9) instead.
convert(xml: string, options?: ConvertOptions) : Object
......@@ -24,7 +70,6 @@ Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name | Type | Mandatory| Description |
......
......@@ -4,7 +4,7 @@ The **EffectKit** module provides basic image processing capabilities, including
This module provides the following classes:
- [Filter](#filter): a class that provides the effect chain, which is a linked list of image processing effects.
- [Filter](#filter): a class that adds a specified effect to the image source.
- [Color](#color): a class used to store the color picked.
- [ColorPicker](#colorpicker): a smart color picker.
......@@ -43,7 +43,6 @@ Creates a **Filter** instance based on the pixel map.
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
let headFilter = effectKit.createEffect(pixelMap);
......@@ -76,7 +75,6 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses a promi
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
effectKit.createColorPicker(pixelMap).then(colorPicker => {
......@@ -106,7 +104,6 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses an asyn
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
effectKit.createColorPicker(pixelMap, (error, colorPicker) => {
......@@ -181,6 +178,7 @@ Obtains the main color of the image and writes the result to a **[Color](#color)
let color = colorPicker.getMainColorSync();
console.log('get main color =' + color);
```
![en-us_image_Main_Color.png](figures/en-us_image_Main_Color.png)
## Filter
......@@ -204,7 +202,7 @@ Adds the blur effect to the filter linked list, and returns the head node of the
| Type | Description |
| :------------- | :---------------------------------------------- |
| [Filter](#filter) | Head node of the filter linked list.|
| [Filter](#filter) | Final image effect.|
**Example**
......@@ -221,6 +219,7 @@ image.createPixelMap(color, opts).then((pixelMap) => {
}
})
```
![en-us_image_Add_Blur.png](figures/en-us_image_Add_Blur.png)
### brightness
......@@ -240,7 +239,7 @@ Adds the brightness effect to the filter linked list, and returns the head node
| Type | Description |
| :------------- | :---------------------------------------------- |
| [Filter](#filter) | Head node of the filter linked list.|
| [Filter](#filter) | Final image effect.|
**Example**
......@@ -257,6 +256,7 @@ image.createPixelMap(color, opts).then((pixelMap) => {
}
})
```
![en-us_image_Add_Brightness.png](figures/en-us_image_Add_Brightness.png)
### grayscale
......@@ -270,7 +270,7 @@ Adds the grayscale effect to the filter linked list, and returns the head node o
| Type | Description |
| :------------- | :---------------------------------------------- |
| [Filter](#filter) | Head node of the filter linked list.|
| [Filter](#filter) | Final image effect.|
**Example**
......@@ -286,10 +286,11 @@ image.createPixelMap(color, opts).then((pixelMap) => {
}
})
```
![en-us_image_Add_Grayscale.png](figures/en-us_image_Add_Grayscale.png)
### getPixelMap
getPixelMap(): image.PixelMap
getPixelMap(): [image.PixelMap](js-apis-image.md#pixelmap7)
Obtains **image.PixelMap** of the source image to which the filter linked list is added.
......
......@@ -77,7 +77,10 @@ result.toString()
```
### equals
### equals<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [equalsTo<sup>9+</sup>](#equalsto9) instead.
equals(other: URI): boolean
......@@ -104,6 +107,33 @@ const uriInstance = new uri.URI('http://username:password@host:8080/directory/fi
const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment');
uriInstance.equals(uriInstance1);
```
### equalsTo<sup>9+</sup>
equalsTo(other: URI): boolean
Checks whether this URI is the same as another URI object.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type.| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| other | [URI](#uri) | Yes| URI object to compare.|
**Return value**
| Type.| Description|
| -------- | -------- |
| boolean | Returns **true** if the two URIs are the same; returns **false** otherwise.|
**Example**
```js
const uriInstance = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment');
uriInstance.equalsTo(uriInstance1);
```
### checkIsAbsolute
......
......@@ -4,21 +4,379 @@
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import Url from '@ohos.url'
```
## URLParams<sup>9+</sup>
## URLSearchParams
### constructor<sup>9+</sup>
### constructor
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLParams)
A constructor used to create a **URLParams** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string[][] \| Record&lt;string, string&gt; \| string \| URLParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string, string&gt;**: list of objects<br>- **string**: string<br>- **URLParams**: object|
**Example**
```js
let objectParams = new Url.URLParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
let objectParams1 = new Url.URLParams({"fod" : '1' , "bard" : '2'});
let objectParams2 = new Url.URLParams('?fod=1&bard=2');
let urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2');
let params = new Url.URLParams(urlObject.search);
```
### append<sup>9+</sup>
append(name: string, value: string): void
Appends a key-value pair into the query string.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the key-value pair to append.|
| value | string | Yes| Value of the key-value pair to append.|
**Example**
```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLParams(urlObject.search.slice(1));
paramsObject.append('fod', '3');
```
### delete<sup>9+</sup>
delete(name: string): void
Deletes key-value pairs of the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the key-value pairs to delete.|
**Example**
```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsobject = new Url.URLParams(urlObject.search.slice(1));
paramsobject.delete('fod');
```
### getAll<sup>9+</sup>
getAll(name: string): string[]
Obtains all the key-value pairs based on the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.|
**Return value**
| Type| Description|
| -------- | -------- |
| string[] | All key-value pairs matching the specified key.|
**Example**
```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let params = new Url.URLParams(urlObject.search.slice(1));
params.append('fod', '3'); // Add a second value for the fod parameter.
console.log(params.getAll('fod').toString()) // Output ["1","3"].
```
### entries<sup>9+</sup>
entries(): IterableIterator<[string, string]>
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;[string, string]&gt; | ES6 iterator.|
**Example**
```js
let searchParamsObject = new Url.URLParams("keyName1=valueName1&keyName2=valueName2");
for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs
console.log(pair[0]+ ', '+ pair[1]);
}
```
### forEach<sup>9+</sup>
forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.|
| thisArg | Object | No| Value to use when the callback is invoked.|
**Table 1** callbackfn parameter description
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | string | Yes| Value that is currently traversed.|
| key | string | Yes| Key that is currently traversed.|
| searchParams | Object | Yes| Instance that invokes the **forEach** method.|
**Example**
```js
const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
myURLObject.URLParams.forEach((value, name, searchParams) => {
console.log(name, value, myURLObject.searchParams === searchParams);
});
```
### get<sup>9+</sup>
get(name: string): string | null
Obtains the value of the first key-value pair based on the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain the value.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Returns the value of the first key-value pair if obtained.|
| null | Returns **null** if no value is obtained.|
**Example**
```js
let paramsObject = new Url.URLParams('name=Jonathan&age=18');
let name = paramsObject.get("name"); // is the string "Jonathan"
let age = parseInt(paramsObject.get("age"), 10); // is the number 18
```
### has<sup>9+</sup>
has(name: string): boolean
Checks whether a key has a value.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to search for its value.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value exists; returns **false** otherwise.|
**Example**
```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLParams(urlObject.search.slice(1));
paramsObject.has('bard') === true;
```
### set<sup>9+</sup>
set(name: string, value: string): void
Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the value to set.|
| value | string | Yes| Value to set.|
**Example**
```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLParams(urlObject.search.slice(1));
paramsObject.set('baz', '3'); // Add a third parameter.
```
### sort<sup>9+</sup>
sort(): void
Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained.
**System capability**: SystemCapability.Utils.Lang
**Example**
```js
let searchParamsObject = new Url.URLParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object
searchParamsObject.sort(); // Sort the key/value pairs
console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4
```
### keys<sup>9+</sup>
keys(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the keys of all the key-value pairs.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the keys of all the key-value pairs.|
**Example**
```js
let searchParamsObject = new Url.URLParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
for (var key of searchParamsObject .keys()) { // Output key-value pairs
console.log(key);
}
```
### values<sup>9+</sup>
values(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the values of all the key-value pairs.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the values of all the key-value pairs.|
**Example**
```js
let searchParams = new Url.URLParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
for (var value of searchParams.values()) {
console.log(value);
}
```
### [Symbol.iterator]<sup>9+</sup>
[Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt;
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;[string, string]&gt; | ES6 iterator.|
**Example**
```js
const paramsObject = new Url.URLParams('fod=bay&edg=bap');
for (const [name, value] of paramsObject) {
console.log(name, value);
}
```
### tostring<sup>9+</sup>
toString(): string
Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| string | String of serialized search parameters, which is percent-encoded if necessary.|
**Example**
```js
let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let params = new Url.URLParams(url.search.slice(1));
params.append('fod', '3');
console.log(params.toString());
```
## URLSearchParams<sup>(deprecated)</sup>
### constructor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>](#constructor9+) instead.
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams)
Creates a **URLSearchParams** instance.
A constructor used to create a **URLSearchParams** instance.
**System capability**: SystemCapability.Utils.Lang
......@@ -38,8 +396,11 @@ let urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2');
let params = new Url.URLSearchParams(urlObject.search);
```
### append<sup>(deprecated)</sup>
### append
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9) instead.
append(name: string, value: string): void
......@@ -62,8 +423,11 @@ let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', '3');
```
### delete<sup>(deprecated)</sup>
### delete
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9) instead.
delete(name: string): void
......@@ -85,8 +449,11 @@ let paramsobject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsobject.delete('fod');
```
### getAll<sup>(deprecated)</sup>
### getAll
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9) instead.
getAll(name: string): string[]
......@@ -115,8 +482,11 @@ params.append('fod', '3'); // Add a second value for the fod parameter.
console.log(params.getAll('fod').toString()) // Output ["1","3"].
```
### entries<sup>(deprecated)</sup>
### entries
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9) instead.
entries(): IterableIterator<[string, string]>
......@@ -140,7 +510,10 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair
```
### forEach
### forEach<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9) instead.
forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
......@@ -173,7 +546,10 @@ myURLObject.searchParams.forEach((value, name, searchParams) => {
```
### get
### get<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9) instead.
get(name: string): string | null
......@@ -203,7 +579,10 @@ let age = parseInt(paramsObject.get("age"), 10); // is the number 18
```
### has
### has<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9) instead.
has(name: string): boolean
......@@ -232,7 +611,10 @@ paramsObject.has('bard') === true;
```
### set
### set<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9) instead.
set(name: string, value: string): void
......@@ -256,7 +638,10 @@ paramsObject.set('baz', '3'); // Add a third parameter.
```
### sort
### sort<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9) instead.
sort(): void
......@@ -273,7 +658,10 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
```
### keys
### keys<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9) instead.
keys(): IterableIterator&lt;string&gt;
......@@ -297,7 +685,10 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
```
### values
### values<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9) instead.
values(): IterableIterator&lt;string&gt;
......@@ -321,7 +712,10 @@ for (var value of searchParams.values()) {
```
### [Symbol.iterator]
### [Symbol.iterator]<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.[Symbol.iterator]<sup>9+</sup>](#symbol.iterator9) instead.
[Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt;
......@@ -344,8 +738,10 @@ for (const [name, value] of paramsObject) {
}
```
### tostring
### tostring<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.tostring<sup>9+</sup>](#tostring9) instead.
toString(): string
......@@ -368,7 +764,6 @@ params.append('fod', '3');
console.log(params.toString());
```
## URL
### Attributes
......@@ -388,12 +783,13 @@ console.log(params.toString());
| protocol | string | Yes| Yes| Protocol in a URL.|
| search | string | Yes| Yes| Serialized query string in a URL.|
| searchParams | URLsearchParams | Yes| No| **URLSearchParams** object allowing access to the query parameters in a URL.|
| URLParams | URLParams | Yes| No| **URLParams** object allowing access to the query parameters in a URL.|
| username | string | Yes| Yes| Username in a URL.|
### constructor
constructor(url: string, base?: string | URL)
constructor(url?: string, base?: string | URL)
Creates a URL.
......@@ -423,6 +819,27 @@ new Url.URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/
new Url.URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/
```
### parseURL<sup>9+</sup>
static parseURL(inputUrl : string, inputBase ?: string | URL)
Parses a URL.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| inputUrl | string | Yes| Input object.|
| inputBase | string \| URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object|
**Example**
```js
let mm = 'http://username:password@host:8080';
Url.URL.parseURL(mm); // Output 'http://username:password@host:8080/';
```
### tostring
......@@ -465,3 +882,4 @@ Converts the parsed URL into a JSON string.
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON();
```
<!--no_check-->
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册