ua.gradsoft.termware
Class TermWareInstance

java.lang.Object
  extended by ua.gradsoft.termware.TermWareInstance

public class TermWareInstance
extends Object

Instance for TermWare-wide general work. (loading files, keepen domain system and so on)


Constructor Summary
TermWareInstance()
           
 
Method Summary
 void addFacts(Term name, IFacts facts)
          add facts to root domain
 void addJavaFacts(String name, IFacts facts)
          add facts to root domain.
 void addJavaStrategy(String name, String className)
          add strategy with name name and implementation class className
 void addParserFactory(String languageName, IParserFactory parserFactory)
          add parser for language language-name defined by interface IParser.
 void addPrinterFactory(String languageName, IPrinterFactory printerFactory)
          add printer for language language-name defined by interface IPrinter
 void addRuleset(Domain d, TermSystem system, Term ruleset)
          add ruleset ruleset to system system in domain d .
 void addSystem(String name, TermSystem system)
          add system system with name name to root domain.
 void addSystem(Term name, TermSystem system)
          add system system with name name to root domain.
 ITermRewritingStrategy createStrategyByName(String name)
          create instance of strategy with name name (instantiente appropriative class, defined by TermWareaddJavaStrategy(name,name).
 DebugStubGenerator getDebugStubGenerator()
           
 int getDecimalScale()
          get target scale for BigDecimal operations.
 Domain getDomain(String name)
          get domain or throw InvalidDomainName exception is such subdomen does not exists in root domain of this instance.
 SortedSet getDomainNames()
          get names of domains (direct sundomens of root), loaded into current runtime.
 IEnv getEnv()
          get default environment
 IFacts getFacts(String name)
          get facts database from root domain.
 IFacts getFacts(Term name)
          resolve facts in root domain
 Domain getOrCreateDomain(String name)
          get direct subdomain of root domain with name name If such domain does not exists - it's created.
 Domain getOrCreateDomain(Term name)
          get subdomain of root domain with name name If such domain does not exists - it's created.
 IParserFactory getParserFactory(String languageName)
          get parserFactory for language language-name
 IPrinterFactory getPrinterFactory(String languageName)
          get printerFactory for language language-name
 Domain getRoot()
          get root domain
 int getRoundingMode()
          get rounding mode, which used in ariphmetic operations.
 SymbolAdoptionPolicy getSymbolAdoptionPolicy()
           
 SymbolTable getSymbolTable()
           
 TermSystem getSysSystem()
          return "sys" system.
 TermFactory getTermFactory()
          get TermFactory for this instance.
 TermLoader getTermLoader()
          get term loader.
 TypeConversion getTypeConversion()
          return TypeConversion of this instance.
 void init()
          init instance
 void init(String[] args)
          initialize (and parse options before)
 Term load(String name)
          load file with expression in TermWare language.
 Term load(String name, IParserFactory parserFactory, Term parserFactoryArgs)
          load file with name name and return target term.
 void removeFacts(Term name)
           
 void removeParserFactory(String languageName)
          remove parser for language language-name
 void removePrinterFactory(String languageName)
          remove printer for language language-name
 void removeStrategy(String name)
          remove strategy with name name from set of strategies.
 void removeSystem(Term name)
          remove system with name name from root domain.
 TermSystem resolveSystem(String name)
          resolve system in root domain with name name
 TermSystem resolveSystem(Term t)
          resolve system in root domain with name t
 void setDecimalScale(int decimalScale)
          set target scale for BigDecimal operations.
 void setEnv(IEnv env)
          set default environment
 void setOptions(String[] args)
           
 void setParentInstance(TermWareInstance parentInstance)
          set parent instance for this instance.
 void setRoundingMode(int roundingMode)
          set rounding mode, which used in ariphmetic operations.
 void setSymbolAdoptionPolicy(SymbolAdoptionPolicy symbolAdoptionPolicy)
           
 void setTermLoaderClassName(String className)
          ser classname for term loader
 Term sysReduce(Term t)
          reduce term t by default system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TermWareInstance

public TermWareInstance()
Method Detail

init

public void init()
init instance


setOptions

public void setOptions(String[] args)

init

public void init(String[] args)
          throws TermWareException
initialize (and parse options before)

Throws:
TermWareException

addRuleset

public void addRuleset(Domain d,
                       TermSystem system,
                       Term ruleset)
                throws TermWareException
add ruleset ruleset to system system in domain d . System system must exists in d TODO: move to domain.

Throws:
TermWareException

addSystem

public void addSystem(Term name,
                      TermSystem system)
               throws TermWareException
add system system with name name to root domain.

Throws:
TermWareException

addSystem

public void addSystem(String name,
                      TermSystem system)
               throws TermWareException
add system system with name name to root domain.

Throws:
TermWareException

resolveSystem

public TermSystem resolveSystem(Term t)
                         throws TermWareException
resolve system in root domain with name t

Throws:
TermWareException

resolveSystem

public TermSystem resolveSystem(String name)
                         throws TermWareException
resolve system in root domain with name name

Throws:
TermWareException

removeSystem

public void removeSystem(Term name)
                  throws TermWareException
remove system with name name from root domain.

Throws:
TermWareException

addJavaFacts

public void addJavaFacts(String name,
                         IFacts facts)
add facts to root domain.

Parameters:
name - - name of facts database.
facts - - instance of implementation class.

addFacts

public void addFacts(Term name,
                     IFacts facts)
              throws TermWareException
add facts to root domain

Parameters:
name - - name of domain (atom or _name term)
facts - - facts database to add.
Throws:
TermWareException

getFacts

public IFacts getFacts(Term name)
                throws TermWareException
resolve facts in root domain

Throws:
TermWareException

getFacts

public IFacts getFacts(String name)
                throws TermWareException
get facts database from root domain.

Parameters:
name - - name of fact database.
Throws:
TermWareException

removeFacts

public void removeFacts(Term name)
                 throws TermWareException
Throws:
TermWareException

addJavaStrategy

public void addJavaStrategy(String name,
                            String className)
add strategy with name name and implementation class className

Parameters:
name - -- name of strategy
className - -- implementation class for strategy, which must implement ITermRewritingStrategy interface
See Also:
ITermRewritingStrategy

removeStrategy

public void removeStrategy(String name)
remove strategy with name name from set of strategies.


createStrategyByName

public ITermRewritingStrategy createStrategyByName(String name)
                                            throws TermWareException
create instance of strategy with name name (instantiente appropriative class, defined by TermWareaddJavaStrategy(name,name).

Throws:
TermWareException

getOrCreateDomain

public Domain getOrCreateDomain(Term name)
                         throws TermWareException
get subdomain of root domain with name name If such domain does not exists - it's created.

Parameters:
name - - name of domain to get. name must be string or atom or denote compound name, i. e. have form _name(t1 ... tN) .
Throws:
AssertException, - if name is not name term.
TermWareException

getOrCreateDomain

public Domain getOrCreateDomain(String name)
                         throws TermWareException
get direct subdomain of root domain with name name If such domain does not exists - it's created.

Parameters:
name - - name of domain to get.
Throws:
TermWareException

getDomain

public Domain getDomain(String name)
                 throws TermWareException
get domain or throw InvalidDomainName exception is such subdomen does not exists in root domain of this instance.

Throws:
TermWareException

getSysSystem

public TermSystem getSysSystem()
return "sys" system.


getDomainNames

public SortedSet getDomainNames()
get names of domains (direct sundomens of root), loaded into current runtime.


load

public Term load(String name)
          throws TermWareException
load file with expression in TermWare language.

Parameters:
name - - name of file to load.
Returns:
term from file
Throws:
TermWareException

load

public Term load(String name,
                 IParserFactory parserFactory,
                 Term parserFactoryArgs)
          throws TermWareException
load file with name name and return target term.

Parameters:
name - - name of file to load.
parserFactory - - parserFactory to use.
parserFactoryArgs - - additional arguments to parserFactory.
Returns:
term from default term loader.
Throws:
TermWareException
See Also:
TermLoader, FileOrClassTermLoader

addParserFactory

public void addParserFactory(String languageName,
                             IParserFactory parserFactory)
add parser for language language-name defined by interface IParser.


removeParserFactory

public void removeParserFactory(String languageName)
remove parser for language language-name


getParserFactory

public IParserFactory getParserFactory(String languageName)
                                throws IllegalParserNameException
get parserFactory for language language-name

Throws:
IllegalParserNameException
See Also:
IParserFactory, IParser

addPrinterFactory

public void addPrinterFactory(String languageName,
                              IPrinterFactory printerFactory)
add printer for language language-name defined by interface IPrinter


removePrinterFactory

public void removePrinterFactory(String languageName)
remove printer for language language-name


getPrinterFactory

public IPrinterFactory getPrinterFactory(String languageName)
                                  throws IllegalPrinterNameException
get printerFactory for language language-name

Throws:
IllegalPrinterNameException
See Also:
IPrinterFactory, IPrinter

sysReduce

public Term sysReduce(Term t)
               throws TermWareException
reduce term t by default system.

Throws:
TermWareException

getTermLoader

public TermLoader getTermLoader()
get term loader.


setTermLoaderClassName

public void setTermLoaderClassName(String className)
                            throws ClassNotFoundException,
                                   InstantiationException,
                                   IllegalAccessException
ser classname for term loader

Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

getRoundingMode

public int getRoundingMode()
get rounding mode, which used in ariphmetic operations.

See Also:
BigDecimal

setRoundingMode

public void setRoundingMode(int roundingMode)
set rounding mode, which used in ariphmetic operations.

See Also:
BigDecimal

getDecimalScale

public int getDecimalScale()
get target scale for BigDecimal operations.

See Also:
BigDecimal.divide(java.math.BigDecimal, int, int)

setDecimalScale

public void setDecimalScale(int decimalScale)
set target scale for BigDecimal operations.

See Also:
BigDecimal.divide(java.math.BigDecimal, int, int)

getRoot

public Domain getRoot()
get root domain

Returns:
root domain

getEnv

public IEnv getEnv()
get default environment


setEnv

public void setEnv(IEnv env)
set default environment


getTermFactory

public TermFactory getTermFactory()
get TermFactory for this instance.

See Also:
TermFactory

setParentInstance

public void setParentInstance(TermWareInstance parentInstance)
set parent instance for this instance.


getSymbolTable

public final SymbolTable getSymbolTable()

getSymbolAdoptionPolicy

public final SymbolAdoptionPolicy getSymbolAdoptionPolicy()

setSymbolAdoptionPolicy

public final void setSymbolAdoptionPolicy(SymbolAdoptionPolicy symbolAdoptionPolicy)

getDebugStubGenerator

public DebugStubGenerator getDebugStubGenerator()

getTypeConversion

public final TypeConversion getTypeConversion()
return TypeConversion of this instance.