public class StringPart extends java.lang.Object implements java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>, java.lang.Iterable<StringPart>
String
for the capability to build a String.substring(int)
.
seek(CharSequence, int)
, lento(CharSequence)
etc.
String.substring(int)
method
of standard Java till Version 6 builds a substring using and references the stored parent String. It was a cheap operation
in calculation time.
toString()
method of any returned CharSequence
for example getCurrentPart()
.toString(). This builds a persistent String which can be stored and used independent of all others.
CharSequence
as parameter should not store that in suggestion of persistence.
For example StringBuilder.append(CharSequence)
uses a non-persistent character sequence and adds it to its own buffer.
CharSequence
. The sequence of chars is represented by the getCurrentPart()
.
The method length()
returns the length of the current part. The method charAt(int)
returns the characters from beginLast
. The method subSequence(int, int)
builds a StringPart.Part
which refers the sub sequence inside the content
.
abcdefghijklmnopqrstuvwxyz Sample of the whole associated String ===================== The === indicates the maximal part ----------- The --- indicates the valid part before some operation +++++ The +++ indicates the valid part after some operationThe actual part of the string is changeable, without building a new substring. So some operations of seeking and scanning are offered.
assign(CharSequence)
, like constructor
setParttoMax()
: Sets the current part of the String to the whole String. For new search operations.
seekPos(int)
, seekPosBack(int)
: Sets the current part begin forward, for example seek(1) to skip over one character
seek(char, int)
, seek(CharSequence, int)
: Searches a character or a CharSequence, sets the begin of the current part to it.
seekAnyChar(CharSequence)
, seekBackToAnyChar(CharSequence)
: Searches any of some given characters.
seek(CharSequence, int)
, seekBackward(CharSequence)
: Searches any of some given characters.
seekAnyString(CharSequence[], int[])
: Searches any of some given character sequences.
seekNoWhitespace()
, seekNoWhitespaceOrComments()
: skip over all white spaces, maybe over comments
seekNoChar(CharSequence)
skip over all given characters
seekBegin()
Expands the spread starting from the most left position (the maximal part)
lento(int)
: set a length of the valid part
lento(char)
, lento(CharSequence, int)
: length till a end character or end string
lentoAnyChar(CharSequence, int)
, lentoAnyString(CharSequence[], int)
: length till one of some given end characters or Strings
lentoAnyCharOutsideQuotion(CharSequence, int)
: regards CharSequence in quotation as non-applying.
firstlineMaxpart()
, nextlineMaxpart()
: line processing. Each line can be individually evaluated or scanned.
StringPartScan
for further scan functions.
StringPartAppend
, StringPartFromFileLines
for complete processing.
StringFunctions
for basic operations.
Modifier and Type | Class and Description |
---|---|
(package private) class |
StringPart.Iter |
static class |
StringPart.Part
This class presents a part of the parent CharSequence of this class.
|
Modifier and Type | Field and Description |
---|---|
protected int |
absPos0
The absolute position of character in the input file of content[0] It is used for
StringPartFromFileLines or adequate reader. |
protected boolean |
bCurrentOk
false if current scanning is not match
|
protected int |
begiMin
The most left possible start position.
|
protected int |
begin
The actual start position of the valid part.
|
protected int |
beginLast
Borders of the last part before calling of scan__(), seek__(), lento__().
|
protected boolean |
bFound
True if the last operation of lento__(), seek etc. has found anything.
|
protected int |
bitMode
Some mode bits.
|
protected boolean |
bStartScan
If true, than all idxLastScanned... are set to 0,
it is after
#scanOk() or after #scanStart |
protected java.lang.CharSequence |
content
The referenced string.
|
protected int |
end
The actual exclusive end position of the valid part.
|
protected int |
endLast
Borders of the last part before calling of scan__(), seek__(), lento__().
|
protected int |
endMax
The most right possible exclusive end position.
|
static int |
mSeekBack
Flag to force seeking backward from the end position.
|
private static int |
mSeekBackward_
Flag bit to force seeking backward.
|
static int |
mSeekCheck
If this bit is set on seek, the position remains if the seek is not successfully (if
found() returns false). |
static int |
mSeekEnd
Flag to force setting the start position after the seeking string.
|
static int |
mSeekToLeft
Flag to force seeking backward from the start position.
|
private static int |
mSeekToLeft_
Flag bit to force seeking left from start (Backward).
|
protected static int |
mSkipOverCommentInsideText_mode
Bit in mode.
|
protected static int |
mSkipOverCommentToEol_mode
Bit in mode.
|
protected static int |
mSkipOverWhitespace_mode
Bit in mode.
|
private int[] |
posRewind
Strategy for buffer shifting:
begiMin should be existing always. |
protected static java.lang.String |
sCheckNewline |
protected static java.lang.String |
sCheckWhitespaces |
(package private) java.lang.String |
sCommentEnd
The string defined the end of comment inside a text.
|
(package private) java.lang.String |
sCommentStart
The string defined the start of comment inside a text.
|
(package private) java.lang.String |
sCommentToEol
The string defined the start of comment to end of line
|
static int |
seekBack |
static int |
seekEnd |
static int |
seekNormal
Flag to force seeking forward.
|
static int |
seekToLeft |
(package private) java.lang.String |
sFile
The file from which the StringPart was build.
|
static java.lang.String |
sVersion
Version, history and license.
|
Constructor and Description |
---|
StringPart()
Creates a new empty StringPart without an associated String.
|
StringPart(java.lang.CharSequence src)
Creates a new StringPart, with the given content from a String.
|
StringPart(java.lang.CharSequence src,
int start,
int end)
Builds a StringPart which uses the designated part of the given src.
|
Modifier and Type | Method and Description |
---|---|
protected char |
absCharAt(int index) |
protected java.lang.String |
absSubString(int from,
int to)
Returns a String from absolute range.
|
StringPart |
assign(java.lang.CharSequence src)
Sets the content to the given string, forgets the old content.
|
StringPart |
assign(StringPart src)
Sets the StringPart with the same String object as the given StringPart, forgets the old content.
|
StringPart |
assignFromEnd(StringPart src)
Sets the content of the StringPart , forgets the old content.
|
StringPart |
assignReplaceEnv(java.lang.StringBuilder input)
Sets the content to the given string, forgets the old content.
|
char |
charAt(int index)
This method returns the characters of the current part.
|
boolean |
checkCharAt(int pos,
java.lang.String chars)
Checks whether the char at pos in the current part is one of chars.
|
void |
clean()
Cleans the instance.
|
void |
close()
Deprecated.
|
int |
compareTo(java.lang.CharSequence str2)
Compares the current part with the given str2
|
java.lang.String |
contentTillSpaceEndOrQuotation(java.lang.String sQuotationStartEnd,
char escapeChar)
Sets the current part either to the whole quotation if it it starts with the quotation char,
or sets it till the first space, or till end if the space is not found.
|
java.lang.String |
debugString()
Returns a debug information of the content of the StringPart.
|
boolean |
equals(java.lang.CharSequence sCmp)
Compares the Part of string with the given string
|
StringPart |
firstlineMaxpart()
Sets the current and the maximal part from position 0 to the first end line character.
|
boolean |
found()
Returns true, if the last called seek__(), lento__() or skipWhitespaceAndComment()
operation founds the requested condition.
|
StringPart |
fromEnd()
Sets the start of the part to the exclusively end, set the end to the end of the content.
|
java.lang.CharSequence |
getCharSequenceRange(long from,
long to)
Returns the current CharSequence between both given absolute positions.
|
java.lang.CharSequence |
getCurrent()
Gets the chars from current Position.
|
java.lang.CharSequence |
getCurrent(int nChars)
Gets the next chars from current Position.
|
char |
getCurrentChar()
Gets the next char at current Position.
|
int |
getCurrentColumn()
Gets the current position in line (column of the text).
|
StringPart.Part |
getCurrentPart()
Returns the actual part of the string.
|
java.lang.CharSequence |
getCurrentPart(int maxLength)
Returns the actual part of the string.
|
long |
getCurrentPosition()
Gets the current position, useable for rewind.
|
java.lang.String |
getInputfile()
This method may be overridden to return the file which is used to build this Stringpart.
|
java.lang.CharSequence |
getLastPart()
Returns the last part of the string before any seek or scan operation.
|
int |
getLenCurrent() |
int |
getLineAndColumn(int[] column)
Get the Line number and the column of the begin position.
|
StringPart.Part |
getPart(int fromPos,
int nrofChars)
Retrurn the part from start to end independent of the current positions.
|
int |
indexEndOfQuotation(char cEndQuotion,
char transcriptChar,
int fromWhere,
int maxToTest)
Searches the end of a quoted string.
|
int |
indexEndOfQuotation(char cEndQuotion,
java.lang.String sInnerQuotionChars,
char transcriptChar,
int fromWhere,
int maxToTest)
Searches the end of a quoted string.
|
int |
indexEndOfQuotion(char cEndQuotion,
int fromWhere,
int maxToTest)
Searches the end of a quoted string.
|
int |
indexOf(char ch)
Returns the position of the char within the part,
returns -1 if the char is not found in the part.
|
int |
indexOf(char ch,
int fromIndex)
Returns the position of the char within the part, started inside the part with fromIndex,
returns -1 if the char is not found in the part started from 'fromIndex'.
|
int |
indexOf(java.lang.CharSequence sCmp)
Returns the position of the string within the part.
|
int |
indexOf(java.lang.CharSequence sCmp,
int fromIndex,
int maxToTest)
Returns the position of the string within the part.
|
int |
indexOfAnyChar(java.lang.CharSequence sChars)
Returns the position of one of the chars in sChars within the part,
returns -1 if the char is not found in the actual part.
|
int |
indexOfAnyChar(java.lang.CharSequence sChars,
int fromWhere,
int maxToTest)
Searches any char contained in sChars in the current part
Example: The given string in the current part is
abc end:zxy
The calling is
indexOfAnyChar("xyz", 0, 20);
The result is 8 because the character 'z' is found first as the end char.
|
int |
indexOfAnyChar(java.lang.CharSequence sChars,
int fromWhere,
int maxToTest,
char transcriptChar,
char quotationStartChar,
char quotationEndChar)
Returns the position of one of the chars in sChars within the part, started inside the part with fromIndex,
returns -1 if the char is not found in the part started from 'fromIndex'.
|
int |
indexOfAnyCharOutsideQuotation(java.lang.CharSequence sChars,
java.lang.String sPossibleQuotChars,
char transliterationChar,
int fromWhere,
int maxToTest)
Searches any char contained in sChars in the current part
but skip over quotations while testing.
|
int |
indexOfAnyCharOutsideQuotion(java.lang.CharSequence sChars,
int fromWhere,
int maxToTest)
Searches any char contained in sChars in the current part
but skip over quotations while testing.
|
int |
indexOfAnyString(java.lang.CharSequence[] listStrings,
int fromWhere,
int maxToTest,
int[] nrofFoundString,
java.lang.String[] foundString)
Returns the position of one of the chars in sChars within the part, started inside the part with fromIndex,
returns -1 if the char is not found in the part started from 'fromIndex'.
|
int |
indexOfNoChar(java.lang.CharSequence sChars)
Returns the position of the first char other than the chars in sChars within the part,
returns -1 if all chars inside the parts are chars given by sChars.
|
int |
indexOfNoChar(java.lang.CharSequence sChars,
int fromWhere)
Returns the position of the first char other than the chars in sChars within the part, started inside the part with fromIndex,
returns -1 if all chars inside the parts started from 'fromIndex' are chars given by sChars.
|
java.util.Iterator<StringPart> |
iterator() |
int |
lastIndexOfAnyChar(java.lang.CharSequence sChars,
int fromWhere,
int maxToTest)
Returns the last position of one of the chars in sChars
within the part of actual part from (fromIndex) to (fromIndex+maxToTest)
or returs -1 if the char is not found in this part.
|
StringPart |
len0end()
Sets the length to the end of the maximal part if the length is 0.
|
StringPart |
lenBacktoNoChar(java.lang.CharSequence sChars)
Posits the end of the part before all of the chars given in the parameter string.
|
StringPart |
lenBacktoNoWhiteSpaces()
Trims all trailing whitespaces within the part.
|
int |
length() |
int |
lengthMaxPart()
Returns the lenght of the maximal part from current position.
|
StringPart |
lento(char cc)
Sets the end position of the part of string to exclusively the char cc.
|
StringPart |
lento(java.lang.CharSequence ss)
Sets the endposition of the part of string to exclusively the given string.
|
StringPart |
lento(java.lang.CharSequence ss,
int mode)
Sets the endposition of the part of string to exclusively the given string.
|
StringPart |
lento(int len)
Deprecated.
use lenToPos, more clarify, especially for JZcmd
|
StringPart |
lentoAnyChar(java.lang.CharSequence sChars)
Sets the length of the current part to any char content in sChars (terminate chars).
|
StringPart |
lentoAnyChar(java.lang.CharSequence sChars,
int maxToTest)
Sets the length of the current part to any char content in sChars (terminate chars).
|
StringPart |
lentoAnyChar(java.lang.CharSequence sChars,
int maxToTest,
int mode)
Sets the length of the current part to any char content in sChars (terminate chars).
|
StringPart |
lentoAnyCharOutsideQuotation(java.lang.CharSequence sChars,
java.lang.String sCharQuot,
char cSubscribe,
int maxToTest) |
StringPart |
lentoAnyCharOutsideQuotion(java.lang.CharSequence sChars,
int maxToTest)
Sets the length of the current part to any char content in sChars (terminate chars),
but skip over quotions while testing.
|
StringPart |
lentoAnyNonEscapedChar(java.lang.CharSequence sCharsEnd,
int maxToTest)
Sets the len to the first position of any given char, but not if the char is escaped.
|
StringPart |
lentoAnyString(java.lang.CharSequence[] strings,
int maxToTest)
Sets the length of the current part to any terminate string given in sString.
|
StringPart |
lentoAnyString(java.lang.CharSequence[] strings,
int maxToTest,
int mode)
Sets the length of the current part to any terminate string given in sString.
|
void |
lentoAnyStringWithIndent(java.lang.CharSequence[] strings,
java.lang.CharSequence sIndentChars,
int maxToTest,
java.lang.StringBuilder buffer)
Sets the length of the current part to any terminate string given in sString.
|
StringPart |
lentoIdentifier()
Sets the endposition of the part of string to the end of the identifier which is beginning on start.
|
StringPart |
lentoIdentifier(java.lang.CharSequence additionalStartChars,
java.lang.CharSequence additionalChars)
Sets the endposition of the part of string to the end of the identifier which is beginning on start.
|
StringPart |
lentoLineEnd()
Sets the length of the current part to the end of the current line.
|
StringPart |
lentoNonEscapedString(java.lang.CharSequence sEnd,
int maxToTest)
Sets the length of the valid part to the first position of the given String,
but not if the String is escaped.
|
StringPart |
lentoNumber(boolean bHex,
int[] dst,
java.lang.String separatorChars)
Sets the end position of the part of string to the end of the number which is beginning on start.
|
StringPart |
lentoPos(int len)
Sets the endposition of the part of string to the given chars after start.
|
StringPart |
lentoQuotionEnd(char sEndQuotion,
int maxToTest)
Sets the length of the current part to the end of the quotion.
|
StringPart |
line()
Sets the current Part from the current position to exactly one line.
|
StringPart |
nextlineMaxpart()
Sets the current and the maximal part from the current end to the next line end character.
|
static java.lang.CharSequence |
replace(java.lang.CharSequence src,
java.lang.CharSequence[] placeholder,
java.lang.CharSequence[] value,
java.lang.StringBuilder dstArg)
Replaces up to 20 placeholder with a given content.
|
StringPartScan |
scan()
This routine provides the this-pointer as StringPartScan in a concatenation of StringPartBase-invocations.
|
StringPart |
seek(char cSeek,
int mode)
Searchs the given character inside the valid part, posits the begin of the part to the begin of the searched char.
|
StringPart |
seek(java.lang.CharSequence sSeek)
Searchs the given String inside the valid part, posits the begin of the part to the begin of the searched string.
|
StringPart |
seek(java.lang.CharSequence sSeek,
int mode)
Common seek operation with several modes in flags.
|
StringPart |
seek(int nr)
Deprecated.
use
seekPos(int) |
StringPart |
seekAfterNewline() |
StringPart |
seekAnyChar(java.lang.CharSequence chars)
Seeks to one of the characters contained in chars, starting from the begin of the current part.
|
StringPart |
seekAnyString(java.lang.CharSequence[] strings,
int[] nrofFoundString)
Searchs the given CharSequence inside the valid part, posits the begin of the part to the begin of the searched string.
|
StringPart |
seekBackToAnyChar(java.lang.CharSequence chars)
Seeks back from the current end to one of the characters contained in chars, starting from the end of the current part.
|
StringPart |
seekBackward(java.lang.CharSequence sSeek)
Seeks back form the current end to the end of the given String starting from the end of the current part.
|
StringPart |
seekBegin()
Displaces the begin of the part to the leftest possible begin.
|
StringPart |
seekCheck(java.lang.CharSequence sSeek)
Seeks to the given CharSequence, result is left side of the string.
|
StringPart |
seekCheckEnd(java.lang.CharSequence sSeek)
Seeks to the given CharSequence, start position is after the string.
|
StringPart |
seekEnd(java.lang.CharSequence sSeek)
Seeks to the given CharSequence, start position is after the string.
|
StringPart |
seekNextLine()
Seeks to the next non-empty line.
|
StringPart |
seekNoChar(java.lang.CharSequence sChars)
Posits the start of the part after all of the chars given in the parameter string.
|
StringPart |
seekNoWhitespace()
Displaces the start of the part to the first char it is no whitespace.
|
StringPart |
seekNoWhitespaceOrComments()
Displaces the begin of the part to the first char it is no whitespace or comment.
|
StringPart |
seekPos(int nr)
Sets the begin of the current part relative to the given number of character.
|
StringPart |
seekPosBack(int nr)
Sets the begin of the current part backward from end.
|
StringPart |
setBeginMaxPart()
Sets the start of the maximal part to the actual start of the valid part.
|
StringPart |
setCurrentMaxPart()
Sets the range of the maximal part to the currentvalid part.
|
protected void |
setCurrentPartTo(StringPart.Part dst)
Sets the actual part of the given Part as destination.
|
void |
setCurrentPosition(long pos)
Sets the current position at a fix position inside the maxPart.
|
boolean |
setIgnoreComment(boolean bSet)
Set the mode of ignoring comments.
|
boolean |
setIgnoreComment(java.lang.String sStart,
java.lang.String sEnd)
Set the character string of inline commentmode of ignoring comments.
|
boolean |
setIgnoreEndlineComment(boolean bSet)
Set the mode of ignoring comments to end of line.
|
boolean |
setIgnoreEndlineComment(java.lang.String sStart)
Set the character string introducing the comments to end of line.
|
boolean |
setIgnoreWhitespaces(boolean bSet)
Set the mode of ignoring whitespaces.
|
void |
setInputfile(java.lang.String file)
Sets the input file for information
getInputfile() |
StringPart |
setLengthMax()
Sets the length to the end of the maximal part.
|
StringPart |
setParttoMax()
Sets the full range of available text.
|
protected StringPart |
skipWhitespaceAndComment()
Deprecated.
|
boolean |
startsWith(java.lang.CharSequence sCmp)
compares the Part of string with the given string.
|
java.lang.CharSequence |
subSequence(int from,
int to)
Returns a volatile CharSequence from the range inside the current part.
|
StringPart.Part |
substring(int pos,
int posendP)
Gets a substring inside the maximal part
pos position of start relative to maxPart
posend exclusive position of end.
|
private static void |
throwIllegalArgumentException(java.lang.String msg,
int value) |
private void |
throwIndexOutOfBoundsException(java.lang.String sMsg)
Central mehtod to invoke excpetion, usefull to set a breakpoint in debug
or to add some standard informations.
|
private static void |
throwSubSeqFaulty(int from,
int to) |
java.lang.String |
toString() |
StringPart |
trim()
Trims all leading and trailing whitespaces within the part.
|
(package private) StringPart |
trimComment()
Trims a java- or C-style line-comment from end of part and all leading and trailing whitespaces.
|
StringPart |
trimWhiteSpaces()
Increments the begin of the current part over maybe found whitespaces
and decrements the end of the current part over maybe found whitespaces.
|
int |
XXXindexOf(java.lang.CharSequence sCmp)
Returns the position of the string within the part.
|
public static final java.lang.String sVersion
contentTillSpaceEndOrQuotation(String, char)
Closeable
is removed. This is faulty, because nothing is open.
The close()
operarion does not close, it cleans only. Some unnecessary warnings were created because the Closeable property.
The close()
operation is now designated as deprecated, use instead
getCharSequenceRange(long, long)
indexOfAnyCharOutsideQuotation(CharSequence, String, char, int, int)
etc.
But this routines should use the capability of StringFunctions.indexOfAnyCharOutsideQuotation(CharSequence, int, int, CharSequence, CharSequence, CharSequence, char, int[])
etc. TODO test and refactoring. The operations are new and not yet tested. But the definitions (heads) are proper.
StringPart.Iter
returns this but with the next selected line.
It is to evaluate a file line per line. It uses the existing routines firstlineMaxpart()
and nextlineMaxpart()
which are proper to use. The lines can be evaluated with operations of StringPart.
This is used well in JZtxtcmd in a for(element: container) loop.
lentoNumber(boolean, int[], String)
mSeekToLeft
etc: all bits are named with leading 'm' for mask.
seekCheck(CharSequence)
: A seek("xyz") shifts the actual position to the end if the seek String is not found.
This is the programmed behavior since 20 years, but it seems to be inconsequent. It may be better to remain the position,
because found() can be checked. This routine is not changed. But the new routine seekCheck(CharSequence)
and a flag mSeekCheck
is introduced instead.
StringPart.Part
is a static class now, with outer reference. It is more clearly. Csharp does not know the concept of non static inner classes
setCurrentMaxPart()
, obvious necessary while test (independent of Csharp!).
StringPart.Part
: possibility of set, because there is a persistent instance possible for setCurrentPartTo(Part)
.
It is because C-usage. This routines are used in the C-version for the Simulink Sfunction DataStruct...Inspc.
StringPart.Part
were related to the current content
.
If the content was shifted in StringPartFromFileLines.readnextContentFromFile(int)
the text referred with a StringPart.Part
were become faulty,
it has referred the same position but the text was shifted in content.
absPos0
contains the character position in the read file in StringPartFromFileLines
, it is incremented there.
The StringPart.Part.absPos0
contains a final value on creation. The difference between both absPos0 is the difference to refer the correct characters.
If the content is shifted out, a IndexOutOfBoundsException is thrown on access of #content, with them the situation is detected.
A StringPart.Part
is only intended for immediate use. Therefore a shifting of content
should be acceptable, but not a greater shifting.
Comment added on Part and some usages like getLastPart()
and StringPartScan.getLastScannedString()
.
getCurrentPart(int)
invoked with -1 returns the whole current part.
seekPosBack(int)
instead new method seekBack, better name, there was a name clash in Java2C-translation with constant definition seekBack
.
checkCharAt(int, String)
should be written with only one return statement for Java2C as define inline.
Java4C.InThCxtRet
firstlineMaxpart()
, nextlineMaxpart()
as new and important mechanism for line to line scanning.
setParttoMax()
returns this.
checkCharAt(int, String)
as replacement or additional to charAt(int)
and comparison, without exception.
lentoPos(int)
instead lento(int)
because it is ambiguous with lento(char)
especially for JZtxtcmdExecuter
interpretation.
lento(CharSequence)
instead String argument. May changes CharSequence instead String without changing the implementation. It has worked with a CharSequence already.
seekPos(int)
instead seek(int)
but it seeks backward from end with negative number. Sets found()
instead exception.
seekBackward(CharSequence)
instead seekBack because name clash in Java2C, C-translated code with seekBack
lentoLineEnd()
, seekBackward(CharSequence)
, seekBackToAnyChar(CharSequence)
more simple for calling in a JZcmd script.
indexOf(CharSequence)
and indexOf(CharSequence)
.
The methods are the same in Java. But in C the handling of reference is different. In Java2C translation a StringJc does not base on CharSequence
because it is a simple reference to char[] and a length only. CharSequence needs ObjectJc and virtual methods.
getLineAndColumn(int[])
instead getLineCt() because it determines the column
in one function instead extra call off getCurrentColumn()
. It is faster.
#setInputfile(CharSequence)
, getInputfile()
line()
setParttoMax()
usefully for new view to content.
Part#Part(int, int)
StringPartScan#getCircumScriptionToAnyChar(CharSequence)
the #getCircumScriptionToAnyChar(CharSequence)
does not work correctly (it has a bug). Use the new one.
content
should be a CharSequence. Then the instance of content may be a StringBuilder.
All content.substring should be replaced by content.subsequence(). The content.indexof-Method should be implemented here.
Advantage: A derived class can use the content
as StringBuilder and it can shift the string by operating with
large contents. Note that a origin position should be used then. This class can contain and regard a origin position,
which is =0 in this class. See StringPartFromFileLines
. That class doesn't regard a less buffer yet, but it should do so.
getPart(int, int)
assignReplaceEnv(StringBuilder)
#scanFloatNumber(boolean)
. It should be possible to scan a float with clearing the buffer. Using in ZbnfParser.
#scanFloatNumber()
. If the String contains only the number digits,
an IndexOutOfBounds-exception was thrown because the end of the String was reached.
seekAnyString(CharSequence,int[])
because it was an erroneous identifier.
lastIndexOfAnyChar(CharSequence,int,int)
lentoAnyChar(CharSequence, int, int)
it should programmed consequently for all indexOf and lento methods.
protected int begin
protected int end
protected int begiMin
abcdefghijklmnopqrstuvwxyz Sample of the whole associated String ===================== The === indicates the maximal part ----------- The --- indicates the valid part before operation ++++++++ The +++ indicates the valid part after operation
protected int endMax
protected int absPos0
StringPartFromFileLines
or adequate reader.private int[] posRewind
begiMin
should be existing always.
Any of this rewind positions should be existing.
But the user must not forgot to remove the rewind positions.
TODOprotected java.lang.CharSequence content
protected boolean bCurrentOk
protected boolean bStartScan
#scanOk()
or after #scanStart
protected int beginLast
protected int endLast
protected boolean bFound
found()
.public static final int mSeekEnd
public static final int seekEnd
public static final int mSeekCheck
found()
returns false).private static final int mSeekBackward_
private static final int mSeekToLeft_
public static final int mSeekToLeft
public static final int seekToLeft
public static final int mSeekBack
public static final int seekBack
public static final int seekNormal
protected int bitMode
protected static final int mSkipOverWhitespace_mode
protected static final int mSkipOverCommentInsideText_mode
protected static final int mSkipOverCommentToEol_mode
protected static final java.lang.String sCheckWhitespaces
protected static final java.lang.String sCheckNewline
java.lang.String sFile
getInputfile()
and setInputFile.java.lang.String sCommentStart
java.lang.String sCommentEnd
java.lang.String sCommentToEol
public StringPart()
public StringPart(java.lang.CharSequence src)
src
- Any CharSequence or Stringpublic StringPart(java.lang.CharSequence src, int start, int end)
abcdefghijklmnopqrstuvwxyz The associated String ---------------- The valid part of src ================ The maximal part and initial the valid part of this +++++ ++++ Possible valid parts of this after some operations ++++ +++ Possible also +++++ ++++ +++ Never valid parts of this after operations because they exceeds the borders of maximal part.
src
- It will be referenced.start
- The beginMin and begin value for the StringPart.end
- The end and endMax value for the StringPart.public void setInputfile(java.lang.String file)
getInputfile()
file
- public final StringPart assign(java.lang.CharSequence src)
content
- The content.this
to concatenate some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart assignReplaceEnv(java.lang.StringBuilder input)
input
- The content initially maybe with place holders for environment variable, they will be replaced.
For java2c-usage the content should not be changed after them, because the String is referred there
originally.this
refers the content.public final StringPart assign(StringPart src)
abcdefghijklmnopqrstuvwxyz The associated String ---------------- The valid part of src ================ The maximal part and initial the valid part of this +++++ ++++ Possible valid parts of this after some operations ++++ +++ Possible also +++++ ++++ +++ Never valid parts of this after operations because they exceeds the borders of maximal part.
src
- The given StringPart.this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart assignFromEnd(StringPart src)
abcdefghijklmnopqrstuvwxyz The associated String ===================== The maximal part of src ------ The valid part of src ============= The maximal and initialy the valid part of this
src
- The source of the operation.this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final boolean setIgnoreComment(boolean bSet)
bSet
- If true than ignore, if false than comments are normal input to parse.public final boolean setIgnoreComment(java.lang.String sStart, java.lang.String sEnd)
sStart
- Start character string of a inline commentsEnd
- End character string of a inline commentpublic final boolean setIgnoreEndlineComment(boolean bSet)
bSet
- If true than ignore, if false than comments are normal input to parse.public final boolean setIgnoreEndlineComment(java.lang.String sStart)
sStart
- String introducing end line commentpublic final boolean setIgnoreWhitespaces(boolean bSet)
bSet
- If true than ignore, if false than comments are normal input to parse.public final StringPart setBeginMaxPart()
abcdefghijklmnopqrstuvwxyz The associated string ================ The maximal part before operation ------ The actual part =========== The maximal part after operation
src
- The given StringPart.this
to concatenate some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart setCurrentMaxPart()
abcdefghijklmnopqrstuvwxyz The associated string ================ The maximal part before operation ------ The actual part ====== The maximal part after operation
src
- The given StringPart.this
to concatenate some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart setParttoMax()
public final StringPart fromEnd()
abcdefghijklmnopqrstuvwxyz The associated String ================= The maximal part ----- The valid part before +++++ The valid part after.
this
to concatenate some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final char charAt(int index)
charAt
in interface java.lang.CharSequence
CharSequence.charAt(int)
public final boolean checkCharAt(int pos, java.lang.String chars)
pos
- chars
- public final java.lang.CharSequence subSequence(int from, int to)
#subString(int, int)
is: It is not persistent.
This method should only used if the CharSequence is processed in the thread immediately
for example by adding to another StringBuilder etc. The returned instance should not be saved
for later usage.
For C usage: The returned instance is located in the Thread Context. It should be freed with releaseUserBuffer_ThreadContextFw(...)<(code>.
The Java2C-translator does that automatically.
subSequence
in interface java.lang.CharSequence
CharSequence.subSequence(int, int)
private static final void throwSubSeqFaulty(int from, int to)
public final int length()
length
in interface java.lang.CharSequence
public final int getLenCurrent()
public final int lengthMaxPart()
@Deprecated public final StringPart lento(int len)
len
- The new length. It must be positive.this
to concat some operations.java.lang.IndexOutOfBoundsException
- if the len is negativ or greater than the position endMax.public final StringPart lentoPos(int len) throws java.lang.IndexOutOfBoundsException
len
- The new length. It must be positive.this
to concatenate some operations.java.lang.IndexOutOfBoundsException
- if the len is negativ or greater than the position endMax.public final StringPart lento(char cc)
abcdefghijklmnopqrstuvwxyz The associated String ================= The maximal part of src ----- The valid part of src before calling the method + after calling lento('w') the end is set to start position, the length() is 0, because the 'w' is outside. ++++++++++ calling set0end() is possible and produce this result.
cc
- char to determine the exclusively end char.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart lento(java.lang.CharSequence ss)
ss
- string to determine the exclusively end char.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart lento(java.lang.CharSequence ss, int mode)
ss
- string to determine the exclusively end char.mode
- Mode of seeking the end, seekEnd or 0 is possible.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart lentoIdentifier()
abcd this is a part uvwxyz The associated String ===================== The border of valid parts of src ------- The valid part of the src before calling the method +++ after calling lentoIdentifier(). The start position is not effected. That's why the identifier-part is only "his".
this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart lentoIdentifier(java.lang.CharSequence additionalStartChars, java.lang.CharSequence additionalChars)
additionalChars
- CharSequence of additinal chars there are also accept
as identifier chars.lentoIdentifier().
public final StringPart lentoNumber(boolean bHex, int[] dst, java.lang.String separatorChars)
" 1'234'456.235"
is parsed correctly as 1234456
with separatorChars=" '". The dot is not parsed.
int[] nr = int[1]; char cc = sp.getCurrentChar()
; if(cc == '-') { bNeg = true; } sp.lentoNumber(false, nr, null); if(bNeg) { nr[0] = -nr[0]; } sp.fromEnd()
bHex
- also parse a..f and A..F, build a hexa numberdst
- either null or int[1] as destination for the parsed number.
Note: The length of the number for fractional part can be detected with separtorChars=null
and getLenCurrent()
separatorChars
- CharSequence of additional chars there are also accept inside a numberpublic final java.lang.String contentTillSpaceEndOrQuotation(java.lang.String sQuotationStartEnd, char escapeChar)
sQuotationStartEnd
- Two chars String for the quotation, usual "\"\"" or for example "<>"escapeChar
- that character which subscribes the end quotation char itself, usual the backslashpublic final StringPart lentoAnyNonEscapedChar(java.lang.CharSequence sCharsEnd, int maxToTest)
scanOk()
before guarantees that the method works.sCharsEnd
- Assembling of chars determine the end of the part.public final StringPart lentoNonEscapedString(java.lang.CharSequence sEnd, int maxToTest)
scanOk()
before guarantees that the method works.sCharsEnd
- Assembling of chars determine the end of the part.public final StringPart line()
public final StringPart firstlineMaxpart()
nextlineMaxpart()
works properly nevertheless.public final StringPart nextlineMaxpart()
found()
to check whether a next line was found.@Deprecated public final StringPart seek(int nr)
seekPos(int)
abcdefghijklmnopqrstuvwxyz The associated String ================= The maximal part ----- The valid part before +++++++ The valid part after calling seek(-2). +++ The valid part after calling seek(2). + The valid part after calling seek(5). The start is set to end, the lenght() is 0. ++++++++++++ The valid part after calling seek(-5).
nr
- of positions to displace. Negative: Displace to left.this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart seekPos(int nr)
found()
to false and does not change the position.
If the range is valid, found()
returns true.
abcdefghijklmnopqrstuvwxyz The associated String ---------- The valid part before +++++++ The valid part after
abcdefghijklmnopqrstuvwxyz The associated String ---------- The valid part before +++++++++++++ The valid part after
nr
- >0 then shift the current part's begin to right maximal to end
nr < 0 then shift the current part's begin to left maximal to begiMin
#seek(int), in opposite this method does not throw an excetion but do nothing and sets {@link #found()} to false.
public final StringPart seekPosBack(int nr)
found()
to false and does not change the position.
If the range is valid, found()
returns true.
abcdefghijklmnopqrstuvwxyz The associated String ---------- The valid part before +++++ The valid part after
nr
- >=0 the number of character from end for the new begin.public final StringPart seekNoWhitespace()
abcdefghijklmnopqrstuvwxyz The associated String ================= The maximal part ---------- The valid part before +++++++ The valid part after, if 'defg' are whitespaces ++++++++++ The valid part after is the same as before, if no whitespace at current position . The valid part after is emtpy, if only whitespaces re found.
this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seekAfterNewline()
@Deprecated protected final StringPart skipWhitespaceAndComment()
seekNoWhitespaceOrComments()
public final StringPart seekNoWhitespaceOrComments()
abcdefghijklmnopqrstuvwxyz The associated String ================= The maximal part ---------- The valid part before +++++++ The valid part after, if 'defg' are whitespaces ++++++++++ The valid part after is the same as before, if no whitespace at current position . The valid part after is emtpy, if only whitespaces re found.
this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final boolean found()
public final StringPart seekBegin()
abcdefghijklmnopqrstuvwxyz The associated String ================= The maximal part ----- The valid part before ++++++++++++ The valid part after calling seekBegin().
this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart seek(java.lang.CharSequence sSeek, int mode)
that is a liststring and his part The associated String ============================= The maximal part ---------------------- The valid part before +++++++++++++++++ The valid part after seek("is",StringPartBase.seekNormal). +++++++++++++++ The valid part after seek("is",StringPartBase.seekEnd). ++ The valid part after seek("is",StringPartBase.back). . The valid part after seek("is",StringPartBase.back + StringPartBase.seekEnd). +++++++++++++++++++++++ The valid part after seek("is",StringPartBase.seekToLeft). +++++++++++++++++++++ The valid part after seek("is",StringPartBase.seekToLeft + StringPartBase.seekEnd). ++++++++++++++++++++++++++ The valid part after seek("xx",StringPartBase.seekToLeft). . The valid part after seek("xx",StringPartBase.seekNormal) or seek("xx",StringPartBase.back).
sSeek
- The string to search for.mode
- Mode of seeking, use ones of mSeekCheck
, seekBack
, seekToLeft
, seekNormal
, added with seekEnd
.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seekBackward(java.lang.CharSequence sSeek)
found()
to false if the String is not contained in the current part.
Then the current part is not changed.sSeek
- The string to seek backward.public final StringPart seekAnyChar(java.lang.CharSequence chars)
found()
to false if a character of chars is not contained in the current part.
Then the current part is not changed.sSeek
- The string to seek backward.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seekBackToAnyChar(java.lang.CharSequence chars)
found()
to false if a character of chars is not contained in the current part.
Then the current part is not changed.sSeek
- The string to seek backward.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seek(java.lang.CharSequence sSeek)
that is a liststring and his part The associated String ============================= The maximal part ---------------------- The valid part before +++++++++++++++++ The valid part after seek("is",StringPartBase.seekNormal). +++++++++++++++ The valid part after seek("is",StringPartBase.seekEnd). ++ The valid part after seek("is",StringPartBase.back). . The valid part after seek("is",StringPartBase.back + StringPartBase.seekEnd). +++++++++++++++++++++++ The valid part after seek("is",StringPartBase.seekToLeft). +++++++++++++++++++++ The valid part after seek("is",StringPartBase.seekToLeft + StringPartBase.seekEnd). ++++++++++++++++++++++++++ The valid part after seek("xx",StringPartBase.seekToLeft). . The valid part after seek("xx",StringPartBase.seekNormal) or seek("xx",StringPartBase.back).This operation calls
seek(CharSequence, int)
with flag seekNormal
.
Use seekCheck(CharSequence)
or seek(CharSequence, int)
with mSeekCheck
.sSeek
- this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seekCheck(java.lang.CharSequence sSeek)
seek(CharSequence)
which sets the current position to the end)sSeek
- public final StringPart seekEnd(java.lang.CharSequence sSeek)
found()
to check whether it is found.sSeek
- public final StringPart seekCheckEnd(java.lang.CharSequence sSeek)
found()
to check whether it is found.sSeek
- public final StringPart seekAnyString(java.lang.CharSequence[] strings, int[] nrofFoundString)
seek(CharSequence sSeek, int mode)
strings
- List of CharSequence contains the strings to search.nrofFoundString
- If given, [0] is set with the number of the found CharSequence in listStrings,
count from 0. This array reference may be null, then unused.public final StringPart seek(char cSeek, int mode)
cSeek
- The character to search for.mode
- Mode of seeking, use ones of back, seekToLeft, seekNormal, added with seekEnd.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seekNoChar(java.lang.CharSequence sChars)
sample: seekNoChar("123") result is: 12312312312abcd12312efghij123123 before: ========================== after: ===================
sChars
- CharSequence with the chars to overread.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart seekNextLine()
public final int indexOfAnyChar(java.lang.CharSequence sChars, int fromWhere, int maxToTest)
abc end:zxyThe calling is
indexOfAnyChar("xyz", 0, 20);The result is 8 because the character 'z' is found first as the end char.
fromWhere
- Offset after begin to begin search. It may be 0 often.sChars
- Some chars to search in sq
If sChars contains a EOT character (code 03, #cEndOfText
) then the search stops at this character
or it is continued to the end of the range in sq. Then the length of the text range is returned
if another character in sChars is not found.
It means: The end of the text range is adequate to an EOT-character. Note that EOT is not unicode,
but it is an ASCII control character.maxToTest
- number of character to test from fromWhere.
If maxToTest is greater then the length of the current part, only the whole current part is tested.
Especially Integer.MAXVALUE and beu used.public final int indexOfAnyChar(java.lang.CharSequence sChars, int fromWhere, int maxToTest, char transcriptChar, char quotationStartChar, char quotationEndChar)
scanTranscriptionToAnyChar(dst, ">?", '\\', '\"', '\"')does not end at a char > after an \ and does not end inside the quotation. If the following string is given:
a text -\>arrow, "quotation>" till > ...followingthen the last '>' is detected as the end character. The first one is a transcription, the second one is inside a quotation.
StringFunctions#convertTranscription(CharSequence, char)
:
Every char after the transcriptChar is accepted. But the known transcription chars
\n, \r, \t, \f, \b are converted to their control-char- equivalence.
The \s and \e mean begin and end of text, coded with ASCII-STX and ETX = 0x2 and 0x3.
The actual part is tested for this, after this operation the actual part begins
after the gotten chars!sChars
- contains some chars to find. If it contains the char with code #cEndOfText
then the number of chars till the end of this text are returned if no char was found.
If a char with code of #cEndOfText
is found in this string, it is the end of this search process too.fromIndex
- begin of search within the part.maxToTest
- maximal numbers of chars to test. It may be Integer.MAX_VALUE.transcriptChar
- any char which is the transcription designation char, especially '\\'.
Set to 0 if no transcription should be regarded.quotationStartChar
- any char which is the begin char of a quotation. Set to 0 if no quotation should be regarded.quotationEndChar
- the adequate end charpublic final int lastIndexOfAnyChar(java.lang.CharSequence sChars, int fromWhere, int maxToTest)
sChars
- contents some chars to find. The char with codefromIndex
- begin of search within the part.maxToTest
- maximal numbers of chars to test. It may be Integer.MAX_VALUE.public final int indexOfAnyString(java.lang.CharSequence[] listStrings, int fromWhere, int maxToTest, int[] nrofFoundString, java.lang.String[] foundString)
listStrings
- contains some Strings to find.fromWhere
- begin of search within the part.maxToTest
- maximal numbers of chars to test. It may be Integer.MAX_VALUE.nrofFoundString
- If given, [0] is set with the number of the found CharSequence in listStrings,
count from 0. This array reference may be null, then unused.foundString
- If given, [0] is set with the found CharSequence. This array reference may be null.public final int indexOfAnyCharOutsideQuotion(java.lang.CharSequence sChars, int fromWhere, int maxToTest)
abc "yxz" end:zxyThe calling is
lentoAnyCharOutsideQuotion("xyz", 20);The result is 14 because the character 'z' is found first as the end char, but outside the quoted string "xyz".
sChars
- One of this chars is a endchar. It may be null: means, every chars is a endchar.fromWhere
- Offset after begin to begin search. It may be 0 often.maxToTest
- number of character to test from fromWhere.
If maxToTest is greater then the length of the current part, only the whole current part is tested.
Especially Integer.MAXVALUE and beu used.public final int indexOfAnyCharOutsideQuotation(java.lang.CharSequence sChars, java.lang.String sPossibleQuotChars, char transliterationChar, int fromWhere, int maxToTest)
abc "yxz" end:zxyThe calling is
lentoAnyCharOutsideQuotion("xyz", 20);The result is 14 because the character 'z' is found first as the end char, but outside the quoted string "xyz".
sChars
- One of this chars is a endchar. It may be null: means, every chars is a endchar.sPossibleQuotChars
- this defines pares of quotation character. Typically "\"\"" or also "\"\"''" or "\"\"''<>".
The char on even position is the start char of a quotation and the following is the end char of that quotation,
which is the same on the typical "quotation" But not on <quotation>.transliterationChar
- this is a only one character which defines that the following character is not to test.
Typical for \" for replacement of a simple quotation mark.fromWhere
- Offset after begin to begin search. It may be 0 often.maxToTest
- number of character to test from fromWhere.
If maxToTest is greater then the length of the current part, only the whole current part is tested.
Especially Integer.MAXVALUE and beu used.public final int indexEndOfQuotion(char cEndQuotion, int fromWhere, int maxToTest)
cEndQuotion
- The character which is the end of the quoted text, the end-quote-character.fromWhere
- Offset after begin to begin search.
It may be 0 if the quotion starts at begin, it is the position of the left
quotion mark.maxToTest
- Limit for searching, offset from begin. It may be Integer.MAX_INTpublic final int indexEndOfQuotation(char cEndQuotion, char transcriptChar, int fromWhere, int maxToTest)
cEndQuotion
- The character which is the end of the quoted text, the end-quote-character.transcriptChar
- The character which prevents end-of-quote detection if the quote-end-character follows.fromWhere
- Offset after begin to begin search.
It may be 0 if the quotion starts at begin, it is the position of the left
quotion mark.maxToTest
- Limit for searching, offset from begin. It may be Integer.MAX_INTpublic final int indexEndOfQuotation(char cEndQuotion, java.lang.String sInnerQuotionChars, char transcriptChar, int fromWhere, int maxToTest)
cEndQuotion
- The character which is the end of the quoted text, the end-quote-character.transcriptChar
- The character which prevents end-of-quote detection if the quote-end-character follows.fromWhere
- Offset after begin to begin search.
It may be 0 if the quotion starts at begin, it is the position of the left
quotion mark.maxToTest
- Limit for searching, offset from begin. It may be Integer.MAX_INTpublic final int indexOfAnyChar(java.lang.CharSequence sChars)
sChars
- contents some chars to find.public final int indexOfNoChar(java.lang.CharSequence sChars, int fromWhere)
sChars
- contents the chars to overread.fromIndex
- begin of search within the part.public final int indexOfNoChar(java.lang.CharSequence sChars)
sChars
- contents the chars to overread.public final StringPart lentoAnyChar(java.lang.CharSequence sChars, int maxToTest)
sChars
- Some chars searched as terminate char for the actual part.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.mode
- Possible values are StringPartBase.seekBack or StringPartBase.seekNormal = 0.public final StringPart lentoAnyChar(java.lang.CharSequence sChars, int maxToTest, int mode)
sChars
- Some chars searched as terminate char for the actual part.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.mode
- Possible values are mSeekBack
or #,seekNormal
= 0.public final StringPart lentoAnyString(java.lang.CharSequence[] strings, int maxToTest)
sString
- The first char is the separator.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.public final StringPart lentoAnyString(java.lang.CharSequence[] strings, int maxToTest, int mode)
sString
- The first char is the separator.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.mode
- possible values are StrinPart.seekNormal or StringPartBase.seekEnd.
public final void lentoAnyStringWithIndent(java.lang.CharSequence[] strings, java.lang.CharSequence sIndentChars, int maxToTest, java.lang.StringBuilder buffer)
. /** This is a comment . * continued in a next line with indent. . but it is able that the user doesn't respect the indentation . also with to large indentation, . * *The second asterix should not be skipped.From this text passage the result is:
.This is a comment .continued in a next line with indent. .but it is able that the user doesn't respect the indentation .also with to large indentation, .*The second asterix should not be skipped.Using the result it is possible to detect paragraph formatting in wikipedia style (see vishia.xml.ConvertWikistyleTextToXml.java)
strings
- List of type CharSequence, containing the possible end strings.iIndentChars
- possible chars inside a skipped indentation. If the last char is space (" "),
also spaces after the indentation of the first line are skipped.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.buffer
- The buffer where the found String is stored. The stored String has no indentations.public final StringPart lentoAnyCharOutsideQuotion(java.lang.CharSequence sChars, int maxToTest)
abc "yxz" ende:zxyThe calling is
lentoAnyCharOutsideQuotion("xyz", 20);The result current part is
abc "yxz" ende:because the char 'z' is found first as the end char, but outside the quoted string "xyz".
sChars
- Some chars searched as terminate char for the actual part.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.public final StringPart lentoAnyCharOutsideQuotation(java.lang.CharSequence sChars, java.lang.String sCharQuot, char cSubscribe, int maxToTest)
public final StringPart lentoQuotionEnd(char sEndQuotion, int maxToTest)
sEndQuotion
- The char determine the end of quotion, it may be at example " or ' or >.maxToTest
- Maximum of chars to test. If the endchar isn't find inside this number of chars,
the actual length is set to 0.public final StringPart lentoLineEnd()
this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart trimWhiteSpaces()
found()
returns false if the current part has no content.
The getCurrentPart()
returns an empty String if the current part has no content
The method invokes seekNoWhitespace()
and lenBacktoNoChar(CharSequence)
with sCheckWhitespaces.public final StringPart lentoAnyChar(java.lang.CharSequence sChars)
sChars
- Some chars searched as terminate char for the actual part.public final StringPart len0end()
this
to concatenate some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final StringPart setLengthMax()
public final StringPart lenBacktoNoChar(java.lang.CharSequence sChars)
sample: lentoBacktoNoChar("123") result is: 1231231231abcd12312efghij123123123klmnopq before: ========================== after: =====================
sChars
- CharSequence with the chars to overread.this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart lenBacktoNoWhiteSpaces()
this
to concatenate some operations, usage example part.set(src).seek(sKey).lento(';').len0end();
Hint: use found()
to detect whether the end string is found.
if the end String is not found, the current part has length ==0public final StringPart trim()
this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
final StringPart trimComment()
this
to concat some operations, like part.set(src).seek(sKey).lento(';').len0end();
public final int compareTo(java.lang.CharSequence str2)
compareTo
in interface java.lang.Comparable<java.lang.CharSequence>
Comparable.compareTo(java.lang.Object)
public final int indexOf(char ch)
ch
- character to find.The
- method throws no IndexOutOfBoundaryException.
It is the same behavior like String.indexOf(char, int fromEnd).public final int indexOf(char ch, int fromIndex)
ch
- character to find.fromIndex
- start of search within the part.The
- method throws no IndexOutOfBoundaryException. If the value of fromIndex
is negative or greater than the end position, -1 is returned (means: not found).
It is the same behavior like String.indexOf(char, int fromEnd).public final int indexOf(java.lang.CharSequence sCmp)
abcdefgabcdefghijk part: =============
sCmp
- string to findpublic final int XXXindexOf(java.lang.CharSequence sCmp)
abcdefgabcdefghijk part: =============
sCmp
- string to findpublic final int indexOf(java.lang.CharSequence sCmp, int fromIndex, int maxToTest)
abcdefgabcdefghijk part: =============
sCmp
- string to findpublic final boolean equals(java.lang.CharSequence sCmp)
public final boolean startsWith(java.lang.CharSequence sCmp)
sCmp
- The text to compare.public StringPartScan scan()
java.lang.ClassCastException
- if the instance is not a StringPartScan. That is an internal software error.public final long getCurrentPosition()
public final void setCurrentPosition(long pos)
pos
- the absolute positionpublic final java.lang.CharSequence getCharSequenceRange(long from, long to)
StringPartFromFileLines
is used.from
- absolute position from beginning of reading the file content.to
- absolute position of exclusively end, if -1 then the current position.StringPart.Part
.public final StringPart.Part substring(int pos, int posendP)
public final java.lang.CharSequence getCurrent(int nChars)
nChars
- number of chars to return. If the number of chars available in string
is less than the required number, only the available string is returned.public final java.lang.CharSequence getCurrent()
public final char getCurrentChar()
public int getLineAndColumn(int[] column)
column
- if given, it should be an int[1]. Then the column is written into. The leftest position is 1public final int getCurrentColumn()
public final java.lang.String getInputfile()
public final StringPart.Part getCurrentPart()
protected final void setCurrentPartTo(StringPart.Part dst)
content
.
The content can be gotten as String from dst with StringPart.Part.toString()
Note: renaming 1019-05-26 from setCurrentPart(...).public final java.lang.CharSequence getLastPart()
public final java.lang.CharSequence getCurrentPart(int maxLength)
maxLength
- if <0 (especially -1) then use the given length without limitation.
elsewhere it is a limitation of characters, maybe necessary if a buffer or space to display is limited.
0 : take 0 characters.public final StringPart.Part getPart(int fromPos, int nrofChars)
getCurrentPosition()
and #getLen()
and apply it here!
Note that it is possible that an older part of string is not available furthermore if a less buffer is used
and the string in the buffer was shifted out. Then this method may be overridden and returns an error hint.fromPos
- The start position for the returned content. It must be a valid position.nrofChars
- The number of characters. It must be >= 0. If the content is shorter,
that shorter part is returned without error.
For example getPart(myPos, Integer.MAXINT) returns all the content till its end.protected final char absCharAt(int index)
protected final java.lang.String absSubString(int from, int to)
from
- The absolute position.to
- The absolute end.public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public final java.lang.String debugString()
"CONTENT_FROM_BEGIN<<<34,45>>>CONTENT_PART<<<"whereat
private final void throwIndexOutOfBoundsException(java.lang.String sMsg) throws java.lang.IndexOutOfBoundsException
sMsg
- java.lang.IndexOutOfBoundsException
private static final void throwIllegalArgumentException(java.lang.String msg, int value)
public void clean()
@Deprecated public void close()
Closeable
is not used here.public static java.lang.CharSequence replace(java.lang.CharSequence src, java.lang.CharSequence[] placeholder, java.lang.CharSequence[] value, java.lang.StringBuilder dstArg)
src
- The source String, it may be a line.placeholder
- An array of strings, any string of them may be found in the src.value
- An array of strings appropriate to the placeholder. Any found placeholder
will be substitute with that string.dst
- A given StringBuilder-instance maybe with a start content. If null, then a StringBuilder will be created herepublic java.util.Iterator<StringPart> iterator()
iterator
in interface java.lang.Iterable<StringPart>