Class TSBuf

java.lang.Object
  extended by TSBuf
All Implemented Interfaces:
java.io.Serializable

 class TSBuf
extends java.lang.Object
implements java.io.Serializable

.

======================================================================
 Class TSBuf -- Bufferobject and checking-methods
 This class handles a buffer and provides token from within this
   buffer. The current pointer is hidden from outside. So this class
   comply with the principle of 'information-hiding'.

 This class uses three different modes:
  single (s): Buffer is filled once when created;
                no refill of buffer possible.
  line   (l): 'TSFile' is specified when class is instanced;
                Buffer may be refilled with next input-record
                using a special method. ('getNext()') Modification
                and rewrite of current data-buffer is supported.
  file   (f): 'TSFile' is specified when class is instanced; Buffer
                is refilled automatically when current end is reached.
                This mode is marked with 'Mde'=='true'.

 Remark: If no additional input is available due to current mode,
         EOF will be generated in any case.
 Attention: 'Buf' is the current input-buffer and 'Lne' is the
             save-value of this data. 'Lne' is updated only, when
             there is new VALID data for 'buf'. So, this string
             contains the last valid data, even if 'buf' is set to
             'null' due to an error. However, it must be assured
             that all changes of the content of 'buf' are reflected
             within 'Lne', too.
 Attention: this class refers to classes: TSUtil, TSFile, TSLogg
 ##TSBuf (Eyecatcher)
======================================================================
 


Field Summary
private  int BrC
           
private  java.lang.String Buf
           
private static java.lang.String[] DefArr
           
private  java.lang.String EMsg
           
protected static java.lang.String IdStr
           
private  java.lang.String Lne
           
private  boolean Mde
           
private  int Pos
           
private  TSFile Rdr
           
private  int SveB
           
private  int SveP
           
private  boolean Usr
           
private  TSFile Wtr
           
 
Constructor Summary
protected TSBuf()
          .
protected TSBuf(java.lang.String val)
          .
protected TSBuf(TSFile R)
          .
protected TSBuf(TSFile R, TSFile W)
          .
 
Method Summary
protected  boolean advPtr(java.lang.String cKw)
          .
protected  char charAt(boolean skp)
          .
private  boolean chkComment(java.lang.String s)
          .
protected  boolean chkSep(boolean skp)
          .
protected  java.lang.String[] getArr()
          .
protected  int getBrL()
          .
protected  java.lang.String getErr()
          .
protected  java.lang.String getErr(java.lang.String msg)
          .
protected  double getFV()
          .
protected  int getHV(int wl)
          .
protected  java.lang.String getKE(boolean exp)
          .
protected  java.lang.String getLne(int p)
          .
protected  boolean getNext(boolean mde)
          .
protected  long getNV()
          .
protected  long getNV(boolean m)
          .
private  boolean getNxt(boolean skp)
          .
protected  java.lang.String getPrnt()
          .
protected  int getStat(boolean c)
          .
protected  java.lang.String getTail(boolean skp)
          .
protected  boolean getUsr()
          .
protected  java.lang.String getVal(int opt)
          .
protected  int length()
          .
protected  boolean mark(boolean clr)
          .
protected  boolean modData(java.lang.String dta)
          .
private  boolean nxtChar()
          .
protected  boolean reset(boolean clr)
          .
protected  boolean setUsr(boolean nS)
          .
protected  boolean skpFwd()
          .
protected  boolean skpFwd(int lv)
          .
protected  java.lang.String skpVal()
          .
protected  java.lang.String skpVal(int lv)
          .
protected  java.lang.String toStr()
          .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IdStr

protected static final java.lang.String IdStr
See Also:
Constant Field Values

DefArr

private static final java.lang.String[] DefArr

Buf

private java.lang.String Buf

Lne

private java.lang.String Lne

Pos

private int Pos

SveP

private int SveP

BrC

private int BrC

SveB

private int SveB

Mde

private boolean Mde

Rdr

private TSFile Rdr

Wtr

private TSFile Wtr

EMsg

private java.lang.String EMsg

Usr

private boolean Usr
Constructor Detail

TSBuf

protected TSBuf()
.
=====================================================================
 Constructor: (1) create Default-Entry
=====================================================================
  


TSBuf

protected TSBuf(java.lang.String val)
.
=====================================================================
 Constructor: (2) create Standard-Entry ('single'-mode)
=====================================================================
  


TSBuf

protected TSBuf(TSFile R)
.
=====================================================================
 Constructor: (3) Create TSFile-entry ('file'-mode)
=====================================================================
  


TSBuf

protected TSBuf(TSFile R,
                TSFile W)
