/**
  * 
  * @param string $className - signature
  * @param boolean $cachable - to cache or not to cache (sometimes we do not cache generic classes)
  * @return MappedClass
  * @throws ClassNotFoundException
  * @throws ClassMapNotFoundException
  */
 public function loadMappedClass($className, $cachable = true)
 {
     $_class = $this->getCachedMappedClass($className);
     if ($cachable && $_class != null) {
         return $_class;
     }
     if (JavaSignatureUtil::isPrimitive($className) || JavaSignatureUtil::isArray($className) || JavaSignatureUtil::isVoid($className)) {
         $_class = $this->forSignature($className);
         $cachable && $this->addMappedClassToCache($className, $_class);
     } else {
         if (JavaSignatureUtil::isGeneric($className)) {
             $_type = JavaSignatureUtil::getSignatureForGenericType($className);
             $_pTypes = JavaSignatureUtil::getSignaturesForGenericTypeParameters($className);
             $_class = $this->loadMappedClass($_type, false);
             $_class->setGeneric(true);
             $_pClasses = array();
             foreach ($_pTypes as $_pType) {
                 $_pClasses[] = $this->loadMappedClass($_pType);
             }
             $_class->setTypeParameters($_pClasses);
             $cachable && $this->addMappedClassToCache($className, $_class);
         } else {
             if (($_class = $this->getNative($className)) !== null) {
                 //ok class found -> go on...
                 $cachable && $this->addMappedClassToCache($className, $_class);
             } else {
                 if (($_class = $this->findMappedClass($className, $cachable)) == null) {
                     class_exists('ClassMapNotFoundException') || (require GWTPHP_DIR . '/exceptions/ClassMapNotFoundException.class.php');
                     throw new ClassMapNotFoundException("Class map not found for class name: " . $className);
                 }
             }
         }
     }
     return $_class;
 }
 /**
  * 
  * @param string $className - signature
  * @param boolean $cachable - to cache or not to cache
  * @return MappedClass
  * @throws ClassNotFoundException
  * @throws ClassMapNotFoundException
  */
 public function loadMappedClass($className, $cachable = true)
 {
     $_class = $this->getCachedMappedClass($className);
     if ($cachable && $_class != null) {
         return $_class;
     }
     if (JavaSignatureUtil::isPrimitive($className) || JavaSignatureUtil::isArray($className) || JavaSignatureUtil::isVoid($className)) {
         $_class = $this->forSignature($className);
     } else {
         if (JavaSignatureUtil::isGeneric($className)) {
             $_type = JavaSignatureUtil::getSignatureForGenericType($className);
             $_pTypes = JavaSignatureUtil::getSignaturesForGenericTypeParameters($className);
             $_class = $this->loadMappedClass($_type, false);
             $_class->setGeneric(true);
             $_pClasses = array();
             foreach ($_pTypes as $_pType) {
                 $_pClasses[] = $this->loadMappedClass($_pType);
             }
             $_class->setTypeParameters($_pClasses);
         } else {
             if (($_class = $this->getNative($className)) !== null) {
                 //ok class found -> go on...
                 //return $_class;
             } else {
                 if (($_class = $this->findMappedClass($className)) == null) {
                     //$phpClass = $this->classLoader->loadClass($_class->getMappedBy());
                     //} else {
                     require_once GWTPHP_DIR . '/maps/java/lang/ClassMapNotFoundException.class.php';
                     throw new ClassMapNotFoundException($className);
                     //$phpClass = $this->classLoader->loadClass($className);
                     //$_class = new SimpleMappedClass();
                 }
                 //$_class->setSignature($className);
                 //$_class->setPHPClass($phpClass);
             }
         }
     }
     //$this->cachedClasses[$_class->getSignature()] = $_class;
     //$this->addMappedClassToCache($_class->getSignature(),$_class);
     $cachable && $this->addMappedClassToCache($className, $_class);
     //$this->addMappedClassToCache($className,$_class);
     //$this->cachedClasses[$className] = $_class;
     return $_class;
 }
