X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fsrc-isv%2Fdoc%2Fdatatype.mediawiki;h=a5293fda140e5999c8aada160908d76cdd20f2d1;hb=refs%2Fchanges%2F50%2F3150%2F4;hp=a637489868af02ed509079ba68406fd74071f6c7;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/src-isv/doc/datatype.mediawiki b/bundles/org.simantics.databoard/src-isv/doc/datatype.mediawiki index a63748986..a5293fda1 100644 --- a/bundles/org.simantics.databoard/src-isv/doc/datatype.mediawiki +++ b/bundles/org.simantics.databoard/src-isv/doc/datatype.mediawiki @@ -1,92 +1,92 @@ -=Datatype= -In Databoard all values have a type representation, [../javadoc/org/simantics/databoard/type/Datatype.html|Datatype]. -It is the base abstract class for all concrete type classes (See table below). -There is a facade class utility ([../javadoc/org/simantics/databoard/Datatypes.html|Datatypes]) that provides functions to most of the Datatype library's features. - -'''[../javadoc/org/simantics/databoard/type|org.simantics.databoard.type]'''. -{| style="background-color: #f9f9f9; border: 1px solid #aaaaaa; " -|- style="background-color: #e9e9e9; " | -| '''Class''' || '''Description''' -|- -| [../javadoc/org/simantics/databoard/type/Datatype.html|Datatype] || Base class for all data types -|- -| [../javadoc/org/simantics/databoard/type/RecordType.html|RecordType] || Record -|- -| [../javadoc/org/simantics/databoard/type/ArrayType.html|ArrayType] || Array - an ordered sequence of elements of one type. -|- -| [../javadoc/org/simantics/databoard/type/MapType.html|MapType] || Map - an ordered map of keys to values. -|- -| [../javadoc/org/simantics/databoard/type/UnionType.html|UnionType] || Union -|- -| [../javadoc/org/simantics/databoard/type/BooleanType.html|BooleanType],[../javadoc/org/simantics/databoard/type/IntType.html|IntType],[../javadoc/org/simantics/databoard/type/LongType.html|LongType],[../javadoc/org/simantics/databoard/type/FloatType.html|FloatType],[../javadoc/org/simantics/databoard/type/DoubleType.html|DoubleType] -| Primitive and numeric types -|- -| [../javadoc/org/simantics/databoard/type/StringType.html|StringType] || String -|- -| [../javadoc/org/simantics/databoard/type/OptionalType.html|OptionalType] || Optional value -|- -| [../javadoc/org/simantics/databoard/type/VariantType.html|VariantType] || Variant value -|} - - -Datatype can be acquired or created using one of the following methods: -* Construct new -* Constant -* [[binding#Reflection|Reflection]]-Read from a Class -* Read from string of [[Databoard_Specification|the text notation]]. -
- Datatype type = new DoubleType(); - Datatype type = Datatypes.DOUBLE; - Datatype type = Datatypes.getDatatype( Double.class ); - - Datatypes.addDefinition("type Node = { id : String; children : Node[] }"); - Datatype type = Datatypes.getDatatype("Node"); -- -==Parsing== -Datatypes are parsed using
Datatypes.DatatypeRepository
.
-- Datatypes.addDefinition("type Node = { id : String; children : Node[] }"); - Datatype type = Datatypes.getDatatype("Node"); -- -Types are printed to types and definitions with -
- String type = type.toString(); - - DatatypeRepository repo = new DatatypeRepository(); - repo.add("temp1", type); - String typeDef = repo.toString(); -- -==Structure Example== -A node is a recursive type. With databoard typesystem it could be stated as -
- type Node = { - id : String; - displayNames : LocalizedTexts; - children : Node[]; - value : Optional(Variant); - } -- -[[Image:NodeType.png|Type presented as tree]] - - -A couple of instances with Databoard value notation: -
- root : Node = { - id = PI_01 - displayNames = map{ en = Instrument } - children = - [ - {id=Child, - displayNames = map{ en = Child} }, - value = 5 : Integer - } - ] - value = - -[[Image:NodeInstance.png|Node values preseted as tree]] +=Datatype= +In Databoard all values have a type representation, [../javadoc/org/simantics/databoard/type/Datatype.html|Datatype]. +It is the base abstract class for all concrete type classes (See table below). +There is a facade class utility ([../javadoc/org/simantics/databoard/Datatypes.html|Datatypes]) that provides functions to most of the Datatype library's features. + +'''[../javadoc/org/simantics/databoard/type|org.simantics.databoard.type]'''. +{| style="background-color: #f9f9f9; border: 1px solid #aaaaaa; " +|- style="background-color: #e9e9e9; " | +| '''Class''' || '''Description''' +|- +| [../javadoc/org/simantics/databoard/type/Datatype.html|Datatype] || Base class for all data types +|- +| [../javadoc/org/simantics/databoard/type/RecordType.html|RecordType] || Record +|- +| [../javadoc/org/simantics/databoard/type/ArrayType.html|ArrayType] || Array - an ordered sequence of elements of one type. +|- +| [../javadoc/org/simantics/databoard/type/MapType.html|MapType] || Map - an ordered map of keys to values. +|- +| [../javadoc/org/simantics/databoard/type/UnionType.html|UnionType] || Union +|- +| [../javadoc/org/simantics/databoard/type/BooleanType.html|BooleanType],[../javadoc/org/simantics/databoard/type/IntType.html|IntType],[../javadoc/org/simantics/databoard/type/LongType.html|LongType],[../javadoc/org/simantics/databoard/type/FloatType.html|FloatType],[../javadoc/org/simantics/databoard/type/DoubleType.html|DoubleType] +| Primitive and numeric types +|- +| [../javadoc/org/simantics/databoard/type/StringType.html|StringType] || String +|- +| [../javadoc/org/simantics/databoard/type/OptionalType.html|OptionalType] || Optional value +|- +| [../javadoc/org/simantics/databoard/type/VariantType.html|VariantType] || Variant value +|} + + +Datatype can be acquired or created using one of the following methods: +* Construct new +* Constant +* [[binding#Reflection|Reflection]]-Read from a Class +* Read from string of [[Databoard_Specification|the text notation]]. + : String - } -
+ Datatype type = new DoubleType(); + Datatype type = Datatypes.DOUBLE; + Datatype type = Datatypes.getDatatype( Double.class ); + + Datatypes.addDefinition("type Node = { id : String; children : Node[] }"); + Datatype type = Datatypes.getDatatype("Node"); ++ +==Parsing== +Datatypes are parsed using
Datatypes.DatatypeRepository
.
++ Datatypes.addDefinition("type Node = { id : String; children : Node[] }"); + Datatype type = Datatypes.getDatatype("Node"); ++ +Types are printed to types and definitions with +
+ String type = type.toString(); + + DatatypeRepository repo = new DatatypeRepository(); + repo.add("temp1", type); + String typeDef = repo.toString(); ++ +==Structure Example== +A node is a recursive type. With databoard typesystem it could be stated as +
+ type Node = { + id : String; + displayNames : LocalizedTexts; + children : Node[]; + value : Optional(Variant); + } ++ +[[Image:NodeType.png|Type presented as tree]] + + +A couple of instances with Databoard value notation: +
+ root : Node = { + id = PI_01 + displayNames = map{ en = Instrument } + children = + [ + {id=Child, + displayNames = map{ en = Child} }, + value = 5 : Integer + } + ] + value = + +[[Image:NodeInstance.png|Node values preseted as tree]] : String + } +