All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.wizards.builder.ArchiveWriter

java.lang.Object
   |
   +----com.sun.wizards.builder.ArchiveWriter

public class ArchiveWriter
extends Object
ArchiveWriter is responsible for creating a wizard archive with native support from the local filesystem.

The wizard archive consists of a ClassLoader (com.sun.wizards.builder.ArchiveClassLoader) which has a class attribute that contains the Java classes and information required to execute the wizard.

You can either subclass ArchiveWriter, or you can maintain one as an instance variable in a containing class. A subclass of ArchiveWriter can be written to define specifically what the wizard will contain.

Graphic of the first panel of the simple wizard.

Graphic of the second panel of the simple wizard.

Here is the code for this wizard builder (using the subclass construction):


 import com.sun.wizards.core.WizardState;
 import com.sun.wizards.core.WizardComposite;
 import com.sun.wizards.builder.ArchiveWriter;
 import com.sun.wizards.panels.*;
 public class SimpleWizardBuilder extends ArchiveWriter
 {
       public SimpleWizardBuilder()
       {
	    super();
	    setArchiveName("simpleWizard");
       }
       protected void createClientTree()
       {
	    super.createClientTree();
	    WizardState wizardState = getWizardState();
	    WizardComposite root = getRoot();
	    // Create the client panels.
	    TextImagePanel firstPanel = new TextImagePanel(wizardState, "First Panel");
	    firstPanel.addText("This is the first panel in the simple wizard.",
	                        0, 25);
	    TextImagePanel secondPanel = new TextImagePanel(wizardState, "Second Panel");
	    secondPanel.addText("This is the second panel in the simple wizard.",
                             0, 25);
         // Add the panels to the wizard.
	    root.addChild(firstPanel);
	    root.addChild(secondPanel);
       }
       public static void main(String[] args)
       {
	    SimpleWizardBuilder builder = new SimpleWizardBuilder();
	    builder.writeArchive();
       }
 }
 

In order to create the wizard from the SimpleWizardBuilder code above, compile and run SimpleWizardBuilder.java. The result of running the SimpleWizardBuilder is a class file called "simpleWizard.class". This class represents a composite of the com.sun.wizards.builder.ArchiveClassLoader and all of the runtime classes required to execute the wizard.

If you did not want to subclass, but simply include an instantiation of this class, you could do the following:


 import com.sun.wizards.core.WizardState;
 import com.sun.wizards.core.WizardComposite;
 import com.sun.wizards.builder.ArchiveWriter;
 import com.sun.wizards.panels.*;
 public class SimpleWizardBuilder2 
 {
       // an instance variable that manages the wizard
       private ArchiveWriter writer = new ArchiveWriter();
     public SimpleWizardBuilder2()
     {
       writer.setArchiveName("simpleWizard2");
     }
     private void configureWizard()
     {
	  WizardState wizardState = writer.getWizardState();
	  WizardComposite root = writer.getRoot();
	  // Create the client panels.
	  TextImagePanel firstPanel = new TextImagePanel(wizardState, "First Panel");
	  firstPanel.addText("This is the first panel in the simple wizard.",
			     0, 25);
	  TextImagePanel secondPanel = new TextImagePanel(wizardState, "Second Panel");
	  secondPanel.addText("This is the second panel in the simple wizard.",
			     0, 25);
	  // Add the panels to the wizard.
	  root.addChild(firstPanel);
	  root.addChild(secondPanel);
     }
     private void writeWizard()
     {
	  // first configure the wizard
	  configureWizard();
	  // now write the archive
	  writer.writeArchive();
     }
     public static void main(String[] args)
     {
	  SimpleWizardBuilder2 builder = new SimpleWizardBuilder2();
	  builder.writeWizard();
     }
 }
 

Notice the differences. In the first case (an is-a relationship), we are overriding certain methods that get called by the superclass to configure the wizard. In the second case (a has-a relationship), we are explicitly calling the methods of the object.


Variable Index

 o archiveName
This is the name of the resulting wizard archive class. Deprecated.
 o baselineImageName
The name of the baseline image (in Wizard Resource form) to place in the wizard Deprecated.
 o cancelMsg
The text that appears when the user presses the cancel button. Deprecated.
 o cout
This output stream is used if useCompression is set to true. Deprecated.
 o exitMsg
The text that appears when the user presses the exit button. Deprecated.
 o iconName