.
=====================================================================
 Constructor: (4) Create TSFile-entry ('line'-mode and update)
=====================================================================
  

Method Detail

advPtr

protected final boolean advPtr(java.lang.String cKw)
.
=====================================================================
 Method "advPtr" (s,l)
 Advance current pointer to point to argument. Returns 'false' if
   argument is NOT found and then the pointer is not changed.
 Method can only be used when '(single-)line'-mode is active
 Attention: Keyword should be specified using 'lowercase'-characters
            or NO match will occur
 ##advPtr.TSBuf (Eyecatcher)
=====================================================================
  


charAt

protected final char charAt(boolean skp)
.
=====================================================================
 Methode "charAt"
 Provide current character and advance char-pointer if requested
 Attention: This method does NOT fill the buffer. If EOL is
            reached '\n' is returned.
 ##charAt.TSBuf (Eyecatcher)
=====================================================================
  


chkComment

private final boolean chkComment(java.lang.String s)
.
=====================================================================
 Methode "chkComment"
 Check, if provided token does not signal a comment.
 If the start of a comment is found, 'false' is returned.
 ##chkComment.TSBuf (Eyecatcher)
=====================================================================
  


chkSep

protected final boolean chkSep(boolean skp)
.
=====================================================================
 Methode "chkSep"
 Check, if next character contains a whitespace as seperator.
 Attention: If this method returns 'true', the position-pointer is
            NOT incremented in every case.
 ##chkSep.TSBuf (Eyecatcher)
=====================================================================
  


getArr

protected final java.lang.String[] getArr()
.
=====================================================================
 Methode "getArr"
 Holen vollstaendige Version eines String-Arrays
         *** Routine akzeptiert Kommentare und uebergeht diese ***
 Ergebnis: Returnwert EMsg      Bedeutung
           <>null     null      Datenwert
           null       null      Datei-/Zeilenende erreicht
           null       <>null    Fehlermeldung
 ##getArr.TSBuf (Eyecatcher)
=====================================================================
  


getBrL

protected final int getBrL()
.
=====================================================================
 Method "getBrL"
 ##getBrL.TSBuf (Eyecatcher)
=====================================================================
  


getErr

protected final java.lang.String getErr()
.
=====================================================================
 Method "getErr"
 ##getErr.TSBuf (Eyecatcher)
=====================================================================
  


getErr

protected final java.lang.String getErr(java.lang.String msg)
.
=====================================================================
 Method "getErr" (2. version)
 ##getErr.TSBuf (Eyecatcher)
=====================================================================
  


getFV

protected final double getFV()
.
=====================================================================
 Methode "getFV"
 Holen der naechsten Float-Zahl als Double-Value
         *** Routine akzeptiert Kommentare und uebergeht diese ***
 Ergebnis: EMsg      Returnwert    Bedeutung
           null      ...           Datenwert
           <>null    NaN           Datei-/Zeilenende erreicht
           <>null    1e99          no number to convert (L=0)
           <>null    2e99          convert-error (illegal chars)
           <>null    3e99          Fehler aus 'getVal()'
 ##getFV.TSBuf (Eyecatcher)
=====================================================================
  


getHV

protected final int getHV(int wl)
.
=====================================================================
 Methode "getHV"
 Extrahieren des naechsten numerischen Hex-Wertes
         *** Routine akzeptiert Kommentare und uebergeht diese ***
 Ergebnis: EMsg      Returnwert    Bedeutung
           null      ...           Datenwert
           <>null    0             Datei-/Zeilenende erreicht
           <>null    -1            no number to convert (L=0)
           <>null    -2            Konvertierungsfehler
           <>null    -3            Fehler aus 'getVal()'
           <>null    -4            Laengen-Fehler des Wertes
 ##getHV.TSBuf (Eyecatcher)
=====================================================================
  


getKE

protected final java.lang.String getKE(boolean exp)
.
=====================================================================
 Methode "getKE"
 Extrahieren des naechsten Schluesselwortes (Keyword-Expression)
  !!Kommentare werden erkannt und uebergangen!!
 Pruefung auf Ausdruck (mit folgender Klammer) moeglich
 Ergebnis: (in Pruefungsreihenfolge):
   Returnwert EMsg      Bedeutung
    <>null     null      Datenwert
    String-Length==0     KEIN Schluesselwort-Ausdruck gef.
    null       null      Datei-/Zeilenende erreicht
    null       <>null    Fehlermeldung
 ##getKE.TSBuf (Eyecatcher)
=====================================================================
  


getLne

