MetaTF API

MetaTF.Parser
Class NamedField

java.lang.Object
  |
  +--MetaTF.Parser.Field
        |
        +--MetaTF.Parser.NamedField
All Implemented Interfaces:
HasFields

public class NamedField
extends Field

Named field

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

Fields inherited from class MetaTF.Parser.Field
beginLine
 
Fields inherited from interface MetaTF.Parser.HasFields
cvsheader
 
Constructor Summary
(package private) NamedField(java.lang.String s)
          Allocate a new object representing a named field
(package private) NamedField(java.lang.String s, int l)
          Allocate a new object representing a named field
(package private) NamedField(java.lang.String t, java.lang.String s, java.lang.String p, Value v)
          Allocate a new object representing a named field
(package private) NamedField(java.lang.String t, java.lang.String s, java.lang.String p, Value v, int l)
          Allocate a new object representing a named field
 
Method Summary
 java.lang.Object accept(DTDVisitor visitor, java.lang.Object data)
          Accept the visitor
 void addField(Field f)
          Add a subfield to this field
 boolean addProperty(java.lang.String type, java.lang.String field, java.lang.String property, Value value, int l)
          Add a property to this field
 void addProperty(java.lang.String p, Value v, int l)
          Add property p=v to this field
(package private)  void checkFields()
          Check that this field is well formed.
 boolean containsField(java.lang.String s)
          Does this field contain a named subfield?
 java.lang.String dump(java.lang.String prefix)
          Dump this field
 java.lang.String getName()
           
 int getNumNamedFields()
           
 java.util.Map getProperties()
           
 Value getProperty(java.lang.String name)
           
 int getTag()
          Get the tag of this field
 java.lang.String getType()
           
 java.lang.String getType(java.lang.String fname)
          Get the type of the field if it matches the name given
 boolean hasProperty(java.lang.String name)
          Does this field have a given property?
 boolean isTagged()
          Is this field tagged?
(package private)  Field replaceFields(java.util.Map inheritedRecords0, java.util.Map inheritedRecords, java.util.Map inheritedFields)
          Do a macro replacement of any fields that do not have properties defined locally.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedField

NamedField(java.lang.String t,
           java.lang.String s,
           java.lang.String p,
           Value v,
           int l)
Allocate a new object representing a named field
Parameters:
t - the type
s - the name of the field
p - the property
v - the value
l - the line in the DTD at which this field was defined

NamedField

NamedField(java.lang.String t,
           java.lang.String s,
           java.lang.String p,
           Value v)
Allocate a new object representing a named field
Parameters:
t - the type
s - the name of the field
p - the property
v - the value

NamedField

NamedField(java.lang.String s,
           int l)
Allocate a new object representing a named field
Parameters:
s - the name of the field
l - the line in the DTD at which this field was defined

NamedField

NamedField(java.lang.String s)
Allocate a new object representing a named field
Parameters:
s - the name of the field
Method Detail

getName

public java.lang.String getName()
Overrides:
getName in class Field
Following copied from class: MetaTF.Parser.Field
Returns:
the name of the field

getProperties

public java.util.Map getProperties()
Returns:
a Map of the fields properties
See Also:
Value

hasProperty

public boolean hasProperty(java.lang.String name)
Does this field have a given property?
Parameters:
name - the name
Returns:
whether the field has property name

getProperty

public Value getProperty(java.lang.String name)
Parameters:
name - the name of the property
Returns:
a property
See Also:
Value

replaceFields

Field replaceFields(java.util.Map inheritedRecords0,
                    java.util.Map inheritedRecords,
                    java.util.Map inheritedFields)
Description copied from class: Field
Do a macro replacement of any fields that do not have properties defined locally.
Overrides:
replaceFields in class Field
Following copied from class: MetaTF.Parser.Field
Parameters:
inheritedRecords0 - Map of records inherited from section 0
inheritedRecords - Map of records inherited from this section
inheritedFields - Map of inherited fields
Returns:
the modified field

checkFields

void checkFields()
           throws DTDException
Check that this field is well formed. 1. It must have a type 2. The only allowed property is 'encoding' 3. The property must have a value
      type==string --> value is none or default 
      type==index  --> value is sectionOffset, sectionStride or default
      otherwise    --> the type may not be sectionOffset, sectionStride,
                       default  or a number
 
All macro substition must be done before checkFields is called
Overrides:
checkFields in class Field
Throws:
DTDException - IF this field is not well-formed
See Also:
replaceFields(java.util.Map, java.util.Map, java.util.Map)

containsField

public boolean containsField(java.lang.String s)
Description copied from class: Field
Does this field contain a named subfield?
Overrides:
containsField in class Field
Following copied from class: MetaTF.Parser.Field
Parameters:
s - the name of the subfield
Returns:
whether this field contains a subfield named s

addProperty

public void addProperty(java.lang.String p,
                        Value v,
                        int l)
                 throws DTDException
Add property p=v to this field

addProperty

public boolean addProperty(java.lang.String type,
                           java.lang.String field,
                           java.lang.String property,
                           Value value,
                           int l)
                    throws DTDException
Add a property to this field
Overrides:
addProperty in class Field
Parameters:
type - the type
field - the name of the field. The property is only added if the field names match
property - the property (default 'encoding')
value - the value of the property
beginLine - the line in the DTD at which this property was defined
Throws:
DTDException - IF
    1. this field already has this property defined
    2. the type is already set
    3. the type is string but the value is not default  or none
       the type is index but the value is not sectionOffset, sectionStride or default
       otherwise, if the value is sectionOffset, sectionStride, default 
       or a number
 

addField

public void addField(Field f)
Description copied from class: Field
Add a subfield to this field
Overrides:
addField in class Field
Following copied from class: MetaTF.Parser.Field
Parameters:
f - the subfield

getNumNamedFields

public int getNumNamedFields()
Overrides:
getNumNamedFields in class Field
Following copied from class: MetaTF.Parser.Field
Returns:
the number of named subfields of this field

getTag

public int getTag()
           throws NoTagException
Get the tag of this field
Overrides:
getTag in class Field
Throws:
NoTagException - ALWAYS

isTagged

public boolean isTagged()
Description copied from class: Field
Is this field tagged?
Overrides:
isTagged in class Field
Following copied from class: MetaTF.Parser.Field
Returns:
whether the field is tagged

getType

public java.lang.String getType()
Overrides:
getType in class Field
Following copied from class: MetaTF.Parser.Field
Returns:
the type of the field

getType

public java.lang.String getType(java.lang.String fname)
Get the type of the field if it matches the name given
Parameters:
fname - the name of the field whose type is required
Returns:
the type IF fname matches ELSE null

dump

public java.lang.String dump(java.lang.String prefix)
Description copied from class: Field
Dump this field
Overrides:
dump in class Field
Following copied from class: MetaTF.Parser.Field
Returns:
a prettified representation of this field

accept

public java.lang.Object accept(DTDVisitor visitor,
                               java.lang.Object data)
Description copied from class: Field
Accept the visitor
Overrides:
accept in class Field

MetaTF API

Copyright © 2001 - Richard Jones     MetaTF