The name of the icon image (the image displayed when the wizard is minimized) Deprecated.
 o imageName
The name of the image (in Wizard Resource form) to place in the wizard Deprecated.
 o nativeSupportResourceWriter
This is the ResourceWriter responsible for adding platform native support. Deprecated.
 o offsetTable
This is a table used to store offsets in the archive. Deprecated.
 o otherResources
Resources written by objects outside of this ArchiveWriter. Deprecated.
 o resources
Resources to be added to the archive. Deprecated.
 o resourceTypes
A mapping between resource types, resource file extensions, and resource paths. Deprecated.
 o root
This is the root of the client tree. Deprecated.
 o systemInterface
SystemInterface for objects interacting with the native build-time platform.
 o useCompression
If this flag is set to true, compression will be used on all sections of the wizard archive. Deprecated.
 o wizardRuntimePath
The path to the Wizard runtime classes. Deprecated.
 o wizardState
This is the wizardState that will be saved in the archive. Deprecated.

Constructor Index

 o ArchiveWriter()
Create an ArchiveWriter with the default ArchiveReader classes and the default RuntimeClasses set.

Method Index

 o addCollection(ResourceCollection)
Adds a resource collection.
 o addResource(String, ResourceWriter)
Add a resource to the archive. Deprecated.
 o addResource(String, String)
Add a single resource to the archive.
 o addResource(String, String, String)
Add a single resource to the archive from the specified path.
 o addResources(String, String)
Add multiple resources from the specified relative directory (relative to the path for this type) to the archive.
 o addResources(String, String, String)
Add multiple resources from the specified relative resourcePath (relative to the specified path) to the archive.
 o addResourceType(String, String, String[])
Add a resource type to the table.
 o addResourceVector(Vector)
Adds the specified vector of resources to the table of resources that will be written into the wizard archive.
 o addTypePath(String, String)
Appends a directory to a specific type's search path.
 o countResources(Vector)
Get the number of resources represented by the specified resource vector.
 o createClientTree()
Create the wizard client tree.
 o getArchiveName()
Returns the name of this wizard archive (without the ".class" extension)
 o getBaselineImage()
Gets the name of the baselineImage to be included in this wizard.
 o getIcon()
Gets the name of the icon to be included in this wizard.
 o getImage()
Gets the name of the image to be included in this wizard.
 o getResourceFile(String, String, String[])
getResourceFile looks at the specified directory for the specified resource file.
 o getRoot()
Returns the root WizardComposite object that will be written into the wizard archive.
 o getRuntimeResources()
This method collects the classnames of the classes required to execute the wizard defined via the createClientTree method.
 o getWizardRuntimeClasspath()
getWizardRuntimeClasspath looks at the classpath for the wizard class files.
 o getWizardState()
Returns the WizardState object that will be written into the wizard archive.
 o searchPath(String, String)
Utility method to search a path for a file.
 o setArchiveName(String)
Sets the name of this archive, omitting the ".class" extension.
 o setArchiveReaderClasses()
Populate the vector containing all of the classes necessary to instantiate the ArchiveReader.
 o setBaselineImage(String)
Sets the baselineImage for this product.
 o setCancelMsg(Msg)
Set the text that will appear when the user clicks the 'cancel' button
 o setExitMsg(Msg)
Set the text that will appear when the user clicks the 'exit' button
 o setIcon(String)
Sets the icon for this product.
 o setImage(String)
Sets the image for this product.
 o setResources()
Set other resources into the archive.
 o setResourceTypes()
Populate the resource type table.
 o setRoot(WizardComposite)
Sets the root WizardCommposite object that will be written into the wizard archive.
 o setRuntimeClasses()
Populate the vector containing all of the classes necessary to instatiate this wizard.
 o setWizardState(WizardState)
Sets the WizardState object that will be written into the wizard archive.
 o writeArchive()
Write the archive file.
 o writeArchive(File)
Write the archive file.

Variables

 o useCompression
 protected boolean useCompression
Note: useCompression is deprecated. use setCompression()

If this flag is set to true, compression will be used on all sections of the wizard archive.

 o root
 protected WizardComposite root
Note: root is deprecated. use set/getRoot()

This is the root of the client tree.

 o archiveName
 protected String archiveName
Note: archiveName is deprecated. use set/getArchiveName()

This is the name of the resulting wizard archive class.

 o offsetTable
 protected Hashtable offsetTable
