Eclipse Platform
2.0

org.eclipse.swt.program
Class Program

java.lang.Object
  |
  +--org.eclipse.swt.program.Program

public final class Program
extends Object

Instances of this class represent programs and their assoicated file extensions in the operating system.


Method Summary
 boolean equals(Object other)
          Returns true if the receiver and the argument represent the same program.
 boolean execute(String fileName)
          Executes the program with the file as the single argument in the operating system.
static Program findProgram(String extension)
          Finds the program that is associated with an extension.
static String[] getExtensions()
          Answer all program extensions in the operating system.
 ImageData getImageData()
          Returns the receiver's image data.
 String getName()
          Returns the receiver's name.
static Program[] getPrograms()
          Answers all available programs in the operating system.
 int hashCode()
          Returns a hash code suitable for this object.
static boolean launch(String fileName)
          Launches the executable associated with the file in the operating system.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

findProgram

public static Program findProgram(String extension)
Finds the program that is associated with an extension. The extension may or may not begin with a '.'.

Parameters:
extension - the program extension
Returns:
the program or nil
Throws:
SWTError -
  • ERROR_NULL_ARGUMENT when extension is null

getExtensions

public static String[] getExtensions()
Answer all program extensions in the operating system.

Returns:
an array of extensions

getPrograms

public static Program[] getPrograms()
Answers all available programs in the operating system.

Returns:
an array of programs

launch

public static boolean launch(String fileName)
Launches the executable associated with the file in the operating system. If the file is an executable, then the executable is launched.

Parameters:
fileName - the file or program name
Returns:
true if the file is launched, otherwise false
Throws:
SWTError -
  • ERROR_NULL_ARGUMENT when fileName is null

execute

public boolean execute(String fileName)
Executes the program with the file as the single argument in the operating system. It is the responsibility of the programmer to ensure that the file contains valid data for this program.

Parameters:
fileName - the file or program name
Returns:
true if the file is launched, otherwise false
Throws:
SWTError -
  • ERROR_NULL_ARGUMENT when fileName is null

getImageData

public ImageData getImageData()
Returns the receiver's image data. This is the icon that is associated with the reciever in the operating system.

Returns:
the image data for the program, may be null

getName

public String getName()
Returns the receiver's name. This is as short and descriptive a name as possible for the program. If the program has no descriptive name, this string may be the executable name, path or empty.

Returns:
an the name of the program

equals

public boolean equals(Object other)
Returns true if the receiver and the argument represent the same program.

Overrides:
equals in class Object
Returns:
true if the programs are the same

hashCode

public int hashCode()
Returns a hash code suitable for this object.

Overrides:
hashCode in class Object
Returns:
a hash code

toString

public String toString()
Overrides:
toString in class Object

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.