Ejemplo n.º 1
0
 DataValue(String str, Integer n, Double bd, String dateStr, Boolean b) {
   this.str = str;
   this.l = (n == null) ? null : Long.valueOf(n);
   this.bd = (bd == null) ? null : BigDecimal.valueOf(bd);
   this.d = WebUtils.parseDate(dateStr);
   this.b = b;
 }
Ejemplo n.º 2
0
 public static final Object getDominantSortAttributeValueFromString(
     String v, DataField dominantAttr) {
   Object value;
   switch (dominantAttr.getDataType()) {
     case BINARY:
       throw new IllegalStateException("cannot sort on a binary field");
     case LONG_STRING:
       throw new IllegalStateException("cannot sort on a long text field");
     case URI:
     case STRING:
       {
         value = v;
         break;
       }
     case INTEGER:
       {
         if (v == null) {
           value = null;
         } else {
           value = Long.valueOf(v);
         }
         break;
       }
     case DECIMAL:
       {
         if (v == null) {
           value = null;
         } else {
           BigDecimal bd = new BigDecimal(v);
           value = bd.setScale(dominantAttr.getNumericScale(), BigDecimal.ROUND_HALF_UP);
         }
         break;
       }
     case BOOLEAN:
       {
         if (v == null) {
           value = null;
         } else {
           value = WebUtils.parseBoolean(v);
         }
         break;
       }
     case DATETIME:
       {
         if (v == null) {
           value = null;
         } else {
           value = WebUtils.parseDate(v);
         }
         break;
       }
     default:
       throw new IllegalStateException("datatype not handled");
   }
   return value;
 }