Home | History | Annotate | Download | only in asn1
      1 package org.bouncycastle.asn1;
      2 
      3 import java.io.IOException;
      4 
      5 /**
      6  * Parser for indefinite-length SEQUENCEs.
      7  */
      8 public class BERSequenceParser
      9     implements ASN1SequenceParser
     10 {
     11     private ASN1StreamParser _parser;
     12 
     13     BERSequenceParser(ASN1StreamParser parser)
     14     {
     15         this._parser = parser;
     16     }
     17 
     18     /**
     19      * Read the next object in the SEQUENCE.
     20      *
     21      * @return the next object in the SEQUENCE, null if there are no more.
     22      * @throws IOException if there is an issue reading the underlying stream.
     23      */
     24     public ASN1Encodable readObject()
     25         throws IOException
     26     {
     27         return _parser.readObject();
     28     }
     29 
     30     /**
     31      * Return an in-memory, encodable, representation of the SEQUENCE.
     32      *
     33      * @return a BERSequence.
     34      * @throws IOException if there is an issue loading the data.
     35      */
     36     public ASN1Primitive getLoadedObject()
     37         throws IOException
     38     {
     39         return new BERSequence(_parser.readVector());
     40     }
     41 
     42     /**
     43      * Return an BERSequence representing this parser and its contents.
     44      *
     45      * @return an BERSequence
     46      */
     47     public ASN1Primitive toASN1Primitive()
     48     {
     49         try
     50         {
     51             return getLoadedObject();
     52         }
     53         catch (IOException e)
     54         {
     55             throw new IllegalStateException(e.getMessage());
     56         }
     57     }
     58 }
     59