Java Language Binding

07 April 2004

# Appendix B: Java Language Binding

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

The Java files are also available as http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/java-binding.zip

### org/w3c/dom/ls/LSException.java:

    package org.w3c.dom.ls;

    public class LSException extends RuntimeException {
        public LSException(short code, String message) {
           super(message);
           this.code = code;
        }
        public short   code;
        // LSExceptionCode
        public static final short PARSE_ERR                 = 81;
        public static final short SERIALIZE_ERR             = 82;

    }

### org/w3c/dom/ls/DOMImplementationLS.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.DOMException;

    public interface DOMImplementationLS {
        // DOMImplementationLSMode
        public static final short MODE_SYNCHRONOUS          = 1;
        public static final short MODE_ASYNCHRONOUS         = 2;

        public LSParser createLSParser(short mode,
                                       String schemaType)
                                       throws DOMException;

        public LSSerializer createLSSerializer();

        public LSInput createLSInput();

        public LSOutput createLSOutput();

    }

### org/w3c/dom/ls/LSParser.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.Document;
    import org.w3c.dom.DOMConfiguration;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;

    public interface LSParser {
        public DOMConfiguration getDomConfig();

        public LSParserFilter getFilter();
        public void setFilter(LSParserFilter filter);

        public boolean getAsync();

        public boolean getBusy();

        public Document parse(LSInput input)
                              throws DOMException, LSException;

        public Document parseURI(String uri)
                                 throws DOMException, LSException;

        // ACTION_TYPES
        public static final short ACTION_APPEND_AS_CHILDREN = 1;
        public static final short ACTION_REPLACE_CHILDREN   = 2;
        public static final short ACTION_INSERT_BEFORE      = 3;
        public static final short ACTION_INSERT_AFTER       = 4;
        public static final short ACTION_REPLACE            = 5;

        public Node parseWithContext(LSInput input,
                                     Node contextArg,
                                     short action)
                                     throws DOMException, LSException;

        public void abort();

    }

### org/w3c/dom/ls/LSInput.java:

    package org.w3c.dom.ls;

    public interface LSInput {
        public java.io.Reader getCharacterStream();
        public void setCharacterStream(java.io.Reader characterStream);

        public java.io.InputStream getByteStream();
        public void setByteStream(java.io.InputStream byteStream);

        public String getStringData();
        public void setStringData(String stringData);

        public String getSystemId();
        public void setSystemId(String systemId);

        public String getPublicId();
        public void setPublicId(String publicId);

        public String getBaseURI();
        public void setBaseURI(String baseURI);

        public String getEncoding();
        public void setEncoding(String encoding);

        public boolean getCertifiedText();
        public void setCertifiedText(boolean certifiedText);

    }

### org/w3c/dom/ls/LSResourceResolver.java:

    package org.w3c.dom.ls;

    public interface LSResourceResolver {
        public LSInput resolveResource(String type,
                                       String namespaceURI,
                                       String publicId,
                                       String systemId,
                                       String baseURI);

    }

### org/w3c/dom/ls/LSParserFilter.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.Node;
    import org.w3c.dom.Element;

    public interface LSParserFilter {
        // Constants returned by startElement and acceptNode
        public static final short FILTER_ACCEPT             = 1;
        public static final short FILTER_REJECT             = 2;
        public static final short FILTER_SKIP               = 3;
        public static final short FILTER_INTERRUPT          = 4;

        public short startElement(Element elementArg);

        public short acceptNode(Node nodeArg);

        public int getWhatToShow();

    }

### org/w3c/dom/ls/LSProgressEvent.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.events.Event;

    public interface LSProgressEvent extends Event {
        public LSInput getInput();

        public int getPosition();

        public int getTotalSize();

    }

### org/w3c/dom/ls/LSLoadEvent.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.Document;
    import org.w3c.dom.events.Event;

    public interface LSLoadEvent extends Event {
        public Document getNewDocument();

        public LSInput getInput();

    }

### org/w3c/dom/ls/LSSerializer.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.DOMConfiguration;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;

    public interface LSSerializer {
        public DOMConfiguration getDomConfig();

        public String getNewLine();
        public void setNewLine(String newLine);

        public LSSerializerFilter getFilter();
        public void setFilter(LSSerializerFilter filter);

        public boolean write(Node nodeArg,
                             LSOutput destination)
                             throws LSException;

        public boolean writeToURI(Node nodeArg,
                                  String uri)
                                  throws LSException;

        public String writeToString(Node nodeArg)
                                    throws DOMException, LSException;

    }

### org/w3c/dom/ls/LSOutput.java:

    package org.w3c.dom.ls;

    public interface LSOutput {
        public java.io.Writer getCharacterStream();
        public void setCharacterStream(java.io.Writer characterStream);

        public java.io.OutputStream getByteStream();
        public void setByteStream(java.io.OutputStream byteStream);

        public String getSystemId();
        public void setSystemId(String systemId);

        public String getEncoding();
        public void setEncoding(String encoding);

    }

### org/w3c/dom/ls/LSSerializerFilter.java:

    package org.w3c.dom.ls;

    import org.w3c.dom.traversal.NodeFilter;

    public interface LSSerializerFilter extends NodeFilter {
        public int getWhatToShow();

    }