Class UtilQuote
java.lang.Object
org.libxmq.imp.UtilQuote
- Direct Known Subclasses:
UtilParseQuote, UtilPrintQuote
Base class for analyzing and manipulating xmq quotes, shared by the
quote parsing and quote printing utilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanSet to true if the quote only consists of newlines and spaces.protected StringWe analyze part of a larger buffer, typically the whole xmq source file.protected intThe buffer_start_ points to where in the larger buffer_ we find the quote to be parsed.protected intThe buffer_stop_ points to just after the quote to be parsed.protected static final booleanDebug flag, currently disabled.protected intStores the index of the first ending newline characters after which lines do not contain non-space characters.protected intWhile looking for the first ending newline, remember the last indent.protected intStores the index of the last leading newline character after which the line contains non-space characters.protected ArrayList<org.libxmq.imp.Line> Stores start,stop,nl for each line found inside a quote.protected intMaximum number of consecutive double quotes found.protected intMaximum number of consecutive single quotes found.protected intThe minimum indentation found.protected booleanTrue if a compound quote form is needed.protected intStores the number of ending newline characters found after the last line with non-space characters.protected intStores the number of leading newline characters found before the first line with non-space characters.protected intTotal number of newlines.protected intStart stores the index either buffer_start_, if no leading newlines are found or start stores the last_leading_nl+1, ie the first character of the first line with non-space characters.protected intStop stores the index either buffer_stop_, if no ending newlines are found or stop stores the first_ending_nl, ie after the end of the last line with non-space characters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcountSame(int start, int stop) Look at the char at index start and count how many identical chars there are forward.protected voidScans the buffer for trailing newline ('\n') and space (' ') characters.protected voidScans q_ for leading newline ('\n') and space (' ') characters.
-
Field Details
-
debug_
protected static final boolean debug_Debug flag, currently disabled.- See Also:
-
buffer_
We analyze part of a larger buffer, typically the whole xmq source file. The part is copied into this buffer_ and any CRLF is converted to LF in the process. -
buffer_start_
protected int buffer_start_The buffer_start_ points to where in the larger buffer_ we find the quote to be parsed. -
buffer_stop_
protected int buffer_stop_The buffer_stop_ points to just after the quote to be parsed. -
min_indent_
protected int min_indent_The minimum indentation found. -
lines_
Stores start,stop,nl for each line found inside a quote. -
num_nl_
protected int num_nl_Total number of newlines. Set to -1 if not counted yet. -
num_leading_nl_
protected int num_leading_nl_Stores the number of leading newline characters found before the first line with non-space characters. -
last_leading_nl_
protected int last_leading_nl_Stores the index of the last leading newline character after which the line contains non-space characters. Is -1 if no leading newline is found. -
all_leading_
protected boolean all_leading_Set to true if the quote only consists of newlines and spaces. -
num_ending_nl_
protected int num_ending_nl_Stores the number of ending newline characters found after the last line with non-space characters. -
first_ending_nl_
protected int first_ending_nl_Stores the index of the first ending newline characters after which lines do not contain non-space characters. Is -1 if no such ending newline is found. -
last_indent_
protected int last_indent_While looking for the first ending newline, remember the last indent. This indent influences the incidental indentation as well. -
start_
protected int start_Start stores the index either buffer_start_, if no leading newlines are found or start stores the last_leading_nl+1, ie the first character of the first line with non-space characters. -
stop_
protected int stop_Stop stores the index either buffer_stop_, if no ending newlines are found or stop stores the first_ending_nl, ie after the end of the last line with non-space characters. -
max_num_consecutive_single_quotes_
protected int max_num_consecutive_single_quotes_Maximum number of consecutive single quotes found. -
max_num_consecutive_double_quotes_
protected int max_num_consecutive_double_quotes_Maximum number of consecutive double quotes found. -
needs_compound_
protected boolean needs_compound_True if a compound quote form is needed.
-
-
Constructor Details
-
UtilQuote
Translate CRLF and CR to LF. Count number of newlines.- Parameters:
b- The buffer to process.start- The start index in the buffer.stop- The stop index in the buffer.
-
-
Method Details
-
countSame
protected int countSame(int start, int stop) Look at the char at index start and count how many identical chars there are forward. Used to count identical quotes in a sequence or count number of spaces used for indentation.- Parameters:
start- The index of the character to count from.stop- The stop index of the counting.- Returns:
- The number of identical characters.
-
findLeadingNewlines
protected void findLeadingNewlines()Scans q_ for leading newline ('\n') and space (' ') characters.The method identifies sequences of newlines and spaces at the start of the string and determines the index of the last newline that precedes a line with non-space content.
Example
q_ = " \n \n Hello World"; findLeadingNewlines(); // num_leading_nl_ = 2 // last_leading_nl_ = 4 -
findEndingNewlines
protected void findEndingNewlines()Scans the buffer for trailing newline ('\n') and space (' ') characters.
-