提交 7f64dd18 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 2e5c5994
# Ability Access Control # Ability Access Control
> ![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. > 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.
## Modules to Import ## Modules to Import
``` ```js
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
``` ```
...@@ -26,7 +26,7 @@ Creates an **AtManager** instance, which is used for ability access control. ...@@ -26,7 +26,7 @@ Creates an **AtManager** instance, which is used for ability access control.
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
``` ```
...@@ -57,7 +57,7 @@ Checks whether an application has been granted the specified permission. This AP ...@@ -57,7 +57,7 @@ Checks whether an application has been granted the specified permission. This AP
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
...@@ -92,7 +92,7 @@ Grants a user granted permission to an application. This API uses a promise to r ...@@ -92,7 +92,7 @@ Grants a user granted permission to an application. This API uses a promise to r
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
...@@ -124,7 +124,7 @@ Grants a user granted permission to an application. This API uses an asynchronou ...@@ -124,7 +124,7 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let permissionFlag = 1; let permissionFlag = 1;
...@@ -159,7 +159,7 @@ Revokes a user granted permission given to an application. This API uses a promi ...@@ -159,7 +159,7 @@ Revokes a user granted permission given to an application. This API uses a promi
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let permissionFlag = 1; let permissionFlag = 1;
...@@ -190,7 +190,7 @@ Revokes a user granted permission given to an application. This API uses an asyn ...@@ -190,7 +190,7 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
...@@ -223,7 +223,7 @@ Obtains the flags of the specified permission of a given application. This API u ...@@ -223,7 +223,7 @@ Obtains the flags of the specified permission of a given application. This API u
**Example** **Example**
``` ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......
# XML-to-JavaScript Conversion # XML-to-JavaScript Conversion
> **NOTE** > **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. > 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.
## Modules to Import ## Modules to Import
``` ```js
import convertxml from '@ohos.convertxml'; import convertxml from '@ohos.convertxml';
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## ConvertXML ## ConvertXML
...@@ -23,61 +19,66 @@ convert(xml: string, options?: ConvertOptions) : Object ...@@ -23,61 +19,66 @@ convert(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object. Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | ------------------ | | ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes| XML text to convert.| | xml | string | Yes | XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No| Settings of the convert operation.| | options | [ConvertOptions](#convertoptions) | No | Options for coversion. |
- Return value **Return value**
| Type| Description| | Type | Description |
| ------ | ---------------------------- | | ------ | ---------------------------- |
| Object | JavaScript object.| | Object | JavaScript object.|
- Example **Example**
```js ```js
let xml = let xml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
' <title>Happy</title>' + ' <title>Happy</title>' +
' <todo>Work</todo>' + ' <todo>Work</todo>' +
' <todo>Play</todo>' + ' <todo>Play</todo>' +
'</note>'; '</note>';
let conv = new convertxml.ConvertXML(); let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = JSON.stringify(conv.convert(xml, options));
console.log(result) console.log(result)
``` ```
## ConvertOptions ## ConvertOptions
| Name| Type| Mandatory| Description| Options for coversion.
**System capability**: SystemCapability.Utils.Lang
| Name | Type| Mandatory| Description |
| ----------------- | -------- | ---- | ----------------------------------------------------------- | | ----------------- | -------- | ---- | ----------------------------------------------------------- |
| trim | boolean | Yes| Whether to trim the whitespace characters before and after the text. The default value is **false**.| | trim | boolean | Yes | Whether to trim the whitespace characters before and after the text. The default value is **false**. |
| ignoreDeclaration | boolean | No| Whether to ignore the XML declaration. The default value is **false**.| | ignoreDeclaration | boolean | No | Whether to ignore the XML declaration. The default value is **false**. |
| ignoreInstruction | boolean | No| Whether to ignore the XML processing instruction. The default value is **false**.| | ignoreInstruction | boolean | No | Whether to ignore the XML processing instruction. The default value is **false**. |
| ignoreAttributes | boolean | No| Whether to print attributes across multiple lines and indent attributes. The default value is **false**.| | ignoreAttributes | boolean | No | Whether to print attributes across multiple lines and indent attributes. The default value is **false**. |
| ignoreComment | boolean | No| Whether to ignore element comments. The default value is **false**.| | ignoreComment | boolean | No | Whether to ignore element comments. The default value is **false**. |
| ignoreCDATA | boolean | No| Whether to ignore the element's CDATA information. The default value is **false**.| | ignoreCDATA | boolean | No | Whether to ignore the element's CDATA information. The default value is **false**. |
| ignoreDoctype | boolean | No| Whether to ignore the element's Doctype information. The default value is **false**.| | ignoreDoctype | boolean | No | Whether to ignore the element's Doctype information. The default value is **false**. |
| ignoreText | boolean | No| Whether to ignore the element's text information. The default value is **false**.| | ignoreText | boolean | No | Whether to ignore the element's text information. The default value is **false**. |
| declarationKey | string | Yes| Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.| | declarationKey | string | Yes | Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.|
| instructionKey | string | Yes| Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.| | instructionKey | string | Yes | Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.|
| attributesKey | string | Yes| Name of the attribute key for **attributes** in the output object. The default value is **_attributes**.| | attributesKey | string | Yes | Name of the attribute key for **attributes** in the output object. The default value is **_attributes**. |
| textKey | string | Yes| Name of the attribute key for **text** in the output object. The default value is **_text**.| | textKey | string | Yes | Name of the attribute key for **text** in the output object. The default value is **_text**. |
| cdataKey | string | Yes| Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**.| | cdataKey | string | Yes | Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**. |
| doctypeKey | string | Yes| Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**.| | doctypeKey | string | Yes | Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**. |
| commentKey | string | Yes| Name of the attribute key for **comment** in the output object. The default value is **_comment**.| | commentKey | string | Yes | Name of the attribute key for **comment** in the output object. The default value is **_comment**. |
| parentKey | string | Yes| Name of the attribute key for **parent** in the output object. The default value is **_parent**.| | parentKey | string | Yes | Name of the attribute key for **parent** in the output object. The default value is **_parent**. |
| typeKey | string | Yes| Name of the attribute key for **type** in the output object. The default value is **_type**.| | typeKey | string | Yes | Name of the attribute key for **type** in the output object. The default value is **_type**. |
| nameKey | string | Yes| Name of the attribute key for **name** in the output object. The default value is **_name**.| | nameKey | string | Yes | Name of the attribute key for **name** in the output object. The default value is **_name**. |
| elementsKey | string | Yes| Name of the attribute key for **elements** in the output object. The default value is **_elements**.| | elementsKey | string | Yes | Name of the attribute key for **elements** in the output object. The default value is **_elements**. |
# Fault Logger # Fault Logger
> ![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. > 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.
## Modules to Import ## Modules to Import
``` ```js
import faultLogger from '@ohos.faultLogger' import faultLogger from '@ohos.faultLogger'
``` ```
...@@ -56,7 +56,7 @@ Obtains the fault information about the current process. This API uses a callbac ...@@ -56,7 +56,7 @@ Obtains the fault information about the current process. This API uses a callbac
**Example** **Example**
``` ```js
function queryFaultLogCallback(error, value) { function queryFaultLogCallback(error, value) {
if (error) { if (error) {
console.info('error is ' + error); console.info('error is ' + error);
...@@ -101,7 +101,7 @@ Obtains the fault information about the current process. This API uses a promise ...@@ -101,7 +101,7 @@ Obtains the fault information about the current process. This API uses a promise
**Example** **Example**
``` ```js
async function getLog() { async function getLog() {
let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH);
if (value) { if (value) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册