net.sf.farrago.catalog.codegen
Class FactoryGen
java.lang.Object
net.sf.farrago.catalog.codegen.FactoryGen
public class FactoryGen
- extends Object
FactoryGen generates a factory class for a JMI model. It's purely a
convenience; JMI already provides factory methods, but their invocation
requires a long ugly expression involving lots of redundancy. For an example
of the generated output, see FarragoMetadataFactory.
- Version:
- $Id: //open/dev/farrago/src/net/sf/farrago/catalog/codegen/FactoryGen.java#21 $
- Author:
- John V. Sichi
Nested Class Summary |
private static class |
FactoryGen.ForkWriter
Writer which takes two underlying writers, and automatically writes
method bodies to one, and method prototypes to the other. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_LARGE_NUMERICS
private static final int MAX_LARGE_NUMERICS
- See Also:
- Constant Field Values
FactoryGen
public FactoryGen()
main
public static void main(String[] args)
throws ClassNotFoundException,
IOException
- Main generator entry point invoked by build.xml (target
"generateMetadataFactory").
- Parameters:
args
-
- args[0] = target .java file for interface output
- args[1] = target .java file for class output
- args[2] = target package name
- args[3] = target interface name
- args[4] = target class name
- args[5] = source package Java metaclass name
- args[6] = source extent name
- (optional) args[7] = model timestamp
- Throws:
ClassNotFoundException
IOException
findPackage
private static RefPackage findPackage(RefPackage refPackage,
Class iface)
generatePackage
private static void generatePackage(PrintWriter pw,
RefPackage refPackage,
String packageAccessor)
throws ClassNotFoundException
- Throws:
ClassNotFoundException
validateClass
private static void validateClass(Class classInterface)
- Validates the given class. In particular, this method detects classes
that can trigger intermittent bugs in Farrago's MDR implementation.
- Parameters:
classInterface
- class to validate- See Also:
countLargeNumerics(Class)
countLargeNumerics
private static int countLargeNumerics(Class classInterface)
- Counts the number of attributes in the given class that are of type
long or double. The count includes attributes from super
interfaces. This method looks at only the methods whose names begin with
"set" and are therefore mutators/setters. Attributes of type
Long
or Double
are not counted as large
numberics (because they do not require extra operand stack space).
This method can be removed when the corresponding bug in MDR is fixed.
- Parameters:
classInterface
- a Farrago catalog interface class
- Returns:
- the number of longs and doubles in the class
- See Also:
- FRG-295