mn8 Language Reference | Index    

Concept

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

Description

In MN8 every data type is a concept and is inherited from the basic Concept data type or another data type which has it's roots in the Concept data type.

Usage

            DEFINE Person [
                @handle TYPEOF String LABEL "nick"
                first_name TYPEOF Element LABEL "First_Name"
                last_name  TYPEOF Element LABEL "Last_Name"
                home_page  TYPEOF Element
                emails LABEL "email_addresses" [
                    email* [
                        @obsolete TYPEOF Logical
                        @address TYPEOF String
                        description]]

                : validEmails [
                    $list TYPEOF Series
                    EACH $email IN /emails/email WHERE $email@obsolete == false do [
                        $list.add($email@address)]
                    return $list] TYPEOF Series

                : init [
                    @handle="crow"
                    /first_name="Csaba"
                    /last_name="Szabo"

                    /emails/email.createNewEntry
                    /emails/email.lastEntry@obsolete = false
                    /emails/email.lastEntry@address  = "crow@nolimits.ro"

                    /emails/email.createNewEntry
                    /emails/email.lastEntry@obsolete = true   /emails/email.lastEntry@address  = "csaba@nolimits.ro"

                    /emails/email.createNewEntry
                    /emails/email.lastEntry@obsolete = false
                    /emails/email.lastEntry@address  = "csabi@nolimits.ro"]

                static : main( $args typeof Series ) [
                    $p typeof Person
                    $p.init
                    print $p.validEmails]]

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

Constructor List

create
top

Operator List

Logical== (Nil $nil)
top

Method List

ConceptcloneConcept
static LogicalextendsConcept (String $conceptType)
static ConceptfromXML (String $content)
static SeriesgetAllInheritedConcepts
ConceptgetConceptAttribute (String $attrName)
static ConceptgetConceptAttributeField (String $attrFieldName)
static SeriesgetConceptAttributeFields
SeriesgetConceptAttributes
static SeriesgetConceptConstructors
ConceptgetConceptElement (String $elemName)
static ConceptgetConceptElementField (String $elemFieldName)
static SeriesgetConceptElementFields
SeriesgetConceptElements
static StringgetConceptLabel
static MethodgetConceptMethod (String $methodName)
static SeriesgetConceptMethods
static SeriesgetConceptOperators
static StringgetConceptType
static ConceptgetErrorHandler
static SeriesgetInheritedConcepts
StringgetResourceURI
static LogicalhasConceptAttribute (String $attrName)
static LogicalhasConceptElement (String $elemName)
static LogicalhasConceptMethod (String $methodName)
LogicalhasPath (String $path)
LogicalisHidden
loadContent (Concept $from)
setConceptLabel (String $label)
static setErrorHandler (Concept $errorHandler)
setHidden (Logical $isHidden)
setShowEmpty (Logical $showEmpty)
LogicalshowEmpty
StringtoTXT
StringtoXML
setResourceURI (String $resURI)
top

Detailed Constructor Info

create

This represents the default constructor of the Concept data type, and therefore every concept from MN8 has an implicit constructor which create a new and empty instance of a concept.

top

Detailed Operator Info

== (Nil $nil)
Parameters:
$nil :To this will be compared this concept.

Returns true if this concept equals with parameter or false otherwise.

top

Detailed Method Info

cloneConcept
Returns: Concept

Create a instance of this concept.

            $a typeof Series
            $a.add(1)
            $a.add(2)
            $b = $a.cloneConcept
            print $b
            -- the result is --
            1
            2
            

top
static extendsConcept (String $conceptType)
Parameters:
$conceptType :Concept type.
Returns: Logical

Returns true if the signature of this concept matches the signature of the concept type from parameter, false otherwise.

            print Concept.extendsConcept("String")
            -- the result is --
            false
            

top
static fromXML (String $content)
Parameters:
$content :XML stream.
Returns: Concept

Attempts to create a concept from a XML stream.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement
            -- and the result --
            config
            

