org.jomc.tools
Class JomcTool

Package class diagram package JomcTool
java.lang.Object
  extended by org.jomc.tools.JomcTool
Direct Known Subclasses:
ClassFileProcessor, ResourceFileProcessor, SourceFileProcessor

public class JomcTool
extends Object

Base tool class.

Version:
$JOMC: JomcTool.java 4527 2012-05-23 00:43:20Z schulte2005 $
Author:
Christian Schulte

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

JomcTool

public JomcTool()
Creates a new JomcTool instance.


JomcTool

public JomcTool(JomcTool tool)
         throws IOException
Creates a new JomcTool instance taking a JomcTool instance to initialize the new instance with.

Parameters:
tool - The instance to initialize the new instance with.
Throws:
NullPointerException - if tool is null.
IOException - if copying tool fails.
Method Detail

getListeners

public List<JomcTool.Listener> getListeners()
Gets the list of registered listeners.

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.

Returns:
The list of registered listeners.
See Also:
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)

getDefaultLogLevel

public static Level getDefaultLogLevel()
Gets the default log level events are logged at.

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.

Returns:
The log level events are logged at by default.
See Also:
getLogLevel(), Level.parse(java.lang.String)

setDefaultLogLevel

public static void setDefaultLogLevel(Level value)
Sets the default log level events are logged at.

Parameters:
value - The new default level events are logged at or null.
See Also:
getDefaultLogLevel()

getLogLevel

public final Level getLogLevel()
Gets the log level of the instance.

Returns:
The log level of the instance.
See Also:
getDefaultLogLevel(), setLogLevel(java.util.logging.Level), isLoggable(java.util.logging.Level)

setLogLevel

public final void setLogLevel(Level value)
Sets the log level of the instance.

Parameters:
value - The new log level of the instance or null.
See Also:
getLogLevel(), isLoggable(java.util.logging.Level)

isLoggable

public boolean isLoggable(Level level)
Checks if a message at a given level is provided to the listeners of the instance.

Parameters:
level - The level to test.
Returns:
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.
Throws:
NullPointerException - if level is null.
See Also:
getLogLevel(), setLogLevel(java.util.logging.Level), log(java.util.logging.Level, java.lang.String, java.lang.Throwable)

getJavaPackageName

public String getJavaPackageName(Specification specification)
Gets the Java package name of a specification.

Parameters:
specification - The specification to get the Java package name of.
Returns:
The Java package name of specification or null.
Throws:
NullPointerException - if specification is null.

getJavaTypeName

public String getJavaTypeName(Specification specification,
                              boolean qualified)
Gets the Java type name of a specification.

Parameters:
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).
Returns:
The Java type name of specification or null.
Throws:
NullPointerException - if specification is null.
See Also:
getJavaPackageName(org.jomc.model.Specification)

getJavaClasspathLocation

public String getJavaClasspathLocation(Specification specification)
Gets the Java class path location of a specification.

Parameters:
specification - The specification to return the Java class path location of.
Returns:
The Java class path location of specification or null.
Throws:
NullPointerException - if specification is null.
See Also:
getJavaTypeName(org.jomc.model.Specification, boolean)

getJavaPackageName

public String getJavaPackageName(SpecificationReference reference)
Gets the Java package name of a specification reference.

Parameters:
reference - The specification reference to get the Java package name of.
Returns:
The Java package name of reference or null.
Throws:
NullPointerException - if reference is null.
See Also:
getJavaPackageName(org.jomc.model.Specification)

getJavaTypeName

public String getJavaTypeName(SpecificationReference reference,
                              boolean qualified)
Gets the name of a Java type of a given specification reference.

Parameters:
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).
Returns:
The Java type name of reference or null.
Throws:
NullPointerException - if reference is null.
See Also:
getJavaTypeName(org.jomc.model.Specification, boolean)

getJavaPackageName

public String getJavaPackageName(Implementation implementation)
Gets the Java package name of an implementation.

Parameters:
implementation - The implementation to get the Java package name of.
Returns:
The Java package name of implementation or null.
Throws:
NullPointerException - if implementation is null.

getJavaTypeName

