public static function init() { self::$classCRC32Cache = new IdentityHashMap(); self::$CLASS_TO_SERIALIZER_INSTANCE = new IdentityHashMap(); self::$NO_SUCH_SERIALIZER = new SerializabilityUtilEx_NoSuchSerializer(); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES = new HashMap(); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES = new HashSet(); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Boolean::typeClass()->getFullName(), "Z"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Byte::typeClass()->getFullName(), "B"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Character::typeClass()->getFullName(), "C"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Double::typeClass()->getFullName(), "D"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Float::typeClass()->getFullName(), "F"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Integer::typeClass()->getFullName(), "I"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Long::typeClass()->getFullName(), "J"); self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Short::typeClass()->getFullName(), "S"); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Boolean::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Byte::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Character::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Double::clazz()); //TODO Exception class //self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Exception::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Float::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Integer::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Long::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Object::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Short::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(String::clazz()); self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Classes::classOf('Throwable')); }
public static function init() { self::$TYPE_NAMES[' Z'] = Boolean::typeClass(); self::$TYPE_NAMES[' B'] = Byte::typeClass(); self::$TYPE_NAMES[' C'] = Character::typeClass(); self::$TYPE_NAMES[' D'] = Double::typeClass(); self::$TYPE_NAMES[' F'] = Float::typeClass(); self::$TYPE_NAMES[' I'] = Integer::typeClass(); self::$TYPE_NAMES[' J'] = Long::typeClass(); self::$TYPE_NAMES[' S'] = Short::typeClass(); }
public static function init() { // Obfuscated self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . BOOLEAN_TYPE] = Boolean::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . BYTE_TYPE] = Byte::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . CHAR_TYPE] = Character::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . DOUBLE_TYPE] = Double::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . FLOAT_TYPE] = Float::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . INT_TYPE] = Integer::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . LONG_TYPE] = Long::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . SHORT_TYPE] = Short::typeClass(); self::$PRIMITIVE_TYPES[self::OBFUSCATED_CLASS_REFIX . VOID_TYPE] = Void::typeClass(); // Regular self::$PRIMITIVE_TYPES[Boolean::typeClass()->getName()] = Boolean::typeClass(); self::$PRIMITIVE_TYPES[Byte::typeClass()->getName()] = Byte::typeClass(); self::$PRIMITIVE_TYPES[Character::typeClass()->getName()] = Character::typeClass(); self::$PRIMITIVE_TYPES[Double::typeClass()->getName()] = Double::typeClass(); self::$PRIMITIVE_TYPES[Float::typeClass()->getName()] = Float::typeClass(); self::$PRIMITIVE_TYPES[Integer::typeClass()->getName()] = Integer::typeClass(); self::$PRIMITIVE_TYPES[Long::typeClass()->getName()] = Long::typeClass(); self::$PRIMITIVE_TYPES[Short::typeClass()->getName()] = Short::typeClass(); self::$PRIMITIVE_TYPES[Void::typeClass()->getName()] = Void::typeClass(); }
public function writeValue(Clazz $clazz, $instance) { if ($clazz === Boolean::typeClass()) { $this->writeObject(new Boolean($instance)); } else { if ($clazz === Byte::typeClass()) { $this->writeObject(new Byte($instance)); } else { if ($clazz === Character::typeClass()) { $this->writeObject(new Character($instance)); } else { if ($clazz === Double::typeClass()) { $this->writeObject(new Double($instance)); } else { if ($clazz === Float::typeClass()) { $this->writeObject(new Float($instance)); } else { if ($clazz === Integer::typeClass()) { $this->writeObject(new Integer($instance)); } else { if ($clazz === Long::typeClass()) { $this->writeObject(new Long($instance)); } else { if ($clazz === Short::typeClass()) { $this->writeObject(new Short($instance)); } else { if ($clazz === String::clazz()) { $this->writeString($instance); } else { if ($clazz->isEnum()) { $this->writeEnum($clazz, $instance); } else { $this->writeObject($instance); } } } } } } } } } } }
public function getTargetType() { return Float::typeClass(); }
private static function printTypeName(Clazz $type) { // Primitives // if ($type === Integer::typeClass()) { return 'int'; } else { if ($type === Long::typeClass()) { return 'long'; } else { if ($type === Short::typeClass()) { return 'short'; } else { if ($type === Byte::typeClass()) { return 'byte'; } else { if ($type === Character::typeClass()) { return 'char'; } else { if ($type === Boolean::typeClass()) { return 'boolean'; } else { if ($type === Float::typeClass()) { return 'float'; } else { if ($type === Double::typeClass()) { return 'double'; } } } } } } } } // Arrays // if ($type->isArray()) { $componentType = $type->getComponentType(); return self::printTypeName($componentType) . '[]'; } // Everything else // return str_replace('$', '.', $type->getName()); }
public static function init() { self::$CLASS_TO_VALUE_READER = new IdentityHashMap(); self::$CLASS_TO_VECTOR_READER = new IdentityHashMap(); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Boolean::typeClass()), new SSSR_VectorReader_Boolean()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Byte::typeClass()), new SSSR_VectorReader_Byte()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Character::typeClass()), new SSSR_VectorReader_Char()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Double::typeClass()), new SSSR_VectorReader_Double()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Float::typeClass()), new SSSR_VectorReader_Float()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Integer::typeClass()), new SSSR_VectorReader_Int()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Long::typeClass()), new SSSR_VectorReader_Long()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Object::clazz()), new SSSR_VectorReader_Object()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Short::typeClass()), new SSSR_VectorReader_Short()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(String::clazz()), new SSSR_VectorReader_String()); self::$CLASS_TO_VALUE_READER->put(Boolean::typeClass(), new SSSR_ValueReader_Boolean()); self::$CLASS_TO_VALUE_READER->put(Byte::typeClass(), new SSSR_ValueReader_Byte()); self::$CLASS_TO_VALUE_READER->put(Character::typeClass(), new SSSR_ValueReader_Char()); self::$CLASS_TO_VALUE_READER->put(Double::typeClass(), new SSSR_ValueReader_Double()); self::$CLASS_TO_VALUE_READER->put(Float::typeClass(), new SSSR_ValueReader_Float()); self::$CLASS_TO_VALUE_READER->put(Integer::typeClass(), new SSSR_ValueReader_Int()); self::$CLASS_TO_VALUE_READER->put(Long::typeClass(), new SSSR_ValueReader_Long()); self::$CLASS_TO_VALUE_READER->put(Object::clazz(), new SSSR_ValueReader_Object()); self::$CLASS_TO_VALUE_READER->put(Short::typeClass(), new SSSR_ValueReader_Short()); self::$CLASS_TO_VALUE_READER->put(String::clazz(), new SSSR_ValueReader_String()); }
public static function jsniName(Clazz $clazz) { if ($clazz->isPrimitive()) { if ($clazz === Boolean::typeClass()) { return 'Z'; } else { if ($clazz === Byte::typeClass()) { return 'B'; } else { if ($clazz === Character::typeClass()) { return 'C'; } else { if ($clazz === Short::typeClass()) { return 'S'; } else { if ($clazz === Integer::typeClass()) { return 'I'; } else { if ($clazz === Long::typeClass()) { return 'J'; } else { if ($clazz === Float::typeClass()) { return 'F'; } else { if ($clazz === Double::typeClass()) { return 'D'; } } } } } } } } throw new RuntimeException('Unhandled primitive tye ' + $clazz->getName()); } else { if ($clazz->isArray()) { return '[' . self::jsniName($clazz->getComponentType()); } else { return 'L' . str_replace('.', '/', $clazz->getFullName()) . ';'; } } }
public static function init() { self::$JS_CHARS_ESCAPED[chr(0)] = '0'; self::$JS_CHARS_ESCAPED[""] = 'b'; self::$JS_CHARS_ESCAPED["\t"] = 't'; self::$JS_CHARS_ESCAPED["\n"] = 'n'; self::$JS_CHARS_ESCAPED["\f"] = 'f'; self::$JS_CHARS_ESCAPED["\r"] = 'r'; self::$JS_CHARS_ESCAPED[self::JS_ESCAPE_CHAR] = self::JS_ESCAPE_CHAR; self::$JS_CHARS_ESCAPED[self::JS_QUOTE_CHAR] = self::JS_QUOTE_CHAR; self::$CLASS_TO_VALUE_WRITER = new IdentityHashMap(); self::$CLASS_TO_VECTOR_WRITER = new IdentityHashMap(); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('boolean[]'), SSSW_VectorWriter::$BOOLEAN_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('byte[]'), SSSW_VectorWriter::$BYTE_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('char[]'), SSSW_VectorWriter::$CHAR_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('double[]'), SSSW_VectorWriter::$DOUBLE_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('float[]'), SSSW_VectorWriter::$FLOAT_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('int[]'), SSSW_VectorWriter::$INT_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('long[]'), SSSW_VectorWriter::$LONG_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('Object[]'), SSSW_VectorWriter::$OBJECT_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('short[]'), SSSW_VectorWriter::$SHORT_VECTOR); self::$CLASS_TO_VECTOR_WRITER->put(Classes::classOf('String[]'), SSSW_VectorWriter::$STRING_VECTOR); self::$CLASS_TO_VALUE_WRITER->put(Boolean::typeClass(), SSSW_ValueWriter::$BOOLEAN); self::$CLASS_TO_VALUE_WRITER->put(Byte::typeClass(), SSSW_ValueWriter::$BYTE); self::$CLASS_TO_VALUE_WRITER->put(Character::typeClass(), SSSW_ValueWriter::$CHAR); self::$CLASS_TO_VALUE_WRITER->put(Double::typeClass(), SSSW_ValueWriter::$DOUBLE); self::$CLASS_TO_VALUE_WRITER->put(Float::typeClass(), SSSW_ValueWriter::$FLOAT); self::$CLASS_TO_VALUE_WRITER->put(Integer::typeClass(), SSSW_ValueWriter::$INT); self::$CLASS_TO_VALUE_WRITER->put(Long::typeClass(), SSSW_ValueWriter::$LONG); self::$CLASS_TO_VALUE_WRITER->put(Object::clazz(), SSSW_ValueWriter::$OBJECT); self::$CLASS_TO_VALUE_WRITER->put(Short::typeClass(), SSSW_ValueWriter::$SHORT); self::$CLASS_TO_VALUE_WRITER->put(String::clazz(), SSSW_ValueWriter::$STRING); }
Classes::register('Byte', new JavaClazz('Byte', $objClass)); Classes::register('Long', new JavaClazz('Long', $objClass)); Classes::register('Short', new JavaClazz('Short', $objClass)); Classes::register('Integer', new JavaClazz('Integer', $objClass)); Classes::register('Character', new JavaClazz('Character', $objClass)); Classes::register('String', new JavaClazz('String', $objClass)); Classes::register('Float', new JavaClazz('Float', $objClass)); Classes::register('Double', new JavaClazz('Double', $objClass)); Classes::register('Void', new JavaClazz('Void', $objClass)); // Aliases Classes::registerAlias('string', String::clazz()); Classes::registerAlias('bool', Boolean::typeClass()); // Signatures Classes::registerSignature(Boolean::SIGNATURE, Boolean::typeClass()); Classes::registerSignature(Byte::SIGNATURE, Byte::typeClass()); Classes::registerSignature(Character::SIGNATURE, Character::typeClass()); Classes::registerSignature(Double::SIGNATURE, Double::typeClass()); Classes::registerSignature(Float::SIGNATURE, Float::typeClass()); Classes::registerSignature(Integer::SIGNATURE, Integer::typeClass()); Classes::registerSignature(Long::SIGNATURE, Long::typeClass()); Classes::registerSignature(Short::SIGNATURE, Short::typeClass()); // Assignable From Long::typeClass()->registerAssignableFrom(array(Double::typeClass(), Integer::typeClass(), Character::typeClass(), Short::typeClass(), Byte::typeClass())); Integer::typeClass()->registerAssignableFrom(array(Character::typeClass(), Short::typeClass(), Byte::typeClass())); Character::typeClass()->registerAssignableFrom(array(Integer::typeClass(), Short::typeClass(), Byte::typeClass())); Short::typeClass()->registerAssignableFrom(array(Integer::typeClass(), Byte::typeClass())); Byte::typeClass()->registerAssignableFrom(array(Integer::typeClass())); Double::typeClass()->registerAssignableFrom(array(Float::typeClass())); Float::typeClass()->registerAssignableFrom(array(Double::typeClass())); Character::typeClass()->registerAssignableFrom(array(String::clazz())); String::clazz()->registerAssignableFrom(array(Character::typeClass()));