SLPTokenizer.java revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License, Version 1.0 only 2N/A * (the "License"). You may not use this file except in compliance 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * ident "%Z%%M% %I% %E% SMI" 2N/A * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * This is a replacement for StringTokenizer since there 2N/A * is an incompatibility between JDK 1.2 and JDK 1.3.1 2N/A * and beyond which breaks slp.jar support for apps which 2N/A * could use either JDK. 2N/A * Calculates the number of times that this tokenizer's 2N/A * nextToken method can be called before it generates an 2N/A // a token starts if 2N/A // (a) next character is a non delimiter 2N/A // (b) there are more characters 2N/A i++;
// we were in a token, now completed it 2N/A // To get here, we must be in a token. 2N/A * Returns the same value as the hasMoreTokens method. 2N/A // Check to see if all there is left are delimiters. 2N/A // If so there are no more elements. 2N/A return true;
// A non-delim char found! 2N/A return false;
// No non-delim chars remain! 2N/A return true;
// Something remains. 2N/A * Tests if there are more tokens available from this 2N/A * tokenizer's string. 2N/A * Returns the same value as the nextToken method, 2N/A * except that its declared return value is Object 2N/A * rather than String. 2N/A * Returns the next token from this string tokenizer. 2N/A // We begin at a delimiter. Return it & advance over. 2N/A // Advance to next delimiter and stop. Return string. 2N/A // We get here only if this is the last token. 2N/A // token till the end 2N/A // token till a delimiter 2N/A // only delimiters till the end (exception!) 2N/A index++;
// Do not include delimiters if no content yet. 2N/A }
else {
// Not the delimiter yet. 2N/A * Returns the next token in this string tokenizer's string. 2N/A // This is not thread safe, but it will String. 2N/A // There are no guarantees StringTokenizer is 2N/A // thread safe either.