1 /*******************************************************************************
2  * Copyright (c) 2007, 2009 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.pde.api.tools.internal.provisional.model;
15 
16 /**
17  * Visits {@link IApiTypeRoot}s in an {@link IApiTypeContainer}
18  *
19  * @since 1.0.0
20  */
21 public abstract class ApiTypeContainerVisitor {
22 
23 	/**
24 	 * Visits a component in the container and returns whether class files in
25 	 * the component should be visited. This method is only called when the
26 	 * class file container being visited is contained in an API component.
27 	 * <p>
28 	 * The default implementation does nothing and returns <code>true</code>.
29 	 * Subclasses may re-implement.
30 	 * </p>
31 	 *
32 	 * @param component API component being visited
33 	 * @return whether class files in the component should be visited
34 	 */
visit(IApiComponent component)35 	public boolean visit(IApiComponent component) {
36 		return true;
37 	}
38 
39 	/**
40 	 * End visiting a component. This method is only called when the class file
41 	 * container being visited is contained in an API component.
42 	 * <p>
43 	 * The default implementation does nothing. Subclasses may re-implement.
44 	 * </p>
45 	 *
46 	 * @param component API component
47 	 */
end(IApiComponent component)48 	public void end(IApiComponent component) {
49 		// subclasses may re-implement
50 	}
51 
52 	/**
53 	 * Visits a container and returns whether class files in the container
54 	 * should be visited.
55 	 * <p>
56 	 * The default implementation does nothing and returns <code>true</code>.
57 	 * Subclasses may re-implement.
58 	 * </p>
59 	 *
60 	 * @param container
61 	 * @return
62 	 */
visit(IApiTypeContainer container)63 	public boolean visit(IApiTypeContainer container) {
64 		return true;
65 	}
66 
67 	/**
68 	 * Ends visiting a container.
69 	 * <p>
70 	 * The default implementation does nothing. Subclasses may re-implement.
71 	 * </p>
72 	 *
73 	 * @param container
74 	 */
end(IApiTypeContainer container)75 	public void end(IApiTypeContainer container) {
76 		// subclasses my re-implement
77 	}
78 
79 	/**
80 	 * Visits a package in the container and returns whether class files in the
81 	 * package should be visited.
82 	 * <p>
83 	 * The default implementation does nothing and returns <code>true</code>.
84 	 * Subclasses may re-implement.
85 	 * </p>
86 	 *
87 	 * @param packageName fully qualified dot separated package name or the
88 	 *            empty string for the default package
89 	 * @return whether class files in the package should be visited
90 	 */
visitPackage(String packageName)91 	public boolean visitPackage(String packageName) {
92 		return true;
93 	}
94 
95 	/**
96 	 * End visiting a package.
97 	 * <p>
98 	 * The default implementation does nothing. Subclasses may re-implement.
99 	 * </p>
100 	 *
101 	 * @param packageName fully qualified dot separated package name or the
102 	 *            empty string for the default package
103 	 */
endVisitPackage(String packageName)104 	public void endVisitPackage(String packageName) {
105 		// subclasses may re-implement
106 	}
107 
108 	/**
109 	 * Visits an {@link IApiTypeRoot} from the specified package.
110 	 * <p>
111 	 * The default implementation does nothing.
112 	 * </p>
113 	 *
114 	 * @param packageName fully qualified dot separated package name or the
115 	 *            empty string for the default package
116 	 * @param typeroot {@link IApiTypeRoot} to visit
117 	 */
visit(String packageName, IApiTypeRoot typeroot)118 	public void visit(String packageName, IApiTypeRoot typeroot) {
119 		// subclasses may re-implement
120 	}
121 
122 	/**
123 	 * End visiting an {@link IApiTypeRoot}.
124 	 * <p>
125 	 * The default implementation does nothing. Subclasses may re-implement.
126 	 * </p>
127 	 *
128 	 * @param packageName fully qualified dot separated package name or the
129 	 *            empty string for the default package
130 	 * @param typeroot {@link IApiTypeRoot} ending visit on
131 	 */
end(String packageName, IApiTypeRoot typeroot)132 	public void end(String packageName, IApiTypeRoot typeroot) {
133 		// subclasses may re-implement
134 	}
135 }
136