mn8 Language Reference | Index    

Element

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

Elements represent the building blocks of everything in MN8. An element is a primary data type which can have attributes and it's values can be a Concept (basically everything).

Usage

        $elem TYPEOF Element
        $attr = Attribute.create("name", "jon")
        $elem.addAttribute( $attr )
        $elem.setValue("employee of the year")
        PRINT $elem

                name: jon
                employee of the year

        PRINT $elem.toXML< name="jon">employee of the yea</>

        $elem.setLabel("employee")
        PRINT $elem
            employee
                name: jon
                employee of the year

        PRINT $elem.toXML<employee name="jon">employee of the year</employee>

Version: 0.1
Authors:Remus Pereni (http://neuro.nolimits.ro)
Location:
Inherits: Concept

Constructor List

create (String $label, Concept $value)
top

Method List

addAttribute (Attribute $attr)
addAttribute (String $name, String $label, Concept $value)
addValue (Concept $value)
SeriesgetAttributes
StringgetLabel
StringgetName
ConceptgetValue
StringgetValueType
LogicalisMulti
setAttributes (Series $attributes)
setLabel (String $label)
setValue (Concept $value)
StringtoXML
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Constructor Info

create (String $label, Concept $value)
Parameters:
$label :The label of this Element.
$value :The value of this Element.

Constructs a new Element concept with the specified value and label.

top

Detailed Method Info

addAttribute (Attribute $attr)
Parameters:
$attr :Attribute to add.
Returns:

Adds a new attribute to this Element.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                $attr typeof Attribute
                $attr.setLabel("color")
                $attr.setValue("blue")
                print $test.getConceptElement("elem").getAttributes
                $test.getConceptElement("elem").addAttribute($attr)
                print $test.getConceptElement("elem").getAttributes
              ]
            ]
            -- the result is --
            
            color: blue
            

top
addAttribute (String $name, String $label, Concept $value)
Parameters:
$name :The name of the attribute to add.
$label :The label of the attribute to add.
$value :The value of the attribute to add.
Returns:

Adds a new attribute to this element with the specified name, label and value.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getAttributes
                $test.getConceptElement("elem").addAttribute("attr", "color", "blue")
                print $test.getConceptElement("elem").getAttributes
              ]
            ]
            -- the result is --
            
            color: blue
            

top
addValue (Concept $value)
Parameters:
$value :The value to be added.
Returns:

Adds a new value to this Element.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getVAlue
                $test.getConceptElement("elem").addValue("and this is the new value")
                print $test.getConceptElement("elem").getVAlue
              ]
            ]
            -- the result is --
            This is the element initial value.
            This is the element initial value.
            and this is the new value.
            

top
getAttributes
Returns: Series

Returns a series concept containing all attributes of this Element.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getAttributes
                $test.getConceptElement("elem").addAttribute("attr", "color", "blue")
                print $test.getConceptElement("elem").getAttributes
              ]
            ]
            -- the result is --
            
            color: blue
            

top
getLabel
Returns: String

Returns a string concept representing this Element's label.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getLabel
              ]
            ]
            -- the result is --
            ElemLabel
            

top
getName
Returns: String

Returns a string concept representing this Element's name.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getName
              ]
            ]
            -- the result is --
            elem
            

top
getValue
Returns: Concept

Returns a concept representing this Element's value.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getValue
              ]
            ]
            -- the result is --
            This is the element initial value.
            

top
getValueType
Returns: String

Returns this concept's value type.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getValueType
              ]
            ]
            -- the result is --
            String
            

top
isMulti
Returns: Logical

Returns true always when the element has as value more items/elements (usualy a TypedSeries)

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").isMulti
              ]
            ]
            -- the result is --
            false
            

top
setAttributes (Series $attributes)
Parameters:
$attributes :Attributes to be set.
Returns:

Sets the attributes from the specified series to this Element concept.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getAttributes
                $color typeof Attribute
                $color.setLabel("color")
                $color.setValue("blue")
                $name typeof Attribute
                $name.setLabel("name")
                $name.setValue("John")
                $attrs typeof Series
                $attrs.add($color)
                $attrs.add($name)
                $test.getConceptElement("elem").setAttributes($attrs)
                print $test.getConceptElement("elem").getAttributes
              ]
            ]
            -- the result is --
            color: blue
            name: John
            

top
setLabel (String $label)
Parameters:
$label :The new label to be set.
Returns:

Sets the label of this Element concept to the specified text.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getLabel
                $test.getConceptElement("elem").setLabel("NewLabel")
                print $test.getConceptElement("elem").getLabel
              ]
            ]
            -- the result is --
            ElemLabel
            NewLabel
            

top
setValue (Concept $value)
Parameters:
$value :The value to be set.
Returns:

Sets the value of this Element concept to the specified value.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").getValue
                $test.getConceptElement("elem").setValue("NewValue")
                print $test.getConceptElement("elem").getValue
              ]
            ]
            -- the result is --
            This is the element initial value.
            NewValue
            

top
toXML
Returns: String

Returns a stream representing the XML rendering of this concept.

            define Test [
              elem="This is the element initial value." label "ElemLabel"

              static : main ($args typeof Series) [
                $test typeof Test
                print $test.getConceptElement("elem").toXML
              ]
            ]
            -- the result is --
            <ElemLabel>This is the element initial value.</ElemLabel>
            

top