1 29 30 package com.caucho.quercus.function; 31 32 import com.caucho.quercus.env.Env; 33 import com.caucho.quercus.env.LongValue; 34 import com.caucho.quercus.env.Value; 35 import com.caucho.quercus.expr.Expr; 36 37 public class IntegerObjectMarshal extends Marshal 38 { 39 public static final Marshal MARSHAL = new IntegerObjectMarshal(); 40 41 public boolean isReadOnly() 42 { 43 return true; 44 } 45 46 public Object marshal(Env env, Expr expr, Class expectedClass) 47 { 48 return new Integer ((int) expr.evalLong(env)); 49 } 50 51 public Object marshal(Env env, Value value, Class expectedClass) 52 { 53 return value.toJavaInteger(); 54 } 55 56 public Value unmarshal(Env env, Object value) 57 { 58 if (value == null) 59 return LongValue.ZERO; 60 else 61 return new LongValue(((Number ) value).longValue()); 62 } 63 } 64 | Popular Tags |