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

package org.bouncycastle.asn1;

import java.io.IOException;

class BERTaggedObjectParser implements ASN1TaggedObjectParser
{
    final int _tagClass;
    final int _tagNo;
    final ASN1StreamParser _parser;
    
    BERTaggedObjectParser(final int tagClass, final int tagNo, final ASN1StreamParser parser) {
        this._tagClass = tagClass;
        this._tagNo = tagNo;
        this._parser = parser;
    }
    
    @Override
    public int getTagClass() {
        return this._tagClass;
    }
    
    @Override
    public int getTagNo() {
        return this._tagNo;
    }
    
    @Override
    public boolean hasContextTag() {
        return this._tagClass == 128;
    }
    
    @Override
    public boolean hasContextTag(final int n) {
        return this._tagClass == 128 && this._tagNo == n;
    }
    
    @Override
    public boolean hasTag(final int n, final int n2) {
        return this._tagClass == n && this._tagNo == n2;
    }
    
    @Override
    public boolean hasTagClass(final int n) {
        return this._tagClass == n;
    }
    
    @Override
    public ASN1Primitive getLoadedObject() throws IOException {
        return this._parser.loadTaggedIL(this._tagClass, this._tagNo);
    }
    
    @Override
    public ASN1Encodable parseBaseUniversal(final boolean b, final int n) throws IOException {
        if (b) {
            return this._parser.parseObject(n);
        }
        return this._parser.parseImplicitConstructedIL(n);
    }
    
    @Override
    public ASN1Encodable parseExplicitBaseObject() throws IOException {
        return this._parser.readObject();
    }
    
    @Override
    public ASN1TaggedObjectParser parseExplicitBaseTagged() throws IOException {
        return this._parser.parseTaggedObject();
    }
    
    @Override
    public ASN1TaggedObjectParser parseImplicitBaseTagged(final int n, final int n2) throws IOException {
        return new BERTaggedObjectParser(n, n2, this._parser);
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        try {
            return this.getLoadedObject();
        }
        catch (final IOException ex) {
            throw new ASN1ParsingException(ex.getMessage());
        }
    }
}
