Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* 
  * Copyright (C) 2012 FoxLabs
  * 
  * 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.foxlabs.validation.converter;
This class provides Converter implementation for the java.lang.Character type.

Author(s):
Fox Mulder
public final class CharacterConverter extends AbstractConverter<Character> {
    
    
CharacterConverter primitive type instance.
    public static final CharacterConverter SIMPLE = new CharacterConverter(.);
    
    
CharacterConverter object type instance.
    public static final CharacterConverter OBJECT = new CharacterConverter(Character.class);
    
    
Character type (can be either primitive or object type).
    private final Class<Charactertype;
    
    
Constructs default CharacterConverter.

Parameters:
type Character type.
Throws:
java.lang.IllegalArgumentException if the specified type is null.
    private CharacterConverter(Class<Charactertype) {
        this. = Assert.notNull(type"type");
    }
    
    
Returns java.lang.Character type.

Returns:
java.lang.Character type.
    @Override
    public Class<CharactergetType() {
        return ;
    }
    
    
Converts string representation of character value into java.lang.Character object.

Parameters:
value String representation of character value.
Returns:
Decoded java.lang.Character object.
Throws:
MalformedValueException if the specified string could not be parsed as a character.
    @Override
    protected <T> Character doDecode(String valueValidationContext<T> context) {
        if (value.length() == 1)
            return value.charAt(0);
        throw new MalformedValueException(thiscontextvalue);
    }
    
New to GrepCode? Check out our FAQ X