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 intEXPECTED_LINE_LENGTH -
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 voidtrim(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 inttrimEndOfLine(java.lang.CharSequence s, int len)protected static inttrimStartOfLine(java.lang.CharSequence s, int len)
-
Field Details
-
EXPECTED_LINE_LENGTH
protected static final int EXPECTED_LINE_LENGTH- See Also:
- Constant Field Values
-
-
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)
-