public class MemString extends Object implements Cloneable
MemString.CharMem
.
It supports sequential access and maintains line and column counters
as follows:MemScanner
.
CHAR_EOTEXT
is currently set to 0x0000
.
It is reserved for "end of data" indication. It must not be contained
in any method's arguments!
Most methods on this level do NOT test for "end of data", but rely on lower-level
access violation in case of overrun.
X
"
LineNumberReader
is
inserted which does normalization to this character.
Udom2Sax
,
Def2Doc3
,
ModuleRegistry
,
Tasks
,
Text2Udom
,
MemScanner
,
Batch
,
Rt
,
Calendaric
,
Batch
Modifier and Type | Class and Description |
---|---|
static class |
MemString.CharMem |
class |
MemString.ReadBehindBufferEndException |
class |
MemString.Reader
used for
aMemString.new Reader() to use the memString
as sequential character data source, e.g. |
Modifier and Type | Field and Description |
---|---|
static char |
CHAR_EOTEXT |
static char |
CHAR_NEWLINE |
protected int |
colnum |
protected MemString.CharMem |
data |
protected int |
len |
protected int |
linenum |
protected int |
start |
Constructor and Description |
---|
MemString(MemString.CharMem mem)
Creates a MemString pointing to the first character in the whole
character data, as given by the charmMem.
|
MemString(MemString ms)
Creates a copy of the MemString argument.
|
MemString(String id,
String data)
Creates a new
MemString.CharMem store and creates a new MemString pointing to the
first character in this data. |
Modifier and Type | Method and Description |
---|---|
void |
adjustLineNumberX()
destructive variant: after advancement guaranteed not to CROSS a linefeed,
(by any method which adds directly to pos and colnum)
the fact of pointing TO a linefeed will be reflected in colnum/linenum.
|
MemString |
advance()
returns a memString which points one(1) character position behind the
current porision of
this and adjusts line and column number
accordingly. |
MemString |
advanceBy(int count) |
void |
advanceByX_sameLine(int i)
destructive variant: advance position and column number by the argument.
|
void |
advanceX()
destructive variant: modifies
this to point
one(1) character position behind its current position,
and adjusts line and column number
FIXME test for CHAR_EOTEXT !?! |
int |
appendAll(StringBuilder sb) |
String |
asString() |
void |
backwardsX()
destructive variant: modifies
this to point
one(1) character position before its current position
and adjusts line and column number
Currently only needed by Text2Udom, when parsing the FILE HEADER. |
void |
backwardsX(int num)
destructive variant: modifies
this to point
given characters position before its current position
and adjusts line and column number |
protected void |
calccolnum()
Count distance to newline character backwards in data.
|
void |
clearLineX()
Writes a blank character to all positions in the data mem from the current
position up to the end of the line.
Uses advanceX() , so see there for exceptions. |
MemString |
copy()
returns a clone.
|
boolean |
equals(String n)
Currently returns the same result as
isPrefixedBy() , i.e. |
int |
get_colnum() |
MemString.CharMem |
get_data() |
int |
get_len() |
int |
get_linenum() |
int |
get_start() |
char |
getChar() |
char |
getChar(int i) |
Location<String> |
getFollowLocation()
Returns a location of the position directly after this MemString.
|
Location<String> |
getLocation()
Returns a location with the field value
MemString.CharMem.originalAddress and
the line and column number. |
MemString |
getNextLine()
Returns a new MemString object pointing to the linefeed character preceding
the character data of the follower line.
Uses advanceX() , so see there for exceptions. |
void |
getNextLineX()
|
String |
getPositionIndication()
Returns a string containing blanks and one single "up-arrow"
to indicate the current column optically.
|
void |
initFrom(MemString ms)
Re-sets all values of "this" to the values of the argument.
|
boolean |
isPrefixedBy(String n)
Returns what it says.
|
static void |
main(String[] args) |
void |
putChar(char c)
Writes the character argument to the current position.
|
String |
toString()
Returns a string containing a representation of the underlying
MemString.CharMem , the position, length, line and column number, and the first
10 characters. |
MemString |
upTo(MemString n)
Returns a new MemString describing the range starting with
this
and ending before the argument. |
void |
upToX(MemString n)
destructive variant:
alters
this to a region ending before the argument. |
public static final char CHAR_EOTEXT
public static final char CHAR_NEWLINE
protected MemString.CharMem data
protected int start
protected int len
protected int linenum
protected int colnum
public MemString(MemString.CharMem mem)
public MemString(String id, String data)
MemString.CharMem
store and creates a new MemString pointing to the
first character in this data.public MemString(MemString ms)
public String asString()
public int appendAll(StringBuilder sb)
public char getChar()
public char getChar(int i)
public void initFrom(MemString ms)
copy()
public String toString()
MemString.CharMem
, the position, length, line and column number, and the first
10 characters.public Location<String> getLocation()
MemString.CharMem.originalAddress
and
the line and column number.
public Location<String> getFollowLocation()
getLocation()
for caveats.public MemString copy()
public MemString upTo(MemString n)
this
and ending before the argument.IllegalArgumentException
- when the underlying CharMem is not identical,
or the argument is "left of" this
.public void upToX(MemString n)
this
to a region ending before the argument.IllegalArgumentException
- when the underlying CharMem is not identical,
or the argument is "left of" this
.public boolean equals(String n)
isPrefixedBy()
, i.e.
does not check maximal length contraints.public boolean isPrefixedBy(String n)
public MemString getNextLine()
advanceX()
, so see there for exceptions.public void getNextLineX()
public void clearLineX()
advanceX()
, so see there for exceptions.public void putChar(char c)
public MemString advance()
this
and adjusts line and column number
accordingly.
advanceX()
, so see there for exceptions.public MemString advanceBy(int count)
public void advanceByX_sameLine(int i)
public void adjustLineNumberX()
public void advanceX()
this
to point
one(1) character position behind its current position,
and adjusts line and column number
FIXME test for CHAR_EOTEXT !?!protected void calccolnum()
backwardsX()
public void backwardsX()
this
to point
one(1) character position before its current position
and adjusts line and column number
public void backwardsX(int num)
this
to point
given characters position before its current position
and adjusts line and column numberpublic int get_len()
public int get_start()
public int get_linenum()
public int get_colnum()
public MemString.CharMem get_data()
public String getPositionIndication()
public static void main(String[] args) throws IOException
IOException
see also the complete user documentation .