Package siena.core

Examples of siena.core.DecimalPrecision


            // can't save it now as it requires its parent key to be mapped
            // so don't do anything for the time being
            continue;
          }*/
          else if (fieldClass == BigDecimal.class){
            DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
            if(ann == null) {
              value = ((BigDecimal)value).toPlainString();
            }else {
              switch(ann.storageType()){
              case DOUBLE:
                value = ((BigDecimal)value).doubleValue();
                break;
              case STRING:
              case NATIVE:
View Full Code Here


            }
          }
        }
      }
      else if(f.getType() == BigDecimal.class){
        DecimalPrecision ann = f.getAnnotation(DecimalPrecision.class);
        if(ann == null) {
          value = new BigDecimal((String)value);
        }else {
          switch(ann.storageType()){
          case DOUBLE:
            value = BigDecimal.valueOf((Double)value);
            break;
          case STRING:
          case NATIVE:
View Full Code Here

            continue;
          }
         
        }
        else if (fieldClass == BigDecimal.class){
          DecimalPrecision ann = f.getAnnotation(DecimalPrecision.class);
          if(ann == null) {
            propValue = ((BigDecimal)propValue).toPlainString();
          }else {
            switch(ann.storageType()){
            case DOUBLE:
              propValue = ((BigDecimal)propValue).doubleValue();
              break;
            case STRING:
            case NATIVE:
View Full Code Here

          return null;
        }
       
      }
      else if (type == BigDecimal.class){
        DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
        if(ann == null) {
          return ((BigDecimal)val).toPlainString();
        }else {
          switch(ann.storageType()){
          case DOUBLE:
            return ((Double)((BigDecimal)val).doubleValue()).toString();
          case STRING:
          case NATIVE:
            return ((BigDecimal)val).toPlainString();
View Full Code Here

      }
      else if (ClassInfo.isEmbeddedNative(field)) {
        return;
      }
      else if (fieldClass == BigDecimal.class){
        DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
        if(ann == null) {
          Util.setField(obj, field, new BigDecimal((String)val));
          return;
        }else {
          switch(ann.storageType()){
          case DOUBLE:
            // TODO add bigdecimal double lexicographic storage
            Util.setField(obj, field, new BigDecimal(val));
            return;
          case STRING:
View Full Code Here

          }
          else if(Enum.class.isAssignableFrom(type)){
            value = value.toString();
          }
          else if(BigDecimal.class == type){
            DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
            if(ann == null) {
              value = (BigDecimal)value;
            }else {
              switch(ann.storageType()){
              case DOUBLE:
                value = ((BigDecimal)value).doubleValue();
                break;
              case STRING:
                value = ((BigDecimal)value).toPlainString();
View Full Code Here

      Max max = field.getAnnotation(Max.class);
      if(max == null)
        column.setSize(""+255); // fixes by default to this value in order to prevent alter tables every time
      else column.setSize(""+max.value());
    } else if(type == BigDecimal.class){           
      DecimalPrecision an = field.getAnnotation(DecimalPrecision.class);
      if(an == null) {
        columnType = Types.DECIMAL;
        column.setSizeAndScale(19, 2);
      }
      else {
        if(an.storageType() == DecimalPrecision.StorageType.NATIVE){
          columnType = Types.DECIMAL;
          column.setSizeAndScale(an.size(), an.scale());
        }else if(an.storageType() == DecimalPrecision.StorageType.STRING) {
          columnType = Types.VARCHAR;
          // should be an.size+"."+sign
          column.setSize((an.size()+2)+"");
        }else if(an.storageType() == DecimalPrecision.StorageType.DOUBLE) {
          columnType = Types.DOUBLE;         
        }else {
          columnType = Types.DECIMAL;
          column.setSizeAndScale(19, 2);
        }
View Full Code Here

    } else if(type == byte[].class){
      return Types.BLOB;
    } else if(Enum.class.isAssignableFrom(type)){
      return Types.VARCHAR;
    } else if(type == BigDecimal.class){           
      DecimalPrecision an = field.getAnnotation(DecimalPrecision.class);
      if(an == null) {
        return Types.DECIMAL;
      }
      else {
        if(an.storageType() == DecimalPrecision.StorageType.NATIVE){
          return Types.DECIMAL;
        }else if(an.storageType() == DecimalPrecision.StorageType.STRING) {
          return Types.VARCHAR;
        }else if(an.storageType() == DecimalPrecision.StorageType.DOUBLE) {
          return Types.DOUBLE;         
        }else {
          return Types.DECIMAL;
        }
      }
View Full Code Here

      ByteArrayInputStream bis = new ByteArrayInputStream((byte[])value);
      ps.setBlob(index, bis);
    } else if(Enum.class.isAssignableFrom(type)){
      ps.setString(index, (String)value);
    } else if(type == BigDecimal.class){           
      DecimalPrecision an = field.getAnnotation(DecimalPrecision.class);
      if(an == null) {
        ps.setObject(index, value);
      }
      else {
        if(an.storageType() == DecimalPrecision.StorageType.NATIVE){
          ps.setBigDecimal(index, (BigDecimal)value);
        }else if(an.storageType() == DecimalPrecision.StorageType.STRING) {
          ps.setString(index, ((BigDecimal)value).toPlainString());
        }else if(an.storageType() == DecimalPrecision.StorageType.DOUBLE) {
          ps.setDouble(index, ((BigDecimal)value).doubleValue());
        }else {
          ps.setBigDecimal(index, (BigDecimal)value);
        }
      }
View Full Code Here

          }
          else if(Enum.class.isAssignableFrom(type)){
            value = value.toString();
          }
          else if(BigDecimal.class == type){
            DecimalPrecision ann = field.getAnnotation(DecimalPrecision.class);
            if(ann == null) {
              value = (BigDecimal)value;
            }else {
              switch(ann.storageType()){
              case DOUBLE:
                value = ((BigDecimal)value).doubleValue();
                break;
              case STRING:
                value = ((BigDecimal)value).toPlainString();
View Full Code Here

TOP

Related Classes of siena.core.DecimalPrecision

Copyright © 2018 www.massapicom. 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.