All Packages Class Hierarchy This Package Previous Next Index
Class org.ifarchive.glk.OpaqueObject
java.lang.Object
|
+----org.ifarchive.glk.OpaqueObject
- public class OpaqueObject
- extends Object
Base class for wrapping opaque Glk objects.
This class contains general methods for handling any type of Glk
object. Objects supported by the library have particular subclasses
such as Window or Stream. You will only need to deal with OpaqueObject
directly if the underlying Glk library contains object types not supported
in this wrapper library.
-
clFileRef
- Glk class number for file references
-
clSoundChannel
- Glk class number for sound channels
-
clStream
- Glk class number for streams
-
clWindow
- Glk class number for windows
-
m_dispid
- Reference to the underlying Glk object.
-
m_glkClass
- The number of the Glk class to which this object belongs.
-
m_jrock
- Rock given to this object if it was created within Java.
-
OpaqueObject(int, int)
- Constructor.
-
castRock(Object)
- Convert a Java rock to a Glk rock.
-
destroy()
- Destroy this object and the underlying Glk object.
-
finalize()
- If the Glk object is still in existence when this object is
garbage-collected, destroy it.
-
getClassCount()
- Count Glk classes.
-
getDispatchRock()
- Get this object's dispatch rock.
-
getRock()
- Return this object's rock.
-
iterate(int, OpaqueObject, Object[])
- Generalised iterator.
-
setRegistry(ObjectRegistry)
- Set an opaque object registry.
-
toString()
- Text representation of this object.
m_dispid
protected int m_dispid
- Reference to the underlying Glk object.
This is a unique integer; the C layer translates it to a pointer.
If m_dispid is 0, the Glk object has been destroyed by the Glk
library.
m_jrock
protected Object m_jrock
- Rock given to this object if it was created within Java.
If this is null, the object was created by Glk, and its
rock must be found by a glk_get_*_rock() call.
m_glkClass
protected int m_glkClass
- The number of the Glk class to which this object belongs.
- See Also:
- clWindow, clStream, clFileRef, clSoundChannel
clWindow
public static final int clWindow
- Glk class number for windows
clStream
public static final int clStream
- Glk class number for streams
clFileRef
public static final int clFileRef
- Glk class number for file references
clSoundChannel
public static final int clSoundChannel
- Glk class number for sound channels
OpaqueObject
protected OpaqueObject(int glkClass,
int dispid)
- Constructor.
- Parameters:
- glkClass - The Glk class this object is in.
- dispid - The dispatch ID assigned to this object.
toString
public String toString()
- Text representation of this object.
- Returns:
- A text string containing this object's Glk class,
identity, and rock.
- Overrides:
- toString in class Object
iterate
public static OpaqueObject iterate(int glkClass,
OpaqueObject o,
Object r[])
- Generalised iterator. For a given object, find the next
object of that class (ordering is arbitrary, but this will
find all objects of the chosen class). If the parameter "o"
is null, the first object of that class is returned.
- Parameters:
- glkClass - Glk class number of objects to iterate over
- o - null, or an object of the correct class.
- r - If not null, r[0] will be set to the returned object's rock.
- Returns:
- The next object, or null if there is no next object
finalize
protected void finalize()
- If the Glk object is still in existence when this object is
garbage-collected, destroy it.
- Overrides:
- finalize in class Object
destroy
protected void destroy()
- Destroy this object and the underlying Glk object. This method
must be overridden in subclasses since Glk has no way of
destroying an object of unknown type.
getRock
public Object getRock()
- Return this object's rock. If the object was created by Glk,
the rock will be of class Long. Otherwise it can be any class.
- Returns:
- The object's rock.
castRock
protected static int castRock(Object object)
- Convert a Java rock to a Glk rock.
Glk for Java allows a rock to be an object of any type,
by storing the rock in the Java layer rather than the underlying
Glk layer. However, if the object really is a number, then
there's no harm it setting it at the Glk level as well as
the Java level.
- Parameters:
- object - Any object.
- Returns:
- If object is a number, its integer value. Otherwise 0.
getClassCount
public static int getClassCount()
- Count Glk classes.
- Returns:
- The number of Glk object classes in the underlying
Glk library.
getDispatchRock
public Object getDispatchRock()
- Get this object's dispatch rock. This will only have
been set if an opaque object registry is in use.
- Returns:
- The dispatch rock.
setRegistry
public static void setRegistry(ObjectRegistry r)
- Set an opaque object registry. It will be called when
opaque objects are created or destroyed.
- Parameters:
- r - An instance of your object registry.
All Packages Class Hierarchy This Package Previous Next Index