Eclipse Platform
Release 3.0

org.eclipse.update.core
Class Utilities

java.lang.Object
  extended byorg.eclipse.update.core.Utilities

public class Utilities
extends Object

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

Note: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


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 name)
          Create a new working file.
static File createWorkingDirectory()
          Returns a new working directory (in temporary space).
static void flushLocalFile()
          Flushes all the keys from the local file map.
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 void mapLocalFile(String key, File temp)
          The file is associated with a lookup key.
static CoreException newCoreException(String s, int code, Throwable e)
          Creates a CoreException from some other exception.
static CoreException newCoreException(String s, String s1, String s2, CoreException e1, CoreException e2)
          Creates a CoreException from two other CoreException
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 name)
                            throws IOException
Create a new working file. The file is marked for deletion on exit.

Parameters:
tmpDir - directory location for new file. Any missing directory levels are created (and marked for deletion on exit)
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)

mapLocalFile

public static void mapLocalFile(String key,
                                File temp)
The file is associated with a lookup key.

Parameters:
key - optional lookup key, or null.
temp - the local working file
Since:
2.0.2

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

flushLocalFile

public static void flushLocalFile()
Flushes all the keys from the local file map. Reinitialize the cache.

Since:
2.1

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,
                                             int code,
                                             Throwable e)
Creates a CoreException from some other exception. The type of the CoreException is IStatus.ERROR If the exception passed as a parameter is also a CoreException, the new CoreException will contain all the status of the passed CoreException.

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

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,
                                             CoreException e1,
                                             CoreException e2)
Creates a CoreException from two other CoreException

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
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.