Class URLDialog

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Dialog
                                   |
                                   +----URLDialog

public class URLDialog
extends Dialog
implements ActionListener
Class definition for a dialog that allows a user to choose a URL to be opened.

Version:
$Revision: 1.7 $, $Date: 2000/10/12 14:08:01 $
Author:
John Cavanaugh

Variable Index

 o CANCEL
 o currDir
Text field for displaying the current directory name.
 o DIR_SEPARATOR
 o DIR_SEPARATOR_STR
 o dirList
List of directories the user can select from.
 o fileList
List of files the user can select from.
 o isDirectory
 o OK
 o PARENT_DIR
 o parentFrame
The frame the dialog is associated with.
 o URLBase
Prefix of the URL; passed in by the parent.
 o URLFile
The file part of the URL the user selected.
 o URLPath
Vector whose elements are the directories in the path name of the selected file.

Constructor Index

 o URLDialog(Frame, String, String)
Constructs a dialog window.

Method Index

 o actionPerformed(ActionEvent)
Action for ActionListener interface; invoked when the user presses button or double-clicks on a file or directory name.
 o buildName(String, Vector, String)
Assemble a URL from the base name and a vector containing the path name components.
 o charMatch(char[], char[])
Look for a character array as a substring in another character array.
 o charScan(char[], int, char)
Assemble a string from a character array, starting at the indicated position and stopping when we come to the indicated character.
 o getDirectory()
Get the directory chosen by the user.
 o getFile()
Get the file chosen by the user.
 o getFileLists(List, List)
Read a directory and put the directory and file names into the given lists.
 o getURL()
Get the full URL chosen by the user.
 o parseLine(char[])
Parse a line from a directory, determining the type and file or directory name.
 o readLine(InputStreamReader)
Read a line from an input stream.
 o setDirectory(String)
Set the directory.

Variables

 o OK
 private static final String OK
 o CANCEL
 private static final String CANCEL
 o DIR_SEPARATOR
 private static final char DIR_SEPARATOR
 o DIR_SEPARATOR_STR
 private static final String DIR_SEPARATOR_STR
 o URLBase
 protected String URLBase
Prefix of the URL; passed in by the parent.

 o URLPath
 protected Vector URLPath
Vector whose elements are the directories in the path name of the selected file.

 o PARENT_DIR
 private static final String PARENT_DIR
 o URLFile
 protected String URLFile
The file part of the URL the user selected.

 o parentFrame
 protected Frame parentFrame
The frame the dialog is associated with.

 o currDir
 protected TextField currDir
Text field for displaying the current directory name.

 o dirList
 protected List dirList
List of directories the user can select from.

 o fileList
 protected List fileList
List of files the user can select from.

 o isDirectory
 boolean isDirectory

Constructors

 o URLDialog
 public URLDialog(Frame owner,
                  String title,
                  String dataAddr) throws MalformedURLException, IOException
Constructs a dialog window.

Parameters:
owner - The frame the dialog is associated with.
title - A title for the dialog window.
dataAddr - Starting point for the URL specification.

Methods

 o getDirectory
 public String getDirectory()
Get the directory chosen by the user.

Returns:
The name of the directory chosen by the user.
 o setDirectory
 public void setDirectory(String name) throws MalformedURLException, IOException
Set the directory.

Parameters:
name - The directory name.
 o getFile
 public String getFile()
Get the file chosen by the user.

Returns:
The name of the file chosen by the user.
 o getURL
 public String getURL()
Get the full URL chosen by the user.

Returns:
The name of the full URL chosen by the user.
 o getFileLists
 private void getFileLists(List dList,
                           List fList) throws MalformedURLException, IOException
Read a directory and put the directory and file names into the given lists.

Parameters:
dList - A list of directory names.
fList - A list of file names.
 o readLine
 private char[] readLine(InputStreamReader reader) throws IOException
Read a line from an input stream.

Parameters:
reader - The input stream reader to read from.
Returns:
A buffer containing the line of data read; null if end of file was reached.
Throws: IOException
If an I/O error occurs while reading the input stream.
 o parseLine
 private String parseLine(char buffer[])
Parse a line from a directory, determining the type and file or directory name.

Parameters:
buffer - The line to be parsed.
Returns:
The name of the file or directory; a directory name will have a slash appended.
 o charMatch
 private int charMatch(char buffer[],
                       char str[])
Look for a character array as a substring in another character array.

Parameters:
buffer - The buffer to search.
str - The substring to search for.
Returns:
The index of the first character past the end of the substring, or -1 if it was not found.
 o charScan
 private String charScan(char buffer[],
                         int start,
                         char endChar)
Assemble a string from a character array, starting at the indicated position and stopping when we come to the indicated character.

Parameters:
buffer - Buffer to take string from.
start - Character position to start the string.
endChar - Character which ends the string.
Returns:
The assembled string.
 o buildName
 private String buildName(String base,
                          Vector path,
                          String file)
Assemble a URL from the base name and a vector containing the path name components.

Parameters:
base - The base name for the URL.
path - The path name components.
file - The file name.
Returns:
The assembled URL.
 o actionPerformed
 public void actionPerformed(ActionEvent e)
Action for ActionListener interface; invoked when the user presses button or double-clicks on a file or directory name.

Parameters:
e - The event which triggered the action.