Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1659 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
15 changed files with 891 additions and 8 deletions
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
/* |
||||
* Copyright 2004-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.core.collection; |
||||
|
||||
import java.util.Iterator; |
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
import java.util.NoSuchElementException; |
||||
|
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* Iterator that combines multiple other iterators. This is a simple implementation that just maintains a list of |
||||
* iterators which are invoked in sequence untill all iterators are exhausted. |
||||
* @author Erwin Vervaet |
||||
*/ |
||||
public class CompositeIterator<E> implements Iterator<E> { |
||||
|
||||
private List<Iterator<E>> iterators = new LinkedList<Iterator<E>>(); |
||||
|
||||
private boolean inUse = false; |
||||
|
||||
/** |
||||
* Create a new composite iterator. Add iterators using the {@link #add(Iterator)} method. |
||||
*/ |
||||
public CompositeIterator() { |
||||
} |
||||
|
||||
/** |
||||
* Add given iterator to this composite. |
||||
*/ |
||||
public void add(Iterator<E> iterator) { |
||||
Assert.state(!inUse, "You can no longer add iterator to a composite iterator that's already in use"); |
||||
if (iterators.contains(iterator)) { |
||||
throw new IllegalArgumentException("You cannot add the same iterator twice"); |
||||
} |
||||
iterators.add(iterator); |
||||
} |
||||
|
||||
public boolean hasNext() { |
||||
inUse = true; |
||||
for (Iterator<Iterator<E>> it = iterators.iterator(); it.hasNext();) { |
||||
if (it.next().hasNext()) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public E next() { |
||||
inUse = true; |
||||
for (Iterator<Iterator<E>> it = iterators.iterator(); it.hasNext();) { |
||||
Iterator<E> iterator = it.next(); |
||||
if (iterator.hasNext()) { |
||||
return iterator.next(); |
||||
} |
||||
} |
||||
throw new NoSuchElementException("Exhaused all iterators"); |
||||
} |
||||
|
||||
public void remove() { |
||||
throw new UnsupportedOperationException("Remove is not supported"); |
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright 2004-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.core.collection; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* A simple subinterface of {@link Map} that exposes a mutex that application code can synchronize on. |
||||
* <p> |
||||
* Expected to be implemented by Maps that are backed by shared objects that require synchronization between multiple |
||||
* threads. An example would be the HTTP session map. |
||||
* |
||||
* @author Keith Donald |
||||
*/ |
||||
public interface SharedMap<K, V> extends Map<K, V> { |
||||
|
||||
/** |
||||
* Returns the shared mutex that may be synchronized on using a synchronized block. The returned mutex is guaranteed |
||||
* to be non-null. |
||||
* |
||||
* Example usage: |
||||
* |
||||
* <pre> |
||||
* synchronized (sharedMap.getMutex()) { |
||||
* // do synchronized work
|
||||
* } |
||||
* </pre> |
||||
* |
||||
* @return the mutex |
||||
*/ |
||||
public Object getMutex(); |
||||
} |
||||
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
/* |
||||
* Copyright 2004-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.core.collection; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Collection; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
import org.springframework.core.style.ToStringCreator; |
||||
|
||||
/** |
||||
* A map decorator that implements <code>SharedMap</code>. By default, simply returns the map itself as the mutex. |
||||
* Subclasses may override to return a different mutex object. |
||||
* |
||||
* @author Keith Donald |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
public class SharedMapDecorator<K, V> implements SharedMap<K, V>, Serializable { |
||||
|
||||
/** |
||||
* The wrapped, target map. |
||||
*/ |
||||
private Map<K, V> map; |
||||
|
||||
/** |
||||
* Creates a new shared map decorator. |
||||
* @param map the map that is shared by multiple threads, to be synced |
||||
*/ |
||||
public SharedMapDecorator(Map<K, V> map) { |
||||
this.map = map; |
||||
} |
||||
|
||||
// implementing Map
|
||||
|
||||
public void clear() { |
||||
map.clear(); |
||||
} |
||||
|
||||
public boolean containsKey(Object key) { |
||||
return map.containsKey(key); |
||||
} |
||||
|
||||
public boolean containsValue(Object value) { |
||||
return map.containsValue(value); |
||||
} |
||||
|
||||
public Set<Map.Entry<K, V>> entrySet() { |
||||
return map.entrySet(); |
||||
} |
||||
|
||||
public V get(Object key) { |
||||
return map.get(key); |
||||
} |
||||
|
||||
public boolean isEmpty() { |
||||
return map.isEmpty(); |
||||
} |
||||
|
||||
public Set<K> keySet() { |
||||
return map.keySet(); |
||||
} |
||||
|
||||
public V put(K key, V value) { |
||||
return map.put(key, value); |
||||
} |
||||
|
||||
public void putAll(Map<? extends K, ? extends V> map) { |
||||
this.map.putAll(map); |
||||
} |
||||
|
||||
public V remove(Object key) { |
||||
return map.remove(key); |
||||
} |
||||
|
||||
public int size() { |
||||
return map.size(); |
||||
} |
||||
|
||||
public Collection<V> values() { |
||||
return map.values(); |
||||
} |
||||
|
||||
// implementing SharedMap
|
||||
|
||||
public Object getMutex() { |
||||
return map; |
||||
} |
||||
|
||||
public String toString() { |
||||
return new ToStringCreator(this).append("map", map).append("mutex", getMutex()).toString(); |
||||
} |
||||
} |
||||
@ -0,0 +1,348 @@
@@ -0,0 +1,348 @@
|
||||
/* |
||||
* Copyright 2004-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.core.collection; |
||||
|
||||
import java.util.AbstractSet; |
||||
import java.util.Collection; |
||||
import java.util.Iterator; |
||||
import java.util.Map; |
||||
import java.util.NoSuchElementException; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Base class for map adapters whose keys are String values. Concrete classes need only implement the abstract hook |
||||
* methods defined by this class. |
||||
* |
||||
* @author Keith Donald |
||||
*/ |
||||
public abstract class StringKeyedMapAdapter<V> implements Map<String, V> { |
||||
|
||||
private Set<String> keySet; |
||||
|
||||
private Collection<V> values; |
||||
|
||||
private Set<Map.Entry<String, V>> entrySet; |
||||
|
||||
// implementing Map
|
||||
|
||||
public void clear() { |
||||
for (Iterator<String> it = getAttributeNames(); it.hasNext();) { |
||||
removeAttribute((String) it.next()); |
||||
} |
||||
} |
||||
|
||||
public boolean containsKey(Object key) { |
||||
return getAttribute(key.toString()) != null; |
||||
} |
||||
|
||||
public boolean containsValue(Object value) { |
||||
if (value == null) { |
||||
return false; |
||||
} |
||||
for (Iterator<String> it = getAttributeNames(); it.hasNext();) { |
||||
Object aValue = getAttribute((String) it.next()); |
||||
if (value.equals(aValue)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public Set<Map.Entry<String, V>> entrySet() { |
||||
return (entrySet != null) ? entrySet : (entrySet = new EntrySet()); |
||||
} |
||||
|
||||
public V get(Object key) { |
||||
return getAttribute(key.toString()); |
||||
} |
||||
|
||||
public boolean isEmpty() { |
||||
return !getAttributeNames().hasNext(); |
||||
} |
||||
|
||||
public Set<String> keySet() { |
||||
return (keySet != null) ? keySet : (keySet = new KeySet()); |
||||
} |
||||
|
||||
public V put(String key, V value) { |
||||
String stringKey = String.valueOf(key); |
||||
V previousValue = getAttribute(stringKey); |
||||
setAttribute(stringKey, value); |
||||
return previousValue; |
||||
} |
||||
|
||||
public void putAll(Map<? extends String, ? extends V> map) { |
||||
for (Map.Entry<? extends String, ? extends V> entry : map.entrySet()) { |
||||
setAttribute(entry.getKey().toString(), entry.getValue()); |
||||
} |
||||
} |
||||
|
||||
public V remove(Object key) { |
||||
String stringKey = key.toString(); |
||||
V retval = getAttribute(stringKey); |
||||
removeAttribute(stringKey); |
||||
return retval; |
||||
} |
||||
|
||||
public int size() { |
||||
int size = 0; |
||||
for (Iterator<String> it = getAttributeNames(); it.hasNext();) { |
||||
size++; |
||||
it.next(); |
||||
} |
||||
return size; |
||||
} |
||||
|
||||
public Collection<V> values() { |
||||
return (values != null) ? values : (values = new Values()); |
||||
} |
||||
|
||||
// hook methods
|
||||
|
||||
/** |
||||
* Hook method that needs to be implemented by concrete subclasses. Gets a value associated with a key. |
||||
* @param key the key to lookup |
||||
* @return the associated value, or null if none |
||||
*/ |
||||
protected abstract V getAttribute(String key); |
||||
|
||||
/** |
||||
* Hook method that needs to be implemented by concrete subclasses. Puts a key-value pair in the map, overwriting |
||||
* any possible earlier value associated with the same key. |
||||
* @param key the key to associate the value with |
||||
* @param value the value to associate with the key |
||||
*/ |
||||
protected abstract void setAttribute(String key, V value); |
||||
|
||||
/** |
||||
* Hook method that needs to be implemented by concrete subclasses. Removes a key and its associated value from the |
||||
* map. |
||||
* @param key the key to remove |
||||
*/ |
||||
protected abstract void removeAttribute(String key); |
||||
|
||||
/** |
||||
* Hook method that needs to be implemented by concrete subclasses. Returns an enumeration listing all keys known to |
||||
* the map. |
||||
* @return the key enumeration |
||||
*/ |
||||
protected abstract Iterator<String> getAttributeNames(); |
||||
|
||||
// internal helper classes
|
||||
|
||||
private class KeySet extends AbstractSet<String> { |
||||
|
||||
public boolean isEmpty() { |
||||
return StringKeyedMapAdapter.this.isEmpty(); |
||||
} |
||||
|
||||
public int size() { |
||||
return StringKeyedMapAdapter.this.size(); |
||||
} |
||||
|
||||
public void clear() { |
||||
StringKeyedMapAdapter.this.clear(); |
||||
} |
||||
|
||||
public Iterator<String> iterator() { |
||||
return new KeyIterator(); |
||||
} |
||||
|
||||
public boolean contains(Object o) { |
||||
return StringKeyedMapAdapter.this.containsKey(o); |
||||
} |
||||
|
||||
public boolean remove(Object o) { |
||||
return StringKeyedMapAdapter.this.remove(o) != null; |
||||
} |
||||
|
||||
} |
||||
|
||||
private class KeyIterator implements Iterator<String> { |
||||
|
||||
private final Iterator<String> it = getAttributeNames(); |
||||
|
||||
private String currentKey; |
||||
|
||||
public boolean hasNext() { |
||||
return it.hasNext(); |
||||
} |
||||
|
||||
public String next() { |
||||
return currentKey = it.next(); |
||||
} |
||||
|
||||
public void remove() { |
||||
if (currentKey == null) { |
||||
throw new NoSuchElementException("You must call next() at least once"); |
||||
} |
||||
StringKeyedMapAdapter.this.remove(currentKey); |
||||
} |
||||
|
||||
} |
||||
|
||||
private class Values extends AbstractSet<V> { |
||||
|
||||
public boolean isEmpty() { |
||||
return StringKeyedMapAdapter.this.isEmpty(); |
||||
} |
||||
|
||||
public int size() { |
||||
return StringKeyedMapAdapter.this.size(); |
||||
} |
||||
|
||||
public void clear() { |
||||
StringKeyedMapAdapter.this.clear(); |
||||
} |
||||
|
||||
public Iterator<V> iterator() { |
||||
return new ValuesIterator(); |
||||
} |
||||
|
||||
public boolean contains(Object o) { |
||||
return StringKeyedMapAdapter.this.containsValue(o); |
||||
} |
||||
|
||||
public boolean remove(Object o) { |
||||
if (o == null) { |
||||
return false; |
||||
} |
||||
for (Iterator<V> it = iterator(); it.hasNext();) { |
||||
if (o.equals(it.next())) { |
||||
it.remove(); |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
private class ValuesIterator implements Iterator<V> { |
||||
|
||||
private final Iterator<String> it = getAttributeNames(); |
||||
|
||||
private String currentKey; |
||||
|
||||
public boolean hasNext() { |
||||
return it.hasNext(); |
||||
} |
||||
|
||||
public V next() { |
||||
currentKey = it.next(); |
||||
return StringKeyedMapAdapter.this.get(currentKey); |
||||
} |
||||
|
||||
public void remove() { |
||||
if (currentKey == null) { |
||||
throw new NoSuchElementException("You must call next() at least once"); |
||||
} |
||||
StringKeyedMapAdapter.this.remove(currentKey); |
||||
} |
||||
|
||||
} |
||||
|
||||
private class EntrySet extends AbstractSet<Map.Entry<String, V>> { |
||||
|
||||
public boolean isEmpty() { |
||||
return StringKeyedMapAdapter.this.isEmpty(); |
||||
} |
||||
|
||||
public int size() { |
||||
return StringKeyedMapAdapter.this.size(); |
||||
} |
||||
|
||||
public void clear() { |
||||
StringKeyedMapAdapter.this.clear(); |
||||
} |
||||
|
||||
public Iterator<Map.Entry<String, V>> iterator() { |
||||
return new EntryIterator(); |
||||
} |
||||
|
||||
@SuppressWarnings("unchecked") |
||||
public boolean contains(Object o) { |
||||
if (!(o instanceof Entry)) { |
||||
return false; |
||||
} |
||||
Entry entry = (Entry) o; |
||||
Object key = entry.getKey(); |
||||
Object value = entry.getValue(); |
||||
if (key == null || value == null) { |
||||
return false; |
||||
} |
||||
return value.equals(StringKeyedMapAdapter.this.get(key)); |
||||
} |
||||
|
||||
@SuppressWarnings("unchecked") |
||||
public boolean remove(Object o) { |
||||
if (!(o instanceof Entry)) { |
||||
return false; |
||||
} |
||||
Entry entry = (Entry) o; |
||||
Object key = entry.getKey(); |
||||
Object value = entry.getValue(); |
||||
if (key == null || value == null || !value.equals(StringKeyedMapAdapter.this.get(key))) { |
||||
return false; |
||||
} |
||||
return StringKeyedMapAdapter.this.remove(((Entry) o).getKey()) != null; |
||||
} |
||||
} |
||||
|
||||
private class EntryIterator implements Iterator<Map.Entry<String, V>> { |
||||
|
||||
private final Iterator<String> it = getAttributeNames(); |
||||
|
||||
private String currentKey; |
||||
|
||||
public boolean hasNext() { |
||||
return it.hasNext(); |
||||
} |
||||
|
||||
public Map.Entry<String, V> next() { |
||||
currentKey = it.next(); |
||||
return new EntrySetEntry(currentKey); |
||||
} |
||||
|
||||
public void remove() { |
||||
if (currentKey == null) { |
||||
throw new NoSuchElementException("You must call next() at least once"); |
||||
} |
||||
StringKeyedMapAdapter.this.remove(currentKey); |
||||
} |
||||
|
||||
} |
||||
|
||||
private class EntrySetEntry implements Entry<String, V> { |
||||
|
||||
private final String currentKey; |
||||
|
||||
public EntrySetEntry(String currentKey) { |
||||
this.currentKey = currentKey; |
||||
} |
||||
|
||||
public String getKey() { |
||||
return currentKey; |
||||
} |
||||
|
||||
public V getValue() { |
||||
return StringKeyedMapAdapter.this.get(currentKey); |
||||
} |
||||
|
||||
public V setValue(V value) { |
||||
return StringKeyedMapAdapter.this.put(currentKey, value); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
|
||||
/** |
||||
* Collection extensions used in the framework. |
||||
*/ |
||||
package org.springframework.core.collection; |
||||
|
||||
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
/* |
||||
* Copyright 2004-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.web.servlet.support; |
||||
|
||||
import javax.servlet.ServletRequest; |
||||
|
||||
import org.springframework.model.ui.PresentationModelFactory; |
||||
import org.springframework.model.ui.support.DefaultPresentationModelFactory; |
||||
import org.springframework.web.context.request.WebRequest; |
||||
|
||||
/** |
||||
* Utilities for working with the <code>model.ui</code> PresentationModel system. |
||||
* @author Keith Donald |
||||
*/ |
||||
public final class PresentationModelUtils { |
||||
|
||||
private static final String PRESENTATION_MODEL_FACTORY_ATTRIBUTE = "presentationModelFactory"; |
||||
|
||||
private PresentationModelUtils() { |
||||
} |
||||
|
||||
/** |
||||
* Get the PresentationModelFactory for the current web request. |
||||
* Will create a new one and cache it as a request attribute if one does not exist. |
||||
* @param request the web request |
||||
* @return the presentation model factory |
||||
*/ |
||||
public static PresentationModelFactory getPresentationModelFactory(WebRequest request) { |
||||
PresentationModelFactory factory = (PresentationModelFactory) request.getAttribute(PRESENTATION_MODEL_FACTORY_ATTRIBUTE, WebRequest.SCOPE_REQUEST); |
||||
if (factory == null) { |
||||
factory = new DefaultPresentationModelFactory(); |
||||
request.setAttribute(PRESENTATION_MODEL_FACTORY_ATTRIBUTE, factory, WebRequest.SCOPE_REQUEST); |
||||
} |
||||
return factory; |
||||
} |
||||
|
||||
/** |
||||
* Get the PresentationModelFactory for the current servlet request. |
||||
* Will create a new one and cache it as a request attribute if one does not exist. |
||||
* @param request the servlet |
||||
* @return the presentation model factory |
||||
*/ |
||||
public static PresentationModelFactory getPresentationModelFactory(ServletRequest request) { |
||||
PresentationModelFactory factory = (PresentationModelFactory) request.getAttribute(PRESENTATION_MODEL_FACTORY_ATTRIBUTE); |
||||
if (factory == null) { |
||||
factory = new DefaultPresentationModelFactory(); |
||||
request.setAttribute(PRESENTATION_MODEL_FACTORY_ATTRIBUTE, factory); |
||||
} |
||||
return factory; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
/* |
||||
* Copyright 2004-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.web.context.request; |
||||
|
||||
import java.util.Iterator; |
||||
|
||||
import org.springframework.core.collection.StringKeyedMapAdapter; |
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* Map backed by a Web request parameter map for accessing request parameters. |
||||
* Also provides support for multi-part requests, providing transparent access to the request "fileMap" as a request parameter entry. |
||||
* @author Keith Donald |
||||
* @since 3.0 |
||||
*/ |
||||
public class NativeWebRequestParameterMap extends StringKeyedMapAdapter<Object> { |
||||
|
||||
/** |
||||
* The wrapped native request. |
||||
*/ |
||||
private NativeWebRequest request; |
||||
|
||||
/** |
||||
* Create a new map wrapping the parameters of given request. |
||||
*/ |
||||
public NativeWebRequestParameterMap(NativeWebRequest request) { |
||||
Assert.notNull(request, "The NativeWebRequest is required"); |
||||
this.request = request; |
||||
} |
||||
|
||||
protected Object getAttribute(String key) { |
||||
/* TODO - MultipartRequest is NOT accessible b/c its in web.servlet |
||||
if (request instanceof MultipartRequest) { |
||||
MultipartRequest multipartRequest = (MultipartRequest) request; |
||||
Object data = multipartRequest.getFileMap().get(key); |
||||
if (data != null) { |
||||
return data; |
||||
} |
||||
} |
||||
*/ |
||||
String[] parameters = request.getParameterValues(key); |
||||
if (parameters == null) { |
||||
return null; |
||||
} else if (parameters.length == 1) { |
||||
return parameters[0]; |
||||
} else { |
||||
return parameters; |
||||
} |
||||
} |
||||
|
||||
protected void setAttribute(String key, Object value) { |
||||
throw new UnsupportedOperationException("WebRequest parameter maps are immutable"); |
||||
} |
||||
|
||||
protected void removeAttribute(String key) { |
||||
throw new UnsupportedOperationException("WebRequest parameter maps are immutable"); |
||||
} |
||||
|
||||
protected Iterator<String> getAttributeNames() { |
||||
return request.getParameterNames(); |
||||
/* TODO - MultipartRequest is NOT accessible b/c its in web.servlet |
||||
if (request instanceof MultipartRequest) { |
||||
MultipartRequest multipartRequest = (MultipartRequest) request; |
||||
CompositeIterator iterator = new CompositeIterator(); |
||||
iterator.add(multipartRequest.getFileMap().keySet().iterator()); |
||||
iterator.add(CollectionUtils.toIterator(request.getParameterNames())); |
||||
return iterator; |
||||
} else { |
||||
return CollectionUtils.toIterator(request.getParameterNames()); |
||||
} |
||||
*/ |
||||
} |
||||
} |
||||
Loading…
Reference in new issue