public static final void  main( String[] args ) throws Exception {
	try {

	String output_file = "mets.zip";
	String metadata_file = "metadata.txt";

	Vector input_filenames = new Vector();
	Vector input_filetypes = new Vector();
	Vector archive_filenames = new Vector();
	Hashtable metadata = new Hashtable();

	for( int i=0; i<args.length; i++ ) {
		if( args[i].equals( "-o" ) ) {
			i++;
			output_file = args[i];
		}

		if( args[i].equals( "-m" ) ) {
			i++;
			metadata_file = args[i];
		}
		if( args[i].equals( "-i" ) ) {
				i++;
				input_filenames.addElement( args[i] );
				i++;
				input_filetypes.addElement( args[i] );
				i++;
				archive_filenames.addElement( args[i] );
		}

		if (args[i].equals( "-h" ) ) {
			System.out.println( "Syntax: METSWriter\n\t\t[-o output-zip-file]\n\t\t[ [-i input-file-name input-mime-type mets-archive-filename] ]\n\t\t[-m metadata-file]\n" );
			System.out.println( "Supported mimetypes:" );
			ParserFactory.list();
			System.exit(1);
		}
	}

	DataParser dp = new DataParser( metadata_file );

	METSMetadata md = readMetadata( dp );

	METSWriter hate = new METSWriter( output_file );


	for( int i=0; i<input_filenames.size(); i++ ) {
				String fn = (String) input_filenames.elementAt(i);
				String ft = (String) input_filetypes.elementAt(i);
				String afn= (String) archive_filenames.elementAt(i);

			try { 
				//Parser p = ParserFactory.createParser( fn, ft, md );
				METSMetadata md2 =  ParserFactory.parse( fn, ft, md ); //p.parse();

				hate.addFile(fn , afn, ft, md2 );
			}
			catch ( Exception ex ) {
				System.out.println("Failed to parse "+fn );
				ex.printStackTrace( System.out );
			}
		}
			

	hate.setMetadata( md );

	hate.write();

	} catch ( Exception e ) {
		e.printStackTrace( System.err );
		System.exit(2);	
	}

	System.exit(0);
}