From: Juergen H. <jho...@us...> - 2006-07-03 15:44:38
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet/view In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv15690/src/org/springframework/web/servlet/view Modified Files: AbstractView.java Log Message: factored out "CollectionUtils.mergePropertiesIntoMap" Index: AbstractView.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/AbstractView.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** AbstractView.java 4 May 2006 14:02:13 -0000 1.25 --- AbstractView.java 3 Jul 2006 15:44:32 -0000 1.26 *************** *** 26,36 **** import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import javax.servlet.ServletException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.web.context.support.WebApplicationObjectSupport; import org.springframework.web.servlet.View; import org.springframework.web.servlet.support.RequestContext; - import org.springframework.util.ClassUtils; /** --- 26,35 ---- import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.BeanNameAware; + import org.springframework.util.CollectionUtils; import org.springframework.web.context.support.WebApplicationObjectSupport; import org.springframework.web.servlet.View; import org.springframework.web.servlet.support.RequestContext; /** *************** *** 128,155 **** */ public void setAttributesCSV(String propString) throws IllegalArgumentException { ! if (propString == null) { ! // leave static attributes unchanged ! return; ! } ! ! StringTokenizer st = new StringTokenizer(propString, ","); ! while (st.hasMoreTokens()) { ! String tok = st.nextToken(); ! int eqIdx = tok.indexOf("="); ! if (eqIdx == -1) { ! throw new IllegalArgumentException("Expected = in attributes CSV string '" + propString + "'"); ! } ! if (eqIdx >= tok.length() - 2) { ! throw new IllegalArgumentException( ! "At least 2 characters ([]) required in attributes CSV string '" + propString + "'"); ! } ! String name = tok.substring(0, eqIdx); ! String value = tok.substring(eqIdx + 1); ! // celete first and last characters of value: { and } ! value = value.substring(1); ! value = value.substring(0, value.length() - 1); ! addStaticAttribute(name, value); } } --- 127,151 ---- */ public void setAttributesCSV(String propString) throws IllegalArgumentException { ! if (propString != null) { ! StringTokenizer st = new StringTokenizer(propString, ","); ! while (st.hasMoreTokens()) { ! String tok = st.nextToken(); ! int eqIdx = tok.indexOf("="); ! if (eqIdx == -1) { ! throw new IllegalArgumentException("Expected = in attributes CSV string '" + propString + "'"); ! } ! if (eqIdx >= tok.length() - 2) { ! throw new IllegalArgumentException( ! "At least 2 characters ([]) required in attributes CSV string '" + propString + "'"); ! } ! String name = tok.substring(0, eqIdx); ! String value = tok.substring(eqIdx + 1); ! // delete first and last characters of value: { and } ! value = value.substring(1); ! value = value.substring(0, value.length() - 1); ! addStaticAttribute(name, value); ! } } } *************** *** 165,170 **** * @see org.springframework.beans.propertyeditors.PropertiesEditor */ ! public void setAttributes(Properties props) { ! setAttributesMap(props); } --- 161,166 ---- * @see org.springframework.beans.propertyeditors.PropertiesEditor */ ! public void setAttributes(Properties attributes) { ! CollectionUtils.mergePropertiesIntoMap(attributes, this.staticAttributes); } *************** *** 238,242 **** } ! // consolidate static and dynamic model attributes Map mergedModel = new HashMap(this.staticAttributes.size() + (model != null ? model.size() : 0)); mergedModel.putAll(this.staticAttributes); --- 234,238 ---- } ! // Consolidate static and dynamic model attributes. Map mergedModel = new HashMap(this.staticAttributes.size() + (model != null ? model.size() : 0)); mergedModel.putAll(this.staticAttributes); *************** *** 245,249 **** } ! // expose RequestContext? if (this.requestContextAttribute != null) { mergedModel.put(this.requestContextAttribute, createRequestContext(request, mergedModel)); --- 241,245 ---- } ! // Expose RequestContext? if (this.requestContextAttribute != null) { mergedModel.put(this.requestContextAttribute, createRequestContext(request, mergedModel)); *************** *** 284,298 **** - public String toString() { - StringBuffer sb = new StringBuffer(getClass().getName()); - if (getBeanName() != null) { - sb.append(": name '").append(getBeanName()).append("'"); - } - else { - sb.append(": unnamed"); - } - return sb.toString(); - } - /** * Expose the model objects in the given map as request attributes. --- 280,283 ---- *************** *** 307,311 **** Map.Entry entry = (Map.Entry) it.next(); if (!(entry.getKey() instanceof String)) { ! throw new ServletException( "Invalid key [" + entry.getKey() + "] in model Map - only Strings allowed as model keys"); } --- 292,296 ---- Map.Entry entry = (Map.Entry) it.next(); if (!(entry.getKey() instanceof String)) { ! throw new IllegalArgumentException( "Invalid key [" + entry.getKey() + "] in model Map - only Strings allowed as model keys"); } *************** *** 316,320 **** if (logger.isDebugEnabled()) { logger.debug("Added model object '" + modelName + "' of type [" + modelValue.getClass().getName() + ! "] to request in " + ClassUtils.getShortName(getClass()) + "'" + getBeanName() + "'"); } } --- 301,305 ---- if (logger.isDebugEnabled()) { logger.debug("Added model object '" + modelName + "' of type [" + modelValue.getClass().getName() + ! "] to request in view with name '" + getBeanName() + "'"); } } *************** *** 323,330 **** if (logger.isDebugEnabled()) { logger.debug("Removed model object '" + modelName + ! "' from request in " + ClassUtils.getShortName(getClass()) + "'" + getBeanName() + "'"); } } } } } --- 308,328 ---- if (logger.isDebugEnabled()) { logger.debug("Removed model object '" + modelName + ! "' from request in view with name '" + getBeanName() + "'"); } } } } + + + public String toString() { + StringBuffer sb = new StringBuffer(getClass().getName()); + if (getBeanName() != null) { + sb.append(": name '").append(getBeanName()).append("'"); + } + else { + sb.append(": unnamed"); + } + return sb.toString(); + } + } |