template.markdown.iso-8583-packer.doc.hex.hex-body-packer.md Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of credible-doc-generator Show documentation
Show all versions of credible-doc-generator Show documentation
This module generates documentation
for the https://github.com/credibledoc/credible-doc repository projects.
See description on the https://github.com/credibledoc/credible-doc page.
# `HexBodyPacker` examples
The following example shows how to define a field with body in the `Hex` format
```Java
&&beginPlaceholder {
"className": "com.credibledoc.substitution.content.generator.code.SourceContentGenerator",
"description": "Example of Hex body definition",
"parameters": {
"sourceRelativePath": "iso-8583-packer/src/test/java/com/credibledoc/iso8583packer/hex/HexBodyPackerTest.java",
"beginString": " private FieldBuilder fixedLengthHex() {",
"endString": " }",
"indentation": ""
}
} &&endPlaceholder
```
The field structure
```XML
&&beginPlaceholder {
"className": "com.credibledoc.substitution.content.generator.code.SourceContentGenerator",
"description": "MsgField dump",
"parameters": {
"sourceRelativePath": "iso-8583-packer/log/iso-8583-packer.log",
"beginString": "HexBodyPackerTest - MsgField structure dump: ",
"includeBeginString": "false",
"endString": "\"/>",
"indentation": ""
}
} &&endPlaceholder
```
The following example shows how to pack the field value
```Java
&&beginPlaceholder {
"className": "com.credibledoc.substitution.content.generator.code.SourceContentGenerator",
"description": "Example of Hex value packing",
"parameters": {
"sourceRelativePath": "iso-8583-packer/src/test/java/com/credibledoc/iso8583packer/hex/HexBodyPackerTest.java",
"beginString": " FieldBuilder fieldBuilder = fixedLengthHex();",
"endString": "assertEquals(value, HexService.bytesToHex(valueBytes));",
"indentation": " "
}
} &&endPlaceholder
```
And the following example shows how to unpack the field bytes to a value
```Java
&&beginPlaceholder {
"className": "com.credibledoc.substitution.content.generator.code.SourceContentGenerator",
"description": "Example of Hex value unpacking",
"parameters": {
"sourceRelativePath": "iso-8583-packer/src/test/java/com/credibledoc/iso8583packer/hex/HexBodyPackerTest.java",
"beginString": " FieldBuilder fieldBuilder = fixedLengthHex();",
"endString": "assertEquals(value, HexService.bytesToHex(valueBytes));",
"indentation": " "
}
} &&endPlaceholder
```
The packed `FieldValue` then looks like the next example
```XML
&&beginPlaceholder {
"className": "com.credibledoc.substitution.content.generator.code.SourceContentGenerator",
"description": "MsgValue dump",
"parameters": {
"sourceRelativePath": "iso-8583-packer/log/iso-8583-packer.log",
"beginString": "HexBodyPackerTest - MsgValue structure dump: ",
"includeBeginString": "false",
"endString": "\"/>",
"indentation": ""
}
} &&endPlaceholder
```
Some examples of packed values
```
&&beginPlaceholder {
"className": "com.credibledoc.substitution.content.generator.code.SourceContentGenerator",
"description": "Some examples of packed values",
"parameters": {
"sourceRelativePath": "iso-8583-packer/log/iso-8583-packer.log",
"beginString": "Examples of values packed with HexBodyPacker",
"includeBeginString": "true",
"endString": "Examples end.",
"includeEndString": "false",
"indentation": ""
}
} &&endPlaceholder
```
The source of the test is located in GitHub [HexBodyPackerTest.java](https://github.com/credibledoc/credible-doc/blob/master/iso-8583-packer/src/test/java/com/credibledoc/iso8583packer/hex/HexBodyPackerTest.java)
More examples see [complex-example.md](../complex-example.md).