Author: nbubna
Date: Fri Jul 6 11:41:27 2007
New Revision: 553989
URL: http://svn.apache.org/viewvc?view=rev&rev=553989
Log:
set manual keys as properties and break default key retrieval into separate
method
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java?view=diff&rev=553989&r1=553988&r2=553989
==============================================================================
---
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
(original)
+++
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
Fri Jul 6 11:41:27 2007
@@ -46,6 +46,9 @@
public void setKey(String key)
{
this.key = key;
+
+ // ensure any manually set key is also set as a property
+ setProperty("key", key);
}
/**
@@ -69,12 +72,8 @@
}
/**
- * Returns the key set for this tool, if not [EMAIL PROTECTED] null}.
Otherwise,
- * looks for a [EMAIL PROTECTED] DefaultKey} annotation on the tool class.
Finally,
- * if there is no default key set, the [EMAIL PROTECTED]
Class#getSimpleName()} is
- * transformed into the key by removing any 'Tool' suffix and lowercasing
- * the first character. This will only return [EMAIL PROTECTED] null} if
there is
- * both no key and no classname set for this tool.
+ * Returns the key set for this tool. If no key has been explicitly
+ * set, this will return the result of [EMAIL PROTECTED] #getDefaultKey()}.
*/
public String getKey()
{
@@ -82,7 +81,19 @@
{
return this.key;
}
+ return getDefaultKey();
+ }
+ /**
+ * Returns the default key value for the set tool class. First, this
+ * looks for a [EMAIL PROTECTED] DefaultKey} annotation on the tool class.
Then,
+ * if there is no default key annotation, the [EMAIL PROTECTED]
Class#getSimpleName()}
+ * is transformed into the key by removing any 'Tool' suffix and
+ * lowercasing the first character. This will only return [EMAIL
PROTECTED] null}
+ * if there is both no key and no classname set for this tool.
+ */
+ public String getDefaultKey()
+ {
if (getClassname() != null)
{
Class clazz = getToolClass();