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 */ 017 package org.apache.commons.configuration.tree; 018 019 /** 020 * <p> 021 * Definition of a <em>Visitor</em> interface for a configuration node 022 * structure. 023 * </p> 024 * <p> 025 * The {@code ConfigurationNode} interface defines a {@code visit()}, 026 * which simplifies traversal of a complex node hierarchy. A configuration node 027 * implementation must provide a way of visiting all nodes in the current 028 * hierarchy. This is a typical application of the GoF <em>Visitor</em> 029 * pattern. 030 * </p> 031 * 032 * @since 1.3 033 * @see ConfigurationNode 034 * @author <a 035 * href="http://commons.apache.org/configuration/team-list.html">Commons 036 * Configuration team</a> 037 * @version $Id: ConfigurationNodeVisitor.java 1206463 2011-11-26 15:47:08Z oheger $ 038 */ 039 public interface ConfigurationNodeVisitor 040 { 041 /** 042 * Visits the specified node. This method is called before eventually 043 * existing children of this node are processed. 044 * 045 * @param node the node to be visited 046 */ 047 void visitBeforeChildren(ConfigurationNode node); 048 049 /** 050 * Visits the specified node. This method is called after eventually 051 * existing children of this node have been processed. 052 * 053 * @param node the node to be visited 054 */ 055 void visitAfterChildren(ConfigurationNode node); 056 057 /** 058 * Returns a flag whether the actual visit process should be aborted. This 059 * method allows a visitor implementation to state that it does not need any 060 * further data. It may be used e.g. by visitors that search for a certain 061 * node in the hierarchy. After that node was found, there is no need to 062 * process the remaining nodes, too. 063 * 064 * @return a flag if the visit process should be stopped 065 */ 066 boolean terminate(); 067 }