01: package org.bouncycastle.asn1;
02:
03: /**
04: * class for breaking up an OID into it's component tokens, ala
05: * java.util.StringTokenizer. We need this class as some of the
06: * lightweight Java environment don't support classes like
07: * StringTokenizer.
08: */
09: public class OIDTokenizer {
10: private String oid;
11: private int index;
12:
13: public OIDTokenizer(String oid) {
14: this .oid = oid;
15: this .index = 0;
16: }
17:
18: public boolean hasMoreTokens() {
19: return (index != -1);
20: }
21:
22: public String nextToken() {
23: if (index == -1) {
24: return null;
25: }
26:
27: String token;
28: int end = oid.indexOf('.', index);
29:
30: if (end == -1) {
31: token = oid.substring(index);
32: index = -1;
33: return token;
34: }
35:
36: token = oid.substring(index, end);
37:
38: index = end + 1;
39: return token;
40: }
41: }
|