/**
  * Processes cell value
  *
  * @param   var in
  * @return  var
  * @throws  lang.FormatException
  */
 public function process($in)
 {
     try {
         return $this->proceed(Enum::valueOf($this->enum, $in));
     } catch (IllegalArgumentException $e) {
         throw new FormatException($e->getMessage());
     }
 }
 public function staticMemberNotWithEnumValueOf()
 {
     Enum::valueOf(XPClass::forName('net.xp_framework.unittest.core.Profiling'), 'fixture');
 }
 /**
  * Return a field type
  *
  * @return  unittest.web.Fields
  */
 public static function forTag($type)
 {
     return parent::valueOf(XPClass::forName('unittest.web.Fields'), strtoupper($type));
 }
 /**
  * Retrieve serialized representation of a variable
  *
  * @param   remote.protocol.SerializedData serialized
  * @param   array context default array()
  * @return  var
  * @throws  lang.ClassNotFoundException if a class cannot be found
  * @throws  lang.FormatException if an error is encountered in the format 
  */
 public function valueOf($serialized, $context = array())
 {
     static $types = NULL;
     if (!$types) {
         $types = array('N' => 'void', 'b' => 'boolean', 'i' => 'integer', 'd' => 'double', 's' => 'string', 'B' => new ClassReference('lang.types.Byte'), 'S' => new ClassReference('lang.types.Short'), 'f' => new ClassReference('lang.types.Float'), 'l' => new ClassReference('lang.types.Long'), 'a' => 'array', 'A' => new ClassReference('lang.types.ArrayList'), 'T' => new ClassReference('util.Date'));
     }
     $token = $serialized->consumeToken();
     switch ($token) {
         case 'N':
             return NULL;
         case 'b':
             return (bool) $serialized->consumeWord();
         case 'i':
             return (int) $serialized->consumeWord();
         case 'd':
             return (double) $serialized->consumeWord();
         case 's':
             return $serialized->consumeString();
         case 'a':
             // arrays
             $a = array();
             $size = $serialized->consumeSize();
             $serialized->consume('{');
             for ($i = 0; $i < $size; $i++) {
                 $key = $this->valueOf($serialized, $context);
                 $a[$key] = $this->valueOf($serialized, $context);
             }
             $serialized->consume('}');
             return $a;
         case 'E':
             // generic exceptions
             $instance = new ExceptionReference($serialized->consumeString());
             $size = $serialized->consumeSize();
             $serialized->consume('{');
             for ($i = 0; $i < $size; $i++) {
                 $member = $this->valueOf($serialized, $context);
                 $instance->{$member} = $this->valueOf($serialized, $context);
             }
             $serialized->consume('}');
             return $instance;
         case 'O':
             // generic objects
             $name = $serialized->consumeString();
             $members = array();
             try {
                 $class = XPClass::forName(strtr($name, $this->packages[0]));
             } catch (ClassNotFoundException $e) {
                 $instance = new UnknownRemoteObject($name);
                 $size = $serialized->consumeSize();
                 $serialized->consume('{');
                 for ($i = 0; $i < $size; $i++) {
                     $member = $this->valueOf($serialized, $context);
                     $members[$member] = $this->valueOf($serialized, $context);
                 }
                 $serialized->consume('}');
                 $instance->__members = $members;
                 return $instance;
             }
             $size = $serialized->consumeSize();
             $serialized->consume('{');
             if ($class->isEnum()) {
                 if ($size != 1 || 'name' != $this->valueOf($serialized, $context)) {
                     throw new FormatException(sprintf('Local class %s is an enum but remote class is not serialized as one (%s)', $name, $serialized->toString()));
                 }
                 $instance = Enum::valueOf($class, $this->valueOf($serialized, $context));
             } else {
                 $instance = $class->newInstance();
                 for ($i = 0; $i < $size; $i++) {
                     $member = $this->valueOf($serialized, $context);
                     $instance->{$member} = $this->valueOf($serialized, $context);
                 }
             }
             $serialized->consume('}');
             return $instance;
         case 'c':
             // builtin classes
             $type = $serialized->consumeWord();
             if (!isset($types[$type])) {
                 throw new FormatException('Unknown type token "' . $type . '"');
             }
             return $types[$type];
         case 'C':
             // generic classes
             return new ClassReference(strtr($serialized->consumeString(), $this->packages[0]));
         default:
             // default, check if we have a mapping
             if (!($mapping = $this->mapping($token, $m = NULL))) {
                 throw new FormatException('Cannot deserialize unknown type "' . $token . '" (' . $serialized->toString() . ')');
             }
             return $mapping->valueOf($this, $serialized, $context);
     }
 }
 public function enum_valueOf_nonexistant()
 {
     Enum::valueOf($this->enumClass(), 'does-not-exist');
 }
 /**
  * Gets the currency instance for a given currency code
  *
  * @param   string code ISO 4217 code
  * @return  util.Currency
  * @throws  lang.IllegalArgumentException
  */
 public static function getInstance($code)
 {
     return Enum::valueOf(XPClass::forName(xp::nameOf(__CLASS__)), $code);
 }
 public function diff($type, $strdate1, $strdate2)
 {
     return DateMath::diff(Enum::valueOf(XPClass::forName('util.TimeInterval'), strtoupper($type)), new Date($strdate1), new Date($strdate2));
 }