    001package org.apache.commons.ssl.asn1;
    002
    003/**
    004 * class for breaking up an OID into it's component tokens, ala
    005 * java.util.StringTokenizer. We need this class as some of the
    006 * lightweight Java environment don't support classes like
    007 * StringTokenizer.
    008 */
    009public class OIDTokenizer {
    010    private String oid;
    011    private int index;
    012
    013    public OIDTokenizer(
    014        String oid) {
    015        this.oid = oid;
    016        this.index = 0;
    017    }
    018
    019    public boolean hasMoreTokens() {
    020        return (index != -1);
    021    }
    022
    023    public String nextToken() {
    024        if (index == -1) {
    025            return null;
    026        }
    027
    028        String token;
    029        int end = oid.indexOf('.', index);
    030
    031        if (end == -1) {
    032            token = oid.substring(index);
    033            index = -1;
    034            return token;
    035        }
    036
    037        token = oid.substring(index, end);
    038
    039        index = end + 1;
    040        return token;
    041    }
    042}