01: // Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
02: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
03: // Released under the terms of the GNU General Public License version 2 or later.
04: package fit;
05:
06: import java.util.*;
07:
08: public class FixtureName {
09: private final String nameAsString;
10:
11: public FixtureName(String tableName) {
12: // REFACTOR Fold GracefulNamer into this class
13: if (GracefulNamer.isGracefulName(tableName))
14: this .nameAsString = GracefulNamer.disgrace(tableName);
15: else
16: this .nameAsString = tableName;
17: }
18:
19: public String toString() {
20: return nameAsString;
21: }
22:
23: public boolean isFullyQualified() {
24: return nameAsString.indexOf('.') != -1;
25: }
26:
27: public static boolean fixtureNameHasPackageSpecified(
28: final String fixtureName) {
29: return new FixtureName(fixtureName).isFullyQualified();
30: }
31:
32: public List getPotentialFixtureClassNames(Set fixturePathElements) {
33: List candidateClassNames = new ArrayList();
34:
35: if (!isFullyQualified()) {
36: for (Iterator i = fixturePathElements.iterator(); i
37: .hasNext();) {
38: String packageName = (String) i.next();
39: addBlahAndBlahFixture(packageName + ".",
40: candidateClassNames);
41: }
42: }
43: addBlahAndBlahFixture("", candidateClassNames);
44:
45: return candidateClassNames;
46: }
47:
48: private void addBlahAndBlahFixture(String qualifiedBy,
49: List candidateClassNames) {
50: candidateClassNames.add(qualifiedBy + nameAsString);
51: candidateClassNames.add(qualifiedBy + nameAsString + "Fixture");
52: }
53: }
|