IN PROGRESS - issue SWF-720: Multiple checkboxes to Collection mapping

http://jira.springframework.org/browse/SWF-720
This commit is contained in:
Keith Donald
2008-06-30 21:22:38 +00:00
parent 4ef2afcd91
commit 9238ff8503
3 changed files with 47 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2004-2008 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.binding.convert.converters;
import java.util.Locale;
import org.springframework.util.StringUtils;
/**
* Converts a String to a Locale using {@link StringUtils#parseLocaleString(String)}.
*
* @author Keith Donald
*/
public class StringToLocale extends StringToObject {
public StringToLocale() {
super(Locale.class);
}
public Object toObject(String string, Class objectClass) throws Exception {
return StringUtils.parseLocaleString(string);
}
public String toString(Object object) throws Exception {
Locale locale = (Locale) object;
return locale.toString();
}
}

View File

@@ -31,6 +31,7 @@ import org.springframework.binding.convert.converters.StringToDouble;
import org.springframework.binding.convert.converters.StringToFloat;
import org.springframework.binding.convert.converters.StringToInteger;
import org.springframework.binding.convert.converters.StringToLabeledEnum;
import org.springframework.binding.convert.converters.StringToLocale;
import org.springframework.binding.convert.converters.StringToLong;
import org.springframework.binding.convert.converters.StringToShort;
import org.springframework.core.enums.LabeledEnum;
@@ -72,6 +73,7 @@ public class DefaultConversionService extends GenericConversionService {
addConverter(new StringToBigDecimal());
addConverter(new StringToClass());
addConverter(new StringToLabeledEnum());
addConverter(new StringToLocale());
addConverter(new StringToDate());
}