-
Notifications
You must be signed in to change notification settings - Fork 4
V0.11 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This major refactoring introduces a sealed class hierarchy for message values,
providing type-safe access to decoded data while always preserving raw bytes.
## New FeatureValue sealed class (src/commonMain/.../vds/FeatureValue.kt)
The sealed class provides different value types based on the encoding:
- ByteValue: Single byte values (e.g., document type identifiers)
- StringValue: C40 or UTF-8 encoded strings
- DateValue: LocalDate values from encoded dates
- MaskedDateValue: Partially masked date strings
- MrzValue: Formatted MRZ strings with proper line breaks
- BytesValue: Raw byte arrays (fallback for unknown encodings)
Each type provides:
- rawBytes: Always available, original byte array
- decoded: Type-safe access to the decoded value
- toString(): Human-readable string representation
Factory method fromBytes() handles decoding with graceful fallback to
BytesValue if decoding fails.
## Refactored classes
### Feature (internal, VDS)
- Simplified to use FeatureValue instead of valueBytes/valueInt/valueStr
### Message (public API)
- Simplified to use FeatureValue
- API consumers can use when() for type-safe value access
### IdbMessage (internal, IDB)
- Converted from constructor-based to factory methods:
- fromDerTlv(): Parse from DER TLV
- fromByteArray(): Parse from raw bytes
- fromNameAndContent(): Create from name and encoded content
- fromTagAndContent(): Create from tag and encoded content
- fromNameAndRawBytes(): Create with raw bytes (for testing)
### DigitalSeal
- Updated getMessage() to create Message with proper MRZ length handling
- Added getMrzLength() helper for MRVA (88) and MRVB (72) formats
### IcaoBarcode
- Updated getMessage() and messageList to use new API
- documentType now uses type-safe FeatureValue.ByteValue casting
### DataEncoder
- Updated encodeDerTlv() methods to create Features with FeatureValue
### IdbMessageGroup
- Builder now uses IdbMessage.fromTagAndContent()
## API Usage Example
```kotlin
val seal = Seal.fromString(barcodeString)
// Simple output
seal.messageList.forEach { msg ->
println("${msg.messageTypeName}: ${msg.value}")
}
// Type-safe access
seal.getMessage("DATE_OF_BIRTH")?.let { msg ->
when (val v = msg.value) {
is FeatureValue.DateValue -> println("Born: ${v.date}")
is FeatureValue.MaskedDateValue -> println("Masked: ${v.value}")
else -> println("$v")
}
}
// Raw bytes always available
val raw = seal.getMessage("MRZ")?.value?.rawBytes
```
## Test updates
- All tests updated to use new API
- valueStr -> value.toString()
- valueBytes -> value.rawBytes
- valueInt -> (value as FeatureValue.ByteValue).value
- IdbMessage constructors -> factory methods
Rename classes to follow consistent naming pattern: - VdsMessage → VdsMessageGroup (container) - Feature → VdsFeature (element) - DigitalSeal → VdsSeal - IdbMessage → IdbFeature (element) - IcaoBarcode → IdbSeal Refactor IdbMessageGroup to match VdsMessageGroup: - Store List<DerTlv> internally with lazy featureList - Rename getMessage() → getFeature() - Rename addMessage() → addFeature() - Rename messagesList → featureList Both standards now share identical API structure.
…encoding logic - Add addFeature(tag, value) method to VdsMessageGroup.Builder for consistency with IdbMessageGroup.Builder - Extract common encoding logic into DataEncoder.encodeValueByCoding() to eliminate code duplication - Add public getFeatureTag() and getFeatureCoding() methods to FeatureConverter and DataEncoder - Simplify Builder implementations in VdsMessageGroup and IdbMessageGroup - Add test cases for tag-based feature addition
- Rename base types: FeatureCoding → MessageCoding, FeatureValue → MessageValue, FeaturesDto → MessageDto - Rename entity classes: VdsFeature → VdsMessage, IdbFeature → IdbMessage - Rename converters: FeatureConverter → MessageConverter, ExtendedFeatureDefinitionRegistry → ExtendedMessageDefinitionRegistry - Update MessageGroup API: featureList → messageList, addFeature() → addMessage(), getFeature() → getMessage() - Update JSON resources: features → messages in SealCodings.json and ExtendedMessageDefinitions.json - Update build config: EXTENDED_FEATURE_DEFINITIONS_JSON → EXTENDED_MESSAGE_DEFINITIONS_JSON - Update README.md examples to reflect new API naming
- Rename MessageConverter to VdsSealCodingRegistry - Rename IdbMessageTypeParser to IdbMessageTypeRegistry - Rename IdbNationalDocumentTypeParser to IdbNationalDocumentTypeRegistry - Add resetToDefaults() to DataEncoder for test isolation - Add KDoc documentation to VdsSealCodingRegistry - Add tests for loadCustom...FromFile functions - Add custom test resource JSON files
tsenger
commented
Jan 22, 2026
Owner
Author
tsenger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking Changes
Unified API naming for VDS and IDB
New Features
Type-safe value access with MessageValue sealed class
seal.getMessage("DATE_OF_BIRTH")?.let { msg ->
when (val v = msg.value) {
is MessageValue.DateValue -> println(v.date)
is MessageValue.MaskedDateValue -> println(v.value)
else -> println(v)
}
}
Types: ByteValue, StringValue, DateValue, MaskedDateValue, MrzValue, BytesValue
resetToDefaults() added to DataEncoder for test isolation.
Migration