01: /*
02: * Author: Chris Seguin
03: *
04: * This software has been developed under the copyleft
05: * rules of the GNU General Public License. Please
06: * consult the GNU General Public License for more
07: * details about use and distribution of this software.
08: */
09: package net.sourceforge.jrefactory.factory;
10:
11: import net.sourceforge.jrefactory.ast.ASTName;
12: import java.util.StringTokenizer;
13:
14: /**
15: * Creates Name objects from strings
16: *
17: *@author Chris Seguin
18: *@created November 23, 1999
19: */
20: public class NameFactory {
21: /**
22: * Constructor for the NameFactory object
23: */
24: private NameFactory() {
25: }
26:
27: /**
28: * Creates a ASTName object based on the packageName and the className. If
29: * the className is null, it is without a class name.
30: *
31: *@param packageName the package name
32: *@param className the class name or null
33: *@return The ASTName value
34: */
35: public static ASTName getName(String packageName, String className) {
36: StringTokenizer tok = new StringTokenizer(packageName, ".");
37:
38: ASTName result = new ASTName();
39:
40: while (tok.hasMoreTokens()) {
41: result.addNamePart(tok.nextToken());
42: }
43:
44: if (className != null) {
45: result.addNamePart(className);
46: }
47:
48: return result;
49: }
50: }
|