Skip to content

Commit bd17e1d

Browse files
committed
Merge pull request 'IDB Sub-messages, 2D-DOC parser, unified API, regristry renaming' (#8) from feature/merged-idb-fr2ddoc into main
Reviewed-on: https://gitea.t-senger.de/tsenger/vdstools/pulls/8
2 parents 50fc922 + 226b7a2 commit bd17e1d

63 files changed

Lines changed: 5675 additions & 664 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ val seal: Seal = Seal.fromString(rawString)
4444
//Get list with all messages in seal
4545
val messageList = seal.messageList
4646
for (message in messageList) {
47-
println("${message.name} (${message.coding}) -> ${message.value}")
47+
println("${message.name} -> ${message.value}")
4848
}
4949

5050
// Access message data by name - value.toString() returns the decoded value
@@ -85,7 +85,7 @@ Some seal types use a two-stage lookup: the header's `documentRef` points to a b
8585
`ADMINISTRATIVE_DOCUMENTS`), and the first tags of the message zone carry administrative metadata
8686
(e.g. the document profile UUID at tag 0, validity dates at tag 1) rather than user-visible content.
8787

88-
These tags are declared as `metadataTagList` in `SealCodings.json` and are automatically separated
88+
These tags are declared as `metadataTagList` in `VdsDocumentTypes.json` and are automatically separated
8989
from the regular `messageList` during parsing. They are only accessible via `metadataMessageList`.
9090

9191
```kotlin
@@ -112,8 +112,8 @@ if (seal.metadataMessageList.isNotEmpty()) {
112112
To check at the type level which tags are configured as metadata (without a concrete seal instance):
113113

114114
```kotlin
115-
DataEncoder.getMetadataTags("ADMINISTRATIVE_DOCUMENTS") // → {0, 1, 2, 3}
116-
DataEncoder.getMetadataTags("RESIDENT_PERMIT") // → {} (no metadata tags)
115+
DataEncoder.vdsDocumentTypes.getMetadataTags("ADMINISTRATIVE_DOCUMENTS") // → {0, 1, 2, 3}
116+
DataEncoder.vdsDocumentTypes.getMetadataTags("RESIDENT_PERMIT") // → {} (no metadata tags)
117117
```
118118

119119
Regular document types have no `metadataTagList` configured, so their `metadataMessageList` is
@@ -259,12 +259,12 @@ val customJson = """[
259259
]"""
260260

261261
// Add to defaults – built-in types remain available:
262-
DataEncoder.addCustomSealCodings(customJson)
263-
DataEncoder.addCustomSealCodingsFromFile("path/to/MyCodings.json") // JVM only
262+
DataEncoder.addCustomVdsDocumentTypes(customJson)
263+
DataEncoder.addCustomVdsDocumentTypesFromFile("path/to/MyDocumentTypes.json") // JVM only
264264

265265
// Replace defaults entirely – only your types are available:
266-
DataEncoder.replaceCustomSealCodings(customJson)
267-
DataEncoder.replaceCustomSealCodingsFromFile("path/to/MyCodings.json") // JVM only
266+
DataEncoder.replaceCustomVdsDocumentTypes(customJson)
267+
DataEncoder.replaceCustomVdsDocumentTypesFromFile("path/to/MyDocumentTypes.json") // JVM only
268268
```
269269

270270
The same pattern applies to the other registries:
@@ -274,13 +274,13 @@ The same pattern applies to the other registries:
274274
DataEncoder.addCustomIdbMessageTypes(jsonString)
275275
DataEncoder.replaceCustomIdbMessageTypes(jsonString)
276276

277-
// IDB national document types
278-
DataEncoder.addCustomIdbNationalDocumentTypes(jsonString)
279-
DataEncoder.replaceCustomIdbNationalDocumentTypes(jsonString)
277+
// IDB document types
278+
DataEncoder.addCustomIdbDocumentTypes(jsonString)
279+
DataEncoder.replaceCustomIdbDocumentTypes(jsonString)
280280

