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 ByteObjectMarshal extends Marshal 38 { 39 public static final Marshal MARSHAL = new ByteObjectMarshal(); 40 41 public Object marshal(Env env, Expr expr, Class expectedClass) 42 { 43 return new Byte ((byte) expr.evalLong(env)); 44 } 45 46 public boolean isReadOnly() 47 { 48 return true; 49 } 50 51 @Override  52 public Object marshal(Env env, Value value, Class expectedClass) 53 { 54 return value.toJavaByte(); 55 } 56 57 public Value unmarshal(Env env, Object value) 58 { 59 if (value == null) 60 return LongValue.ZERO; 61 else 62 return new LongValue(((Number ) value).longValue()); 63 } 64 } 65 | Popular Tags |