Stefy

stefy.avm
Class VariableX

java.lang.Object
  |
  +--stefy.avm.VariableX
Direct Known Subclasses:
RuleX

public class VariableX
extends java.lang.Object

VariableX class, DD. The VariableX class is used to separate DD functionallity from the class Variable. It provides methods for building AVMs, printing AVMs, etc.


Field Summary
static int current_tuple_id
          Useful information for semantic calculation.
 Variable o
           
static boolean PrintInternals
          If true, printing AVMs includes some internal information.
static int SMODE_ASSERT
          Search mode with assert (fails if a path does not exist).
static int SMODE_CREATE
          Search mode with creation of path if necessary and if possible.
static int SMODE_N
          Search mode that returns a null (or equivalent) if path does not exist or not possible.
static int SMODE_NCREATE
          Search mode that will create a path if necessary and if possible.
static int SMODE_OCREATE
          Search mode with overriding creation of path and value if necessary.
 
Constructor Summary
VariableX()
          Constructor.
VariableX(AttributeSet a, TypeHierarchyX tl)
          Constructor.
VariableX(java.lang.String s)
          Constructor.
VariableX(Variable v)
          Constructor.
VariableX(Variable v, AttributeSet a, TypeHierarchyX t)
          Constructor.
 
Method Summary
 void addPair(java.lang.String p, java.lang.String atom)
           
 void addPair(java.lang.String p, Variable v)
           
 VariableX compile(java.lang.String s)
          Compiles string into this variablex and returns this.
static VariableX compileS(java.lang.String s)
          Compiles a new variableX and returns it.
 VariableX compileVariable(Tokenizer tok, java.util.HashMap hash)
           
 VariableX duplicateAndSeparate()
           
static boolean equal(java.lang.Object o1, java.lang.Object o2)
          Compares two variables or objects whether they have equal values.
 Variable findSet()
          Find the set representative (non-static method).
static Variable findSet(Variable o)
          Find the set representative (FIND-UNION data structure) (static method).
protected static java.lang.Object get_p(Variable v)
          Gets the value of immediate variable reference (can be another variable).
 Variable get(java.lang.String p)
          Gets a sub-AVM, fails if the path does not exist (fatal error).
 Variable get(java.lang.String p, int smode)
          Get value from an AVM using path.
 Variable getA(java.lang.String p)
           
static Variable[] getAllSubAVMs(Variable v)
          Get an array of all sub-AVMs of a given AVM.
static Variable getAS(Variable v, java.lang.String p)
          Static method for getting a sub-AVM.
 Variable getF(java.lang.String p)
           
 Variable getHelper(java.lang.String p, int f)
           
 Variable getN(java.lang.String p)
          Gets a sub-AVM.
static Variable getNS(Variable v, java.lang.String p)
           
static Variable getOS(Variable v, java.lang.String p)
          Static method for getting a sub-AVM.
static java.lang.Object getS_p(Variable o, java.lang.String p, int smode)
          Get the actual object in the path.
static Variable getS(Variable o, java.lang.String p, int smode)
          Get value from an AVM using path (static).
 Type getType()
          Gets the type of an AVM.
 Type getType(java.lang.String p)
          Gets the type of the AVM specified by a path.
 java.lang.String getTypeName(java.lang.String p)
          Get type name from the path.
static Type getTypeS(Variable v1, java.lang.String p)
          Static function to get a type.
static java.lang.Object getValue(Variable o)
          Gets the set value.
static Tokenizer init(Tokenizer tok)
          Tokenizer initialization.
static java.lang.String insertPrefix(java.lang.String s, java.lang.String pref, int mode)
          General string-manipulation function for inserting prefixes.
static boolean isAtom(Variable v)
          Verify whether this variable contains an atom, a static method.
static boolean isAVMS(Variable v)
          Verify whether this variable contains an AVM, a static method.
static Variable newVariable(java.lang.String type)
          Creates a new variable that contains an AVM.
static void remove(Variable v, java.lang.String p)
          Removes a value.
 Variable set(java.lang.String p, java.lang.Object o, int smode)
          Sets the value in an AVM.
static void setOS(Variable v, java.lang.String p, java.lang.String a)
          Set a value to an atom.
