MetaTF API

MetaTF.Runtime
Class MetaTFState

java.lang.Object
  |
  +--MetaTF.Runtime.MetaTFState

public class MetaTFState
extends java.lang.Object

The state of the reader/writer

Version:
rel-1-2 ($Revision: 1.1 $, $Date: 2000/12/15 16:35:32 $),
Author:
Richard Jones

Constructor Summary
MetaTFState()
           
 
Method Summary
static int getCurrentSection(int tag)
          Get the appropriate section
static TraceField getTraceField(int s, int rtag, int f)
          Get TraceField
static TraceRecord getTraceRecord(int s, int rtag)
          Get TraceRecord
static void init(int n, int f)
          Initialise the reader/writer state
static void initRecord(int s, int r, int f)
          Initialise a Record
static void initSection(int s, int r)
          Initialise a section
static void putSection(LowLevelWriter llw, int i)
          Write section metadata to change current section after changing the current section in the reader/writer
static Index readIndex(LowLevelReader llr, IndexTraceField tf)
          High-level read primitive to read an indexed value according to the field's encoding held in a IndexTraceField
static java.lang.String readln(LowLevelReader llr)
          Reads a string with assumed encoding of none e.g.
static long readNum(LowLevelReader llr, NumTraceField tf)
          High-level read primitive to read a number according to the field's encoding held in a NumTraceField
static int readSpecial(LowLevelReader llr)
          Try to read a metadata record and adjust the state of the reader/writer accordingly.
static java.lang.String readString(LowLevelReader llr, StringTraceField tf)
          High-level read primitive to read a string according to the field's encoding held in a StringTraceField
static void setField(int s, int r, int f, int i, TraceField val)
          Set a TraceField in the sections/records/fields structure
static void setSection(int i)
          Change the current section in the reader/writer
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaTFState

public MetaTFState()
Method Detail

init

public static void init(int n,
                        int f)
Initialise the reader/writer state
Parameters:
n - the number of sections in the DTD
f - the number of distinct field names

initSection

public static void initSection(int s,
                               int r)
Initialise a section
Parameters:
s - the section number
the - number of records in section s

initRecord

public static void initRecord(int s,
                              int r,
                              int f)
Initialise a Record
Parameters:
s - the section number
r - the record tag (i.e. its number)
f - the number of fields

setField

public static void setField(int s,
                            int r,
                            int f,
                            int i,
                            TraceField val)
Set a TraceField in the sections/records/fields structure
Parameters:
s - the section number
r - the record number
f - the field number
val - the TraceField

getTraceRecord

public static TraceRecord getTraceRecord(int s,
                                         int rtag)
Get TraceRecord
Parameters:
s - the section number
rtag - the tag of the record
Returns:
the TraceRecord for this record in this section

getTraceField

public static TraceField getTraceField(int s,
                                       int rtag,
                                       int f)
Get TraceField
Parameters:
s - the section number
rtag - the tag of the record
f - the field number
Returns:
the TraceField for this record in this section

getCurrentSection

public static int getCurrentSection(int tag)
Get the appropriate section
Parameters:
tag - the tag that has just been reaf

readSpecial

public static int readSpecial(LowLevelReader llr)
                       throws BadRecordException,
                              java.io.IOException
Try to read a metadata record and adjust the state of the reader/writer accordingly.
Returns:
the tag

readNum

public static long readNum(LowLevelReader llr,
                           NumTraceField tf)
                    throws BadRecordException,
                           java.io.IOException
High-level read primitive to read a number according to the field's encoding held in a NumTraceField
Parameters:
tf - the NumTraceField
Throws:
BadRecordException - IF the encoding is MetaTFConstants.SectionOffset or MetaTFConstants.SectionStride
java.io.IOException - IF the read fails

readString

public static java.lang.String readString(LowLevelReader llr,
                                          StringTraceField tf)
                                   throws BadRecordException,
                                          java.io.IOException
High-level read primitive to read a string according to the field's encoding held in a StringTraceField
Parameters:
tf - the StringTraceField
Throws:
BadRecordException - IF the encoding is neither MetaTFConstants.None nor MetaTFConstants.Default
java.io.IOException - IF the read fails

readln

public static java.lang.String readln(LowLevelReader llr)
                               throws BadRecordException,
                                      java.io.IOException
Reads a string with assumed encoding of none e.g. used to read Comments

readIndex

public static Index readIndex(LowLevelReader llr,
                              IndexTraceField tf)
                       throws BadRecordException,
                              java.io.IOException
High-level read primitive to read an indexed value according to the field's encoding held in a IndexTraceField
Parameters:
tf - the IndexTraceField
Throws:
BadRecordException - IF the encoding is neither MetaTFConstants.SectionOffset MetaTFConstants.SectionStride nor MetaTFConstants.Default
java.io.IOException - IF the read fails

setSection

public static void setSection(int i)
                       throws BadRecordException
Change the current section in the reader/writer
Parameters:
i - the new section which must be valid
Throws:
BadRecordException - IF i is an invalid section number

putSection

public static void putSection(LowLevelWriter llw,
                              int i)
                       throws BadRecordException,
                              java.io.IOException
Write section metadata to change current section after changing the current section in the reader/writer
Parameters:
i - the new section which must be valid
Throws:
BadRecordException - IF i is an invalid section number
java.io.IOException - IF the write fails

MetaTF API

Copyright © 2001 - Richard Jones     MetaTF