Class SimpleTextParser.StringCollector

  • All Implemented Interfaces:
    java.util.function.IntConsumer, java.util.function.IntPredicate
    Enclosing class:
    SimpleTextParser

    private final class SimpleTextParser.StringCollector
    extends java.lang.Object
    implements java.util.function.IntPredicate, java.util.function.IntConsumer
    Internal class used to collect strings from the character stream while ensuring that the collected strings do not exceed the maximum configured string length.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int col
      Start position column.
      private int line
      Start position line.
      private java.util.function.IntPredicate pred
      Character predicate.
      private java.lang.StringBuilder sb
      String builder instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      StringCollector​(int line, int col, java.util.function.IntPredicate pred)
      Construct a new instance with the given start position and character predicate.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(int value)
      java.lang.String getString()
      Get the string collected by this instance.
      private boolean hasExceededMaxStringLength()
      Return true if this collector has exceeded the maximum configured string length.
      boolean test​(int value)
      • Methods inherited from class java.lang.Object

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

        andThen
      • Methods inherited from interface java.util.function.IntPredicate

        and, negate, or
    • Field Detail

      • sb

        private final java.lang.StringBuilder sb
        String builder instance.
      • line

        private final int line
        Start position line.
      • col

        private final int col
        Start position column.
      • pred

        private final java.util.function.IntPredicate pred
        Character predicate.
    • Constructor Detail

      • StringCollector

        StringCollector​(int line,
                        int col,
                        java.util.function.IntPredicate pred)
        Construct a new instance with the given start position and character predicate.
        Parameters:
        line - start position line
        col - start position col
        pred - character predicate
    • Method Detail

      • test

        public boolean test​(int value)
        Specified by:
        test in interface java.util.function.IntPredicate
      • accept

        public void accept​(int value)
        Specified by:
        accept in interface java.util.function.IntConsumer
      • getString

        public java.lang.String getString()
        Get the string collected by this instance.
        Returns:
        the string collected by this instance
        Throws:
        java.lang.IllegalStateException - if the string exceeds the maximum configured length
      • hasExceededMaxStringLength

        private boolean hasExceededMaxStringLength()
        Return true if this collector has exceeded the maximum configured string length.
        Returns:
        true if this collector has exceeded the maximum string length