Show
Ignore:
Timestamp:
11/11/07 21:43:04 (1 year ago)
Author:
mikey
Message:

whitespace fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/XJConf/DefinedTag.php

    r117 r121  
    77 */ 
    88namespace net::xjconf; 
    9 use net::xjconf::Tag; 
    109use net::xjconf::definitions::Definition; 
    1110use net::xjconf::definitions::ConcreteTagDefinition; 
     
    1817class DefinedTag implements Tag 
    1918{ 
    20  
    21         /** 
    22          * name of the tag 
    23          * 
    24          * @var  string 
    25          */ 
    26         private $name = null; 
    27  
    28         /** 
    29          * character data 
    30          * 
    31          * @var  string 
    32          */ 
    33         private $data = null; 
    34  
    35         /** 
    36          * content of the tag 
    37          * 
    38          * @var  mixed 
    39          */ 
    40         private $content = null; 
    41  
    42         /** 
    43          * attributes of the tag 
    44          * 
    45          * @var  array 
    46          */ 
    47         private $atts = array(); 
    48  
    49         /** 
    50          * Children of the tag 
    51          * 
    52          * @var  array 
    53          */ 
    54         private $children = array(); 
    55  
    56         /** 
    57          * value of the tag 
    58          * 
    59          * @var  TagDefinition 
    60          */ 
    61         private $tagDef = null; 
    62  
    63         /** 
    64          * Create a new tag without attributes 
    65          * 
    66          * @param name   name of the tag 
    67          */ 
    68         public function __construct($name, $atts = array()) 
    69         { 
    70                 $this->name = $name; 
    71                 $this->atts = $atts; 
    72         } 
    73  
    74         /** 
    75          * Get the name of the tag 
    76          * 
    77          * @return   name of the tag 
    78          */ 
    79         public function getName() 
    80         { 
    81                 return $this->name; 
    82         } 
    83  
    84         /** 
    85          * Set the key 
    86          * 
    87          * @param  string  $key 
    88          */ 
    89         public function setKey($key) 
    90         { 
    91                 $this->key = $key; 
    92         } 
    93  
    94         /** 
    95          * Get the key under which the value will be stored 
    96          * 
    97          * @return  string 
    98          */ 
    99         public function getKey() 
    100         { 
    101                 return $this->tagDef->getKey($this); 
    102         } 
    103  
    104         /** 
    105          * Add text data 
    106          * 
    107          * @param   string  $buf 
    108          * @return  int     new length of data 
    109          */ 
    110         public function addData($buf) 
    111         { 
    112                 $this->data .= $buf; 
    113                 return strlen($this->data); 
    114         } 
    115  
    116         /** 
    117          * Get the character data of the tag 
    118          * 
    119          * @return   character data 
    120          */ 
    121         public function getData() 
    122         { 
    123                 return $this->data; 
    124         } 
    125  
    126         /** 
    127          * Check, whether the tag has a certain attribute 
    128          * 
    129          * @param   string   $name 
    130          * @return  boolean 
    131          */ 
    132         public function hasAttribute($name) 
    133         { 
    134                 return isset($this->atts[$name]); 
    135         } 
    136  
    137         /** 
    138          * get an attribute 
    139          * 
    140          * @param   string  $name  name of the attribute 
    141          * @return  string  value of the attribute 
    142          */ 
    143         public function getAttribute($name) 
    144         { 
    145                 if ($this->hasAttribute($name) == true) { 
    146                     return $this->atts[$name]; 
    147                 } 
    148  
    149                 return null; 
    150         } 
    151  
    152         /** 
    153          * get all attributes 
    154          * 
    155          * @return  array 
    156          */ 
    157         public function getAttributes() 
    158         { 
    159                 return $this->atts; 
    160         } 
    161  
    162         /** 
     19    /** 
     20     * name of the tag 
     21     * 
     22     * @var  string 
     23     */ 
     24    private $name     = null; 
     25    /** 
     26     * character data 
     27     * 
     28     * @var  string 
     29     */ 
     30    private $data     = null; 
     31    /** 
     32     * content of the tag 
     33     * 
     34     * @var  mixed 
     35     */ 
     36    private $content  = null; 
     37    /** 
     38     * attributes of the tag 
     39     * 
     40     * @var  array 
     41     */ 
     42    private $atts     = array(); 
     43    /** 
     44     * Children of the tag 
     45     * 
     46     * @var  array 
     47     */ 
     48    private $children = array(); 
     49    /** 
     50     * value of the tag 
     51     * 
     52     * @var  TagDefinition 
     53     */ 
     54    private $tagDef   = null; 
     55 
     56    /** 
     57     * Create a new tag without attributes 
     58     * 
     59     * @param name   name of the tag 
     60     */ 
     61    public function __construct($name, $atts = array()) 
     62    { 
     63        $this->name = $name; 
     64        $this->atts = $atts; 
     65    } 
     66 
     67    /** 
     68     * Get the name of the tag 
     69     * 
     70     * @return   name of the tag 
     71     */ 
     72    public function getName() 
     73    { 
     74        return $this->name; 
     75    } 
     76 
     77    /** 
     78     * Set the key 
     79     * 
     80     * @param  string  $key 
     81     */ 
     82    public function setKey($key) 
     83    { 
     84        $this->key = $key; 
     85    } 
     86 
     87    /** 
     88     * Get the key under which the value will be stored 
     89     * 
     90     * @return  string 
     91     */ 
     92    public function getKey() 
     93    { 
     94        return $this->tagDef->getKey($this); 
     95    } 
     96 
     97    /** 
     98     * Add text data 
     99     * 
     100     * @param   string  $buf 
     101     * @return  int     new length of data 
     102     */ 
     103    public function addData($buf) 
     104    { 
     105        $this->data .= $buf; 
     106        return strlen($this->data); 
     107    } 
     108 
     109    /** 
     110     * Get the character data of the tag 
     111     * 
     112     * @return   character data 
     113     */ 
     114    public function getData() 
     115    { 
     116        return $this->data; 
     117    } 
     118 
     119    /** 
     120     * Check, whether the tag has a certain attribute 
     121     * 
     122     * @param   string   $name 
     123     * @return  boolean 
     124     */ 
     125    public function hasAttribute($name) 
     126    { 
     127        return isset($this->atts[$name]); 
     128    } 
     129 
     130    /** 
     131     * get an attribute 
     132     * 
     133     * @param   string  $name  name of the attribute 
     134     * @return  string  value of the attribute 
     135     */ 
     136    public function getAttribute($name) 
     137    { 
     138        if ($this->hasAttribute($name) === true) { 
     139            return $this->atts[$name]; 
     140        } 
     141 
     142        return null; 
     143    } 
     144 
     145    /** 
     146     * get all attributes 
     147     * 
     148     * @return  array 
     149     */ 
     150    public function getAttributes() 
     151    { 
     152        return $this->atts; 
     153    } 
     154 
     155    /** 
    163156     * Add a new child to this tag. 
    164157     * 
     
    168161    public function addChild(Tag $child) 
    169162    { 
    170        array_push($this->children, $child); 
     163        array_push($this->children, $child); 
    171164        return count($this->children); 
    172165    } 
    173166 
    174        /** 
    175         * Get the child with a specific name 
    176        
    177         * @param   string  $name 
    178         * @return  Tag 
    179         */ 
    180        public function getChild($name) 
    181        
    182            foreach ($this->children as $child) { 
    183                    if ($child->getName() == $name) { 
    184                                return $child; 
    185                        
    186                
    187  
    188                return null; 
    189        
    190  
    191        /** 
    192         * Get all children of the tag 
    193        
    194         * @return  array 
    195         */ 
    196        public function getChildren() 
    197        
    198                return $this->children; 
    199        
    200  
    201        /** 
     167    /** 
     168    * Get the child with a specific name 
     169   
     170    * @param   string  $name 
     171    * @return  Tag 
     172    */ 
     173    public function getChild($name) 
     174   
     175        foreach ($this->children as $child) { 
     176            if ($child->getName() === $name) { 
     177                return $child; 
     178           
     179       
     180 
     181        return null; 
     182   
     183 
     184    /** 
     185    * Get all children of the tag 
     186   
     187    * @return  array 
     188    */ 
     189    public function getChildren() 
     190   
     191        return $this->children; 
     192   
     193 
     194    /** 
    202195     * Set the content (overrides the character data) 
    203196     * 
    204197     * @param  mixed  $content 
    205198     */ 
    206        public function setContent($content) 
    207        
    208                $this->content = $content; 
    209        
    210  
    211        /** 
    212         * Get the content 
    213        
    214         * @return  mixed 
    215         */ 
    216        public function getContent() 
    217        
    218                if (null != $this->content) { 
    219                        return $this->content; 
    220                
    221  
    222                return $this->getData(); 
    223        
    224  
    225        /** 
    226         * Fetch the value 
    227        
    228         * @return      mixed  the value of the tag 
    229         */ 
    230        public function getConvertedValue() 
    231        
    232                return $this->tagDef->convertValue($this); 
    233        
    234  
    235        /** 
    236         * Get the type of the value 
    237        
    238         * @param   Tag     $tag 
    239         * @return  string 
    240         */ 
    241        public function getValueType(Tag $tag) 
    242        
    243                return $this->tagDef->getValueType($tag); 
    244        
    245  
    246        /** 
    247         * Get the setter method 
    248        
    249         * @return  string 
    250         */ 
     199    public function setContent($content) 
     200   
     201        $this->content = $content; 
     202   
     203 
     204    /** 
     205    * Get the content 
     206   
     207    * @return  mixed 
     208    */ 
     209    public function getContent() 
     210   
     211        if (null != $this->content) { 
     212            return $this->content; 
     213       
     214 
     215        return $this->getData(); 
     216   
     217 
     218    /** 
     219    * Fetch the value 
     220   
     221     * @return    mixed  the value of the tag 
     222    */ 
     223    public function getConvertedValue() 
     224   
     225        return $this->tagDef->convertValue($this); 
     226   
     227 
     228    /** 
     229    * Get the type of the value 
     230   
     231    * @param   Tag     $tag 
     232    * @return  string 
     233    */ 
     234    public function getValueType(Tag $tag) 
     235   
     236        return $this->tagDef->getValueType($tag); 
     237   
     238 
     239    /** 
     240    * Get the setter method 
     241   
     242    * @return  string 
     243    */ 
    251244    public function getSetterMethod() 
    252245    { 
    253        return $this->tagDef->getSetterMethod($this); 
    254     } 
    255  
    256        /** 
    257         * Checks, whether the tag supports indexed children 
    258        
    259         * @return  boolean 
    260         */ 
    261        public function supportsIndexedChildren() 
    262        
    263                return $this->tagDef->supportsIndexedChildren(); 
    264        
    265  
    266        /** 
     246        return $this->tagDef->getSetterMethod($this); 
     247    } 
     248 
     249    /** 
     250    * Checks, whether the tag supports indexed children 
     251   
     252    * @return  boolean 
     253    */ 
     254    public function supportsIndexedChildren() 
     255   
     256        return $this->tagDef->supportsIndexedChildren(); 
     257   
     258 
     259    /** 
    267260    * Set the tag definition object used for this tag 
    268261    * 
     
    272265    { 
    273266        if ($tagDef instanceof ConcreteTagDefinition) { 
    274                $this->tagDef = $tagDef; 
     267            $this->tagDef = $tagDef; 
    275268            return; 
    276269        }