Interface Handle
- All Superinterfaces:
Comparable<Handle>
- All Known Implementing Classes:
HandleImpl
A handle is an identifier used for various objects. It contains a String id, an integer index and an
arbitrary number of tags, which are also handles. A handle is always contained in a single Space, and may
belong to one or more Groups within that Space. A handle's id may not be empty or blank and may consist
of printable ASCII characters, with the exception of the colon (:) which is reserved as a separator for
subhandles.
A handle may have any number of subhandles. The ids of subhandles are in the format handle:subhandle. A
subhandle may not have subhandles of its own. Subhandles may be used in any situation where a handle would need to
have parameters attached to it that are also handles. Subhandles are used internally for the identifying handles of
Spaces to identify their respective Groups.
Every handle has an index and a sub-index. Indices are unique for handles within a given Space, starting from
0. Sub-indices are unique for subhandles within their parent handle, also starting from 0. A handle that is not a
subhandle has a sub-index of -1.
-
Method Summary
Modifier and TypeMethodDescriptionintCompares this handle with the specified handle for order.Creates a new subhandle.getId()intgetIndex()Creates a subhandle with the specified id if it does not already exist and returns the subhandle with that id.getSpace()intReturns-1if this handle is not a subhandle.getTags()The returnedHandleSetis modifiable and tags may be added to or removed from it at will.boolean
-
Method Details
-
getHandleManager
HandleManager getHandleManager()- Returns:
HandleManagermanaging this handle
-
getSpace
Space getSpace()- Returns:
Spacethat this handle is contained in
-
getId
String getId()- Returns:
Stringid of this handle
-
getIndex
int getIndex()- Returns:
- index of this handle
-
getSubIndex
int getSubIndex()Returns-1if this handle is not a subhandle.- Returns:
- sub-index of this handle
-
getSubHandles
HandleSet getSubHandles()- Returns:
- subhandles contained in this handle
-
createSubHandle
Creates a new subhandle. ThrowsUnsupportedOperationExceptionif this handle is a subhandle or is associated with aSpace(subhandles for space handles are used exclusively forGroups, useSpace.createGroup(String)instead).- Parameters:
id-Stringid for the new subhandle- Returns:
- created subhandle
- Throws:
NullPointerException- if the id isnullIllegalArgumentException- if the id is empty, blank, contains non-ASCII or non-printable characters or the colon (:), or if a subhandle with the given id already exists in this handleUnsupportedOperationException- if this handle is a subhandle or if this handle is associated with aSpace
-
getOrCreateSubHandle
Creates a subhandle with the specified id if it does not already exist and returns the subhandle with that id. ThrowsUnsupportedOperationExceptionif this handle is a subhandle or is associated with aSpace(subhandles for space handles are used exclusively forGroups) and a subhandle with the specified id is not present. UseSpace.getOrCreateGroup(String).- Parameters:
id-Stringid for the subhandle- Returns:
- created or pre-existing subhandle
- Throws:
NullPointerException- if the id isnullIllegalArgumentException- if the id is empty, blank, contains non-ASCII or non-printable characters or the colon (:)UnsupportedOperationException- if this handle is a subhandle or if this handle is associated with aSpaceand a subhandle with the specified id is not present
-
getTags
HandleSet getTags()The returnedHandleSetis modifiable and tags may be added to or removed from it at will.- Returns:
HandleSetcontaining the tags of this handle
-
isSubHandle
boolean isSubHandle()- Returns:
trueif this handle is a subhandle
-
compareTo
Compares this handle with the specified handle for order. Returns a negative integer, zero, or a positive integer as this handle is less than, equal to, or greater than the specified handle. The order of handles is specified by three things. If theSpacesof the handles are different, comparison is done with the space's handle. If the spaces are the same, comparison is done with the index, using the sub-index if the indices are also the same.- Specified by:
compareToin interfaceComparable<Handle>- Parameters:
o- handle to be compared.- Returns:
- negative integer, zero, or a positive integer as this handle is less than, equal to, or greater than the specified handle
- Throws:
NullPointerException- if the specified handle isnull
-