    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *     http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.configuration2.tree;
    018
    019/**
    020 * <p>
    021 * Definition of a <em>Visitor</em> interface for a configuration node
    022 * structure.
    023 * </p>
    024 * <p>
    025 * This is a typical application of the GoF <em>Visitor</em> pattern. An object
    026 * implementing this interface can be used to traverse a hierarchical structure
    027 * of nodes in various ways. The type of the nodes in the structure is generic;
    028 * a corresponding {@link NodeHandler} implementation must be available for
    029 * navigating through the structure.
    030 * </p>
    031 * <p>
    032 * Note that the exact way the methods of a {@code ConfigurationNodeVisitor} are
    033 * invoked is dependent on a specific traversal process.
    034 * </p>
    035 *
    036 * @since 1.3
    037 * @param <T> the type of the nodes processed by this visitor
    038 */
    039public interface ConfigurationNodeVisitor<T>
    040{
    041    /**
    042     * Visits the specified node before the children of this node - if existing
    043     * - are processed.
    044     *
    045     * @param node the node to be visited
    046     * @param handler the {@code NodeHandler}
    047     */
    048    void visitBeforeChildren(T node, NodeHandler<T> handler);
    049
    050    /**
    051     * Visits the specified node after after its children - if existing - have
    052     * been processed.
    053     *
    054     * @param node the node to be visited
    055     * @param handler the {@code NodeHandler}
    056     */
    057    void visitAfterChildren(T node, NodeHandler<T> handler);
    058
    059    /**
    060     * Returns a flag whether the current visit process should be aborted. This
    061     * method allows a visitor implementation to state that it does not need any
    062     * further data. It may be used e.g. by visitors that search for a certain
    063     * node in the hierarchy. After that node was found, there is no need to
    064     * process the remaining nodes, too. This method is called after each
    065     * visited node. A result of <strong>true</strong> indicates that the
    066     * current iteration is to be aborted.
    067     *
    068     * @return a flag if the visit process should be stopped
    069     */
    070    boolean terminate();
    071}