|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.qedeq.base.io.TextInput
public class TextInput
This class provides convenient methods for parsing input.
Field Summary | |
---|---|
static char |
CR
Char marking end of input line. |
static int |
EOF
Char marking end of data. |
Constructor Summary | |
---|---|
TextInput(java.io.File file,
java.lang.String encoding)
Constructor using FILE source. |
|
TextInput(java.io.Reader reader)
Constructor using Reader source. |
|
TextInput(java.lang.String source)
Constructor using String source. |
|
TextInput(java.lang.StringBuffer source)
Constructor using StringBuffer source. |
Method Summary | |
---|---|
void |
addColumn(int number)
Add the following columns. |
void |
addPosition(SourcePosition delta)
Adds a given position to the current one and changes the row and column number accordingly. |
void |
addRow(int number)
Add the following rows and reset column (if number == 0 ). |
java.lang.String |
asString()
Get complete input source. |
void |
forward(int number)
Skips a given amount of characters and increments the reading position accordingly. |
boolean |
forward(java.lang.String search)
Skips until a given keyword is reached. |
int |
getChar()
Reads a single character and does not change the reading position. |
int |
getChar(int skip)
Reads a single character and does not change the reading position. |
int |
getColumn()
Returns the current column number. |
java.lang.String |
getLine()
Returns the current line. |
int |
getMaximumPosition()
Returns the highest position number possible. |
int |
getPosition()
Returns the current position. |
SourcePosition |
getPosition(int find)
Get given byte position as SourcePosition . |
int |
getPosition(SourcePosition position)
Get given byte position as SourcePosition . |
int |
getRow()
Returns the current line number. |
java.lang.String |
getSourceArea(SourceArea area)
Get source area as string. |
SourcePosition |
getSourcePosition()
Returns the current position. |
java.lang.String |
getSubstring(int from,
int to)
Reads a substring. |
boolean |
isEmpty()
Is there no data left for reading? |
boolean |
isEmpty(int skip)
Is there no data left for reading after skipping? |
int |
read()
Reads a single character and increments the reading position by one. |
java.lang.String |
readCounter()
Reads the next (big) integer, leading whitespace is skipped. |
int |
readInverse()
Decrements the reading position by one and reads a single character. |
java.lang.String |
readLetterDigitString()
Reads the next string containing only letters or digits, leading whitespace is skipped. |
java.lang.String |
readNextAttributeValue()
Reads attribute value out of XML stream. |
java.lang.String |
readNextXmlName()
Reads tag or attribute name out of XML stream. |
int |
readNonNegativeInt()
Reads the next integer, leading whitespace is skipped. |
java.lang.String |
readQuoted()
Reads the next quoted string, leading whitespace is skipped. |
java.lang.String |
readString(int number)
Reads a given amount of characters and increments the reading position accordingly. |
java.lang.String |
readStringTilWhitespace()
Reads the next string until whitespace occurs, leading whitespace is skipped. |
void |
replace(int from,
int to,
java.lang.String replacement)
Replace given interval with given string. |
void |
setColumn(int column)
Sets the current column position (and indirectly the position). |
void |
setPosition(int position)
Sets the current position (and indirectly the row and column number). |
void |
setPosition(SourcePosition position)
Sets the current position (and indirectly the row and column number). |
void |
setRow(int row)
Sets the current line number (and indirectly the position). |
java.lang.String |
showLinePosition()
Show reading position. |
void |
skipBackToBeginOfXmlTag()
Skip current position back to beginning of an XML tag. |
void |
skipForwardToEndOfXmlTag()
Skip current position forward to end of an XML tag. |
void |
skipToEndOfLine()
Skip forward to end of line. |
void |
skipWhiteSpace()
Skips white space, beginning from reading position. |
void |
skipWhiteSpaceInverse()
Skips white space, beginning from reading position. |
Methods inherited from class java.io.InputStream |
---|
available, close, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EOF
public static final char CR
Constructor Detail |
---|
public TextInput(java.io.Reader reader) throws java.io.IOException
Reader
source.
reader
- Data source. This reader will be closed (even if reading fails).
java.io.IOException
- Reading failed.
java.lang.NullPointerException
- Argument was a null pointer.public TextInput(java.lang.StringBuffer source)
StringBuffer
source.
source
- data source
java.lang.NullPointerException
- Argument was a null pointer.public TextInput(java.lang.String source)
String
source.
source
- data source
java.lang.NullPointerException
- Argument was a null pointer.public TextInput(java.io.File file, java.lang.String encoding) throws java.io.IOException
FILE
source.
file
- Data source.encoding
- Take this encoding for file.
java.io.IOException
- File reading failed.
java.lang.NullPointerException
- One argument was a null pointer.Method Detail |
---|
public final int read()
-1
is returned.
Otherwise a cast to char
gives the character read.
read
in class java.io.InputStream
-1
is returned.public final int readInverse()
-1
is returned.
Otherwise a cast to char
gives the character read.
-1
is returned.public final java.lang.String readString(int number)
number
- amount of characters to read
public final void forward(int number)
number
- Amount of characters to read. Must be positive - if not nothing happens.public final boolean forward(java.lang.String search)
search
- Look for this keyword.
public final int getChar()
-1
is returned.
Otherwise a cast to char
gives the character read.
-1
is returnedpublic final int getChar(int skip)
-1
is returned. Otherwise a cast to char
gives the character read.
skip
- Offset from current reading position. Maybe negative.
-1
is returned.public final java.lang.String getSubstring(int from, int to)
from
- Absolute reading position.to
- Read to this position.
public final java.lang.String asString()
public final void replace(int from, int to, java.lang.String replacement)
from
- Absolute reading position.to
- Read to this position.replacement
- Replacement for interval.public final void skipWhiteSpace()
public final void skipWhiteSpaceInverse()
public final void skipBackToBeginOfXmlTag()
<tagName
.
java.lang.IllegalArgumentException
- No begin of XML tag found.public final void skipToEndOfLine()
public final void skipForwardToEndOfXmlTag()
>
. Quoted data is skipped.
java.lang.IllegalArgumentException
- No end of XML tag found.public final java.lang.String readNextXmlName()
java.lang.IllegalArgumentException
- Next non white space character is "="
or ">".public final java.lang.String readNextAttributeValue()
java.lang.IllegalArgumentException
- Following had not one of the following forms:
= "value"
= value
public final boolean isEmpty()
public final boolean isEmpty(int skip)
skip
- Add this number to current position.
public final java.lang.String readLetterDigitString()
java.lang.IllegalArgumentException
- if no such characters could
be foundpublic final java.lang.String readStringTilWhitespace()
public final int readNonNegativeInt()
java.lang.IllegalArgumentException
- if no digits where found or
the number was to big for an int
public final java.lang.String readCounter()
Changes reading position.
java.lang.IllegalArgumentException
- if no digits where found.public final java.lang.String readQuoted()
java.lang.IllegalArgumentException
- No correctly quoted string was found.public final int getRow()
public final int getColumn()
public final java.lang.String getLine()
public final int getPosition()
public final SourcePosition getSourcePosition()
public final int getMaximumPosition()
public final void setPosition(int position)
position
- Set current position to this value.public final void setPosition(SourcePosition position)
position
- Set current position to this value.public final void addPosition(SourcePosition delta)
delta
- Add this position to current one.public final void setRow(int row)
row
- Move to this line number.public final SourcePosition getPosition(int find)
SourcePosition
.
find
- Get row and column information for this byte position.
public final int getPosition(SourcePosition position)
SourcePosition
.
position
- Get row and column information for this byte position.
public final java.lang.String getSourceArea(SourceArea area)
area
- Get this area as string.
public final void addRow(int number)
number == 0
).
number
- Add this number of rows.public final void setColumn(int column)
column
is out of range the minimum value (1) or the maximum possible column
value is taken.
column
- Move to this column. First column has the number one.public final void addColumn(int number)
number
- Add this number of columns.public final java.lang.String showLinePosition()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |