提交 91ac2b7a 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 e122fa58
# URI String Parsing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -10,15 +10,12 @@
import uri from '@ohos.uri'
```
## System Capabilities
SystemCapability.Utils.Lang
## URI
### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| scheme | string | Yes| No| Scheme in the URI.|
......@@ -38,6 +35,8 @@ constructor(uri: string)
A constructor used to create a URI instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type.| Readable| Writable| Description|
......@@ -59,6 +58,8 @@ new uri.URI('http://username:password@host:8080'); // Output 'http://username:pa
toString(): string
**System capability**: SystemCapability.Utils.Lang
Obtains the query string applicable to this URL.
**Return value**
......@@ -81,6 +82,8 @@ equals(other: URI): boolean
Checks whether this URI is the same as another URI object.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type.| Mandatory| Description|
......@@ -107,6 +110,8 @@ checkIsAbsolute(): boolean
Checks whether this URI is an absolute URI (whether the scheme component is defined).
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type.| Description|
......@@ -127,6 +132,8 @@ normalize(): URI
Normalizes the path of this URI.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type.| Description|
......
# URL String Parsing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
......@@ -10,10 +10,6 @@
import Url from '@ohos.url'
```
## System Capabilities
SystemCapability.Utils.Lang
## URLSearchParams
......@@ -23,11 +19,13 @@ constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearc
Creates a **URLSearchParams** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object|
| init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>-&nbsp;**Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object |
**Example**
......@@ -46,6 +44,8 @@ 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|
......@@ -68,6 +68,8 @@ delete(name: string): void
Deletes key-value pairs of the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -89,6 +91,8 @@ 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|
......@@ -117,6 +121,8 @@ 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|
......@@ -139,6 +145,8 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th
Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -170,6 +178,8 @@ 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|
......@@ -199,6 +209,8 @@ has(name: string): boolean
Checks whether a key has a value.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -226,6 +238,8 @@ 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|
......@@ -246,8 +260,9 @@ paramsObject.set('baz', 3); // Add a third parameter.
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.
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**
......@@ -262,9 +277,10 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
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|
......@@ -287,6 +303,8 @@ 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|
......@@ -307,9 +325,10 @@ for (var value of searchParams.values()) {
[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|
......@@ -330,9 +349,10 @@ for (const [name, value] of paramsObject) {
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|
......@@ -351,9 +371,10 @@ console.log(params.toString());
## URL
### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.|
......@@ -374,9 +395,10 @@ console.log(params.toString());
constructor(url: string, base?: string | URL)
Creates a URL.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -408,6 +430,8 @@ toString(): string
Converts the parsed URL into a string.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -426,9 +450,10 @@ url.toString()
toJSON(): string
Converts the parsed URL into a JSON string.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......
# XML Parsing and Generation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -10,10 +10,6 @@
import xml from '@ohos.xml';
```
## System Capabilities
SystemCapability.Utils.Lang
## XmlSerializer
......@@ -23,6 +19,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
A constructor used to create an **XmlSerializer** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -45,6 +43,8 @@ setAttributes(name: string, value: string): void
Sets an attribute.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -66,6 +66,8 @@ addEmptyElement(name: string): void
Adds an empty element.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -86,6 +88,8 @@ setDeclaration(): void
Sets a declaration.
**System capability**: SystemCapability.Utils.Lang
**Example**
```js
......@@ -100,6 +104,8 @@ startElement(name: string): void
Writes the start tag based on the given element name.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -122,6 +128,8 @@ endElement(): void
Writes the end tag of the element.
**System capability**: SystemCapability.Utils.Lang
**Example**
```js
......@@ -140,6 +148,8 @@ setNamespace(prefix: string, namespace: string): void
Sets the namespace for an element tag.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -164,6 +174,8 @@ setComment(text: string): void
Sets the comment.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -187,6 +199,8 @@ setCDATA(text: string): void
Sets CDATA attributes.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -208,6 +222,8 @@ setText(text: string): void
Sets **Text**.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -232,6 +248,8 @@ setDocType(text: string): void
Sets **DocType**.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -256,6 +274,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default).
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -289,6 +309,8 @@ parse(option: ParseOptions): void
Parses XML information.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -329,6 +351,8 @@ that.parse(options);
Defines the XML parsing options.
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
......@@ -349,6 +373,8 @@ getColumnNumber(): number
Obtains the column line number, which starts from 1.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -362,6 +388,8 @@ getDepth(): number
Obtains the depth of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -375,6 +403,8 @@ getLineNumber(): number
Obtains the current line number, starting from 1.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -388,6 +418,8 @@ getName(): string
Obtains the name of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -401,6 +433,8 @@ getNamespace(): string
Obtains the namespace of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -414,6 +448,8 @@ getPrefix(): string
Obtains the prefix of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -427,6 +463,8 @@ getText(): string
Obtains the text of the current event.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -440,6 +478,8 @@ isEmptyElementTag(): boolean
Checks whether the current element is empty.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -453,6 +493,8 @@ isWhitespace(): boolean
Checks whether the current text event contains only whitespace characters.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
......@@ -466,6 +508,8 @@ getAttributeCount(): number
Obtains the number of attributes for the current start tag.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
......@@ -476,6 +520,8 @@ Obtains the number of attributes for the current start tag.
Enumerates the events.
**System capability**: SystemCapability.Utils.Lang
| Name| Value| Description|
| -------- | -------- | -------- |
| START_DOCUMENT | 0 | Indicates a start document event.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册