protected final java.lang.String getLne(int p)
.
=====================================================================
 Method "getLne"
 Method returns 'Line-data' starting at position 'p'
 Line-data is a copy of buffer-data
 Line-data is ONLY changed, if reading of file succeeds
 ##getLne.TSBuf (Eyecatcher)
=====================================================================
  


getNext

protected final boolean getNext(boolean mde)
.
=====================================================================
 Method "getNext" (s,l)
 Write back current line if possible and requested.
 Read line from input-file and provide it as 'inputline'.
 Flush-function is executed in every case (set pointer to EOL)
 If 'mde' is set, method ends after flush-function.
 This method is ONLY valid if 'line'-mode is active.

 Return-conditions :
   Returnvalue EMsg      Meaning
    false      null      Data was sucessfully read/skipped
    true       null      EOF was reached
    true       <>null    EMsg contains errormessage
 Attention: This method does NOT check, if previous buffer is
            valid and fully processed. However, because 'Buf' may be
            'null' due to search for next valid token, the save-value
            'Lne' must be written. It must be assured that all changes
            of the content of 'buf' must be reflected within 'Lne',
            too.
 ##getNext.TSBuf (Eyecatcher)
=====================================================================
  


getNV

protected final long getNV()
.
=====================================================================
 Method "getNV"
 Extract and return the next numeric value from inputline. Use a
 'long'-value in order to handle unsigned integers.
 Comments -- refer to extended version
 ##getNV.TSBuf (Eyecatcher)
=====================================================================
  


getNV

protected final long getNV(boolean m)
.
=====================================================================
 Method "getNV" (extended version)
 Extrahieren des naechsten numerischen Wertes
 Achtung: nur ganzahlige Werte (+/-) erlaubt!!
         *** Routine akzeptiert Kommentare und uebergeht diese ***
 ACHTUNG: 'Unsigned-Integer'-Werte werden unterstuetzt
 Ergebnis: EMsg      Returnwert    Bedeutung
           null      ...           Datenwert
           <>null    0             Datei-/Zeilenende erreicht
           <>null    -1            no number to convert (L=0)
           <>null    -2            Konvertierungsfehler
           <>null    -3            Fehler aus 'getVal()'
 ##getNV.TSBuf (Eyecatcher)
=====================================================================
  


getNxt

private final boolean getNxt(boolean skp)
.
=====================================================================
 Method "getNxt" ((s,l),f)
 Read date from S-/T-/W-file or ..-file using 'file'-mode. Read them
   into 'buf' and skip empty lines if requested.
 Keep old data and add new one if marker is set.

 No new data is read if (single-)line-mode is active. So,
   EOF is returned.
 ##getNxt.TSBuf (Eyecatcher)
=====================================================================
  


getPrnt

protected final java.lang.String getPrnt()
.
=====================================================================
 Method "getPrnt"
 Method returns 'Line-data' surrounded with single-quotes.
 Line-data is a copy of buffer-data.
 Line-data is ONLY changed, if reading of file succeeds.
 Attention: A leading blanc is added to seperate the data-fragments.
 ##getPrnt.TSBuf (Eyecatcher)
=====================================================================
  


getStat

protected final int getStat(boolean c)
.
=====================================================================
 Method "getStat"
 Get statistic-values of current I/O  (independend of mode)
  Method uses appropriate i/o-function due to current mode
 Attention: values are valid even if file is already closed
            values are initialized (again) when file is opened
 ##getStat.TSBuf (Eyecatcher)
=====================================================================
  


getTail

protected final java.lang.String getTail(boolean skp)
.
=====================================================================
 Method "getTail" (s,l)
 Extrahieren des Rest-Wertes in String-Form
 Achtung: Diese Methode ist NUR fuer den Zeilenmodus erlaubt.
 Ergebnis: Returnwert EMsg      Bedeutung
           <>null     null      Datenwert
           null       null      Zeilenende erreicht
 ##getTail.TSBuf (Eyecatcher)
=====================================================================
  


getUsr

protected final boolean getUsr()
.
=====================================================================
 Method "getUsr"
 Get current state of user-flag.
 This field/method is NOT used by TSBuf itself. Applications may use
   this field, to extend the capabilities of the class.
 ##getUsr.TSFile (Eyecatcher)
=====================================================================
  


getVal

