Package moss

Class TypeMgr

java.lang.Object
moss.TypeMgr
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AtomTypeMgr, BondTypeMgr, FreeTypeMgr

public abstract class TypeMgr extends Object implements Serializable
Class for a node or edge type manager.

A node or edge type manager manages integer numbers that are used to encode the type/attribute/label of a node or an edge. Such a type consists of a base type (30 bits) and flags (2 bits) that indicate a wildcard type and a special type. For wildcards and specials the base type may still be used to distinguish the actual types (e.g. distinguish different types of wildcards).

Since:
2007.06.20
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    the mask for the base type
    static final int
    the mask for the type flags
    static final int
    the flag for a special type
    static final int
    the flag for a wildcard type
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a node or edge type manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract int
    add(String name)
    Add a type to the type manager.
    static int
    getBase(int code)
    Get the base type (remove flags).
    abstract int
    Map a type name to the corresponding type code.
    abstract String
    getName(int code)
    Map a type code to the corresponding type name.
    abstract int
    Get the number of managed types.
    abstract boolean
    Check whether a type manager is fixed (is not extendable).
    static boolean
    isSpecial(int code)
    Check whether a type code specifies a special type.
    static boolean
    isWildcard(int code)
    Check whether a type code specifies a wildcard.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • TypeMgr

      public TypeMgr()
      Create a node or edge type manager.
      Since:
      2023.07.31 (Christian Borgelt)
  • Method Details

    • isFixed

      public abstract boolean isFixed()
      Check whether a type manager is fixed (is not extendable).
      Returns:
      whether the type manager is fixed
      Since:
      2009.08.13 (Christian Borgelt)
    • getTypeCount

      public abstract int getTypeCount()
      Get the number of managed types.
      Returns:
      the number of types in this type manager
      Since:
      2020.10.16 (Christian Borgelt)
    • add

      public abstract int add(String name)
      Add a type to the type manager.

      If the name is already present, no new mapping is added, but the code already associated with the name is returned, thus automatically avoiding duplicate entries.

      If the type manager does not allow for adding types and the name is not present, this function should return -1.

      Parameters:
      name - the name of the type
      Returns:
      the code of the type or -1 if the name does not exist in this type manager and adding is not possible
      Since:
      2007.06.20 (Christian Borgelt)
      See Also:
    • getCode

      public abstract int getCode(String name)
      Map a type name to the corresponding type code.
      Parameters:
      name - the name of the type
      Returns:
      the code of the type
      Since:
      2007.06.20 (Christian Borgelt)
    • getName

      public abstract String getName(int code)
      Map a type code to the corresponding type name.
      Parameters:
      code - the code of the type
      Returns:
      the name of the type
      Since:
      2007.06.20 (Christian Borgelt)
    • getBase

      public static int getBase(int code)
      Get the base type (remove flags).
      Parameters:
      code - the code from which to get the base type
      Returns:
      the base type specified by the code
      Since:
      2008.08.13 (Christian Borgelt)
    • isWildcard

      public static boolean isWildcard(int code)
      Check whether a type code specifies a wildcard.
      Parameters:
      code - the code of the type to check
      Returns:
      whether the code specifies a wildcard
      Since:
      2007.06.20 (Christian Borgelt)
    • isSpecial

      public static boolean isSpecial(int code)
      Check whether a type code specifies a special type.
      Parameters:
      code - the code of the type to check
      Returns:
      whether the code specifies a special type
      Since:
      2007.06.20 (Christian Borgelt)