Changeset 21

Show
Ignore:
Timestamp:
08/28/06 17:45:30 (2 years ago)
Author:
mikey
Message:

- added hasChildDefinition($def)
- added getChildDefinition($def)
- completed doc blocks

Files:

Legend:

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

    r14 r21  
    11<?php 
     2/** 
     3 * Definition container of an attribute. 
     4 * 
     5 * @author  Stephan Schmidt <stephan.schmidt@schlund.de> 
     6 * @author  Frank Kleine <frank.kleine@schlund.de> 
     7 */ 
    28XJConfLoader::load('converters.factories.ValueConverterFactoryChain', 
    39                   'definitions.Definition', 
     
    1723 * - Whether the attribute is required, or not 
    1824 * 
    19  * @author Stephan Schmidt <stephan.schmidt@schlund.de> 
     25 * @package     XJConf 
     26 * @subpackage  definitions 
    2027 */ 
    2128class AttributeDefinition implements Definition 
    2229{ 
    23  
    2430    /** 
    2531     * name of the attribute 
     
    2834     */ 
    2935        private $name         = null; 
    30  
    3136    /** 
    3237     * Type of the attribute 
     
    3540     */ 
    3641        private $type         = null; 
    37  
    3842    /** 
    3943     * Name of the setter method 
     
    4246     */ 
    4347        private $setter       = null; 
    44  
    4548    /** 
    4649     * Default value 
     
    4952     */ 
    5053    private $defaultValue = null; 
    51  
    5254    /** 
    5355     * Whether the attribute is required 
     
    5658     */ 
    5759    private $required     = false; 
    58  
    5960    /** 
    6061     * Converter used to convert the attribute 
     
    8485                } 
    8586        } 
    86  
    87     /** 
    88      * Set the default value for the attribute. 
    89      * 
    90      * @param    defaultValue   default value that will be used, if a tag does not provide the attribute 
    91      * @see      getDefault() 
    92      */ 
    93     public function setDefault($defaultValue) 
    94     { 
    95         $this->defaultValue = $defaultValue; 
    96     } 
    97  
    98     /** 
    99      * Get the default value of the attribute. 
    100      * 
    101      * @return  string 
    102      * @see     setDefault() 
    103      */ 
    104     public function getDefault() 
    105     { 
    106         return $this->defaultValue; 
    107     } 
    108  
    109     /** 
    110      * returns whether the attribute is required or not 
    111      * 
    112      * @return  boolean 
    113      */ 
    114     public function isRequired() 
    115     { 
    116         return $this->required; 
    117     } 
    118     /** 
    119      * set if attribute is required 
    120      * 
    121      * @param  boolean  $required 
    122      */ 
    123     public function setRequired($required) 
    124     { 
    125         $this->required = $required; 
    126     } 
    127  
    128         /** 
    129          * Set the setter method 
    130      * 
    131      * If no setter method is specified, the standard 
    132      * name "setAttributename()" will be used instead. 
    133          * 
    134          * @param  string  $setter  name of the setter method 
    135          * @see    getSetterMethod() 
    136          */ 
    137         public function setSetterMethod($setter) 
    138         { 
    139                 $this->setter = $setter; 
    140         } 
    141  
    142         /** 
    143          * Get the name of the setter method that should be used 
    144      * to set the attribute value in the parent container 
     87         
     88        /** 
     89         * Get the name of the attribute. 
    14590         * 
    14691         * @return  string 
    147      * @see     setSetterMethod() 
    148          */ 
    149         public function getSetterMethod() 
    150         { 
    151                 if (null == $this->setter) { 
    152                         return 'set' . ucfirst($this->name); 
    153                 } 
    154  
    155                 return $this->setter; 
    156         } 
    157  
    158         /** 
    159          * Get the name of the attribute. 
     92         */ 
     93        public function getName() 
     94        { 
     95                return $this->name; 
     96        } 
     97         
     98        /** 
     99         * Get the type of the attribute 
    160100         * 
    161101         * @return  string 
    162102         */ 
    163         public function getName() 
    164         { 
    165                 return $this->name; 
    166         } 
    167  
    168     /** 
    169      * Get the type of the attribute 
    170      * 
    171      * @param   Tag     $tag 
    172      * @return  string 
    173      */ 
    174     public function getValueType(Tag $tag) 
    175     { 
    176         return $this->valueConverter->getType(); 
    177     } 
    178  
    179         /** 
    180          * Get the type of the attribute 
    181          * 
    182          * @return  string 
    183          */ 
    184103        public function getType() 
    185104        { 
    186105                return $this->type; 
    187106        } 
    188  
     107         
    189108        /** 
    190109         * Convert a value to the defined type 
     
    211130        if (null == $value) { 
    212131            if ($this->isRequired() == true) { 
    213                 throw new MissingAttributeException("The attribute '" + this.name + "' is required for the tag '" + tag.getName() + "'."); 
     132                throw new MissingAttributeException('The attribute "' . $this->getName() . '" is required for the tag "' . $tag->getName() . '".'); 
    214133            } 
    215134 
     
    224143                return $instance; 
    225144        } 
    226  
     145         
     146        /** 
     147     * Get the type of the attribute 
     148     * 
     149     * @param   Tag     $tag 
     150     * @return  string 
     151     */ 
     152    public function getValueType(Tag $tag) 
     153    { 
     154        return $this->valueConverter->getType(); 
     155    } 
     156     
     157    /** 
     158         * Set the setter method 
     159     * 
     160     * If no setter method is specified, the standard 
     161     * name "setAttributename()" will be used instead. 
     162         * 
     163         * @param  string  $setter  name of the setter method 
     164         * @see    getSetterMethod() 
     165         */ 
     166        public function setSetterMethod($setter) 
     167        { 
     168                $this->setter = $setter; 
     169        } 
     170 
     171        /** 
     172         * Get the name of the setter method that should be used 
     173     * to set the attribute value in the parent container 
     174         * 
     175         * @return  string 
     176     * @see     setSetterMethod() 
     177         */ 
     178        public function getSetterMethod() 
     179        { 
     180                if (null == $this->setter) { 
     181                        return 'set' . ucfirst($this->getName()); 
     182                } 
     183 
     184                return $this->setter; 
     185        } 
     186     
     187    /** 
     188     * Add a child definition 
     189     * 
     190     * Attributes can not have any children. 
     191     * 
     192     * @param  Definition  $def 
     193     */ 
     194    public function addChildDefinition(Definition $def) 
     195    { 
     196        // attributes can not have any children. 
     197    } 
     198     
     199    /** 
     200     * Checks whether this definition has a specific child condition 
     201     * 
     202     * @param   string   $def 
     203     * @return  boolean  true if definition has a specific child condition, else false 
     204     */ 
     205    public function hasChildDefinition($def) 
     206    { 
     207        return false; 
     208    } 
     209     
     210    /** 
     211     * Returns the first found definition of type $def 
     212     * 
     213     * @param   string   $def 
     214     * @return  Definition 
     215     */ 
     216    public function getChildDefinition($def) 
     217    { 
     218        return null; 
     219    } 
     220 
     221    /** 
     222     * Return all child definitions. 
     223     * 
     224     * Currently, it is not possible to add any child 
     225     * definitions to an attribute 
     226     * 
     227     * @return  array 
     228     */ 
     229    public function getChildDefinitions() { 
     230        return array(); 
     231    } 
     232 
     233    /** 
     234     * Set the default value for the attribute. 
     235     * 
     236     * @param  string  $defaultValue  default value that will be used, if a tag does not provide the attribute 
     237     * @see    getDefault() 
     238     */ 
     239    public function setDefault($defaultValue) 
     240    { 
     241        $this->defaultValue = $defaultValue; 
     242    } 
     243 
     244    /** 
     245     * Get the default value of the attribute. 
     246     * 
     247     * @return  string 
     248     * @see     setDefault() 
     249     */ 
     250    public function getDefault() 
     251    { 
     252        return $this->defaultValue; 
     253    } 
     254 
     255    /** 
     256     * returns whether the attribute is required or not 
     257     * 
     258     * @return  boolean 
     259     */ 
     260    public function isRequired() 
     261    { 
     262        return $this->required; 
     263    } 
     264     
     265    /** 
     266     * set if attribute is required 
     267     * 
     268     * @param  boolean  $required 
     269     */ 
     270    public function setRequired($required) 
     271    { 
     272        $this->required = $required; 
     273    } 
     274     
    227275    /** 
    228276     * Get the value converter for this tag 
     
    232280    private function getValueConverter() 
    233281    { 
    234         if ($this->valueConverter == null) { 
     282        if (null == $this->valueConverter) { 
    235283            $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); 
    236284        } 
     285         
    237286        return $this->valueConverter; 
    238     } 
    239  
    240     /** 
    241      * Add a child definition 
    242      * 
    243      * Attributes can not have any children. 
    244      * 
    245      * @param  Definition  $def 
    246      */ 
    247     public function addChildDefinition(Definition $def) 
    248     { 
    249         // attributes can not have any children. 
    250     } 
    251  
    252     /** 
    253      * Return all child definitions. 
    254      * 
    255      * Currently, it is not possible to add any child 
    256      * definitions to an attribute 
    257      * 
    258      * @return array 
    259      */ 
    260     public function getChildDefinitions() { 
    261         return array(); 
    262287    } 
    263288} 
  • trunk/XJConf/definitions/CDataDefinition.php

    r14 r21  
    5252        $this->type = $type; 
    5353    } 
     54     
     55    /** 
     56     * get the name under which the data will be stored 
     57     * 
     58     * @return  string 
     59     */ 
     60    public function getName() 
     61    { 
     62        return 'data'; 
     63    } 
     64 
     65    /** 
     66         * get the type of the data 
     67         * 
     68         * @return  string 
     69         */ 
     70        public function getType() 
     71        { 
     72                return $this->type; 
     73        } 
     74         
     75    /** 
     76     * Convert the character data to any type 
     77     * 
     78     * @param   Tag    $tag 
     79         * @return  mixed  concerted value 
     80     */ 
     81    public function convertValue(Tag $tag) 
     82    { 
     83        $instance = $this->getValueConverter()->convertValue($tag, $this); 
     84                return $instance; 
     85    } 
     86 
     87    /** 
     88     * Get the type of the cdata 
     89     * 
     90     * @param   Tag     $tag 
     91     * @return  string 
     92     */ 
     93    public function getValueType(Tag $tag) { 
     94        return $this->getValueConverter()->getType(); 
     95    } 
    5496 
    5597    /** 
     
    78120    } 
    79121 
    80     /** 
     122       /** 
    81123     * Character data cannot have any child definitions 
    82124     * 
     
    87129        // Character data can not have any children. 
    88130    } 
    89  
     131         
     132        /** 
     133     * Checks whether this definition has a specific child condition 
     134     * 
     135     * @param   string   $def 
     136     * @return  boolean  true if definition has a specific child condition, else false 
     137     */ 
     138    public function hasChildDefinition($def) 
     139    { 
     140        return false; 
     141    } 
     142     
    90143    /** 
    91      * Convert the character data to any type 
     144     * Returns the first found definition of type $def 
    92145     * 
    93      * @param   Tag    $tag 
    94          * @return  mixed  concerted value 
     146     * @param   string   $def 
     147     * @return  Definition 
    95148     */ 
    96     public function convertValue(Tag $tag
     149    public function getChildDefinition($def
    97150    { 
    98         $instance = $this->getValueConverter()->convertValue($tag, $this); 
    99                 return $instance; 
     151        return null; 
    100152    } 
    101  
    102     /** 
    103      * get the name under which the data will be stored 
    104      * 
    105      * @return  string 
    106      */ 
    107     public function getName() 
    108     { 
    109         return 'data'; 
    110     } 
    111  
    112     /** 
    113      * Get the type of the cdata 
    114      * 
    115      * @param   Tag     $tag 
    116      * @return  string 
    117      */ 
    118     public function getValueType(Tag $tag) { 
    119         return $this->getValueConverter()->getType(); 
    120     } 
    121  
    122         /** 
    123          * get the type of the data 
    124          * 
    125          * @return  string 
    126          */ 
    127         public function getType() 
    128         { 
    129                 return $this->type; 
    130         } 
    131153 
    132154    /** 
     
    138160     * @return  array 
    139161     */ 
    140     public function getChildDefinitions() { 
     162    public function getChildDefinitions() 
     163    { 
    141164        return array(); 
    142165    } 
    143  
     166     
    144167    /** 
    145168     * Get the value converter for this character data 
     
    149172    private function getValueConverter() 
    150173    { 
    151         if ($this->valueConverter == null) { 
     174        if (null == $this->valueConverter) { 
    152175            $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); 
    153176        } 
  • trunk/XJConf/definitions/ChildDefinition.php

    r14 r21  
    4343        { 
    4444                return $this->name; 
     45        } 
     46         
     47        /** 
     48         * get the type of the child 
     49         * 
     50         * @return  string 
     51         */ 
     52        public function getType() 
     53        { 
     54                return null; 
    4555        } 
    4656 
     
    98108        // Character data can not have any children. 
    99109    } 
     110     
     111    /** 
     112     * Checks whether this definition has a specific child condition 
     113     * 
     114     * @param   string   $def 
     115     * @return  boolean  true if definition has a specific child condition, else false 
     116     */ 
     117    public function hasChildDefinition($def) 
     118    { 
     119        return false; 
     120    } 
     121     
     122    /** 
     123     * Returns the first found definition of type $def 
     124     * 
     125     * @param   string   $def 
     126     * @return  Definition 
     127     */ 
     128    public function getChildDefinition($def) 
     129    { 
     130        return null; 
     131    } 
    100132 
    101133    /** 
     
    105137     * definitions to a child 
    106138     * 
    107      * @return array 
     139     * @return array 
    108140     */ 
    109141    public function getChildDefinitions() { 
     
    111143    } 
    112144 
    113         /** 
    114          * get the type of the child 
    115          * 
    116          * @return  string 
    117          */ 
    118         public function getType() 
    119         { 
    120                 return null; 
    121         } 
     145         
    122146} 
    123147?> 
  • trunk/XJConf/definitions/ConstructorDefinition.php

    r6 r21  
    11<?php 
     2/** 
     3 * Definition for the constructor of a class 
     4 * 
     5 * @author  Stephan Schmidt <stephan.schmidt@schlund.de> 
     6 * @author  Frank Kleine <frank.kleine@schlund.de> 
     7 */ 
    28XJConfLoader::load('definitions.Definition'); 
    39/** 
    410 * Definition for the constructor of a class 
    511 * 
    6  * @author Stephan Schmidt <stephan.schmidt@schlund.de> 
     12 * @package     XJConf 
     13 * @subpackage  definitions 
    714 */ 
    815class ConstructorDefinition implements Definition 
     
    1421     */ 
    1522    private $params = array(); 
    16  
     23     
    1724    /** 
    18     * Add a new child definition (equals a parameter of the constructor) 
    19    
    20     * @param  Definition  $def 
    21     */ 
    22     public function addChildDefinition(Definition $def
     25    * Get the name under which it will be stored 
     26   
     27    * @return  string 
     28    */ 
     29    public function getName(
    2330    { 
    24         array_push($this->params, $def)
     31        return '__constructor'
    2532    } 
    26  
     33     
    2734    /** 
    28      * Get the parameters of the constructor 
    29    
    30      * @return  array 
    31     */ 
    32     public function getParams() 
    33    
    34         return $this->params
    35    
    36  
    37     /** 
     35        * get the type of the constructor 
     36       
     37         * @return  string 
     38        */ 
     39       public function getType() 
     40       
     41               return null
     42       
     43         
     44       /** 
    3845     * Convert the constructor. 
    3946     * 
     
    4855    } 
    4956 
    50    /** 
    51     * Get the name under which it will be stored 
    52     * 
    53     * @return  string 
    54     */ 
    55     public function getName() 
    56     { 
    57         return '__constructor'; 
    58     } 
    59  
    6057    /** 
    6158     * Get the type of the constructor 
     
    6865        return null; 
    6966    } 
    70  
     67     
    7168    /** 
    7269     * Get the setter method 
     
    7774    { 
    7875        return null; 
     76    } 
     77 
     78    /** 
     79     * Add a new child definition (equals a parameter of the constructor) 
     80     * 
     81     * @param  Definition  $def 
     82     */ 
     83    public function addChildDefinition(Definition $def) 
     84    { 
     85        array_push($this->params, $def); 
     86    } 
     87     
     88    /** 
     89     * Checks whether this definition has a specific child condition 
     90     * 
     91     * @param   string   $def 
     92     * @return  boolean  true if definition has a specific child condition, else false 
     93     */ 
     94    public function hasChildDefinition($def) 
     95    { 
     96        foreach ($this->params as $param) { 
     97            if (get_class($param) == $def) { 
     98                return true; 
     99            } 
     100        } 
     101         
     102        return false; 
     103    } 
     104     
     105    /** 
     106     * Returns the first found definition of type $def 
     107     * 
     108     * @param   string   $def 
     109     * @return  Definition 
     110     */ 
     111    public function getChildDefinition($def) 
     112    { 
     113        foreach ($this->params as $param) { 
     114            if (get_class($param) == $def) { 
     115                return $param; 
     116            } 
     117        } 
     118         
     119        return null; 
     120    } 
     121     
     122    /** 
     123     * Return all child definitions. 
     124     * 
     125     * @return  array 
     126     */ 
     127    public function getChildDefinitions() { 
     128        return $this->params; 
    79129    } 
    80130 
     
    99149        return $childrenNames; 
    100150    } 
    101  
     151     
    102152    /** 
    103      * Return all child definitions. 
     153     * Get the parameters of the constructor 
    104154     * 
    105      * @return array 
     155     * @return array 
    106156     */ 
    107     public function getChildDefinitions() { 
     157    public function getParams() 
     158    { 
    108159        return $this->params; 
    109160    } 
    110  
    111         /** 
    112          * get the type of the constructor 
    113          * 
    114          * @return  string 
    115          */ 
    116         public function getType() 
    117         { 
    118                 return null; 
    119         } 
    120161} 
    121162?> 
  • trunk/XJConf/definitions/Definition.php

    r6 r21  
    11<?php 
    22/** 
    3  * Interface for tag and attribute definitions 
     3 * Interface for tag and attribute definitions. 
    44 * 
    5  * @author Stephan Schmidt <stephan.schmidt@schlund.de> 
     5 * @author  Stephan Schmidt <stephan.schmidt@schlund.de> 
     6 * @author  Frank Kleine <frank.kleine@schlund.de> 
     7 */ 
     8/** 
     9 * Interface for tag and attribute definitions. 
     10 * 
     11 * @package     XJConf 
     12 * @subpackage  definitions 
    613 */ 
    714interface Definition 
     
    1421     */ 
    1522        public function getName(); 
     23         
     24        /** 
     25     * Get the type of the definition 
     26     * 
     27     * @return  string 
     28     */ 
     29        public function getType(); 
    1630 
    1731    /** 
     
    4256     * Add a child definition of any type 
    4357     * 
    44      * @param  Definition  def 
     58     * @param  Definition  $def 
    4559     */ 
    4660    public function addChildDefinition(Definition $def); 
    47  
     61     
    4862    /** 
    49      * Get the type of the definition 
     63     * Checks whether this definition has a specific child condition 
    5064     * 
    51      * @return string 
     65     * @param   string   $def 
     66     * @return  boolean  true if definition has a specific child condition, else false 
    5267     */ 
    53         public function getType(); 
    54  
    55         /** 
     68    public function hasChildDefinition($def); 
     69     
     70    /** 
     71     * Returns the first found definition of type $def 
     72     * 
     73     * @param   string   $def 
     74     * @return  Definition 
     75     */ 
     76    public function getChildDefinition($def); 
     77     
     78    /** 
    5679         * Get all child definitions of the definition 
    5780         * 
    58          * @return array 
     81         * @return array 
    5982         */ 
    6083        public function getChildDefinitions(); 
  • trunk/XJConf/definitions/FactoryMethodDefinition.php

    r6 r21  
    11<?php 
     2/** 
     3 * FactoryMethodDefinition 
     4 * 
     5 * @author  Stephan Schmidt <me@schst.net> 
     6 * @author  Frank Kleine <frank.kleine@schlund.de> 
     7 */ 
    28XJConfLoader::load('definitions.Definition', 
    39                   'exceptions.UnsupportedOperationException' 
     
    915 * is used to create an instance. 
    1016 * 
    11  * @author Stephan Schmidt <me@schst.net> 
     17 * @package     XJConf 
     18 * @subpackage  definitions 
    1219 */ 
    1320class FactoryMethodDefinition implements Definition 
     
    3542                $this->name = $name; 
    3643        } 
    37  
    38     /** 
    39      * Get the parameters of the factory method 
    40      * 
    41      * @return  array 
    42      */ 
    43     public function getParams() 
    44     { 
    45         return $this->params; 
    46     } 
    47  
    48     /** 
    49      * Add a new child definition (equals a parameter of the factory method) 
    50      * 
    51      *  @param  Definition  $def 
    52      */ 
    53     public function addChildDefinition(Definition $def) 
    54     { 
    55         array_push($this->params, $def); 
    56     } 
    57  
    58     /** 
     44         
     45        /** 
    5946     * Get the name under which it will be stored 
    6047     * 
     
    6552                return $this->name; 
    6653        } 
    67  
     54         
     55        /** 
     56         * get the type of the factory method 
     57         * 
     58         * @return  string 
     59         */ 
     60        public function getType() 
     61        { 
     62                return null; 
     63        } 
     64         
    6865        /** 
    6966     * Convert the factory method. 
     
    8784                throw new UnsupportedOperationException(); 
    8885        } 
    89  
    90     /** 
     86         
     87       /** 
    9188     * Get the setter method 
    9289     * 
     
    9794                throw new UnsupportedOperationException(); 
    9895        } 
    99  
     96         
     97    /** 
     98     * Add a new child definition (equals a parameter of the factory method) 
     99     * 
     100     *  @param  Definition  $def 
     101     */ 
     102    public function addChildDefinition(Definition $def) 
     103    { 
     104        array_push($this->params, $def); 
     105    } 
     106     
     107    /** 
     108     * Checks whether this definition has a specific child condition 
     109     * 
     110     * @param   string   $def 
     111     * @return  boolean  true if definition has a specific child condition, else false 
     112     */ 
     113    public function hasChildDefinition($def) 
     114    { 
     115        foreach ($this->params as $param) { 
     116            if (get_class($param) == $def) { 
     117                return true; 
     118            } 
     119        } 
     120         
     121        return false; 
     122    } 
     123     
     124    /** 
     125     * Returns the first found definition of type $def 
     126     * 
     127     * @param   string   $def 
     128     * @return  Definition 
     129     */ 
     130    public function getChildDefinition($def) 
     131    { 
     132        foreach ($this->params as $param) { 
     133            if (get_class($param) == $def) { 
     134                return $param; 
     135            } 
     136        } 
     137         
     138        return null; 
     139    } 
     140     
    100141    /** 
    101142     * Return all child definitions. 
    102143     * 
    103      * @return array 
     144     * @return array 
    104145     */ 
    105146    public function getChildDefinitions() { 
    106147        return $this->params; 
    107148    } 
    108  
    109        /** 
    110         * get the type of the factory method 
    111        
    112          * @return  string 
    113         */ 
    114        public function getType() 
    115        
    116                return null
    117        
     149         
     150    /** 
     151     * Get the parameters of the factory method 
     152   
     153     * @return  array 
     154    */ 
     155    public function getParams() 
     156   
     157        return $this->params
     158   
    118159} 
    119160?> 
  • trunk/XJConf/definitions/TagDefinition.php

    r14 r21  
    105105                $this->setType($type); 
    106106        } 
     107         
     108        /** 
     109         * set the name of the value 
     110         * 
     111         * @param  string  $name 
     112         */ 
     113        public function setName($name) 
     114        { 
     115                $this->name = $name; 
     116        } 
     117         
     118        /** 
     119         * get the name of the value 
     120         * 
     121         * @return  string 
     122         */ 
     123        public function getName() 
     124        { 
     125                return $this->name; 
     126        } 
    107127 
    108128        /** 
     
    115135                $this->type = $type; 
    116136        } 
    117  
    118     /** 
    119      * Add a new child definition 
    120      * 
    121      * Possible definitions are: 
    122      * - AttributeDefinition 
    123      * - ConstructorDefinition 
    124      * - FactoryMethodDefinition 
    125      * - CDataDefinition 
    126      * 
    127      * @param  Definition  $def 
    128      */ 
    129     public function addChildDefinition(Definition $def) 
    130     { 
    131         if ($def instanceof AttributeDefinition) { 
    132             $this->addAttribute($def); 
    133             return; 
    134         } 
    135  
    136         if ($def instanceof FactoryMethodDefinition) { 
    137             $this->factoryMethod = $def; 
    138             return; 
    139         } 
    140  
    141         if ($def instanceof ConstructorDefinition) { 
    142             $this->constructor = $def; 
    143             return; 
    144         } 
    145  
    146         if ($def instanceof CDataDefinition) { 
    147             $this->cdata = $def; 
    148             return; 
    149         } 
    150     } 
    151  
    152         /** 
    153          * Add an attribute to the tag 
    154          * 
    155          * @param  AttributeDefinition  $att 
    156          */ 
    157         public function addAttribute(AttributeDefinition $att) 
    158         { 
    159                 array_push($this->atts, $att); 
    160         } 
    161  
    162         public function getAttributes() { 
    163             return $this->atts; 
    164         } 
    165  
    166         /** 
    167          * set the name of the value 
    168          * 
    169          * @param  string  $name 
    170          */ 
    171         public function setName($name) 
    172         { 
    173                 $this->name = $name; 
    174         } 
    175  
    176         /** 
    177          * Set the name of the tag 
    178          * 
    179          * @param name 
    180          */ 
    181         public function setTagName($name) 
    182         { 
    183                 $this->tagName = $name; 
    184         } 
    185  
    186         /** 
    187          * Set the attribute that will be used as key. 
    188      * 
    189          * @return   name of the value 
    190          */ 
    191         public function setKeyAttribute($att) 
    192         { 
    193         $this->name          = '__attribute'; 
    194                 $this->nameAttribute = $att; 
    195         } 
    196  
    197         /** 
    198          * get the name of the value 
     137         
     138        /** 
     139         * get the type of the tag 
    199140         * 
    200141         * @return  string 
    201142         */ 
    202         public function getName() 
    203         { 
    204                 return $this->name; 
    205         } 
    206  
    207         /** 
    208          * get the name of the tag 
    209          * 
    210          * @return  string 
    211          */ 
    212         public function getTagName() 
    213         { 
    214                 return $this->tagName; 
    215         } 
    216  
    217         /** 
    218          * get the name of the tag 
    219          * 
    220          * @return  string 
    221          */ 
    222         public function getKey(DefinedTag $tag) 
    223         { 
    224                 if ('__attribute' == $this->name) { 
    225                 return $tag->getAttribute($this->nameAttribute); 
    226         } 
    227  
    228         return $this->name; 
    229