what is this?

Discussion in 'Java' started by [XaToA], Jul 27, 2003.

  1. [XaToA]

    [XaToA] Guest

    [XaToA], Jul 27, 2003
    #1
    1. Advertising

  2. "[XaToA]" <>, Sun, 27 Jul 2003 11:21:55 +0200:

    > can anybody says me what is this page?
    > http://www.onjava.com/pub/a/onjava/2001/02/08/dom.html?page=2
    >
    > i try to make one class with the interface code but appears this error:
    > illegal start of type
    > const short ..
    >
    > how can i implements this code , interface code, into one class?
    > thanks


    Make it a "final static" instead of a const. It's not entirely the same,
    but it will have the same purpose that way.

    Greets
    Bhun.
    dhek bhun kho, Jul 27, 2003
    #2
    1. Advertising

  3. On Sun, 27 Jul 2003 11:21:55 +0200, "[XaToA]" <>
    wrote:

    > can anybody says me what is this page?
    > http://www.onjava.com/pub/a/onjava/2001/02/08/dom.html?page=2
    >
    > i try to make one class with the interface code but appears this error:
    > illegal start of type
    > const short ..
    >
    > how can i implements this code , interface code, into one class?
    > thanks


    NodeFiler is an interface defined in xerces.jar, it's full name
    is org.w3c.dom.traversal.NodeFilter. This is not something you
    need to compile, I believe the author was just showing the
    definition for further explanation of the use of NodeFilter and
    its static values. But unfortunately, this is not valid Java
    code (const and unsigned are invalid in Java, they are C/C++
    keywords). So I have no idea where that code came from, but the
    actual code for NodeFilter from Xerces 1.4.4 below.

    Hope this helps.

    --Joe

    --------

    /*
    * Copyright (c) 2000 World Wide Web Consortium,
    * (Massachusetts Institute of Technology, Institut National de
    * Recherche en Informatique et en Automatique, Keio University). All
    * Rights Reserved. This program is distributed under the W3C's Software
    * Intellectual Property License. This program is distributed in the
    * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
    * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    * PURPOSE.
    * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
    */

    package org.w3c.dom.traversal;

    import org.w3c.dom.Node;

    /**
    * Filters are objects that know how to "filter out" nodes. If a
    * <code>NodeIterator</code> or <code>TreeWalker</code> is given a
    * <code>NodeFilter</code>, it applies the filter before it returns the next
    * node. If the filter says to accept the node, the traversal logic returns
    * it; otherwise, traversal looks for the next node and pretends that the
    * node that was rejected was not there.
    * <p>The DOM does not provide any filters. <code>NodeFilter</code> is just an
    * interface that users can implement to provide their own filters.
    * <p><code>NodeFilters</code> do not need to know how to traverse from node
    * to node, nor do they need to know anything about the data structure that
    * is being traversed. This makes it very easy to write filters, since the
    * only thing they have to know how to do is evaluate a single node. One
    * filter may be used with a number of different kinds of traversals,
    * encouraging code reuse.
    * <p>See also the <a
    href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document
    Object Model (DOM) Level 2 Traversal and Range Specification</a>.
    * @since DOM Level 2
    */
    public interface NodeFilter {
    // Constants returned by acceptNode
    /**
    * Accept the node. Navigation methods defined for
    * <code>NodeIterator</code> or <code>TreeWalker</code> will return this
    * node.
    */
    public static final short FILTER_ACCEPT = 1;
    /**
    * Reject the node. Navigation methods defined for
    * <code>NodeIterator</code> or <code>TreeWalker</code> will not return
    * this node. For <code>TreeWalker</code>, the children of this node
    * will also be rejected. <code>NodeIterators</code> treat this as a
    * synonym for <code>FILTER_SKIP</code>.
    */
    public static final short FILTER_REJECT = 2;
    /**
    * Skip this single node. Navigation methods defined for
    * <code>NodeIterator</code> or <code>TreeWalker</code> will not return
    * this node. For both <code>NodeIterator</code> and
    * <code>TreeWalker</code>, the children of this node will still be
    * considered.
    */
    public static final short FILTER_SKIP = 3;

    // Constants for whatToShow
    /**
    * Show all <code>Nodes</code>.
    */
    public static final int SHOW_ALL = 0xFFFFFFFF;
    /**
    * Show <code>Element</code> nodes.
    */
    public static final int SHOW_ELEMENT = 0x00000001;
    /**
    * Show <code>Attr</code> nodes. This is meaningful only when creating an
    * iterator or tree-walker with an attribute node as its
    * <code>root</code>; in this case, it means that the attribute node
    * will appear in the first position of the iteration or traversal.
    * Since attributes are never children of other nodes, they do not
    * appear when traversing over the document tree.
    */
    public static final int SHOW_ATTRIBUTE = 0x00000002;
    /**
    * Show <code>Text</code> nodes.
    */
    public static final int SHOW_TEXT = 0x00000004;
    /**
    * Show <code>CDATASection</code> nodes.
    */
    public static final int SHOW_CDATA_SECTION = 0x00000008;
    /**
    * Show <code>EntityReference</code> nodes.
    */
    public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
    /**
    * Show <code>Entity</code> nodes. This is meaningful only when creating
    * an iterator or tree-walker with an<code> Entity</code> node as its
    * <code>root</code>; in this case, it means that the <code>Entity</code>
    * node will appear in the first position of the traversal. Since
    * entities are not part of the document tree, they do not appear when
    * traversing over the document tree.
    */
    public static final int SHOW_ENTITY = 0x00000020;
    /**
    * Show <code>ProcessingInstruction</code> nodes.
    */
    public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
    /**
    * Show <code>Comment</code> nodes.
    */
    public static final int SHOW_COMMENT = 0x00000080;
    /**
    * Show <code>Document</code> nodes.
    */
    public static final int SHOW_DOCUMENT = 0x00000100;
    /**
    * Show <code>DocumentType</code> nodes.
    */
    public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
    /**
    * Show <code>DocumentFragment</code> nodes.
    */
    public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
    /**
    * Show <code>Notation</code> nodes. This is meaningful only when creating
    * an iterator or tree-walker with a <code>Notation</code> node as its
    * <code>root</code>; in this case, it means that the
    * <code>Notation</code> node will appear in the first position of the
    * traversal. Since notations are not part of the document tree, they do
    * not appear when traversing over the document tree.
    */
    public static final int SHOW_NOTATION = 0x00000800;

    /**
    * Test whether a specified node is visible in the logical view of a
    * <code>TreeWalker</code> or <code>NodeIterator</code>. This function
    * will be called by the implementation of <code>TreeWalker</code> and
    * <code>NodeIterator</code>; it is not normally called directly from
    * user code. (Though you could do so if you wanted to use the same
    * filter to guide your own application logic.)
    * @param nThe node to check to see if it passes the filter or not.
    * @return a constant to determine whether the node is accepted,
    * rejected, or skipped, as defined above.
    */
    public short acceptNode(Node n);

    }
    Joseph Millar, Jul 27, 2003
    #3
  4. [XaToA]

    [XaToA] Guest

    i am trying to import:
    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xerces.dom.traversal.NodeIteratorImpl;
    import org.apache.xerces.dom.DocumentImpl;
    import org.apache.xerces.domx.traversal.NodeFilter;

    and appears this error.


    file.java [29:1] package org.apache.xerces.dom.traversal does not exist
    import org.apache.xerces.dom.traversal.NodeIteratorImpl;
    ^
    file.java [31:1] package org.apache.xerces.domx.traversal does not exist
    import org.apache.xerces.domx.traversal.NodeFilter;
    ^


    what jar file must i download for putting in my classpasth?
    where can i find this file?
    thanks


    "Joseph Millar" <> escribió en el mensaje
    news:...
    > On Sun, 27 Jul 2003 11:21:55 +0200, "[XaToA]"

    <>
    > wrote:
    >
    > > can anybody says me what is this page?
    > > http://www.onjava.com/pub/a/onjava/2001/02/08/dom.html?page=2
    > >
    > > i try to make one class with the interface code but appears this error:
    > > illegal start of type
    > > const short ..
    > >
    > > how can i implements this code , interface code, into one class?
    > > thanks

    >
    > NodeFiler is an interface defined in xerces.jar, it's full name
    > is org.w3c.dom.traversal.NodeFilter. This is not something you
    > need to compile, I believe the author was just showing the
    > definition for further explanation of the use of NodeFilter and
    > its static values. But unfortunately, this is not valid Java
    > code (const and unsigned are invalid in Java, they are C/C++
    > keywords). So I have no idea where that code came from, but the
    > actual code for NodeFilter from Xerces 1.4.4 below.
    >
    > Hope this helps.
    >
    > --Joe
    >
    > --------
    >
    > /*
    > * Copyright (c) 2000 World Wide Web Consortium,
    > * (Massachusetts Institute of Technology, Institut National de
    > * Recherche en Informatique et en Automatique, Keio University). All
    > * Rights Reserved. This program is distributed under the W3C's Software
    > * Intellectual Property License. This program is distributed in the
    > * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
    > * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    > * PURPOSE.
    > * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
    > */
    >
    > package org.w3c.dom.traversal;
    >
    > import org.w3c.dom.Node;
    >
    > /**
    > * Filters are objects that know how to "filter out" nodes. If a
    > * <code>NodeIterator</code> or <code>TreeWalker</code> is given a
    > * <code>NodeFilter</code>, it applies the filter before it returns the

    next
    > * node. If the filter says to accept the node, the traversal logic

    returns
    > * it; otherwise, traversal looks for the next node and pretends that the
    > * node that was rejected was not there.
    > * <p>The DOM does not provide any filters. <code>NodeFilter</code> is

    just an
    > * interface that users can implement to provide their own filters.
    > * <p><code>NodeFilters</code> do not need to know how to traverse from

    node
    > * to node, nor do they need to know anything about the data structure

    that
    > * is being traversed. This makes it very easy to write filters, since the
    > * only thing they have to know how to do is evaluate a single node. One
    > * filter may be used with a number of different kinds of traversals,
    > * encouraging code reuse.
    > * <p>See also the <a
    >

    href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Do
    cument
    > Object Model (DOM) Level 2 Traversal and Range Specification</a>.
    > * @since DOM Level 2
    > */
    > public interface NodeFilter {
    > // Constants returned by acceptNode
    > /**
    > * Accept the node. Navigation methods defined for
    > * <code>NodeIterator</code> or <code>TreeWalker</code> will return

    this
    > * node.
    > */
    > public static final short FILTER_ACCEPT = 1;
    > /**
    > * Reject the node. Navigation methods defined for
    > * <code>NodeIterator</code> or <code>TreeWalker</code> will not

    return
    > * this node. For <code>TreeWalker</code>, the children of this node
    > * will also be rejected. <code>NodeIterators</code> treat this as a
    > * synonym for <code>FILTER_SKIP</code>.
    > */
    > public static final short FILTER_REJECT = 2;
    > /**
    > * Skip this single node. Navigation methods defined for
    > * <code>NodeIterator</code> or <code>TreeWalker</code> will not

    return
    > * this node. For both <code>NodeIterator</code> and
    > * <code>TreeWalker</code>, the children of this node will still be
    > * considered.
    > */
    > public static final short FILTER_SKIP = 3;
    >
    > // Constants for whatToShow
    > /**
    > * Show all <code>Nodes</code>.
    > */
    > public static final int SHOW_ALL = 0xFFFFFFFF;
    > /**
    > * Show <code>Element</code> nodes.
    > */
    > public static final int SHOW_ELEMENT = 0x00000001;
    > /**
    > * Show <code>Attr</code> nodes. This is meaningful only when creating

    an
    > * iterator or tree-walker with an attribute node as its
    > * <code>root</code>; in this case, it means that the attribute node
    > * will appear in the first position of the iteration or traversal.
    > * Since attributes are never children of other nodes, they do not
    > * appear when traversing over the document tree.
    > */
    > public static final int SHOW_ATTRIBUTE = 0x00000002;
    > /**
    > * Show <code>Text</code> nodes.
    > */
    > public static final int SHOW_TEXT = 0x00000004;
    > /**
    > * Show <code>CDATASection</code> nodes.
    > */
    > public static final int SHOW_CDATA_SECTION = 0x00000008;
    > /**
    > * Show <code>EntityReference</code> nodes.
    > */
    > public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
    > /**
    > * Show <code>Entity</code> nodes. This is meaningful only when

    creating
    > * an iterator or tree-walker with an<code> Entity</code> node as its
    > * <code>root</code>; in this case, it means that the

    <code>Entity</code>
    > * node will appear in the first position of the traversal. Since
    > * entities are not part of the document tree, they do not appear when
    > * traversing over the document tree.
    > */
    > public static final int SHOW_ENTITY = 0x00000020;
    > /**
    > * Show <code>ProcessingInstruction</code> nodes.
    > */
    > public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
    > /**
    > * Show <code>Comment</code> nodes.
    > */
    > public static final int SHOW_COMMENT = 0x00000080;
    > /**
    > * Show <code>Document</code> nodes.
    > */
    > public static final int SHOW_DOCUMENT = 0x00000100;
    > /**
    > * Show <code>DocumentType</code> nodes.
    > */
    > public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
    > /**
    > * Show <code>DocumentFragment</code> nodes.
    > */
    > public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
    > /**
    > * Show <code>Notation</code> nodes. This is meaningful only when

    creating
    > * an iterator or tree-walker with a <code>Notation</code> node as its
    > * <code>root</code>; in this case, it means that the
    > * <code>Notation</code> node will appear in the first position of the
    > * traversal. Since notations are not part of the document tree, they

    do
    > * not appear when traversing over the document tree.
    > */
    > public static final int SHOW_NOTATION = 0x00000800;
    >
    > /**
    > * Test whether a specified node is visible in the logical view of a
    > * <code>TreeWalker</code> or <code>NodeIterator</code>. This function
    > * will be called by the implementation of <code>TreeWalker</code> and
    > * <code>NodeIterator</code>; it is not normally called directly from
    > * user code. (Though you could do so if you wanted to use the same
    > * filter to guide your own application logic.)
    > * @param nThe node to check to see if it passes the filter or not.
    > * @return a constant to determine whether the node is accepted,
    > * rejected, or skipped, as defined above.
    > */
    > public short acceptNode(Node n);
    >
    > }
    >
    >
    [XaToA], Jul 27, 2003
    #4
  5. On Sun, 27 Jul 2003 13:34:07 +0200, "[XaToA]" <>
    wrote:

    > i am trying to import:
    > import org.apache.xerces.parsers.DOMParser;
    > import org.apache.xerces.dom.traversal.NodeIteratorImpl;
    > import org.apache.xerces.dom.DocumentImpl;
    > import org.apache.xerces.domx.traversal.NodeFilter;
    >
    > and appears this error.
    >
    >
    > file.java [29:1] package org.apache.xerces.dom.traversal does not exist
    > import org.apache.xerces.dom.traversal.NodeIteratorImpl;
    > ^


    NodeIteratorImpl is in package org.apache.xerces.dom.NodeIteratorImpl.

    The source code for 2.4.0 has this class in the first package,
    but the binary has it in the same place as 1.4.4. It's a bit
    confusing, but I have to think the binary is correct.

    > file.java [31:1] package org.apache.xerces.domx.traversal does not exist
    > import org.apache.xerces.domx.traversal.NodeFilter;
    > ^


    NodeFilter is in package org.w3c.dom.traversal.NodeFilter.

    > what jar file must i download for putting in my classpasth?
    > where can i find this file?


    Both of these classes are in Xerces.jar 1.4.4. See the first
    page of the article for where to download it from.

    http://xml.apache.org/dist/xerces-j/

    Try making those changes and see if that works. Not sure why
    Ms. Fesler has those classes in other packages, but I'm not an
    XML expert (yet).

    --Joe
    Joseph Millar, Jul 27, 2003
    #5
  6. [XaToA]

    Roedy Green Guest

    On Sun, 27 Jul 2003 11:21:55 +0200, "[XaToA]"
    <> wrote or quoted :

    >i try to make one class with the interface code but appears this error:
    >illegal start of type
    > const short ..


    const unsigned long SHOW_NOTATION = 0x00000800;
    short acceptNode(in Node n);
    };

    const and in are not Java keywords. This looks very like Java, but it
    is not Java.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 30, 2003
    #6
  7. [XaToA]

    pete kirkham Guest

    In common with all DOM interfaces, (see http://www.w3.org/DOM/) the
    interface in the excerpt is written in IDL (Interface description
    language).

    Get a CORBA implementation or an IDL to java compiler and it'll generate
    some suitable Java representation of the interface.


    Pete
    pete kirkham, Jul 30, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page