Package railo.runtime.exp

Examples of railo.runtime.exp.CasterException


        else if(o instanceof Number) return toBooleanValue(((Number)o).doubleValue());
        else if(o instanceof String) return toBooleanValue((String)o);
        else if(o instanceof Castable) return ((Castable)o).castToBooleanValue();
        else if(o == null) return toBooleanValue("");
        else if(o instanceof ObjectWrap) return toBooleanValue(((ObjectWrap)o).getEmbededObject());
        throw new CasterException(o,"boolean");
    }
View Full Code Here


     * @throws PageException
     */
    public static boolean toBooleanValue(String str) throws PageException {
      Boolean b = toBoolean(str,null);
      if(b!=null) return b.booleanValue();
      throw new CasterException("Can't cast String ["+str+"] to a boolean");
    }
View Full Code Here

        else if(o instanceof String) return toDoubleValue(o.toString(),true);
        //else if(o instanceof Clob) return toDoubleValue(toString(o));
        else if(o instanceof Castable) return ((Castable)o).castToDoubleValue();
        else if(o == null) return 0;//toDoubleValue("");
        else if(o instanceof ObjectWrap) return toDoubleValue(((ObjectWrap)o).getEmbededObject());
        throw new CasterException(o,"number");
    }
View Full Code Here

        double deep=1;
        int pos=0;
        int len=str.length();
       
       
        if(len==0) throw new CasterException("can't cast empty string to a number value");
        char curr=str.charAt(pos);
        boolean isMinus=false;
       
        if(curr=='+') {
            if(len==++pos) throw new CasterException("can't cast [+] string to a number value");         
        }
        if(curr=='-') {
            if(len==++pos) throw new CasterException("can't cast [-] string to a number value")
            isMinus=true;
        }
        boolean hasDot=false;
        //boolean hasExp=false;
        do {
            curr=str.charAt(pos);
            if(curr<'0') {
                if(curr=='.') {
                    if(hasDot) {
                      if(!alsoFromDate) throw new CasterException("cannot cast ["+str+"] string to a number value")
                      return toDoubleValueViaDate(str);
                    }
                    hasDot=true;
                }
                else {
                    if(pos==0 && Decision.isBoolean(str)) return toBooleanValue(str,false)?1.0D:0.0D;
                    if(!alsoFromDate) throw new CasterException("cannot cast ["+str+"] string to a number value")
                  return toDoubleValueViaDate(str);
                    //throw new CasterException("can't cast ["+str+"] string to a number value");
                }
            }
            else if(curr>'9') {
                if(curr == 'e' || curr == 'E') {
                  try{
                    return Double.parseDouble(str);
                  }
                  catch( NumberFormatException e){
                    if(!alsoFromDate) throw new CasterException("cannot cast ["+str+"] string to a number value")
                      return toDoubleValueViaDate(str);
                    //throw new CasterException("can't cast ["+str+"] string to a number value");
                  }
                }
                //else {
                    if(pos==0 && Decision.isBoolean(str)) return toBooleanValue(str,false)?1.0D:0.0D;
                    if(!alsoFromDate) throw new CasterException("cannot cast ["+str+"] string to a number value")
                  return toDoubleValueViaDate(str);
                    //throw new CasterException("can't cast ["+str+"] string to a number value");
                //}
            }
            else if(!hasDot) {
View Full Code Here

        return rtn_;
    }
   
    private static double toDoubleValueViaDate(String str) throws CasterException {
    DateTime date = DateCaster.toDateSimple(str, false,false, null, null);// not advanced here, neo also only support simple
    if(date==null)throw new CasterException("can't cast ["+str+"] string to a number value");
      return date.castToDoubleValue(0);
  }
View Full Code Here

        if(o instanceof String)
            throw new ExpressionException("Can't cast String ["+o.toString()+"] to a number");
        else if(o instanceof ObjectWrap) return toIntValue(((ObjectWrap)o).getEmbededObject());
   
       
        throw new CasterException(o,"number");
    }
View Full Code Here

        }
        else if(o instanceof ObjectWrap) {
            return toCharValue(((ObjectWrap)o).getEmbededObject());
        }                                                                                                                                                                              
        else if(o == null) return toCharValue("");
        throw new CasterException(o,"char");
    }
View Full Code Here

        else if(o instanceof Number) return (((Number)o).byteValue());
        else if(o instanceof String) return (byte)toDoubleValue(o.toString());     
        else if(o instanceof ObjectWrap) {
            return toByteValue(((ObjectWrap)o).getEmbededObject());
        }
        throw new CasterException(o,"byte");
    }
View Full Code Here

          }                                                                                                                                                    
        }
        else if(o instanceof Castable) return (long)((Castable)o).castToDoubleValue();   
        else if(o instanceof ObjectWrap) return toLongValue(((ObjectWrap)o).getEmbededObject());
   
        throw new CasterException(o,"long");
    }
View Full Code Here

        else if(o instanceof Number) return (((Number)o).floatValue());
        else if(o instanceof String) return (float)toDoubleValue(o.toString());                                                                                                                                                     
        else if(o instanceof Castable) return (float)((Castable)o).castToDoubleValue();   
        else if(o instanceof ObjectWrap) return toFloatValue(((ObjectWrap)o).getEmbededObject());
   
        throw new CasterException(o,"float");
    }
View Full Code Here

TOP

Related Classes of railo.runtime.exp.CasterException

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.