MetaTF API

MetaTF.Parser
Class Section

java.lang.Object
  |
  +--MetaTF.Parser.Section
All Implemented Interfaces:
java.lang.Comparable, HasFields, HasProperties

public class Section
extends java.lang.Object
implements HasFields, HasProperties, java.lang.Comparable

Section

Version:
rel-1-2 ($Revision: 1.3 $, $Date: 2000/12/15 16:29:55 $),
Author:
Richard Jones
See Also:
The MetaTF Grammar, Record, Field

Fields inherited from interface MetaTF.Parser.HasFields
cvsheader
 
Fields inherited from interface MetaTF.Parser.HasProperties
cvsheader
 
Constructor Summary
(package private) Section(java.lang.String s, int i)
          Allocate a new object to represent asection
(package private) Section(java.lang.String s, int i, boolean b)
          Allocate a new object to represent asection
(package private) Section(java.lang.String s, int i, boolean b, int l)
          Allocate a new object to represent asection
 
Method Summary
 java.lang.Object accept(DTDVisitor visitor, java.lang.Object data)
          Accept the visitor
 void addField(Field f)
          Add a Field to this section Simply override old definitions (i.e.
 void addProperty(java.lang.String type, java.lang.String fname, java.lang.String p, Value v, int l)
          Add a property to this section or record
(package private)  void addRecord(Record r)
          Add a Record to this section
(package private)  void addRecordByTag(int tag, Record r)
          Add a Record to the list of 'records by tag' in this section
 int compareTo(java.lang.Object s)
          Compare sections by number
 java.lang.String dump(java.lang.String prefix)
          Dump a representation of this section
 java.util.Map getFields()
           
 int getLine()
           
 int getMaxTag()
           
 java.lang.String getName()
           
 int getNumber()
           
 Value getProperty(java.lang.String fname, java.lang.String p)
          Get the valeue of the named property if the field is defined at the section level
 Record getRecord(int tag)
          Get a record defined in this section
 Record getRecord(java.lang.String str)
          Get a record defined in this section
 java.util.Map getRecords()
           
 boolean hasRecord(int t)
          Does this section define a record?
 boolean hasRecord(java.lang.String name)
          Does this section define a record?
 boolean isCached()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Section

Section(java.lang.String s,
        int i,
        boolean b,
        int l)
  throws DTDException
Allocate a new object to represent asection
Parameters:
s - the name of the section
i - the number of the section
b - is the section cached?
the - line in the DTD where this section's definition started
Throws:
DTDException - IF this section number or name is already used

Section

Section(java.lang.String s,
        int i,
        boolean b)
  throws DTDException
Allocate a new object to represent asection
Parameters:
s - the name of the section
i - the number of the section
b - is the section cached?
Throws:
DTDException - IF this section number is already used

Section

Section(java.lang.String s,
        int i)
  throws DTDException
Allocate a new object to represent asection
Parameters:
s - the name of the section
the - line in the DTD where this section's definition started
Throws:
DTDException - IF this section number is already used
Method Detail

addRecord

void addRecord(Record r)
         throws DTDException
Add a Record to this section
 1. if a record of this name is known, remove it
 2. do any macro replacement of field names
 3. do semantic check on fields
 4. finally, add record to section
 
Parameters:
r - the record to add
Throws:
DTDException - if this is improper

addProperty

public void addProperty(java.lang.String type,
                        java.lang.String fname,
                        java.lang.String p,
                        Value v,
                        int l)
                 throws DTDException
Description copied from interface: HasProperties
Add a property to this section or record
Specified by:
addProperty in interface HasProperties
Following copied from interface: MetaTF.Parser.HasProperties
Parameters:
type - the type
field - the name of the field. The property is only added if the field names match
property - the property
value - the value of the property
beginLine - the line in the DTD at which this property was defined
Throws:
DTDException -  

getProperty

public Value getProperty(java.lang.String fname,
                         java.lang.String p)
                  throws DTDException
Get the valeue of the named property if the field is defined at the section level
Parameters:
fname - the name of the field
p - the property
Throws:
DTDException - IF fname is not defined at the section level || fname does not have property p

addField

public void addField(Field f)
              throws DTDException
Add a Field to this section Simply override old definitions (i.e. don't worry about redefinition)
Specified by:
addField in interface HasFields
Parameters:
f - the field to add
Throws:
DTDException - IF f is neither a named not a tag field || the DTD doesn't contain this section(!!)

addRecordByTag

void addRecordByTag(int tag,
                    Record r)
              throws DTDException
Add a Record to the list of 'records by tag' in this section
Parameters:
tag - the tag
r - the record to add
Throws:
DTDException - IF a record of this tag has already been added

getRecord

public Record getRecord(int tag)
                 throws DTDException
Get a record defined in this section
Parameters:
tag - the tag of the record
Throws:
DTDException - if this section does not contain a record with tag tag

getRecord

public Record getRecord(java.lang.String str)
                 throws DTDException
Get a record defined in this section
Parameters:
str - the name of the record
Throws:
DTDException - if this section does not contain a record named str

getName

public java.lang.String getName()
Returns:
the name of the section

getNumber

public int getNumber()
Returns:
the section's number

getRecords

public java.util.Map getRecords()
Returns:
the records defined in this section: Map

getFields

public java.util.Map getFields()
Returns:
the fields defined in this section: Map

hasRecord

public boolean hasRecord(java.lang.String name)
Does this section define a record?
Parameters:
name - the name of the record
Returns:
whether the section contains this record

hasRecord

public boolean hasRecord(int t)
Does this section define a record?
Parameters:
t - the tag of the record
Returns:
whether the section contains this record

getMaxTag

public int getMaxTag()
Returns:
the largest tag of any record defined in this section

isCached

public boolean isCached()
Returns:
whether this is a cached section

getLine

public int getLine()
Returns:
the number of the line in the DTD where this section's definition started

compareTo

public int compareTo(java.lang.Object s)
Compare sections by number
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
s - the section to compare
Returns:
0 IF section numbers match, 1 IF this section has a higher number, -1 OTHERWISE

dump

public java.lang.String dump(java.lang.String prefix)
Dump a representation of this section
Parameters:
prefix - an identifying prefix
Returns:
a prettified representation of this section

accept

public java.lang.Object accept(DTDVisitor visitor,
                               java.lang.Object data)
Accept the visitor

MetaTF API

Copyright © 2001 - Richard Jones     MetaTF