Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * 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;
Converts objects from one type to another. May support conversion of multiple source types to multiple target types.

Implementations of this interface are thread-safe and can be shared.

A converter is more generic than a formatter. A formatter only handles converting from String and back, while converters convert from an arbitrary Object type to another.

Author(s):
Keith Donald
See also:
org.springframework.binding.format.Formatter
public interface Converter {

The source classes this converter can convert from.

Returns:
the supported source classes
	public Class[] getSourceClasses();

The target classes this converter can convert to.

Returns:
the supported target classes
	public Class[] getTargetClasses();

Convert the provided source object argument to an instance of the specified target class.

Parameters:
source the source object to convert, its class must be one of the supported sourceClasses
targetClass the target class to convert the source to, it must be one of the supported targetClasses
context an optional conversion context that may be used to influence the conversion process
Returns:
the converted object, an instance of the target type
Throws:
ConversionException an exception occurred during the type conversion
	public Object convert(Object sourceClass targetClassObject contextthrows ConversionException;
New to GrepCode? Check out our FAQ X