View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.spring.convert;
17  
18  import java.io.File;
19  
20  import org.kohsuke.MetaInfServices;
21  import org.kuali.common.util.spring.convert.support.PropertiesToXmlStringConverter;
22  import org.kuali.common.util.spring.convert.support.XmlStringToPropertiesConverter;
23  import org.kuali.common.util.spring.format.BytesFormatFactory;
24  import org.kuali.common.util.spring.format.CanonicalFileFormatter;
25  import org.kuali.common.util.spring.format.FileListFormatFactory;
26  import org.kuali.common.util.spring.format.PathListFormatFactory;
27  import org.kuali.common.util.spring.format.TimeFormatFactory;
28  import org.kuali.common.util.spring.format.XmlPropertiesFormatFactory;
29  import org.kuali.common.util.spring.format.optional.OptionalStringFormatFactory;
30  import org.kuali.common.util.spring.format.optional.OptionalTimeZoneFormatFactory;
31  import org.springframework.core.convert.ConversionService;
32  import org.springframework.format.support.DefaultFormattingConversionService;
33  
34  @MetaInfServices(ConversionService.class)
35  public class DefaultConversionService extends DefaultFormattingConversionService {
36  
37  	public DefaultConversionService() {
38  		addFormatterForFieldAnnotation(new BytesFormatFactory());
39  		addFormatterForFieldAnnotation(new TimeFormatFactory());
40  		addFormatterForFieldAnnotation(new OptionalStringFormatFactory());
41  		addFormatterForFieldAnnotation(new OptionalTimeZoneFormatFactory());
42  		addFormatterForFieldAnnotation(new FileListFormatFactory());
43  		addFormatterForFieldAnnotation(new PathListFormatFactory());
44  		addFormatterForFieldAnnotation(new XmlPropertiesFormatFactory());
45  		addFormatterForFieldType(File.class, new CanonicalFileFormatter());
46  		addConverter(new XmlStringToPropertiesConverter());
47  		addConverter(new PropertiesToXmlStringConverter());
48  	}
49  
50  }