static Variable setS(Variable v, java.lang.String p, java.lang.Object o, int smode)
          Sets the value in an AVM (static method).
 void setType(java.lang.String p, java.lang.String t)
          Sets a type of a basic AVM, use "" to set the root.
 java.lang.String toString()
          Returns a string representation of the object variable.
 java.lang.String toString(CBFilterAVMTupleX filterAVM)
          Returns a string representation of the object variable.
static java.lang.String toString(Variable v)
          Returns a string representation of the given variable (static version).
static java.lang.String toString(Variable v, AttributeSet attSet, TypeHierarchyX tLat, CBFilterAVMTupleX avmFilter)
          Returns a string representation of the given variable (static version).
static java.lang.String toString(Variable v, CBFilterAVMTupleX filterAVM)
          Returns a string representation of the given variable (static version).
static java.lang.String toString2S(Variable v, java.util.Map ref, int[][] count, AttributeSet attSet, TypeHierarchyX tlat, CBFilterAVMTupleX filterAVM)
           
 java.lang.String toStringShort()
          A short string representation of a variable.
static java.lang.String toStringShort(Variable o)
          A short string representation of a variable (static version).
 java.lang.String toStringType()
          The name of the root type.
 VariableX unify(VariableX other, int mode)
          Unify this variablex destructively with other variablex and return the result.
static void walkAndMarkS(Variable v, java.util.Map ref, int[][] count, Variable[][] vars)
          General purpose depth-first walker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PrintInternals

public static boolean PrintInternals
If true, printing AVMs includes some internal information.

o

public Variable o

SMODE_ASSERT

public static final int SMODE_ASSERT
Search mode with assert (fails if a path does not exist).

SMODE_CREATE

public static final int SMODE_CREATE
Search mode with creation of path if necessary and if possible. Fails if not possible.

SMODE_N

public static final int SMODE_N
Search mode that returns a null (or equivalent) if path does not exist or not possible.

SMODE_OCREATE

public static final int SMODE_OCREATE
Search mode with overriding creation of path and value if necessary.

SMODE_NCREATE

public static final int SMODE_NCREATE
Search mode that will create a path if necessary and if possible. Returns null if not possible.

current_tuple_id

public static int current_tuple_id
Useful information for semantic calculation.
Constructor Detail

VariableX

public VariableX(Variable v,
                 AttributeSet a,
                 TypeHierarchyX t)
Constructor.
Parameters:
v - handled variable
a - associated attribute set
t - associated type hierarcy

VariableX

public VariableX(Variable v)
Constructor.
Parameters:
v - handled variable

VariableX

public VariableX()
Constructor. The handled variable is implicitly created. Static fields are used to get the last used attribute set and the type hierarchy.

VariableX

public VariableX(AttributeSet a,
                 TypeHierarchyX tl)
Constructor. The handled variable is implicitly created.
Parameters:
a - the associated attribute set
tl - the associated type hierarchy.

VariableX

public VariableX(java.lang.String s)
Constructor. The handled variable is implicitly created. Static fields are used to get the last used attribute set and the type hierarchy. Compiles the string into the variable.
Parameters:
s - the source string
Method Detail

unify

public VariableX unify(VariableX other,
                       int mode)
Unify this variablex destructively with other variablex and return the result.
Parameters:
other - the other variablex
mode - unification mode (UNIFY_D, UNIFY_N, or UNIFY_S)
Returns:
this if succeeds, null otherwise

duplicateAndSeparate

public VariableX duplicateAndSeparate()

addPair

public void addPair(java.lang.String p,
                    Variable v)

addPair

public void addPair(java.lang.String p,
                    java.lang.String atom)

getType

public Type getType()
Gets the type of an AVM.
Returns:
the AVM type
See Also:
getTypeS(stefy.avm.Variable, java.lang.String)

get_p

protected static java.lang.Object get_p(Variable v)
Gets the value of immediate variable reference (can be another variable).
Returns:
immediate reference

getType

public Type getType(java.lang.String p)
Gets the type of the AVM specified by a path.
Parameters:
p - the path
Returns:
type of the AVM
See Also:
getTypeS(stefy.avm.Variable, java.lang.String)

getTypeS

public static Type getTypeS(Variable v1,
                            java.lang.String p)
Static function to get a type.
Parameters:
v1 - the root AVM
p - the path
Returns:
type of AVM

getTypeName

public java.lang.String getTypeName(java.lang.String p)
Get type name from the path.
Parameters:
p - path
Returns:
type name

