public class StringPartFromFileLines extends StringPartScan
Reader
.
readNextContent(int)
.
This routine checks whether there is enough space to read a next content.
The essential values for that are the StringPart.begin
value.
It is assumed that the content before StringPart.begin
are already processed
and hence no more necessary.
Additional the readNextContent(int)
expects an at least number of chars to read.
If the StringPart.begin
is lesser as that argument, nothing is read.
With that rule the readNextContent(int)
can be called any time without check,
but does nothing of it is not necessary, to save time.
Modifier and Type | Class and Description |
---|---|
private class |
StringPartFromFileLines.CharSq |
StringPart.Iter, StringPart.Part
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
bEof |
(package private) boolean |
bLesserReadAsExpected |
(package private) char[] |
cBuffer |
private char |
cExpectedSesoncNl
The second newline character set if the first nl was read.
|
(package private) java.nio.charset.Charset |
charset |
(package private) int |
endIxLinePosition
After the last used position in the
linePositions array. |
(package private) java.io.Reader |
inpr
The reader maybe with correct charset.
|
(package private) IntegerBlockArray |
linePositions |
(package private) int |
nLineCt
Current line.
|
(package private) int |
nrFirstLineInPositions
The number of the first line for the current position
|
(package private) java.lang.String |
sNewline |
static java.lang.String |
version
Version, history and license.
|
(package private) int |
zBuffer
Nr of characters in buffer.
|
beginScan, beginScanLast, nLastFloatNumber, nLastIntegerNumber, nLastIntegerSign, sLastString, sVersion
absPos0, bCurrentOk, begiMin, begin, beginLast, bFound, bitMode, bStartScan, content, end, endLast, endMax, mSeekBack, mSeekCheck, mSeekEnd, mSeekToLeft, mSkipOverCommentInsideText_mode, mSkipOverCommentToEol_mode, mSkipOverWhitespace_mode, sCheckNewline, sCheckWhitespaces, sCommentEnd, sCommentStart, sCommentToEol, seekBack, seekEnd, seekNormal, seekToLeft, sFile
Constructor and Description |
---|
StringPartFromFileLines(java.lang.Class<?> clazz,
java.lang.String pathInJarFromClazz,
int maxSizeBuffer,
java.lang.String sEncodingDetect,
java.nio.charset.Charset charsetDefault)
Loads a resource from jar file into this StringBuffer.
|
StringPartFromFileLines(java.io.File fromFile)
Fills a StringPart from a File.
|
StringPartFromFileLines(java.io.File fromFile,
int maxBuffer,
java.lang.String sEncodingDetect,
java.nio.charset.Charset charset)
Fills a StringPart from a File.
|
StringPartFromFileLines(java.io.InputStream input,
java.lang.String sInputPath,
int sizeBuffer,
java.lang.String sEncodingDetect,
java.nio.charset.Charset charsetDefault)
Fills a StringPart from a opened Stream.
|
StringPartFromFileLines(java.io.Reader input,
java.lang.String sInputPath,
int sizeBuffer)
Fills a StringPart from a opened Stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the work.
|
private int |
evalLineIndices(int from,
int to) |
int |
getLineAndColumn(int[] column)
Returns the line and column of the current position.
|
boolean |
readNextContent(int minPosToRead)
Read next content from the file.
|
boolean |
readnextContentFromFile(int minSizeForAction)
Deprecated.
use
readNextContent(int) as the overridden form of base routine. |
getCircumScriptionToAnyChar, getCircumScriptionToAnyCharOutsideQuotion, getLastScannedFloatNumber, getLastScannedIntegerNumber, getLastScannedIntegerSign, getLastScannedPart, getLastScannedPart, getLastScannedString, scan, scan, scanAnyChar, scanChar, scanDigits, scanDigits, scanFloatNumber, scanFloatNumber, scanFloatNumber, scanFractionalExponent, scanFractionalNumber, scanHex, scanHex, scanHexOrDecimal, scanHexOrDecimal, scanIdentifier, scanIdentifier, scanInteger, scanInteger, scanInteger, scanLiteral, scanOk, scanPositivInteger, scanQuotion, scanQuotion, scanSkipComment, scanSkipSpace, scanStart, scanStart, scanToAnyChar, scanToAnyChar, seekScanPos
absCharAt, absSubString, assign, assign, assignFromEnd, assignReplaceEnv, charAt, checkCharAt, clean, compareTo, contentTillSpaceEndOrQuotation, debugString, equals, firstlineMaxpart, found, fromEnd, getCharSequenceRange, getCurrent, getCurrent, getCurrentChar, getCurrentColumn, getCurrentPart, getCurrentPart, getCurrentPosition, getInputfile, getLastPart, getLenCurrent, getPart, indexEndOfQuotation, indexEndOfQuotation, indexEndOfQuotion, indexOf, indexOf, indexOf, indexOf, indexOfAnyChar, indexOfAnyChar, indexOfAnyChar, indexOfAnyCharOutsideQuotation, indexOfAnyCharOutsideQuotion, indexOfAnyString, indexOfNoChar, indexOfNoChar, iterator, lastIndexOfAnyChar, len0end, lenBacktoNoChar, lenBacktoNoWhiteSpaces, length, lengthMaxPart, lento, lento, lento, lento, lentoAnyChar, lentoAnyChar, lentoAnyChar, lentoAnyCharOutsideQuotation, lentoAnyCharOutsideQuotion, lentoAnyNonEscapedChar, lentoAnyString, lentoAnyString, lentoAnyStringWithIndent, lentoIdentifier, lentoIdentifier, lentoLineEnd, lentoNonEscapedString, lentoNumber, lentoPos, lentoQuotionEnd, line, nextlineMaxpart, replace, seek, seek, seek, seek, seekAfterNewline, seekAnyChar, seekAnyString, seekBackToAnyChar, seekBackward, seekBegin, seekCheck, seekCheckEnd, seekEnd, seekNextLine, seekNoChar, seekNoWhitespace, seekNoWhitespaceOrComments, seekPos, seekPosBack, setBeginMaxPart, setCurrentMaxPart, setCurrentPartTo, setCurrentPosition, setIgnoreComment, setIgnoreComment, setIgnoreEndlineComment, setIgnoreEndlineComment, setIgnoreWhitespaces, setInputfile, setLengthMax, setParttoMax, skipWhitespaceAndComment, startsWith, subSequence, substring, toString, trim, trimComment, trimWhiteSpaces, XXXindexOf
public static final java.lang.String version
StringPartFromFileLines(Reader, String, int)
StringPartFromFileLines(InputStream, String, int, String, Charset)
with negativ argument sizeBuffer
StringPartFromFileLines(Class, String, int, String, Charset)
StringPartFromFileLines(InputStream, String, int, String, Charset)
with negativ argument sizeBuffer
StringPart
, improvement here: readnextContentFromFile(int)
shifts only StringPart.begin
/2
to save the content near to and left from the current working area for access capability of a Part
near the current content.
StringPartFromFileLines(InputStream, String, int, String, Charset)
to use with ClassLoader.getSystemClassLoader().getResourceAsStream("path");
- 2015-06-07 Hartmut chg:
getLineAndColumn(int[])
: column counts from 1 on leftest position.
- 2014-05-22 Hartmut new:
StringPart.setInputfile(String)
invoked with input file
- 2014-04-22 Hartmut chg: improved line numbers
- 2012-12-22 Hartmut chg: close() the file in constructor if the whole file was read.
- 2010-02-11 Hartmut new: The ctor StringPartFromFileLines(File fromFile) is added,
it is compatible to StringPartFromFile now.
- 2009-05-31 Hartmut detecting and ignoring a BOM (byte order mark) as first char.
- 2009-04-09 Hartmut encoding detection korrig.
- 2006-05-00 Hartmut creation
final char[] cBuffer
int zBuffer
final java.nio.charset.Charset charset
private char cExpectedSesoncNl
int nLineCt
boolean bEof
boolean bLesserReadAsExpected
java.io.Reader inpr
int nrFirstLineInPositions
IntegerBlockArray linePositions
int endIxLinePosition
linePositions
array.java.lang.String sNewline
public StringPartFromFileLines(java.io.File fromFile) throws java.io.FileNotFoundException, java.io.IOException, java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetException
StringPartFromFileLines(File, int, String, Charset)
with default arguments for charset and buffer size.fromFile
- The file to readjava.io.FileNotFoundException
- If the file is not foundjava.io.IOException
- If any other exception is thrownjava.nio.charset.IllegalCharsetNameException
java.nio.charset.UnsupportedCharsetException
public StringPartFromFileLines(java.io.File fromFile, int maxBuffer, java.lang.String sEncodingDetect, java.nio.charset.Charset charset) throws java.io.FileNotFoundException, java.io.IOException, java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetException
StringPartFromFileLines(InputStream, String, int, String, Charset)
with the opened file.fromFile
- The file to readmaxBuffer
- The maximum of length of the associated StringBuffer.sEncodingDetect
- If not null, this string is searched in the first line,
read in US-ASCII or UTF-16-Format. If this string is found, the followed
string in quotation marks or as identifier with addition '-' char is read
and used as charset name. If the charset name is failed, a CharsetException is thrown.
It means, a failed content of file may cause a charset exception.charset
- If not null, this charset is used as default, if no other charset is found in the files first line,
see param sEncodingDetect. If null and not charset is found in file, the systems default charset is used.java.io.FileNotFoundException
- If the file is not foundjava.io.IOException
- If any other exception is thrownjava.nio.charset.IllegalCharsetNameException
java.nio.charset.UnsupportedCharsetException
public StringPartFromFileLines(java.lang.Class<?> clazz, java.lang.String pathInJarFromClazz, int maxSizeBuffer, java.lang.String sEncodingDetect, java.nio.charset.Charset charsetDefault) throws java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetException, java.io.IOException
close()
to close the resource.clazz
- This class is the start point of the:pathInJarFromClazz
- relative from clazz, use "../../package/path/to/resource.ext" if it is not in the same package.maxSizeBuffer
- The size for the StringPart is gotten from the resource: InputStream.available()
,
at least 1000 chars if available() returns not the length, but at least this size.sEncodingDetect
- If not null, this string is searched in the first 2 lines,
read in US-ASCII or UTF-16-Format. If this string is found, the followed
string in quotion marks or as identifier with addition '-' char is read
and used as charset name. If the charset name is failed, a CharsetException is thrown.
It means, a failed content of file may cause a charset exception.charset
- If not null, this charset is used as default, if no other charset is found in the files first line,
see param sEncodingDetect. If null and not charset is found in file, the systems default charset is used.java.nio.charset.IllegalCharsetNameException
java.nio.charset.UnsupportedCharsetException
java.io.IOException
public StringPartFromFileLines(java.io.Reader input, java.lang.String sInputPath, int sizeBuffer) throws java.io.IOException, java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetException
ClassLoader.getSystemClassLoader().getResourceAsStream("path");
.
It is the core method called in the other constructors using a File input.
This is the core routine called from all other constructors. All capabilities described on the other constructors are here.input
- Any input stream, maybe a ClassLoader getRessourceAsStreamsInputPath
- Hint for error messages from which input is it.sizeBuffer
- The length of the associated StringBuffer.java.io.IOException
java.nio.charset.IllegalCharsetNameException
java.nio.charset.UnsupportedCharsetException
public StringPartFromFileLines(java.io.InputStream input, java.lang.String sInputPath, int sizeBuffer, java.lang.String sEncodingDetect, java.nio.charset.Charset charsetDefault) throws java.io.IOException, java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetException
ClassLoader.getSystemClassLoader().getResourceAsStream("path");
.
It is the core method called in the other constructors using a File input.
This is the core routine called from all other constructors. All capabilities described on the other constructors are here.input
- Any input stream, maybe a ClassLoader getRessourceAsStreamsInputPath
- Hint for error messages from which input is it.sizeBuffer
- The length of the associated StringBuffer.
If negative, then determine form input.available, but use the given negate number as maximum if >= (-1000). sEncodingDetect
- If not null, this string is searched in the first 2 lines,
read in US-ASCII or UTF-16-Format. If this string is found, the followed
string in quotion marks or as identifier with addition '-' char is read
and used as charset name. If the charset name is failed, a CharsetException is thrown.
It means, a failed content of file may cause a charset exception.charset
- If not null, this charset is used as default, if no other charset is found in the files first line,
see param sEncodingDetect. If null and not charset is found in file, the systems default charset is used.java.io.IOException
java.nio.charset.IllegalCharsetNameException
java.nio.charset.UnsupportedCharsetException
public int getLineAndColumn(int[] column)
IntegerBlockArray
which uses blocks of a constant size.getLineAndColumn
in class StringPart
column
- The leftest position in a line is 1, like usual in editors.StringPart.getLineAndColumn(int[])
private int evalLineIndices(int from, int to)
public boolean readNextContent(int minPosToRead) throws java.io.IOException
StringPart.begin
is lesser the argument minSizeForAction.
If does not shift the content if the StringPart.begin
is < 1/8 of the size. That is especially after reading head information.
But it reads from file if especially minSizeForAction is ==0.
If shifts the text in the internal buffer StringPart.content
respectively cBuffer
(the same) but only the half of current content.
Especially Part
remain accessible if they are near the current content. See remarks there about persistence.readNextContent
in class StringPartScan
minPosToRead
- returns without action if Current position (it is StringPart.begin
) is lesser.
Set =0 for reading the first content.
Set to about 2/3 of size for normal operation.java.io.IOException
@Deprecated public boolean readnextContentFromFile(int minSizeForAction) throws java.io.IOException
readNextContent(int)
as the overridden form of base routine.StringPart.begin
is lesser the argument minSizeForAction.
If does not shift the content if the StringPart.begin
is < 1/8 of the size. That is especially after reading head information.
But it reads from file if especially minSizeForAction is ==0.
If shifts the text in the internal buffer StringPart.content
respectively cBuffer
(the same) but only the half of current content.
Especially Part
remain accessible if they are near the current content. See remarks there about persistence.minSizeForAction
- returns without action if Current position (it is StringPart.begin
) is lesser.
Set =0 for reading the first content.
Set to about 2/3 of size for normal operation.java.io.IOException
public void close()
StringPartScan
Closeable
is not used here.close
in class StringPartScan