Note: offsetTable is deprecated. do not use this variable

This is a table used to store offsets in the archive. This table will be written near the end of the archive, and serve as a lookup table for named sections in the archive.

 o wizardState
 protected WizardState wizardState
Note: wizardState is deprecated. use get/setWizardState()

This is the wizardState that will be saved in the archive.

 o nativeSupportResourceWriter
 protected NativeSupportResourceWriter nativeSupportResourceWriter
Note: nativeSupportResourceWriter is deprecated. do not use this variable

This is the ResourceWriter responsible for adding platform native support.

 o cout
 protected DeflaterOutputStream cout
Note: cout is deprecated. do not use this variable

This output stream is used if useCompression is set to true.

 o wizardRuntimePath
 protected String wizardRuntimePath
Note: wizardRuntimePath is deprecated. use getWizardRuntimeClasspath()

The path to the Wizard runtime classes.

 o resourceTypes
 protected Hashtable resourceTypes
Note: resourceTypes is deprecated. do not use this variable, use get/setResourceType()

A mapping between resource types, resource file extensions, and resource paths. The file extensions and resource paths are only used at archive build time. The hashtable is of the following form:
  Hashtable {
    [Type1]  <-->  Vector{ String(path1), String[] { extension 1_1, extension 1_2, ..., extension 1_N } }
    [Type2]  <-->  Vector{ String(path2), String[] { extension 2_1, extension 2_2, ..., extension 2_N } }
    [...]    <-->  [...]
    [TypeN]  <-->  Vector{ String(pathN), String[] { extension N_1, extension N_2, ..., extension N_N } }
  }
 

 o resources
 protected Hashtable resources
Note: resources is deprecated. do not use this variable, instead use the various addResource() and addResources() methods

Resources to be added to the archive. Resources include any type of file or other information required to execute the wizard.

 o otherResources
 protected Hashtable otherResources
Note: otherResources is deprecated. use new ResourceCollection and ResourceResolver classes

Resources written by objects outside of this ArchiveWriter.

 o imageName
 protected String imageName
Note: imageName is deprecated. use get/SetImage()

The name of the image (in Wizard Resource form) to place in the wizard

 o baselineImageName
 protected String baselineImageName
Note: baselineImageName is deprecated. use get/setBaselineImage()

The name of the baseline image (in Wizard Resource form) to place in the wizard

 o iconName
 protected String iconName
Note: iconName is deprecated. use get/setIcon()

The name of the icon image (the image displayed when the wizard is minimized)

 o exitMsg
 protected Msg exitMsg
Note: exitMsg is deprecated. use get/setExitMsg()

The text that appears when the user presses the exit button.

 o cancelMsg
 protected Msg cancelMsg
Note: cancelMsg is deprecated. use get/setCancelMsg()

The text that appears when the user presses the cancel button.

 o systemInterface
 public static SystemInterface systemInterface
SystemInterface for objects interacting with the native build-time platform. Any object that needs to interact with the buildtime platform can use this static field to do so.

Constructors

 o ArchiveWriter
 public ArchiveWriter()
Create an ArchiveWriter with the default ArchiveReader classes and the default RuntimeClasses set.

Methods

 o addCollection
 public void addCollection(ResourceCollection collection)
Adds a resource collection.

Parameters:
collection - The collection to add
 o getWizardState
 public WizardState getWizardState()
Returns the WizardState object that will be written into the wizard archive.

Returns:
The wizard state that will be written into the archive
 o setWizardState
 public void setWizardState(WizardState state)
Sets the WizardState object that will be written into the wizard archive.

Parameters:
state - The wizard state that will be written into the archive
 o getRoot
 public WizardComposite getRoot()
Returns the root WizardComposite object that will be written into the wizard archive.

Returns:
The wizard state that will be written into the archive
 o setRoot
 public void setRoot(WizardComposite newRoot)
Sets the root WizardCommposite object that will be written into the wizard archive.

Parameters:
newRoot - The WizardComposite that will be written into the archive
 o setResourceTypes
 protected void setResourceTypes()
Populate the resource type table. See the field description for information on the format of this table. If you override this method, be sure to call super.setResourceTypes(). You should only add to each type's path and possible extensions or else you will risk not gathering resources.

 o createClientTree
 protected void createClientTree()
Create the wizard client tree. The default behavior only provides the root of the tree.

 o setArchiveReaderClasses
 protected void setArchiveReaderClasses()
