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

package org.bouncycastle.asn1;

import java.io.IOException;

abstract class ASN1UniversalType extends ASN1Type
{
    final ASN1Tag tag;
    
    ASN1UniversalType(final Class clazz, final int n) {
        super(clazz);
        this.tag = ASN1Tag.create(0, n);
    }
    
    final ASN1Primitive checkedCast(final ASN1Primitive asn1Primitive) {
        if (this.javaClass.isInstance(asn1Primitive)) {
            return asn1Primitive;
        }
        throw new IllegalStateException("unexpected object: " + asn1Primitive.getClass().getName());
    }
    
    ASN1Primitive fromImplicitPrimitive(final DEROctetString derOctetString) {
        throw new IllegalStateException("unexpected implicit primitive encoding");
    }
    
    ASN1Primitive fromImplicitConstructed(final ASN1Sequence asn1Sequence) {
        throw new IllegalStateException("unexpected implicit constructed encoding");
    }
    
    final ASN1Primitive fromByteArray(final byte[] array) throws IOException {
        return this.checkedCast(ASN1Primitive.fromByteArray(array));
    }
    
    final ASN1Primitive getContextTagged(final ASN1TaggedObject asn1TaggedObject, final boolean b) {
        return this.checkedCast(ASN1Util.checkContextTagClass(asn1TaggedObject).getBaseUniversal(b, this));
    }
    
    final ASN1Primitive getTagged(final ASN1TaggedObject asn1TaggedObject, final boolean b) {
        return this.checkedCast(asn1TaggedObject.getBaseUniversal(b, this));
    }
    
    final ASN1Tag getTag() {
        return this.tag;
    }
}
