net.sf.ovanttasks.ovnative.win32
Class UrlFile

java.lang.Object
  extended by net.sf.ovanttasks.ovnative.win32.UrlFile

public class UrlFile
extends Object

UrlFile reads and writes Windows Shortcut files in the .url format. It can be used to create or read url files which are used by Microsoft for Shortcuts and Favorites.

see windows shortcut url urlFile format for details of the urlFile format.*

 UrlFile sf = new UrlFile(new File(Win32
                .getSpecialDirectory(Win32.SPECIALDIRECTORY_PERSONAL_DESKTOP),
                "Go to ROXES Technologies.url"));
 sf.setUrl(new URL("http://www.roxes.com"));
 sf.setIconFile("C:\\winnt\\explorer.exe");
 sf.setIconIndex(1);
 // create desktop shortcut
 sf.save();
 
 // dump created shortcut to console
 System.out.println(sf);
 
 // create favorite
 // save shortcut in internet explorer favorites directory 
 sf.save(new File(Win32
                .getSpecialDirectory(Win32.SPECIALDIRECTORY_PERSONAL_FAVORITES),
                "Go to ROXES Technologies.url"));
 

Author:
lars.gersmann@roxes.com, arnep@users.sf.net

Field Summary
static String LINE_BREAK
           
static int SHOWCOMMAND_MAXIMIZED
           
static int SHOWCOMMAND_MINIMIZED
           
static int SHOWCOMMAND_NORMAL
           
static String SIGNATURE
           
 
Constructor Summary
UrlFile(File urlFile, boolean load)
          Create a new LnkFile instance for a specified location.
UrlFile(String directory, String name, boolean load)
          Create a new UrlFile instance for a specified location.
 
Method Summary
 String getHotKey()
           
 String getIconFile()
           
 int getIconIndex()
           
 String getModified()
           
 int getShowCommand()
           
 URL getUrl()
           
 File getUrlFile()
           
 String getWorkingDirectory()
           
 void load()
           
 void save()
           
 void save(File file)
           
 void save(String directory, String name)
           
 void setHotKey(String hotKey)
           
 void setIcon(String iconFile, int iconIndex)
           
 void setModified(String string)
           
 void setShowCommand(int i)
           
 void setUrl(URL url)
           
 void setWorkingDirectory(String string)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIGNATURE

public static final String SIGNATURE
See Also:
Constant Field Values

LINE_BREAK

public static final String LINE_BREAK
See Also:
Constant Field Values

SHOWCOMMAND_NORMAL

public static final int SHOWCOMMAND_NORMAL
See Also:
Constant Field Values

SHOWCOMMAND_MAXIMIZED

public static final int SHOWCOMMAND_MAXIMIZED
See Also:
Constant Field Values

SHOWCOMMAND_MINIMIZED

public static final int SHOWCOMMAND_MINIMIZED
See Also:
Constant Field Values
Constructor Detail

UrlFile

public UrlFile(File urlFile,
               boolean load)
        throws IOException
Create a new LnkFile instance for a specified location.

If load is true the instance of LnkFile is initialized with the values from the lnkFile.

The native library is also loaded.

Parameters:
urlFile - The lnkFile to use
load - wether or not load the data from existing file.
Throws:
IOException

UrlFile

public UrlFile(String directory,
               String name,
               boolean load)
        throws IOException
Create a new UrlFile instance for a specified location.

{@link File#File(java.lang.String, java.lang.String) If load is true the instance of UrlFile is initialized with the values from the file.

The native library is also loaded.

Parameters:
directory - The parent pathname string
name - The child pathname
load - wether or not load the data from existing file.
Throws:
IOException
Method Detail

load

public void load()
          throws IOException
Throws:
IOException

getUrlFile

public File getUrlFile()

toString

public String toString()
Overrides:
toString in class Object

getIconIndex

public int getIconIndex()
Returns:
iconIndex

getModified

public String getModified()
Returns:
modified

getShowCommand

public int getShowCommand()
Returns:
showCommand (see the SHOWCOMMAND_* constants)

getUrl

public URL getUrl()
Returns:
url to open

getWorkingDirectory

public String getWorkingDirectory()
Returns:
working directory

setModified

public void setModified(String string)
Parameters:
string - modification date

setShowCommand

public void setShowCommand(int i)
Parameters:
i - the show command to use (see the SHOWCOMMAND_* constants)

setUrl

public void setUrl(URL url)
Parameters:
url - url to open

setWorkingDirectory

public void setWorkingDirectory(String string)
Parameters:
string - the working directory

save

public void save(String directory,
                 String name)
          throws IOException
Throws:
IOException

save

public void save()
          throws IOException
Throws:
IOException

save

public void save(File file)
          throws IOException
Throws:
IOException

getHotKey

public String getHotKey()

getIconFile

public String getIconFile()
Returns:
the icon urlFile

setHotKey

public void setHotKey(String hotKey)

setIcon

public void setIcon(String iconFile,
                    int iconIndex)
Parameters:
iconFile - the icon urlFile to use (valid urlFile types are exe, dll and ico)
iconIndex -


Copyright © 2008 Orangevolt. All Rights Reserved.