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