public String getJavaTypeName(Implementation implementation,
                              boolean qualified)
Gets the Java type name of an implementation.

Parameters:
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).
Returns:
The Java type name of implementation or null.
Throws:
NullPointerException - if implementation is null.
See Also:
getJavaPackageName(org.jomc.model.Implementation)

getJavaClasspathLocation

public String getJavaClasspathLocation(Implementation implementation)
Gets the Java class path location of an implementation.

Parameters:
implementation - The implementation to return the Java class path location of.
Returns:
The Java class path location of implementation or null.
Throws:
NullPointerException - if implementation is null.

getJavaInterfaceNames

@Deprecated
public 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.

Gets a list of names of all Java types an implementation implements.

Parameters:
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).
Returns:
An unmodifiable list of names of all Java types implemented by implementation.
Throws:
NullPointerException - if implementation is null.

getImplementedJavaTypeNames

public List<String> getImplementedJavaTypeNames(Implementation implementation,
                                                boolean qualified)
Gets a list of names of all Java types an implementation implements.

Parameters:
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).
Returns:
An unmodifiable list of names of all Java types implemented by implementation.
Throws:
NullPointerException - if implementation is null.
Since:
1.2
See Also:
getJavaTypeName(org.jomc.model.Specification, boolean)

getJavaTypeName

public String getJavaTypeName(Argument argument)
Gets the Java type name of an argument.

Parameters:
argument - The argument to get the Java type name of.
Returns:
The Java type name of argument.
Throws:
NullPointerException - if argument is null.

getJavaMethodParameterName

public String getJavaMethodParameterName(Argument argument)
Gets a Java method parameter name of an argument.

Parameters:
argument - The argument to get the Java method parameter name of.
Returns:
The Java method parameter name of argument.
Throws:
NullPointerException - if argument is null.
Since:
1.2

getJavaTypeName

public String getJavaTypeName(Property property,
                              boolean boxify)
Gets the Java type name of a property.

Parameters:
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.
Returns:
The Java type name of property.
Throws:
NullPointerException - if property is null.

isJavaPrimitiveType

public boolean isJavaPrimitiveType(Property property)
Gets a flag indicating the type of a given property is a Java primitive.

Parameters:
property - The property to query.
Returns:
true, if the Java type of property is primitive; false, if not.
Throws:
NullPointerException - if property is null.
See Also:
getJavaTypeName(org.jomc.model.Property, boolean)

getJavaGetterMethodName

public String getJavaGetterMethodName(Property property)
Gets the name of a Java getter method of a given property.

Parameters:
property - The property to get a Java getter method name of.
Returns:
The Java getter method name of property.
Throws:
NullPointerException - if property is null.
See Also:
getJavaIdentifier(java.lang.String, boolean)

getJavaSetterMethodName

public String getJavaSetterMethodName(Property property)
Gets the name of a Java setter method of a given property.

Parameters:
property - The property to get a Java setter method name of.
Returns:
The Java setter method name of property.
Throws:
NullPointerException - if property is null.
Since:
1.2
See Also:
getJavaIdentifier(java.lang.String, boolean)

getJavaMethodParameterName

public String getJavaMethodParameterName(Property property)
Gets a Java method parameter name of a property.

Parameters:
property - The property to get the Java method parameter name of.
Returns:
The Java method parameter name of property.
Throws:
NullPointerException - if property is null.
Since:
1.2

getJavaTypeName

public String getJavaTypeName(Dependency dependency)
Gets the name of a Java type of a given dependency.

Parameters:
dependency - The dependency to get a dependency Java type name of.
Returns:
The Java type name of dependency or null.
Throws:
NullPointerException - if dependency is null.
See Also:
getJavaTypeName(org.jomc.model.Specification, boolean)

getJavaGetterMethodName

public String getJavaGetterMethodName(Dependency dependency)
Gets the name of a Java getter method of a given dependency.

Parameters:
dependency - The dependency to get a Java getter method name of.
Returns:
The Java getter method name of dependency.
Throws:
NullPointerException - if dependency is null.
See Also:
getJavaIdentifier(java.lang.String, boolean)

getJavaSetterMethodName

