lightmelody

changeset 709:81419276ecf2 objectify

completed MessageNode
author Mayank Singh <mayanks43@gmail.com>
date Thu, 03 Jan 2013 19:48:34 +0530
parents ce57acd85a97
children 17145d045199
files src/MessageNode.gs
diffstat 1 files changed, 36 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/MessageNode.gs	Wed Jan 02 13:18:15 2013 +0530
     1.2 +++ b/src/MessageNode.gs	Thu Jan 03 19:48:34 2013 +0530
     1.3 @@ -24,7 +24,7 @@
     1.4      _name : string?
     1.5      _value : string?
     1.6      _raw_mode : bool
     1.7 -
     1.8 +    _attributes : dict of string,string
     1.9      _next : Lm.MessageNode?
    1.10      _prev : Lm.MessageNode?
    1.11      _parent : Lm.MessageNode?
    1.12 @@ -38,6 +38,7 @@
    1.13          self._prev       = null
    1.14          self._parent     = null
    1.15          self._children   = null
    1.16 +        self._attributes = new dict of string,string
    1.17          
    1.18      def static last_child (node : MessageNode) : MessageNode?
    1.19          l : MessageNode
    1.20 @@ -72,9 +73,42 @@
    1.21          
    1.22          return child
    1.23      
    1.24 +    def get_child(child_name : string?) : MessageNode?
    1.25 +        l : MessageNode
    1.26 +        l = self._children
    1.27 +        while(l!=null)
    1.28 +            if l._name == child_name
    1.29 +                return l
    1.30 +             l = l._next
    1.31 +        return null
    1.32 +    
    1.33 +    def set_attribute(name : string?, value : string?)
    1.34 +        self._attributes[name] = value
    1.35 +        
    1.36 +    def get_attribute(name : string?) : string?
    1.37 +        if name in self._attributes.keys
    1.38 +            return self._attributes[name]
    1.39 +        else
    1.40 +            return null
    1.41 +            
    1.42 +    def set_attributes(attributes : dict of string,string)
    1.43 +        for attribute_key in attributes.keys
    1.44 +            self.set_attribute(attribute_key, attributes[attribute_key])
    1.45 +        
    1.46      prop value : string?
    1.47 +        get
    1.48 +            return self._value    
    1.49          set
    1.50              self._value = value
    1.51 +
    1.52 +    prop raw_mode : bool
    1.53          get
    1.54 -            return self._value
    1.55 +            return self._raw_mode
    1.56 +        set
    1.57 +            self._raw_mode = value
    1.58      
    1.59 +
    1.60 +        
    1.61 +        
    1.62 +        
    1.63 +