package edu.vt.marian.Document; import java.io.*; import java.net.*; import java.util.*; import edu.vt.marian.common.*; /** Unit tester for MarcDocument (and thus MarcRecord) class. @author Robert France */ public class MarcFilter { // Defaults: can be reset by command line argument. static private String docFile = null; // Default is System.in. static private String mapFile = "ansel_uni_comb.map"; static private String XmlHeader = "" + System.getProperty("line.separator") + ""; static private String XmlTrailer = ""; static private boolean writeAscii = false; static private boolean writeHtml = false; static private boolean writeTapeFormat = false; static private boolean writeXml = false; static private boolean writeOams = false; static private void showUsage() { System.err.println("usage: MarcFilter -o[achox] [ -i ] [ -m ]"); System.err.println(" -o output format:"); System.err.println(" a==ascii, h==html, c==MARC communication format,"); System.err.println(" o==OAMS, x=OAI MARC xml"); } static private int parseCommandLine(String argv[]) { for (int i=0; i"); System.out.println("
"); System.out.println("MARC Records from '" + docFile + "'"); System.out.println("
"); System.out.println(""); System.out.println("

MARC Records from '" + docFile + "'

"); System.out.println("

 

"); } if (writeXml) { System.out.println(XmlHeader); } try { while( true ) { MarcDocument doc = new MarcDocument(5104, testMap, debug); if ( (Err = doc.setFromTapeFormat(in)) != ReturnCodes.OK) { System.out.println("Error (" + Err + ") on setFromTapeFormat()."); continue; } numDocs++; if (writeAscii || writeHtml) { System.out.println("

 

"); } if (writeAscii) { if (writeHtml) { System.out.println("

Record #" + numDocs + ": MARIAN \"Long Description\" in ASCII:

"); System.out.println("
");
				}
				else
					System.out.println("Record #" + numDocs + ":  MARIAN \"Long Description\" in ASCII:");
					
				if ( (Err = doc.presentLong(DigInfObj.ASCII, bw)) != ReturnCodes.OK)
				{
					System.err.println("Error (" + Err + ") on presentLong(), doc #" + numDocs + ".");
				}
				bw.newLine();
				bw.flush();
				if (writeHtml)
				{
					System.out.println("
"); } } if (writeHtml) { System.out.println("

 

"); System.out.println("

Record #" + numDocs + ": Long description in HTML:

"); if ( (Err = doc.presentLong(DigInfObj.HTML, bw)) != ReturnCodes.OK) { System.err.println("Error (" + Err + ") on presentAsHtml(), doc #" + numDocs + "."); } bw.newLine(); bw.flush(); } if (writeTapeFormat) { if (writeHtml) { System.out.println("

 

"); System.out.println("

In Tape Format:

"); System.out.println("
");
				}
				if ( (Err = doc.presentAsTapeFormat(bw)) != ReturnCodes.OK)
				{
					System.err.println("Error (" + Err + ") on presentAsXml(), doc #" + numDocs + ".");
				}
				if (writeHtml)
				{
					System.out.println("
"); bw.newLine(); bw.newLine(); } bw.flush(); } if (writeXml) { if (writeHtml) { System.out.println("

 

"); System.out.println("

In OAI XML:

"); System.out.println("
");
				}
				if ( (Err = doc.presentAsXml(bw)) != ReturnCodes.OK)
				{
					System.err.println("Error (" + Err + ") on presentAsXml(), doc #" + numDocs + ".");
				}
				if (writeHtml)
				{
					System.out.println("
"); bw.newLine(); bw.newLine(); } bw.flush(); } if (writeOams) { if (writeHtml) { System.out.println("

 

"); System.out.println("

In OAMS:

"); System.out.println("
");
				}
				if ( (Err = doc.presentShort(DigInfObj.XML, bw)) != ReturnCodes.OK)
				{
					System.err.println("Error (" + Err + ") on presentAsXml(), doc #" + numDocs + ".");
				}
				if (writeHtml)
				{
					System.out.println("
"); bw.newLine(); bw.newLine(); } bw.flush(); } } } catch (EOFException e) { } if (writeHtml) { System.out.println(""); System.out.println(""); } if (writeXml) { System.out.println(XmlTrailer); } System.err.println("End of File."); } }