Class KnowledgeSlot

  • All Implemented Interfaces:
    java.io.Serializable

    public class KnowledgeSlot
    extends java.lang.Object
    implements java.io.Serializable
    Class used to store knowledge in the KnowledgeBase. A KnowledgeSlot can store an object, but also any number of children KnowledgeSlots. This hierarchical composition of KnowledgeSlots builds up the KnowledgeBase and allows fast indexing and search of properties.
    Author:
    Joao Dias
    See Also:
    KnowledgeBase, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      KnowledgeSlot​(java.lang.String name)
      Creates an empty KnowledgeSpot, identified by the received name
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears all the information stored in the KnowledgeSlot (including all its children)
      boolean containsKey​(java.lang.String key)
      Determines if this KnowledgeSlot has a child with a specific key
      int CountElements()
      Counts the number of valid elements (ones that have a value stored in them) stored within this KnowledgeSlot (may include children, grandchildren, grandgrandchildren, etc).
      KnowledgeSlot get​(java.lang.String key)
      Gets the child KnowledgeSlot identified by the given key
      java.util.Iterator<java.lang.String> getKeyIterator()
      Gets an Iterator that iterates over the set of existing child Keys
      java.util.Set<java.lang.String> getKeys()  
      java.lang.String getName()
      Gets the KnowledgeSlot identifier
      java.lang.Object getValue()
      Gets the object stored in the KnowledgeSlot
      void put​(java.lang.String key, KnowledgeSlot kSlot)
      Adds a KS child to the KnowledgeSlot
      void remove​(java.lang.String key)
      Removes a child from the KnowledgeSlot
      void setValue​(java.lang.Object object)
      Sets the object stored in the KnowledgeSlot
      java.lang.String toString()
      Converts the KnowledgeSlot to a String
      java.lang.String toXML()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • KnowledgeSlot

        public KnowledgeSlot​(java.lang.String name)
        Creates an empty KnowledgeSpot, identified by the received name
        Parameters:
        name - - the name that identifies the KnowledgeSlot
    • Method Detail

      • clear

        public void clear()
        Clears all the information stored in the KnowledgeSlot (including all its children)
      • containsKey

        public boolean containsKey​(java.lang.String key)
        Determines if this KnowledgeSlot has a child with a specific key
        Parameters:
        key - - the key of the child to search
        Returns:
        true if the KnowledgeSlot contains a child with the received key
      • get

        public KnowledgeSlot get​(java.lang.String key)
        Gets the child KnowledgeSlot identified by the given key
        Parameters:
        key - - the key of the child to get
        Returns:
        the child KnowledgeSlot
      • getKeys

        public java.util.Set<java.lang.String> getKeys()
      • getKeyIterator

        public java.util.Iterator<java.lang.String> getKeyIterator()
        Gets an Iterator that iterates over the set of existing child Keys
        Returns:
        the key Iterator
      • getName

        public java.lang.String getName()
        Gets the KnowledgeSlot identifier
        Returns:
        the KnowledgeSlot ID
      • getValue

        public java.lang.Object getValue()
        Gets the object stored in the KnowledgeSlot
        Returns:
        the object stored in the KS
      • CountElements

        public int CountElements()
        Counts the number of valid elements (ones that have a value stored in them) stored within this KnowledgeSlot (may include children, grandchildren, grandgrandchildren, etc).
        Returns:
        the number of elements stored inside the KnowledgeSlot
      • put

        public void put​(java.lang.String key,
                        KnowledgeSlot kSlot)
        Adds a KS child to the KnowledgeSlot
        Parameters:
        key - - the Key of the KnowledgeSlot to ADD
        kSlot - - the KnowledgeSlot to ADD
      • remove

        public void remove​(java.lang.String key)
        Removes a child from the KnowledgeSlot
        Parameters:
        key - - the key of the child to remove
      • setValue

        public void setValue​(java.lang.Object object)
        Sets the object stored in the KnowledgeSlot
        Parameters:
        object - - the new object to store in the KnowledgeSlot
      • toString

        public java.lang.String toString()
        Converts the KnowledgeSlot to a String
        Overrides:
        toString in class java.lang.Object
        Returns:
        the converted String
      • toXML

        public java.lang.String toXML()