281-
// Extended message definitions (VDS administrative documents)
282-
DataEncoder.addCustomExtendedMessageDefinitions(jsonString)
283-
DataEncoder.replaceCustomExtendedMessageDefinitions(jsonString)
281+
// VDS profile definitions (VDS administrative documents)
282+
DataEncoder.addCustomVdsProfileDefinitions(jsonString)
283+
DataEncoder.replaceCustomVdsProfileDefinitions(jsonString)
284284

285285
// Revert all registries to embedded defaults:
286286
DataEncoder.resetToDefaults()
@@ -319,7 +319,7 @@ val vdsSeal = VdsSeal(header, messageGroup, signer)
319319
| `DATE` | 3-byte date (ICAO format, e.g. "2024-06-15") |
320320
| `MASKED_DATE` | 4-byte date with uncertainty masks |
321321

322-
See `src/commonMain/resources/SealCodings.json` for the complete structure of the default codings.
322+
See `src/commonMain/resources/VdsDocumentTypes.json` for the complete structure of the default document types.
323323

324324
## Byte-level structure inspection with the `dissect` package
325325

build.gradle.kts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ tasks.register("generateResourceConstants") {
212212
outputDir.mkdirs()
213213

214214
// JSON-Dateien einlesen
215-
val sealCodings = file("$inputDir/SealCodings.json").readText()
215+
val vdsDocumentTypes = file("$inputDir/VdsDocumentTypes.json").readText()
216216
val idbMessageTypes = file("$inputDir/IdbMessageTypes.json").readText()
217-
val idbDocumentTypes = file("$inputDir/IdbNationalDocumentTypes.json").readText()
218-
val extendedMessageDefinitions = file("$inputDir/ExtendedMessageDefinitions.json").readText()
217+
val idbDocumentTypes = file("$inputDir/IdbGermanDocumentTypes.json").readText()
218+
val vdsProfileDefinitions = file("$inputDir/VdsProfileDefinitions.json").readText()
219+
val fr2ddocFieldDefinitions = file("$inputDir/Fr2ddocFieldDefinitions.json").readText()
219220

220221
// Kotlin Code generieren
221222
val kotlinCode = """
@@ -228,13 +229,15 @@ package de.tsenger.vdstools.generated
228229
* Source: src/commonMain/resources/
229230
*/
230231
internal object ResourceConstants {
231-
const val SEAL_CODINGS_JSON: String = ""${'"'}$sealCodings""${'"'}
232+
const val VDS_DOCUMENT_TYPES_JSON: String = ""${'"'}$vdsDocumentTypes""${'"'}
232233
233234
const val IDB_MESSAGE_TYPES_JSON: String = ""${'"'}$idbMessageTypes""${'"'}
234235
235236
const val IDB_DOCUMENT_TYPES_JSON: String = ""${'"'}$idbDocumentTypes""${'"'}
236237
237-
const val EXTENDED_MESSAGE_DEFINITIONS_JSON: String = ""${'"'}$extendedMessageDefinitions""${'"'}
238+
const val VDS_PROFILE_DEFINITIONS_JSON: String = ""${'"'}$vdsProfileDefinitions""${'"'}
239+
240+
const val FR2DDOC_FIELD_DEFINITIONS_JSON: String = ""${'"'}$fr2ddocFieldDefinitions""${'"'}
238241
}
239242
""".trimIndent()
240243

@@ -244,7 +247,7 @@ internal object ResourceConstants {
244247
writeText(kotlinCode)
245248
}
246249

247-
println("✅ Generated ResourceConstants.kt with ${sealCodings.length + idbMessageTypes.length + idbDocumentTypes.length + extendedMessageDefinitions.length} bytes")
250+
println("✅ Generated ResourceConstants.kt with ${vdsDocumentTypes.length + idbMessageTypes.length + idbDocumentTypes.length + vdsProfileDefinitions.length + fr2ddocFieldDefinitions.length} bytes")
248251
}
249252
}
250253

0 commit comments

Comments
 (0)