OSDN Git Service

X.690 Amendment1 (10/2003)
authorjwat <jwat@users.sourceforge.jp>
Tue, 8 May 2012 08:01:06 +0000 (17:01 +0900)
committerjwat <jwat@users.sourceforge.jp>
Tue, 8 May 2012 08:01:06 +0000 (17:01 +0900)
94 files changed:
jp/bitmeister/asn1/codec/ASN1Decoder.java
jp/bitmeister/asn1/codec/ASN1Encoder.java
jp/bitmeister/asn1/codec/ber/BerDecoder.java
jp/bitmeister/asn1/codec/ber/BerEncoder.java
jp/bitmeister/asn1/codec/ber/DerEncoder.java
jp/bitmeister/asn1/codec/ber/EncodedOctets.java
jp/bitmeister/asn1/codec/ber/package-info.java
jp/bitmeister/asn1/codec/package-info.java
jp/bitmeister/asn1/codec/xer/XerConstants.java
jp/bitmeister/asn1/codec/xer/XerDecoder.java
jp/bitmeister/asn1/codec/xer/XerEncoder.java
jp/bitmeister/asn1/codec/xer/XerStringEscapeUtil.java
jp/bitmeister/asn1/codec/xer/package-info.java
jp/bitmeister/asn1/exception/ASN1DecodingException.java
jp/bitmeister/asn1/exception/ASN1EncodingException.java
jp/bitmeister/asn1/exception/ASN1Exception.java
jp/bitmeister/asn1/exception/ASN1IllegalArgument.java
jp/bitmeister/asn1/exception/ASN1IllegalDefinition.java
jp/bitmeister/asn1/exception/ASN1InvalidDataValue.java
jp/bitmeister/asn1/exception/ASN1RuntimeException.java
jp/bitmeister/asn1/exception/DetailedMessage.java
jp/bitmeister/asn1/exception/package-info.java
jp/bitmeister/asn1/processor/ASN1Processor.java
jp/bitmeister/asn1/processor/ASN1StringBuilder.java
jp/bitmeister/asn1/processor/ASN1Visitor.java
jp/bitmeister/asn1/processor/ASN1VisitorAdaptor.java
jp/bitmeister/asn1/processor/package-info.java
jp/bitmeister/asn1/sample/FrightStatus.java
jp/bitmeister/asn1/sample/FrightStatusMain.java
jp/bitmeister/asn1/sample/FrightStatusTypes.asn
jp/bitmeister/asn1/sample/FrightStatusTypes.java
jp/bitmeister/asn1/type/ASN1Module.java
jp/bitmeister/asn1/type/ASN1ModuleManager.java
jp/bitmeister/asn1/type/ASN1TagClass.java
jp/bitmeister/asn1/type/ASN1TagDefault.java
jp/bitmeister/asn1/type/ASN1TagMode.java
jp/bitmeister/asn1/type/ASN1TagValue.java
jp/bitmeister/asn1/type/ASN1Type.java
jp/bitmeister/asn1/type/BuiltInModule.java
jp/bitmeister/asn1/type/CollectionType.java
jp/bitmeister/asn1/type/Concatenatable.java
jp/bitmeister/asn1/type/ConstructiveType.java
jp/bitmeister/asn1/type/ElementSpecification.java
jp/bitmeister/asn1/type/ElementsChecker.java
jp/bitmeister/asn1/type/ModuleSpecification.java
jp/bitmeister/asn1/type/NamedTypeSpecification.java
jp/bitmeister/asn1/type/PrimitiveType.java
jp/bitmeister/asn1/type/SelectiveType.java
jp/bitmeister/asn1/type/SizeCountable.java
jp/bitmeister/asn1/type/StringType.java
jp/bitmeister/asn1/type/StructuredType.java
jp/bitmeister/asn1/type/TimeType.java
jp/bitmeister/asn1/type/TypeSpecification.java
jp/bitmeister/asn1/type/UnknownType.java
jp/bitmeister/asn1/type/ValueComparable.java
jp/bitmeister/asn1/type/builtin/ANY.java
jp/bitmeister/asn1/type/builtin/BIT_STRING.java
jp/bitmeister/asn1/type/builtin/BOOLEAN.java
jp/bitmeister/asn1/type/builtin/CHOICE.java
jp/bitmeister/asn1/type/builtin/ENUMERATED.java
jp/bitmeister/asn1/type/builtin/INTEGER.java
jp/bitmeister/asn1/type/builtin/NULL.java
jp/bitmeister/asn1/type/builtin/OBJECT_IDENTIFIER.java
jp/bitmeister/asn1/type/builtin/OCTET_STRING.java
jp/bitmeister/asn1/type/builtin/REAL.java
jp/bitmeister/asn1/type/builtin/RELATIVE_OID.java
jp/bitmeister/asn1/type/builtin/SEQUENCE.java
jp/bitmeister/asn1/type/builtin/SEQUENCE_OF.java
jp/bitmeister/asn1/type/builtin/SET.java
jp/bitmeister/asn1/type/builtin/SET_OF.java
jp/bitmeister/asn1/type/builtin/package-info.java
jp/bitmeister/asn1/type/package-info.java
jp/bitmeister/asn1/type/useful/BMPString.java
jp/bitmeister/asn1/type/useful/CHARACTER_STRING.java
jp/bitmeister/asn1/type/useful/EMBEDDED_PDV.java
jp/bitmeister/asn1/type/useful/EXTERNAL.java
jp/bitmeister/asn1/type/useful/GeneralString.java
jp/bitmeister/asn1/type/useful/GeneralizedTime.java
jp/bitmeister/asn1/type/useful/GraphicString.java
jp/bitmeister/asn1/type/useful/IA5String.java
jp/bitmeister/asn1/type/useful/NumericString.java
jp/bitmeister/asn1/type/useful/ObjectDescriptor.java
jp/bitmeister/asn1/type/useful/PrintableString.java
jp/bitmeister/asn1/type/useful/TeletexString.java
jp/bitmeister/asn1/type/useful/UTCTime.java
jp/bitmeister/asn1/type/useful/UTF8String.java
jp/bitmeister/asn1/type/useful/UniversalString.java
jp/bitmeister/asn1/type/useful/VideotexString.java
jp/bitmeister/asn1/type/useful/VisibleString.java
jp/bitmeister/asn1/type/useful/package-info.java
jp/bitmeister/asn1/value/BinString.java
jp/bitmeister/asn1/value/HexString.java
jp/bitmeister/asn1/value/StringItem.java
jp/bitmeister/asn1/value/package-info.java

