Sort (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.osf.base

## Class Sort

- java.lang.Object
- - hlt.osf.base.Sort

- All Implemented Interfaces:
    Comparable

      public class Sort
      extends java.lang.Object
      implements Comparable

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `BitCode` | `code` The bit vector code of this Sort.
    `int` | `index` The index of this Sort (not necessarily its index in the sort code array).
    `java.lang.String` | `name` The name of this Sort.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Sort(int index, java.lang.String name, BitCode code)` Constructs a Sort object with the specified index, name, and bit code.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addIsaDeclaration(java.lang.String name)` Adds the specified name to the set of names of immediate supersorts of this sort, and returns true if it was not there (ie., declared so) before.
    `BitCode` | `ancestors()` Returns the set of ancestors of this sort as a BitCode.
    `static Sort` | `bottom()` Returns the bottom sort as a static constant.
    `void` | `clearIsaDeclarations()` Cleans up this sort by resetting its is-a declarations to null.
    `static int` | `codeSize()` Returns the sort code size for an encoded taxonomy.
    `Context` | `context()`
    `BitCode` | `descendants()` Returns the set of descendants of this sort as a BitCode.
    `boolean` | `equals(Sort sort)` Returns true iff this sort's name is equal to the specified one's.
    `BitCode` | `getChildren()` Returns this sort's children (that is, its maximal lower bounds) as set of sorts.
    `BitCode` | `getParents()` Returns this sort's parents (that is, its minimal upper bounds) as a set of sorts.
    `int` | `height()` Returns the height of this Sort in its taxonomy.
    `boolean` | `isBottom()` Return true iff this sort is bottom.
    `boolean` | `isLocked()` Returns true iff this sort's bit code is locked - which means that its bit code will not be modified by the 3 Boolean static operations 'not', 'and', and 'or'.
    `boolean` | `isStrictSubsortOf(Sort sort)` Returns true iff this sort is a strict subsort of the specified sort.
    `boolean` | `isSubsortOf(Sort sort)` Returns true iff this sort is a subsort of the specified sort.
    `boolean` | `isTop()` Return true iff this sort is top.
    `boolean` | `isUnrelatedTo(Sort sort)` Returns true iff this sort is unrelated to the specified sort.
    `boolean` | `lessThan(Comparable sort)` Returns true iff this is a strict lower sort of the specified sort.
    `Sort` | `lock()` Locks this sort's bit code - which means that its code will not be modified by the 3 Boolean static bit code operations 'not', 'and', and 'or'.
    `int` | `numberOfDescendants()` Returns the number of subsorts of this sort (not including itself).
    `boolean` | `precedes(Sort sort)` This defines the "precedes" ordering as described in the specification.
    `Sort` | `resetChildren()` Erases this sort's children.
    `void` | `resetHeight()`
    `Sort` | `resetParents()` Erases this sort's parents.
    `Sort` | `setCode(BitCode code)` Sets the bit code of this Sort object to the specified bit code, and returns this sort.
    `static void` | `setCodeSize(int size)` Sets the sort code size for an encoded taxonomy.
    `Sort` | `setContext(Context context)`
    `Sort` | `setHeight(int height)`
    `Sort` | `setIndex(int index)` Sets the index of this Sort object to the specified index, and returns this sort.
    `static Sort` | `top()` Returns the top sort as a static constant.
    `java.lang.String` | `toString()` Returns a string form of this Sort object.
    `Sort` | `unlock()` Unlocks this sort's bit code - which means that its code may be modified by the 3 Boolean static bit code operations 'not', 'and', and 'or'.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### index

          public int index

      The index of this Sort (not necessarily its index in the sort code array).

    - #### name

          public java.lang.String name

      The name of this Sort.

    - #### code

          public BitCode code

      The bit vector code of this Sort.

  - ### Constructor Detail

    - #### Sort

          public Sort(int index,
              java.lang.String name,
              BitCode code)

      Constructs a Sort object with the specified index, name, and bit code.

  - ### Method Detail

    - #### setIndex

          public Sort setIndex(int index)

      Sets the index of this Sort object to the specified index, and returns this sort.

    - #### setCode

          public Sort setCode(BitCode code)

      Sets the bit code of this Sort object to the specified bit code, and returns this sort.

    - #### isSubsortOf

          public boolean isSubsortOf(Sort sort)

      Returns true iff this sort is a subsort of the specified sort.

    - #### isStrictSubsortOf

          public boolean isStrictSubsortOf(Sort sort)

      Returns true iff this sort is a strict subsort of the specified sort.

    - #### isUnrelatedTo

          public boolean isUnrelatedTo(Sort sort)

      Returns true iff this sort is unrelated to the specified sort.

    - #### context

          public Context context()

    - #### setContext

          public Sort setContext(Context context)

    - #### codeSize

          public static int codeSize()
                              throws LockedCodeArrayException

      Returns the sort code size for an encoded taxonomy. Raises a LockedCodeArrayException if the sort code array is not locked.
      Throws:
        `LockedCodeArrayException`

    - #### setCodeSize

          public static void setCodeSize(int size)
                                  throws LockedCodeArrayException

      Sets the sort code size for an encoded taxonomy. Raises a LockedCodeArrayException if the sort code array is locked.
      Throws:
        `LockedCodeArrayException`

    - #### top

          public static Sort top()

      Returns the top sort as a static constant. This is safe only if the taxonomy this is relative to has been encoded. Raises a LockedCodeArrayException if the sort code array is locked. This is because its correct code size is only dtermined after the sorts have been all encoded.

    - #### isTop

          public boolean isTop()

      Return true iff this sort is top.

    - #### bottom

          public static Sort bottom()

      Returns the bottom sort as a static constant.

    - #### isBottom

          public boolean isBottom()

      Return true iff this sort is bottom.

    - #### addIsaDeclaration

          public boolean addIsaDeclaration(java.lang.String name)

      Adds the specified name to the set of names of immediate supersorts of this sort, and returns true if it was not there (ie., declared so) before.

    - #### clearIsaDeclarations

          public void clearIsaDeclarations()

      Cleans up this sort by resetting its is-a declarations to null.

    - #### getParents

          public BitCode getParents()

      Returns this sort's parents (that is, its minimal upper bounds) as a set of sorts. Note that this set be empty - in which case this sort must be the top sort. This assumes that the sorts have been encoded.

    - #### resetParents

          public Sort resetParents()

      Erases this sort's parents.

    - #### getChildren

          public BitCode getChildren()

      Returns this sort's children (that is, its maximal lower bounds) as set of sorts. Note that set array may be empty - in which case this sort must be the bottom sort. This assumes that the sorts have been encoded.

    - #### resetChildren

          public Sort resetChildren()

      Erases this sort's children.

    - #### height

          public int height()
                     throws LockedCodeArrayException

      Returns the height of this Sort in its taxonomy. (See the specification.)
      Throws:
        `LockedCodeArrayException`

    - #### setHeight

          public Sort setHeight(int height)

    - #### resetHeight

          public void resetHeight()

    - #### numberOfDescendants

          public int numberOfDescendants()

      Returns the number of subsorts of this sort (not including itself).

    - #### descendants

          public BitCode descendants()
                              throws LockedCodeArrayException

      Returns the set of descendants of this sort as a BitCode. (See the specification.)
      Throws:
        `LockedCodeArrayException`

    - #### ancestors

          public BitCode ancestors()
                            throws LockedCodeArrayException

      Returns the set of ancestors of this sort as a BitCode. (See the specification.)
      Throws:
        `LockedCodeArrayException`

    - #### lessThan

          public boolean lessThan(Comparable sort)

      Returns true iff this is a strict lower sort of the specified sort. This is used by the `hlt.language.tools.Misc.sort` method used in class `Taxonomy` to sort the declared sorts.
      Specified by:
        `lessThan` in interface `Comparable`

    - #### precedes

          public boolean precedes(Sort sort)

      This defines the "precedes" ordering as described in the specification. This is a topological ordering that respects the is-a ordering to ease the detection of potential cycles. A cycle is a set of sorts with equal codes after transitive closure has been performed. Using this "precedes" comparison to reorder the array will make all elements in a cycle be contiguous.

    - #### equals

          public boolean equals(Sort sort)

      Returns true iff this sort's name is equal to the specified one's.

    - #### lock

          public Sort lock()

      Locks this sort's bit code - which means that its code will not be modified by the 3 Boolean static bit code operations 'not', 'and', and 'or'.

    - #### unlock

          public Sort unlock()

      Unlocks this sort's bit code - which means that its code may be modified by the 3 Boolean static bit code operations 'not', 'and', and 'or'.

    - #### isLocked

          public boolean isLocked()

      Returns true iff this sort's bit code is locked - which means that its bit code will not be modified by the 3 Boolean static operations 'not', 'and', and 'or'.

    - #### toString

          public java.lang.String toString()

      Returns a string form of this Sort object. This string is its name.
      Overrides:
        `toString` in class `java.lang.Object`