net.sourceforge.rssowl.util.shop
Class FileShop

java.lang.Object
  extended bynet.sourceforge.rssowl.util.shop.SimpleFileShop
      extended bynet.sourceforge.rssowl.util.shop.FileShop

public class FileShop
extends SimpleFileShop

Factory class for some File concerns in RSSOwl

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
 
Fields inherited from class net.sourceforge.rssowl.util.shop.SimpleFileShop
OP_ABORTED, OP_FAILED, OP_SUCCESSFULL
 
Constructor Summary
private FileShop()
          This utility class constructor is hidden
 
Method Summary
static boolean copyManifestFiles(String toPath)
          Copys java.exe.manifest and javaw.exe.manifest to the java.home/bin/ directory, if not yet copyd.
(package private) static void copyXML(String url, String dest)
          Copy a XML to another file
static boolean exists(String path)
          Check if the given Path points to an existing file.
static void exportCategory(org.eclipse.swt.widgets.Shell parent, String name, String[] format)
          Open a FileDialog for the user to choose where to export the XML holding the category(s).
static boolean exportUserSettings(org.eclipse.swt.widgets.Shell parent)
          Open a FileDialog for the user to choose where to export the "user.xml"
static String getContent(InputStream inS)
          Read the contents from an InputStream into a String.
static String getContent(URL url)
          Read the contents from an URL into a String.
static String getFilePath(org.eclipse.swt.widgets.Shell parent, String[] formats, String fileName, int style, String path)
          Get a path to a file from the user
static String getFilePath(String[] formats, String fileName, int style, String path)
          Get a path to a file from the user
static String getSavePath(String fileName, String format)
          Get the FilePath from the user to save the file
static int importUserSettings(org.eclipse.swt.widgets.Shell parent)
          Open a FileDialog for the user to choose from which file the settings should be imported
static boolean isMediumWriteable(File file)
          Test if the medium from where RSSOwl is executed is writeable
private static boolean overwrite()
          Open dialog to ask if the file should be overwritten
static void saveRSSXML(String rssUrl, String fileName)
          Open a FileDialog for the user to choose where to save the RSS XML of the selected news feed
static boolean saveSelectedNewsFeed()
          Save current selected news XML to a file
static String suggestRSSFileName(String initName)
          Suggest a filename for a RSS newsfeed with using the current date.
 
Methods inherited from class net.sourceforge.rssowl.util.shop.SimpleFileShop
copy, copy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileShop

private FileShop()
This utility class constructor is hidden

Method Detail

copyManifestFiles

public static boolean copyManifestFiles(String toPath)
Copys java.exe.manifest and javaw.exe.manifest to the java.home/bin/ directory, if not yet copyd. These files enable WinXP Look & Feel on Windows XP operating systems.

Parameters:
toPath - Path to copy to
Returns:
TRUE if the manifest files have been copied

exists

public static boolean exists(String path)
Check if the given Path points to an existing file.

Parameters:
path - The path to check.
Returns:
boolean TRUE if the File exists

exportCategory

public static void exportCategory(org.eclipse.swt.widgets.Shell parent,
                                  String name,
                                  String[] format)
                           throws IOException
Open a FileDialog for the user to choose where to export the XML holding the category(s).

Parameters:
parent - The parent Shell of the Dialog
name - Suggested name for the file
format - Preselected formats
Throws:
IOException - If an IO Error occurs

exportUserSettings

public static boolean exportUserSettings(org.eclipse.swt.widgets.Shell parent)
                                  throws IOException
Open a FileDialog for the user to choose where to export the "user.xml"

Parameters:
parent - The parent Shell of the Dialog
Returns:
boolean TRUE if the user has not canceld the dialog
Throws:
IOException - If an IO Error occurs

getContent

public static String getContent(InputStream inS)
Read the contents from an InputStream into a String.

Parameters:
inS - Any InputStream (e.g. from an URL)
Returns:
String A new String from the byte array

getContent

public static String getContent(URL url)
                         throws IOException
Read the contents from an URL into a String.

Parameters:
url - Any valid URL that is online
Returns:
String A new String from the contents of the URL
Throws:
IOException - If an error occurs

getFilePath

public static String getFilePath(org.eclipse.swt.widgets.Shell parent,
                                 String[] formats,
                                 String fileName,
                                 int style,
                                 String path)
Get a path to a file from the user

Parameters:
parent - The parent Shell of the dialog
formats - List of selectable file extensions
fileName - The preselected filename for the dialog
style - Either SWT.OPEN or SWT.SAVE
path - If not NULL browser into given directory
Returns:
String The file path

getFilePath

public static String getFilePath(String[] formats,
                                 String fileName,
                                 int style,
                                 String path)
Get a path to a file from the user

Parameters:
formats - List of selectable file extensions
fileName - The preselected filename for the dialog
style - Either SWT.OPEN or SWT.SAVE
path - If not NULL browser into given directory
Returns:
String The file path

getSavePath

public static String getSavePath(String fileName,
                                 String format)
Get the FilePath from the user to save the file

Parameters:
fileName - Preselected filename
format - Format of the file to save
Returns:
String Save path

importUserSettings

public static int importUserSettings(org.eclipse.swt.widgets.Shell parent)
                              throws IOException
Open a FileDialog for the user to choose from which file the settings should be imported

Parameters:
parent - The parent Shell of the Dialog
Returns:
int Either OP_SUCCESSFULL, OP_FAILED or OP_ABORTED as result of the operation
Throws:
IOException - If an IO Error occurs

isMediumWriteable

public static boolean isMediumWriteable(File file)
Test if the medium from where RSSOwl is executed is writeable

Parameters:
file - A file to write
Returns:
TRUE if the medium is writeable

saveRSSXML

public static void saveRSSXML(String rssUrl,
                              String fileName)
Open a FileDialog for the user to choose where to save the RSS XML of the selected news feed

Parameters:
rssUrl - URL / Path to the rss xml
fileName - Sugggest a filename with current date

saveSelectedNewsFeed

public static boolean saveSelectedNewsFeed()
Save current selected news XML to a file

Returns:
TRUE if save was successfull

suggestRSSFileName

public static String suggestRSSFileName(String initName)
Suggest a filename for a RSS newsfeed with using the current date.

Parameters:
initName - The initial name suggestion
Returns:
String The suggested filename

overwrite

private static boolean overwrite()
Open dialog to ask if the file should be overwritten

Returns:
TRUE if file should be overwritten

copyXML

static void copyXML(String url,
                    String dest)
Copy a XML to another file

Parameters:
url - URL / Path to the rss xml
dest - Path to the destinationfile


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo