Stefy

stefy.avm
Class TypeHierarchyX

java.lang.Object
  |
  +--stefy.avm.TypeHierarchyX

public class TypeHierarchyX
extends java.lang.Object

TypeHierarchyX class (DD) implements a hierarchy of types. It provides operations for defining new types, finding type names, building the type hierarchy, etc.

In order to bring an TypeHierarchy instance to a consistent state, the method normalize has to be executed.


Field Summary
static boolean Strict
          If true, then a type has to be added before specifying any sub-type relations that includes it, and types can be included in type hierarchy on the fly.
 
Constructor Summary
TypeHierarchyX()
          Constructor.
TypeHierarchyX(java.lang.String top, java.lang.String bot)
          Constructor.
 
Method Summary
 void addRelations(java.lang.String relations)
          Add type relations.
 void addType(java.lang.String name)
          Add a new type.
 void addType(java.lang.String name, java.lang.String parents)
          Add a type and define its parents.
 TypeHierarchyX compile(java.lang.String s)
          Compiles a type hierarchy specification from a string.
 TypeHierarchyX compile(Tokenizer tok)
          Compiles a type hierarchy using a tokenizer.
 void defineBotName(java.lang.String name)
          Define name of the bottom type.
 void defineTopName(java.lang.String name)
          Define name of the top type.
 Type getTopType()
          Get a clone of top type
 Type getType(java.lang.String name)
          Get type by name.
 java.lang.String getTypeName(Type t)
          Get a type name.
 TypeX[] getTypes(boolean includeNat)
          Get an array of types.
static Tokenizer init(Tokenizer tok)
          Tokenizer initialization, done before compiling a TypeHierarchy.
 void normalize()
           
 java.lang.String toString()
          Prints out a type hierarchy, which can be compiled by the method compile(String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Strict

public static boolean Strict
If true, then a type has to be added before specifying any sub-type relations that includes it, and types can be included in type hierarchy on the fly.
Constructor Detail

TypeHierarchyX

public TypeHierarchyX(java.lang.String top,
                      java.lang.String bot)
Constructor.
Parameters:
top - The name of the top type.
bot - The name of the bottom type.

TypeHierarchyX

public TypeHierarchyX()
Constructor. Adds two types: bot and top.
Method Detail

defineTopName

public void defineTopName(java.lang.String name)
Define name of the top type.
Parameters:
name - top type name

defineBotName

public void defineBotName(java.lang.String name)
Define name of the bottom type.
Parameters:
name - bot type name

getType

public Type getType(java.lang.String name)
Get type by name.
Parameters:
name - type type name
Returns:
the type

getTopType

public Type getTopType()
Get a clone of top type
Returns:
the top type

getTypeName

public java.lang.String getTypeName(Type t)
Get a type name.
Parameters:
t - the type
Returns:
type name

getTypes

public TypeX[] getTypes(boolean includeNat)
Get an array of types.
Parameters:
includeNat - if true not-a-type is include, otherwise it is not included
Returns:
the array

addType

public void addType(java.lang.String name)
Add a new type.
Parameters:
name - the name of the type

addType

public void addType(java.lang.String name,
                    java.lang.String parents)
Add a type and define its parents.
Parameters:
name - the name of the new type
parents - the parents in the form "p1,p2,..."

addRelations

public void addRelations(java.lang.String relations)
Add type relations.
Parameters:
relations - in the form "parent:child,P:c:grandchild..."

init

public static Tokenizer init(Tokenizer tok)
Tokenizer initialization, done before compiling a TypeHierarchy.
Parameters:
tok - the tokenizer.
Returns:
the same tokenizer.

compile

public TypeHierarchyX compile(java.lang.String s)
Compiles a type hierarchy specification from a string. The compiled information is added to existing information.
Parameters:
s - input string
See Also:
compile(Tokenizer)

compile

public TypeHierarchyX compile(Tokenizer tok)
                       throws java.io.IOException
Compiles a type hierarchy using a tokenizer. The compiled information is added to existing information. An implicit call to normalize() method is used.

Format example:

!define top name: *top*.
!define bot name: *bot*.
list. nlist :< list. elist:< list.
t. t1. t2. employee. dept.
Parameters:
tok - the input tokenizer

normalize

public void normalize()

toString

public java.lang.String toString()
Prints out a type hierarchy, which can be compiled by the method compile(String).
Overrides:
toString in class java.lang.Object
Returns:
string representation.

Stefy

Submit a bug or feature
Copyright 1998-2004 Vlado Keselj. All Rights Reserved.