Package com.swiftmq.mgmt
Class Entity
- java.lang.Object
-
- com.swiftmq.mgmt.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Entity.ClonableMap
-
Field Summary
Fields Modifier and Type Field Description protected DumpableFactory
factory
static java.lang.String
SET_COMMAND
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(java.lang.String name, Command command)
Add a command to the command registry.void
addEntity(Entity entity)
Add an Entity.void
addEntityWatchListener(EntityWatchListener l)
Adds an EntityWatchListener.void
addProperty(java.lang.String name, Property property)
Add a property.protected boolean
commandIncluded(Command command, java.lang.String[] exclude)
void
createCommands()
Creates the commands out of the command registry.Entity
createCopy()
Internal use only.CommandRegistry
getCommandRegistry()
Returns the command registry.java.lang.String[]
getContext()
Internal use only.java.lang.String
getDescription()
Returns the description.java.lang.String[]
getDisplayContext()
Internal use only.java.lang.String
getDisplayName()
Returns the display name.int
getDumpId()
Returns a unique dump id for this object.java.lang.Object
getDynamicObject()
Returns the dynamic object.java.lang.String[]
getDynamicPropNames()
Returns the dynamic property names.java.util.Map
getEntities()
Returns a Map with all Entities.Entity
getEntity(java.lang.String name)
Returns a Sub-Entity.EntityAddListener
getEntityAddListener()
Returns the EntityAddListenerjava.lang.String[]
getEntityNames()
Returns an array with all sub-entity namesEntityRemoveListener
getEntityRemoveListener()
Returns the EntityRemoveListenerjavax.swing.ImageIcon
getIcon()
Internal use only.java.lang.String
getName()
Returns the entity name.Entity
getParent()
Returns the parent Entity.java.util.Map
getProperties()
Returns a Map of all properties.Property
getProperty(java.lang.String name)
Returns a property.java.lang.String
getState()
Internal use only.java.lang.Object
getUserObject()
Returns the user object.boolean
isDynamic()
Internal use only.protected boolean
isSetParent()
boolean
isUpgrade()
protected void
notifyEntityWatchListeners(boolean entityAdded, Entity entity)
protected java.lang.String
quote(java.lang.String s)
void
readContent(java.io.DataInput in)
Read the content of this object from the stream.protected java.lang.String
readDump(java.io.DataInput in)
protected byte[]
readDumpByteArray(java.io.DataInput in)
protected Dumpable
readDumpDumpable(java.io.DataInput in, DumpableFactory factory)
protected Entity.ClonableMap
readDumpDumpableEntityMap(java.io.DataInput in, DumpableFactory factory)
protected Entity.ClonableMap
readDumpDumpablePropMap(java.io.DataInput in, DumpableFactory factory)
protected java.lang.String[]
readDumpStringArray(java.io.DataInput in)
void
removeCommand(java.lang.String name)
Remove a command from the command registry.void
removeDynamicEntity(java.lang.Object dynamicObject)
Removes an Entity with that dynamic object set.void
removeEntities()
Removes all Entities.void
removeEntity(Entity entity)
Removes an Entity.void
removeEntityWatchListener(EntityWatchListener l)
Removes an EntityWatchListener.void
removeProperty(java.lang.String name)
Remove a property.void
setDynamic(boolean b)
Internal use only.void
setDynamicObject(java.lang.Object dynamicObject)
Attach a dynamic object to this entity.void
setDynamicPropNames(java.lang.String[] dynamicPropNames)
Set an array of dynamic property names.void
setEntityAddListener(EntityAddListener entityAddListener)
Set the EntityAddListener.void
setEntityRemoveListener(EntityRemoveListener entityRemoveListener)
Set the EntityRemoveListener.void
setImageArray(byte[] array)
Internal use only.void
setName(java.lang.String name)
Set the entity name.protected void
setParent(Entity parent)
void
setState(java.lang.String state)
Internal use only.void
setUpgrade(boolean upgrade)
void
setUserObject(java.lang.Object userObject)
Attach a user object to this entity.java.lang.String
toJson()
java.lang.String
toString()
void
writeContent(java.io.DataOutput out)
Write the content of this object to the stream.protected void
writeDump(java.io.DataOutput out, byte[] s)
protected void
writeDump(java.io.DataOutput out, Dumpable d)
protected void
writeDump(java.io.DataOutput out, java.lang.String s)
protected void
writeDump(java.io.DataOutput out, java.lang.String[] s)
protected void
writeDump(java.io.DataOutput out, java.util.Map map)
-
-
-
Field Detail
-
SET_COMMAND
public static final java.lang.String SET_COMMAND
- See Also:
- Constant Field Values
-
factory
protected DumpableFactory factory
-
-
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.
-
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 interfaceDumpable
- 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 interfaceDumpable
- 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.
-
addEntity
public void addEntity(Entity entity) throws EntityAddException
Add an Entity.- Parameters:
entity
- entity.- Throws:
EntityAddException
- thrown by an EntityAddListener.
-
removeEntity
public void removeEntity(Entity entity) throws EntityRemoveException
Removes an Entity.- Parameters:
entity
- entity.- Throws:
EntityRemoveException
- thrown by an EntityRemoveListener.
-
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 classjava.lang.Object
-
-