Package jcmdline

Examples of jcmdline.FileParam


  public AbstractParsedCommand validateArguments(CmdLineHandler cmdLineHandler) throws ConsoleException {
    ConcatParsedCommand parsedCommandDTO = new ConcatParsedCommand();
   
    if(cmdLineHandler != null){
      //-o
      FileParam oOption = (FileParam) cmdLineHandler.getOption(ConcatParsedCommand.O_ARG);
      if ((oOption.isSet())){
              File outFile = oOption.getFile();
              //checking extension
              ValidationUtility.assertValidPdfExtension(outFile.getName());
              parsedCommandDTO.setOutputFile(outFile)
          }else{
            throw new ParseException(ParseException.ERR_NO_O);
          }
 
      //-f -l -d
      FileParam lOption = (FileParam) cmdLineHandler.getOption(ConcatParsedCommand.L_ARG);
      PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(ConcatParsedCommand.F_ARG);
      FileParam dOption = (FileParam) cmdLineHandler.getOption(ConcatParsedCommand.D_ARG);
      if(lOption.isSet() || fOption.isSet() || dOption.isSet()){
        if(lOption.isSet() ^ fOption.isSet() ^ dOption.isSet()){
          if(fOption.isSet()){
            //validate file extensions
            for(Iterator fIterator = fOption.getPdfFiles().iterator(); fIterator.hasNext();){
              PdfFile currentFile = (PdfFile) fIterator.next();
                  if (!((currentFile.getFile().getName().toLowerCase().endsWith(PDF_EXTENSION)) && (currentFile.getFile().getName().length()>PDF_EXTENSION.length()))){
                    throw new ParseException(ParseException.ERR_IN_NOT_PDF, new String[]{currentFile.getFile().getPath()});
                  }
                }
            parsedCommandDTO.setInputFileList(FileUtility.getPdfFiles(fOption.getPdfFiles()));
          }else if(lOption.isSet()){
            if(lOption.getFile().getPath().toLowerCase().endsWith(CSV_EXTENSION) || lOption.getFile().getPath().toLowerCase().endsWith(XML_EXTENSION)){
              parsedCommandDTO.setInputCvsOrXmlFile(lOption.getFile());
            }else{
              throw new ParseException(ParseException.ERR_NOT_CSV_OR_XML);
            }
          }else{
            if ((dOption.isSet())){
                    File inputDir = dOption.getFile();
                    ValidationUtility.assertValidDirectory(inputDir);
                    parsedCommandDTO.setInputDirectory(inputDir)
                }
          }
        }else{
View Full Code Here

TOP

Related Classes of jcmdline.FileParam

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.