FileDocCategorySizeDatePackage
Link.javaAPI DocphoneME MR2 API (J2ME)4576Wed May 02 18:00:02 BST 2007com.sun.midp.links

Link

public class Link extends Object

Fields Summary
private Link
emptyLinkCache
private int
nativePointer
Constructors Summary
Link()
Creates a new, empty link. This link must be filled in by native code before it can be used.

    
Methods Summary
public native voidclose()

public booleanequals(java.lang.Object obj)

        return
            obj instanceof Link
            && ((Link)obj).nativePointer == this.nativePointer;
    
private native voidfinalize()

public inthashCode()

        return nativePointer;
    
private native voidinit0(int sender, int receiver)

public native booleanisOpen()

public static com.sun.midp.links.LinknewLink(com.sun.cldc.isolate.Isolate sender, com.sun.cldc.isolate.Isolate receiver)

        int rid = receiver.id();  // throws NullPointerException
        int sid = sender.id();    // throws NullPointerException

        if (rid == -1 || sid == -1
                || receiver.isTerminated() || sender.isTerminated() ) {
            throw new IllegalStateException();
        }

        /*
         * IMPL_NOTE - this has race conditions. One of the isolates can
         * change state between the test and the call to init0().
         */

        Link link = new Link();
        link.init0(sender.id(), receiver.id());
        return link;
    
public LinkMessagereceive()
Throws IllegalArgumentException if the calling thread is not in the receiving isolate for this link. (Note: this differs from the JSR-121 specification, which states that UnsupportedOperationException should be thrown in this case. That exception doesn't appear in CLDC, so IllegalArgumentException is thrown instead.)

        Link emptyLink;
        LinkMessage msg = new LinkMessage();

        synchronized (this) {
            if (emptyLinkCache == null) {
                emptyLink = new Link();
            } else {
                emptyLink = emptyLinkCache;
                emptyLinkCache = null;
            }
        }

        receive0(msg, emptyLink);

        if (!msg.containsLink()) {
            synchronized (this) {
                if (emptyLinkCache == null) {
                    emptyLinkCache = emptyLink;
                }
            }
        }

        return msg;
    
private native voidreceive0(LinkMessage msg, com.sun.midp.links.Link link)

public voidsend(LinkMessage lm)
Throws IllegalArgumentException if the calling thread is not in the sending isolate for this link. (Note: this differs from the JSR-121 specification, which states that UnsupportedOperationException should be thrown in this case. That exception doesn't appear in CLDC, so IllegalArgumentException is thrown instead.)

        if (lm == null) {
            throw new NullPointerException();
        }
        send0(lm);
    
private native voidsend0(LinkMessage msg)