|
|||||||||
Atavism Version 2018.1 | AGIS API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatavism.server.engine.Namespace
public class Namespace
For each conceptual object stored in the database, every plugin has the option of creating and maintaining one or more "sub-objects" containing just those members that are meaningful to that plugin. When it comes time to store them in the database, the plugin needs some unique token in addition to the objects oid to identify the each of the plugin's sub-objects. Namespace objects provide that unique token, and each plugin stores it's persistent objects in one or more namespaces that only that kind of plugin uses. Namespace objects are identified by a string, which is interned to produce a small integer, and the mappings between namespace strings and the small integers used to represent them is stored in the database. When the server starts up, each plugin reads the mapping into memory, creating Namespace objects for each entry in the mapping.
Namespace objects can be created on the fly, by calling the static method Namespace.intern(String name), which looks up the string in the in-memory map of Namespace strings. If the string is found, it returns the associated namespace object; otherwise, it stores the new namespace in the database, and creates and returns the newly-interned Namespace object.
At this point, the number of unique namespaces is limited to 31, because a set of namespaces must be compressed to fit integer with 1 bit per namespace.
An Entity, which represents a particular plugin's sub-object, "knows" what Namespace it belongs to.
Field Summary | |
---|---|
static Namespace |
AGISITEM
The second of two Inventory Plugin namespaces, used for inventory items |
static Namespace |
BAG
The first of two Inventory Plugin namespaces, used for inventory bags |
static Namespace |
BILLING
The Billing Plugin's namespace |
static Namespace |
CLASSABILITY
The ClassAbility Plugin's namespace |
static Namespace |
COMBAT
The Combat Plugin's namespace |
static Namespace |
FACTION
|
static Namespace |
INSTANCE
InstancePlugin namespace. |
static Namespace |
MOB
The Mob Manager Plugin's namespace |
static Namespace |
OBJECT_MANAGER
The Object Manager Plugin's namespace |
static Namespace |
QUEST
The first of two Quest Plugin namespaces, used for quests |
static long |
serialVersionUID
|
static Namespace |
TRAINER
The Trainer Plugin's namespace |
static Namespace |
TRANSIENT
The transient namespace, used when the plugin's subobject should not be stored persistently |
static int |
transientNamespaceNumber
The number of the transient namespace is hard-wired to 1 |
static Namespace |
VOICE
A namespace for the voice plugin |
static Namespace |
WM_INSTANCE
World manager instance namespace. |
static Namespace |
WORLD_MANAGER
The World Manager Plugin's namespace |
Constructor Summary | |
---|---|
Namespace()
Marshalling requires that there be a public no-args constructor, but nothing but marshalling should call this constructor |
|
Namespace(java.lang.String name,
int number)
This constructor is private, since all Namespace objects should be created by Namespace.intern(String name) |
Method Summary | |
---|---|
static Namespace |
addDBNamespace(java.lang.String name,
int number)
This method is called by the database code to create interned Namespace objects as a result of a call to encacheNamespaceMapping. |
static java.lang.Integer |
compressNamespaceList(java.util.Set<Namespace> namespaces)
Given a set of Namespace objects, compress the set into an Integer, with 1 bit whose bit number is the number of the Namespace, or return null if the namespace set is null or has no elements. |
static java.util.List<Namespace> |
decompressNamespaceList(java.lang.Integer namespacesInteger)
Given an Integer with 1 bit whose bit number is the number of the Namespace, decompress into a Set |
static void |
encacheNamespaceMapping()
This method is called by Engine to encache database-resident Namespace objects. |
java.lang.String |
getName()
Getter for the Namespace string name. |
static Namespace |
getNamespace(java.lang.String nsString)
Return the namespace associated with the string argument, or throw an error if no such namespace exists |
static Namespace |
getNamespaceFromInt(java.lang.Integer nsInt)
Return the namespace whose number is the Integer argument, or null if no such namespace exists |
protected static Namespace |
getNamespaceFromIntOrError(java.lang.Integer nsInt)
|
static Namespace |
getNamespaceIfExists(java.lang.String nsString)
Return the namespace associated with the string argument, or null if it does not exist. |
int |
getNumber()
Getter for the Namespace number. |
static Namespace |
intern(java.lang.String name)
This is the external entrypoint used to create a namespace. |
void |
marshalObject(AOByteBuffer buf)
When marshalled, a Namespace object is represented by a byte containing it's number. |
java.lang.String |
toString()
|
java.lang.Object |
unmarshalObject(AOByteBuffer buf)
The unmarshalling operation looks up the number read from the input stream in the mapping from number to Namespace object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static Namespace TRANSIENT
public static Namespace OBJECT_MANAGER
public static Namespace WORLD_MANAGER
public static Namespace COMBAT
public static Namespace MOB
public static Namespace BAG
public static Namespace AGISITEM
public static Namespace QUEST
public static Namespace FACTION
public static Namespace INSTANCE
public static Namespace WM_INSTANCE
public static Namespace VOICE
public static Namespace TRAINER
public static Namespace CLASSABILITY
public static Namespace BILLING
public static final int transientNamespaceNumber
public static final long serialVersionUID
Constructor Detail |
---|
public Namespace()
public Namespace(java.lang.String name, int number)
Method Detail |
---|
public java.lang.String getName()
public int getNumber()
public java.lang.String toString()
toString
in class java.lang.Object
public void marshalObject(AOByteBuffer buf)
marshalObject
in interface Marshallable
buf
- The byte bufferpublic java.lang.Object unmarshalObject(AOByteBuffer buf)
unmarshalObject
in interface Marshallable
public static Namespace intern(java.lang.String name)
public static Namespace addDBNamespace(java.lang.String name, int number)
public static void encacheNamespaceMapping()
public static Namespace getNamespace(java.lang.String nsString)
public static Namespace getNamespaceIfExists(java.lang.String nsString)
public static Namespace getNamespaceFromInt(java.lang.Integer nsInt)
protected static Namespace getNamespaceFromIntOrError(java.lang.Integer nsInt)
public static java.lang.Integer compressNamespaceList(java.util.Set<Namespace> namespaces)
public static java.util.List<Namespace> decompressNamespaceList(java.lang.Integer namespacesInteger)
|
Copyright © 2018 Dragonsan Studios Sp. z o.o. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |