31 March 2003

Appendix D: Java Language Binding

This appendix contains the complete Java [Java] bindings for the Level 3 Document Object Model Events.

The Java files are also available as http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/java-binding.zip

org/w3c/dom/events/EventException.java:

package org.w3c.dom.events;

public class EventException extends RuntimeException {
    public EventException(short code, String message) {
       super(message);
       this.code = code;
    }
    public short   code;
    // EventExceptionCode
    public static final short UNSPECIFIED_EVENT_TYPE_ERR = 0;
    public static final short DISPATCH_REQUEST_ERR      = 1;

}

org/w3c/dom/events/Event.java:

package org.w3c.dom.events;

public interface Event {
    // PhaseType
    public static final short CAPTURING_PHASE           = 1;
    public static final short AT_TARGET                 = 2;
    public static final short BUBBLING_PHASE            = 3;

    public String getType();

    public EventTarget getTarget();

    public EventTarget getCurrentTarget();

    public short getEventPhase();

    public boolean getBubbles();

    public boolean getCancelable();

    public long getTimeStamp();

    public void stopPropagation();

    public void preventDefault();

    public void initEvent(String eventTypeArg, 
                          boolean canBubbleArg, 
                          boolean cancelableArg);

    public String getNamespaceURI();

    public boolean isCustom();

    public void stopImmediatePropagation();

    public boolean isDefaultPrevented();

    public void initEventNS(String namespaceURIArg, 
                            String eventTypeArg, 
                            boolean canBubbleArg, 
                            boolean cancelableArg);

}

org/w3c/dom/events/EventTarget.java:

package org.w3c.dom.events;

public interface EventTarget {
    public void addEventListener(String type, 
                                 EventListener listener, 
                                 boolean useCapture);

    public void removeEventListener(String type, 
                                    EventListener listener, 
                                    boolean useCapture);

    public boolean dispatchEvent(Event evt)
                                 throws EventException;

    public void addEventListenerNS(String namespaceURI, 
                                   String type, 
                                   EventListener listener, 
                                   boolean useCapture, 
                                   Object evtGroup);

    public void removeEventListenerNS(String namespaceURI, 
                                      String type, 
                                      EventListener listener, 
                                      boolean useCapture);

    public boolean willTriggerNS(String namespaceURI, 
                                 String type);

    public boolean hasEventListenerNS(String namespaceURI, 
                                      String type);

}

org/w3c/dom/events/EventListener.java:

package org.w3c.dom.events;

public interface EventListener {
    public void handleEvent(Event evt);

}

org/w3c/dom/events/DocumentEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.DOMException;

public interface DocumentEvent {
    public Event createEvent(String eventType)
                             throws DOMException;

    public boolean canDispatch(String namespaceURI, 
                               String type);

}

org/w3c/dom/events/CustomEvent.java:

package org.w3c.dom.events;

public interface CustomEvent extends Event {
    public void setDispatchState(EventTarget target, 
                                 short phase);

    public boolean isPropagationStopped();

    public boolean isImmediatePropagationStopped();

}

org/w3c/dom/events/UIEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.views.AbstractView;

public interface UIEvent extends Event {
    public AbstractView getView();

    public int getDetail();

    public void initUIEvent(String typeArg, 
                            boolean canBubbleArg, 
                            boolean cancelableArg, 
                            AbstractView viewArg, 
                            int detailArg);

    public void initUIEventNS(String namespaceURI, 
                              String typeArg, 
                              boolean canBubbleArg, 
                              boolean cancelableArg, 
                              AbstractView viewArg, 
                              int detailArg);

}

org/w3c/dom/events/TextEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.views.AbstractView;

public interface TextEvent extends UIEvent {
    public String getData();

    public void initTextEvent(String typeArg, 
                              boolean canBubbleArg, 
                              boolean cancelableArg, 
                              AbstractView viewArg, 
                              String dataArg);

    public void initTextEventNS(String namespaceURI, 
                                String type, 
                                boolean canBubbleArg, 
                                boolean cancelableArg, 
                                AbstractView viewArg, 
                                String dataArg);

}

org/w3c/dom/events/MouseEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.views.AbstractView;

public interface MouseEvent extends UIEvent {
    public int getScreenX();

    public int getScreenY();

    public int getClientX();

    public int getClientY();

    public boolean getCtrlKey();

    public boolean getShiftKey();

    public boolean getAltKey();

    public boolean getMetaKey();

    public short getButton();

    public EventTarget getRelatedTarget();

