Class Expression.Tokenizer

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.String>
    Enclosing class:
    Expression

    private class Expression.Tokenizer
    extends java.lang.Object
    implements java.util.Iterator<java.lang.String>
    Expression tokenizer that allows to iterate over a String expression token by token. Blank characters will be skipped.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String input
      The original input expression.
      private int pos
      Actual position in expression string.
      private java.lang.String previousToken
      The previous token or null if none.
    • Constructor Summary

      Constructors 
      Constructor Description
      Tokenizer​(java.lang.String input)
      Creates a new tokenizer for an expression.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getPos()
      Get the actual character position in the string.
      boolean hasNext()  
      java.lang.String next()  
      private char peekNextChar()
      Peek at the next character, without advancing the iterator.
      void remove()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • pos

        private int pos
        Actual position in expression string.
      • input

        private java.lang.String input
        The original input expression.
      • previousToken

        private java.lang.String previousToken
        The previous token or null if none.
    • Constructor Detail

      • Tokenizer

        public Tokenizer​(java.lang.String input)
        Creates a new tokenizer for an expression.
        Parameters:
        input - The expression string.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.String>
      • peekNextChar

        private char peekNextChar()
        Peek at the next character, without advancing the iterator.
        Returns:
        The next character or character 0, if at end of string.
      • next

        public java.lang.String next()
        Specified by:
        next in interface java.util.Iterator<java.lang.String>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<java.lang.String>
      • getPos

        public int getPos()
        Get the actual character position in the string.
        Returns:
        The actual character position.