StringReaderEncodedStringNavigatorpublic class StringNavigator extends Object implements StringReader
| Modifier and Type | Field | Description |
|---|---|---|
static int |
DEFAULT_DATA_BLOCK_DELIM_SIZE |
|
static int |
DEFAULT_DATA_BLOCK_SIZE |
/ Reads the text and fetchs the characters according to the given
charachters no also the pointer is advanced accordingly @param charNo
Number of characters to be read @return The resulted string and null if
any error occured
public String getText(int charNo){
if (charNo>0){ filePointer += charNo; String part = null; // Detecting
the end of the available text if ((pointer+charNo) >=
getText().length()){
residualText = getText().substring(pointer,getText().length()); // The
case of variable amount of text to be read if (!FixedBlockRead){ int
newBlockPart = charNo - residualText.length(); pointer = newBlockPart; if
((doReadData())&&(pointer==0)){ filePointer -= newBlockPart; return
residualText + getText(newBlockPart); } }else{ EndOfText = true; } return
residualText; } if (pointer<0) { int rsidualLength =
residualText.length(); String leftPart =
residualText.substring(rsidualLength+pointer); charNo += pointer;
pointer=0; part = leftPart + getText().substring(pointer,pointer+charNo) ;
}else{ part = getText().substring(pointer,pointer+charNo); }
if ((pointer+charNo)== getText().length()) { doReadData(); }else{
updatePointer(charNo); } return part; } return ""; }
|
| Constructor | Description |
|---|---|
StringNavigator(File textFile) |
Constructs the class with the given file
|
StringNavigator(File textFile,
int dataBlockSize) |
Constructs the class with the given file and will read the information
according to the provided data block size
|
StringNavigator(InputStream dataStream,
int dataBlockSize) |
Constructs the class with the given file and will read the information
according to the provided data block size
|
StringNavigator(String Text) |
Constructs the class with the given text
|
| Modifier and Type | Method | Description |
|---|---|---|
int |
availableCharacters() |
Returns the number of available characters in the buffer
|
void |
close() |
|
boolean |
EndOfValue() |
|
int |
getDataBlockDelimiterSize() |
|
int |
getDataBlockSize() |
|
String |
getLastReadText() |
|
long |
getPosition() |
|
String |
getText() |
Returns the text
|
String |
getText(int charNo) |
Reads the text and fetchs the characters according to the given
charachters no also the pointer is advanced accordingly
|
String |
getText(int charNo,
int code) |
|
boolean |
isWithDelimiter() |
|
void |
jump(int stepNo) |
The pointer is advanced with the given position number
|
void |
reset() |
|
void |
setDataBlockDelimiterSize(int newDelimiterSize) |
|
void |
setDataBlockSize(int newBlockSize) |
|
void |
setText(String newText) |
Sets the text
|
void |
setWithDelimiter(boolean WithDelimiter) |
public static final int DEFAULT_DATA_BLOCK_SIZE
public static final int DEFAULT_DATA_BLOCK_DELIM_SIZE
public StringNavigator(String Text)
Text - the text for navigationpublic StringNavigator(File textFile) throws IOException
textFile - the file that contains the text for navigationIOException - if the file does not exist or any error occured while
reading itpublic StringNavigator(File textFile, int dataBlockSize) throws IOException
textFile - the file that contains the text for navigationIOException - if the file does not exist or any error occured while
reading itpublic StringNavigator(InputStream dataStream, int dataBlockSize) throws IOException
textFile - the file that contains the text for navigationIOException - if the file does not exist or any error occured while
reading itpublic String getText(int charNo, int code)
getText in interface StringReaderpublic String getText(int charNo)
getText in interface StringReadercharNo - Number of characters to be readpublic void jump(int stepNo)
jump in interface StringReaderstepsNo - Number of positions to jumb it can be negative to make the
pointer move in the reverese directionpublic boolean EndOfValue()
public int availableCharacters()
public String getText()
getText in interface StringReaderpublic void setText(String newText)
newText - the new text to be processedpublic void reset()
public long getPosition()
public void setDataBlockSize(int newBlockSize)
public void setDataBlockDelimiterSize(int newDelimiterSize)
public void setWithDelimiter(boolean WithDelimiter)
public int getDataBlockSize()
public int getDataBlockDelimiterSize()
public boolean isWithDelimiter()
public String getLastReadText()
Copyright © 2019 SMYLD. All rights reserved.