org.simantics.databoard.parser.repository
Class DataTypeRepository

java.lang.Object
  extended by org.simantics.databoard.parser.repository.DataTypeRepository

public class DataTypeRepository
extends java.lang.Object

Type repository maintains a mapping from strings to data types. It can also convert abstract syntax trees to data types.

Author:
Hannu Niemistö

Constructor Summary
DataTypeRepository()
           
 
Method Summary
 void add(java.util.List<AstTypeDefinition> definitions)
          Adds all type definitions to the repository.
 DataType add(java.lang.String name, AstType ast)
          Adds a type to the repository.
 void add(java.lang.String name, DataType type)
          Adds a type to the repository.
 void addDefinition(DataTypeDefinition def)
          Add a type definition to the repository.
 void addDefinitions(DataTypeDefinition... defs)
          Add a type definitions to the repository.
 void addDefinitions(java.io.InputStream definitions)
           
 void addDefinitions(java.lang.String definitions)
          Parses and adds type definitions to the repository.
 boolean contains(DataType type)
           
 boolean contains(java.lang.String name)
           
 java.lang.String get(DataType type)
           
 DataType get(java.lang.String name)
          Gets a data type in the repository.
 java.util.Set<java.lang.String> getTypeNames()
           
 java.lang.String toString()
           
 DataType translate(AstType ast)
          Translates an unnamed data type.
 DataType translate(java.lang.String typeString)
          Parses an unnamed data type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataTypeRepository

public DataTypeRepository()
Method Detail

add

public void add(java.lang.String name,
                DataType type)
Adds a type to the repository.

Parameters:
name - Name of the type
type - Type to be added

get

public DataType get(java.lang.String name)
Gets a data type in the repository.

Parameters:
name -
Returns:
the data type

get

public java.lang.String get(DataType type)

contains

public boolean contains(java.lang.String name)

contains

public boolean contains(DataType type)

getTypeNames

public java.util.Set<java.lang.String> getTypeNames()
Returns:
a view of all data types defined in this repository.

addDefinitions

public void addDefinitions(DataTypeDefinition... defs)
Add a type definitions to the repository.

Parameters:
defs - type definitions

addDefinition

public void addDefinition(DataTypeDefinition def)
Add a type definition to the repository.

Parameters:
def - type definition

add

public DataType add(java.lang.String name,
                    AstType ast)
             throws DataTypeSyntaxError
Adds a type to the repository.

Parameters:
name - Name of the type
ast - Abstract syntax tree of the type to be added
Returns:
Translated data type
Throws:
DataTypeSyntaxError

add

public void add(java.util.List<AstTypeDefinition> definitions)
         throws DataTypeSyntaxError
Adds all type definitions to the repository.

Parameters:
definitions - Abstract syntax trees of the definitions
Throws:
DataTypeSyntaxError

addDefinitions

public void addDefinitions(java.lang.String definitions)
                    throws DataTypeSyntaxError
Parses and adds type definitions to the repository.

Parameters:
definitions - Definitions in textual format.
Throws:
DataTypeSyntaxError

addDefinitions

public void addDefinitions(java.io.InputStream definitions)
                    throws java.io.IOException,
                           DataTypeSyntaxError
Throws:
java.io.IOException
DataTypeSyntaxError

translate

public DataType translate(AstType ast)
                   throws DataTypeSyntaxError
Translates an unnamed data type.

Parameters:
ast - Abstract syntax tree of the type to be translated
Returns:
Translated data type
Throws:
DataTypeSyntaxError

translate

public DataType translate(java.lang.String typeString)
                   throws DataTypeSyntaxError
Parses an unnamed data type.

Parameters:
typeString - The textual representation of the type to be translated
Returns:
Translated data type
Throws:
DataTypeSyntaxError

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object