From 6ca6ae7ea97c2834237d4d249d0240acc5f83289 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 31 Mar 2009 04:52:10 +0000 Subject: [PATCH] git-svn-id: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core@3163 ae02f08e-27ec-0310-ae8c-8ba02fe2eafd --- pom.xml | 2 +- src/main/java/org/xerial/util/tree/TreeWalker.java | 8 +- .../java/org/xerial/util/tree/TreeWalkerTest.java | 95 ++++++++++++++++++++++ 3 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/xerial/util/tree/TreeWalkerTest.java diff --git a/pom.xml b/pom.xml index 1581819..6c57883 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.xerial xerial-core Xerial Core - 1.0.2 + 1.0.3-SNAPSHOT Xerial Core: standard utilities for XerialJ project diff --git a/src/main/java/org/xerial/util/tree/TreeWalker.java b/src/main/java/org/xerial/util/tree/TreeWalker.java index 95417a4..32a370f 100644 --- a/src/main/java/org/xerial/util/tree/TreeWalker.java +++ b/src/main/java/org/xerial/util/tree/TreeWalker.java @@ -43,13 +43,15 @@ public interface TreeWalker * @param visitor * A {@link TreeVisitor} that handles tree visit events * @throws XerialException - * when we have to stop the walking + * when we have to stop the walking due to some read error */ public void walk(TreeVisitor visitor) throws XerialException; /** * Skip the descendants of the current node - * @throws XerialException TODO + * + * @throws XerialException + * when we have to stop the walking due to some read error */ public void skipDescendants() throws XerialException; @@ -61,7 +63,7 @@ public interface TreeWalker * @return {@link TreeNode} representation of the tree structured data * beginning from the current node * @throws XerialException - * when we have to stop the walking + * when we have to stop the walking due to some read error * */ public TreeNode getSubTree() throws XerialException; diff --git a/src/test/java/org/xerial/util/tree/TreeWalkerTest.java b/src/test/java/org/xerial/util/tree/TreeWalkerTest.java new file mode 100644 index 0000000..847e191 --- /dev/null +++ b/src/test/java/org/xerial/util/tree/TreeWalkerTest.java @@ -0,0 +1,95 @@ +/*-------------------------------------------------------------------------- + * Copyright 2009 Taro L. Saito + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *--------------------------------------------------------------------------*/ +//-------------------------------------- +// XerialJ +// +// TreeWalkerTest.java +// Since: Mar 31, 2009 1:27:39 PM +// +// $URL$ +// $Author$ +//-------------------------------------- +package org.xerial.util.tree; + +import java.io.Reader; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.xerial.core.XerialException; +import org.xerial.util.FileResource; +import org.xerial.util.xml.XMLTreeWalker; + +public class TreeWalkerTest +{ + + @Before + public void setUp() throws Exception + {} + + @After + public void tearDown() throws Exception + {} + + class MyWalker extends XMLTreeWalker + { + public MyWalker(Reader xmlReader) + { + super(xmlReader); + } + + } + + @Test + public void testname() throws Exception + { + MyWalker walker = new MyWalker(FileResource.open(TreeWalkerTest.class, "../xml/simple.xml")); + walker.walk(new TreeVisitor() { + + public void finish(TreeWalker walker) throws XerialException + { + // TODO Auto-generated method stub + + } + + public void init(TreeWalker walker) throws XerialException + { + // TODO Auto-generated method stub + + } + + public void leaveNode(String nodeName, TreeWalker walker) throws XerialException + { + // TODO Auto-generated method stub + + } + + public void text(String textDataFragment, TreeWalker walker) throws XerialException + { + // TODO Auto-generated method stub + + } + + public void visitNode(String nodeName, String immediateNodeValue, TreeWalker walker) throws XerialException + { + // TODO Auto-generated method stub + + } + + }); + } + +} -- 2.11.0