hades.manager
Class ComponentInfo

java.lang.Object
  extended byhades.manager.ComponentInfo

public class ComponentInfo
extends java.lang.Object

ComponentInfo - A class to read, write, and manager Colibri CLB data. The ComponentInfo data is used to store dependency information, author, version, name attributes, and a short description text about Hades simulation models and design files.

The information is is stored as plain text in a '.clb'-file which stands for CoLiBri or Component_Library_Browser. For loading existing and creating new information files, two different constructors are provided.

The format of the file is as follows: every information consists of a tag line and the data line(s), tags are enclosed in [], some tags are a MUST while others are optional. The currently supported tags are:

   [files x]       MUST  x lines with all filenames used by the component
   [references x]  MUST  x lines contain the URLs of all used sub-components
   [type]          MUST    the following line is the type of the component
   [archive]       OPT.    the following line is the filename of a jar-archive containing ALL the files listed here
   [start]         OPT.    name of the start class (sunw.demo.juggler.juggler)
   [init]          OPT.    the parameter of an init-method (eg. a filename)
   [icon]          OPT.    the filename of the component's icon
   [image]         OPT.    the component's (larger) image
   [html]          OPT.    the filename of a html file 
   [description]   OPT.    the following line (only one!) is a component description with encoded control chars
    


Field Summary
static boolean debug
           
 
Constructor Summary
ComponentInfo()
          Creates an empty ComponentInfo for new Components To store information call the set..() methods and finally saveComponentInfo()
ComponentInfo(java.lang.String pathname)
          Creates a new ComponentInfo and loads all the supported data out of the given file.
 