top
static getAllInheritedConcepts
Returns: Series

Returns all inherited concepts by this concept.

            print Concept.getAllInheritedConcepts()
            -- the result is --
            Concept
            

top
getConceptAttribute (String $attrName)
Parameters:
$attrName :Attribute name.
Returns: Concept
Exceptions:
noSuchAttribute :
(Warning)
If the concept does not have such an Attribute.

Returns the attribute value or nil if attribute with that name not exist.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            $tmpdir = $rootElement/tmpdir
            print $tmpdir.getConceptAttribute("path")
            -- and the result --
            path: d:/tmp/
            

top
static getConceptAttributeField (String $attrFieldName)
Parameters:
$attrFieldName :Attribute field name.
Returns: Concept
Exceptions:
noSuchField :
(Warning)
If the concept does not have such an Element or Attribute field.

Returns the attribute field definition.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            $tmpdir = $rootElement/tmpdir
            print $tmpdir.getConceptAttributeField("path")
            -- and the result --
            @path TYPEOF String LABEL "path"
            

top
static getConceptAttributeFields
Returns: Series

Returns a series with all attribute fields of this concept.

top
getConceptAttributes
Returns: Series

Returns a series containing elements of type Attribute with information about the attributes defined in this concept.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            $tmpdir = $rootElement/tmpdir
            print $tmpdir.getConceptAttributeFields
            -- and the result --
            @path TYPEOF String LABEL "path"
            @permission TYPEOF String LABEL "permission"
            

top
static getConceptConstructors
Returns: Series

Returns a series with this concept constructors.

            print Concept.getConceptConstructors
            -- and the result --
            create: TYPEOF Concept
            

top
getConceptElement (String $elemName)
Parameters:
$elemName :Element name.
Returns: Concept
Exceptions:
noSuchElement :
(Warning)
If the concept does not have such an Element.

Returns the element value or nil if element with that name not exist.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement/tmpdir
            -- and the result --
            tmpdir  path: d:/tmp/   permission: rw
            

top
static getConceptElementField (String $elemFieldName)
Parameters:
$elemFieldName :Element field name.
Returns: Concept
Exceptions:
noSuchField :
(Warning)
If the concept does not have such an Element or Attribute field.

Returns the element field definition.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.getConceptElementField("tmpdir")
            -- and the result --
            tmpdir TYPEOF Element LABEL "tmpdir"
            

top
static getConceptElementFields
Returns: Series

Returns a series with all element fields of this concept.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.getConceptElementFields
            -- and the result --
            tmpdir TYPEOF Element LABEL "tmpdir"
            testdir TYPEOF Element LABEL "testdir"
            

top
getConceptElements
Returns: Series

Returns a series containing elements of type String with the name of the elements defined in this concept.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.getConceptElements
            -- and the result --
            tmpdir  path: d:/tmp/   permission: rw
            testdir  path: d:/test/
            

top
static getConceptLabel
Returns: String

Returns the concept label.

            print Concept.getConceptLabel
            -- the result is --
            Concept
            

top
static getConceptMethod (String $methodName)
Parameters:
$methodName :Method name (ex. Concept.getConceptMethod("getConceptLabel:"))
Returns: Method
Exceptions:
noSuchMethod :
(Error)
If the concept does not have such an Method.

Returns the method.

            print Concept.getConceptMethod("getConceptLabel:")
            -- the result is --
            STATIC getConceptLabel: TYPEOF String
            

top
static getConceptMethods
Returns: Series

Returns a series containing elements of type Element with information about the methods defined in this concept.

            print Concept.getConceptMethods
            -- the result is --
            STATIC setErrorHandler:Concept
            getConceptElement:String TYPEOF Concept
            STATIC getConceptElementFields: TYPEOF Series
            getConceptAttribute:String TYPEOF Concept
            STATIC getConceptAttributeFields: TYPEOF Series
            loadContent:Concept
            STATIC getConceptLabel: TYPEOF String
            STATIC getConceptOperators: TYPEOF Series
            getConceptElements: TYPEOF Series
            ...
            

