FileDocCategorySizeDatePackage
Reference.javaAPI DocphoneME MR2 API (J2ME)6224Wed May 02 18:00:38 BST 2007com.sun.midp.io.j2me.jcrmi

Reference

public class Reference extends Object implements javax.microedition.jcrmi.RemoteRef
JCRMI remote reference.

Fields Summary
private Protocol
connection
Remote reference uses this connection for card communication.
private short
objectID
Remote object identifier.
private String
hashModifier
Anticollision string for remote object.
private String
className
The name of the most specific remote interface implemented by remote object.
Constructors Summary
Reference(Protocol connection, short objectID, String hashModifier, String className)
Creates new remote reference object.

param
connection Remote reference uses this connection for card communication.
param
objectID Remote object identifier.
param
hashModifier Anticollision string for remote object in UTF-8 representation.
param
className the name of the most specific remote interface implemented by remote object.


        this.connection = connection;
        this.objectID = objectID;
        this.hashModifier = hashModifier;
        this.className = className;
    
Methods Summary
java.lang.StringgetClassName()
Returns the name of the most specific remote interface implemented by remote object.

return
the name of interface

        return className;
    
java.lang.StringgetHashModifier()
Returns hash modifier for this reference.

return
hash modifier

        return hashModifier;
    
shortgetObjectID()
Returns object identifier for this reference.

return
object identifier

        return objectID;
    
public java.lang.Objectinvoke(java.lang.String method, java.lang.Object[] params)
Invokes a remote method.

A remote method invocation consists of three steps:

  1. Marshall the representation for the method and parameters.

  2. Communicate the method invocation to the host and unmarshall the return value or exception returned.

  3. Return the result of the method invocation to the caller.

The remote method invoked on the card can throw an exception to signal that an unexpected condition has been detected.

If the exception thrown on the card is an exception defined in the Java Card 2.2 API, then the same exception is thrown to the stub method. The client can access the reason code associated with Java Card-specific exceptions using the standard getReason() method.

If the exception thrown on the card is a subclass of an exception defined in the Java Card 2.2 API, then the closest exception defined in the API (along with the reason code, if applicable) is thrown to the stub method. The detail message string of the exception object may indicate that exception subclass was thrown on the card.

Apart from the exceptions thrown by the remote method itself, errors during communication, marshalling, protocol handling, unmarshalling, stub object instantiation, and so on, related to the JCRMI method invocation, results in a RemoteException being thrown to the stub method.

param
method simple (not fully qualified) name of the method followed by the method descriptor. Representation of a method descriptor is the same as that described in The Java Virtual Machine Specification (§ 4.3.3)
param
params the parameter list
return
result of remote method invocation
exception
java.lang.Exception if any exception occurs during the remote method invocation

        return connection.invoke(this, method, params);
    
public booleanremoteEquals(javax.microedition.jcrmi.RemoteRef obj)
Compares two remote references. Two remote references are equal if they refer to the same remote object.

param
obj - the Object to compare with
return
true if these Objects are equal; false otherwise


        if (obj == null || ! (obj instanceof Reference)) {
            return false;
        }

        Reference r = (Reference) obj;
        if (r.objectID != objectID) {
            return false;
        }

        if (r.connection == connection) {
            return true;
        }

        return (r.connection.getCardSessionId() ==
                connection.getCardSessionId()) &&
                r.connection.isOpened() &&
                connection.isOpened();
    
public intremoteHashCode()
Returns a hashcode for a remote object. Two remote object stubs that refer to the same remote object will have the same hash code.

return
the remote object hashcode

        return connection.getCardSessionId() << 16 + objectID;