COM.hugin.HAPI
Class ClassCollection

java.lang.Object
  extended byCOM.hugin.HAPI.ClassCollection

public class ClassCollection
extends java.lang.Object

Classes are grouped into ClassCollections. Each class must belong to exactly one ClassCollection. A ClassCollection can be considered a closed world of interdependent Classes (i.e., Bayesian networks and LIMIDs). That is, each Class may contain instances of other Classes of the ClassCollection, but not of Classes of other ClassCollections.

Several operations are supported for ClassCollections:

  • Creation and deletion
  • Addition of Class objects specified in NET files
  • Saving to a NET file
  • Retrieval of the list of Class objects
  • Retrieval of a Class object by its name

  • Constructor Summary
    ClassCollection()
              Constructs a new (empty) ClassCollection.
    ClassCollection(java.lang.String hkbFileName)
              Constructs a class collection by loading the corresponding Hugin Knowledge Base (HKB) file.
    ClassCollection(java.lang.String hkbFileName, java.lang.String password)
              Constructs a class collection by loading the corresponding Hugin Knowledge Base (HKB) file.
     
    Method Summary
     void delete()
              Deletes this ClassCollection and all its member Classes.
     Class getClassByName(java.lang.String name)
              Returns the Class of this ClassCollection that has the given name.
     ClassList getMembers()
              Returns a ClassList containing the members of this ClassCollection.
     java.lang.Object getUserData()
              Returns the value stored within the user data slot of this ClassCollection.
     boolean isAlive()
              Is this ClassCollection object alive?
     void parseClasses(java.lang.String netStringOrFileName)
              Constructs one or more classes from a NET file or a NET description given as a string.
     void parseClasses(java.lang.String netStringOrFileName, ClassParseListener pl)
              Constructs one or more classes from a NET file or a NET description given as a string.
     void saveAsKB(java.lang.String fileName)
              Saves this ClassCollection as a Hugin Knowledge Base (HKB) file.
     void saveAsKB(java.lang.String fileName, java.lang.String password)
              Saves this ClassCollection as a password-protected Hugin Knowledge Base (HKB) file.
     void saveAsNet(java.lang.String netName)
              Writes a NET description of this ClassCollection to a file.
     void setUserData(java.lang.Object data)
              Sets the user data field of this ClassCollection.
     java.lang.String toNetString()
              Creates a NET description of this ClassCollection.
     java.lang.String toString()
              Returns a String of names of the member Classes of this ClassCollection.
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Constructor Detail

    ClassCollection

    public ClassCollection()
                    throws ExceptionHugin
    Constructs a new (empty) ClassCollection.


    ClassCollection

    public ClassCollection(java.lang.String hkbFileName,
                           java.lang.String password)
                    throws ExceptionHugin
    Constructs a class collection by loading the corresponding Hugin Knowledge Base (HKB) file. The HKB file must contain a class collection.

    Parameters:
    hkbFileName - the name of the HKB file
    password - a password needed to load the file.

    ClassCollection

    public ClassCollection(java.lang.String hkbFileName)
                    throws ExceptionHugin
    Constructs a class collection by loading the corresponding Hugin Knowledge Base (HKB) file. The HKB file must contain a class collection.

    Parameters:
    hkbFileName - the name of the HKB file.
    Method Detail

    parseClasses

    public void parseClasses(java.lang.String netStringOrFileName,
                             ClassParseListener pl)
                      throws ExceptionHugin
    Constructs one or more classes from a NET file or a NET description given as a string.

    Parameters:
    netStringOrFileName - a string containing a NET description or the name of a NET file
    pl - a ClassParseListener.
    Throws:
    ExceptionHugin

    parseClasses

    public void parseClasses(java.lang.String netStringOrFileName)
                      throws ExceptionHugin
    Constructs one or more classes from a NET file or a NET description given as a string. This method uses a DefaultClassParseListener.

    Parameters:
    netStringOrFileName - a string containing a NET description or the name of a NET file.
    Throws:
    ExceptionHugin

    delete

    public void delete()
                throws ExceptionHugin
    Deletes this ClassCollection and all its member Classes.

    Throws:
    ExceptionHugin

    getMembers

    public ClassList getMembers()
                         throws ExceptionHugin
    Returns a ClassList containing the members of this ClassCollection.

    Throws:
    ExceptionHugin

    getClassByName

    public Class getClassByName(java.lang.String name)
                         throws ExceptionHugin
    Returns the Class of this ClassCollection that has the given name. If no such class exists, null is returned.

    Parameters:
    name - A string representing the name of a Class.
    Throws:
    ExceptionHugin

    saveAsKB

    public void saveAsKB(java.lang.String fileName,
                         java.lang.String password)
                  throws ExceptionHugin
    Saves this ClassCollection as a password-protected Hugin Knowledge Base (HKB) file. If password is non-null, the file will be password protected. This password must be used in order to load the file.

    Parameters:
    fileName - the name of the file to which the HKB is saved.
    password - if non-null, this must be used in order to load the file.
    Throws:
    ExceptionHugin

    saveAsNet

    public void saveAsNet(java.lang.String netName)
                   throws ExceptionHugin
    Writes a NET description of this ClassCollection to a file.

    Parameters:
    netName - the name of the NET file.
    Throws:
    ExceptionHugin

    toNetString

    public java.lang.String toNetString()
                                 throws ExceptionHugin
    Creates a NET description of this ClassCollection.

    Returns:
    A string containing the NET description.
    Throws:
    ExceptionHugin

    saveAsKB

    public void saveAsKB(java.lang.String fileName)
                  throws ExceptionHugin
    Saves this ClassCollection as a Hugin Knowledge Base (HKB) file. The HKB file will not be password protected.

    Parameters:
    fileName - the name of the HKB file.
    Throws:
    ExceptionHugin

    isAlive

    public boolean isAlive()
    Is this ClassCollection object alive?


    toString

    public java.lang.String toString()
    Returns a String of names of the member Classes of this ClassCollection.

    Returns:
    A String like e.g., "{ ClassA, ClassB }".

    getUserData

    public java.lang.Object getUserData()
    Returns the value stored within the user data slot of this ClassCollection. If the stored value is NULL, or if no value has been stored, NULL is returned.

    Returns:
    Object stored within the ClassCollection.

    setUserData

    public void setUserData(java.lang.Object data)
    Sets the user data field of this ClassCollection. The Hugin API provides a slot within each ClassCollection for use exclusively by the user/application.

    Parameters:
    data - User-defined data associated with this ClassCollection.