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

java.lang.Objectorg.jomc.tools.JomcTool
public class JomcTool
Base tool class.
| Nested Class Summary | |
|---|---|
static class |
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 | |
|---|---|
String |
getBooleanString(Boolean b)
Formats a Boolean to a string. |
String |
getCsvString(String str)
Formats a string to a CSV string. |
static Level |
getDefaultLogLevel()
Gets the default log level events are logged at. |
static String |
getDefaultTemplateProfile()
Deprecated. The static modifier of this method and support to setup the default template profile using
a system property will be removed in version 2.0. |
String |
getDisplayLanguage(String language)
Gets the display language of a given language code. |
String |
getHtmlString(String str)
Formats a string to a HTML string with HTML entities. |
List<String> |
getImplementedJavaTypeNames(Implementation implementation,
boolean qualified)
Gets a list of names of all Java types an implementation implements. |
String |
getIndentation()
Gets the indentation string of the instance. |
String |
getIndentation(int level)
Gets an indentation string for a given indentation level. |
String |
getInputEncoding()
Gets the encoding to use for reading files. |
String |
getIsoDate(Calendar calendar)
Formats a calendar instance to a string. |
String |
getIsoDateTime(Calendar calendar)
Formats a calendar instance to a string. |
String |
getIsoTime(Calendar calendar)
Formats a calendar instance to a string. |
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,
int indentationLevel,
String linePrefix)
Formats a text to a Javadoc comment. |
String |
getJavadocComment(Texts texts,
int indentationLevel,
String linePrefix)
Formats a text from a list of texts to a Javadoc comment. |
String |
getJavaGetterMethodName(Dependency dependency)
Gets the name of a Java getter method of a given dependency. |
String |
getJavaGetterMethodName(Message message)
Gets the name of a Java getter method of a given message. |
String |
getJavaGetterMethodName(Property property)
Gets the name of a Java getter method of a given property. |
String |
getJavaIdentifier(String str,
boolean capitalize)
Formats a string to a Java identifier. |
List<String> |
getJavaInterfaceNames(Implementation implementation,
boolean qualified)
Deprecated. As of JOMC 1.2, replaced by method getImplementedJavaTypeNames(org.jomc.model.Implementation, boolean).
This method will be removed in version 2.0. |
String |
getJavaMethodParameterName(Argument argument)
Gets a Java method parameter name of an argument. |
String |
getJavaMethodParameterName(Dependency dependency)
Gets a Java method parameter name of a dependency. |
String |
getJavaMethodParameterName(Message message)
Gets a Java method parameter name of a message. |
String |
getJavaMethodParameterName(Property property)
Gets a Java method parameter name of a property. |
String |
getJavaModifierName(Implementation implementation,
Dependency dependency)
Gets the Java modifier name of a dependency of a given implementation. |
String |
getJavaModifierName(Implementation implementation,
Message message)
Gets the Java modifier name of a message of a given implementation. |
String |
getJavaModifierName(Implementation implementation,
Property property)
Gets the Java modifier name of a 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. |
String |
getJavaScriptString(String str)
Formats a string to a JavaScript string applying JavaScript string rules. |
String |
getJavaSetterMethodName(Dependency dependency)
Gets the name of a Java setter method of a given dependency. |
String |
getJavaSetterMethodName(Message message)
Gets the name of a Java setter method of a given message. |
String |
getJavaSetterMethodName(Property property)
Gets the name of a Java setter method of a given property. |
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. |
String |
getLineSeparator()
Gets the line separator of the instance. |
List<JomcTool.Listener> |
getListeners()
Gets the list of registered listeners. |
Locale |
getLocale()
Gets the locale of the instance. |
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. |
String |
getMediumDate(Calendar calendar)
Formats a calendar instance to a string. |
String |
getMediumDateTime(Calendar calendar)
Formats a calendar instance to a string. |
String |
getMediumTime(Calendar calendar)
Formats a calendar instance to a string. |
Model |
getModel()
Gets the model of the instance. |
Modules |
getModules()
Deprecated. As of JOMC 1.2, please use method getModel() and ModelHelper.getModules(org.jomc.modlet.Model).
This method will be removed in version 2.0. |
String |
getOutputEncoding()
Gets the encoding to use for writing files. |
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 |
getSqlString(String str)
Formats a string to a SQL string. |
String |
getTemplateEncoding()
Gets the encoding to use for reading templates. |
URL |
getTemplateLocation()
Gets the location to search for templates in addition to searching the class path. |
Map<String,Object> |
getTemplateParameters()
Gets the template parameters of the instance. |
String |
getTemplateProfile()
Gets the template profile of the instance. |
VelocityContext |
getVelocityContext()
Gets a new velocity context used for merging templates. |
VelocityEngine |
getVelocityEngine()
Gets the VelocityEngine of the instance. |
Template |
getVelocityTemplate(String templateName)
Gets a velocity template for a given name. |
String |
getXmlString(String str)
Formats a string to a XML string with XML entities. |
String |
getYears(Calendar start,
Calendar end)
Gets a string describing the range of years for given calendars. |
boolean |
isJavaDefaultPackage(Implementation implementation)
Gets a flag indicating the class of a given implementation is located in the Java default package. |
boolean |
isJavaDefaultPackage(Specification specification)
Gets a flag indicating the class of a given specification is located in the Java default package. |
boolean |
isJavaPrimitiveType(Property property)
Gets a flag indicating 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. |
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. |
static void |
setDefaultTemplateProfile(String value)
Deprecated. The static modifier of this method will be removed in version 2.0. |
void |
setIndentation(String value)
Sets the indentation string of the instance. |
void |
setInputEncoding(String value)
Sets the encoding to use for reading files. |
void |
setLineSeparator(String value)
Sets the line separator of the instance. |
void |
setLocale(Locale value)
Sets the locale of the instance. |
void |
setLogLevel(Level value)
Sets the log level of the instance. |
void |
setModel(Model value)
Sets the model of the instance. |
void |
setOutputEncoding(String value)
Sets the encoding to use for writing files. |
void |
setTemplateEncoding(String value)
Sets the encoding to use for reading templates. |
void |
setTemplateLocation(URL value)
Sets the location to search for templates in addition to searching the class path. |
void |
setTemplateProfile(String value)
Sets the template profile of the instance. |
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 |
| Constructor Detail |
|---|
public JomcTool()
JomcTool instance.
public JomcTool(JomcTool tool)
throws IOException
JomcTool instance taking a JomcTool instance to initialize the new instance with.
tool - The instance to initialize the new instance with.
NullPointerException - if tool is null.
IOException - if copying tool fails.| 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 final Level getLogLevel()
getDefaultLogLevel(),
setLogLevel(java.util.logging.Level),
isLoggable(java.util.logging.Level)public final 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(Specification specification)
specification - The specification to get the Java package name of.
specification or null.
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 or null.
NullPointerException - if specification is null.public String getJavaClasspathLocation(Specification specification)
specification - The specification to return the Java class path location of.
specification or null.
NullPointerException - if specification is null.public String getJavaPackageName(SpecificationReference reference)
reference - The specification reference to get the Java package name of.
reference or null.
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 or null.
NullPointerException - if reference is null.public String getJavaPackageName(Implementation implementation)
implementation - The implementation to get the Java package name of.
implementation or null.
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 or null.
NullPointerException - if implementation is null.public String getJavaClasspathLocation(Implementation implementation)
implementation - The implementation to return the Java class path location of.
implementation or null.
NullPointerException - if implementation is null.
@Deprecated
public List<String> getJavaInterfaceNames(Implementation implementation,
boolean qualified)
getImplementedJavaTypeNames(org.jomc.model.Implementation, boolean).
This method will be removed in version 2.0.
implementation - The implementation to get names of all implemented Java types 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 List<String> getImplementedJavaTypeNames(Implementation implementation,
boolean qualified)
implementation - The implementation to get names of all implemented Java types 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 getJavaMethodParameterName(Argument argument)
argument - The argument to get the Java method parameter 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 Java type of property is primitive; false, if not.
NullPointerException - if property is null.public String getJavaGetterMethodName(Property property)
property - The property to get a Java getter method name of.
property.
NullPointerException - if property is null.public String getJavaSetterMethodName(Property property)
property - The property to get a Java setter method name of.
property.
NullPointerException - if property is null.public String getJavaMethodParameterName(Property property)
property - The property to get the Java method parameter 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 or null.
NullPointerException - if dependency is null.public String getJavaGetterMethodName(Dependency dependency)
dependency - The dependency to get a Java getter method name of.
dependency.
NullPointerException - if dependency is null.public String getJavaSetterMethodName(Dependency dependency)
dependency - The dependency to get a Java setter method name of.
dependency.
NullPointerException - if dependency is null.public String getJavaMethodParameterName(Dependency dependency)
dependency - The dependency to get the Java method parameter name of.
dependency.
NullPointerException - if dependency is null.public String getJavaGetterMethodName(Message message)
message - The message to get a Java getter method name of.
message.
NullPointerException - if message is null.public String getJavaSetterMethodName(Message message)
message - The message to get a Java setter method name of.
message.
NullPointerException - if message is null.public String getJavaMethodParameterName(Message message)
message - The message to get the Java method parameter name of.
message.
NullPointerException - if message is null.
public String getJavaModifierName(Implementation implementation,
Dependency dependency)
implementation - The implementation declaring the dependency to get a 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 declaring the message to get a 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 the property to get a Java modifier name of.property - The property to get a Java modifier name of.
property of implementation.
NullPointerException - if implementation or property is null.
public String getJavadocComment(Text text,
int indentationLevel,
String linePrefix)
text - The text to format to a Javadoc comment.indentationLevel - The indentation level of the comment.linePrefix - The text to prepend lines with.
text formatted to a Javadoc comment.
NullPointerException - if text or linePrefix is null.
IllegalArgumentException - if indentationLevel is negative.
public String getJavadocComment(Texts texts,
int indentationLevel,
String linePrefix)
texts - The list of texts to format to a Javadoc comment.indentationLevel - The indentation level of the comment.linePrefix - The text to prepend lines with.
NullPointerException - if texts or linePrefix is null.
IllegalArgumentException - if indentationLevel is negative.getLocale()public String getJavaString(String str)
str - The string to format to a Java string or null.
str formatted to a Java string or null.StringEscapeUtils.escapeJava(java.lang.String)
public String getJavaIdentifier(String str,
boolean capitalize)
str - The string to format or null.capitalize - true, to return an identifier with the first character upper cased; false, to
return an identifier with the first character lower cased.
str formatted to a Java identifier or null.public boolean isJavaDefaultPackage(Specification specification)
specification - The specification to query.
true, if the class of specification is located in the Java default package;
false, else.
NullPointerException - if specification is null.public boolean isJavaDefaultPackage(Implementation implementation)
implementation - The implementation to query.
true, if the class of implementation is located in the Java default package;
false, else.
NullPointerException - if implementation is null.public String getHtmlString(String str)
str - The string to format to a HTML string with HTML entities or null.
str formatted to a HTML string with HTML entities or null.StringEscapeUtils.escapeHtml(java.lang.String)public String getXmlString(String str)
str - The string to format to a XML string with XML entities or null.
str formatted to a XML string with XML entities or null.StringEscapeUtils.escapeXml(java.lang.String)public String getJavaScriptString(String str)
str - The string to format to a JavaScript string by applying JavaScript string rules or null.
str formatted to a JavaScript string with JavaScript string rules applied or null.StringEscapeUtils.escapeJavaScript(java.lang.String)public String getSqlString(String str)
str - The string to format to a SQL string or null.
str formatted to a SQL string or null.StringEscapeUtils.escapeSql(java.lang.String)public String getCsvString(String str)
str - The string to format to a CSV string or null.
str formatted to a CSV string or null.StringEscapeUtils.escapeCsv(java.lang.String)public String getBooleanString(Boolean b)
Boolean to a string.
b - The Boolean to format to a string or null.
b formatted to a string.getLocale()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 to a string.
calendar formatted using a short format style pattern.
NullPointerException - if calendar is null.DateFormat.SHORTpublic String getMediumDate(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a medium format style pattern.
NullPointerException - if calendar is null.DateFormat.MEDIUMpublic String getLongDate(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a long format style pattern.
NullPointerException - if calendar is null.DateFormat.LONGpublic String getIsoDate(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using an ISO-8601 format style.
NullPointerException - if calendar is null.yyyy-DDDpublic String getShortTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a short format style pattern.
NullPointerException - if calendar is null.DateFormat.SHORTpublic String getMediumTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a medium format style pattern.
NullPointerException - if calendar is null.DateFormat.MEDIUMpublic String getLongTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a long format style pattern.
NullPointerException - if calendar is null.DateFormat.LONGpublic String getIsoTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using an ISO-8601 format style.
NullPointerException - if calendar is null.HH:mmpublic String getShortDateTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a short format style pattern.
NullPointerException - if calendar is null.DateFormat.SHORTpublic String getMediumDateTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a medium format style pattern.
NullPointerException - if calendar is null.DateFormat.MEDIUMpublic String getLongDateTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a long format style pattern.
NullPointerException - if calendar is null.DateFormat.LONGpublic String getIsoDateTime(Calendar calendar)
calendar - The calendar to format to a string.
calendar formatted using a ISO-8601 format style.
NullPointerException - if calendar is null.yyyy-MM-dd'T'HH:mm:ssZ
public String getYears(Calendar start,
Calendar end)
start - The start of the range.end - The end of the range.
start and end (e.g. "start - end").
NullPointerException - if start or end is null.public final Model getModel()
getModules(),
setModel(org.jomc.modlet.Model)public final void setModel(Model value)
value - The new model of the instance or null.getModel()@Deprecated public Modules getModules()
getModel() and ModelHelper.getModules(org.jomc.modlet.Model).
This method will be removed in version 2.0.
getModel(),
setModel(org.jomc.modlet.Model)
public final VelocityEngine getVelocityEngine()
throws IOException
VelocityEngine of the instance.
VelocityEngine of the instance.
IOException - if initializing a new velocity engine fails.setVelocityEngine(org.apache.velocity.app.VelocityEngine)public final void setVelocityEngine(VelocityEngine value)
VelocityEngine of the instance.
value - The new VelocityEngine of the instance or null.getVelocityEngine()public VelocityContext getVelocityContext()
getTemplateParameters()public final Map<String,Object> getTemplateParameters()
This accessor method returns a reference to the live map, not a snapshot. Therefore any modification you make
to the returned map will be present inside the object. This is why there is no set method for the
template parameters property.
getVelocityContext()public final URL getTemplateLocation()
null.setTemplateLocation(java.net.URL)public final void setTemplateLocation(URL value)
value - The new location to search for templates in addition to searching the class path or null.getTemplateLocation()public final String getTemplateEncoding()
setTemplateEncoding(java.lang.String)public final void setTemplateEncoding(String value)
value - The new encoding to use for reading templates or null.getTemplateEncoding()public final String getInputEncoding()
setInputEncoding(java.lang.String)public final void setInputEncoding(String value)
value - The new encoding to use for reading files or null.getInputEncoding()public final String getOutputEncoding()
setOutputEncoding(java.lang.String)public final void setOutputEncoding(String value)
value - The encoding to use for writing files or null.getOutputEncoding()@Deprecated public static String getDefaultTemplateProfile()
static modifier of this method and support to setup the default template profile using
a system property will be removed in version 2.0.
The default template profile is controlled by system property
org.jomc.tools.JomcTool.defaultTemplateProfile holding the name of the template profile to use by
default. If that property is not set, the jomc-java default is returned.
setDefaultTemplateProfile(java.lang.String)@Deprecated public static void setDefaultTemplateProfile(String value)
static modifier of this method will be removed in version 2.0.
value - The new default template profile or null.getDefaultTemplateProfile()public final String getTemplateProfile()
getDefaultTemplateProfile(),
setTemplateProfile(java.lang.String)public final void setTemplateProfile(String value)
value - The new template profile of the instance or null.getTemplateProfile()public final String getIndentation()
setIndentation(java.lang.String)public final String getIndentation(int level)
level - The indentation level to get an indentation string for.
level.
IllegalArgumentException - if level is negative.getIndentation()public final void setIndentation(String value)
value - The new indentation string of the instance or null.getIndentation()public final String getLineSeparator()
setLineSeparator(java.lang.String)public final void setLineSeparator(String value)
value - The new line separator of the instance or null.getLineSeparator()public final Locale getLocale()
setLocale(java.util.Locale)public final void setLocale(Locale value)
value - The new locale of the instance or null.getLocale()
public Template getVelocityTemplate(String templateName)
throws IOException
This method searches templates at the following locations in the shown order.
org/jomc/tools/templates/profile/language/templateNameorg/jomc/tools/templates/profile/templateNameorg/jomc/tools/templates/default profile/language/templateNameorg/jomc/tools/templates/default profile/templateName
templateName - The name of the template to get.
templateName.
NullPointerException - if templateName is null.
IOException - if getting the template fails.getLocale(),
getTemplateProfile(),
getTemplateEncoding(),
getVelocityEngine()
public 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(),
isLoggable(java.util.logging.Level)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
| Copyright © 2005-2012 The JOMC Project. All Rights Reserved. |