• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.asn1;
2 
3 /**
4  * class for breaking up an OID into it's component tokens, ala
5  * java.util.StringTokenizer. We need this class as some of the
6  * lightweight Java environment don't support classes like
7  * StringTokenizer.
8  */
9 public class OIDTokenizer
10 {
11     private String  oid;
12     private int     index;
13 
OIDTokenizer( String oid)14     public OIDTokenizer(
15         String oid)
16     {
17         this.oid = oid;
18         this.index = 0;
19     }
20 
hasMoreTokens()21     public boolean hasMoreTokens()
22     {
23         return (index != -1);
24     }
25 
nextToken()26     public String nextToken()
27     {
28         if (index == -1)
29         {
30             return null;
31         }
32 
33         String  token;
34         int     end = oid.indexOf('.', index);
35 
36         if (end == -1)
37         {
38             token = oid.substring(index);
39             index = -1;
40             return token;
41         }
42 
43         token = oid.substring(index, end);
44 
45         index = end + 1;
46         return token;
47     }
48 }
49