1 /* 2 * $Id: ItemVisitor.java,v 1.2 2004/07/24 00:16:21 benjmestrallet Exp $ 3 * 4 * Copyright 2002-2004 Day Management AG, Switzerland. 5 * 6 * Licensed under the Day RI License, Version 2.0 (the "License"), 7 * as a reference implementation of the following specification: 8 * 9 * Content Repository API for Java Technology, revision 0.12 10 * <http://www.jcp.org/en/jsr/detail?id=170> 11 * 12 * You may not use this file except in compliance with the License. 13 * You may obtain a copy of the License files at 14 * 15 * http://www.day.com/content/en/licenses/day-ri-license-2.0 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 */ 24 package javax.jcr; 25 26 /** 27 * The <code>ItemVisitor</code> defines an interface for the 28 * <i>Visitor</i> design pattern (see, for example, <i>Design Patterns</i>, 29 * Gamma <i>et al.</i>, 1995). 30 * This interface defines two signatures of the 31 * <code>visit</code> method; one taking a <code>Node</code>, the other a 32 * <code>Property</code>. When an object implementing this interface is passed 33 * to <code>{@link Item#accept(ItemVisitor visitor)}</code> the appropriate 34 * <code>visit</code> method is automatically called, depending on whether the 35 * <code>Item</code> in question is a <code>Node</code> or a 36 * <code>Property</code>. Different implementations of this interface can be 37 * written for different purposes. It is, for example, possible for the 38 * <code>{@link #visit(Node node)}</code> method to call <code>accept</code> on the 39 * children of the passed node and thus recurse through the tree performing some 40 * operation on each <code>Item</code>. 41 * 42 * @author Peeter Piegaze 43 */ 44 public interface ItemVisitor { 45 46 /** 47 * This method is called when the <code>ItemVisitor</code> is 48 * passed to the <code>accept</code> method of a <code>Property</code>. 49 * If this method throws an exception the visiting process is aborted. 50 * 51 * @param property The <code>Property</code> that is accepting this visitor. 52 * @throws RepositoryException if an error occurrs 53 */ 54 public void visit(Property property) throws RepositoryException; 55 56 /** 57 * This method is called when the <code>ItemVisitor</code> is 58 * passed to the <code>accept</code> method of a <code>Node</code>. 59 * If this method throws an exception the visiting process is aborted. 60 * 61 * @param node The <code>Node</code that is accepting this visitor. 62 * @throws RepositoryException if an error occurrs 63 */ 64 public void visit(Node node) throws RepositoryException; 65 }