ace.xmlparsers
Class ParseACEZipFile

java.lang.Object
  extended by ace.xmlparsers.ParseACEZipFile

public class ParseACEZipFile
extends java.lang.Object

Contains methods to zip and unzip the componant XML files of an ACE project.

This class uses the java.util.zip package to compress and decompress the componant files of an ACE project. A special file called project.sp is used internally to specify the path to the ACE XML project file and both are included in the zip file. The ACE XML project file will specify the pathnames to the ACE XML files that were compressed in the zip file. It is with the ACE XML project file that one is able to associate the different files of the extracted zip file with the different types of ACE datatypes/XML files (Taxonomy, Feature Key, Feature vectors, and etc). This ACE XML project file will be written automatically if one was not written already.


Constructor Summary
ParseACEZipFile()
           
 
Method Summary
static void add(java.lang.String zip_file, java.lang.String file_path)
          Adds a single ACE XML file to an existing ACE project zip folder.
static java.lang.String[] extract(java.lang.String file_name, java.lang.String zip_file, java.lang.String file_type, java.lang.String destpath)
          Extracts the specified file(s) from the given zip file.
static java.lang.String parseZip(java.lang.String zipfile, java.lang.String destination)
          Coordinates the the extraction of an ACE project zip file.
static void saveZip(java.lang.String[] files2, java.lang.String name)
          Saves all of the given files into a compressed zipfile.
static void saveZip(java.lang.String project_path, java.lang.String project_name)
          Given the path to an ACE XML project file and the name of this ACE project, this method retrieves the paths to the componant ACE XML files contained in the project file and then calls the other saveZip method to save them all in a zip file.
static void saveZip(java.lang.String taxonomy_path, java.lang.String[] feature_defs_paths, java.lang.String[] data_set_paths, java.lang.String[] classification_paths, java.lang.String[] other_paths, java.lang.String project_name)
          Saves an ACE project in a zip file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseACEZipFile

public ParseACEZipFile()
Method Detail

parseZip

public static java.lang.String parseZip(java.lang.String zipfile,
                                        java.lang.String destination)
                                 throws java.lang.Exception
Coordinates the the extraction of an ACE project zip file.

After the zip file is extracted, a new ACE XML project file is written specifying the paths to the newly extracted files.

Parameters:
zipfile - Specifies the path to the zip file that the user wishes to extract
destination - Specifies the path to the folder to which the contents of the zip file will be extracted
Returns:
project_file_path Specifies the path to the ACE XML project file after extraction (not absolute).
Throws:
java.lang.Exception - Throws an exception if an error occurs

saveZip

public static void saveZip(java.lang.String taxonomy_path,
                           java.lang.String[] feature_defs_paths,
                           java.lang.String[] data_set_paths,
                           java.lang.String[] classification_paths,
                           java.lang.String[] other_paths,
                           java.lang.String project_name)
                    throws java.lang.Exception
Saves an ACE project in a zip file

Given the paths to all componant ACE XML files, this method combines all files into a compressed Zip file. An ACE XML project file will written to specify the given file paths and will be included in the zip file. All files to be included in the zip file are combined into one array before being passed to method compress.

Parameters:
taxonomy_path - Specifies the path to the taxonomy file for the ACE project.
classification_paths - Specifies the path(s) to the classification file(s) for the ACE project.
feature_defs_paths - Specifies the path(s) to the feature definitions/key file(s) for the ACE project.
data_set_paths - Specifies the path(s) to the data set/feature vectors file(s) for the ACE project.
other_paths - Specifies the path(s) to any other (non ACE XML) files that the user wishes to compress.
project_name - This will be the name of the compressed zip file and the ACE XML project file (with extensions .zip and .xml respectively).
Throws:
java.lang.Exception - If no files are specified to be zipped.

saveZip

public static void saveZip(java.lang.String project_path,
                           java.lang.String project_name)
                    throws java.lang.Exception
Given the path to an ACE XML project file and the name of this ACE project, this method retrieves the paths to the componant ACE XML files contained in the project file and then calls the other saveZip method to save them all in a zip file.

Parameters:
project_path - Specifies the path to the ACE XML Project file
project_name - Specifies the name of the project. This will be the name of the new zip file.
Throws:
java.lang.Exception - If an error occurs

saveZip

public static void saveZip(java.lang.String[] files2,
                           java.lang.String name)
                    throws java.lang.Exception
Saves all of the given files into a compressed zipfile.

Parameters:
files2 - The files to be compressed.
name - The name of the zipfile into which the files will be saved.
Throws:
java.lang.Exception - If an error occurs.

extract

public static java.lang.String[] extract(java.lang.String file_name,
                                         java.lang.String zip_file,
                                         java.lang.String file_type,
                                         java.lang.String destpath)
                                  throws java.lang.Exception
Extracts the specified file(s) from the given zip file.

If file_type is not null, all files of that file type contained in the zip file will be extracted. Otherwise, the single file specified by file_name will be extracted.

Parameters:
file_name - If file_type is null, this specifies the name of the single file to be extracted from the zip_file.
zip_file - Specifies the path to the zip file containing the file(s) to be extracted
file_type - Can be either "project_file", "taxonomy_file", "feature_key_file", "feature_vector_file", or "classifications_file". If filetype is not one of these Strings, an exception will be thrown.
destpath - Specifies the directory into which the file(s) should be extracted.
Returns:
The array of paths to the specified filetype. example: if file type is feature_vectors, this method will return the array of paths to all the feature vectors specified in this ACE project zip file. If filetype is Taxonomy (a project may only have one taxonomy) or if only a single file was specified to be extracted, an array of size 1 will be returned.
Throws:
java.lang.Exception - If incorrect filetype is specified

add

public static void add(java.lang.String zip_file,
                       java.lang.String file_path)
                throws java.lang.Exception
Adds a single ACE XML file to an existing ACE project zip folder.

*note*: In the event that a taxonomy file is specified to be added, any previously stored taxonomy file will be discarded. The file will not be deleted but it will no longer be a part of this ACE project. With any other ACE XMl file type, the new file is simply added to the appropriate array.

Parameters:
file_type - Specifies the type of ACE XML file to be added. This can be either: "taxonomy", "feature_settings", "feature_vectors", or "classifications"
zip_file - Specifies the path to the zip file to which the file specified in file_path is to be added.
file_path - Specifies the path to the file to be added to the zip file
Throws:
java.lang.Exception - If invalid filetype is specified.