com.h3c.util

## Class Tokenizer

- java.lang.Object
- - com.h3c.util.Tokenizer

-     public class Tokenizer
      extends Object

  Utility class to provide a concise way to parse out string tokens and to allow repeated (infinite) parsing of the same string pattern.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `circular`
    `protected String` | `delimiters`
    `protected StringTokenizer` | `st`
    `protected String` | `string`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Tokenizer(String string, String delimiters)` Create a new tokenizer on the string and using the given delimiter characters.
    `Tokenizer(String string, String delimiters, boolean circular)` Create a new tokenizer on the string and using the given delimiter characters.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `circular()` Returns true if the tokenizer is marked as a circular one.
    `String` | `delimiters()` Get the delimiters string.
    `boolean` | `hasNext()` Determine if there are any more tokens to be parsed.
    `String` | `next()` Get the next token string.
    `int` | `nextInt()` Get the next token as an integer.
    `long` | `nextLong()` Get the next token as a long.
    `void` | `reset()` Reset the tokenizer to point to the beginning of the original string.
    `String` | `string()` Get the underlying string used to construct the tokenizer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### st

          protected StringTokenizer st

    - #### string

          protected String string

    - #### delimiters

          protected String delimiters

    - #### circular

          protected boolean circular

  - ### Constructor Detail

    - #### Tokenizer

          public Tokenizer(String string,
                   String delimiters)

      Create a new tokenizer on the string and using the given delimiter characters.
      Parameters:
        `string` - string to be tokenized
        `delimiters` - string of delimiters

    - #### Tokenizer

          public Tokenizer(String string,
                   String delimiters,
                   boolean circular)

      Create a new tokenizer on the string and using the given delimiter characters.
      Parameters:
        `string` - string to be tokenized
        `delimiters` - string of delimiters
        `circular` - true if the tokenizer is to be a circular one

  - ### Method Detail

    - #### reset

          public void reset()

      Reset the tokenizer to point to the beginning of the original string.

    - #### hasNext

          public boolean hasNext()

      Determine if there are any more tokens to be parsed.
      Returns:
        true if more tokens are available; false otherwise; always returns true for circular tokenizer

    - #### next

          public String next()

      Get the next token string.
      Returns:
        next token string

    - #### nextInt

          public int nextInt()

      Get the next token as an integer.
      Returns:
        next token parsed into an integer value

    - #### nextLong

          public long nextLong()

      Get the next token as a long.
      Returns:
        next token parsed into a long value

    - #### circular

          public boolean circular()

      Returns true if the tokenizer is marked as a circular one.
      Returns:
        true if tokenizer is circular; false otherwise

    - #### string

          public String string()

      Get the underlying string used to construct the tokenizer.
      Returns:
        string being parsed into tokens

    - #### delimiters

          public String delimiters()

      Get the delimiters string.
      Returns:
        the delimiters string

Copyright © 2014. All Rights Reserved.