geirm 01/03/16 21:08:41
Modified: src/java/org/apache/velocity/runtime/configuration
Configuration.java
Log:
Added getProperty() config value accessor method. Used by Runtime to get
values, so internal subsystems can access 'raw' values directly from the
configuration. (Needed it for switching VelocimacroFactory to use the
CSV for libraries...)
Revision Changes Path
1.13 +32 -1
jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configuration.java
Index: Configuration.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configuration.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Configuration.java 2001/03/14 21:48:37 1.12
+++ Configuration.java 2001/03/17 05:08:40 1.13
@@ -136,7 +136,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:daveb@miceda-data">Dave Bryson</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Configuration.java,v 1.12 2001/03/14 21:48:37 jvanzyl Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
+ * @version $Id: Configuration.java,v 1.13 2001/03/17 05:08:40 geirm Exp $
*/
public class Configuration extends Hashtable
{
@@ -436,6 +437,36 @@
}
}
+ /**
+ * Gets a property from the configuration.
+ *
+ * @param key property to retrieve
+ * @return value as object. Will return user value if exists,
+ * if not then default value if exists, otherwise null
+ */
+ public Object getProperty( String key)
+ {
+ /*
+ * first, try to get from the 'user value' store
+ */
+ Object o = this.get(key);
+
+ if ( o == null)
+ {
+ /*
+ * if there isn't a value there, get it from the
+ * defaults if we have them
+ */
+
+ if (defaults != null)
+ {
+ o = defaults.get(key);
+ }
+ }
+
+ return o;
+ }
+
/**
* Set a property taking into consideration
* duplicate keys.