You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2007/07/06 20:41:28 UTC
svn commit: r553989 -
/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
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 {@link null}. Otherwise,
- * looks for a {@link DefaultKey} annotation on the tool class. Finally,
- * if there is no default key set, the {@link Class#getSimpleName()} is
- * transformed into the key by removing any 'Tool' suffix and lowercasing
- * the first character. This will only return {@link 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 {@link #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 {@link DefaultKey} annotation on the tool class. Then,
+ * if there is no default key annotation, the {@link Class#getSimpleName()}
+ * is transformed into the key by removing any 'Tool' suffix and
+ * lowercasing the first character. This will only return {@link null}
+ * if there is both no key and no classname set for this tool.
+ */
+ public String getDefaultKey()
+ {
if (getClassname() != null)
{
Class clazz = getToolClass();