Class UtilQuote

java.lang.Object
org.libxmq.imp.UtilQuote
Direct Known Subclasses:
UtilParseQuote, UtilPrintQuote

public class UtilQuote extends Object
Base class for analyzing and manipulating xmq quotes, shared by the quote parsing and quote printing utilities.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Set to true if the quote only consists of newlines and spaces.
    protected String
    We analyze part of a larger buffer, typically the whole xmq source file.
    protected int
    The buffer_start_ points to where in the larger buffer_ we find the quote to be parsed.
    protected int
    The buffer_stop_ points to just after the quote to be parsed.
    protected static final boolean
    Debug flag, currently disabled.
    protected int
    Stores the index of the first ending newline characters after which lines do not contain non-space characters.
    protected int
    While looking for the first ending newline, remember the last indent.
    protected int
    Stores 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 int
    Maximum number of consecutive double quotes found.
    protected int
    Maximum number of consecutive single quotes found.
    protected int
    The minimum indentation found.
    protected boolean
    True if a compound quote form is needed.
    protected int
    Stores the number of ending newline characters found after the last line with non-space characters.
    protected int
    Stores the number of leading newline characters found before the first line with non-space characters.
    protected int
    Total number of newlines.
    protected int
    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.
    protected int
    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.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    UtilQuote(String b, int start, int stop)
    Translate CRLF and CR to LF.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    countSame(int start, int stop)
    Look at the char at index start and count how many identical chars there are forward.
    protected void
    Scans the buffer for trailing newline ('\n') and space (' ') characters.
    protected void
    Scans q_ for leading newline ('\n') and space (' ') characters.

    Methods inherited from class Object

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

    • debug_

      protected static final boolean debug_
      Debug flag, currently disabled.
      See Also:
    • buffer_

      protected String 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_

      protected ArrayList<org.libxmq.imp.Line> 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

      protected UtilQuote(String b, int start, int stop)
      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.