setType

public void setType(java.lang.String p,
                    java.lang.String t)
Sets a type of a basic AVM, use "" to set the root.
Parameters:
p - path
t - the type name

isAVMS

public static boolean isAVMS(Variable v)
Verify whether this variable contains an AVM, a static method.
Parameters:
v - a variable
Returns:
true if it is an AVM, false otherwise

isAtom

public static boolean isAtom(Variable v)
Verify whether this variable contains an atom, a static method.
Parameters:
v - a variable
Returns:
true if it is an Atom, false otherwise

newVariable

public static Variable newVariable(java.lang.String type)
Creates a new variable that contains an AVM.
Parameters:
type - the root type of AVM
Returns:
the variable

get

public Variable get(java.lang.String p)
Gets a sub-AVM, fails if the path does not exist (fatal error).
Parameters:
p - path
Returns:
sub-AVM

getF

public Variable getF(java.lang.String p)

getN

public Variable getN(java.lang.String p)
Gets a sub-AVM. Returns null if the path does not exist.
Parameters:
p - path
Returns:
sub-AVM

getAS

public static Variable getAS(Variable v,
                             java.lang.String p)
Static method for getting a sub-AVM. Fails (fatal error) if the path does not exist.
Parameters:
v - variable containing the AVM
p - the path
Returns:
the sub-AVM, or null if path does not exist.
See Also:
SMODE_ASSERT

getA

public Variable getA(java.lang.String p)

getOS

public static Variable getOS(Variable v,
                             java.lang.String p)
Static method for getting a sub-AVM. Creates path or overrides it, if exists (SMODE_OCREATE). the path does not exist.
Parameters:
v - variable containing the AVM
p - the path
Returns:
the sub-AVM, or null if path does not exist.
See Also:
getS(stefy.avm.Variable, java.lang.String, int), SMODE_OCREATE

getNS

public static Variable getNS(Variable v,
                             java.lang.String p)

getHelper

public Variable getHelper(java.lang.String p,
                          int f)

set

public Variable set(java.lang.String p,
                    java.lang.Object o,
                    int smode)
Sets the value in an AVM.
See Also:
setS(stefy.avm.Variable, java.lang.String, java.lang.Object, int)

setS

public static Variable setS(Variable v,
                            java.lang.String p,
                            java.lang.Object o,
                            int smode)
Sets the value in an AVM (static method). The value is unified with the existing value, except in the SMODE_OCREATE mode.
Parameters:
v - root AVM
p - path to the value
o - the value
smode: -
SMODE_ASSERT
Search mode with assert (fails if a path does not exist).
SMODE_CREATE
Search mode with creation of path if necessary and if possible. Fails if not possible.
SMODE_N
Search mode that returns a null (or equivalent) if path does not exist.
SMODE_OCREATE
Search mode with overriding creation of path and value if necessary.
SMODE_NCREATE
Search mode with creation of path if necessary and if possible. Returns null if not possible.
Returns:
the value or null if not successful

setOS

public static void setOS(Variable v,
                         java.lang.String p,
                         java.lang.String a)
Set a value to an atom. Overrides existing path (SMODE_OCREATE).
Parameters:
v - the variable
p - the path
a - the atom

remove

public static void remove(Variable v,
                          java.lang.String p)
Removes a value.
Parameters:
v - the variable
p - the path

getS

public static Variable getS(Variable o,
                            java.lang.String p,
                            int smode)
Get value from an AVM using path (static).
Parameters:
o - variable handled by this static method
p - path
smode: -
SMODE_ASSERT
Search mode with assert (fails if a path does not exist).
SMODE_CREATE
Search mode with creation of path if necessary and if possible. Fails if not possible.
SMODE_N
Search mode that returns a null (or equivalent) if path does not exist.
SMODE_OCREATE
Search mode with overriding creation of path and value if necessary.
SMODE_NCREATE
Search mode with creation of path if necessary and if possible. Returns null if not possible.

getS_p

public static java.lang.Object getS_p(Variable o,
                                      java.lang.String p,
                                      int smode)
Get the actual object in the path.
Parameters:
o - the handled variable
p - path
smode: -
SMODE_ASSERT
Search mode with assert (fails if a path does not exist).
SMODE_CREATE
Search mode with creation of path if necessary and if possible. Fails if not possible.
SMODE_N
Search mode that returns a null (or equivalent) if path does not exist.
SMODE_OCREATE
Search mode with overriding creation of path and value if necessary.
SMODE_NCREATE
Search mode with creation of path if necessary and if possible. Returns null if not possible.
Returns:
the object, or possibly null in SMODE_N and SMODE_NCREATE modes.

