|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.jomc.tools.JomcTool
public abstract class JomcTool
Base tool class.
| Nested Class Summary | |
|---|---|
static interface |
JomcTool.Listener
Listener interface. |
| Field Summary | |
|---|---|
private String |
inputEncoding
The encoding to use for reading files. |
private List<JomcTool.Listener> |
listeners
The listeners of the instance. |
private ModelManager |
modelManager
The model manager of the instance. |
private Modules |
modules
The modules of the instance. |
private static byte[] |
NO_BYTES
Empty byte array. |
private String |
outputEncoding
The encoding to use for writing files. |
private String |
profile
The profile of the instance. |
private static String |
TEMPLATE_PREFIX
The prefix of the template location. |
private String |
templateEncoding
The encoding to use for reading templates. |
private static String |
VELOCITY_RESOURCE_LOADER
Name of the velocity classpath resource loader implementation. |
private VelocityEngine |
velocityEngine
VelocityEngine of the generator. |
| Constructor Summary | |
|---|---|
JomcTool()
Creates a new JomcTool instance. |
|
JomcTool(JomcTool tool)
Creates a new JomcTool instance taking a JomcTool instance to initialize the new instance with. |
|
| Method Summary | |
|---|---|
String |
getDisplayLanguage(String language)
Gets the display language of a given language code. |
String |
getInputEncoding()
Gets the encoding to use for reading files. |
String |
getJavaClasspathLocation(Implementation implementation)
Gets the Java class path location of an implementation. |
String |
getJavaClasspathLocation(Specification specification)
Gets the Java class path location of a specification. |
String |
getJavadocComment(Text text,
String linebreak)
Formats a text to a Javadoc comment. |
String |
getJavaGetterMethodName(Dependency dependency)
Gets the name of a Java accessor method of a given dependency. |
String |
getJavaGetterMethodName(Message message)
Gets the name of a Java accessor method of a given message. |
String |
getJavaGetterMethodName(Property property)
Gets the name of a Java accessor method of a given property. |
List<String> |
getJavaInterfaces(Implementation implementation,
boolean qualified)
Gets all Java interfaces an implementation implements. |
String |
getJavaModifierName(Implementation implementation,
Dependency dependency)
Gets the name of a Java modifier of a dependency of a given implementation. |
String |
getJavaModifierName(Implementation implementation,
Message message)
Gets the name of a Java modifier of a message of a given implementation. |
String |
getJavaModifierName(Implementation implementation,
Property property)
Gets the name of a Java modifier for a given property of a given implementation. |
String |
getJavaPackageName(Implementation implementation)
Gets the Java package name of an implementation. |
String |
getJavaPackageName(Specification specification)
Gets the Java package name of a specification. |
String |
getJavaPackageName(SpecificationReference reference)
Gets the Java package name of a specification reference. |
private String |
getJavaPackageName(String identifier)
|
String |
getJavaString(String str)
Formats a string to a Java string with unicode escapes. |
String |
getJavaTypeName(Argument argument)
Gets the Java type name of an argument. |
String |
getJavaTypeName(Dependency dependency)
Gets the name of a Java type of a given dependency. |
String |
getJavaTypeName(Implementation implementation,
boolean qualified)
Gets the Java type name of an implementation. |
String |
getJavaTypeName(Property property,
boolean boxify)
Gets the Java type name of a property. |
String |
getJavaTypeName(Specification specification,
boolean qualified)
Gets the Java type name of a specification. |
String |
getJavaTypeName(SpecificationReference reference,
boolean qualified)
Gets the name of a Java type of a given specification reference. |
List<JomcTool.Listener> |
getListeners()
Gets the list of registered listeners. |
String |
getLongDate(Calendar calendar)
Formats a calendar instance to a string. |
String |
getLongDateTime(Calendar calendar)
Formats a calendar instance to a string. |
String |
getLongTime(Calendar calendar)
Formats a calendar instance to a string. |
private String |
getMessage(String key,
Object args)
|
ModelManager |
getModelManager()
Gets the model manager of the instance. |
Modules |
getModules()
Gets the modules of the instance. |
String |
getOutputEncoding()
Gets the encoding to use for writing files. |
String |
getProfile()
Gets the profile of the instance. |
String |
getShortDate(Calendar calendar)
Formats a calendar instance to a string. |
String |
getShortDateTime(Calendar calendar)
Formats a calendar instance to a string. |
String |
getShortTime(Calendar calendar)
Formats a calendar instance to a string. |
String |
getTemplateEncoding()
Gets the encoding to use for reading templates. |
VelocityContext |
getVelocityContext()
Gets the velocity context used for merging templates. |
VelocityEngine |
getVelocityEngine()
Gets the VelocityEngine used for generating source code. |
Template |
getVelocityTemplate(String templateName)
Gets a velocity template for a given name. |
String |
getYears(Calendar start,
Calendar end)
Gets a string describing the range of years for given calendars. |
boolean |
isJavaClassDeclaration(Implementation implementation)
Gets a flag indicating if a given implementation declares a Java class. |
boolean |
isJavaClassDeclaration(Specification specification)
Gets a flag indicating if a given specification declares a Java class. |
boolean |
isJavaDefaultPackage(Implementation implementation)
Gets a flag indicating if the class of a given implementation is located in the Java default package. |
boolean |
isJavaDefaultPackage(Specification specification)
Gets a flag indicating if the class of a given specification is located in the Java default package. |
boolean |
isJavaPrimitiveType(Property property)
Gets a flag indicating if the type of a given property is a Java primitive. |
protected void |
log(Level level,
String message,
Throwable throwable)
Notifies registered listeners. |
void |
setInputEncoding(String value)
Sets the encoding to use for reading files. |
void |
setModelManager(ModelManager value)
Sets the model manager of the instance. |
void |
setModules(Modules value)
Sets the modules of the instance. |
void |
setOutputEncoding(String value)
Sets the encoding to use for writing files. |
void |
setProfile(String value)
Sets the profile of the instance. |
void |
setTemplateEncoding(String value)
Sets the encoding to use for reading templates. |
void |
setVelocityEngine(VelocityEngine value)
Sets the VelocityEngine of the instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final byte[] NO_BYTES
private static final String TEMPLATE_PREFIX
private static final String VELOCITY_RESOURCE_LOADER
private Modules modules
private ModelManager modelManager
private VelocityEngine velocityEngine
VelocityEngine of the generator.
private String templateEncoding
private String inputEncoding
private String outputEncoding
private String profile
private List<JomcTool.Listener> listeners
| Constructor Detail |
|---|
public JomcTool()
JomcTool instance.
public JomcTool(JomcTool tool)
JomcTool instance taking a JomcTool instance to initialize the new instance with.
tool - The instance to initialize the new instance with.| Method Detail |
|---|
public List<JomcTool.Listener> getListeners()
public String getJavaPackageName(Specification specification)
specification - The specification to get the Java package name of.
specification.
NullPointerException - if specification is null.
public String getJavaTypeName(Specification specification,
boolean qualified)
specification - The specification to get the Java type name of.qualified - true to return the fully qualified type name (with package name prepended);
false to return the short type name (without package name prepended).
specification.
NullPointerException - if specification is null.public String getJavaClasspathLocation(Specification specification)
specification - The specification to return the Java class path location of.
specification.
NullPointerException - if specification is null.public String getJavaPackageName(SpecificationReference reference)
reference - The specification reference to get the Java package name of.
reference.
NullPointerException - if reference is null.
public String getJavaTypeName(SpecificationReference reference,
boolean qualified)
reference - The specification reference to get a Java type name of.qualified - true to return the fully qualified type name (with package name prepended);
false to return the short type name (without package name prepended).
reference.
NullPointerException - if reference is null.public String getJavaPackageName(Implementation implementation)
implementation - The implementation to get the Java package name of.
implementation.
NullPointerException - if implementation is null.
public String getJavaTypeName(Implementation implementation,
boolean qualified)
implementation - The implementation to get the Java type name of.qualified - true to return the fully qualified type name (with package name prepended);
false to return the short type name (without package name prepended).
implementation.
NullPointerException - if implementation is null.public String getJavaClasspathLocation(Implementation implementation)
implementation - The implementation to return the Java class path location of.
implementation.
NullPointerException - if implementation is null.
public List<String> getJavaInterfaces(Implementation implementation,
boolean qualified)
implementation - The implementation to get all implemented Java interfaces of.qualified - true to return the fully qualified type names (with package name prepended);
false to return the short type names (without package name prepended).
implementation.
NullPointerException - if implementation is null.public String getJavaTypeName(Argument argument)
argument - The argument to get the Java type name of.
argument.
NullPointerException - if argument is null.
public String getJavaTypeName(Property property,
boolean boxify)
property - The property to get the Java type name of.boxify - true to return the name of the Java wrapper class when the type is a Java primitive type;
false to return the exact binary name (unboxed name) of the Java type.
property.
NullPointerException - if property is null.public boolean isJavaPrimitiveType(Property property)
property - The property to query.
true if the type of property is a Java primitive; false if not.
NullPointerException - if property is null.public String getJavaGetterMethodName(Property property)
property - The property to get a Java accessor method name of.
property.
NullPointerException - if property is null.public String getJavaTypeName(Dependency dependency)
dependency - The dependency to get a dependency Java type name of.
dependency.
NullPointerException - if dependency is null.public String getJavaGetterMethodName(Dependency dependency)
dependency - The dependency to get a Java accessor method name of.
dependency.
NullPointerException - if dependency is null.public String getJavaGetterMethodName(Message message)
message - The message to get a Java accessor method name of.
message.
NullPointerException - if message is null.
public String getJavaModifierName(Implementation implementation,
Dependency dependency)
implementation - The implementation to get a dependency Java modifier name of.dependency - The dependency to get a Java modifier name of.
dependency of implementation.
NullPointerException - if implementation or dependency is null.
public String getJavaModifierName(Implementation implementation,
Message message)
implementation - The implementation to get a message Java modifier name of.message - The message to get a Java modifier name of.
message of implementation.
NullPointerException - if implementation or message is null.
public String getJavaModifierName(Implementation implementation,
Property property)
implementation - The implementation declaring property.property - The property to get a Java modifier name for.
property of implementation.
NullPointerException - if implementation or property is null.
public String getJavadocComment(Text text,
String linebreak)
text - The text to format to a Javadoc comment.linebreak - The text to replace line breaks with.
text formatted as a Javadoc comment.
NullPointerException - if text or linebreak is null.public String getJavaString(String str)
str - The string to format to a Java string or null.
str formatted as a Java string or null.public boolean isJavaClassDeclaration(Specification specification)
specification - The specification to test.
true if specification is declaring the Java class with name
specification.getClazz(); false if specification does not declare that class.
NullPointerException - if specification is null.public boolean isJavaClassDeclaration(Implementation implementation)
implementation - The implementation to test.
true if implementation is declaring the Java class with name
implementation.getClazz(); false if implementation.getClazz() is null or
implementation does not declare that class.
NullPointerException - if implementation is null.public boolean isJavaDefaultPackage(Specification specification)
specification - The specification to test.
true if the class of specification is located in the Java default package; false
if not.
NullPointerException - if specification is null.public boolean isJavaDefaultPackage(Implementation implementation)
implementation - The implementation to test.
true if the class of implementation is located in the Java default package; false
if not.
NullPointerException - if implementation is null.public String getDisplayLanguage(String language)
language - The language code to get the display language of.
language.
NullPointerException - if language is null.public String getShortDate(Calendar calendar)
calendar - The calendar to format.
calendar formatted using a short format style pattern.
NullPointerException - if calendar is null.DateFormat.SHORTpublic String getLongDate(Calendar calendar)
calendar - The calendar to format.
calendar formatted using a long format style pattern.
NullPointerException - if calendar is null.DateFormat.LONGpublic String getShortTime(Calendar calendar)
calendar - The calendar to format.
calendar formatted using a short format style pattern.
NullPointerException - if calendar is null.DateFormat.SHORTpublic String getLongTime(Calendar calendar)
calendar - The calendar to format.
calendar formatted using a long format style pattern.
NullPointerException - if calendar is null.DateFormat.LONGpublic String getShortDateTime(Calendar calendar)
calendar - The calendar to format.
calendar formatted using a short format style pattern.
NullPointerException - if calendar is null.DateFormat.SHORTpublic String getLongDateTime(Calendar calendar)
calendar - The calendar to format.
calendar formatted using a long format style pattern.
NullPointerException - if calendar is null.DateFormat.LONG
public String getYears(Calendar start,
Calendar end)
start - The start of the range.end - The end of the range.
start and end.
NullPointerException - if start or end is null.public Modules getModules()
setModules(org.jomc.model.Modules)public void setModules(Modules value)
value - The new modules of the instance.getModules()public ModelManager getModelManager()
setModelManager(org.jomc.model.ModelManager)public void setModelManager(ModelManager value)
value - The new model manager of the instance.getModelManager()public VelocityEngine getVelocityEngine()
VelocityEngine used for generating source code.
VelocityEngine used for generating source code.
IllegalStateException - if initializing a new velocity engine fails.setVelocityEngine(org.apache.velocity.app.VelocityEngine)public void setVelocityEngine(VelocityEngine value)
VelocityEngine of the instance.
value - The new VelocityEngine of the instance.getVelocityEngine()public VelocityContext getVelocityContext()
public String getTemplateEncoding()
setTemplateEncoding(java.lang.String)public void setTemplateEncoding(String value)
value - The encoding to use for reading templates.getTemplateEncoding()public String getInputEncoding()
setInputEncoding(java.lang.String)public void setInputEncoding(String value)
value - The encoding to use for reading files.getInputEncoding()public String getOutputEncoding()
setOutputEncoding(java.lang.String)public void setOutputEncoding(String value)
value - The encoding to use for writing files.getOutputEncoding()public String getProfile()
setProfile(java.lang.String)public void setProfile(String value)
value - The profile of the instance.getProfile()
public Template getVelocityTemplate(String templateName)
throws IOException
This method returns the template corresponding to the profile of the instance. If that template is not found, the template corresponding to the default profile is returned so that only templates differing from the default templates need to be provided when exchanging templates.
templateName - The name of the template to get.
templateName.
NullPointerException - if templateName is null.
IOException - if getting the template fails.getProfile(),
getTemplateEncoding()
protected void log(Level level,
String message,
Throwable throwable)
level - The level of the event.message - The message of the event.throwable - The throwable of the event.getListeners()private String getJavaPackageName(String identifier)
private String getMessage(String key,
Object args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||