Class ANTLRNoNewLineStream

java.lang.Object
org.antlr.runtime.ANTLRStringStream
net.javapla.jawn.templates.stringtemplate.rewrite.ANTLRNoNewLineStream
All Implemented Interfaces:
org.antlr.runtime.CharStream, org.antlr.runtime.IntStream

public class ANTLRNoNewLineStream
extends org.antlr.runtime.ANTLRStringStream
This is purposefully not optimised for speed, as it only ought to be for reading files, and it should be up to other classes to cache the results from this.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static int EXPECTED_LINE_LENGTH  

    Fields inherited from class org.antlr.runtime.ANTLRStringStream

    charPositionInLine, data, lastMarker, line, markDepth, markers, n, name, p

    Fields inherited from interface org.antlr.runtime.CharStream

    EOF
  • Constructor Summary

    Constructors 
    Constructor Description
    ANTLRNoNewLineStream​(java.io.InputStream input, java.lang.String encoding)  
    ANTLRNoNewLineStream​(java.net.URL f)  
    ANTLRNoNewLineStream​(java.net.URL f, java.lang.String encoding)  
  • Method Summary

    Modifier and Type Method Description
    protected static void trim​(java.lang.StringBuilder bob, java.lang.String line)
    Trim the string but keep a single space in the end of the string if one or more is present.
    protected static int trimEndOfLine​(java.lang.CharSequence s, int len)  
    protected static int trimStartOfLine​(java.lang.CharSequence s, int len)  

    Methods inherited from class org.antlr.runtime.ANTLRStringStream

    consume, getCharPositionInLine, getLine, getSourceName, index, LA, LT, mark, release, reset, rewind, rewind, seek, setCharPositionInLine, setLine, size, substring, toString

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • ANTLRNoNewLineStream

      public ANTLRNoNewLineStream​(java.net.URL f) throws java.io.IOException
      Throws:
      java.io.IOException
    • ANTLRNoNewLineStream

      public ANTLRNoNewLineStream​(java.net.URL f, java.lang.String encoding) throws java.io.IOException
      Throws:
      java.io.IOException
    • ANTLRNoNewLineStream

      public ANTLRNoNewLineStream​(java.io.InputStream input, java.lang.String encoding) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • trim

      protected static final void trim​(java.lang.StringBuilder bob, java.lang.String line)
      Trim the string but keep a single space in the end of the string if one or more is present. The original String.trim() removes all characters such as spaces and newlines: (character <= ' '). Keeping a single space is needed as the removal of all newline characters AND spaces results in strings suddenly missing correct spacing in the words. However, skip the extra space if the line starts with a tag start '<', as the previous line probably ended anyway. At this point in the execution we know that \r and \n are removed completely (due to AsyncBufferedReader), so we only need to look at the spaces surrounding the line.
      Parameters:
      bob -
      line -
    • trimStartOfLine

      protected static final int trimStartOfLine​(java.lang.CharSequence s, int len)
    • trimEndOfLine

      protected static final int trimEndOfLine​(java.lang.CharSequence s, int len)