top
static getConceptOperators
Returns: Series

Returns a series which contains all operators of this concept.

            print Concept.getConceptOperators
            -- the result is --
            >:String TYPEOF Logical
            +:Logical TYPEOF String
            +:Real TYPEOF String
            +:Concept TYPEOF String
            <:String TYPEOF Logical
            +:Integer TYPEOF String
            +:Character TYPEOF String
            +:String TYPEOF String
            ==:String TYPEOF Logical
            +:Nil TYPEOF String
            ==:Nil TYPEOF Logical
            

top
static getConceptType
Returns: String

Returns this concept type.

            print Concept.getConceptType
            -- the result is --
            Concept
            

top
static getErrorHandler
Returns: Concept

Returns the concept which error handler method is used by this concept if it is set or nil if it is not.

            define Test [                                                                   
              :handlerMethod($e typeof Error) [                                             
                print $e.getMSG                                                             
              ]                                                                          
                                                                                
              static : main ($args typeof Series) [                                         
                $con typeof Test                                                            
                Test.setErrorHandler($con)                                                  
                Error.create("error", "handlerMethod", "This is an error message.")         
                print Test.getErrorHandler                                                  
              ]                                                                             
            ]
            -- the result is --
            Test
            

top
static getInheritedConcepts
Returns: Series

Returns a series with inherited concepts.

            print Series.getInheritedConcepts
            -- the result is --
            Concept
            

top
getResourceURI
Returns: String