get

public Variable get(java.lang.String p,
                    int smode)
Get value from an AVM using path.
See Also:
getS(stefy.avm.Variable, java.lang.String, int)

findSet

public Variable findSet()
Find the set representative (non-static method).
Returns:
the set representative.
See Also:
findSet(Variable)

findSet

public static Variable findSet(Variable o)
Find the set representative (FIND-UNION data structure) (static method).
Parameters:
o - a set element
Returns:
the set representative

getValue

public static java.lang.Object getValue(Variable o)
Gets the set value.
Parameters:
o - a set element
Returns:
the value p of the set representative.

equal

public static boolean equal(java.lang.Object o1,
                            java.lang.Object o2)
Compares two variables or objects whether they have equal values. (Works for atomic values for now)

init

public static Tokenizer init(Tokenizer tok)
Tokenizer initialization.
Parameters:
tok - the tokenizer.

compileS

public static VariableX compileS(java.lang.String s)
Compiles a new variableX and returns it.
Parameters:
s - the source string
Returns:
new variableX

compile

public VariableX compile(java.lang.String s)
Compiles string into this variablex and returns this.
Parameters:
s - the source string
Returns:
this variable

compileVariable

public VariableX compileVariable(Tokenizer tok,
                                 java.util.HashMap hash)
                          throws java.io.IOException

toStringShort

public java.lang.String toStringShort()
A short string representation of a variable.
Returns:
a short string representation

toStringType

public java.lang.String toStringType()
The name of the root type.
Returns:
the name of the root type.

toStringShort

public static java.lang.String toStringShort(Variable o)
A short string representation of a variable (static version).
Returns:
a short string representation

toString

public java.lang.String toString()
Returns a string representation of the object variable.
Overrides:
toString in class java.lang.Object
Returns:
a string representation

toString

public java.lang.String toString(CBFilterAVMTupleX filterAVM)
Returns a string representation of the object variable.
Parameters:
filterAVM - filter to be applied on each AVM tuple before producing the string; use null for default behaviour.
Returns:
a string representation

toString

public static java.lang.String toString(Variable v,
                                        CBFilterAVMTupleX filterAVM)
Returns a string representation of the given variable (static version).
Parameters:
v - the given variable
filterAVM - filter to be applied on each AVM tuple before producing the string; use null for default behaviour.
Returns:
a string representation

toString

public static java.lang.String toString(Variable v)
Returns a string representation of the given variable (static version).
Parameters:
v - the given variable
Returns:
a string representation

toString

public static java.lang.String toString(Variable v,
                                        AttributeSet attSet,
                                        TypeHierarchyX tLat,
                                        CBFilterAVMTupleX avmFilter)
Returns a string representation of the given variable (static version).
Parameters:
v - the given variable
attSet - an attribute set
tLat - a type Hierarchy
avmFilter - a filter for AVM tuples, if we want to change the behaviour of the function. Use null to get the default behaviour.
Returns:
a string representation

getAllSubAVMs

public static Variable[] getAllSubAVMs(Variable v)
Get an array of all sub-AVMs of a given AVM. There can be a tail of nulls in the array.
Parameters:
v - the variable (root AVM)
Returns:
an array of sub-AVMs

walkAndMarkS

public static void walkAndMarkS(Variable v,
                                java.util.Map ref,
                                int[][] count,
                                Variable[][] vars)
General purpose depth-first walker.

toString2S

public static java.lang.String toString2S(Variable v,
                                          java.util.Map ref,
                                          int[][] count,
                                          AttributeSet attSet,
                                          TypeHierarchyX tlat,
                                          CBFilterAVMTupleX filterAVM)

insertPrefix

public static java.lang.String insertPrefix(java.lang.String s,
                                            java.lang.String pref,
                                            int mode)
General string-manipulation function for inserting prefixes. A prefix is inserted at the beginning of each line.
Parameters:
s - the input string
pref - the prefix
mode - 0 - for inserting prefixes at the beginning of each line, 1 - for inserting only after the first line
Returns:
the new string with inserted prefixes.

Stefy

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