Method Summary
 void addFile(java.lang.String file)
          Add a new file that belongs to this component.
 void addReference(java.lang.String ref)
          Add a new Reference-URL.
 java.lang.String getArchive()
          Get the archive name for the component.
 java.lang.String getAuthor()
           
 java.lang.String getDescription()
          Get the description for the component.
 java.util.Vector getFiles()
          Get filenames that belong to this component.
 java.lang.String getHTML()
          Get filenames that contain html information about this component.
 javax.swing.ImageIcon getIconObject()
          Get the type-icon for the component.
 java.lang.String getIconpath()
          Get the iconpath for the component.
 java.awt.Image getImageObject()
          Get the thumbnail image for the component.
 java.lang.String getImagepath()
          Get the pathname for the thumbnail image for the component.
 java.lang.String getInit()
          Get the parameter for a possible init method (eg.
 java.lang.String getName()
           
 java.lang.String getPathname()
          return the component's "pathname" URL.
 java.util.Vector getReferences()
          Get Reference-URLs of sub-components used by this component.
 java.lang.String getStart()
          Get the start class/file for the component.
 java.lang.String getSubtype()
           
 java.lang.String getType()
          Get the type of the component.
 java.lang.String getVersion()
           
static void main(java.lang.String[] argv)
           
static void msg(java.lang.String s)
          send a msg to the Console
 boolean removeFile(java.lang.String file)
          Remove a component's file.
 boolean removeReference(java.lang.String ref)
          Remove a Reference-URL.
 void saveComponentInfo()
          Save the ComponentInfo information.
 void saveComponentInfo(java.lang.String pathname)
          Save the ComponentInfo information to the location specified.
 boolean search(java.util.Vector keys)
           
 void setArchive(java.lang.String archive)
          Set the archive name for the component.
 void setAuthor(java.lang.String author)
          Set the component's author.
 void setDescription(java.lang.String description)
          Set the description for the component.
 void setHTML(java.lang.String file)
          Set the file that contains information about this component.
 void setIconpath(java.lang.String iconpath)
          Set the iconpath for the component.
 void setImagepath(java.lang.String imagepath)
          Set the pathname for the thumbnail image for the component.
 void setInit(java.lang.String init)
          Set the parameter for a possible init method (eg.
 void setName(java.lang.String name)
           
 void setPathname(java.lang.String pathname)
           
 void setStart(java.lang.String start)
          Set the start/main class for the component.
 void setType(java.lang.String type)
          Set the type of the component.
 void setVersion(java.lang.String s)
           
 boolean showOpen()
          will return true when "Open" in context menue should be enabled
 java.lang.String toString()
          Returns the name of the component which is shown in the JTree!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Constructor Detail

ComponentInfo

public ComponentInfo()
Creates an empty ComponentInfo for new Components To store information call the set..() methods and finally saveComponentInfo()


ComponentInfo

public ComponentInfo(java.lang.String pathname)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Creates a new ComponentInfo and loads all the supported data out of the given file.

Throws:
java.io.IOException - if an Exception occurs while loading the file
java.io.FileNotFoundException
See Also:
File
Method Detail

getSubtype

public java.lang.String getSubtype()

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getPathname

public java.lang.String getPathname()
return the component's "pathname" URL. For example: zip://hades.zip?/libraries/gatelib/And2.clb file://c:/windows/temp/hades/praktikum/dlatch.clb


setPathname

public void setPathname(java.lang.String pathname)

getFiles

public java.util.Vector getFiles()
Get filenames that belong to this component.

Returns:
Vector Vector containing the filenames

addFile

public void addFile(java.lang.String file)
Add a new file that belongs to this component.

Parameters:
file - filename as String

removeFile

public boolean removeFile(java.lang.String file)
Remove a component's file.

Parameters:
file - filename
Returns:
boolean whether file was found and removed

getReferences

public java.util.Vector getReferences()
Get Reference-URLs of sub-components used by this component.

Returns:
Vector Vector containing the URLs

addReference

public void addReference(java.lang.String ref)
Add a new Reference-URL.

Parameters:
ref - Reference-URL

removeReference

public boolean removeReference(java.lang.String ref)
Remove a Reference-URL.

Parameters:
ref - Reference-URL
Returns:
boolean whether url was found and removed

getStart

public java.lang.String getStart()
Get the start class/file for the component.

Returns:
String the name of the start class/file or null if unknown

setStart

public void setStart(java.lang.String start)
Set the start/main class for the component.


getInit

public java.lang.String getInit()
Get the parameter for a possible init method (eg. a resource-filename)

Returns:
String the parameter string or null if unknown

setInit

public void setInit(java.lang.String init)
Set the parameter for a possible init method (eg. a resource-filename)

Parameters:
init - the parameter string

getType

public java.lang.String getType()
Get the type of the component.

Returns:
String a component-type (as defined in ComponentType or custom)
See Also:
ComponentType

setType

public void setType(java.lang.String type)
Set the type of the component.

Parameters:
type - a component-type (as defined in ComponentType or custom)
See Also:
ComponentType

getAuthor

public java.lang.String getAuthor()

setAuthor

public void setAuthor(java.lang.String author)
Set the component's author.

Parameters:
author - author of the component

getVersion

public java.lang.String getVersion()

setVersion

public void setVersion(java.lang.String s)

getArchive

public java.lang.String getArchive()
Get the archive name for the component. All other files are searched in this jar-archive.

Returns:
String archive name

setArchive

public void setArchive(java.lang.String archive)
Set the archive name for the component. All other files are searched in this jar-archive.

Parameters:
archive - archive name

getImagepath

public java.lang.String getImagepath()
Get the pathname for the thumbnail image for the component.

Returns:
String filename of an image

setImagepath

public void setImagepath(java.lang.String imagepath)
Set the pathname for the thumbnail image for the component.


getIconpath

public java.lang.String getIconpath()
Get the iconpath for the component. The iconpath should be a small logo of the component.

Returns:
String filename of an image

setIconpath

public void setIconpath(java.lang.String iconpath)
Set the iconpath for the component. The iconpath should be a small logo of the component.

Parameters:
iconpath - filename of an image

getDescription

public java.lang.String getDescription()
Get the description for the component. The description may contain only ASCII chars (8 bit) but can have multiple lines.

Returns:
String description as String

setDescription

public void setDescription(java.lang.String description)
Set the description for the component. The description may contain only ASCII chars (8 bit) but can have multiple lines.

Parameters:
description - text-description

getHTML

public java.lang.String getHTML()
Get filenames that contain html information about this component.

Returns:
Vector Vector containing the filenames

setHTML

public void setHTML(java.lang.String file)
Set the file that contains information about this component.

Parameters:
file - filename as String

showOpen

public boolean showOpen()
will return true when "Open" in context menue should be enabled

Returns:
(boolean) enable open in context menue

search

public boolean search(java.util.Vector keys)

getIconObject

public javax.swing.ImageIcon getIconObject()
Get the type-icon for the component. Delegate to DesignManager.

Returns:
ImageIcon Icon of this component

getImageObject

public java.awt.Image getImageObject()
Get the thumbnail image for the component. We just delegate this to DesignManager.

Returns:
Image Image of this component

saveComponentInfo

public void saveComponentInfo()
                       throws java.io.IOException
Save the ComponentInfo information. This uses the original pathname for this CLB file (if any).

Throws:
java.io.IOException - if an Exception occurs while saving the data

saveComponentInfo

public void saveComponentInfo(java.lang.String pathname)
                       throws java.io.IOException
Save the ComponentInfo information to the location specified. To follow the standard, the pathname should end with ".clb"

Parameters:
pathname - the pathname to store the information in
Throws:
java.io.IOException - if an Exception occurs while saving the data

toString

public java.lang.String toString()
Returns the name of the component which is shown in the JTree!


msg

public static void msg(java.lang.String s)
send a msg to the Console


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception