001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029: package javax.jcr.util;
030:
031: import javax.jcr.ItemVisitor;
032: import javax.jcr.Node;
033: import javax.jcr.Property;
034: import javax.jcr.RepositoryException;
035:
036: public abstract class TraversingItemVisitor implements ItemVisitor {
037: protected final boolean breadthFirst;
038: protected final int maxLevel;
039:
040: public TraversingItemVisitor() {
041: this (false, -1);
042: }
043:
044: public TraversingItemVisitor(boolean breadthFirst) {
045: this (breadthFirst, -1);
046: }
047:
048: public TraversingItemVisitor(boolean breadthFirst, int maxLevel) {
049: throw new UnsupportedOperationException();
050: }
051:
052: protected abstract void entering(Property property, int level)
053: throws RepositoryException;
054:
055: protected abstract void entering(Node node, int level)
056: throws RepositoryException;
057:
058: protected abstract void leaving(Property property, int level)
059: throws RepositoryException;
060:
061: protected abstract void leaving(Node node, int level)
062: throws RepositoryException;
063:
064: public void visit(Property property) throws RepositoryException {
065: // entering(property, currentLevel);
066: // leaving(property, currentLevel);
067: }
068:
069: public void visit(Node node) throws RepositoryException {
070: throw new UnsupportedOperationException();
071: }
072:
073: public static class Default extends TraversingItemVisitor {
074: public Default() {
075: }
076:
077: public Default(boolean breadthFirst) {
078: super (breadthFirst);
079: }
080:
081: public Default(boolean breadthFirst, int maxLevel) {
082: super (breadthFirst, maxLevel);
083: }
084:
085: protected void entering(Node node, int level)
086: throws RepositoryException {
087: }
088:
089: protected void entering(Property property, int level)
090: throws RepositoryException {
091: }
092:
093: protected void leaving(Node node, int level)
094: throws RepositoryException {
095: }
096:
097: protected void leaving(Property property, int level)
098: throws RepositoryException {
099: }
100: }
101: }
|