Skip to content

Commit

Permalink
SWS-361
Browse files Browse the repository at this point in the history
  • Loading branch information
poutsma committed Jun 13, 2008
1 parent db7558a commit 7759a6b
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,38 @@ else if (entry.getKey() instanceof Class && entry.getValue() instanceof String)
}
}

/**
* Adds an implicit Collection for the given type.
*
* @see XStream#addImplicitCollection(Class, String)
*/
public void addImplicitCollection(String name, Class type) {
getXStream().addImplicitCollection(type, name);
}

/**
* Set a implicit colletion/type map, consisting of string implicit collection mapped to <code>Class</code>
* instances (or Strings to be converted to <code>Class</code> instances).
*
* @see org.springframework.beans.propertyeditors.ClassEditor
*/
public void setImplicitCollection(Map implicitCollection) {
for (Iterator iterator = implicitCollection.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
// Check whether we need to convert from String to Class.
Class type;
if (entry.getValue() instanceof Class) {
type = (Class) entry.getValue();
}
else {
ClassEditor editor = new ClassEditor();
editor.setAsText(String.valueOf(entry.getValue()));
type = (Class) editor.getValue();
}
addImplicitCollection((String) entry.getKey(), type);
}
}

public boolean supports(Class clazz) {
if (ObjectUtils.isEmpty(supportedClasses)) {
return true;
Expand Down

0 comments on commit 7759a6b

Please sign in to comment.