simplecharacterconverter.java

来自「pojo的mvc框架」· Java 代码 · 共 43 行

JAVA
43
字号
package xyz.frame.converter.basic;import xyz.frame.LogicRequest;import xyz.frame.converter.ConversionException;import xyz.frame.converter.Converter;/** * Converts to Character. Uses the error key invalid_character if unable to * parse its information. *  * @author Guilherme Silveira */public class SimpleCharacterConverter implements Converter {	/**	 * Converts	 * 	 * @see xyz.frame.converter.Converter#convert(java.lang.String,	 *      java.lang.Class, xyz.frame.scope.LogicRequest)	 */	public Object convert(String value, Class<?> type, LogicRequest context)			throws ConversionException {		if (value == null || value.equals("")) {			return null;		}		if (value.length() != 1) {			throw new ConversionException("invalid_character",					"Content is more than a single character");		}		return Character.valueOf(value.charAt(0));	}	/**	 * Returns the list of supported types	 * 	 * @see xyz.frame.converter.Converter#getSupportedTypes()	 */	public Class<?>[] getSupportedTypes() {		return new Class[] { Character.class };	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?