ix.iview.util
Class IVUtil

java.lang.Object
  extended by ix.iview.util.IVUtil

public class IVUtil
extends java.lang.Object

Class for useful static methods.


Field Summary
static java.lang.String TYPE_STRING_a
           
static java.lang.String TYPE_STRING_b
           
 
Constructor Summary
IVUtil()
           
 
Method Summary
static boolean bothEmpty(java.util.Collection list, java.util.Collection otherList)
           
static boolean bothEmpty(java.util.Map map, java.util.Map otherMap)
           
static boolean checkCopyObject(java.lang.String thing, UIObject uio, java.lang.String name)
          Check if the object should be overwritten or copied.
static boolean checkNodeRefConsistency(UIRefinement uir, Ordering o)
          This should be a method within Orderings and Constraints!
static void enableVars(VarSpecifier parent, javax.swing.text.JTextComponent jtc)
          Enables the use of declarations when a question-mark is typed in a text componenet.
static java.lang.String ensureVarName(java.lang.String name)
           
static java.lang.Object extractType(Constraint tConstraint)
           
static java.lang.Object extractType(Constraint tConstraint, UIDomain domain)
           
static java.util.List filterClassConstraints(java.util.List constraints)
          Looks through constraints and finds all most likely class info.
static java.util.List filterProperty(java.lang.String property, java.util.List constraints)
          Looks through constraints and finds those for given property.
static java.util.List filterVariableProperty(ItemVar var, java.lang.String property, java.util.List constraints)
          Looks through constraints and finds the most likely for class info.
static Constraint findClassConstraint(ItemVar var, java.util.List constraints)
          Looks through constraints and finds the most likely for class info.
static java.util.Set findNameMatches(java.lang.String pattern, java.util.List namedThings)
          Finds objects in the given list whose names match the given string.
static int findString(java.lang.String pattern, java.lang.String text)
           
static java.lang.Object findVariableClass(ItemVar var, java.util.List constraints)
          Looks through constraints and finds the most likely for class info.
static java.lang.Object getConstraintValue(Constraint constr)
           
static java.lang.String getPropertyFromPattern(LList pattern)
          Looks at the first element in the list and compares it to the given property.
static java.lang.String getRelativeName(java.lang.Object relative)
           
static java.lang.String getSubjectInPattern(LList pattern)
          Looks at the second element in the list returns it as a string.
static java.lang.String ideReleaseToString()
           
static boolean isClassConstraint(Constraint c)
          Looks through constraints and finds the most likely for class info.
static boolean isClassConstraint(ItemVar var, Constraint c)
          Looks through constraints and finds the most likely for class info.
static boolean isEmptyConstraint(Constraint constraint)
           
static boolean isInPattern(ItemVar var, LList pattern)
           
static boolean isPropertyPattern(ObjectProperty prop, LList pattern)
          Looks at the first element in the list and compares it to the given property.
static boolean isSimplePropertyAssignment(PatternAssignment ass, ObjectProperty prop, ItemVar var)
          Looks at the second element in the list and compares it to the given variable.
static boolean isSubjectInPattern(ItemVar var, LList pattern)
          Looks at the second element in the list and compares it to the given variable.
static java.util.List makeObjectClassTree(UIDomain uid, java.util.List classList)
          Turn the given list of object classes into a list that shows the tree (root first)
static VariableDeclaration makeVariableDeclaration(java.lang.String name)
           
static java.util.List makeVariableDeclarations(java.util.Collection vars)
          Turns the given collection of variables (names or ItemVars) into a list of variable declarations
static java.lang.String namedListToDisplay(java.util.Collection l)
           
static void offerVars(VarSpecifier parent, javax.swing.text.JTextComponent jtc, java.util.List decs, java.awt.Point location, int position)
          Offers the declared variables (if any) for completion, splices in selection (if any) NOTE: the "?"
static java.lang.String printCondition(Constraint cond)
           
static java.lang.String printConstraint(Constraint constraint)
           
static java.lang.String printConstraintParameters(Constraint constraint)
           
static java.lang.String printConstraints(java.util.Collection constraints)
           
static void printIDEReleaseGreeting()
           
static java.lang.String printNode(NodeSpec node)
           
static java.lang.String printNodes(java.util.Collection nodes)
           
static java.lang.String printOrdering(Ordering ordering)
           
static java.lang.String printOrderings(java.util.Collection orderings)
           
static java.lang.String printUIObjects(java.util.Collection objects)
           
static java.lang.String printVarDec(VariableDeclaration varDec)
           
static java.lang.String printVarDecs(java.util.Collection varDecs)
           
