Class TSFile

java.lang.Object
  extended by TSFile
Direct Known Subclasses:
TSFile$td, TSFile$trk, TSFileS, TSFileT, TSFileW, TSFileX

 class TSFile
extends java.lang.Object

.

======================================================================
 Class TSFile -- Compress, decompress, reduce or expand of a file
  Reduce     - change normal format to tokenized version [UT]->[UB]
  Expand     - change tokenized format to normal version [UB]->[UT]
  Compress   - use zlib-algorithm to compress tokenized format
  Uncompress - uncompress data to tokenized format [CB]->[UB]
   Uncompress/Expand is done step by step while reading data
   Reduce is done step by step while writing data
     (Write data to file is executed before file is closed)
   Compress is executed before file is closed
 ##TSFile (Eyecatcher)
======================================================================
 


Field Summary
private  TSByteArrIO BIO
           
private  TSBuf cB
           
private  TSFleStack cItS
           
private  int cMde
           
private  int cP
           
private  int cRep
           
private static java.text.DecimalFormat[] dF
           
private static java.text.DecimalFormat DF2
           
private  java.lang.StringBuilder DtaB
           
private  java.util.ArrayList<java.lang.String> DtaI
           
private  java.lang.String DtaO
           
private  java.lang.String EMsg
           
private static float[] F
           
private static java.text.DecimalFormatSymbols fFS
           
private static java.lang.String[] FL1
           
private static java.lang.String[] FL2
           
private  java.io.File Fle
           
private static byte[] FlePfx
           
private  java.lang.String FNme
           
protected static int IA
           
protected static int ICB
           
protected static int ICT
           
protected static java.lang.String IdStr
           
protected static int IN
           
private static int IO_app
           
private static int IO_bin
           
private static int IO_bio
           
private static int IO_cpr
           
private static int IO_Msk
           
private static int IO_out
           
private static int IO_rqf
           
private  java.io.InputStream IS
           
private  java.util.Stack<TSFleStack> ItS
           
protected static int IU
           
protected static int IUB
           
protected static int IUT
           
private static int MaxLen
           
private static java.lang.String Mkr0
           
private static java.lang.String Mkr1
           
private  int mode
           
protected static int OA
           
protected static int OAA
           
protected static int OB_Len
           
protected static int OCB
           
protected static int OCT
           
private  java.io.OutputStream OS
           
private static int OSize
           
protected static int OU
           
protected static int OUA
           
protected static int OUB
           
protected static int OUT
           
private  int Pos
           
private  int rc
           
private  java.io.BufferedReader Rdr
           
private  int rl
           
private static java.text.DecimalFormat[] sF
           
protected static TSFleTok tok1
           
private  java.io.BufferedWriter Wtr
           
private static java.text.DecimalFormat[] xF
           
 
Constructor Summary
protected TSFile()
          .
protected TSFile(java.io.File dat)
          .
 
Method Summary
protected  TSBuf chgBuf(TSBuf nB)
          .
protected  java.lang.String chkFKng(java.lang.String s, boolean t)
          .
protected  java.lang.String close()
          .
private  boolean Expand()
          .
protected  java.lang.String getData()
          .
protected  java.lang.String getErr()
          .
private  java.lang.String getFloat(int c)
          .
private  java.lang.String getFloat$(int rep, int rd)
          .
private  java.lang.String getHex$(int rep, int len, boolean up)
          .
private  long getInt(int len)
          .
private  java.lang.String getInt$(int rep)
          .
private  java.lang.String getItem(java.lang.String rv)
          .
protected  int getMode(int md)
          .
protected  java.lang.String getPath()
          .
private  java.lang.String getPrfx(boolean ext)
          .
protected  int getStat(boolean c)
          .
private  java.lang.String getString(int len)
          .
private  java.lang.String getString$(boolean add)
          .
protected  TSFleTok getTok(int i)
          .
protected  TSFleTok getTok(java.lang.String s)
          .
protected  int getTyp()
          .
private  java.lang.String getUInt$(int rep)
          .
protected  java.lang.String open(int iom)
          .
protected  java.lang.String prtMode()
          .
protected  java.lang.String putData(java.lang.String dta)
          .
protected  boolean Reduce(java.lang.String lne)
          .
protected  boolean setBuffer(TSByteArrIO cIO)
          .
protected  java.lang.String setTyp(int id)
          .
private  java.lang.String skpLne(java.lang.String cB, boolean noI)
          .
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

OB_Len

protected static int OB_Len

OSize

private static final int OSize
See Also:
Constant Field Values

MaxLen

private static final int MaxLen
See Also:
Constant Field Values

fFS

private static final java.text.DecimalFormatSymbols fFS

DF2

private static final java.text.DecimalFormat DF2

dF

private static final java.text.DecimalFormat[] dF

