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

package org.bouncycastle.asn1;

import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.Enumeration;

class LazyConstructionEnumeration implements Enumeration
{
    private ASN1InputStream aIn;
    private Object nextObj;
    
    public LazyConstructionEnumeration(final byte[] array) {
        this.aIn = new ASN1InputStream(array, true);
        this.nextObj = this.readObject();
    }
    
    @Override
    public boolean hasMoreElements() {
        return this.nextObj != null;
    }
    
    @Override
    public Object nextElement() {
        if (this.nextObj != null) {
            final Object nextObj = this.nextObj;
            this.nextObj = this.readObject();
            return nextObj;
        }
        throw new NoSuchElementException();
    }
    
    private Object readObject() {
        try {
            return this.aIn.readObject();
        }
        catch (final IOException obj) {
            throw new ASN1ParsingException("malformed ASN.1: " + obj, obj);
        }
    }
}