Returns the URI associated with this resource, this is sticky, therefore once you assign it will stick with the concept until it will be set to "". In case the resource is loaded from a public resource (file://, ftp://, http://, ...) this will be set automatically.

It is important for concepts that have to know where this resource originated, for example for resolving entities when a concept is loaded from XML.

            $file from "d:/tmp/test.xml"
            print $file/content.getResourceURI
            $elm = Concept.fromXML($file/content)
            print $elem.getResourceURI
            -- And the result
            file:/d:/tmp/test.xml
            file:/d:/tmp/test.xml
            

top
static hasConceptAttribute (String $attrName)
Parameters:
$attrName :Attribute name.
Returns: Logical

Returns true is this concept has a attribute with the name given as parameter or false otherwise.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            $tmpdir = $rootElement/tmpdir
            print $tmpdir.hasConceptAttribute("path")
            -- and the result --
            true
            

top
static hasConceptElement (String $elemName)
Parameters:
$elemName :Element name.
Returns: Logical

Returns true is this concept has a element with the name given as parameter or false otherwise.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.hasConceptElement("tmpdir")
            -- and the result --
            true
            

top
static hasConceptMethod (String $methodName)
Parameters:
$methodName :Method name.
Returns: Logical

Returns true is this concept has a method with the name given as parameter or false otherwise.

            print Concept.hasConceptMethod("getConceptLabel:")
            -- the result is --
            true
            

top
hasPath (String $path)
Parameters:
$path :

Navigational pattern. Represented by: / - element marker, if is the first character also marks the root element, @ - attribute marker.

Returns: Logical

Returns true if the path specified in parameter using standard MN8 navigational patterns can be found inside the actual concept. False otherwise.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.hasPath("tmpdir@permission")
            print $rootElement.hasPath("config/testdir@path")
            -- and the result --
            true
            false
            

top
isHidden
Returns: Logical

Returns true if this concept is marked hidden or false otherwise.

            $con typeof Concept                                                             
            print $con.isHidden                                                             
            $con.setHidden(true)                                                            
            print $con.isHidden
            -- the result is --
            false
            true
            

top
loadContent (Concept $from)
Parameters:
$from :Concept which attributes and elements will be loaded.
Returns:

Loads from the concept given as parameter to this concept, all those attributes and elements value which name correspond with this concept attributes or elements name.

            define Test [
              tmpdir [
                @path
                @permission
              ]
              testdir [
                @path
              ]
                                                                                
              static : main ($args typeof Series) [
                $xml from "/test/scripts/config.xml"
                $rootElement = Concept.fromXML($xml/content.toTXT)
                $con typeof Test
                $con.loadContent($rootElement)
                print $con.getConceptElements
              ]
            ]
            -- the result is --
            tmpdir  permission: rw  path: d:/tmp/
            testdir  path: d:/test/
            

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

Sets the label of this concept to the string specified in parameter.

            $con typeof Concept                                                             
            $con.setConceptLabel("NewLabel")                                                
            print $con.getConceptLabel
            -- the result is --
            NewLabel
            

top
static setErrorHandler (Concept $errorHandler)
Parameters:
$errorHandler :Concept in which the error handler methods will be searched.
Returns:

Sets the error handler for this concept.

            define Test [                                                                   
              :handlerMethod($e typeof Error) [                                             
                print $e.getMSG                                                             
              ]                                                                          
                                                                                
              static : main ($args typeof Series) [                                         
                $con typeof Test                                                            
                Test.setErrorHandler($con)                                                  
                Error.create("error", "handlerMethod", "This is an error message.")         
                print Test.getErrorHandler                                                  
              ]                                                                             
            ]
            -- the result is --
            Test
            

top
setHidden (Logical $isHidden)
Parameters:
$isHidden :If true the concept is hidden, otherwise it is not.
Returns:

Hide or unhide a concept, depending on the value of the parameter.

            $con typeof Concept                                                             
            print $con.isHidden                                                             
            $con.setHidden(true)                                                            
            print $con.isHidden
            -- the result is --
            false
            true
            

top
setShowEmpty (Logical $showEmpty)
Parameters:
$showEmpty :The logical to be set.
Returns:

Sets the specified logical to indicate whether or not this concept should be showEmpty. If the showEmpty is set to true then when the concept is empty it is acting like a hidden concept.

            $con typeof Concept
            $con.setShowEmpty(false)  #by default showEmpty is true.
            print $con.showEmpty
            -- the result is --
            false
            

top
showEmpty
Returns: Logical

Returns the logical indicating whether this concept is showEmpty or not.

            $con typeof Concept
            $con.setShowEmpty(false)  #by default showEmpty is true.
            print $con.showEmpty
            -- the result is --
            false
            

top
toTXT
Returns: String

Returns a stream representing the simple text rendering of this concept.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.toTXT
            -- and the result --
            config
            tmpdir
                      path: d:/tmp/   permission: rw
            testdir
                      path: d:/test/
            

top
toXML
Returns: String

Returns a stream representing the XML rendering of this concept.

            -- the test.xml file --
            <config>
              <tmpdir path="d:/tmp/" permission="rw"/>
              <testdir path="d:/test/"/>
            </config>
            -- the example --
            $xml from "d:/test.xml"
            $rootElement = Concept.fromXML($xml/content.toTXT)
            print $rootElement.toXML
            -- and the result --
            <config>
            <tmpdir path="d:/tmp/" permission="rw"></tmpdir>
            <testdir path="d:/test/"></testdir>
            </config>
            

top
setResourceURI (String $resURI)
Parameters:
$resURI :The resource URI.
Returns:

Allows a concept to be associated with a resource.

It is important for concepts that have to know where this resource originated, for example for resolving entities when a concept is loaded from XML.

            $doc = "<?xml version='1.0'?>\n"
            $doc += "<!DOCTYPE reference SYSTEM 'rfc2629.dtd'>\n"
            $doc += "<reference anchor='RFC0008'/>"
            $doc.setResourceURI("d:/work/2629/rfc/reference/")
            $el = Concept.fromXML($doc)
            print $el.getResourceURI
            -- And the result -- 
            file:/d:/work/2629/rfc/reference/    
            

top