xF

private static final java.text.DecimalFormat[] xF

sF

private static final java.text.DecimalFormat[] sF

F

private static final float[] F

FlePfx

private static final byte[] FlePfx

FL1

private static final java.lang.String[] FL1

FL2

private static final java.lang.String[] FL2

Mkr0

private static final java.lang.String Mkr0
See Also:
Constant Field Values

Mkr1

private static final java.lang.String Mkr1
See Also:
Constant Field Values

tok1

protected static final TSFleTok tok1

IN

protected static final int IN
See Also:
Constant Field Values

IUT

protected static final int IUT
See Also:
Constant Field Values

IUB

protected static final int IUB
See Also:
Constant Field Values

ICT

protected static final int ICT
See Also:
Constant Field Values

ICB

protected static final int ICB
See Also:
Constant Field Values

OUT

protected static final int OUT
See Also:
Constant Field Values

OUB

protected static final int OUB
See Also:
Constant Field Values

OCT

protected static final int OCT
See Also:
Constant Field Values

OCB

protected static final int OCB
See Also:
Constant Field Values

IU

protected static final int IU
See Also:
Constant Field Values

IA

protected static final int IA
See Also:
Constant Field Values

OU

protected static final int OU
See Also:
Constant Field Values

OA

protected static final int OA
See Also:
Constant Field Values

OUA

protected static final int OUA
See Also:
Constant Field Values

OAA

protected static final int OAA
See Also:
Constant Field Values

IO_rqf

private static final int IO_rqf
See Also:
Constant Field Values

IO_bio

private static final int IO_bio
See Also:
Constant Field Values

IO_out

private static final int IO_out
See Also:
Constant Field Values

IO_app

private static final int IO_app
See Also:
Constant Field Values

IO_cpr

private static final int IO_cpr
See Also:
Constant Field Values

IO_bin

private static final int IO_bin
See Also:
Constant Field Values

IO_Msk

private static final int IO_Msk
See Also:
Constant Field Values

Fle

private java.io.File Fle

cMde

private int cMde

mode

private int mode

FNme

private java.lang.String FNme

EMsg

private java.lang.String EMsg

Rdr

private java.io.BufferedReader Rdr

Wtr

private java.io.BufferedWriter Wtr

IS

private java.io.InputStream IS

OS

private java.io.OutputStream OS

BIO

private TSByteArrIO BIO

Pos

private int Pos

cP

private int cP

ItS

private java.util.Stack<TSFleStack> ItS

cItS

private TSFleStack cItS

DtaI

private java.util.ArrayList<java.lang.String> DtaI

DtaO

private java.lang.String DtaO

DtaB

private java.lang.StringBuilder DtaB

cB

private TSBuf cB

cRep

private int cRep

rc

private int rc

rl

private int rl
Constructor Detail

TSFile

protected TSFile()
.
=====================================================================
 Constructor: (1) Create Default-Entry
=====================================================================
  


TSFile

protected TSFile(java.io.File dat)
.
=====================================================================
 Constructor: (2) Create Standard-Entry
=====================================================================
  

Method Detail

chgBuf

protected final TSBuf chgBuf(TSBuf nB)
.
=====================================================================
 Method "chgBuf"
 Modify or read current inputbuffer-reference
 This field/method is NOT used by TSFile. Applications may use this
   field to support methods with its current input-buffer
 ##chgBuf.TSFile (Eyecatcher)
=====================================================================
  


chkFKng

protected java.lang.String chkFKng(java.lang.String s,
                                   boolean t)
.
=====================================================================
 Method "chkFKng" (Dummy for extended classes)
 Check File-Identifier for current type of file
  First Argument (String):
    null   - provide full key for write
             returns 'null' if key not available due to error(s)
             else returns the requested file-id
    <>null - check provided file-id
             returns 'null' if the check succeeds
             else returns an error-message (result <> null)
  Form of file-id must be of the type specified with the second
    argument. If this type is not supported an error is returned
    in every case.
 THIS dummy-function returns an error in every case, because
   - normally - it is overwritten.
 ##chkFKng.TSFile (Eyecatcher)
=====================================================================
  


close

protected java.lang.String close()
.
=====================================================================
 Method "close"
 Close reader/writer again
 Method returns error-message or 'null'
 ##close.TSFile (Eyecatcher)
=====================================================================
  


Expand

private final boolean Expand()
.
=====================================================================
 Method "Expand"
 Process token-definitions and create lines of data.
 Attention: - Method is ONLY used when 'input' is active.
            - Binary file is completely loaded into memory.
            - 'cP' is (mis)used as 'current-shift-level', which
              differs from value 'ItS.size()'.
 ##Expand.TSFile (Eyecatcher)
=====================================================================
  


getData

