diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2022-02-10 14:00:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-10 14:00:06 +0100 |
commit | 7fe844da786691bf839f169bcab8e71b5021329e (patch) | |
tree | dad727a39dc76d330fe28480e24e8a846c36b760 /src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java | |
parent | Merge pull request #41 from UnionInternationalCheminsdeFer/1.2.13 (diff) | |
parent | version number update (diff) | |
download | UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.tar UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.tar.gz UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.tar.bz2 UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.tar.lz UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.tar.xz UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.tar.zst UIC-barcode-7fe844da786691bf839f169bcab8e71b5021329e.zip |
Diffstat (limited to 'src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java')
-rw-r--r-- | src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java b/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java index ce89a3e..3af7217 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/SequenceCoder.java @@ -150,13 +150,24 @@ class SequenceCoder implements Decoder, Encoder { @Override public <T> T decode(BitBuffer bitbuffer, Class<T> classOfT,Field f1, - Annotation[] extraAnnotations) { + Annotation[] extraAnnotations, + AsnExtractor extractor) { UperEncoder.logger.debug(String.format("decode SEQUENCE %s",classOfT.getSimpleName())); AnnotationStore annotations = new AnnotationStore(classOfT.getAnnotations(),extraAnnotations); T result = UperEncoder.instantiate(classOfT); - Asn1ContainerFieldSorter sorter = new Asn1ContainerFieldSorter(classOfT); + Asn1ContainerFieldSorter sorter = new Asn1ContainerFieldSorter(classOfT); boolean hasExtensionMarker = UperEncoder.hasExtensionMarker(annotations); boolean extensionPresent = false; + + //check Extraction + boolean extract = false; + if (extractor != null && !extractor.isStarted() && extractor.found(classOfT.getCanonicalName())) { + extractor.startExtraction(bitbuffer.position()); + extract = true; + } + + + //start decodong if (hasExtensionMarker) { extensionPresent = bitbuffer.get(); UperEncoder.logger.debug(String.format("with extension marker, extension %s", extensionPresent ? "present!" : "absent")); @@ -175,7 +186,7 @@ class SequenceCoder implements Decoder, Encoder { (UperEncoder.isOptional(f) && optionalFieldsMask.pop()))) { UperEncoder.logger.debug(String.format("Field : %s", f.getName())); try { - f.set(result, UperEncoder.decodeAny(bitbuffer,f.getType(),f, f.getAnnotations())); + f.set(result, UperEncoder.decodeAny(bitbuffer,f.getType(),f, f.getAnnotations(),extractor)); } catch (IllegalAccessException e) { throw new IllegalArgumentException("can't access 'set method' for field " + f + " of class " + classOfT + " " + e, e); } @@ -196,6 +207,11 @@ class SequenceCoder implements Decoder, Encoder { if (!hasExtensionMarker) { //done sorter.revertAccess(); + + if (extract) { + extractor.endExtraction(bitbuffer.position()); + } + return result; } @@ -222,7 +238,7 @@ class SequenceCoder implements Decoder, Encoder { Class<?> classOfElement = field != null ? field.getType() : null; if (field != null) { try { - Object decodedValue = UperEncoder.decodeAsOpenType(bitbuffer, classOfElement,field, field.getAnnotations()); + Object decodedValue = UperEncoder.decodeAsOpenType(bitbuffer, classOfElement,field, field.getAnnotations(),extractor); if (field != null) { field.set(result, decodedValue); } @@ -269,6 +285,11 @@ class SequenceCoder implements Decoder, Encoder { } // end of extension handling } sorter.revertAccess(); + + if (extract) { + extractor.endExtraction(bitbuffer.position()); + } + return result; } |