Package org.springframework.data.simpledb.core.entity

Source Code of org.springframework.data.simpledb.core.entity.SimpleFieldWrapper

package org.springframework.data.simpledb.core.entity;

import org.springframework.data.mapping.model.MappingException;
import org.springframework.data.simpledb.attributeutil.SimpleDBAttributeConverter;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.text.ParseException;

public class SimpleFieldWrapper<T, ID extends Serializable> extends AbstractSimpleFieldWrapper<T, ID> {

  public SimpleFieldWrapper(Field field, EntityWrapper<T, ID> parent, final boolean isNewParent) {
    super(field, parent, isNewParent);
  }

  @Override
  public String serializeValue() {
    return SimpleDBAttributeConverter.encode(this.getFieldValue());
  }

  @Override
  public Object deserializeValue(String value) {
    try {
      return SimpleDBAttributeConverter.decodeToFieldOfType(value, getField().getType());
    } catch(IllegalArgumentException e) {
      throw new MappingException("Could not map attributes", e);
    } catch(ParseException e) {
      throw new MappingException("Could not map attributes", e);
    }
  }

}
TOP

Related Classes of org.springframework.data.simpledb.core.entity.SimpleFieldWrapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.