protected final java.lang.String getData()
.
=====================================================================
 Method "getData"
 Read next line
 Next line is provided from file or buffer
 If buffer is empty is is filled with decompressed data from file
 if an error is found: EMsg is set and 'null' is returned
 ##getData.TSFile (Eyecatcher)
=====================================================================
  


getErr

protected final java.lang.String getErr()
.
=====================================================================
 Method "getErr"
 Get active error-message ('null' if none)
 ##getErr.TSFile (Eyecatcher)
=====================================================================
  


getFloat

private final java.lang.String getFloat(int c)
.
=====================================================================
 Method "getFloat"
 Get 4 Byte from file, use as FLOAT and convert them to STRING
 ##getFloat.TSFile (Eyecatcher)
=====================================================================
  


getFloat$

private final java.lang.String getFloat$(int rep,
                                         int rd)
.
=====================================================================
 Method "getFloat$"
 Get 'rep' x float-value from file using 'getFloat()'
 ##getFloat$.TSFile (Eyecatcher)
=====================================================================
  


getHex$

private final java.lang.String getHex$(int rep,
                                       int len,
                                       boolean up)
.
=====================================================================
 Method "getHex$"
 Get 'rep' x UINT from file and convert to 'hexadecimal'-String
 ##getHex$.TSFile (Eyecatcher)
=====================================================================
  


getInt

private final long getInt(int len)
.
=====================================================================
 Method "getInt"
 Get 'Integer'/'Unsigned Integer' ('len' Byte) from buffer as 'long'.
 Method uses current inputbuffer and increments position-pointer.
 ##getInt.TSFile (Eyecatcher)
=====================================================================
  


getInt$

private final java.lang.String getInt$(int rep)
.
=====================================================================
 Method "getInt$"
 Get 'rep' x int-value from file using 'getInt()'
 Convert SIGNED values to String and concatenate them
   (separated with ' ')
 ##getInt$.TSFile (Eyecatcher)
=====================================================================
  


getItem

private final java.lang.String getItem(java.lang.String rv)
.
=====================================================================
 Method "getItem"
 Extract next item and provide it in String-format.
   Surrrounding quotes are deleted if present.
 If no item is found, 'null' is returned.
 Method operates on 'DtaO' and uses pointer 'cP'
  (compare to 'remark' within method 'reduce').
 If 'empty remaining string' is found, 'Mkr0' is returned.
 If string-fragment was successfully stored, 'Mkr0' is returned.
 If a valid 'empty string' is found, 'Mkr1' is returned.

 Testing for 'special values' is possible! (rv!=null)
  In this case 'null' is returned if match is found
   and the found original values otherwise.

 ATTENTION: '(' and')' is a valid seperator. So, these chars can
            only be skipped using 'request special value'.
 Attention: This method uses global 'Reduce'-buffer 'DtaB' to support
            input-records which are split among more than one line.
 ##getItem.TSFile (Eyecatcher)
=====================================================================
  


getMode

protected final int getMode(int md)
.
=====================================================================
 Method "getMode"
 Provides caller with last used I/O-mode, modified as requested.
 Attention: I/O-Mode is masked to reflect binary/compress ONLY.
 ##getMode.TSFile (Eyecatcher)
=====================================================================
  


getPath

protected final java.lang.String getPath()
.
=====================================================================
 Method "getPath"
 Returns current (complete / fully-qualified) filename as stored.
 ##getPath.TSFile (Eyecatcher)
=====================================================================
  


getPrfx

private final java.lang.String getPrfx(boolean ext)
.
=====================================================================
 Methode "getPrfx"
 Returns a prefix-definition of an output-line as String using
   iteration-counter as basis. This method uses the current
   shift-level as basis.
   'cP' is (mis)used as 'current-shift-level', which differs from
     value 'ItS.size()'.
 ##getPrfx.TSFile (Eyecatcher)
=====================================================================
  


getStat

protected final int getStat(boolean c)
.
=====================================================================
 Method "getStat"
 Get statistic-values of current I/O
 Attention: values are valid even if file is already closed
            values are initialized when file is opened (again)
 ##getStat.TSFile (Eyecatcher)
=====================================================================
  


getString

private final java.lang.String getString(int len)
.
=====================================================================
 Method "getString"
 Read Unicode-String from binary file.
 ATTENTION: + No additional Blank is added.
            + If input-data is not fully available, up to 5 retries
               are scheduled.
            + Data may be read from 'file' or 'IO-buffer' (due to IS).
            + Position-pointer 'Pos' is adjusted.
 ##getString.TSFile (Eyecatcher)
=====================================================================
  


getString$

private final java.lang.String getString$(boolean add)
.
=====================================================================
 Method "getString$"
 Get one String-definition and surround it with quotes if needed or
   requested.
 ##getString$.TSFile (Eyecatcher)
=====================================================================
  


getTok

