net.jimmc.jshortcut
Class JShellLink

java.lang.Object
  |
  +--net.jimmc.jshortcut.JShellLink

public class JShellLink
extends java.lang.Object

Provide access to shortcuts (shell links) from Java. The native library (jshortcut.dll) is loaded when JShellLink is first loaded. By default, JShellLink first looks for the native library in the PATH, using System.loadLibrary. If the native library is not found in the PATH, JShellLink then looks through each directory in the CLASSPATH (as determined by the value of the system property java.class.path). If an entry in the CLASSPATH is a jar file, then JShellLink looks for the native library in the directory containing that jar file. The application can override this behavior and force JShellLink to look for the native library in a specific directory by setting the system property JSHORTCUT_HOME to point to that directory. This property must be set before the JShellLink class is loaded. This makes it possible to use this library from a self-extracting jar file.


Constructor Summary
JShellLink()
          Create a JShellLink object with no values filled in.
JShellLink(java.lang.String folder, java.lang.String name)
          Create a JShellLink object for a specified location.
 
Method Summary
 java.lang.String getArguments()
          Get the arguments for this shortcut.
 java.lang.String getDescription()
          Get the description for this shortcut.
static java.lang.String getDirectory(java.lang.String dirtype)
          Get the requested directory.
 java.lang.String getFolder()
          Get the folder for this shortcut.
 int getIconIndex()
          Get the icon index for this shortcut.
 java.lang.String getIconLocation()
          Get the icon location for this shortcut.
 java.lang.String getName()
          Get the base name for this shortcut.
 java.lang.String getPath()
          Get the path for this shortcut.
 java.lang.String getWorkingDirectory()
          Get the working directory for this shortcut.
 void load()
          Load a shortcut from disk.
 void save()
          Write out this shortcut to disk.
 void setArguments(java.lang.String arguments)
          Set the arguments for this shortcut.
 void setDescription(java.lang.String description)
          Set the description for this shortcut.
 void setFolder(java.lang.String folder)
          Set the folder for this shortcut.
 void setIconIndex(int iconIndex)
          Set the icon index for this shortcut.
 void setIconLocation(java.lang.String iconLocation)
          Set the icon location for this shortcut.
 void setName(java.lang.String name)
          Set the shortcut base name for this shortcut.
 void setPath(java.lang.String path)
          Set the path for this shortcut.
 void setWorkingDirectory(java.lang.String workingDirectory)
          Set the working directory for this shortcut.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JShellLink

public JShellLink()
Create a JShellLink object with no values filled in.


JShellLink

public JShellLink(java.lang.String folder,
                  java.lang.String name)
Create a JShellLink object for a specified location.

Method Detail

getDirectory

public static java.lang.String getDirectory(java.lang.String dirtype)
Get the requested directory.

Parameters:
dirtype - One of the following special strings:
  • common_desktopdirectory - the All Users desktop folder (not on earlier Windows)
  • common_programs - the All Users programs (not on earlier Windows)
  • desktop - the Desktop
  • personal - the My Documents folder
  • programs - the Start Menu/Programs folder
  • program_files - the Program Files folder
Returns:
The location of the special folder.

setFolder

public void setFolder(java.lang.String folder)
Set the folder for this shortcut.


getFolder

public java.lang.String getFolder()
Get the folder for this shortcut.


setName

public void setName(java.lang.String name)
Set the shortcut base name for this shortcut.


getName

public java.lang.String getName()
Get the base name for this shortcut.


setDescription

public void setDescription(java.lang.String description)
Set the description for this shortcut.


getDescription

public java.lang.String getDescription()
Get the description for this shortcut.


setPath

public void setPath(java.lang.String path)
Set the path for this shortcut. If the working directory is null, this call also sets the working directory to the parent of the given path.


getPath

public java.lang.String getPath()
Get the path for this shortcut.


setArguments

public void setArguments(java.lang.String arguments)
Set the arguments for this shortcut.


getArguments

public java.lang.String getArguments()
Get the arguments for this shortcut.


setWorkingDirectory

public void setWorkingDirectory(java.lang.String workingDirectory)
Set the working directory for this shortcut.


getWorkingDirectory

public java.lang.String getWorkingDirectory()
Get the working directory for this shortcut.


setIconLocation

public void setIconLocation(java.lang.String iconLocation)
Set the icon location for this shortcut.


getIconLocation

public java.lang.String getIconLocation()
Get the icon location for this shortcut.


setIconIndex

public void setIconIndex(int iconIndex)
Set the icon index for this shortcut.


getIconIndex

public int getIconIndex()
Get the icon index for this shortcut.


load

public void load()
Load a shortcut from disk.


save

public void save()
Write out this shortcut to disk.