Examples of ExcelManipulateException


Examples of loxia.support.excel.exception.ExcelManipulateException

    result.add(getMessage(READ_STATUS_PREFIX + "." + readStatus.getStatus(), locale, null));
    if(readStatus.getStatus() != ReadStatus.STATUS_SUCCESS){
      if(readStatus.getStatus() == ReadStatus.STATUS_DATA_COLLECTION_ERROR){
        for(Exception e : readStatus.getExceptions()){
          if(e instanceof ExcelManipulateException){
            ExcelManipulateException eme = (ExcelManipulateException)e;
            result.add(getMessage(EXCEL_EXCEPTION_PREFIX + "." + eme.getErrorCode(),
                locale, eme.getArgs()));
          }
        }
      }else
        result.add(readStatus.getMessage());
    }
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

    throws ExcelManipulateException{
    DataConvertor<?> dc = DataConvertorConfigurator.getInstance().getConvertor(clazz);
    //primitive type should be mandatory
    if(clazz.isPrimitive()) cellDefinition.setMandatory(true);
    if(dc == null){
      throw new ExcelManipulateException(ErrorCode.UNSUPPORTING_DATA_TYPE,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    }
    return dc.convert(value, sheetNo, cellIndex, cellDefinition);
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

public class BigDecimalConvertor implements DataConvertor<BigDecimal> {

  public BigDecimal convert(Object value, int sheetNo, String cellIndex,
      ExcelCell cellDefinition) throws ExcelManipulateException {
    if(value == null && cellDefinition.isMandatory())
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    if(value == null) return null;
    if(value instanceof String){
      String str = (String) value;
      str = str.trim();
      if(str.length() == 0){
        if(cellDefinition.isMandatory())
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
              new Object[]{sheetNo + 1, cellIndex,
              null,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        else
          return null;
      }else{
        try {
          return new BigDecimal((String)value);
        } catch (NumberFormatException e) {
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
              new Object[]{sheetNo + 1, cellIndex,
              value,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        }
      }
    }else if(value instanceof Double){
      return new BigDecimal((Double)value);
    }else
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
          new Object[]{sheetNo + 1, cellIndex,
          value,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
  }
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

public class IntegerConvertor extends ChoiceConvertor<Integer> {

  @Override
  protected Integer convertValue(Object value, int sheetNo, String cellIndex, ExcelCell cellDefinition) throws ExcelManipulateException {
    if(value == null && cellDefinition.isMandatory())
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    if(value == null) return null;
    if(value instanceof String){
      String str = (String) value;
      str = str.trim();
      if(str.length() == 0){
        if(cellDefinition.isMandatory())
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
              new Object[]{sheetNo + 1, cellIndex,
              null,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        else
          return null;
      }else{
        try {
          Integer v = Integer.parseInt((String)value);
          return v;
        } catch (NumberFormatException e) {
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
              new Object[]{sheetNo + 1, cellIndex,
              value,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        }
      }
    }else if(value instanceof Double){
      return (int)Math.rint((Double)value);
    }else
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
          new Object[]{sheetNo + 1, cellIndex,
          value,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
  }
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

public class DoubleConvertor implements DataConvertor<Double> {

  public Double convert(Object value, int sheetNo, String cellIndex,
      ExcelCell cellDefinition) throws ExcelManipulateException {
    if(value == null && cellDefinition.isMandatory())
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    if(value == null) return null;
    if(value instanceof String){
      String str = (String) value;
      str = str.trim();
      if(str.length() == 0){
        if(cellDefinition.isMandatory())
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
              new Object[]{sheetNo + 1, cellIndex,
              null,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        else
          return null;
      }else{
        try {
          return new Double((String)value);
        } catch (NumberFormatException e) {
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
              new Object[]{sheetNo + 1, cellIndex,
              value,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        }
      }
    }else if(value instanceof Double){
      return (Double)value;
    }else
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
          new Object[]{sheetNo + 1, cellIndex,
          value,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
  }
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

  protected String convertValue(Object value, int sheetNo, String cellIndex,
      ExcelCell cellDefinition) throws ExcelManipulateException {
    String str = (value == null ? null : value.toString());
    if(str != null && str.length() == 0) str = null;
    if(str == null && cellDefinition.isMandatory())
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    //remove .0 for Integer Data
    if(value instanceof Double
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

  @Override
  protected Long convertValue(Object value, int sheetNo, String cellIndex,
      ExcelCell cellDefinition) throws ExcelManipulateException {
    if(value == null && cellDefinition.isMandatory())
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    if(value == null) return null;
    if(value instanceof String){
      String str = (String) value;
      str = str.trim();
      if(str.length() == 0){
        if(cellDefinition.isMandatory())
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
              new Object[]{sheetNo + 1, cellIndex,
              null,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        else
          return null;
      }else{
        try {
          Long v = Long.parseLong((String)value);
          return v;
        } catch (NumberFormatException e) {
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
              new Object[]{sheetNo + 1, cellIndex,
              value,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        }
      }
    }else if(value instanceof Double){
      return Math.round((Double)value);
    }else
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_NUMBER,
          new Object[]{sheetNo + 1, cellIndex,
          value,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
  }
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

  }

  public Date convert(Object value, int sheetNo, String cellIndex,
      ExcelCell cellDefinition) throws ExcelManipulateException {
    if(value == null && cellDefinition.isMandatory())
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
          new Object[]{sheetNo + 1, cellIndex,
          null,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
    if(value == null) return null;
    if(value instanceof String){
      String str = (String) value;
      if(str.length() == 0){
        if(cellDefinition.isMandatory())
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_NULL,
              new Object[]{sheetNo + 1, cellIndex,
              null,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        else
          return null;
      }else{
        String pattern = cellDefinition.getPattern() == null ?
            datePattern : cellDefinition.getPattern();
        try {
          DateFormat df = new SimpleDateFormat(pattern);
          return df.parse((String)value);
        } catch (ParseException e) {
          throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_DATE,
              new Object[]{sheetNo + 1, cellIndex,
              value,cellDefinition.getPattern(),
              cellDefinition.getChoiceString()});
        }
      }
    }else if(value instanceof Date){
      return (Date)value;
    }else if(value instanceof Double){
      return DateUtil.getJavaDate((Double)value);
    }else
      throw new ExcelManipulateException(ErrorCode.WRONG_DATA_TYPE_DATE,
          new Object[]{sheetNo + 1, cellIndex,
          value,cellDefinition.getPattern(),
          cellDefinition.getChoiceString()});
  }
View Full Code Here

Examples of loxia.support.excel.exception.ExcelManipulateException

  public T convert(Object value, int sheetNo, String cellIndex, ExcelCell cellDefinition) throws ExcelManipulateException {
    T convertedValue = convertValue(value, sheetNo, cellIndex, cellDefinition);
    List<? extends T> choices = getChoices(cellDefinition);
    if(convertedValue == null || choices == null || choices.contains(convertedValue))
      return convertedValue;
    throw new ExcelManipulateException(ErrorCode.OUT_OF_CHOICES,
        new Object[]{sheetNo + 1, cellIndex,
        convertedValue,cellDefinition.getPattern(),
        cellDefinition.getChoiceString()});
  }
View Full Code Here
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.