6 "A data type component with component name and data type"
7 @JavaType "org.simantics.databoard.type.Component"
8 @FieldNames [name, "type"]
9 data DatatypeComponent = DatatypeComponent String Datatype
11 """A data type that represents the data types supported by the Simantics
13 @JavaType "org.simantics.databoard.type.Datatype"
15 @JavaType "org.simantics.databoard.type.BooleanType"
17 | @JavaType "org.simantics.databoard.type.ByteType"
19 | @JavaType "org.simantics.databoard.type.IntegerType"
21 | @JavaType "org.simantics.databoard.type.LongType"
23 | @JavaType "org.simantics.databoard.type.FloatType"
25 | @JavaType "org.simantics.databoard.type.DoubleType"
27 | @JavaType "org.simantics.databoard.type.StringType"
29 | @JavaType "org.simantics.databoard.type.ArrayType"
30 @FieldNames [componentType]
32 | @JavaType "org.simantics.databoard.type.OptionalType"
33 @FieldNames [componentType]
35 | @JavaType "org.simantics.databoard.type.MapType"
36 @FieldNames [keyType, valueType]
37 MapType Datatype Datatype
38 | @JavaType "org.simantics.databoard.type.RecordType"
39 @FieldNames [components]
40 RecordType (Vector DatatypeComponent)
41 | @JavaType "org.simantics.databoard.type.UntionType"
42 @FieldNames [components]
43 UnionType (Vector DatatypeComponent)
44 | @JavaType "org.simantics.databoard.type.VariantType"
47 importJava "org.simantics.databoard.type.Datatype" where
50 showDatatype :: Datatype -> String
52 "Get the number of type components in an data type"
53 @JavaName getComponentCount
54 datatypeCompnentCount :: Datatype -> Integer
56 "Get a component type of a composite data type"
57 @JavaName getComponentType
58 datatypeComponentType :: Datatype -> ChildReference -> Datatype
61 instance Show Datatype where
66 importJava "org.simantics.databoard.binding.Binding" where
67 "Check whether a dynamic object is an instance of a given binding"
69 isBindingInstance :: Binding Dynamic -> Dynamic -> Boolean
71 "Create a serializable object from a textual representation"
72 parseValueDefinition :: Serializable a => String -> a
74 "Compare two serializable objects\n\nResult is -1, 0 or 1 depending the partial ordering of the objects."
76 compareObjects :: Serializable a => a -> a -> Integer
78 "The default value of a serializable type"
79 @JavaName createDefault
80 serializableDefaultValue :: Serializable a => a
82 "Create a random value of a serializable type"
83 @JavaName createRandom
84 serializableRandomValue :: Serializable a => <Random> a
86 "Get a textual representation of a serializable value"
88 showSerializable :: Serializable a => a -> String
91 @JavaName getComponent
92 getSerializableComponent_ :: Serializable a => a -> ChildReference -> Binding b -> b
94 "Get a component binding"
95 @JavaName getComponentBinding
96 getComponentBinding :: Binding a -> ChildReference -> Binding b
98 "Get a child data component of a composite serializable value"
99 getSerializableComponent :: Serializable a => Serializable b => a -> ChildReference -> b
100 getSerializableComponent object ref = getSerializableComponent_ object ref binding
104 importJava "org.simantics.databoard.serialization.Serializer" where
105 "A data serializer for SCL type a"
109 @JavaName "serialize"
110 serialize_ :: Serializer a -> a -> ByteArray
113 @JavaName "deserialize"
114 deserialize_ :: Serializer a -> ByteArray -> a
116 importJava "org.simantics.databoard.Bindings" where
118 @JavaName "getSerializer"
119 serializerOf :: Binding a -> Serializer a
123 bindingToString :: Binding a -> String
125 "Adapt between types using explicitly provided binding objects: `adapt_ value from to`"
127 adapt_ :: a -> Binding a -> Binding b -> b
129 "Adapt value from one serializable type to another"
130 adapt :: Serializable a => Serializable b => a -> b
131 adapt x = adapt_ x binding binding
133 instance Show (Binding a) where
134 show = bindingToString
136 "Serializes a value to a byte array using default serializer."
137 serialize :: Serializable a => a -> ByteArray
138 serialize v = serialize_ (serializerOf binding) v
140 "Deserializes a value from a byte array using default serializer."
141 deserialize :: Serializable a => ByteArray -> a
142 deserialize ba = deserialize_ (serializerOf binding) ba
144 importJava "org.simantics.databoard.Bindings" where
145 "Get a default binding for a given data type"
147 datatypeBinding :: Datatype -> Binding Dynamic
149 importJava "org.simantics.databoard.Datatypes" where
150 "Get a data type from a string representation"
152 translateDatatype :: String -> Datatype
154 importJava "org.simantics.databoard.binding.mutable.Variant" where
155 // data Variant (in Builtins)
156 "Create a variant using an explicitly provided binding value (unchecked cast)"
158 createVariant_ :: Binding Dynamic -> Dynamic -> Variant
160 "Get the data type of a variant object"
162 variantDatatype :: Variant -> Datatype
164 "Get raw value contained by a variant (unchecked cast)"
166 rawVariantValue :: Variant -> a
168 "Create a variant from a raw object (based on Java class)"
170 variantOf :: a -> Variant
172 "Create a variant with explicitly provided binding and value"
174 variant_ :: Binding a -> a -> Variant
176 "Get value from a variant using a given binding"
178 variantValue_ :: Variant -> Binding a -> a
182 showVariant :: Variant -> String
184 "Get a component of compound data value in a variant"
185 @JavaName getComponent
186 variantComponent :: Variant -> ChildReference -> Variant
188 "Create a variant of a given data type from an object in the default binding (unchecked, use with extreme caution)"
189 createVariant :: Datatype -> Dynamic -> Variant
190 createVariant dt v = createVariant_ (datatypeBinding dt) v
192 "Create a variant from a serializable value"
193 variant :: Serializable a => a -> Variant
194 variant v = variant_ binding v
196 "Get the value of a variant in a serializable type"
197 variantValue :: Serializable a => Variant -> a
198 variantValue v = variantValue_ v binding
200 instance Show Variant where
203 "Get an element of a compound variant value using an index reference"
204 variantElement :: Serializable a => Variant -> Integer -> a
205 variantElement v i = variantValue (variantComponent v (indexReference i))
207 importJava "org.simantics.databoard.accessor.reference.ChildReference" where
208 "A reference to a child element in a composite data type/binding or value"
211 "Combine a list of child data object references into a single path reference"
213 compileReference :: [ChildReference] -> ChildReference
215 importJava "org.simantics.databoard.accessor.reference.IndexReference" where
216 """Get a reference to a child data object using an index (zero-based)
217 * Element index of an array object
218 * Field index of a record or union type
220 * Key component of a map type/binding
221 * Component of any single-component type/binding (optional, array)
222 * Contained value/type of any single-element object (optional, union, variant)
224 * Value component of a map type/binding
227 indexReference :: Integer -> ChildReference
229 importJava "org.simantics.databoard.accessor.reference.KeyReference" where
230 """Get a reference to a MapType child data object using a given key value
231 * Contained value of a map object for a given key value
234 keyReference :: Variant -> ChildReference
236 importJava "org.simantics.databoard.accessor.reference.NameReference" where
237 """Get a reference to a child data object using a field name
238 * A component name of a record or union data type/binding
239 * "key": The key component of a map data type/binding
240 * "value": The value component of a map data type/binding
243 nameReference :: String -> ChildReference
245 importJava "org.simantics.databoard.accessor.reference.LabelReference" where
246 """Get a reference to a child data object using a label
247 * A component name of a record or union data type/binding
248 * A string representation of the index of a record or union data type/binding component
249 * "v": The component type of an array/optional data type/binding
250 * "0"/"key": The key component of a map data type/binding
251 * "1"/"value": The value component of a map data type/binding
254 labelReference :: String -> ChildReference
256 importJava "org.simantics.databoard.accessor.reference.ComponentReference" where
257 """Get a reference to a component child data object
258 * Component of an array/optional data type/binding
259 * Contained value of an optional/variant/union object
262 componentReference :: ChildReference