Package moss
Class TypeMgr
java.lang.Object
moss.TypeMgr
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AtomTypeMgr
,BondTypeMgr
,FreeTypeMgr
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract int
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
isFixed()
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.
-
Field Details
-
BASEMASK
public static final int BASEMASKthe mask for the base type- See Also:
-
FLAGMASK
public static final int FLAGMASKthe mask for the type flags- See Also:
-
WILDCARD
public static final int WILDCARDthe flag for a wildcard type- See Also:
-
SPECIAL
public static final int SPECIALthe flag for a special type- See Also:
-
-
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
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
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
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)
-