Changeset 135
- Timestamp:
- 01/21/07 17:40:17 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/serializer/stubXMLSerializer.php
r97 r135 2 2 /** 3 3 * XMLSerializer main class 4 * 4 * 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles … … 14 14 /** 15 15 * XMLSerializer main class 16 * 16 * 17 17 * @package stubbles 18 18 * @subpackage xml_serializer … … 30 30 self::OPT_ROOT_TAG => null, 31 31 ); 32 32 33 33 /** 34 34 * Currently used options … … 37 37 */ 38 38 private $opts; 39 39 40 40 /** 41 41 * Serialize any data structure to XML … … 49 49 // set the currently used options 50 50 $this->opts = array_merge($this->defaultOpts, $opts); 51 51 52 52 $this->serializeDispatcher($data, $xmlWriter, $this->opts[self::OPT_ROOT_TAG]); 53 53 } … … 107 107 protected function serializeObject($object, stubXMLStreamWriter $xmlWriter, $tagName) { 108 108 $clazz = new stubReflectionClass(get_class($object)); 109 109 110 110 if ($tagName === null) { 111 111 if ($clazz->hasAnnotation('XMLTag')) { … … 116 116 } 117 117 } 118 118 119 119 $xmlWriter->writeStartElement($tagName); 120 120 … … 122 122 $properties = $clazz->getProperties(); 123 123 foreach ($properties as $property) { 124 if (!$property->isPublic()) { 125 continue; 126 } 124 127 if ($property->hasAnnotation('XMLIgnore')) { 125 128 continue; … … 133 136 if ($property->hasAnnotation('XMLTag')) { 134 137 $xmlTag = $property->getAnnotation('XMLTag'); 135 138 136 139 if (is_array($propValue)) { 137 140 $this->serializeArray($propValue, $xmlWriter, $xmlTag->getTagName(), $xmlTag->getElementTagName()); 138 141 } else { 139 $this->serializeDispatcher($propValue, $xmlWriter, $xmlTag->getTagName()); 142 $this->serializeDispatcher($propValue, $xmlWriter, $xmlTag->getTagName()); 140 143 } 141 144 continue; … … 146 149 $methods = $clazz->getMethods(); 147 150 foreach ($methods as $method) { 151 if (!$method->isPublic()) { 152 continue; 153 } 154 if ($method->isConstructor()) { 155 continue; 156 } 148 157 if ($method->hasAnnotation('XMLIgnore')) { 149 158 continue; … … 157 166 if ($method->hasAnnotation('XMLTag')) { 158 167 $xmlTag = $method->getAnnotation('XMLTag'); 159 168 160 169 if (is_array($returnValue)) { 161 170 $this->serializeArray($returnValue, $xmlWriter, $xmlTag->getTagName(), $xmlTag->getElementTagName()); 162 171 } else { 163 $this->serializeDispatcher($returnValue, $xmlWriter, $xmlTag->getTagName()); 172 $this->serializeDispatcher($returnValue, $xmlWriter, $xmlTag->getTagName()); 164 173 } 165 174 continue; … … 168 177 $xmlWriter->writeEndElement(); 169 178 } 170 179 171 180 /** 172 181 * Serialize an array
