Class Entity

  • All Implemented Interfaces:
    Dumpable
    Direct Known Subclasses:
    Configuration, EntityList

    public class Entity
    extends java.lang.Object
    implements Dumpable
    A Entity represents a node within the management tree. It may contain Property objects, as well as sub-entities. Each Entity must have a CommandRegistry where commands are registered to be performed on that Entity or their childs.
    Author:
    IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
    • Constructor Detail

      • Entity

        public Entity​(java.lang.String name,
                      java.lang.String displayName,
                      java.lang.String description,
                      java.lang.String state)
        Creates a new Entity.
        Parameters:
        name - the name of the entity.
        displayName - the display name.
        description - a description.
        state - the state (not used at the moment).
      • Entity

        protected Entity()
    • Method Detail

      • getDumpId

        public int getDumpId()
        Description copied from interface: Dumpable
        Returns a unique dump id for this object.
        Specified by:
        getDumpId in interface Dumpable
        Returns:
        unique dump id
      • isSetParent

        protected boolean isSetParent()
      • writeDump

        protected void writeDump​(java.io.DataOutput out,
                                 java.lang.String s)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readDump

        protected java.lang.String readDump​(java.io.DataInput in)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDump

        protected void writeDump​(java.io.DataOutput out,
                                 java.lang.String[] s)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readDumpStringArray

        protected java.lang.String[] readDumpStringArray​(java.io.DataInput in)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDump

        protected void writeDump​(java.io.DataOutput out,
                                 byte[] s)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readDumpByteArray

        protected byte[] readDumpByteArray​(java.io.DataInput in)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDump

        protected void writeDump​(java.io.DataOutput out,
                                 Dumpable d)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readDumpDumpable

        protected Dumpable readDumpDumpable​(java.io.DataInput in,
                                            DumpableFactory factory)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDump

        protected void writeDump​(java.io.DataOutput out,
                                 java.util.Map map)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readDumpDumpablePropMap

        protected Entity.ClonableMap readDumpDumpablePropMap​(java.io.DataInput in,
                                                             DumpableFactory factory)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readDumpDumpableEntityMap

        protected Entity.ClonableMap readDumpDumpableEntityMap​(java.io.DataInput in,
                                                               DumpableFactory factory)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeContent

        public void writeContent​(java.io.DataOutput out)
                          throws java.io.IOException
        Description copied from interface: Dumpable
        Write the content of this object to the stream.
        Specified by:
        writeContent in interface Dumpable
        Parameters:
        out - output stream
        Throws:
        java.io.IOException - if an error occurs
      • readContent

        public void readContent​(java.io.DataInput in)
                         throws java.io.IOException
        Description copied from interface: Dumpable
        Read the content of this object from the stream.
        Specified by:
        readContent in interface Dumpable
        Parameters:
        in - input stream
        Throws:
        java.io.IOException - if an error occurs
      • setImageArray

        public void setImageArray​(byte[] array)
        Internal use only.
      • getIcon

        public javax.swing.ImageIcon getIcon()
        Internal use only.
      • isDynamic

        public boolean isDynamic()
        Internal use only.
      • setDynamic

        public void setDynamic​(boolean b)
        Internal use only.
      • getUserObject

        public java.lang.Object getUserObject()
        Returns the user object.
        Returns:
        user object.
      • setUserObject

        public void setUserObject​(java.lang.Object userObject)
        Attach a user object to this entity.
        Parameters:
        userObject - user object.
      • getDynamicObject

        public java.lang.Object getDynamicObject()
        Returns the dynamic object.
        Returns:
        dynamic object.
      • setDynamicObject

        public void setDynamicObject​(java.lang.Object dynamicObject)
        Attach a dynamic object to this entity. In case this entity is dynamic (part of the usage list), and there is a dynamic object which corresponds to this entity, e.g. a connection object, this should be attached with this method.
        Parameters:
        dynamicObject - dynamic object.
      • getDynamicPropNames

        public java.lang.String[] getDynamicPropNames()
        Returns the dynamic property names.
        Returns:
        array of property names.
      • setDynamicPropNames

        public void setDynamicPropNames​(java.lang.String[] dynamicPropNames)
        Set an array of dynamic property names. These are displayed in the dynamic chart of a dynamic entity, each with a separate colored line. The type of these dynamic properties must be of Integer, and, of course, the properties must be added to this entity.
        Parameters:
        dynamicPropNames - array of property names.
      • getContext

        public java.lang.String[] getContext()
        Internal use only.
      • getDisplayContext

        public java.lang.String[] getDisplayContext()
        Internal use only.
      • createCommands

        public void createCommands()
        Creates the commands out of the command registry. Normally, this is performed automatically, except for dynamic entities.
        See Also:
        EntityList
      • getCommandRegistry

        public CommandRegistry getCommandRegistry()
        Returns the command registry.
        Returns:
        command registry.
      • getName

        public java.lang.String getName()
        Returns the entity name.
        Returns:
        entity name.
      • setName

        public void setName​(java.lang.String name)
        Set the entity name.
        Parameters:
        name - name.
      • getDisplayName

        public java.lang.String getDisplayName()
        Returns the display name.
        Returns:
        display name.
      • getDescription

        public java.lang.String getDescription()
        Returns the description.
        Returns:
        description.
      • addCommand

        public void addCommand​(java.lang.String name,
                               Command command)
        Add a command to the command registry.
        Parameters:
        name - command name.
        command - command.
      • removeCommand

        public void removeCommand​(java.lang.String name)
        Remove a command from the command registry.
        Parameters:
        name - command name.
      • getState

        public java.lang.String getState()
        Internal use only.
      • setState

        public void setState​(java.lang.String state)
        Internal use only.
      • addProperty

        public void addProperty​(java.lang.String name,
                                Property property)
        Add a property.
        Parameters:
        name - property name.
        property - property.
      • removeProperty

        public void removeProperty​(java.lang.String name)
        Remove a property.
        Parameters:
        name - property name.
      • getProperty

        public Property getProperty​(java.lang.String name)
        Returns a property.
        Parameters:
        name - property name.
        Returns:
        property.
      • getProperties

        public java.util.Map getProperties()
        Returns a Map of all properties.
        Returns:
        map of properties.
      • removeEntities

        public void removeEntities()
        Removes all Entities.
      • removeDynamicEntity

        public void removeDynamicEntity​(java.lang.Object dynamicObject)
        Removes an Entity with that dynamic object set.
        Parameters:
        dynamicObject - dynamic object.
      • getEntity

        public Entity getEntity​(java.lang.String name)
        Returns a Sub-Entity.
        Parameters:
        name - name.
        Returns:
        Entity.
      • getEntityNames

        public java.lang.String[] getEntityNames()
        Returns an array with all sub-entity names
        Returns:
        array with all sub-entity names.
      • getEntities

        public java.util.Map getEntities()
        Returns a Map with all Entities.
        Returns:
        entity map.
      • getParent

        public Entity getParent()
        Returns the parent Entity.
        Returns:
        parent Entity.
      • setParent

        protected void setParent​(Entity parent)
      • getEntityAddListener

        public EntityAddListener getEntityAddListener()
        Returns the EntityAddListener
        Returns:
        listener.
      • setEntityAddListener

        public void setEntityAddListener​(EntityAddListener entityAddListener)
        Set the EntityAddListener. There can only be 1 EntityAddListener which is responsible to verify the addition and may be throw an EntityAddException.
        Parameters:
        entityAddListener - listener.
      • getEntityRemoveListener

        public EntityRemoveListener getEntityRemoveListener()
        Returns the EntityRemoveListener
        Returns:
        listener.
      • setEntityRemoveListener

        public void setEntityRemoveListener​(EntityRemoveListener entityRemoveListener)
        Set the EntityRemoveListener. There can only be 1 EntityRemoveListener which is responsible to verify the removal and may be throw an EntityRemoveException.
        Parameters:
        entityRemoveListener - listener.
      • addEntityWatchListener

        public void addEntityWatchListener​(EntityWatchListener l)
        Adds an EntityWatchListener. There can be several of thos listeners registered at an Entity. They all are informed on addition/removal of sub-entities after the action has been performed (Entity added/removed).
        Parameters:
        l - listener.
      • removeEntityWatchListener

        public void removeEntityWatchListener​(EntityWatchListener l)
        Removes an EntityWatchListener.
        Parameters:
        l - listener.
      • notifyEntityWatchListeners

        protected void notifyEntityWatchListeners​(boolean entityAdded,
                                                  Entity entity)
      • createCopy

        public Entity createCopy()
        Internal use only.
      • isUpgrade

        public boolean isUpgrade()
      • setUpgrade

        public void setUpgrade​(boolean upgrade)
      • quote

        protected java.lang.String quote​(java.lang.String s)
      • commandIncluded

        protected boolean commandIncluded​(Command command,
                                          java.lang.String[] exclude)
      • toJson

        public java.lang.String toJson()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object