index cffea2c..2bd5534 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 7c3a587..1b9cb90 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 1d007f5..25c5ae8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -284,6 +284,13 @@ public class BerDecoder implements ASN1Decoder,
                        case 0x41:
                                data.set(Double.NEGATIVE_INFINITY);
                                break;
+                       // X.690 Amendment1 (10/2003)
+                       case 0x42:
+                               data.set(Double.NaN);
+                               break;
+                       case 0x43:
+                               data.set(-0d);
+                               break;
                        default:
                                ASN1DecodingException ex = new ASN1DecodingException();
                                ex.setMessage("'0x" + Integer.toHexString(octets[0] & 0xff)
index 83be1d9..9bb84c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -191,6 +191,8 @@ public class BerEncoder implements ASN1Encoder,
                } else if (data.value().isInfinite()) { // special value.
                        encoded = new byte[] { data.value() == Double.POSITIVE_INFINITY ? (byte) 0x40
                                        : 0x41 };
+               } else if (data.value().isNaN()) {
+                       encoded = new byte[] {0x43}; // X.690 Amendment1 (10/2003)
                } else { // ISO6093
                        String str = data.value().toString();
                        encoded = new byte[str.length() + 1];
index cfe0fc4..2f2b5e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -86,6 +86,8 @@ public class DerEncoder extends BerEncoder {
                } else if (data.value().isInfinite()) { // special value.
                        encoded = new byte[] { data.value() == Double.POSITIVE_INFINITY ? (byte) 0x40
                                        : 0x41 };
+               } else if (data.value().isNaN()) {
+                       encoded = new byte[] {0x43}; // X.690 Amendment1 (10/2003)
                } else if (data.isBinary()) { // IEEE754 double form.
                        long bits = Double.doubleToLongBits(data.value());
 
index 70f3100..de57181 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index ec14553..3e882cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 5f45de8..c82cb64 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 18a5139..4d4ce63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,5 +34,6 @@ class XerConstants {
        static final String BOOLEAN_FALSE = "false";
        static final String REAL_PLUS_INFINITY = "PLUS-INFINITY";
        static final String REAL_MINUS_INFINITY = "MINUS-INFINITY";
+       static final String REAL_NAN = "NOT-A-NUMBER";
        static final String REAL_ZERO = "0";
 }
index 4b31a4f..cc0c88e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package jp.bitmeister.asn1.codec.xer;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.BOOLEAN_FALSE;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.BOOLEAN_TRUE;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_MINUS_INFINITY;
+import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_NAN;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_PLUS_INFINITY;
 
 import java.io.InputStream;
@@ -688,6 +689,8 @@ public class XerDecoder implements ASN1Decoder,
                                        data.set(Double.POSITIVE_INFINITY);
                                } else if (qName.equals(REAL_MINUS_INFINITY)) {
                                        data.set(Double.NEGATIVE_INFINITY);
+                               } else if (qName.equals(REAL_NAN)) {
+                                       data.set(Double.NaN);
                                }
                        }
 
