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.
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]]
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.
Parameters: |
$nil : | To this will be compared this concept. |
|
Returns true if this concept equals with parameter or false otherwise.
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
Parameters: |
$conceptType : | Concept type. |
|
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
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
Returns all inherited concepts by this concept.
print Concept.getAllInheritedConcepts()
-- the result is --
Concept
Parameters: |
$attrName : | Attribute name. |
|
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/
Parameters: |
$attrFieldName : | Attribute field name. |
|
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"
Returns a series with all attribute fields of this concept.
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"
Returns a series with this concept constructors.
print Concept.getConceptConstructors
-- and the result --
create: TYPEOF 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
Parameters: |
$elemFieldName : | Element field name. |
|
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"
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"
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/
Returns the concept label.
print Concept.getConceptLabel
-- the result is --
Concept
Parameters: |
$methodName : | Method name (ex. Concept.getConceptMethod("getConceptLabel:")) |
|
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
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
...
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
Returns this concept type.
print Concept.getConceptType
-- the result is --
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
Returns a series with inherited concepts.
print Series.getInheritedConcepts
-- the result is --
Concept
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
Parameters: |
$attrName : | Attribute name. |
|
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
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
Parameters: |
$methodName : | Method name. |
|
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
Parameters: |
$path : |
Navigational pattern. Represented by: / - element marker, if is the
first character also marks the root element, @ - attribute marker.
|
|
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
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
Parameters: |
$from : | Concept which attributes and elements will be loaded. |
|
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/
Parameters: |
$label : | The new label to be set. |
|
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
Parameters: |
$errorHandler : | Concept in which the error handler methods will be searched. |
|
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
Parameters: |
$isHidden : | If true the concept is hidden, otherwise it is not. |
|
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
Parameters: |
$showEmpty : | The logical to be set. |
|
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
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
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/
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>
Parameters: |
$resURI : | The resource URI. |
|
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/