|
||||||||||
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. |
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 | |
---|---|
static Level |
getDefaultLogLevel()
Gets the default log level events are logged at. |
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(org.jomc.model.Implementation implementation)
Gets the Java class path location of an implementation. |
String |
getJavaClasspathLocation(org.jomc.model.Specification specification)
Gets the Java class path location of a specification. |
String |
getJavadocComment(org.jomc.model.Text text,
String linebreak)
Formats a text to a Javadoc comment. |
String |
getJavaGetterMethodName(org.jomc.model.Dependency dependency)
Gets the name of a Java accessor method of a given dependency. |
String |
getJavaGetterMethodName(org.jomc.model.Message message)
Gets the name of a Java accessor method of a given message. |
String |
getJavaGetterMethodName(org.jomc.model.Property property)
Gets the name of a Java accessor method of a given property. |
List<String> |
getJavaInterfaceNames(org.jomc.model.Implementation implementation,
boolean qualified)
Gets all Java interfaces an implementation implements. |
String |
getJavaModifierName(org.jomc.model.Implementation implementation,
org.jomc.model.Dependency dependency)
Gets the name of a Java modifier of a dependency of a given implementation. |
String |
getJavaModifierName(org.jomc.model.Implementation implementation,
org.jomc.model.Message message)
Gets the name of a Java modifier of a message of a given implementation. |
String |
getJavaModifierName(org.jomc.model.Implementation implementation,
org.jomc.model.Property property)
Gets the name of a Java modifier for a given property of a given implementation. |
String |
getJavaPackageName(org.jomc.model.Implementation implementation)
Gets the Java package name of an implementation. |
String |
getJavaPackageName(org.jomc.model.Specification specification)
Gets the Java package name of a specification. |
String |
getJavaPackageName(org.jomc.model.SpecificationReference reference)
Gets the Java package name of a specification reference. |
String |
getJavaString(String str)
Formats a string to a Java string with unicode escapes. |
String |
getJavaTypeName(org.jomc.model.Argument argument)
Gets the Java type name of an argument. |
String |
getJavaTypeName(org.jomc.model.Dependency dependency)
Gets the name of a Java type of a given dependency. |
String |
getJavaTypeName(org.jomc.model.Implementation implementation,
boolean qualified)
Gets the Java type name of an implementation. |
String |
getJavaTypeName(org.jomc.model.Property property,
boolean boxify)
Gets the Java type name of a property. |
String |
getJavaTypeName(org.jomc.model.Specification specification,
boolean qualified)
Gets the Java type name of a specification. |
String |
getJavaTypeName(org.jomc.model.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. |
Level |
getLogLevel()
Gets the log level of the instance. |
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. |
org.jomc.model.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. |
org.apache.velocity.VelocityContext |
getVelocityContext()
Gets the velocity context used for merging templates. |
org.apache.velocity.app.VelocityEngine |
getVelocityEngine()
Gets the VelocityEngine used for generating source code. |
org.apache.velocity.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(org.jomc.model.Implementation implementation)
Gets a flag indicating if a given implementation declares a Java class. |
boolean |
isJavaClassDeclaration(org.jomc.model.Specification specification)
Gets a flag indicating if a given specification declares a Java class. |
boolean |
isJavaDefaultPackage(org.jomc.model.Implementation implementation)
Gets a flag indicating if the class of a given implementation is located in the Java default package. |
boolean |
isJavaDefaultPackage(org.jomc.model.Specification specification)
Gets a flag indicating if the class of a given specification is located in the Java default package. |
boolean |
isJavaPrimitiveType(org.jomc.model.Property property)
Gets a flag indicating if the type of a given property is a Java primitive. |
boolean |
isLoggable(Level level)
Checks if a message at a given level is provided to the listeners of the instance. |
protected void |
log(Level level,
String message,
Throwable throwable)
Notifies registered listeners. |
static void |
setDefaultLogLevel(Level value)
Sets the default log level events are logged at. |
void |
setInputEncoding(String value)
Sets the encoding to use for reading files. |
void |
setLogLevel(Level value)
Sets the log level of the instance. |
void |
setModules(org.jomc.model.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(org.apache.velocity.app.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 |
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()
This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
to the returned list will be present inside the object. This is why there is no set
method for the
listeners property.
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)
public static Level getDefaultLogLevel()
The default log level is controlled by system property org.jomc.tools.JomcTool.defaultLogLevel
holding
the log level to log events at by default. If that property is not set, the WARNING
default is
returned.
getLogLevel()
,
Level.parse(java.lang.String)
public static void setDefaultLogLevel(Level value)
value
- The new default level events are logged at or null
.getDefaultLogLevel()
public Level getLogLevel()
getDefaultLogLevel()
,
setLogLevel(java.util.logging.Level)
,
isLoggable(java.util.logging.Level)
public void setLogLevel(Level value)
value
- The new log level of the instance or null
.getLogLevel()
,
isLoggable(java.util.logging.Level)
public boolean isLoggable(Level level)
level
- The level to test.
true
if messages at level
are provided to the listeners of the instance;
false
if messages at level
are not provided to the listeners of the instance.
NullPointerException
- if level
is null
.getLogLevel()
,
setLogLevel(java.util.logging.Level)
,
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)
public String getJavaPackageName(org.jomc.model.Specification specification)
specification
- The specification to get the Java package name of.
specification
.
NullPointerException
- if specification
is null
.public String getJavaTypeName(org.jomc.model.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(org.jomc.model.Specification specification)
specification
- The specification to return the Java class path location of.
specification
.
NullPointerException
- if specification
is null
.public String getJavaPackageName(org.jomc.model.SpecificationReference reference)
reference
- The specification reference to get the Java package name of.
reference
.
NullPointerException
- if reference
is null
.public String getJavaTypeName(org.jomc.model.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(org.jomc.model.Implementation implementation)
implementation
- The implementation to get the Java package name of.
implementation
.
NullPointerException
- if implementation
is null
.public String getJavaTypeName(org.jomc.model.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(org.jomc.model.Implementation implementation)
implementation
- The implementation to return the Java class path location of.
implementation
.
NullPointerException
- if implementation
is null
.public List<String> getJavaInterfaceNames(org.jomc.model.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(org.jomc.model.Argument argument)
argument
- The argument to get the Java type name of.
argument
.
NullPointerException
- if argument
is null
.public String getJavaTypeName(org.jomc.model.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(org.jomc.model.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(org.jomc.model.Property property)
property
- The property to get a Java accessor method name of.
property
.
NullPointerException
- if property
is null
.public String getJavaTypeName(org.jomc.model.Dependency dependency)
dependency
- The dependency to get a dependency Java type name of.
dependency
.
NullPointerException
- if dependency
is null
.public String getJavaGetterMethodName(org.jomc.model.Dependency dependency)
dependency
- The dependency to get a Java accessor method name of.
dependency
.
NullPointerException
- if dependency
is null
.public String getJavaGetterMethodName(org.jomc.model.Message message)
message
- The message to get a Java accessor method name of.
message
.
NullPointerException
- if message
is null
.public String getJavaModifierName(org.jomc.model.Implementation implementation, org.jomc.model.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(org.jomc.model.Implementation implementation, org.jomc.model.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(org.jomc.model.Implementation implementation, org.jomc.model.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(org.jomc.model.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(org.jomc.model.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(org.jomc.model.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(org.jomc.model.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(org.jomc.model.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.SHORT
public String getLongDate(Calendar calendar)
calendar
- The calendar to format.
calendar
formatted using a long format style pattern.
NullPointerException
- if calendar
is null
.DateFormat.LONG
public String getShortTime(Calendar calendar)
calendar
- The calendar to format.
calendar
formatted using a short format style pattern.
NullPointerException
- if calendar
is null
.DateFormat.SHORT
public String getLongTime(Calendar calendar)
calendar
- The calendar to format.
calendar
formatted using a long format style pattern.
NullPointerException
- if calendar
is null
.DateFormat.LONG
public String getShortDateTime(Calendar calendar)
calendar
- The calendar to format.
calendar
formatted using a short format style pattern.
NullPointerException
- if calendar
is null
.DateFormat.SHORT
public 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 org.jomc.model.Modules getModules()
setModules(org.jomc.model.Modules)
public void setModules(org.jomc.model.Modules value)
value
- The new modules of the instance.getModules()
public org.apache.velocity.app.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(org.apache.velocity.app.VelocityEngine value)
VelocityEngine
of the instance.
value
- The new VelocityEngine
of the instance.getVelocityEngine()
public org.apache.velocity.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 org.apache.velocity.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 of 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 or null
.throwable
- The throwable of the event or null
.
NullPointerException
- if level
is null
.getListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |