Visitor xref

View Javadoc

    1   /*
    2    * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
    3    *
    4    * This software is open source.
    5    * See the bottom of this file for the licence.
    6    */
    7
    8   package org.dom4j;
    9
    10  /***
    11   * <p>
    12   * <code>Visitor</code> is used to implement the <code>Visitor</code>
    13   * pattern in DOM4J. An object of this interface can be passed to a
    14   * <code>Node</code> which will then call its typesafe methods. Please refer
    15   * to the <i>Gang of Four </i> book of Design Patterns for more details on the
    16   * <code>Visitor</code> pattern.
    17   * </p>
    18   *
    19   * <p>
    20   * This <a href="http://www.patterndepot.com/put/8/JavaPatterns.htm">site </a>
    21   * has further discussion on design patterns and links to the GOF book. This <a
    22   * href="http://www.patterndepot.com/put/8/visitor.pdf">link </a> describes the
    23   * Visitor pattern in detail.
    24   * </p>
    25   *
    26   * @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a>
    27   * @version $Revision: 1.8 $
    28   */
    29  public interface Visitor {
    30      /***
    31       * <p>
    32       * Visits the given <code>Document</code>
    33       * </p>
    34       *
    35       * @param document
    36       *            is the <code>Document</code> node to visit.
    37       */
    38      void visit(Document document);
    39
    40      /***
    41       * <p>
    42       * Visits the given <code>DocumentType</code>
    43       * </p>
    44       *
    45       * @param documentType
    46       *            is the <code>DocumentType</code> node to visit.
    47       */
    48      void visit(DocumentType documentType);
    49
    50      /***
    51       * <p>
    52       * Visits the given <code>Element</code>
    53       * </p>
    54       *
    55       * @param node
    56       *            is the <code>Element</code> node to visit.
    57       */
    58      void visit(Element node);
    59
    60      /***
    61       * <p>
    62       * Visits the given <code>Attribute</code>
    63       * </p>
    64       *
    65       * @param node
    66       *            is the <code>Attribute</code> node to visit.
    67       */
    68      void visit(Attribute node);
    69
    70      /***
    71       * <p>
    72       * Visits the given <code>CDATA</code>
    73       * </p>
    74       *
    75       * @param node
    76       *            is the <code>CDATA</code> node to visit.
    77       */
    78      void visit(CDATA node);
    79
    80      /***
    81       * <p>
    82       * Visits the given <code>Comment</code>
    83       * </p>
    84       *
    85       * @param node
    86       *            is the <code>Comment</code> node to visit.
    87       */
    88      void visit(Comment node);
    89
    90      /***
    91       * <p>
    92       * Visits the given <code>Entity</code>
    93       * </p>
    94       *
    95       * @param node
    96       *            is the <code>Entity</code> node to visit.
    97       */
    98      void visit(Entity node);
    99
    100     /***
    101      * <p>
    102      * Visits the given <code>Namespace</code>
    103      * </p>
    104      *
    105      * @param namespace
    106      *            is the <code>Namespace</code> node to visit.
    107      */
    108     void visit(Namespace namespace);
    109
    110     /***
    111      * <p>
    112      * Visits the given <code>ProcessingInstruction</code>
    113      * </p>
    114      *
    115      * @param node
    116      *            is the <code>ProcessingInstruction</code> node to visit.
    117      */
    118     void visit(ProcessingInstruction node);
    119
    120     /***
    121      * <p>
    122      * Visits the given <code>Text</code>
    123      * </p>
    124      *
    125      * @param node
    126      *            is the <code>Text</code> node to visit.
    127      */
    128     void visit(Text node);
    129 }
    130
    131 /*
    132  * Redistribution and use of this software and associated documentation
    133  * ("Software"), with or without modification, are permitted provided that the
    134  * following conditions are met:
    135  *
    136  * 1. Redistributions of source code must retain copyright statements and
    137  * notices. Redistributions must also contain a copy of this document.
    138  *
    139  * 2. Redistributions in binary form must reproduce the above copyright notice,
    140  * this list of conditions and the following disclaimer in the documentation
    141  * and/or other materials provided with the distribution.
    142  *
    143  * 3. The name "DOM4J" must not be used to endorse or promote products derived
    144  * from this Software without prior written permission of MetaStuff, Ltd. For
    145  * written permission, please contact dom4j-info@metastuff.com.
    146  *
    147  * 4. Products derived from this Software may not be called "DOM4J" nor may
    148  * "DOM4J" appear in their names without prior written permission of MetaStuff,
    149  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
    150  *
    151  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
    152  *
    153  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
    154  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    155  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    156  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
    157  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    158  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    159  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    160  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    161  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    162  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    163  * POSSIBILITY OF SUCH DAMAGE.
    164  *
    165  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
    166  */