Class ReteNode

    • Field Detail

      • typenodes

        protected java.util.Map typenodes
        The type nodes.
      • typenodesets

        protected java.util.Map typenodesets
        Matching nodes for each (sub)type (cached for speed).
      • indirectnodesets

        protected volatile java.util.Map indirectnodesets
        Indirectly affected nodes for an attribute type (cached for speed).
      • initialfact

        protected InitialFactNode initialfact
        The initial fact node (if any).
      • terminalnodes

        protected java.util.Map terminalnodes
        The terminal nodes (IRule -> Node).
      • builder

        protected ReteBuilder builder
        The rete builder.
      • relevants

        protected volatile AttributeSet relevants
        The set of relevant attributes.
      • check

        protected boolean check
        Do a consistency check after each state change (requires asserts).
      • nodecounter

        protected int nodecounter
        The node counter in this network.
      • inited

        protected boolean inited
        For debugging: node is inited and network must not be changed anymore.
      • changecnt

        protected int changecnt
      • checked

        protected java.util.List checked
    • Constructor Detail

      • ReteNode

        public ReteNode()
        Create a new rete system.
        Parameters:
        state - The state.
    • Method Detail

      • addObject

        public void addObject​(java.lang.Object id,
                              OAVObjectType type,
                              IOAVState state,
                              ReteMemory mem,
                              AbstractAgenda agenda)
        Tell the condition system about a new object in the state.
        Parameters:
        object - The new object.
      • removeObject

        public void removeObject​(java.lang.Object id,
                                 OAVObjectType type,
                                 IOAVState state,
                                 ReteMemory mem,
                                 AbstractAgenda agenda)
        Tell the condition system about a removed object in the state.
        Parameters:
        object - The removed object.
      • modifyObject

        public void modifyObject​(java.lang.Object id,
                                 OAVObjectType type,
                                 OAVAttributeType attr,
                                 java.lang.Object oldvalue,
                                 java.lang.Object newvalue,
                                 IOAVState state,
                                 ReteMemory mem,
                                 AbstractAgenda agenda)
        Tell the condition system about a modified object in the state.
        Parameters:
        object - The new object.
      • modifyIndirectObject

        public void modifyIndirectObject​(java.lang.Object object,
                                         OAVAttributeType type,
                                         java.lang.Object oldvalue,
                                         java.lang.Object newvalue,
                                         IOAVState state,
                                         ReteMemory mem,
                                         AbstractAgenda agenda)
        Propagate an indirect object change to this node.
        Specified by:
        modifyIndirectObject in interface INode
        Parameters:
        object - The changed object.
      • addRule

        public void addRule​(IRule rule)
        Add a rule to the network.
        Parameters:
        rule - The rule to add.
      • removeRule

        public void removeRule​(IRule rule)
        Remove a rule from the network.
        Parameters:
        rule - The rule to remove.
      • putTerminalNode

        public void putTerminalNode​(TerminalNode node)
        Set the terminal node for a rule.
        Parameters:
        rule - The rule.
        node - The node.
      • getTerminalNode

        public TerminalNode getTerminalNode​(IRule rule)
        Set the terminal node for a rule.
        Parameters:
        rule - The rule.
        node - The node.
      • getNodeCount

        public int getNodeCount()
        Get the number of nodes in the network.
        Returns:
        The number of nodes.
      • getTypeNode

        public TypeNode getTypeNode​(OAVObjectType type)
        Get the node for a type.
        Parameters:
        type - The type.
        Returns:
        The type node (if any).
      • getInitialFactNode

        public InitialFactNode getInitialFactNode()
        Get the initial fact node (if any).
      • createNodeMemory

        public java.lang.Object createNodeMemory​(IOAVState state)
        Create the node memory.
        Specified by:
        createNodeMemory in interface INode
        Parameters:
        state - The state.
        Returns:
        The node memory.
      • getIndirectAttributes

        public AttributeSet getIndirectAttributes()
        Get the set of indirect attribute types. I.e. attributes of objects, which are not part of an object conditions (e.g. for chained extractors)
        Specified by:
        getIndirectAttributes in interface INode
        Returns:
        The relevant attribute types.
      • getBuilder

        public ReteBuilder getBuilder()
        Get the builder.
        Returns:
        The rete builder.
      • getTypeNodes

        protected java.util.Set getTypeNodes​(OAVObjectType type)
        Get the set of matching type nodes for a (sub)type.
        Parameters:
        type - The object type.
        Returns:
        The set of type nodes for that object type.
      • getIndirectNodes

        protected java.util.Set getIndirectNodes​(OAVAttributeType attrtype,
                                                 OAVTypeModel tmodel)
        Get the set of indirectly affected nodes for an attribute type.
        Parameters:
        attrtype - The attribute type.
        tmodel - The OAV type model.
        Returns:
        The set of indirectly affected nodes for that attribute type.
      • doClone

        protected void doClone​(java.lang.Object theclone)
        Do clone makes a deep clone without regarding cycles.
        Specified by:
        doClone in class AbstractNode
        Parameters:
        clone - The clone.
      • checkConsistency

        protected boolean checkConsistency​(ReteMemory mem)
        Check consistency of Rete network/memory. For debugging. Only performs some simple checks and does not assure complete consistency.
      • getNextNodeId

        public int getNextNodeId()
        Get the next nodecounter.
        Returns:
        The id for the next node.
      • setInited

        public void setInited​(boolean inited)
        Set the inited state.