KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sample > registry > model > RegistryVisitor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.sample.registry.model;
20
21 import org.sample.registry.model.v09.Registry09;
22 import org.sample.registry.model.v09.Service09;
23
24 public interface RegistryVisitor {
25
26     void visit(Registry component);
27     void visit(Entries component);
28     void visit(KnownTypes component);
29     void visit(Service component);
30     void visit(ServiceProvider component);
31     void visit(ServiceType component);
32     void visit(Registry09 component);
33     void visit(Service09 component);
34
35     /**
36      * Default shallow visitor.
37      */

38     public static class Default implements RegistryVisitor {
39         public void visit(Registry component) {
40             visitChild();
41         }
42         public void visit(Registry09 component) {
43             visitChild();
44         }
45         public void visit(Entries component) {
46             visitChild();
47         }
48         public void visit(KnownTypes component) {
49             visitChild();
50         }
51         public void visit(Service component) {
52             visitChild();
53         }
54         public void visit(Service09 component) {
55             visitChild();
56         }
57         public void visit(ServiceProvider component) {
58             visitChild();
59         }
60         public void visit(ServiceType component) {
61             visitChild();
62         }
63         protected void visitChild() {
64         }
65     }
66     
67     /**
68      * Deep visitor.
69      */

70     public static class Deep extends Default {
71         protected void visitChild(RegistryComponent component) {
72             for (RegistryComponent child : component.getChildren()) {
73                 child.accept(this);
74             }
75         }
76     }
77 }
78
Popular Tags