예제 #3
0
 /**	 
  * 
  * @param string $crc
  * @return void
  * @throws CRCParseException
  */
 public function setCRC($crc, $parse = false)
 {
     if ($parse && $this->isArray()) {
         $pos = strpos($crc, '[');
         if ($pos === false) {
             class_exists('CRCParseException') || (require GWTPHP_DIR . '/exceptions/CRCParseException.class.php');
             throw new CRCParseException('\'[\' not found in:' . $crc);
         }
         //echo $pos;
         //echo "<br>\n";
         $this->crc = substr($crc, 0, $pos);
         if ($this->getComponentType()->isPrimitive() && !$this->getComponentType()->isArray()) {
             return;
         }
         //$baseCrc = substr($crc,0,$pos);
         //echo $baseCrc;
         //echo "<br>\n";
         $nextCRC = substr($crc, -strlen($crc) + $pos + 1);
         if ($nextCRC[0] == '[' && $this->getComponentType()->isArray()) {
             $this->getComponentType()->setCRC($nextCRC, true);
         } else {
             if ($nextCRC[0] == 'L' && !$this->getComponentType()->isPrimitive()) {
                 $this->getComponentType()->setCRC(substr($nextCRC, 1, strlen($nextCRC) - 2), true);
             } else {
                 if (($this->getComponentType()->isArray() || $this->getComponentType()->isArray()) && $nextCRC[0] != '[' && $nextCRC[0] != 'L') {
                     $this->getComponentType()->setCRC($nextCRC, true);
                 } else {
                     class_exists('CRCParseException') || (require GWTPHP_DIR . '/exceptions/CRCParseException.class.php');
                     throw new CRCParseException($crc);
                 }
             }
         }
         //echo $nextCRC;
         //echo "<br>\n";
     } else {
         try {
             if ($this->isGeneric()) {
                 $this->crc = JavaSignatureUtil::getSignatureForGenericType($crc);
                 $crcParams = JavaSignatureUtil::getSignaturesForGenericTypeParameters($crc);
                 $params = $this->getTypeParameters();
                 $crcParamsCount = count($crcParams);
                 $paramsCount = count($params);
                 if ($crcParamsCount != $paramsCount) {
                     class_exists('CRCParseException') || (require GWTPHP_DIR . '/exceptions/CRCParseException.class.php');
                     throw new CRCParseException("Parsing generic CRC error: (probably not equal count of typeParameters: {$paramsCount} and count of typeCRC: {$crcParamsCount}) CRC: " . $crc);
                 }
                 for ($i = 0; $i < $paramsCount; ++$i) {
                     $params[$i]->setCRC($crcParams[$i]);
                 }
             } else {
                 $this->crc = $crc;
             }
         } catch (SignatureParseException $ex) {
             class_exists('CRCParseException') || (require GWTPHP_DIR . '/exceptions/CRCParseException.class.php');
             throw new CRCParseException('Parsing generic CRC error: (probably not equal count of \'< and \'> ' . $crc);
         }
     }
 }
 /**
  * 
  *
  * @param string $signature
  * @return SimpleMappedClass
  * @throws SignatureParseException
  */
 private function forSignature($signature)
 {
     if (JavaSignatureUtil::isVoid($signature)) {
         $_class = new SimpleMappedClass();
         $_class->setPrimitive(false);
         $_class->setSignature($signature);
         return $_class;
     } else {
         if (JavaSignatureUtil::isPrimitive($signature)) {
             $_class = new SimpleMappedClass();
             $_class->setPrimitive(true);
             $_class->setSignature($signature);
             return $_class;
         } else {
             if (JavaSignatureUtil::isArray($signature)) {
                 $_class = new SimpleMappedClass();
                 $_class->setPrimitive(false);
                 $_class->setSignature(JavaSignatureUtil::isGeneric($signature) ? JavaSignatureUtil::getSignatureForGenericType($signature) : $signature);
                 $_class->setArray(true);
                 $_class->setComponentType($this->loadMappedClass(JavaSignatureUtil::getSignatureForComponentTypeOfArray($signature)));
                 return $_class;
             } else {
                 require_once GWTPHP_DIR . '/maps/java/lang/SignatureParseException.class.php';
                 throw new SignatureParseException("Signature for not primitive or array type: " . $signature);
             }
         }
     }
 }