1 9 package com.vladium.emma.data; 10 11 import java.io.IOException ; 12 13 import com.vladium.util.ClassLoaderResolver; 14 import com.vladium.util.args.IOptsParser; 15 import com.vladium.emma.Command; 16 import com.vladium.emma.IAppConstants; 17 import com.vladium.emma.IAppErrorCodes; 18 import com.vladium.emma.EMMARuntimeException; 19 20 24 public 25 final class mergeCommand extends Command 26 { 27 29 public mergeCommand (final String usageToolName, final String [] args) 30 { 31 super (usageToolName, args); 32 } 33 34 public synchronized void run () 35 { 36 ClassLoader loader; 37 try 38 { 39 loader = ClassLoaderResolver.getClassLoader (); 40 } 41 catch (Throwable t) 42 { 43 loader = getClass ().getClassLoader (); 44 } 45 46 try 47 { 48 { 50 final IOptsParser parser = getOptParser (loader); 51 final IOptsParser.IOpts parsedopts = parser.parse (m_args); 52 53 { 55 final int usageRequestLevel = parsedopts.usageRequestLevel (); 56 57 if (usageRequestLevel > 0) 58 { 59 usageexit (parser, usageRequestLevel, null); 60 return; 61 } 62 } 63 64 final IOptsParser.IOpt [] opts = parsedopts.getOpts (); 65 66 if (opts == null) { 68 parsedopts.error (m_out, STDOUT_WIDTH); 69 usageexit (parser, IOptsParser.SHORT_USAGE, null); 70 return; 71 } 72 73 75 try 76 { 77 for (int o = 0; o < opts.length; ++ o) 78 { 79 final IOptsParser.IOpt opt = opts [o]; 80 final String on = opt.getCanonicalName (); 81 82 if (! processOpt (opt)) 83 { 84 if ("in".equals (on)) 85 { 86 m_datapath = getListOptValue (opt, PATH_DELIMITERS, true); 87 } 88 else if ("out".equals (on)) 89 { 90 m_outFileName = opt.getFirstValue (); 91 } 92 } 93 } 94 95 97 if (! processFilePropertyOverrides ()) return; 98 99 101 processCmdPropertyOverrides (parsedopts); 102 } 103 catch (IOException ioe) 104 { 105 throw new EMMARuntimeException (IAppErrorCodes.ARGS_IO_FAILURE, ioe); 106 } 107 108 { 110 } 111 } 112 113 { 115 final MergeProcessor processor = MergeProcessor.create (); 116 processor.setAppName (IAppConstants.APP_NAME); 118 processor.setDataPath (m_datapath); 119 processor.setSessionOutFile (m_outFileName); 120 processor.setPropertyOverrides (m_propertyOverrides); 121 122 processor.run (); 123 } 124 } 125 catch (EMMARuntimeException yre) 126 { 127 129 exit (true, yre.getMessage (), yre, RC_UNEXPECTED); return; 131 } 132 catch (Throwable t) 133 { 134 137 exit (true, "unexpected failure: ", t, RC_UNEXPECTED); return; 139 } 140 141 exit (false, null, null, RC_OK); 142 } 143 144 146 147 protected void initialize () 148 { 149 super.initialize (); 150 } 151 152 protected String usageArgsMsg () 153 { 154 return "[options]"; 155 } 156 157 159 161 162 private String [] m_datapath; private String m_outFileName; 164 165 }
| Popular Tags
|