X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.simulator.variable%2Fsrc%2Forg%2Fsimantics%2Fsimulator%2Fvariable%2FNodeManager.java;h=27bf8c51b4d03757db7d7e98dec8fdf66acb30a6;hp=345aff81f82e88771156ff69b5f19c67901719f0;hb=3c17e1a55c108f120808016dd5e4d3893c29c0e8;hpb=066c758d34f60a9da4e7b2387689475de1a9cf84 diff --git a/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/NodeManager.java b/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/NodeManager.java index 345aff81f..27bf8c51b 100644 --- a/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/NodeManager.java +++ b/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/NodeManager.java @@ -36,112 +36,114 @@ import org.simantics.simulator.variable.exceptions.NotInRealmException; */ public interface NodeManager { - // --- Do not require a realm access --- - - /** - * The realm of the node manager. Almost all other methods - * of this class must be called inside this realm. - */ - Realm getRealm(); - - /** - * Returns the name of the node. This method does not require - * that caller is in realm. - */ - String getName(Node node); - - /** - * Adds a listener to a certain node. The new listener is called as - * soon as possible (for example before simulator takes the next simulation - * step). After the first call, it is called always the node value - * or structure may have changed. This can be called outside of the realm. - */ - void addNodeListener(Node node, Runnable listener); - - /** - * Removes previously added listener. This can be called outside of - * the realm. - */ - void removeNodeListener(Node node, Runnable listener); - - // --- Require a realm access --- - - /** - * @return {@code null} if node cannot be found, otherwise a node with the given path - * @throws InvalidPathException if the path is not in a valid path format - * @throws NotInRealmException if not synchronized to the realm - */ - Node getNode(String path) throws NodeManagerException; - /** - * @return {@code null} if node cannot be found, otherwise a child node with the given name - * @throws NotInRealmException if not synchronized to the realm - */ - Node getChild(Node node, String name) throws NodeManagerException; - Node getProperty(Node node, String name) throws NodeManagerException; - List getChildNames(Node node) throws NodeManagerException; - List getPropertyNames(Node node) throws NodeManagerException; - List getChildren(Node node) throws NodeManagerException; - List getProperties(Node node) throws NodeManagerException; - - /** - * @throws NoValueException if the node has no value (and therefore no datatype) - * @throws NotInRealmException if not synchronized to the realm - */ - Datatype getDatatype(Node node) throws NodeManagerException; - /** - * @throws NoValueException if the node has no value - * @throws BindingException if the value can not be bound to the given binding - * @throws NotInRealmException if not synchronized to the realm - */ - Object getValue(Node node, Binding binding) throws NodeManagerException, BindingException; - /** - * A variant of {@link #getValue(Object, Binding)} that uses - * a binding chosen by the node manager. - */ - Variant getValue(Node node) throws NodeManagerException; - /** - * @throws NoSuchNodeException if the property does not exist - * @throws NoValueException if the property has no value - * @throws NotInRealmException if not synchronized to the realm - * @throws BindingException if the value can not be bound to the given binding - */ - Object getValue(Node node, String property, Binding binding) throws NodeManagerException, BindingException; - /** - * A variant of {@link #getValue(Object, String, Binding)} that uses - * a binding chosen by the node manager. - */ - Variant getValue(Node node, String property) throws NodeManagerException; - - /** - * @throws BindingException if the value can not be bound to the given binding - * @throws NoValueException if the property has no value that could be assigned - * @throws NotInRealmException if not synchronized to the realm - */ - void setValue(Node node, Object value, Binding binding) throws NodeManagerException, BindingException; - /** - * @throws BindingException if the value can not be bound to the given binding - * @throws NoSuchNodeException if the property does not exist - * @throws NoValueException if the property has no value that could be assigned - * @throws NotInRealmException if not synchronized to the realm - */ - void setValue(Node node, String property, Object value, Binding binding) throws NodeManagerException, BindingException; - - /** - * Asks the full URI of a property node. The parent of the property is also given as a parameter. - * This is an optional method, NodeManager does not have to implement it for all nodes. - */ + public static final Variant PENDING_NODE_VALUE = new Variant(); + + // --- Do not require a realm access --- + + /** + * The realm of the node manager. Almost all other methods + * of this class must be called inside this realm. + */ + Realm getRealm(); + + /** + * Returns the name of the node. This method does not require + * that caller is in realm. + */ + String getName(Node node); + + /** + * Adds a listener to a certain node. The new listener is called as + * soon as possible (for example before simulator takes the next simulation + * step). After the first call, it is called always the node value + * or structure may have changed. This can be called outside of the realm. + */ + void addNodeListener(Node node, Runnable listener); + + /** + * Removes previously added listener. This can be called outside of + * the realm. + */ + void removeNodeListener(Node node, Runnable listener); + + // --- Require a realm access --- + + /** + * @return {@code null} if node cannot be found, otherwise a node with the given path + * @throws InvalidPathException if the path is not in a valid path format + * @throws NotInRealmException if not synchronized to the realm + */ + Node getNode(String path) throws NodeManagerException; + /** + * @return {@code null} if node cannot be found, otherwise a child node with the given name + * @throws NotInRealmException if not synchronized to the realm + */ + Node getChild(Node node, String name) throws NodeManagerException; + Node getProperty(Node node, String name) throws NodeManagerException; + List getChildNames(Node node) throws NodeManagerException; + List getPropertyNames(Node node) throws NodeManagerException; + List getChildren(Node node) throws NodeManagerException; + List getProperties(Node node) throws NodeManagerException; + + /** + * @throws NoValueException if the node has no value (and therefore no datatype) + * @throws NotInRealmException if not synchronized to the realm + */ + Datatype getDatatype(Node node) throws NodeManagerException; + /** + * @throws NoValueException if the node has no value + * @throws BindingException if the value can not be bound to the given binding + * @throws NotInRealmException if not synchronized to the realm + */ + Object getValue(Node node, Binding binding) throws NodeManagerException, BindingException; + /** + * A variant of {@link #getValue(Object, Binding)} that uses + * a binding chosen by the node manager. + */ + Variant getValue(Node node) throws NodeManagerException; + /** + * @throws NoSuchNodeException if the property does not exist + * @throws NoValueException if the property has no value + * @throws NotInRealmException if not synchronized to the realm + * @throws BindingException if the value can not be bound to the given binding + */ + Object getValue(Node node, String property, Binding binding) throws NodeManagerException, BindingException; + /** + * A variant of {@link #getValue(Object, String, Binding)} that uses + * a binding chosen by the node manager. + */ + Variant getValue(Node node, String property) throws NodeManagerException; + + /** + * @throws BindingException if the value can not be bound to the given binding + * @throws NoValueException if the property has no value that could be assigned + * @throws NotInRealmException if not synchronized to the realm + */ + void setValue(Node node, Object value, Binding binding) throws NodeManagerException, BindingException; + /** + * @throws BindingException if the value can not be bound to the given binding + * @throws NoSuchNodeException if the property does not exist + * @throws NoValueException if the property has no value that could be assigned + * @throws NotInRealmException if not synchronized to the realm + */ + void setValue(Node node, String property, Object value, Binding binding) throws NodeManagerException, BindingException; + + /** + * Asks the full URI of a property node. The parent of the property is also given as a parameter. + * This is an optional method, NodeManager does not have to implement it for all nodes. + */ String getPropertyURI(Node parent, Node property); - /** - * Asks for the classifications of a property node. - * This is an optional method, NodeManager does not have to implement it for all nodes. - * A default implementation should just return {@link Collections#emptySet()}. - * Classifications can be any strings, however a recommended interpretation is to return - * the URIs of the primary ontological types that this node corresponds to. - * - * @param node the node to classify - * @return classifications of the node, empty set if the node has no classifications - */ - Set getClassifications(Node node) throws NodeManagerException; + /** + * Asks for the classifications of a property node. + * This is an optional method, NodeManager does not have to implement it for all nodes. + * A default implementation should just return {@link Collections#emptySet()}. + * Classifications can be any strings, however a recommended interpretation is to return + * the URIs of the primary ontological types that this node corresponds to. + * + * @param node the node to classify + * @return classifications of the node, empty set if the node has no classifications + */ + Set getClassifications(Node node) throws NodeManagerException; } \ No newline at end of file