org.ceryle.ui.xnode
Class XNodeCollectionImporter

java.lang.Object
  extended by org.ceryle.ui.xnode.XNodeCollectionImporter

public class XNodeCollectionImporter
extends Object

A utility used to import the files found in a directory into an XNodeCollection. The ExtensionFileFilter controlling the file types can be supplied at instantiation time or the importer will use the default (*.txt, *.html, *.htm, and *.xml). Once run the start() method is not reentrant.

This was originally written as a Thread hence the start() method, but has since been demoted to a simple class. If the setup doesn't work or the user cancels, the start is ignored.

Filenames and Document IDs

The file extensions will be stripped from the filenames and used as IDs so long as this works: if either a conflict occurs or an ID is invalid, the user is queried for a valid ID.

Note: There is no XNode overwrite protection for this importer: this should only be used to import into a new, empty XNodeCollection.

Since:
JDK1.4
Version:
$Id: XNodeCollectionImporter.java,v 3.1 2007-06-15 12:09:53 altheim Exp $
Author:
Murray Altheim

Field Summary
static String ISO_8859_1_ENCODING
           
static int m_filecount_query_threshold
          The threshold in file count after which the user is asked whether or not to continue.
static String UTF_8_ENCODING
           
 
Constructor Summary
XNodeCollectionImporter(String cid, File dir, ExtensionFileFilter filter, Desktop desktop, ActionListener listener)
          Import the files found in directory dir into XNodeCollection cid.
 
Method Summary
 void start()
          Start the import process.
protected  String unmangleName(String filename)
          This is the reverse of JSPWiki's mangleName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_filecount_query_threshold

public static int m_filecount_query_threshold
The threshold in file count after which the user is asked whether or not to continue. The default value is 100.


ISO_8859_1_ENCODING

public static final String ISO_8859_1_ENCODING
See Also:
Constant Field Values

UTF_8_ENCODING

public static final String UTF_8_ENCODING
See Also:
Constant Field Values
Constructor Detail

XNodeCollectionImporter

public XNodeCollectionImporter(String cid,
                               File dir,
                               ExtensionFileFilter filter,
                               Desktop desktop,
                               ActionListener listener)
                        throws XNodeException,
                               IOException
Import the files found in directory dir into XNodeCollection cid. By default this imports *.txt, *.htm, *.html, and *.xml files. The ActionListener is optional.

All checks for directory writeability and such are done on construction.

Parameters:
cid - the Collection ID
dir - the source directory
filter - the optional ExtensionFileFilter to filter imported files by file extension
desktop - the application Desktop
listener - the optional ActionListener to receive an event upon completion
Throws:
IOException - if unable to locate or read from the directory
XNodeException - if unable to get the XNodeCollection or any XNodeStore failure occurs during import
Method Detail

start

public void start()
           throws IllegalStateException
Start the import process.

Throws:
IllegalStateException - if the collection has been cancelled, could not be established, or has already finished.

unmangleName

protected String unmangleName(String filename)
This is the reverse of JSPWiki's mangleName. This is identical in functionality to the like-named method in AbstractFileProvider.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.