static java.lang.String propertyFromConstraint(Constraint c)
          Looks at the pattern of the given constraint and returns the string that is the first element of that pattern, i.e. the place where a property would be.
static ObjectProperty propertyFromConstraint(UIObjectClass oClass, Constraint c)
          Looks at the pattern of the given constraint and returns the string that is the first element of that pattern, i.e. the place where a property would be.
static ObjectProperty propertyFromPattern(java.util.List pattern, UIObjectClass oClass)
          Looks for an ObjectProperty in the given pattern that is defined for the given UIObjectClass.
static ObjectProperty propertyFromString(java.lang.String s, UIObjectClass oc)
          Finds a property of the given class whose name matches the given string.
static Constraint readCondition(Symbol type, Symbol rel, java.lang.String text)
           
static java.lang.String releaseToString()
           
static java.util.Set removeConstraint(java.util.Set cSet, Constraint c)
           
static LList replaceInPattern(ItemVar oldVar, ItemVar newVar, LList pattern)
          Replace each variable in each given constraint with the new one propertiesMap (property-constraintSet)
static java.util.HashMap replaceVarInConstraints(ItemVar oldVar, ItemVar newVar, java.util.HashMap constraintsMap)
          Replace each variable in each given constraint with the new one propertiesMap (property-constraintSet)
static boolean sameConstraint(Constraint one, Constraint other)
          Determines whether the two constraints are the same.
static boolean sameList(java.util.List list, java.util.List otherList)
           
static boolean sameMap(java.util.Map m1, java.util.Map m2)
           
static boolean sameObject(java.lang.Object thing, java.lang.Object other)
           
static boolean sameObjectConstraint(Constraint c, Constraint otherC)
          Determines whether the two constraints are on the same thing.
static boolean sameSet(java.util.Collection list, java.util.Collection otherList)
           
static boolean sameStableMap(java.util.Map m1, java.util.Map m2)
           
static boolean sameString(java.lang.String thing, java.lang.String other)
           
static boolean sameSymbol(java.lang.Object thing, java.lang.Object other)
           
static Constraint setConstraintValue(Constraint constr, java.lang.Object val)
           
static Constraint setConstraintValue(UIObjectClass oClass, Constraint constr, java.lang.Object val)
           
static java.util.List sortConstraintCollection(java.util.Collection col)
           
static java.util.Collection sortNamedCollection(java.util.Collection c)
           
static java.util.List sortNodeCollection(java.util.Collection c)
           
static java.util.List sortTICollection(java.util.Collection c)
           
 java.lang.String textDerenderPatterns(java.util.List specs)
           
static java.lang.String textRenderPatterns(java.util.Collection specs)
           
static void useVar(javax.swing.text.JTextComponent jtc, int position, java.lang.String var)
           
static ItemVar variableFromConstraint(Constraint c)
          Looks for an ObjectProperty in the given pattern that is defined for the given UIObjectClass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_STRING_a

public static java.lang.String TYPE_STRING_a

TYPE_STRING_b

public static java.lang.String TYPE_STRING_b
Constructor Detail

IVUtil

public IVUtil()
Method Detail

ideReleaseToString

public static java.lang.String ideReleaseToString()

releaseToString

public static java.lang.String releaseToString()

printIDEReleaseGreeting

public static void printIDEReleaseGreeting()

findString

public static int findString(java.lang.String pattern,
                             java.lang.String text)

findNameMatches

public static java.util.Set findNameMatches(java.lang.String pattern,
                                            java.util.List namedThings)
Finds objects in the given list whose names match the given string.

Returns:
the matches sorted by how early the string appears in the name.

sortNamedCollection

public static java.util.Collection sortNamedCollection(java.util.Collection c)

sortNodeCollection

public static java.util.List sortNodeCollection(java.util.Collection c)

sortConstraintCollection

public static java.util.List sortConstraintCollection(java.util.Collection col)

sortTICollection

public static java.util.List sortTICollection(java.util.Collection c)

sameList

public static boolean sameList(java.util.List list,
                               java.util.List otherList)

sameMap

public static boolean sameMap(java.util.Map m1,
                              java.util.Map m2)

sameStableMap

public static boolean sameStableMap(java.util.Map m1,
                                    java.util.Map m2)

sameSet

public static boolean sameSet(java.util.Collection list,
                              java.util.Collection otherList)

sameObject

public static boolean sameObject(java.lang.Object thing,
                                 java.lang.Object other)

sameString

public static boolean sameString(java.lang.String thing,
                                 java.lang.String other)

sameSymbol