Populate the vector containing all of the classes necessary to instantiate the ArchiveReader.

 o setRuntimeClasses
 protected void setRuntimeClasses()
Populate the vector containing all of the classes necessary to instatiate this wizard.

 o setResources
 protected void setResources()
Set other resources into the archive. Subclasses should override this method to set images, audio files, or other runtime resources to the archive.

 o addResourceType
 public void addResourceType(String type,
                             String path,
                             String extensions[])
Add a resource type to the table. For example, one might specify:
 addResourceType("MyAudioFiles", "/home/audio:/usr/local/audiop", new String[] {".wav", ".au", ".s3m"})
 
Note the unix-specific path string. If you plan on building your wizard on any platform, you would want to use the File.separator and File.pathSeparator constructions.

Parameters:
type - The type of the resource. Default types include:
  • RuntimeClasses
  • Images
  • Audio
path - The buildtime path to search for resources of this type
extensions - A list of valid extensions for this type. Fo *
 o addTypePath
 public void addTypePath(String type,
                         String directory) throws IllegalArgumentException
Appends a directory to a specific type's search path. If the type does not exist, an exception is thrown.

Parameters:
type - The type of resource that we should search for files in the specified directory for
directory - The directory to append to the specified type's search path
 o addResources
 public void addResources(String type,
                          String resourcePath)
Add multiple resources from the specified relative directory (relative to the path for this type) to the archive. The previously specified path (via addResourceType()) is used to search for the resources, at the relative offset specified by the resourcePath. All resources of the specified type that lie in the specified resource Path are added to the archive.

As an example, suppose you had previously added a type to the wizard archive using:

 addResourceType("MyFiles", new String[] {"c:\a;c:\b;c:\c", ".myfiles"});
 
Then, you could add all files with the extension .myfiles by doing this:
 addResources("MyFiles", "/home/dad/hisfiles");
 
This would add all files from the c:\a, c:\b, and c:\c directories with the extension of .myfiles.

Parameters:
type - The type of the resources.
resourcePath - The path to the resources.
 o addResources
 public void addResources(String type,
                          String path,
                          String resourcePath)
Add multiple resources from the specified relative resourcePath (relative to the specified path) to the archive. All resources of the specified type that lie in the specified resource Path are added to the archive. If the resource is not found at the specified path, the search path for that type is searched.

Parameters:
type - The type of the resources.
path - The path to the resource tree.
resourcePath - The path to the resources.
 o addResource
 public void addResource(String type,
                         String name)
Add a single resource to the archive. The type argument specifies what type of resource is being added. The predefined path for this type is searched to find the resource. Only the first one found with the correct name is added. The name is the resource name of the resource to add. Predefined resource types include:

Parameters:
type - The type of the resource.
name - The name of the resource.
 o addResource
 public void addResource(String type,
                         String path,
                         String name)
Add a single resource to the archive from the specified path. The type argument specifies what type of resource is being added. Predefined resource types include:

Parameters:
type - The type of the resource.
path - The path to the resource.
name - The name of the resource.
 o searchPath
 public static String searchPath(String path,
                                 String filename)
Utility method to search a path for a file.

Parameters:
path - The pathSeparator-separated path to search.
filename - The relative filename to search for within the supplied PATH
Returns:
The full path to the file (not including the filename), if it is found, or null if the file is not found.
 o addResource
 public void addResource(String name,
                         ResourceWriter writer)
Note: addResource() is deprecated. use new ResourceCollection ResourceResolver classes

Add a resource to the archive. At buildtime, this ResourceWriter will be called upon to write its contents to the archive.

Parameters:
name - The name of the resource.
writer - The object that will write the resource data into the archive.
 o getRuntimeResources
 protected void getRuntimeResources()
This method collects the classnames of the classes required to execute the wizard defined via the createClientTree method.

 o addResourceVector
 protected void addResourceVector(Vector resourceVector)
Adds the specified vector of resources to the table of resources that will be written into the wizard archive.

Parameters:
resourceVector - The vector containing wizard resource name(s). Each element of this array can be one of the following types:
  • String[] - If the length is two, the element is assumed to be of the form:
        {path, resource name}
        
    The supplied path will be used to locate the resource. If the supplied path is null, the wizard runtime package path is assumed.
  • String - If the element is a String, the string is assumed to be the name of the resource. The CLASSPATH will be searched to find the resource.
 o getArchiveName
 public String getArchiveName()