public String getJavaSetterMethodName(Dependency dependency)
Gets the name of a Java setter method of a given dependency.

Parameters:
dependency - The dependency to get a Java setter method name of.
Returns:
The Java setter method name of dependency.
Throws:
NullPointerException - if dependency is null.
Since:
1.2
See Also:
getJavaIdentifier(java.lang.String, boolean)

getJavaMethodParameterName

public String getJavaMethodParameterName(Dependency dependency)
Gets a Java method parameter name of a dependency.

Parameters:
dependency - The dependency to get the Java method parameter name of.
Returns:
The Java method parameter name of dependency.
Throws:
NullPointerException - if dependency is null.
Since:
1.2

getJavaGetterMethodName

public String getJavaGetterMethodName(Message message)
Gets the name of a Java getter method of a given message.

Parameters:
message - The message to get a Java getter method name of.
Returns:
The Java getter method name of message.
Throws:
NullPointerException - if message is null.
See Also:
getJavaIdentifier(java.lang.String, boolean)

getJavaSetterMethodName

public String getJavaSetterMethodName(Message message)
Gets the name of a Java setter method of a given message.

Parameters:
message - The message to get a Java setter method name of.
Returns:
The Java setter method name of message.
Throws:
NullPointerException - if message is null.
Since:
1.2
See Also:
getJavaIdentifier(java.lang.String, boolean)

getJavaMethodParameterName

public String getJavaMethodParameterName(Message message)
Gets a Java method parameter name of a message.

Parameters:
message - The message to get the Java method parameter name of.
Returns:
The Java method parameter name of message.
Throws:
NullPointerException - if message is null.
Since:
1.2

getJavaModifierName

public String getJavaModifierName(Implementation implementation,
                                  Dependency dependency)
Gets the Java modifier name of a dependency of a given implementation.

Parameters:
implementation - The implementation declaring the dependency to get a Java modifier name of.
dependency - The dependency to get a Java modifier name of.
Returns:
The Java modifier name of dependency of implementation.
Throws:
NullPointerException - if implementation or dependency is null.

getJavaModifierName

public String getJavaModifierName(Implementation implementation,
                                  Message message)
Gets the Java modifier name of a message of a given implementation.

Parameters:
implementation - The implementation declaring the message to get a Java modifier name of.
message - The message to get a Java modifier name of.
Returns:
The Java modifier name of message of implementation.
Throws:
NullPointerException - if implementation or message is null.

getJavaModifierName

public String getJavaModifierName(Implementation implementation,
                                  Property property)
Gets the Java modifier name of a property of a given implementation.

Parameters:
implementation - The implementation declaring the property to get a Java modifier name of.
property - The property to get a Java modifier name of.
Returns:
The Java modifier name of property of implementation.
Throws:
NullPointerException - if implementation or property is null.

getJavadocComment

public String getJavadocComment(Text text,
                                int indentationLevel,
                                String linePrefix)
Formats a text to a Javadoc comment.

Parameters:
text - The text to format to a Javadoc comment.
indentationLevel - The indentation level of the comment.
linePrefix - The text to prepend lines with.
Returns:
text formatted to a Javadoc comment.
Throws:
NullPointerException - if text or linePrefix is null.
IllegalArgumentException - if indentationLevel is negative.

getJavadocComment

public String getJavadocComment(Texts texts,
                                int indentationLevel,
                                String linePrefix)
Formats a text from a list of texts to a Javadoc comment.

Parameters:
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.
Returns:
The text corresponding to the locale of the instance from the list of texts formatted to a Javadoc comment.
Throws:
NullPointerException - if texts or linePrefix is null.
IllegalArgumentException - if indentationLevel is negative.
Since:
1.2
See Also:
getLocale()

getJavaString

public String getJavaString(String str)
Formats a string to a Java string with unicode escapes.

Parameters:
str - The string to format to a Java string or null.
Returns:
str formatted to a Java string or null.
See Also:
StringEscapeUtils.escapeJava(java.lang.String)

getJavaIdentifier

public String getJavaIdentifier(String str,
                                boolean capitalize)
Formats a string to a Java identifier.

