Package org.postgresql.util

# Class PGtokenizer

java.lang.Object
org.postgresql.util.PGtokenizer

public class PGtokenizer extends Object
This class is used to tokenize the text output of org.postgres. It's mainly used by the geometric classes, but is useful in parsing any output from custom data types output from org.postgresql.

See Also:
  - `PGbox`
  - `PGcircle`
  - `PGlseg`
  - `PGpath`
  - `PGpoint`
  - `PGpolygon`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected List<String>`
  `tokens`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PGtokenizer(String string, char delim)`
  Create a tokeniser.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getSize()`
  `String`
  `getToken(int n)`
  `void`
  `remove(String l, String t)`
  This removes the lead/trailing strings from all tokens.
  `static String`
  `remove(String s, String l, String t)`
  This removes the lead/trailing strings from a string.
  `void`
  `removeAngle()`
  Removes < and > from the beginning and end of all tokens.
  `static String`
  `removeAngle(String s)`
  Removes < and > from the beginning and end of a string.
  `void`
  `removeBox()`
  Removes [ and ] from the beginning and end of all tokens.
  `static String`
  `removeBox(String s)`
  Removes [ and ] from the beginning and end of a string.
  `void`
  `removeCurlyBrace()`
  Removes < and > from the beginning and end of all tokens.
  `static String`
  `removeCurlyBrace(String s)`
  Removes curly braces { and } from the beginning and end of a string.
  `void`
  `removePara()`
  Removes ( and ) from the beginning and end of all tokens.
  `static String`
  `removePara(String s)`
  Removes ( and ) from the beginning and end of a string.
  `int`
  `tokenize(String string, char delim)`
  This resets this tokenizer with a new string and/or delimiter.
  `PGtokenizer`
  `tokenizeToken(int n, char delim)`
  This returns a new tokenizer based on one of our tokens.

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

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

- ## Field Details

  - ### tokens

    protected List<String> tokens

- ## Constructor Details

  - ### PGtokenizer

    public PGtokenizer(String string, char delim)
    Create a tokeniser.

    We could have used StringTokenizer to do this, however, we needed to handle nesting of '(' ')' '[' ']' '<' and '>' as these are used by the geometric data types.

    Parameters:
      `string` - containing tokens
      `delim` - single character to split the tokens

- ## Method Details

  - ### tokenize

    public int tokenize(String string, char delim)
    This resets this tokenizer with a new string and/or delimiter.
    Parameters:
      `string` - containing tokens
      `delim` - single character to split the tokens
    Returns:
      number of tokens

  - ### getSize

    public int getSize()
    Returns:
      the number of tokens available

  - ### getToken

    public String getToken(int n)
    Parameters:
      `n` - Token number ( 0 ... getSize()-1 )
    Returns:
      The token value

  - ### tokenizeToken

    public PGtokenizer tokenizeToken(int n, char delim)
    This returns a new tokenizer based on one of our tokens.

    The geometric datatypes use this to process nested tokens (usually PGpoint).

    Parameters:
      `n` - Token number ( 0 ... getSize()-1 )
      `delim` - The delimiter to use
    Returns:
      A new instance of PGtokenizer based on the token

  - ### remove

    public static String remove(String s, String l, String t)
    This removes the lead/trailing strings from a string.
    Parameters:
      `s` - Source string
      `l` - Leading string to remove
      `t` - Trailing string to remove
    Returns:
      String without the lead/trailing strings

  - ### remove

    public void remove(String l, String t)
    This removes the lead/trailing strings from all tokens.
    Parameters:
      `l` - Leading string to remove
      `t` - Trailing string to remove

  - ### removePara

    public static String removePara(String s)
    Removes ( and ) from the beginning and end of a string.
    Parameters:
      `s` - String to remove from
    Returns:
      String without the ( or )

  - ### removePara

    public void removePara()
    Removes ( and ) from the beginning and end of all tokens.

  - ### removeBox

    public static String removeBox(String s)
    Removes [ and ] from the beginning and end of a string.
    Parameters:
      `s` - String to remove from
    Returns:
      String without the [ or ]

  - ### removeBox

    public void removeBox()
    Removes [ and ] from the beginning and end of all tokens.

  - ### removeAngle

    public static String removeAngle(String s)
    Removes < and > from the beginning and end of a string.
    Parameters:
      `s` - String to remove from
    Returns:
      String without the < or >

  - ### removeAngle

    public void removeAngle()
    Removes < and > from the beginning and end of all tokens.

  - ### removeCurlyBrace

    public static String removeCurlyBrace(String s)
    Removes curly braces { and } from the beginning and end of a string.
    Parameters:
      `s` - String to remove from
    Returns:
      String without the { or }

  - ### removeCurlyBrace

    public void removeCurlyBrace()
    Removes < and > from the beginning and end of all tokens.