Class FormatTokenizer

java.lang.Object
overit.geocall.util.FormatTokenizer

public class FormatTokenizer extends Object
Auxiliary class to extract tokens from a string called format. The tokens are searched through two delimiter characters. See the constructor FormatTokenizer(format,c1,c2) for more information on how tokens are created.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected char
     
    protected char
     
    protected String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FormatTokenizer(String format, char c1, char c2)
    The constructor that defines the string called format from which the tokens will be extracted, and the two characthers that delimit the token.
    A token can be of two types: formatted: the part of the format that starts with the first input character and ends with the second input character.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if there are still tokens to analyze.
    boolean
    Return if the string passed as input is a formatted string.
    Locate and return the next token to analyze.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _begin

      protected int _begin
    • _format

      protected String _format
    • _c1

      protected char _c1
    • _c2

      protected char _c2
  • Constructor Details

    • FormatTokenizer

      public FormatTokenizer(String format, char c1, char c2)
      The constructor that defines the string called format from which the tokens will be extracted, and the two characthers that delimit the token.
      A token can be of two types:
      • formatted: the part of the format that starts with the first input character and ends with the second input character. The token contains the two delimiter characters;
      • constant: the part of the format between two formatted tokens. This token doesn't contains the delimiter characters.
      For example the string
      "{0{Someone has filled}{| has filled}{P||Jane Doe has filled}{L||Baby Doe has filled}} the bath tub{1{}{ of |}}"
      contains a first formatted token ("{0{Someone has filled}{| has filled} {P||Jane Doe has filled}{L||Baby Doe has filled}}"), a first constant token (" the bath tub") and a second formatted token ("{1{}{ of |}}").
      Parameters:
      format - The string to elaborate containing the tokens.
      c1 - The first delimiter character.
      c2 - The second delimiter character.
  • Method Details

    • hasNext

      public boolean hasNext()
      Check if there are still tokens to analyze.
      Returns:
      The boolean to indicate if there are still tokens.
    • next

      public String next()
      Locate and return the next token to analyze. See the constructor FormatTokenizer(format,c1,c2) to understand how a token is defined.
      Returns:
      The string containing the next token.
    • isFormat

      public boolean isFormat(String s)
      Return if the string passed as input is a formatted string. For formatted string we mean a string that starts with the first delimiter character and ends with the second delimiter character.
      Parameters:
      s - The string to check if it is formatted.
      Returns:
      Return the boolean to understand if the string is formatted. Obviously "true" means that the string is formatted, "false" means no.