protected final java.lang.String getVal(int opt)
.
=====================================================================
 Method "getVal"
 Get next value returning a 'string'. If value STARTS with quotes,
   these surrounding quotes are deleted and all occurrences of '\"'
   are changed to '"'. However, all following chars of the value
   are NOT changed. The result-value ends when a
   'termination-character' is found (outside a quoted string).
 Attention: If 'file'-mode is active, the (first) quoted string
            is not fully processed and EOF of the line is reached
            a new record is read into storage and searching for
            'end-of-string' continues.
 Result: Return-value EMsg      Meaning
         <>null       null      valid data
         null         null      EOF/EOL (end-of-file/line) reached
         null         <>null    error-message (*)
 (*): If 'line'-mode is active, NO error-message can be returned.
 ##getVal.TSBuf (Eyecatcher)
=====================================================================
  


length

protected final int length()
.
=====================================================================
 Method "length"
 Name of method is requested by class 'String'
 This method provides the length of the CURRENT line. This may
   include 'Whitespace'-characters.
 Attention: If a default-reader is available, the current line may
            change unknown to the user of this method.
 ##length.TSBuf (Eyecatcher)
=====================================================================
  


mark

protected final boolean mark(boolean clr)
.
=====================================================================
 Method "mark"
 Handle control of position -- mark it.
 Returns 'false', if NO position was already marked.
 ##mark.TSBuf (Eyecatcher)
=====================================================================
  


modData

protected final boolean modData(java.lang.String dta)
.
=====================================================================
 Method "modData" ((s),l)
 Modify dataline, insert changes (before current pointer).
 If 'mark' is active, all data between marker-position and current
   pointer ('Pos') is deleted.
 Only values, which are already read from line, may be changed.
 Method can ONLY be used when '(single-)line'-mode is active
 ##modData.TSBuf (Eyecatcher)
=====================================================================
  


nxtChar

private final boolean nxtChar()
.
=====================================================================
 Utility-method "nxtChar" (private)
 Checks characters within 'Buf' and starting at position 'Pos' if
 they are 'Whitespace'-characters. Adjust pointer 'Pos' to first
 character, which do NOT fullfill this condition.
 If NO such character is found until end-of-line, 'Pos' is set to
 bufferlength and 'true' is returned. Otherwise 'false' is returned.
 Attention: - The current position-pointer 'Pos' is NOT checked.
            - ONLY current buffer is used (no read)
 ##nxtChar.TSBuf (Eyecatcher)
=====================================================================
  


reset

protected final boolean reset(boolean clr)
.
=====================================================================
 Method "reset"
 Handle control of position.
 Returns 'false', if function was successful.
 ##reset.TSBuf (Eyecatcher)
=====================================================================
  


setUsr

protected final boolean setUsr(boolean nS)
.
=====================================================================
 Method "setUsr"
 Set or Reset state of current user-flag.
 This field/method is NOT used by TSBuf itself. Applications may use
   this field, to extend the capabilities of the class.
 ##setUsr.TSFile (Eyecatcher)
=====================================================================
  


skpFwd

protected final boolean skpFwd(int lv)
.
=====================================================================
 Method "skpFwd"
 skip (key)words until specified bracket is closed
 returns 'true' if EOF/error found
 ##skpFwd.TSBuf (Eyecatcher)
=====================================================================
  


skpFwd

protected final boolean skpFwd()
.
=====================================================================
 Method "skpFwd" (Version 2)
 skip (key)words until (next) bracket is closed
 returns 'true' if EOF/error found
 ##skpFwd.TSBuf (Eyecatcher)
=====================================================================
  


skpVal

protected final java.lang.String skpVal(int lv)
.
=====================================================================
 Methode "skpVal"
 Extrahieren der naechsten Werte bis zur schliessenden Klammer
  und liefern der Gesamt-Kette in String-Form.
 Als Trennzeichen wird ' ' verwendet! Mehrere Trennzeichen der
  Originalzeile werden ggf. durch EIN ' ' ersetzt.
 Wenn KEIN Trennzeichen vorhanden ist, wird auch KEINES eingesetzt.
 Attention: The last closing bracket is NOT skipped!
 Ergebnis: Returnwert EMsg      Bedeutung
           <>null     null      Datenwert
           null       null      Datei-/Zeilenende erreicht
           null       <>null    Fehlermeldung
 ##skpVal.TSBuf (Eyecatcher)
=====================================================================
  


skpVal

protected final java.lang.String skpVal()
.
=====================================================================
 Methode "skpVal" (Version 2)
 Extrahieren der naechsten Werte bis zur schliessenden Klammer
  und liefern der Gesamt-Kette in String-Form.
 Dokumentation: vgl. Version 1
 ##skpVal.TSBuf (Eyecatcher)
=====================================================================
  


toStr

protected final java.lang.String toStr()
.
=====================================================================
 Method "toStr"
 Build a string-representation of all values of this class
 ##toStr.TSBuf (Eyecatcher)
=====================================================================