index 70be035..0a4a41f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import static jp.bitmeister.asn1.codec.xer.XerConstants.BOOLEAN_FALSE;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.BOOLEAN_TRUE;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.END_TAG_START;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_MINUS_INFINITY;
+import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_NAN;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_PLUS_INFINITY;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.REAL_ZERO;
 import static jp.bitmeister.asn1.codec.xer.XerConstants.SINGLE_TAG_END;
@@ -312,7 +313,10 @@ public class XerEncoder implements ASN1Encoder,
                                        + (data.value() == Double.POSITIVE_INFINITY ? REAL_PLUS_INFINITY
                                                        : REAL_MINUS_INFINITY) + SINGLE_TAG_END;
                }
-               if (data.value() == 0) {
+               else if (data.value().isNaN()) {
+                       return TAG_START + REAL_NAN + SINGLE_TAG_END;
+               }
+               else if (data.value() == 0) {
                        return REAL_ZERO;
                }
                return BigDecimal.valueOf(data.value()).stripTrailingZeros()
index 40cb2aa..b5e8550 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index ecdc3f3..c9a7c2b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 8ca3b96..9c598c7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index de1cdea..e2b42bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 5a3bbed..a81806f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index d7539b9..d6d0372 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 68b4277..82d53ee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 162d409..b0a5805 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 5ae0bd9..bda784b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 853f7d0..dccde49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index bf07f9f..0f9b21d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 6961c40..afb2abd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 96b2b2b..74b0761 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index fe3bdc8..b392d80 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index e105b3a..06e3612 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 60585eb..07385ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 76211f2..0ccd75e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index f4190ea..1ce192c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -73,8 +73,7 @@ public class FrightStatusMain {
                System.out.println("Source data:");
                System.out.println(frights);
                derEncAndDec(frights);
-               xerEncAndDec(frights);
-
+               xerEncAndDec(frights);          
        }
 
        static void derEncAndDec(ASN1Type data) {
index 511196d..292e8f0 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2011-2012 BitMeister Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 FrightStatusTypes DEFINITIONS AUTOMATIC TAGS ::= BEGIN
        
        FrightNumber ::= PrintableString
index 25c950e..5237550 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -144,4 +144,5 @@ public class FrightStatusTypes extends ASN1Module {
                }
 
        }
+       
 }
index 6d89c2c..b9d353d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -96,8 +96,7 @@ public abstract class ASN1Module {
                        ModuleSpecification spec) {
                for (Class<?> e : module.getDeclaredClasses()) {
                        if (ASN1Type.class.isAssignableFrom(e)) {
-                               @SuppressWarnings("unchecked")
-                               Class<? extends ASN1Type> type = (Class<? extends ASN1Type>) e;
+                               Class<? extends ASN1Type> type = e.asSubclass(ASN1Type.class);
                                spec.register(type);
                        }
                }
index a8b18b6..16565fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index e92c5da..d50011b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index d2d9fab..d5508dd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 3bfadd6..337175b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 25c4d78..65c66d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a412d2a..ffb3dbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index cd0c4b1..74e6418 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 15ee6f0..5a209a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index ddf9e22..6a2a91f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 7614dd2..3320ae4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,9 +68,7 @@ public abstract class ConstructiveType extends StructuredType {
                                                .getAnnotation(ASN1Element.class), f));
                        }
                }