Parameters:
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.
Returns:
str formatted to a Java identifier or null.
Since:
1.2

isJavaDefaultPackage

public boolean isJavaDefaultPackage(Specification specification)
Gets a flag indicating the class of a given specification is located in the Java default package.

Parameters:
specification - The specification to query.
Returns:
true, if the class of specification is located in the Java default package; false, else.
Throws:
NullPointerException - if specification is null.

isJavaDefaultPackage

public boolean isJavaDefaultPackage(Implementation implementation)
Gets a flag indicating the class of a given implementation is located in the Java default package.

Parameters:
implementation - The implementation to query.
Returns:
true, if the class of implementation is located in the Java default package; false, else.
Throws:
NullPointerException - if implementation is null.

getHtmlString

public String getHtmlString(String str)
Formats a string to a HTML string with HTML entities.

Parameters:
str - The string to format to a HTML string with HTML entities or null.
Returns:
str formatted to a HTML string with HTML entities or null.
Since:
1.2
See Also:
StringEscapeUtils.escapeHtml(java.lang.String)

getXmlString

public String getXmlString(String str)
Formats a string to a XML string with XML entities.

Parameters:
str - The string to format to a XML string with XML entities or null.
Returns:
str formatted to a XML string with XML entities or null.
Since:
1.2
See Also:
StringEscapeUtils.escapeXml(java.lang.String)

getJavaScriptString

public String getJavaScriptString(String str)
Formats a string to a JavaScript string applying JavaScript string rules.

Parameters:
str - The string to format to a JavaScript string by applying JavaScript string rules or null.
Returns:
str formatted to a JavaScript string with JavaScript string rules applied or null.
Since:
1.2
See Also:
StringEscapeUtils.escapeJavaScript(java.lang.String)

getSqlString

public String getSqlString(String str)
Formats a string to a SQL string.

Parameters:
str - The string to format to a SQL string or null.
Returns:
str formatted to a SQL string or null.
Since:
1.2
See Also:
StringEscapeUtils.escapeSql(java.lang.String)

getCsvString

public String getCsvString(String str)
Formats a string to a CSV string.

Parameters:
str - The string to format to a CSV string or null.
Returns:
str formatted to a CSV string or null.
Since:
1.2
See Also:
StringEscapeUtils.escapeCsv(java.lang.String)

getBooleanString

public String getBooleanString(Boolean b)
Formats a Boolean to a string.

Parameters:
b - The Boolean to format to a string or null.
Returns:
b formatted to a string.
Since:
1.2
See Also:
getLocale()

getDisplayLanguage

public String getDisplayLanguage(String language)
Gets the display language of a given language code.

Parameters:
language - The language code to get the display language of.
Returns:
The display language of language.
Throws:
NullPointerException - if language is null.

getShortDate

