php.java.bridge
Class GlobalRef

java.lang.Object
  extended by php.java.bridge.GlobalRef

 class GlobalRef
extends java.lang.Object

A global array of object references that the client keeps during the connection (int -> Object mappings). After connection shutdown the request-handling bridge instance and its global ref array are destroyed. We guarantee that the first ref ID is 1 and that each new ref ID is n+1. This can be used to avoid round-trips by "guessing" the next object ID, see java_begin_document()/java_end_document().


Nested Class Summary
(package private)  class GlobalRef.Entry
           
 
Field Summary
static int DEFAULT_SIZE
          The default size (prime).
 
Constructor Summary
GlobalRef()
          Create a new global ref table.
GlobalRef(int initialCapacity)
           
 
Method Summary
 int append(java.lang.Object value)
          Append an object to the global ref table.
 java.lang.String dump()
          Return a string representation of the global ref table.
 java.lang.Object get(int id)
          Get the object associated with the ref ID
 void remove(int id)
          Remove an element from the table.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE
The default size (prime).

See Also:
Constant Field Values
Constructor Detail

GlobalRef

public GlobalRef(int initialCapacity)

GlobalRef

public GlobalRef()
Create a new global ref table. Must be called for each new or recycled JavaBridge instance.

Method Detail

get

public java.lang.Object get(int id)
Get the object associated with the ref ID

Parameters:
id - The ref ID
Returns:
The associated object.
Throws:
java.lang.NullPointerException - if ref ID does not exist.

remove

public void remove(int id)
Remove an element from the table.

Parameters:
id - The ref ID.

dump

public java.lang.String dump()
Return a string representation of the global ref table.

Returns:
The string representation.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

append

public int append(java.lang.Object value)
Append an object to the global ref table.

Parameters:
value - The value, may be null or PhpNull
Returns:
The ref ID.