Java APG, Version 1.0
Author Lowell D. Thomas
Copyright © Coast to Coast Research, Inc. 2011

com.coasttocoastresearch.apg
Class Utilities.LineCatalog

java.lang.Object
  extended by com.coasttocoastresearch.apg.Utilities.LineCatalog
Enclosing class:
Utilities

public static class Utilities.LineCatalog
extends java.lang.Object

A class for reading a text file and cataloging its text lines. A catalog record is generated for each text line. The records have information about the line number, the offset to the first character of the line and the line length.


Nested Class Summary
 class Utilities.LineCatalog.Line
          Class defining a catalog record for an individual line of text.
 
Constructor Summary
Utilities.LineCatalog(char[] inputArray)
          Constructor
Utilities.LineCatalog(java.lang.String inputString)
          Constructor
 
Method Summary
 void clear()
          Clears the catalog of all lines.
 void displayErrors(java.io.PrintStream out)
          Displays all errors encountered during the cataloging, if any.
 void displayWarnings(java.io.PrintStream out)
          Displays all warnings issued during the cataloging, if any.
 int getErrorCount()
          Get the number of errors encountered during the cataloging.
 Utilities.LineCatalog.Line getLine(int lineno)
          Retrieves a single catalog Line by line number.
 int getLineCount()
          Get the number of lines in the text file.
 Utilities.LineCatalog.Line getLineFromOffset(int offset)
          Retrieves a single catalog Line for the line containing the requested offset character.
 java.util.ListIterator<Utilities.LineCatalog.Line> getLineIterator()
          Get an iterator over the cataloged record Lines.
 int getWarningCount()
          Get the number of warnings issuedduring the cataloging.
 java.lang.String toString()
          Displays all lines of text with all Line information for each line.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Utilities.LineCatalog

public Utilities.LineCatalog(char[] inputArray)
                      throws java.lang.IllegalArgumentException
Constructor

Parameters:
inputArray - the text whose lines are to be cataloged as a character array.
Throws:
java.lang.IllegalArgumentException - thrown if the input string is null or empty.

Utilities.LineCatalog

public Utilities.LineCatalog(java.lang.String inputString)
                      throws java.lang.IllegalArgumentException
Constructor

Parameters:
inputString - the text whose lines are to be cataloged as a String.
Throws:
java.lang.IllegalArgumentException - thrown if the input string is null or empty.
Method Detail

clear

public void clear()
Clears the catalog of all lines. Clears the list of errors and warnings.


displayErrors

public void displayErrors(java.io.PrintStream out)
Displays all errors encountered during the cataloging, if any.

Parameters:
out - the output device to display on.

displayWarnings

public void displayWarnings(java.io.PrintStream out)
Displays all warnings issued during the cataloging, if any.

Parameters:
out - the output device to display on.

getErrorCount

public int getErrorCount()
Get the number of errors encountered during the cataloging.

Returns:
the number of errors.

getLine

public Utilities.LineCatalog.Line getLine(int lineno)
Retrieves a single catalog Line by line number.

Parameters:
lineno - the number (1-based) of the line to retrieve.
Returns:
the catalog Line record.

getLineCount

public int getLineCount()
Get the number of lines in the text file.

Returns:
the number of lines

getLineFromOffset

public Utilities.LineCatalog.Line getLineFromOffset(int offset)
Retrieves a single catalog Line for the line containing the requested offset character.

Parameters:
offset - the offset of the first text character to find the line of.
Returns:
the catalog record Line.

getLineIterator

public java.util.ListIterator<Utilities.LineCatalog.Line> getLineIterator()
Get an iterator over the cataloged record Lines.

Returns:
the iterator.

getWarningCount

public int getWarningCount()
Get the number of warnings issuedduring the cataloging.

Returns:
the number of warnings.

toString

public java.lang.String toString()
Displays all lines of text with all Line information for each line.

Overrides:
toString in class java.lang.Object
Returns:
the display as a single String.

Java APG, Version 1.0
Author Lowell D. Thomas
Copyright © Coast to Coast Research, Inc. 2011

Licence Notification

All the software in this distribution is free software:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program in the COPYING file. If not, see GPL, Version 2
or GPL, Version 3 or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.