/* XBN Java: Generically useful, non-GUI Java code. http://sourceforge.net/projects/xbnjava Copyright (C) 1997-2003, Jeff Epstein All rights reserved. Modifications: No Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * If modifications are made to source code then this license should indicate that fact in the "Modifications" section above. * Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NOTE: This license contains NO advertising clause.] */ package xbn.util; import xbn.XBNObject; /**

Represents multiple-line source text, from which lines are retrieved individually, and in order.

Source code:  ForLineRetrieval.java.  Example code  See the example code for FLRFile.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public abstract class ForLineRetrieval extends XBNObject { //Must initialize this to 1. private int iLineNumber = 1; private String sLineSep = null; private int iLineSepLength = -1; protected ForLineRetrieval(String s_lineSep) { throwAXIfBadStr(s_lineSep, "s_lineSep", sCNSTR); sLineSep = s_lineSep; iLineSepLength = sLineSep.length(); } /**

Get the next line of text from the source.

**/ public abstract StringBuffer getNextLine(); /**

What is the number of the line about to be read?

**/ public final int getLineNumberNext() { return iLineNumber; } /**

How many lines have been read thus far?. What is the number of the line that was just read in?

@return (getLineNumberNext() - 1) **/ public final int getLineNumberPrev() { return (getLineNumberNext() - 1); } /**

Increment the line number. Sometime during getNextLine, this must be called. Of course, don't call it after the entire text has been processed.

**/ protected final void incLineNumber() { iLineNumber++; } /**

Are there more lines to be retrieved with getNextLine?

@return true If there are more lines to be processed.
false If all lines have been processed. **/ public abstract boolean hasMoreLines(); public final String getLineSeparator() { return sLineSep; } public final int getLineSepLength() { return iLineSepLength; } }