|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object blog.Model
public class Model
This class contains all the information available about the structure of the model. In particular, it keeps lists of user-defined types and functions. Attributes of those types and functions are stored in the individual Type and Function objects.
Please note that the mutator methods contain little error-checking, if any.Since the type- and semantic checking of the model is done dynamically while the model file is being parsed, it is assumed that if an error occurs it is caught by the type/semantic checker.
Field Summary | |
---|---|
protected java.util.List |
functions
Stores user-defined Function objects in the order they were declared. |
protected java.util.Map |
functionsByName
Maps function names to lists of functions with that name (and different argument types). |
static java.lang.Object |
MULTIPLE_FUNCTIONS
Value returned by getRandomFunc when there are multiple random functions with the given name. |
static java.lang.Object |
NULL
The BLOG null value. |
protected java.util.List<fove.Parfactor> |
parfactors
Parfactors, in the order they were defined. |
protected java.util.List |
types
Stores user-defined Type objects in the order they were declared. |
protected java.util.Map |
typesByName
Maps type names to Type objects. |
Constructor Summary | |
---|---|
Model()
Class constructor. |
Method Summary | |
---|---|
NonRandomFunction |
addEnumeratedObject(java.lang.String name,
Type type)
Adds to the model a non-random constant with the given name, denoting a new enumerated object of the given type. |
void |
addFunction(Function f)
Adds the given user-defined function to this model. |
void |
addParfactor(fove.Parfactor pf)
Adds the given parfactor to this model. |
void |
addType(java.lang.String typeName)
Creates a new user-defined type with the given name and adds it to this model. |
boolean |
checkCompleteness()
Returns true if every random function has a dependency statement, or if the model contains at least one parfactor. |
boolean |
checkTypesAndScope()
Check types and scopes in the model. |
static int |
compareArgs(java.lang.Object obj1,
java.lang.Object obj2)
Compares two objects that can serve as arguments to basic random variables. |
static int |
compareArgTuples(java.lang.Object[] objs1,
java.lang.Object[] objs2)
Returns a number that is negative, positive, or zero according to whether objs1 comes before, after, or at the same place as
objs2 in a lexicographic ordering. |
int |
compile()
Does compilation steps that can only be done correctly once the model is complete. |
boolean |
existsType(java.lang.String typeName)
Checks whether the specified type has been defined. |
Function |
getApplicableFunc(java.lang.String name,
Type[] types)
Returns the user-defined or built-in Function with the given name that is applicable to the given type list, or null if no such function exists. |
java.lang.Object |
getConstantValue(java.lang.String name)
Returns the value of the non-random constant with the given name, or null if there is no such non-random constant. |
java.util.Collection |
getFuncsWithName(java.lang.String name)
Returns all user-defined or built-in functions with the given name. |
Function |
getFunction(Function.Sig sig)
Returns the user-defined or built-in Function object with the specified signature, or null if no such function exists. |
java.util.Collection |
getFunctions()
Returns the user-defined functions in this model. |
java.util.Set |
getListedTypes(java.lang.String typeList)
Returns a Set consisting of the user-defined types named in the given string. |
static int |
getObjectIndex(java.lang.Object obj)
Returns the index of the given object among objects of its type. |
java.util.Collection |
getOverlappingFuncs(java.lang.String name,
Type[] types)
Returns the user-defined or built-in functions with the given name that could apply to some tuple of objects with the given types. |
java.util.List<fove.Parfactor> |
getParfactors()
Returns the parfactors in this model, in the order they were declared. |
java.lang.Object |
getRandomFunc(java.lang.String name,
int numArgs)
Returns the unique random function with the given name and number of arguments. |
Type |
getType(java.lang.String typeName)
Returns the type information for the given type. |
java.util.Collection |
getTypes()
Returns the user-defined types in this model. |
static int |
nextCreationIndex()
Returns a number that is one greater than the last number returned by this method. |
void |
print(java.io.PrintStream s)
Prints this model to the given stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object NULL
equals
to compare BLOG
objects, and methods can return null as an error indicator without
worrying about the possibility that a BLOG value might actually
be null.
public static final java.lang.Object MULTIPLE_FUNCTIONS
protected java.util.List types
protected java.util.Map typesByName
protected java.util.List functions
protected java.util.Map functionsByName
protected java.util.List<fove.Parfactor> parfactors
Constructor Detail |
---|
public Model()
Method Detail |
---|
public void addType(java.lang.String typeName)
public boolean existsType(java.lang.String typeName)
public Type getType(java.lang.String typeName)
public java.util.Collection getTypes()
public java.util.Set getListedTypes(java.lang.String typeList)
If some of the named types are undefined, this method prints an error message and returns null.
public void addFunction(Function f)
java.lang.IllegalStateException
- if there is already a user-defined
function with the same signaturepublic Function getFunction(Function.Sig sig)
public java.util.Collection getFuncsWithName(java.lang.String name)
public Function getApplicableFunc(java.lang.String name, Type[] types)
public java.util.Collection getOverlappingFuncs(java.lang.String name, Type[] types)
public java.lang.Object getRandomFunc(java.lang.String name, int numArgs)
public java.util.Collection getFunctions()
public java.lang.Object getConstantValue(java.lang.String name)
public NonRandomFunction addEnumeratedObject(java.lang.String name, Type type)
getValue()
method.public void addParfactor(fove.Parfactor pf)
public java.util.List<fove.Parfactor> getParfactors()
public void print(java.io.PrintStream s)
public boolean checkTypesAndScope()
compile
is that this method does all its processing in
the order in which functions were declared, whereas
compile
may jump around following the uses of nonrandom
functions.
public boolean checkCompleteness()
public int compile()
public static int nextCreationIndex()
public static int compareArgs(java.lang.Object obj1, java.lang.Object obj2)
public static int compareArgTuples(java.lang.Object[] objs1, java.lang.Object[] objs2)
objs1
comes before, after, or at the same place as
objs2
in a lexicographic ordering.
objs1
- an array of BLOG objects that can serve as argumentsobjs2
- an array of BLOG objects that can serve as argumentspublic static int getObjectIndex(java.lang.Object obj)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |