|
From: <mb...@re...> - 2004-11-05 23:45:51
|
Author: mbooth
Date: 2004-11-06 00:38:51 +0100 (Sat, 06 Nov 2004)
New Revision: 84
Modified:
ccm-core/trunk/src/com/arsdigita/formbuilder/util/Placeholders.java
ccm-core/trunk/src/com/arsdigita/util/StringUtils.java
Log:
Handle dashes (-) in parameter names and do something useful with array values.
Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/util/Placeholders.java
===================================================================
--- ccm-core/trunk/src/com/arsdigita/formbuilder/util/Placeholders.java 2004-11-05 19:57:28 UTC (rev 83)
+++ ccm-core/trunk/src/com/arsdigita/formbuilder/util/Placeholders.java 2004-11-05 23:38:51 UTC (rev 84)
@@ -114,18 +114,8 @@
while(params.hasNext()) {
ParameterData param = (ParameterData)params.next();
Object value = param.getValue();
- m_vars.put("form." + param.getName(), (value == null ? "(null)" : value.toString()));
+ m_vars.put("form." + param.getName(), (value == null ? "(null)" : value));
}
-
- /*
- Iterator keys = data.keySet().iterator();
- while (keys.hasNext()) {
- String key = (String)keys.next();
- Object value = data.get(key);
-
- m_vars.put("form." + key, (value == null ? "(null)" : value.toString()));
- }
- */
}
protected void setSystemVars() {
Modified: ccm-core/trunk/src/com/arsdigita/util/StringUtils.java
===================================================================
--- ccm-core/trunk/src/com/arsdigita/util/StringUtils.java 2004-11-05 19:57:28 UTC (rev 83)
+++ ccm-core/trunk/src/com/arsdigita/util/StringUtils.java 2004-11-05 23:38:51 UTC (rev 84)
@@ -1091,7 +1091,7 @@
try {
Util.substitute(result,
matcher,
- compiler.compile("(::(?:\\w+(?:\\.\\w+)*)::)"),
+ compiler.compile("(::(?:\\w+(?:[.-]+\\w+)*)::)"),
subst,
input,
Util.SUBSTITUTE_ALL);
@@ -1203,12 +1203,41 @@
Object value = (m_hash.containsKey(key) ?
m_hash.get(key) :
placeholder);
+
+ if( s_log.isDebugEnabled() ) {
+ Object hashValue = m_hash.get( key );
+
+ s_log.debug( "Placeholder: " + placeholder );
+ s_log.debug( "Key: " + key );
+ if( null != value ) {
+ s_log.debug( "Value (" + value.getClass().getName() +
+ "): " + value.toString() );
+ }
+ if( null != hashValue ) {
+ s_log.debug( "Hash Value (" +
+ hashValue.getClass().getName() + "): " +
+ hashValue.toString() );
+ }
+ }
+
String val;
- try {
+ if( value instanceof PlaceholderValueGenerator ) {
PlaceholderValueGenerator gen = (PlaceholderValueGenerator)value;
val = gen.generate(key);
- } catch (ClassCastException ex) {
- val = (String)value;
+ } else if( value.getClass().isArray() ) {
+ Object[] values = (Object[]) value;
+
+ StringBuffer buf = new StringBuffer();
+ for( int i = 0; i < values.length; i++ ) {
+ buf.append( values[i].toString() );
+ if( (values.length - 1) != i ) {
+ buf.append( ", " );
+ }
+ }
+
+ val = buf.toString();
+ } else {
+ val = value.toString();
}
appendBuffer.append(val);
|