protected TSFleTok getTok(int i)
.
=====================================================================
 Method "getTok" (Dummy for extended classes)
 Provide requested token due to token-number.
 This dummy-version, which should be overwritten, returns an error.
 ##getTok.TSFile (Eyecatcher)
=====================================================================
  


getTok

protected TSFleTok getTok(java.lang.String s)
.
=====================================================================
 Method "getTok" (Dummy for extended classes)
 Provide requested token due to token-name.
 This dummy-version, which should be overwritten, returns an error.
 ##getTok.TSFile (Eyecatcher)
=====================================================================
  


getTyp

protected int getTyp()
.
=====================================================================
 Method "getTyp" (Dummy for extended classes).
 Provides current identifier-type (if available).
 This dummy-version, which should be overwritten, returns a
   default-value (0).
 ##getTyp.TSFile (Eyecatcher)
=====================================================================
  


getUInt$

private final java.lang.String getUInt$(int rep)
.
=====================================================================
 Method "getUInt$"
 Get 'rep' x unsigned int-value from file using 'getInt()'
 Convert unsigned values to String and concatenate them
 ##getUInt$.TSFile (Eyecatcher)
=====================================================================
  


open

protected java.lang.String open(int iom)
.
=====================================================================
 Method "open"
 Open file and create Reader or Writer
 If 'Input' is requested (or special option):
    check input-mode of file (in this case 'iom'-argument is modified)
  All modes/formats are supported for 'input'!
 The following I/O-ID's are used:
     IN  = 0(00)   Input, unknown format
     IUT = 128(80) Input, UT-Format (format is requested)
     IUB = 129(81) Input, UB-Format (format is requested)
     ICT = 130(82) Input, CT-Format (format is requested)
     ICB = 131(83) Input, CB-Format (format is requested)
     OUT = 8(08)   Output, UT-Format
     OUB = 9(09)   Output, UB-Format
     OCT = 10(0A)  Output, CT-Format
     OCB = 11(0B)  Output, CB-Format
     IU  = 16(10)  Input, unicode
     IA  = 17(11)  Input, ascii
     OU  = 24(18)  Output, unicode
     OA  = 25(19)  Output, ascii
     OUA = 28(1C)  Output, unicode,append
     OAA = 29(1D)  Output, ascii,append
 This includes the following flags:
     IO_bin = x01  ASCII(=Binary) (else: Unicode=Text)
     IO_cpr = x02  Compress
     IO_app = x04  Append   (if 'buffered-I/O')
     IO_out = x08  Output
     IO_bio = x10  Buffered-IO (no File-ID)
     IO_rqf = x80  format requested with input
   and masks:
     IO_Msk = x03  mask file-format from IO-command

 Method returns an error-message or 'null' if no error
 Attention: ALL Parameters are checked in any case!
            If 'binary input' is requested the COMPLETE file is also
               loaded into memory. Buffer-methods must then be
               used to access the data.
 ##open.TSFile (Eyecatcher)
=====================================================================
  


prtMode

protected final java.lang.String prtMode()
.
=====================================================================
 Method "prtMode"
 Return format of file according to current IO-mode.
 ##prtMde.TSFile (Eyecatcher)
=====================================================================
  


putData

protected final java.lang.String putData(java.lang.String dta)
.
=====================================================================
 Method "putData"
 Write line to file
 Do Compress and/or Reduce if requested
 Method returns error-message or 'null' if no error
 ##putData.TSFile (Eyecatcher)
=====================================================================
  


Reduce

protected final boolean Reduce(java.lang.String lne)
.
=====================================================================
 Method "Reduce"
 Reduce Data-Definition to token-format.
 Attention: - Method is ONLY used when 'output' is active.
            - Variable 'cP' is also used for inpt with different
                meaning.
 ##Reduce.TSFile (Eyecatcher)
=====================================================================
  


setBuffer

protected final boolean setBuffer(TSByteArrIO cIO)
.
=====================================================================
 Method "setBuffer"
 Replace current (binary) IO-Buffer with external one.
 Remark: This method is ONLY successful, if the file is NOT
         already opened.
 ##setBuffer.TSFile (Eyecatcher)
=====================================================================
  


setTyp

protected java.lang.String setTyp(int id)
.
=====================================================================
 Method "setTyp" (Dummy for extended classes).
 Activate an identifier-type for writing.
 This dummy-version, which should be overwritten, returns an error.
 ##setTyp.TSFile (Eyecatcher)
=====================================================================
  


skpLne

private final java.lang.String skpLne(java.lang.String cB,
                                      boolean noI)
.
=====================================================================
 Methode "skpLne"
 Save the current buffer to the inputqueue and provides a new
   buffer which is correctly initialized.
 ##getPrfx.TSFile (Eyecatcher)
=====================================================================
  


toStr

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