|
| 1 | +--- |
| 2 | +layout: default-layout |
| 3 | +title: CodeParser Class - Dynamsoft Code Parser SDK Android Edition API Reference |
| 4 | +description: This page shows CodeParser Class of Dynamsoft Code Parser SDK Android Edition. |
| 5 | +keywords: CodeParser, api reference, Android |
| 6 | +needAutoGenerateSidebar: true |
| 7 | +--- |
| 8 | + |
| 9 | +# CodeParser Class |
| 10 | + |
| 11 | +The `CodeParser` class enable users to configure the code parser settings or parse the content. |
| 12 | + |
| 13 | +## Definition |
| 14 | + |
| 15 | +*Namespace:* com.dynamsoft.dcp |
| 16 | + |
| 17 | +*Assembly:* DynamsoftCodeParser.aar |
| 18 | + |
| 19 | +```java |
| 20 | +class CodeParser |
| 21 | +``` |
| 22 | + |
| 23 | +| Method | Description | |
| 24 | +| ------ | ----------- | |
| 25 | +| [`CodeParser`](#codeparser) | The constructor.| |
| 26 | +| [`initSettingsFromFile`](#initsettingsfromfile) | Initialize runtime settings with the settings in a given JSON file. | |
| 27 | +| [`initSettings`](#initsettings) | Initialize runtime settings with the settings in a given JSON string. | |
| 28 | +| [`parse`](#parse) | Parses code data for readable results. | |
| 29 | +| [`resetSettings`](#resetsettings) | Reset runtime settings to default. | |
| 30 | + |
| 31 | +## CodeParser |
| 32 | + |
| 33 | +Default constructor of a `CodeParser` object. |
| 34 | + |
| 35 | +```java |
| 36 | +CodeParser(); |
| 37 | +``` |
| 38 | + |
| 39 | +## Parse |
| 40 | + |
| 41 | +Parses code data for human-readable results. |
| 42 | + |
| 43 | +```java |
| 44 | +ParsedResultItem parse(byte[] bytes, String taskSettingName) throws CodeParserException; |
| 45 | +``` |
| 46 | + |
| 47 | +**Parameters** |
| 48 | + |
| 49 | +`[in] bytes` The array of bytes which contain the code string. |
| 50 | + |
| 51 | +`[in] taskSettingName`<sub>Optional</sub> The name of [`CodeParserTaskSetting`]({{site.parameters}}file/task-settings/code-parser-task-settings.html) which defines the settings used for code parsing. |
| 52 | + |
| 53 | +**Return Value** |
| 54 | + |
| 55 | +Returns [`ParsedResultItem`](parsed-result-item.md) which stores the human-readable results. |
| 56 | + |
| 57 | +## ResetSettings |
| 58 | + |
| 59 | +Reset all parameters to default values. |
| 60 | + |
| 61 | +```java |
| 62 | +void resetSettings(); |
| 63 | +``` |
| 64 | + |
| 65 | +## InitSettingsFromFile |
| 66 | + |
| 67 | +Initialize settings from a given file. |
| 68 | + |
| 69 | +```java |
| 70 | +void initSettingsFromFile(String filePath) throws CodeParserException; |
| 71 | +``` |
| 72 | + |
| 73 | +**Parameters** |
| 74 | + |
| 75 | +`[in] filePath` The path of the settings file. |
| 76 | + |
| 77 | +## InitSettings |
| 78 | + |
| 79 | +Initialize settings from a given string. |
| 80 | + |
| 81 | +```java |
| 82 | +void initSettings(String content) throws CodeParserException; |
| 83 | +``` |
| 84 | + |
| 85 | +**Parameters** |
| 86 | + |
| 87 | +`[in] content` A JSON string that represents the content of the settings. |
0 commit comments