1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one or more 4 * contributor license agreements. See the NOTICE file distributed with 5 * this work for additional information regarding copyright ownership. 6 * The ASF licenses this file to You under the Apache License, Version 2.0 7 * (the "License"); you may not use this file except in compliance with 8 * the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.apache.geronimo.util.asn1; 20 21 /** 22 * class for breaking up an OID into it's component tokens, ala 23 * java.util.StringTokenizer. We need this class as some of the 24 * lightweight Java environment don't support classes like 25 * StringTokenizer. 26 */ 27 public class OIDTokenizer 28 { 29 private String oid; 30 private int index; 31 32 public OIDTokenizer( 33 String oid) 34 { 35 this.oid = oid; 36 this.index = 0; 37 } 38 39 public boolean hasMoreTokens() 40 { 41 return (index != -1); 42 } 43 44 public String nextToken() 45 { 46 if (index == -1) 47 { 48 return null; 49 } 50 51 String token; 52 int end = oid.indexOf('.', index); 53 54 if (end == -1) 55 { 56 token = oid.substring(index); 57 index = -1; 58 return token; 59 } 60 61 token = oid.substring(index, end); 62 63 index = end + 1; 64 return token; 65 } 66 }