Returns the name of this wizard archive (without the ".class" extension)

Returns:
the name of this wizard archive (without the ".class" extension)
 o setArchiveName
 public void setArchiveName(String archiveName)
Sets the name of this archive, omitting the ".class" extension.

Parameters:
archiveName - The name of this archive
 o writeArchive
 public void writeArchive()
Write the archive file. The output of this method is a classfile named [archiveName].class. If that classfile already exists, it will be deleted and the new archive will be written.

The [archiveName].class file is the wizard archive, and can be executed by running the class through the Java virtual machine.

 o writeArchive
 public void writeArchive(File archiveFile)
Write the archive file. The output of this method is a classfile named [archiveName].class. If that classfile already exists, it will be deleted and the new archive will be written.

The [archiveName].class file is the wizard archive, and can be executed by running the class through the Java virtual machine.

Parameters:
out - The outputstream to which the wizard archive will be written.
 o getWizardRuntimeClasspath
 public String getWizardRuntimeClasspath()
getWizardRuntimeClasspath looks at the classpath for the wizard class files.

Returns:
The absolute pathname of the specified class.
 o getResourceFile
 public String getResourceFile(String path,
                               String resourceName,
                               String extensions[])
getResourceFile looks at the specified directory for the specified resource file.

Parameters:
path - The path to the resource file.
resourceName - The dot-separated name of the resource file to find.
extensions - The possible extensions that the resource might have. Only the first resource found will be returned.
Returns:
The absolute pathname of the specified resource.
 o setImage
 public void setImage(String imageName)
Sets the image for this product. The image will appear on the left side of the wizard. It should be specified in wizard resource form ([packageName].[imagename_without_extension]). It is recommended that this image be 120 pixels wide x 290 pixels long. Make sure you include your image in the resource collections (by overriding setResources()) or your image will not be included in the archive!

Parameters:
imageName - The name of the image, in wizard resource form.
 o getImage
 public String getImage()
Gets the name of the image to be included in this wizard.

Returns:
The name of the image.
 o setIcon
 public void setIcon(String iconName)
Sets the icon for this product. The icon will appear on the left side of the wizard. It should be specified in wizard resource form ([packageName].[imagename_without_extension]) Make sure you include your image in the resource collections (by overriding setResources()) or your image will not be included in the archive!

Parameters:
iconName - The name of the icon, in wizard resource form. It is recommended that this image be 48 pixels square.
 o getIcon
 public String getIcon()
Gets the name of the icon to be included in this wizard.

Returns:
The name of the icon.
 o setBaselineImage
 public void setBaselineImage(String baselineImage)
Sets the baselineImage for this product. The baselineImage will appear below the console image on the left side of the wizard. It should be specified in wizard resource form ([packageName].[imagename_without_extension]). It is recommended that this image be 120 pixels wide x 30 pixels long.Make sure you include your image in the resource collections (by overriding setResources()) or your image will not be included in the archive!

Parameters:
baselineImage - The name of the baselineImage, in wizard resource form.
 o getBaselineImage
 public String getBaselineImage()
Gets the name of the baselineImage to be included in this wizard.

Returns:
The name of the baselineImage.
 o setExitMsg
 public void setExitMsg(Msg exitMsg)
Set the text that will appear when the user clicks the 'exit' button

Parameters:
exitMsg - The localized Msg that should appear when the user presses the "Exit" Button. If no text is supplied via this method, then the wizard will not prompt the user when the exit button is pressed, and simply exit. If text is supplied, it will be localized at runtime Using the correct locale resource bundle, by using the Msg class to produce the desired localized text.
See Also:
Msg
 o setCancelMsg
 public void setCancelMsg(Msg cancelMsg)
Set the text that will appear when the user clicks the 'cancel' button

Parameters:
cancelMsg - The localized Msg that should appear when the user presses the "Cancel" Button. If no text is supplied via this method, then the wizard will not prompt the user when the cancel button is pressed, and simply cancel whatever it was doing at the time. If text is supplied, it will be localized using the correct runtime locale resource bundle and the supplied key.
See Also:
Msg
 o countResources
 public static short countResources(Vector resourceVector)
Get the number of resources represented by the specified resource vector.

Parameters:
resourceVector - The vector containing resources to be counted.

All Packages  Class Hierarchy  This Package  Previous  Next  Index