public static boolean sameSymbol(java.lang.Object thing,
                                 java.lang.Object other)

bothEmpty

public static boolean bothEmpty(java.util.Collection list,
                                java.util.Collection otherList)

bothEmpty

public static boolean bothEmpty(java.util.Map map,
                                java.util.Map otherMap)

checkCopyObject

public static boolean checkCopyObject(java.lang.String thing,
                                      UIObject uio,
                                      java.lang.String name)
Check if the object should be overwritten or copied. Ask the user if copying makes sense.

Returns:
true if the object is to be copied, false if not.

makeObjectClassTree

public static java.util.List makeObjectClassTree(UIDomain uid,
                                                 java.util.List classList)
Turn the given list of object classes into a list that shows the tree (root first)


getRelativeName

public static java.lang.String getRelativeName(java.lang.Object relative)

isEmptyConstraint

public static boolean isEmptyConstraint(Constraint constraint)

setConstraintValue

public static Constraint setConstraintValue(Constraint constr,
                                            java.lang.Object val)

setConstraintValue

public static Constraint setConstraintValue(UIObjectClass oClass,
                                            Constraint constr,
                                            java.lang.Object val)

getConstraintValue

public static java.lang.Object getConstraintValue(Constraint constr)

findVariableClass

public static java.lang.Object findVariableClass(ItemVar var,
                                                 java.util.List constraints)
Looks through constraints and finds the most likely for class info. (type ?var = Agent) or (class ?var = Agent) or (?var type = Agent)... Looks for TYPE_STRING_a and first, then b (if a not found)

Returns:
the reference to the object class as it appears in the assignment

removeConstraint

public static java.util.Set removeConstraint(java.util.Set cSet,
                                             Constraint c)

filterClassConstraints

public static java.util.List filterClassConstraints(java.util.List constraints)
Looks through constraints and finds all most likely class info. (type ?var = Agent) or (class ?var = Agent) or (?var type = Agent)... Looks for TYPE_STRING_a and first, then b (if a not found). Leaves given list intact.


isClassConstraint

public static boolean isClassConstraint(ItemVar var,
                                        Constraint c)
Looks through constraints and finds the most likely for class info. (type ?var = Agent) or (class ?var = Agent) or (?var type = Agent)... Looks for TYPE_STRING_a and first, then b (if a not found)


isClassConstraint

public static boolean isClassConstraint(Constraint c)
Looks through constraints and finds the most likely for class info. (type ?var = Agent) or (class ?var = Agent) or (?var type = Agent)... Looks for TYPE_STRING_a and first, then b (if a not found)


findClassConstraint

public static Constraint findClassConstraint(ItemVar var,
                                             java.util.List constraints)
Looks through constraints and finds the most likely for class info. (type ?var = Agent) or (class ?var = Agent) or (?var type = Agent)... Looks for TYPE_STRING_a and first, then b (if a not found)


extractType

public static java.lang.Object extractType(Constraint tConstraint)

extractType

public static java.lang.Object extractType(Constraint tConstraint,
                                           UIDomain domain)

propertyFromConstraint

public static java.lang.String propertyFromConstraint(Constraint c)
Looks at the pattern of the given constraint and returns the string that is the first element of that pattern, i.e. the place where a property would be.

Returns:
the string in the first place of the pattern or "";

propertyFromConstraint

public static ObjectProperty propertyFromConstraint(UIObjectClass oClass,
                                                    Constraint c)
Looks at the pattern of the given constraint and returns the string that is the first element of that pattern, i.e. the place where a property would be.

Returns:
the string in the first place of the pattern or "";

variableFromConstraint

public static ItemVar variableFromConstraint(Constraint c)
Looks for an ObjectProperty in the given pattern that is defined for the given UIObjectClass. Can handle null values in both parameters. return@ the ObjectProperty or null if none is found.


propertyFromPattern

public static ObjectProperty propertyFromPattern(java.util.List pattern,
                                                 UIObjectClass oClass)
Looks for an ObjectProperty in the given pattern that is defined for the given UIObjectClass. Can handle null values in both parameters. return@ the ObjectProperty or null if none is found.


propertyFromString

public static ObjectProperty propertyFromString(java.lang.String s,
                                                UIObjectClass oc)
Finds a property of the given class whose name matches the given string.


filterProperty

public static java.util.List filterProperty(java.lang.String property,
                                            java.util.List constraints)
Looks through constraints and finds those for given property. Leaves given list intact.


filterVariableProperty

public static java.util.List filterVariableProperty(ItemVar var,
                                                    java.lang.String property,
                                                    java.util.List constraints)
