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.
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.
-
archiveName
- This is the name of the resulting wizard archive class.
Deprecated.
-
baselineImageName
- The name of the baseline image (in Wizard Resource form) to place in the wizard
Deprecated.
-
cancelMsg
- The text that appears when the user presses the cancel button.
Deprecated.
-
cout
- This output stream is used if useCompression is set to true.
Deprecated.
-
exitMsg
- The text that appears when the user presses the exit button.
Deprecated.
-
iconName
- The name of the icon image (the image displayed when the wizard is minimized)
Deprecated.
-
imageName
- The name of the image (in Wizard Resource form) to place in the wizard
Deprecated.
-
nativeSupportResourceWriter
- This is the ResourceWriter responsible for adding
platform native support.
Deprecated.
-
offsetTable
- This is a table used to store offsets in the archive.
Deprecated.
-
otherResources
- Resources written by objects outside of this ArchiveWriter.
Deprecated.
-
resources
- Resources to be added to the archive.
Deprecated.
-
resourceTypes
-
A mapping between resource types, resource file extensions, and
resource paths.
Deprecated.
-
root
- This is the root of the client tree.
Deprecated.
-
systemInterface
- SystemInterface for objects interacting with the native build-time platform.
-
useCompression
- If this flag is set to true, compression will be used on all sections
of the wizard archive.
Deprecated.
-
wizardRuntimePath
- The path to the Wizard runtime classes.
Deprecated.
-
wizardState
- This is the wizardState that will be saved in the archive.
Deprecated.
-
ArchiveWriter()
- Create an ArchiveWriter with the default ArchiveReader classes
and the default RuntimeClasses set.
-
addCollection(ResourceCollection)
- Adds a resource collection.
-
addResource(String, ResourceWriter)
- Add a resource to the archive.
Deprecated.
-
addResource(String, String)
- Add a single resource to the archive.
-
addResource(String, String, String)
- Add a single resource to the archive from the specified path.
-
addResources(String, String)
- Add multiple resources from the specified relative directory
(relative to the path for this type) to the archive.
-
addResources(String, String, String)
-
Add multiple resources from the specified relative resourcePath
(relative to the specified path) to the archive.
-
addResourceType(String, String, String[])
- Add a resource type to the table.
-
addResourceVector(Vector)
- Adds the specified vector of resources to the table of
resources that will be written into the wizard archive.
-
addTypePath(String, String)
- Appends a directory to a specific type's search path.
-
countResources(Vector)
- Get the number of resources represented by the specified
resource vector.
-
createClientTree()
- Create the wizard client tree.
-
getArchiveName()
- Returns the name of this wizard archive (without the ".class" extension)
-
getBaselineImage()
- Gets the name of the baselineImage to be included in this wizard.
-
getIcon()
-
Gets the name of the icon to be included in this wizard.
-
getImage()
- Gets the name of the image to be included in this wizard.
-
getResourceFile(String, String, String[])
- getResourceFile looks at the specified directory for the
specified resource file.
-
getRoot()
- Returns the root WizardComposite object that will be written into the
wizard archive.
-
getRuntimeResources()
- This method collects the classnames of the classes required to
execute the wizard defined via the createClientTree method.
-
getWizardRuntimeClasspath()
- getWizardRuntimeClasspath looks at the classpath for the
wizard class files.
-
getWizardState()
- Returns the WizardState object that will be written into the
wizard archive.
-
searchPath(String, String)
- Utility method to search a path for a file.
-
setArchiveName(String)
- Sets the name of this archive, omitting the ".class" extension.
-
setArchiveReaderClasses()
- Populate the vector containing all of the classes necessary
to instantiate the ArchiveReader.
-
setBaselineImage(String)
- Sets the baselineImage for this product.
-
setCancelMsg(Msg)
- Set the text that will appear when the user clicks the 'cancel' button
-
setExitMsg(Msg)
- Set the text that will appear when the user clicks the 'exit' button
-
setIcon(String)
- Sets the icon for this product.
-
setImage(String)
- Sets the image for this product.
-
setResources()
- Set other resources into the archive.
-
setResourceTypes()
- Populate the resource type table.
-
setRoot(WizardComposite)
- Sets the root WizardCommposite object that will be written into the
wizard archive.
-
setRuntimeClasses()
- Populate the vector containing all of the classes necessary
to instatiate this wizard.
-
setWizardState(WizardState)
- Sets the WizardState object that will be written into the
wizard archive.
-
writeArchive()
- Write the archive file.
-
writeArchive(File)
- Write the archive file.
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.
root
protected WizardComposite root
- Note: root is deprecated.
use set/getRoot()
- This is the root of the client tree.
archiveName
protected String archiveName
- Note: archiveName is deprecated.
use set/getArchiveName()
- This is the name of the resulting wizard archive class.
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.
wizardState
protected WizardState wizardState
- Note: wizardState is deprecated.
use get/setWizardState()
- This is the wizardState that will be saved in the archive.
nativeSupportResourceWriter
protected NativeSupportResourceWriter nativeSupportResourceWriter
- Note: nativeSupportResourceWriter is deprecated.
do not use this variable
- This is the ResourceWriter responsible for adding
platform native support.
cout
protected DeflaterOutputStream cout
- Note: cout is deprecated.
do not use this variable
- This output stream is used if useCompression is set to true.
wizardRuntimePath
protected String wizardRuntimePath
- Note: wizardRuntimePath is deprecated.
use getWizardRuntimeClasspath()
- The path to the Wizard runtime classes.
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 } }
}
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.
otherResources
protected Hashtable otherResources
- Note: otherResources is deprecated.
use new ResourceCollection and ResourceResolver classes
- Resources written by objects outside of this ArchiveWriter.
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
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
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)
exitMsg
protected Msg exitMsg
- Note: exitMsg is deprecated.
use get/setExitMsg()
- The text that appears when the user presses the exit button.
cancelMsg
protected Msg cancelMsg
- Note: cancelMsg is deprecated.
use get/setCancelMsg()
- The text that appears when the user presses the cancel button.
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.
ArchiveWriter
public ArchiveWriter()
- Create an ArchiveWriter with the default ArchiveReader classes
and the default RuntimeClasses set.
addCollection
public void addCollection(ResourceCollection collection)
- Adds a resource collection.
- Parameters:
- collection - The collection to add
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
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
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
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
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.
createClientTree
protected void createClientTree()
- Create the wizard client tree. The default behavior only
provides the root of the tree.
setArchiveReaderClasses
protected void setArchiveReaderClasses()
- Populate the vector containing all of the classes necessary
to instantiate the ArchiveReader.
setRuntimeClasses
protected void setRuntimeClasses()
- Populate the vector containing all of the classes necessary
to instatiate this wizard.
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.
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 *
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
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.
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.
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:
"Images"
"Audio"
"RuntimeClasses"
"ArchiveReader"
- Parameters:
- type - The type of the resource.
- name - The name of the resource.
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:
"Images"
"Audio"
"RuntimeClasses"
"ArchiveReader"
- Parameters:
- type - The type of the resource.
- path - The path to the resource.
- name - The name of the resource.
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.
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.
getRuntimeResources
protected void getRuntimeResources()
- This method collects the classnames of the classes required to
execute the wizard defined via the createClientTree method.
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.
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)
setArchiveName
public void setArchiveName(String archiveName)
- Sets the name of this archive, omitting the ".class" extension.
- Parameters:
- archiveName - The name of this archive
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.
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.
getWizardRuntimeClasspath
public String getWizardRuntimeClasspath()
- getWizardRuntimeClasspath looks at the classpath for the
wizard class files.
- Returns:
- The absolute pathname of the specified class.
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.
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.
getImage
public String getImage()
- Gets the name of the image to be included in this wizard.
- Returns:
- The name of the image.
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.
getIcon
public String getIcon()
- Gets the name of the icon to be included in this wizard.
- Returns:
- The name of the icon.
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.
getBaselineImage
public String getBaselineImage()
- Gets the name of the baselineImage to be included in this wizard.
- Returns:
- The name of the baselineImage.
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
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
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