Eclipse Platform
2.0

org.eclipse.update.core
Class Utilities

java.lang.Object
  |
  +--org.eclipse.update.core.Utilities

public class Utilities
extends Object

This class is a collection of utility functions that can be used for install processing


Constructor Summary
Utilities()
           
 
Method Summary
static void copy(InputStream is, OutputStream os, InstallMonitor monitor)
          Copies specified input stream to the output stream.
static File createLocalFile(File tmpDir, String key, String name)
          Create a new working file.
static File createWorkingDirectory()
          Returns a new working directory (in temporary space).
static String format(Date date)
          Formats a Date based on the default Locale If teh Date is null returns an empty String
static File lookupLocalFile(String key)
          Returns a previously cached local file (in temporary area) matching the specified key.
static CoreException newCoreException(String s, String s1, String s2, Throwable e1, Throwable e2)
          Creates a CoreException from two other exception
static CoreException newCoreException(String s, Throwable e)
          Creates a CoreException from some other exception.
static void removeLocalFile(String key)
          Removes the specified key from the local file map.
static void shutdown()
          Perform shutdown processing for temporary file handling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

createWorkingDirectory

public static File createWorkingDirectory()
                                   throws IOException
Returns a new working directory (in temporary space). Ensures the directory exists. Any directory levels that had to be created are marked for deletion on exit.

Returns:
working directory
Throws:
IOException
Since:
2.0

createLocalFile

public static File createLocalFile(File tmpDir,
                                   String key,
                                   String name)
                            throws IOException
Create a new working file. The file is marked for deletion on exit. The file is optionally associated with a lookup key.

Parameters:
tmpDir - directory location for new file. Any missing directory levels are created (and marked for deletion on exit)
key - optional lookup key, or null.
name - optional file name, or null. If name is not specified, a temporary name is generated.
Returns:
created working file
Throws:
IOException
Since:
2.0
See Also:
lookupLocalFile(String)

lookupLocalFile

public static File lookupLocalFile(String key)
Returns a previously cached local file (in temporary area) matching the specified key.

Parameters:
key - lookup key
Returns:
cached file, or null.
Since:
2.0

removeLocalFile

public static void removeLocalFile(String key)
Removes the specified key from the local file map. The file is not actually deleted until VM termination.

Parameters:
key - lookup key
Since:
2.0

copy

public static void copy(InputStream is,
                        OutputStream os,
                        InstallMonitor monitor)
                 throws IOException,
                        InstallAbortedException
Copies specified input stream to the output stream. Neither stream is closed as part of this operation.

Parameters:
is - input stream
os - output stream
monitor - progress monitor
Throws:
IOException
InstallAbortedException
Since:
2.0

newCoreException

public static CoreException newCoreException(String s,
                                             Throwable e)
Creates a CoreException from some other exception. The type of the CoreException is IStatus.ERROR If the exceptionpassed as a parameter is also a CoreException, the new CoreException will contain all the status of the passed CoreException.

Parameters:
s - exception string
e - actual exception being reported
Returns:
a CoreException
Since:
2.0
See Also:
IStatus.ERROR

newCoreException

public static CoreException newCoreException(String s,
                                             String s1,
                                             String s2,
                                             Throwable e1,
                                             Throwable e2)
Creates a CoreException from two other exception

Parameters:
s - overall exception string
s1 - string for first detailed exception
s2 - string for second detailed exception
e1 - first detailed exception
e2 - second detailed exception
Returns:
a CoreException with multi-status
Since:
2.0

format

public static String format(Date date)
Formats a Date based on the default Locale If teh Date is null returns an empty String

Parameters:
date - the Date to format
Returns:
the formatted Date as a String
Since:
2.0

shutdown

public static void shutdown()
Perform shutdown processing for temporary file handling. This method is called when platform is shutting down. It is not intended to be called at any other time under normal circumstances. A side-effect of calling this method is that the contents of the temporary directory managed by this class are deleted.

Since:
2.0

Eclipse Platform
2.0

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