public String getShortDate(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date of calendar formatted using a short format style pattern.
Throws:
NullPointerException - if calendar is null.
See Also:
DateFormat.SHORT

getMediumDate

public String getMediumDate(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date of calendar formatted using a medium format style pattern.
Throws:
NullPointerException - if calendar is null.
Since:
1.2
See Also:
DateFormat.MEDIUM

getLongDate

public String getLongDate(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date of calendar formatted using a long format style pattern.
Throws:
NullPointerException - if calendar is null.
See Also:
DateFormat.LONG

getIsoDate

public String getIsoDate(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date of calendar formatted using an ISO-8601 format style.
Throws:
NullPointerException - if calendar is null.
Since:
1.2
See Also:
yyyy-DDD

getShortTime

public String getShortTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The time of calendar formatted using a short format style pattern.
Throws:
NullPointerException - if calendar is null.
See Also:
DateFormat.SHORT

getMediumTime

public String getMediumTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The time of calendar formatted using a medium format style pattern.
Throws:
NullPointerException - if calendar is null.
Since:
1.2
See Also:
DateFormat.MEDIUM

getLongTime

public String getLongTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The time of calendar formatted using a long format style pattern.
Throws:
NullPointerException - if calendar is null.
See Also:
DateFormat.LONG

getIsoTime

public String getIsoTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The time of calendar formatted using an ISO-8601 format style.
Throws:
NullPointerException - if calendar is null.
Since:
1.2
See Also:
HH:mm

getShortDateTime

public String getShortDateTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date and time of calendar formatted using a short format style pattern.
Throws:
NullPointerException - if calendar is null.
See Also:
DateFormat.SHORT

getMediumDateTime

public String getMediumDateTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date and time of calendar formatted using a medium format style pattern.
Throws:
NullPointerException - if calendar is null.
Since:
1.2
See Also:
DateFormat.MEDIUM

getLongDateTime

public String getLongDateTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date and time of calendar formatted using a long format style pattern.
Throws:
NullPointerException - if calendar is null.
See Also:
DateFormat.LONG

getIsoDateTime

public String getIsoDateTime(Calendar calendar)
Formats a calendar instance to a string.

Parameters:
calendar - The calendar to format to a string.
Returns:
The date and time of calendar formatted using a ISO-8601 format style.
Throws:
NullPointerException - if calendar is null.
Since:
1.2
See Also:
yyyy-MM-dd'T'HH:mm:ssZ

getYears

public String getYears(Calendar start,
                       Calendar end)
Gets a string describing the range of years for given calendars.

Parameters:
start - The start of the range.
end - The end of the range.
Returns:
Formatted range of the years of start and end (e.g. "start - end").
Throws:
NullPointerException - if start or end is null.

getModel

public final Model getModel()
Gets the model of the instance.

Returns:
The model of the instance.
See Also:
getModules(), setModel(org.jomc.modlet.Model)

setModel

public final void setModel(Model value)
Sets the model of the instance.

Parameters:
value - The new model of the instance or null.
See Also:
getModel()

getModules

@Deprecated
public 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.

Gets the modules of the instance.

Returns:
The modules of the instance.
See Also:
getModel(), setModel(org.jomc.modlet.Model)

getVelocityEngine

public final VelocityEngine getVelocityEngine()
                                       throws IOException
Gets the VelocityEngine of the instance.

Returns:
The VelocityEngine of the instance.
Throws:
IOException - if initializing a new velocity engine fails.
See Also:
setVelocityEngine(org.apache.velocity.app.VelocityEngine)

setVelocityEngine

public final void setVelocityEngine(VelocityEngine value)
Sets the VelocityEngine of the instance.

Parameters:
value - The new VelocityEngine of the instance or null.
See Also:
getVelocityEngine()

getVelocityContext

public VelocityContext getVelocityContext()
Gets a new velocity context used for merging templates.

Returns:
A new velocity context used for merging templates.
See Also:
getTemplateParameters()

getTemplateParameters

public final Map<String,Object> getTemplateParameters()
Gets the template parameters of the instance.

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.

Returns:
The template parameters of the instance.
Since:
1.2
See Also:
getVelocityContext()

getTemplateLocation

public final URL getTemplateLocation()
Gets the location to search for templates in addition to searching the class path.

Returns:
The location to search for templates in addition to searching the class path or null.
Since:
1.2
See Also:
setTemplateLocation(java.net.URL)

setTemplateLocation

public final void setTemplateLocation(URL value)
Sets the location to search for templates in addition to searching the class path.

Parameters:
value - The new location to search for templates in addition to searching the class path or null.
Since:
1.2
See Also:
getTemplateLocation()

getTemplateEncoding

public final String getTemplateEncoding()
Gets the encoding to use for reading templates.

Returns:
The encoding to use for reading templates.
See Also:
setTemplateEncoding(java.lang.String)

setTemplateEncoding

public final void setTemplateEncoding(String value)
Sets the encoding to use for reading templates.

Parameters:
value - The new encoding to use for reading templates or null.
See Also:
getTemplateEncoding()

getInputEncoding

public final String getInputEncoding()
Gets the encoding to use for reading files.

Returns:
The encoding to use for reading files.
See Also:
setInputEncoding(java.lang.String)

setInputEncoding

public final void setInputEncoding(String value)
Sets the encoding to use for reading files.

Parameters:
value - The new encoding to use for reading files or null.
See Also:
getInputEncoding()

getOutputEncoding

public final String getOutputEncoding()
Gets the encoding to use for writing files.

Returns:
The encoding to use for writing files.
See Also:
setOutputEncoding(java.lang.String)

setOutputEncoding

public final void setOutputEncoding(String value)
Sets the encoding to use for writing files.

Parameters:
value - The encoding to use for writing files or null.
See Also:
getOutputEncoding()

getDefaultTemplateProfile

@Deprecated
public 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.

Gets the default template profile.

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.

Returns:
The default template profile.
See Also:
setDefaultTemplateProfile(java.lang.String)

setDefaultTemplateProfile

@Deprecated
public static void setDefaultTemplateProfile(String value)
Deprecated. The static modifier of this method will be removed in version 2.0.

Sets the default template profile.

Parameters:
value - The new default template profile or null.
See Also:
getDefaultTemplateProfile()

getTemplateProfile

public final String getTemplateProfile()
Gets the template profile of the instance.

Returns:
The template profile of the instance.
See Also:
getDefaultTemplateProfile(), setTemplateProfile(java.lang.String)

setTemplateProfile

public final void setTemplateProfile(String value)
Sets the template profile of the instance.

Parameters:
value - The new template profile of the instance or null.
See Also:
getTemplateProfile()

getIndentation

public final String getIndentation()
Gets the indentation string of the instance.

Returns:
The indentation string of the instance.
See Also:
setIndentation(java.lang.String)

getIndentation

public final String getIndentation(int level)
Gets an indentation string for a given indentation level.

Parameters:
level - The indentation level to get an indentation string for.
Returns:
The indentation string for level.
Throws:
IllegalArgumentException - if level is negative.
See Also:
getIndentation()

setIndentation

public final void setIndentation(String value)
Sets the indentation string of the instance.

Parameters:
value - The new indentation string of the instance or null.
See Also:
getIndentation()

getLineSeparator

public final String getLineSeparator()
Gets the line separator of the instance.

Returns:
The line separator of the instance.
See Also:
setLineSeparator(java.lang.String)

setLineSeparator

public final void setLineSeparator(String value)
Sets the line separator of the instance.

Parameters:
value - The new line separator of the instance or null.
See Also:
getLineSeparator()

getLocale

public final Locale getLocale()
Gets the locale of the instance.

Returns:
The locale of the instance.
Since:
1.2
See Also:
setLocale(java.util.Locale)

setLocale

public final void setLocale(Locale value)
Sets the locale of the instance.

Parameters:
value - The new locale of the instance or null.
Since:
1.2
See Also:
getLocale()

getVelocityTemplate

public Template getVelocityTemplate(String templateName)
                             throws IOException
Gets a velocity template for a given name.

This method searches templates at the following locations in the shown order.

  1. org/jomc/tools/templates/profile/language/templateName
  2. org/jomc/tools/templates/profile/templateName
  3. org/jomc/tools/templates/default profile/language/templateName
  4. org/jomc/tools/templates/default profile/templateName

Parameters:
templateName - The name of the template to get.
Returns:
The template matching templateName.
Throws:
NullPointerException - if templateName is null.
IOException - if getting the template fails.
See Also:
getLocale(), getTemplateProfile(), getTemplateEncoding(), getVelocityEngine()

log

public void log(Level level,
                String message,
                Throwable throwable)
Notifies registered listeners.

Parameters:
level - The level of the event.
message - The message of the event or null.
throwable - The throwable of the event or null.
Throws:
NullPointerException - if level is null.
See Also:
getListeners(), isLoggable(java.util.logging.Level)


Copyright © 2005-2012 The JOMC Project. All Rights Reserved.Get JOMC at SourceForge.net. Fast, secure and Free Open Source software downloads
Please note that this documentation is maintained by non-native english speaking authors. As such, you may encounter phrases or wordings which seem imprecise or may even have a totally different meaning to native english speaking readers than what the individual author was trying to express. If you are a native english speaking reader and find any such phrases or wordings we kindly ask you to send an email to the corresponding author and help us improve this documentation in order to avoid misunderstandings. You will find the authors' email addresses at the top of each class. Please accept our apologies for any inconvenience caused.