| 1 |
|
package org.apache.torque.engine.database.model; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
import java.util.Hashtable; |
| 23 |
|
import java.util.List; |
| 24 |
|
|
| 25 |
|
import org.apache.torque.engine.EngineException; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@author |
| 31 |
|
@version |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 33 |
|
public class NameFactory |
| 34 |
|
{ |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
public static final String JAVA_GENERATOR = |
| 39 |
|
JavaNameGenerator.class.getName(); |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
public static final String CONSTRAINT_GENERATOR = |
| 45 |
|
ConstraintNameGenerator.class.getName(); |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
private static NameFactory instance = new NameFactory(); |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
private Hashtable algorithms; |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
0
|
protected NameFactory()... |
| 62 |
|
{ |
| 63 |
0
|
algorithms = new Hashtable(5); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
@param |
| 70 |
|
|
| 71 |
|
@return |
| 72 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 73 |
0
|
protected NameGenerator getAlgorithm(String name)... |
| 74 |
|
throws EngineException |
| 75 |
|
{ |
| 76 |
0
|
synchronized (algorithms) |
| 77 |
|
{ |
| 78 |
0
|
NameGenerator algorithm = (NameGenerator) algorithms.get(name); |
| 79 |
0
|
if (algorithm == null) |
| 80 |
|
{ |
| 81 |
0
|
try |
| 82 |
|
{ |
| 83 |
0
|
algorithm = |
| 84 |
|
(NameGenerator) Class.forName(name).newInstance(); |
| 85 |
|
} |
| 86 |
|
catch (InstantiationException e) |
| 87 |
|
{ |
| 88 |
0
|
throw new EngineException("Unable to instantiate class " |
| 89 |
|
+ name + ": Make sure it's in your run-time classpath", e); |
| 90 |
|
} |
| 91 |
|
catch (Exception e) |
| 92 |
|
{ |
| 93 |
0
|
throw new EngineException(e); |
| 94 |
|
} |
| 95 |
0
|
algorithms.put(name, algorithm); |
| 96 |
|
} |
| 97 |
0
|
return algorithm; |
| 98 |
|
} |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
@param |
| 106 |
|
@link |
| 107 |
|
|
| 108 |
|
@param |
| 109 |
|
@return |
| 110 |
|
@throws |
| 111 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 112 |
0
|
public static String generateName(String algorithmName, List inputs)... |
| 113 |
|
throws EngineException |
| 114 |
|
{ |
| 115 |
0
|
NameGenerator algorithm = instance.getAlgorithm(algorithmName); |
| 116 |
0
|
return algorithm.generateName(inputs); |
| 117 |
|
} |
| 118 |
|
} |