// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.asn1;

import java.io.IOException;

class DLTaggedObjectParser extends BERTaggedObjectParser
{
    private final boolean _constructed;
    
    DLTaggedObjectParser(final int n, final int n2, final boolean constructed, final ASN1StreamParser asn1StreamParser) {
        super(n, n2, asn1StreamParser);
        this._constructed = constructed;
    }
    
    @Override
    public ASN1Primitive getLoadedObject() throws IOException {
        return this._parser.loadTaggedDL(this._tagClass, this._tagNo, this._constructed);
    }
    
    @Override
    public ASN1Encodable parseBaseUniversal(final boolean b, final int n) throws IOException {
        if (b) {
            return this.checkConstructed().parseObject(n);
        }
        return this._constructed ? this._parser.parseImplicitConstructedDL(n) : this._parser.parseImplicitPrimitive(n);
    }
    
    @Override
    public ASN1Encodable parseExplicitBaseObject() throws IOException {
        return this.checkConstructed().readObject();
    }
    
    @Override
    public ASN1TaggedObjectParser parseExplicitBaseTagged() throws IOException {
        return this.checkConstructed().parseTaggedObject();
    }
    
    @Override
    public ASN1TaggedObjectParser parseImplicitBaseTagged(final int n, final int n2) throws IOException {
        return new DLTaggedObjectParser(n, n2, this._constructed, this._parser);
    }
    
    private ASN1StreamParser checkConstructed() throws IOException {
        if (!this._constructed) {
            throw new IOException("Explicit tags must be constructed (see X.690 8.14.2)");
        }
        return this._parser;
    }
}
