|
| 1 | +--- |
| 2 | +layout: default-layout |
| 3 | +title: CodeParser Class - Dynamsoft Code Parser Module Java Edition API Reference |
| 4 | +description: Definition of the CodeParser class in Dynamsoft Code Parser Module Java Edition. |
| 5 | +keywords: CodeParser, api reference, java |
| 6 | +needAutoGenerateSidebar: true |
| 7 | +--- |
| 8 | + |
| 9 | +# CodeParser Class |
| 10 | + |
| 11 | +The `CodeParser` class provides functionality for parsing codes from byte data. |
| 12 | + |
| 13 | +## Definition |
| 14 | + |
| 15 | +*Package:* com.dynamsoft.dcp |
| 16 | + |
| 17 | +```java |
| 18 | +public class CodeParser |
| 19 | +``` |
| 20 | + |
| 21 | +## Constructors |
| 22 | + |
| 23 | +| Constructor | Description | |
| 24 | +|---------------------------|-------------| |
| 25 | +| [`CodeParser`](#codeparser) | Constructor to create a new CodeParser instance.| |
| 26 | + |
| 27 | +## Methods |
| 28 | + |
| 29 | +| Method | Description | |
| 30 | +|----------------------|-------------| |
| 31 | +| [`Parse`](#parse) | Parses code from byte data. | |
| 32 | +| [`InitSettings`](#initsettings) | Initializes the code parser with JSON settings. | |
| 33 | +| [`InitSettingsFromFile`](#initsettingsfromfile) | Initializes the code parser with settings from a file. | |
| 34 | +| [`ResetSettings`](#resetsettings) | Resets the code parser settings to default. | |
| 35 | + |
| 36 | +### CodeParser |
| 37 | + |
| 38 | +Constructor to create a new CodeParser instance. |
| 39 | + |
| 40 | +```java |
| 41 | +public CodeParser() |
| 42 | +``` |
| 43 | + |
| 44 | +### Parse |
| 45 | + |
| 46 | +Parses code from byte data. |
| 47 | + |
| 48 | +```java |
| 49 | +public ParsedResultItem Parse(byte[] data) throws CodeParserException |
| 50 | +``` |
| 51 | + |
| 52 | +**Parameters** |
| 53 | + |
| 54 | +`data` The byte array containing the data to parse. |
| 55 | + |
| 56 | +**Return Value** |
| 57 | + |
| 58 | +Returns a `ParsedResultItem` object containing the parsed result. |
| 59 | + |
| 60 | +**Exceptions** |
| 61 | + |
| 62 | +`CodeParserException` Thrown when an error occurs during parsing. |
| 63 | + |
| 64 | +**See Also** |
| 65 | + |
| 66 | +[ParsedResultItem]({{ site.dcp_java_api }}parsed-result-item.html) |
| 67 | +[CodeParserException]({{ site.dcp_java_api }}code-parser-exception.html) |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +```java |
| 72 | +public ParsedResultItem Parse(byte[] data, String taskSettingName) throws CodeParserException |
| 73 | +``` |
| 74 | + |
| 75 | +**Parameters** |
| 76 | + |
| 77 | +`data` The byte array containing the data to parse. |
| 78 | +`taskSettingName` The name of the task setting to use for parsing. |
| 79 | + |
| 80 | +**Return Value** |
| 81 | + |
| 82 | +Returns a `ParsedResultItem` object containing the parsed result. |
| 83 | + |
| 84 | +**Exceptions** |
| 85 | + |
| 86 | +`CodeParserException` Thrown when an error occurs during parsing. |
| 87 | + |
| 88 | +**See Also** |
| 89 | + |
| 90 | +[ParsedResultItem]({{ site.dcp_java_api }}parsed-result-item.html) |
| 91 | +[CodeParserException]({{ site.dcp_java_api }}code-parser-exception.html) |
| 92 | + |
| 93 | +### InitSettings |
| 94 | + |
| 95 | +Initializes the code parser with JSON settings. |
| 96 | + |
| 97 | +```java |
| 98 | +public void InitSettings(String content) throws CodeParserException |
| 99 | +``` |
| 100 | + |
| 101 | +**Parameters** |
| 102 | + |
| 103 | +`content` A JSON string containing the settings. |
| 104 | + |
| 105 | +**Exceptions** |
| 106 | + |
| 107 | +`CodeParserException` Thrown when an error occurs during initialization. |
| 108 | + |
| 109 | +**See Also** |
| 110 | + |
| 111 | +[CodeParserException]({{ site.dcp_java_api }}code-parser-exception.html) |
| 112 | + |
| 113 | +### InitSettingsFromFile |
| 114 | + |
| 115 | +Initializes the code parser with settings from a file. |
| 116 | + |
| 117 | +```java |
| 118 | +public void InitSettingsFromFile(String filePath) throws CodeParserException |
| 119 | +``` |
| 120 | + |
| 121 | +**Parameters** |
| 122 | + |
| 123 | +`filePath` The path to the file containing the settings. |
| 124 | + |
| 125 | +**Exceptions** |
| 126 | + |
| 127 | +`CodeParserException` Thrown when an error occurs during initialization. |
| 128 | + |
| 129 | +**See Also** |
| 130 | + |
| 131 | +[CodeParserException]({{ site.dcp_java_api }}code-parser-exception.html) |
| 132 | + |
| 133 | +### ResetSettings |
| 134 | + |
| 135 | +Resets the code parser settings to default. |
| 136 | + |
| 137 | +```java |
| 138 | +public void ResetSettings() throws CodeParserException |
| 139 | +``` |
| 140 | + |
| 141 | +**Exceptions** |
| 142 | + |
| 143 | +`CodeParserException` Thrown when an error occurs during reset. |
| 144 | + |
| 145 | +**See Also** |
| 146 | + |
| 147 | +[CodeParserException]({{ site.dcp_java_api }}code-parser-exception.html) |
0 commit comments