    public void initMouseEvent(String typeArg, 
                               boolean canBubbleArg, 
                               boolean cancelableArg, 
                               AbstractView viewArg, 
                               int detailArg, 
                               int screenXArg, 
                               int screenYArg, 
                               int clientXArg, 
                               int clientYArg, 
                               boolean ctrlKeyArg, 
                               boolean altKeyArg, 
                               boolean shiftKeyArg, 
                               boolean metaKeyArg, 
                               short buttonArg, 
                               EventTarget relatedTargetArg);

    public void initMouseEventNS(String namespaceURI, 
                                 String typeArg, 
                                 boolean canBubbleArg, 
                                 boolean cancelableArg, 
                                 AbstractView viewArg, 
                                 int detailArg, 
                                 int screenXArg, 
                                 int screenYArg, 
                                 int clientXArg, 
                                 int clientYArg, 
                                 boolean ctrlKeyArg, 
                                 boolean altKeyArg, 
                                 boolean shiftKeyArg, 
                                 boolean metaKeyArg, 
                                 short buttonArg, 
                                 EventTarget relatedTargetArg, 
                                 boolean altGraphKeyArg);

    public boolean getAltGraphKey();

}

org/w3c/dom/events/KeyboardEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.views.AbstractView;

public interface KeyboardEvent extends UIEvent {
    // KeyLocationCode
    public static final int DOM_KEY_LOCATION_STANDARD = 0x00;
    public static final int DOM_KEY_LOCATION_LEFT     = 0x01;
    public static final int DOM_KEY_LOCATION_RIGHT    = 0x02;
    public static final int DOM_KEY_LOCATION_NUMPAD   = 0x03;
    public static final int DOM_KEY_LOCATION_UNKNOWN  = 0x04;

    public String getKeyIdentifier();

    public int getKeyLocation();

    public boolean getCtrlKey();

    public boolean getShiftKey();

    public boolean getAltKey();

    public boolean getMetaKey();

    public boolean getAltGraphKey();

    public void initKeyboardEvent(String typeArg, 
                                  boolean canBubbleArg, 
                                  boolean cancelableArg, 
                                  AbstractView viewArg, 
                                  String keyIdentifierArg, 
                                  int keyLocationArg, 
                                  boolean ctrlKeyArg, 
                                  boolean shiftKeyArg, 
                                  boolean altKeyArg, 
                                  boolean metaKeyArg, 
                                  boolean altGraphKeyArg);

    public void initKeyboardEventNS(String namespaceURI, 
                                    String type, 
                                    boolean canBubbleArg, 
                                    boolean cancelableArg, 
                                    AbstractView viewArg, 
                                    String keyIdentifierArg, 
                                    int keyLocationArg, 
                                    boolean ctrlKeyArg, 
                                    boolean shiftKeyArg, 
                                    boolean altKeyArg, 
                                    boolean metaKeyArg, 
                                    boolean altGraphKeyArg);

}

org/w3c/dom/events/MutationEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.Node;

public interface MutationEvent extends Event {
    // attrChangeType
    public static final short MODIFICATION              = 1;
    public static final short ADDITION                  = 2;
    public static final short REMOVAL                   = 3;

    public Node getRelatedNode();

    public String getPrevValue();

    public String getNewValue();

    public String getAttrName();

    public short getAttrChange();

    public void initMutationEvent(String typeArg, 
                                  boolean canBubbleArg, 
                                  boolean cancelableArg, 
                                  Node relatedNodeArg, 
                                  String prevValueArg, 
                                  String newValueArg, 
                                  String attrNameArg, 
                                  short attrChangeArg);

    public void initMutationEventNS(String namespaceURI, 
                                    String typeArg, 
                                    boolean canBubbleArg, 
                                    boolean cancelableArg, 
                                    Node relatedNodeArg, 
                                    String prevValueArg, 
                                    String newValueArg, 
                                    String attrNameArg, 
                                    short attrChangeArg);

}

org/w3c/dom/events/MutationNameEvent.java:

package org.w3c.dom.events;

import org.w3c.dom.Node;

public interface MutationNameEvent extends MutationEvent {
    public String getPrevNamespaceURI();

    public String getPrevNodeName();

    public void initMutationNameEvent(String typeArg, 
                                      boolean canBubbleArg, 
                                      boolean cancelableArg, 
                                      Node relatedNodeArg, 
                                      String prevNamespaceURI, 
                                      String prevNodeName);

    public void initMutationNameEventNS(String namespaceURI, 
                                        String typeArg, 
                                        boolean canBubbleArg, 
                                        boolean cancelableArg, 
                                        Node relatedNodeArg, 
                                        String prevNamespaceURI, 
                                        String prevNodeName);

}