Changeset 135

Show
Ignore:
Timestamp:
01/21/07 17:40:17 (2 years ago)
Author:
schst
Message:

Do not try to export private properties or methods or the cosntructor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/xml/serializer/stubXMLSerializer.php

    r97 r135  
    22/** 
    33 * XMLSerializer main class 
    4  *  
     4 * 
    55 * @author      Stephan Schmidt <schst@stubbles.net> 
    66 * @package     stubbles 
     
    1414/** 
    1515 * XMLSerializer main class 
    16  *  
     16 * 
    1717 * @package     stubbles 
    1818 * @subpackage  xml_serializer 
     
    3030                      self::OPT_ROOT_TAG    => null, 
    3131                    ); 
    32                      
     32 
    3333    /** 
    3434     * Currently used options 
     
    3737     */ 
    3838    private $opts; 
    39      
     39 
    4040    /** 
    4141     * Serialize any data structure to XML 
     
    4949        // set the currently used options 
    5050        $this->opts = array_merge($this->defaultOpts, $opts); 
    51          
     51 
    5252        $this->serializeDispatcher($data, $xmlWriter, $this->opts[self::OPT_ROOT_TAG]); 
    5353    } 
     
    107107    protected function serializeObject($object, stubXMLStreamWriter $xmlWriter, $tagName) { 
    108108        $clazz = new stubReflectionClass(get_class($object)); 
    109          
     109 
    110110        if ($tagName === null) { 
    111111            if ($clazz->hasAnnotation('XMLTag')) { 
     
    116116            } 
    117117        } 
    118          
     118 
    119119        $xmlWriter->writeStartElement($tagName); 
    120120 
     
    122122        $properties = $clazz->getProperties(); 
    123123        foreach ($properties as $property) { 
     124            if (!$property->isPublic()) { 
     125                continue; 
     126            } 
    124127            if ($property->hasAnnotation('XMLIgnore')) { 
    125128                continue; 
     
    133136            if ($property->hasAnnotation('XMLTag')) { 
    134137                $xmlTag = $property->getAnnotation('XMLTag'); 
    135                  
     138 
    136139                if (is_array($propValue)) { 
    137140                    $this->serializeArray($propValue, $xmlWriter, $xmlTag->getTagName(), $xmlTag->getElementTagName()); 
    138141                } else { 
    139                     $this->serializeDispatcher($propValue, $xmlWriter, $xmlTag->getTagName());                  
     142                    $this->serializeDispatcher($propValue, $xmlWriter, $xmlTag->getTagName()); 
    140143                } 
    141144                continue; 
     
    146149        $methods = $clazz->getMethods(); 
    147150        foreach ($methods as $method) { 
     151            if (!$method->isPublic()) { 
     152                continue; 
     153            } 
     154            if ($method->isConstructor()) { 
     155                continue; 
     156            } 
    148157            if ($method->hasAnnotation('XMLIgnore')) { 
    149158                continue; 
     
    157166            if ($method->hasAnnotation('XMLTag')) { 
    158167                $xmlTag = $method->getAnnotation('XMLTag'); 
    159                  
     168 
    160169                if (is_array($returnValue)) { 
    161170                    $this->serializeArray($returnValue, $xmlWriter, $xmlTag->getTagName(), $xmlTag->getElementTagName()); 
    162171                } else { 
    163                     $this->serializeDispatcher($returnValue, $xmlWriter, $xmlTag->getTagName());                    
     172                    $this->serializeDispatcher($returnValue, $xmlWriter, $xmlTag->getTagName()); 
    164173                } 
    165174                continue; 
     
    168177        $xmlWriter->writeEndElement(); 
    169178    } 
    170      
     179 
    171180    /** 
    172181     * Serialize an array