the program ends like this:
System.out.println( "done" );
// System.exit( 0 );
} // end main
there in the class containing main. I don't see anything out of the
ordinary about it.
package com.mindprod.htmlmacros;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import com.mindprod.filter.ExtensionListFilter;
/**
* Feeds the entire Mindprod website to the Replacer macro mechanism
refreshing
* expansions of all macros. Expands HTML boilerplate refresher macros
e.g. <!--
* macro Include dogs.txt --> <!-- generated --> <img
* src="images/animals/dog.jpg" height="410" width="511" alt="dog">
<!--
* /generated by Include --> Allows arbitrary expander macro code.
Futures:
* Error messages give offset/line number, nearby text check for
generated by
* macro not just generated to remove old text. Can embed a " in a
parm by
* encoding it as "
*/
public class ReplaceMindprod extends Replacer {
/**
* True if want debugging output, counts of files gathered from
different
* dirs.
*/
private static final boolean DEBUGGING = false;
/**
* total count of files gathered
*/
private static int gatherCount;
/**
* arrayList where we build list of files to process.
*/
static ArrayList<String> filesToProcess;
/**
* Estimated files will process.
*/
public static final int ESTIMATED_TOTAL_FILES = 4500;
/**
* Collect all files in the given dirName for processing.
*
* @param dirName
* Name of fully qualified directory where to look for the
html
* files.
* @param filter
* filter to use to decide while files in that dir to
process.
*/
static void gather ( String dirName, FilenameFilter filter )
{
String[] filenames = new File( dirName ).list( filter );
if ( filenames == null )
{
throw new IllegalArgumentException(
"com.mindprod.htmlmacros.ReplaceMindprod: No such dir:
"
+ dirName );
}
gatherCount += filenames.length;
if ( DEBUGGING )
{
System.out.println( filenames.length
+ " files gathered from "
+ dirName );
}
for ( String filename : filenames )
{
filesToProcess.add( dirName + "/" + filename );
}
}
/**
* Get fully qualified name of all the files to process
*/
public static void gatherFiles ()
{
// add *.html files in mindprod
filesToProcess = new ArrayList<String>( ESTIMATED_TOTAL_FILES
);
FilenameFilter f = new ExtensionListFilter( new String[] {
"html"
} );
gather( "e:/mindprod", f );
gather( "e:/mindprod/animalrights", f );
gather( "e:/mindprod/applets", f );
gather( "e:/mindprod/applications", f );
gather( "e:/mindprod/bgloss", f );
// bookcovers
gather( "e:/mindprod/contact", f );
gather( "e:/mindprod/deepthoughts", f );
// dvdcovers
gather( "e:/mindprod/environment", f );
gather( "e:/mindprod/esperanto", f );
gather( "e:/mindprod/ethics", f );
gather( "e:/mindprod/feedback", f );
gather( "e:/mindprod/ggloss", f );
gather( "e:/mindprod/humanrights", f );
// icon
// images
// include won't work since macros in wrong dir
gather( "e:/mindprod/jgloss", f );
// jgloss/include
// kjv, rarely changes, do manually when it needs it.
gather( "e:/mindprod/livinglove", f );
gather( "e:/mindprod/livinglove/methods", f );
gather( "e:/mindprod/money", f );
// pads
gather( "e:/mindprod/phone", f );
gather( "e:/mindprod/politics", f );
gather( "e:/mindprod/politics/laser", f );
// precis
gather( "e:/mindprod/projects", f );
gather( "e:/mindprod/quadra", f );
// redir, only makes sense to expand them in place. Don't
disturb copied
// versions
gather( "e:/mindprod/redir", f );
gather( "e:/mindprod/religion", f );
// renney
// replicator
gather( "e:/mindprod/reunion", f );
// screenshots
// snippets
// sound
gather( "e:/mindprod/utilities", f );
gather( "e:/mindprod/webstarts", f );
// zips
// all files are ready to go.
}
/**
* Expands macros written in Java in HTML files files.
*
* @param args
* names of files to process, no wildcards.
*/
public static void main ( String[] args )
{
System.out.println( "\nExpanding macros on entire Mindprod
website" );
Tools.setWebRoot( "e:\\mindprod" );
gatherFiles();
System.out.println( gatherCount
+ " files gathered for mindprod site macro expansion." );
assert gatherCount <= ESTIMATED_TOTAL_FILES;
for ( String fileToProcess : filesToProcess )
{
assert fileToProcess != null;
assert new File( fileToProcess ).exists() : "file to
process missing";
try
{
expandMacrosInFile( new File( fileToProcess ), true /*
quiet */);
}
catch ( Exception e )
{
System.err.println( e.getMessage()
+ " in file "
+ fileToProcess );
System.err.println();
e.printStackTrace();
// we don't exit. We keep on processing files.
}
} // end for each file loop
System.out.println( "done" );
// don't remove the System.exit( 0 ). It bypasses a Sun bug.
System.exit( 0 );
} // end main
} // end ReplaceMindProd