Changeset 498
- Timestamp:
- 04/13/07 16:21:22 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/stubSerializedObject.php
r407 r498 22 22 * @var string 23 23 */ 24 protected $className; 24 protected $fqClassName; 25 /** 26 * non qualified class name 27 * 28 * @var string 29 */ 30 protected $nqClassName; 25 31 /** 26 32 * the instance of the serialized class … … 49 55 public function __construct(stubObject $object) 50 56 { 51 $this->className = $object->getClassName(); 57 $this->fqClassName = $object->getClassName(); 58 if (null != $this->fqClassName) { 59 $this->nqClassName = stubClassLoader::getNonQualifiedClassName($this->fqClassName); 60 } else { 61 $this->nqClassName = get_class($object); 62 } 63 52 64 $this->classInstance = $object; 53 65 $this->hashCode = $object->hashCode(); … … 62 74 { 63 75 $this->data = serialize($this->classInstance); 64 return array(' className', 'hashCode', 'data');76 return array('fqClassName', 'nqClassName', 'hashCode', 'data'); 65 77 } 66 78 … … 78 90 } 79 91 80 $nqClassName = stubClassLoader::getNonQualifiedClassName($this->className); 81 if (class_exists($nqClassName, false) == false) { 82 stubClassLoader::load($this->className); 92 if (class_exists($this->nqClassName, false) == false) { 93 stubClassLoader::load($this->fqClassName); 83 94 } 84 95 … … 94 105 public function getSerializedClassName() 95 106 { 96 return $this-> className;107 return $this->fqClassName; 97 108 } 98 109 … … 117 128 public function getClassName() 118 129 { 119 return stubClassLoader::getFullQualifiedClassName( get_class($this));130 return stubClassLoader::getFullQualifiedClassName(__CLASS__); 120 131 } 121 132 … … 155 166 { 156 167 // do not throw a stubException to prevent cirular references 157 throw new Exception('Can not serialize a serialized ' . $this->getClassName() . ' representation of ' . $this-> className);168 throw new Exception('Can not serialize a serialized ' . $this->getClassName() . ' representation of ' . $this->fqClassName); 158 169 } 159 170 … … 177 188 { 178 189 $string = $this->getClassName() . " {\n"; 179 $string .= ' class(string): ' . $this->className . "\n"; 190 $string .= ' fqClassName(string): ' . $this->fqClassName . "\n"; 191 $string .= ' nqClassName(string): ' . $this->nqClassName . "\n"; 180 192 $string .= ' data(string): ' . serialize($this->classInstance) . "\n"; 181 193 $string .= "}\n"; trunk/src/test/php/net/stubbles/stubSerializedObjectTestCase.php
r407 r498 116 116 public function testToString() 117 117 { 118 $this->assertEqual((string) $this->serializedObject, "net.stubbles.stubSerializedObject {\n class(string): test.stub3stubBaseObject\n data(string): " . serialize($this->stubBaseObject) . "\n}\n");118 $this->assertEqual((string) $this->serializedObject, "net.stubbles.stubSerializedObject {\n fqClassName(string): test.stub3stubBaseObject\n nqClassName(string): stub3stubBaseObject\n data(string): " . serialize($this->stubBaseObject) . "\n}\n"); 119 119 } 120 120
