Author: remy.maucherat(a)jboss.com
Date: 2008-03-25 10:49:56 -0400 (Tue, 25 Mar 2008)
New Revision: 540
Modified:
trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
trunk/webapps/docs/changelog.xml
Log:
- Allow specifying a default value for property lookup.
Modified: trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
===================================================================
--- trunk/java/org/apache/tomcat/util/IntrospectionUtils.java 2008-03-25 08:17:56 UTC (rev
539)
+++ trunk/java/org/apache/tomcat/util/IntrospectionUtils.java 2008-03-25 14:49:56 UTC (rev
540)
@@ -498,7 +498,15 @@
prev = value.length();
continue;
}
- String n = value.substring(pos + 2, endName);
+ int endName2 = value.indexOf(':', pos);
+ String n = null;
+ String d = null;
+ if (endName2 > 0 && endName2 < endName) {
+ n = value.substring(pos + 2, endName2);
+ d = value.substring(endName2 + 1, endName);
+ } else {
+ n = value.substring(pos + 2, endName);
+ }
String v = null;
if (staticProp != null) {
v = (String) ((Hashtable) staticProp).get(n);
@@ -511,8 +519,13 @@
}
}
}
- if (v == null)
- v = "${" + n + "}";
+ if (v == null) {
+ if (d == null) {
+ v = "${" + n + "}";
+ } else {
+ v = d;
+ }
+ }
sb.append(v);
prev = endName + 1;
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-03-25 08:17:56 UTC (rev 539)
+++ trunk/webapps/docs/changelog.xml 2008-03-25 14:49:56 UTC (rev 540)
@@ -48,6 +48,9 @@
<fix>
Comet state recycling. (remm)
</fix>
+ <update>
+ Add support for specifying defaults for properties (format is
${property:default}). (remm)
+ </update>
</changelog>
</subsection>
</section>
Show replies by date