-               @SuppressWarnings("unchecked")
-               Class<? extends ConstructiveType> parent = (Class<? extends ConstructiveType>) type
-                               .getSuperclass();
+               Class<? extends ConstructiveType> parent = type.getSuperclass().asSubclass(ConstructiveType.class);
                ElementSpecification[] array;
                if (parent == SET.class || parent == SEQUENCE.class
                                || parent.isAnnotationPresent(ASN1Extendable.class)) {
index 75cd4df..0d615af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 047dd9e..686d82c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a2df100..7d66523 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 7011a2c..77b3754 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -155,9 +155,8 @@ public class NamedTypeSpecification implements
                if (tag != null) {
                        return tagClass == tag.tagClass() && tagNumber == tag.tagNumber();
                }
-               @SuppressWarnings("unchecked")
                TypeSpecification typeSpec = TypeSpecification
-                               .getSpecification((Class<? extends ASN1Type>) field.getType());
+                               .getSpecification(field.getType().asSubclass(ASN1Type.class));
                if (typeSpec.tagged()) {
                        return typeSpec.matches(tagClass, tagNumber);
                }
@@ -169,10 +168,9 @@ public class NamedTypeSpecification implements
         * 
         * @return An empty instance of this element type.
         */
-       @SuppressWarnings("unchecked")
        public ASN1Type instantiate() {
                return ASN1Type
-                               .instantiate((Class<? extends ASN1Type>) field.getType());
+                               .instantiate(field.getType().asSubclass(ASN1Type.class));
        }
 
        /**
@@ -180,9 +178,8 @@ public class NamedTypeSpecification implements
         * 
         * @return The type of this field.
         */
-       @SuppressWarnings("unchecked")
        Class<? extends ASN1Type> type() {
-               return (Class<? extends ASN1Type>) field.getType();
+               return field.getType().asSubclass(ASN1Type.class);
        }
 
        /**
@@ -190,9 +187,8 @@ public class NamedTypeSpecification implements
         * 
         * @return
         */
-       @SuppressWarnings("unchecked")
        Class<? extends ASN1Type> enclosingType() {
-               return (Class<? extends ASN1Type>) field.getDeclaringClass();
+               return field.getDeclaringClass().asSubclass(ASN1Type.class);
        }
 
        /**
index c97bed7..87274fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a2e1bfe..12eb6d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import jp.bitmeister.asn1.annotation.ASN1Alternative;
 import jp.bitmeister.asn1.annotation.ASN1Extendable;
 import jp.bitmeister.asn1.exception.ASN1IllegalArgument;
 import jp.bitmeister.asn1.exception.ASN1IllegalDefinition;
+import jp.bitmeister.asn1.exception.ASN1InvalidDataValue;
 import jp.bitmeister.asn1.type.builtin.CHOICE;
 
 /**
@@ -64,9 +65,7 @@ public abstract class SelectiveType extends StructuredType {
                                                ASN1Alternative.class).value(), f));
                        }
                }
-               @SuppressWarnings("unchecked")
-               Class<? extends SelectiveType> parent = (Class<? extends SelectiveType>) type
-                               .getSuperclass();
+               Class<? extends SelectiveType> parent = type.getSuperclass().asSubclass(SelectiveType.class);
                NamedTypeSpecification[] array;
                if (parent == CHOICE.class || parent.isAnnotationPresent(ASN1Extendable.class)) {
                        if (alternatives.isEmpty()) {
@@ -333,6 +332,24 @@ public abstract class SelectiveType extends StructuredType {
                return selection() != null;
        }
 
+       /* (non-Javadoc)
+        * @see jp.bitmeister.asn1.type.ASN1Type#validate()
+        */
+       @Override
+       public void validate() throws ASN1InvalidDataValue {
+               ASN1Type selected = selectedValue();
+               if (selected != null) {
+                       selected.validate();
+               }
+               else {
+                       ASN1InvalidDataValue ex = new ASN1InvalidDataValue();
+                       ex.setMessage("Mandatory data value is not present.",
+                                       null, getClass(),
+                                       null, this);
+                       throw ex;
+               }
+       }
+
        /*
         * (non-Javadoc)
         * 
index 16e1098..245a14c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 3992440..2a0a5c8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index b976ac8..1fc5783 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index af965a7..b65afd3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 28d96b7..065bbe5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,6 @@ public class TypeSpecification {
         *            The {@code Class} object of an ASN.1 type.
         * @return The {@code TypeSpecification} of the type.
         */
-       @SuppressWarnings("unchecked")
        static TypeSpecification getSpecification(Class<? extends ASN1Type> type) {
                if (TYPE_SPECIFICATIONS.containsKey(type)) {
                        return TYPE_SPECIFICATIONS.get(type);
@@ -63,11 +62,11 @@ public class TypeSpecification {
                } else if (type.isMemberClass()) {
                        Class<?> enclosure = type.getDeclaringClass();
                        if (ASN1Module.class.isAssignableFrom(enclosure)) {
-                               Class<? extends ASN1Module> module = (Class<? extends ASN1Module>) enclosure;
+                               Class<? extends ASN1Module> module = enclosure.asSubclass(ASN1Module.class);
                                specification.module = module;
                        }
                        if (ASN1Type.class.isAssignableFrom(enclosure)) {
-                               Class<? extends ASN1Type> enclosingType = (Class<? extends ASN1Type>) enclosure;
+                               Class<? extends ASN1Type> enclosingType = enclosure.asSubclass(ASN1Type.class);
                                specification.module = getSpecification(enclosingType).module;
                        }
                }
@@ -83,7 +82,7 @@ public class TypeSpecification {
                        try {
                                Class<? extends ASN1Type> referenceType = type;
                                do {
-                                       referenceType = (Class<? extends ASN1Type>) referenceType.getSuperclass();
+                                       referenceType = referenceType.getSuperclass().asSubclass(ASN1Type.class);
                                } while (referenceType.isAnnotationPresent(ASN1Extendable.class));
                                specification.reference = getSpecification(referenceType);
                        } catch (ClassCastException e) {
index f36d49a..b7dc36b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 3e2c304..42c4e1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 600815f..d465b04 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 64b2782..348f026 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -134,9 +134,7 @@ public class BIT_STRING extends PrimitiveType<boolean[]> implements
                        }
                        map.put(value, fieldId);
                }
-               @SuppressWarnings("unchecked")
-               Class<? extends BIT_STRING> parent = (Class<? extends BIT_STRING>) type
-                               .getSuperclass();
+               Class<? extends BIT_STRING> parent = type.getSuperclass().asSubclass(BIT_STRING.class);
                if (parent != BIT_STRING.class) {
                        if (!map.isEmpty()) {
                                ASN1IllegalDefinition ex = new ASN1IllegalDefinition();
index c731d6d..cfdd967 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 81e8c2a..ff539fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index adcb83c..abdb094 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 8edb00e..e991ffe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -133,9 +133,7 @@ public class INTEGER extends PrimitiveType<BigInteger> implements
                        }
                        map.put(value, fieldId);
                }
-               @SuppressWarnings("unchecked")
-               Class<? extends INTEGER> parent = (Class<? extends INTEGER>) type
-                               .getSuperclass();
+               Class<? extends INTEGER> parent = type.getSuperclass().asSubclass(INTEGER.class);
                if (parent == ENUMERATED.class) {
                        if (map.isEmpty()) {
                                ASN1IllegalDefinition ex = new ASN1IllegalDefinition();
index 06b6d60..29a1154 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 0c584aa..2d4037f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 02d450e..c286b9b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 43d05fd..915fe46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index bf23672..ba644a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 8871cd0..de4adff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index abab6c5..69955c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index e283c78..2cc24ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 1fbe07e..2c90363 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 633cec9..748b087 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 6f8e092..98cd5bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 9540e4c..695780c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index b06989d..851055b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index ffabbc9..cc1ea4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 5b152c3..4ac80e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 6881f3a..0e3a9b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 3770a65..80fb663 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a8b0621..8df5605 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 1c40377..dfaa2ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 508bff5..5053cc1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 586eb96..f7014fe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a2cfe3e..db96b5c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index e1499fe..08336dd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index cdcda78..5b5d262 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index f084eb4..ae5c889 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 1fe0240..fb90cee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 0dadef9..3df2da7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 6e06d1d..4b9b1d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a6aeeb2..f5c8ccc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index ea5fe07..7ff0ddf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index f93b50f..006391d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 38a5299..e5d63b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index a57a946..c3aff41 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.