public function getFullClassPaths($className) { $classPaths = array(); if (($pos = strpos($className, INNER_PHP_CLASS_SEPARATOR)) !== false) { if (GWTPHPContext::getInstance()->getGwtCompatibilityVersion() < GWTPHPContext::GWT_VERSION_1_5_0) { $className = substr($className, 0, $pos); } else { // since 1.5 $className = JavaSignatureUtil::innecJavaClassNameToPHPClassName($className); } } $classNameToPath = str_replace('.', DIRECTORY_SEPARATOR, $className) . parent::getFilePostfix(); foreach (parent::getClassPaths() as $rootPath) { $classPaths[] = $rootPath . DIRECTORY_SEPARATOR . $classNameToPath; } // $r = parent::getRootPath().'/'; // $d = str_replace('.', DIRECTORY_SEPARATOR ,$className); // $p = parent::getFilePostfix(); // $cmd = $r.$d.$p; return $classPaths; //return $this->rootPath.str_replace('.', DIRECTORY_SEPARATOR ,$className).parent::getFilePostfix(); }
/** * Enter description here... * * @param string $className * @return SimpleMappedClass */ public function getNative($className) { if (JavaSignatureUtil::isNative($className)) { $class = new SimpleMappedClass(); $class->setClassLoader($this->getClassLoader()); $class->setSignature($className); $class->setMappedName($className); $class->setCRC(JavaSignatureUtil::getSerializationSignatureForNative($className)); return $class; } else { return null; } }
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(true); $_class->setSignature($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); } } } }
/** * Returns a string that encodes the object. It is an error to try to encode * an object that is not assignable to the service method's return type. * * <p> * If the serializationPolicy parameter is not <code>null</code>, it is * used to determine what types can be encoded as part of this response. If * this parameter is <code>null</code>, then only subtypes of * {@link com.google.gwt.user.client.rpc.IsSerializable IsSerializable} or * types which have custom field serializers may be encoded. * </p> * * @param ReflectionMethod $serviceMethod the method whose result we are encoding * @param Object $object the instance that we wish to encode * @param SerializationPolicy $serializationPolicy determines the serialization policy to be used * @return String a string that encodes the object, if the object is compatible with * the service method's declared return type * * @throws IllegalArgumentException if the result is not assignable to the * service method's return type * @throws NullPointerException if the serviceMethod or the * serializationPolicy are <code>null</code> * @throws SerializationException if the result cannot be serialized */ public static function encodeResponseForSuccess(MappedMethod $serviceMethod, $object, SerializationPolicy $serializationPolicy, MappedClassLoader $mappedClassLoader) { if ($serviceMethod === null) { throw new NullPointerException("serviceMethod cannot be null"); } if ($serializationPolicy === null) { throw new NullPointerException("serializationPolicy"); } /*MappedClass*/ $methodReturnType = $serviceMethod->getReturnType(); if ($methodReturnType != '' && $object !== null) { $actualReturnType; if ($methodReturnType->isPrimitive()) { //$actualReturnType = RPC::getPrimitiveClassFromWrapper(object.getClass()); } else { //actualReturnType = object.getClass(); } // if (actualReturnType == null // || !methodReturnType.isAssignableFrom(actualReturnType)) { // throw new IllegalArgumentException("Type '" // + printTypeName(object.getClass()) // + "' does not match the return type in the method's signature: '" // + getSourceRepresentation(serviceMethod) + "'"); // } } // TODO: fix this mess if ($methodReturnType !== null && ($methodReturnType->isPrimitive() || $methodReturnType->isArray() || JavaSignatureUtil::isVoid($methodReturnType->getSignature()))) { } else { if (is_object($object)) { //echo "<br>\n : ".print_r($object,true); //echo "<br>\n : ".print_r($methodReturnType,true); //echo "<br>\n <hr>"; $_methodReturnType = $mappedClassLoader->findMappedClassByObject($object); if ($_methodReturnType != null) { $methodReturnType = $_methodReturnType; } } } return RPC::encodeResponse($methodReturnType, $object, false, $serializationPolicy); }
/** * * * @param string $signature * @throws SignatureParseException * @return string */ public static function getSignatureForGenericType($signature) { $lPos = strpos($signature, '<'); $rPos = strrpos($signature, '>'); if ($lPos === false || $rPos === false || !JavaSignatureUtil::isGeneric($signature)) { require_once GWTPHP_DIR . '/maps/java/lang/SignatureParseException.class.php'; throw new SignatureParseException("Not an generic signature: " . $signature); } //$genericTypeSignature = substr ( $signature, 0, $lPos ).substr ( $signature, $rPos+1, strlen($signature) ); return substr($signature, 0, $lPos) . substr($signature, $rPos + 1, strlen($signature)); //$second = $signature[1] ; //if ($signature[1] == TypeSignatures::$OBJECT) // [Ljava.lang.String; // return substr($signature,-strlen($signature)+2,strlen($signature)-3); //else // return substr($signature,-strlen($signature)+1); }
/** * * @return string * */ public function getName() { if ($this->isPrimitive()) { return JavaSignatureUtil::signatureToName($this->getSignature()); } return $this->getSignature(); //return $this->getPHPClass()->getName(); }
/** * Enter description here... * * @param string $className * @return SimpleMappedClass */ private function getNative($className) { if (JavaSignatureUtil::isNative($className)) { $class = new SimpleMappedClass(); $class->setClassLoader($this->getClassLoader()); $class->setSignature($className); return $class; } else { return null; } }