SetViewerParsedCommand parsedCommandDTO = new SetViewerParsedCommand();
if(cmdLineHandler != null){
//-o
FileParam oOption = (FileParam) cmdLineHandler.getOption(SetViewerParsedCommand.O_ARG);
if ((oOption.isSet())){
File outFile = oOption.getFile();
ValidationUtility.assertValidDirectory(outFile);
parsedCommandDTO.setOutputFile(outFile);
}else{
throw new ParseException(ParseException.ERR_NO_O);
}
//-p
StringParam pOption = (StringParam) cmdLineHandler.getOption(SetViewerParsedCommand.P_ARG);
if(pOption.isSet()){
parsedCommandDTO.setOutputFilesPrefix(pOption.getValue());
}
//-mode
StringParam mOption = (StringParam) cmdLineHandler.getOption(SetViewerParsedCommand.M_ARG);
if(mOption.isSet()){
parsedCommandDTO.setMode(getMode(mOption.getValue()));
}
//-layout
StringParam lOption = (StringParam) cmdLineHandler.getOption(SetViewerParsedCommand.L_ARG);
if(lOption.isSet()){
parsedCommandDTO.setLayout(getLayout(lOption.getValue()));
}
//-nfsmode
StringParam nfsmOption = (StringParam) cmdLineHandler.getOption(SetViewerParsedCommand.NFSM_ARG);
if(nfsmOption.isSet()){
parsedCommandDTO.setNfsmode(getNFSMode(nfsmOption.getValue()));
}
//-direction
StringParam directionOption = (StringParam) cmdLineHandler.getOption(SetViewerParsedCommand.DIRECTION_ARG);
if(directionOption.isSet()){
parsedCommandDTO.setDirection(getDirection(directionOption.getValue()));
}
//-f -d
PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(SetViewerParsedCommand.F_ARG);
FileParam dOption = (FileParam) cmdLineHandler.getOption(SetViewerParsedCommand.D_ARG);
if(fOption.isSet() || dOption.isSet()){
//-f
if(fOption.isSet()){
//validate file extensions
for(Iterator fIterator = fOption.getPdfFiles().iterator(); fIterator.hasNext();){
PdfFile currentFile = (PdfFile) fIterator.next();
ValidationUtility.assertValidPdfExtension(currentFile.getFile().getName());
}
parsedCommandDTO.setInputFileList(FileUtility.getPdfFiles(fOption.getPdfFiles()));
}
//-d
if ((dOption.isSet())){
File inputDir = dOption.getFile();
ValidationUtility.assertValidDirectory(inputDir);
parsedCommandDTO.setInputDirectory(inputDir);
}
}else{
throw new ParseException(ParseException.ERR_NO_F_OR_D);