Looks through constraints and finds the most likely for class info. (type ?var = Agent) or (class ?var = Agent) or (?var type = Agent)... Looks for TYPE_STRING_a and b first, then i and j (if a and b not found)


replaceInPattern

public static LList replaceInPattern(ItemVar oldVar,
                                     ItemVar newVar,
                                     LList pattern)
Replace each variable in each given constraint with the new one propertiesMap (property-constraintSet)


replaceVarInConstraints

public static java.util.HashMap replaceVarInConstraints(ItemVar oldVar,
                                                        ItemVar newVar,
                                                        java.util.HashMap constraintsMap)
Replace each variable in each given constraint with the new one propertiesMap (property-constraintSet)


isInPattern

public static boolean isInPattern(ItemVar var,
                                  LList pattern)

isSubjectInPattern

public static boolean isSubjectInPattern(ItemVar var,
                                         LList pattern)
Looks at the second element in the list and compares it to the given variable.


getSubjectInPattern

public static java.lang.String getSubjectInPattern(LList pattern)
Looks at the second element in the list returns it as a string.


isPropertyPattern

public static boolean isPropertyPattern(ObjectProperty prop,
                                        LList pattern)
Looks at the first element in the list and compares it to the given property.


getPropertyFromPattern

public static java.lang.String getPropertyFromPattern(LList pattern)
Looks at the first element in the list and compares it to the given property.


isSimplePropertyAssignment

public static boolean isSimplePropertyAssignment(PatternAssignment ass,
                                                 ObjectProperty prop,
                                                 ItemVar var)
Looks at the second element in the list and compares it to the given variable.


sameConstraint

public static boolean sameConstraint(Constraint one,
                                     Constraint other)
Determines whether the two constraints are the same. Checks type, relation, and the string version of parameters (printCOnstraintParameters) Call this to compare constraints for the same property to work out whether one should replace the other, or whether they are


sameObjectConstraint

public static boolean sameObjectConstraint(Constraint c,
                                           Constraint otherC)
Determines whether the two constraints are on the same thing. Call this to compare constraints for the same property to work out whether one should replace the other, or whether they are


readCondition

public static Constraint readCondition(Symbol type,
                                       Symbol rel,
                                       java.lang.String text)
                                throws SyntaxException
Throws:
SyntaxException

checkNodeRefConsistency

public static boolean checkNodeRefConsistency(UIRefinement uir,
                                              Ordering o)
This should be a method within Orderings and Constraints!


namedListToDisplay

public static java.lang.String namedListToDisplay(java.util.Collection l)

textRenderPatterns

public static java.lang.String textRenderPatterns(java.util.Collection specs)

textDerenderPatterns

public java.lang.String textDerenderPatterns(java.util.List specs)

printNodes

public static java.lang.String printNodes(java.util.Collection nodes)

printOrderings

public static java.lang.String printOrderings(java.util.Collection orderings)

printVarDecs

public static java.lang.String printVarDecs(java.util.Collection varDecs)

printNode

public static java.lang.String printNode(NodeSpec node)

printVarDec

public static java.lang.String printVarDec(VariableDeclaration varDec)

printOrdering

public static java.lang.String printOrdering(Ordering ordering)

printCondition

public static java.lang.String printCondition(Constraint cond)

printConstraints

public static java.lang.String printConstraints(java.util.Collection constraints)

printConstraint

public static java.lang.String printConstraint(Constraint constraint)

printConstraintParameters

public static java.lang.String printConstraintParameters(Constraint constraint)

printUIObjects

public static java.lang.String printUIObjects(java.util.Collection objects)

useVar

public static void useVar(javax.swing.text.JTextComponent jtc,
                          int position,
                          java.lang.String var)

enableVars

public static void enableVars(VarSpecifier parent,
                              javax.swing.text.JTextComponent jtc)
Enables the use of declarations when a question-mark is typed in a text componenet. NOTE: the "?" will not appear when typed!


offerVars

public static void offerVars(VarSpecifier parent,
                             javax.swing.text.JTextComponent jtc,
                             java.util.List decs,
                             java.awt.Point location,
                             int position)
Offers the declared variables (if any) for completion, splices in selection (if any) NOTE: the "?" does not appear when typed!


ensureVarName

public static java.lang.String ensureVarName(java.lang.String name)

makeVariableDeclarations

public static java.util.List makeVariableDeclarations(java.util.Collection vars)
Turns the given collection of variables (names or ItemVars) into a list of variable declarations


makeVariableDeclaration

public static VariableDeclaration makeVariableDeclaration(java.lang.String name)