OSDN Git Service

Bug fix on BerDecoder.
authorjwat <jwat@users.sourceforge.jp>
Thu, 7 Jul 2011 02:48:02 +0000 (11:48 +0900)
committerjwat <jwat@users.sourceforge.jp>
Thu, 7 Jul 2011 02:48:02 +0000 (11:48 +0900)
Clearing content octets when a DerOctets is fixed.
Fix ambiguous definition on FrightStatusTypes.asn.

jp/bitmeister/asn1/codec/ber/BerDecoder.java
jp/bitmeister/asn1/codec/ber/DerEncoder.java
jp/bitmeister/asn1/sample/FrightStatus.java
jp/bitmeister/asn1/sample/FrightStatusTypes.asn

index 9e733cb..15c2e49 100644 (file)
@@ -160,6 +160,8 @@ public class BerDecoder implements ASN1Decoder,
                } while (specification != null);
                try {
                        data.accept(this);
+               } catch (ASN1DecodingException ex) {
+                       throw ex;
                } catch (Exception e) {
                        ASN1DecodingException ex = new ASN1DecodingException();
                        ex.setMessage("Exception thrown while decoding process.", e,
@@ -416,6 +418,7 @@ public class BerDecoder implements ASN1Decoder,
                                        if (e.matches(BerDecoder.this.tagClass,
                                                        BerDecoder.this.tagNumber)) {
                                                processComponent(data, e);
+                                               break;
                                        }
                                }
                        }
index 8a3c843..8e66793 100644 (file)
@@ -293,6 +293,7 @@ public class DerEncoder extends BerEncoder {
                                System.arraycopy(e, 0, encodedOctets, index, e.length);
                                index += e.length;
                        }
+                       clearContents();
                }
 
                /**
@@ -309,9 +310,16 @@ public class DerEncoder extends BerEncoder {
                }
 
                /**
-                * @return
+                * Returns all content octets.
+                * 
+                * @return The array of content octets.
                 */
                abstract byte[][] getContents();
+               
+               /**
+                * Clears content octets.
+                */
+               abstract void clearContents();
 
                /**
                 * Comparator used for sorting elements by the canonical order for tags.
@@ -419,6 +427,14 @@ public class DerEncoder extends BerEncoder {
                        return new byte[][] {contents};
                }
 
+               /* (non-Javadoc)
+                * @see jp.bitmeister.asn1.codec.ber.DerEncoder.DerOctets#clearContents()
+                */
+               @Override
+               void clearContents() {
+                       contents = null;
+               }
+
        }
 
        /**
@@ -480,6 +496,14 @@ public class DerEncoder extends BerEncoder {
                        return contents;
                }
                
+               /* (non-Javadoc)
+                * @see jp.bitmeister.asn1.codec.ber.DerEncoder.DerOctets#clearContents()
+                */
+               @Override
+               void clearContents() {
+                       // nothing to do.
+               }
+
                /**
                 * Sorts elements by the canonical order for tags.
                 * 
index cfbf89d..9050932 100644 (file)
@@ -23,11 +23,11 @@ import jp.bitmeister.asn1.sample.FrightStatusTypes.Information;
 import jp.bitmeister.asn1.sample.FrightStatusTypes.Status;
 import jp.bitmeister.asn1.type.ASN1TagClass;
 import jp.bitmeister.asn1.type.ASN1TagMode;
-import jp.bitmeister.asn1.type.builtin.SEQUENCE;
+import jp.bitmeister.asn1.type.builtin.SET;
 
 @ASN1ModuleRef(FrightStatusTypes.class)
 @ASN1Tag(value = 0, tagClass = ASN1TagClass.APPLICATION, tagMode = ASN1TagMode.IMPLICIT)
-public class FrightStatus extends SEQUENCE {
+public class FrightStatus extends SET {
 
        @ASN1Element(0)
        public FrightNumber frightNo;
@@ -41,6 +41,7 @@ public class FrightStatus extends SEQUENCE {
        public Information arrival;
        
        @ASN1Element(3)
+       @ASN1Tag(2)
        public Status status;
        
        public FrightStatus() {}
index abd13ca..19ff5e6 100644 (file)
@@ -24,7 +24,7 @@ FrightStatusTypes DEFINITIONS AUTOMATIC TAGS ::= BEGIN
                frightNo FrightNumber,
                departure [0] IMPLICIT Information,
                arrival [1] IMPLICIT Information,
-               status Status
+               status [2] Status
        }
        
        AllFrights ::= SEQUENCE OF FrightStatus