Package org.pdfsam.console.exceptions.console

Examples of org.pdfsam.console.exceptions.console.ParseException


        CmdLineHandler cmdLineHandler = cmdHandler.getCommandLineHandler();
        log.debug("Starting arguments parsing.");
        if (cmdLineHandler != null) {
          retVal = cmdLineHandler.parse(inputArguments);
          if (!retVal) {
            throw new ParseException(ParseException.ERR_PARSE, new String[] { cmdLineHandler.getParseError() });
          }
        } else {
          throw new ConsoleException(ConsoleException.CMD_LINE_HANDLER_NULL);
        }
      } else {
View Full Code Here


      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(SlideShowParsedCommand.P_ARG);
          if(pOption.isSet()){
            parsedCommandDTO.setOutputFilesPrefix(pOption.getValue());
          }

          //-f
          PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(SlideShowParsedCommand.F_ARG);          
          if(fOption.isSet()){
            PdfFile inputFile = fOption.getPdfFile();
            ValidationUtility.assertValidPdfExtension(inputFile.getFile().getName())
              parsedCommandDTO.setInputFile(FileUtility.getPdfFile(inputFile));                 
          }else{
            throw new ParseException(ParseException.ERR_NO_F)
          }
         
          //-t
          StringParam tOption = (StringParam) cmdLineHandler.getOption(SlideShowParsedCommand.T_ARG);
          if(tOption.isSet()){
            HashSet transitionsList = new HashSet(tOption.getValues().size());
            for(Iterator tIterator = tOption.getValues().iterator(); tIterator.hasNext();){
              String transition = (String) tIterator.next();
              Transition transitionObject = stringToTransition(transition);
              if(!transitionsList.add(transitionObject)){
                throw new SlideShowException(SlideShowException.UNABLE_TO_ADD_TRANSITION, new String[]{transition,transitionObject.toString()});
              }
            }
            parsedCommandDTO.setTransitions((Transition[])transitionsList.toArray(new Transition[transitionsList.size()]));
          }
         
          //-dt
          StringParam dtOption = (StringParam) cmdLineHandler.getOption(SlideShowParsedCommand.DT_ARG);
          if(dtOption.isSet()){
            parsedCommandDTO.setDefaultTransition(stringToTransition(dtOption.getValue()));
          }
         
          //-l
          FileParam lOption = (FileParam) cmdLineHandler.getOption(SlideShowParsedCommand.L_ARG);
          if(lOption.isSet()){
            if(lOption.getFile().getPath().toLowerCase().endsWith(XML_EXTENSION)){
          parsedCommandDTO.setInputXmlFile(lOption.getFile());
        }else{
          throw new ParseException(ParseException.ERR_NOT_XML);
        }
          }
         
          //-fullscreen
          parsedCommandDTO.setFullScreen(((BooleanParam) cmdLineHandler.getOption(SlideShowParsedCommand.FULLSCREEN_ARG)).isTrue());
View Full Code Here

      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(RotateParsedCommand.P_ARG);
          if(pOption.isSet()){
View Full Code Here

        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);
        }
           
            //-hidemenu
            parsedCommandDTO.setHideMenu(((BooleanParam) cmdLineHandler.getOption(SetViewerParsedCommand.HIDEMENU_ARG)).isTrue());
            //-hidetoolbar
View Full Code Here

      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(DecryptParsedCommand.P_ARG);
          if(pOption.isSet()){
View Full Code Here

      if ((oOption.isSet())){
              File outFile = oOption.getFile();
              ValidationUtility.assertValidDirectory(outFile);
              parsedCommandDTO.setOutputFile(outFile)
          }else{
            throw new ParseException(ParseException.ERR_NO_O);
          }
     
      //-f and -d
      PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(UnpackParsedCommand.F_ARG);
          FileParam dOption = (FileParam) cmdLineHandler.getOption(UnpackParsedCommand.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);
      }
    }else{
      throw new ConsoleException(ConsoleException.CMD_LINE_HANDLER_NULL);
    }
    return parsedCommandDTO; 
View Full Code Here

      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(SplitParsedCommand.P_ARG);
          if(pOption.isSet()){
            parsedCommandDTO.setOutputFilesPrefix(pOption.getValue());
          }

          //-f
          PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(SplitParsedCommand.F_ARG);          
          if(fOption.isSet()){
            PdfFile inputFile = fOption.getPdfFile();
            ValidationUtility.assertValidPdfExtension(inputFile.getFile().getName());
              parsedCommandDTO.setInputFile(FileUtility.getPdfFile(inputFile));                 
          }else{
            throw new ParseException(ParseException.ERR_NO_F)
          }

          //-s
          StringParam sOption = (StringParam) cmdLineHandler.getOption(SplitParsedCommand.S_ARG);
          if(sOption.isSet()){
            parsedCommandDTO.setSplitType(sOption.getValue());
          }else{
            throw new ParseException(ParseException.ERR_NO_S)
          }
         
          //-b
          LongParam bOption = (LongParam) cmdLineHandler.getOption(SplitParsedCommand.B_ARG);         
          if(SplitParsedCommand.S_SIZE.equals(parsedCommandDTO.getSplitType())){
            if(bOption.isSet()){     
              parsedCommandDTO.setSplitSize(new Long(bOption.longValue()));
            }else{
              throw new ParseException(ParseException.ERR_NO_B);
            }
          }else{
            if(bOption.isSet()){
              throw new ParseException(ParseException.ERR_B_NOT_NEEDED);
              }
          }
         
          //-bl
          IntParam blOption = (IntParam) cmdLineHandler.getOption(SplitParsedCommand.BL_ARG);         
          if(SplitParsedCommand.S_BLEVEL.equals(parsedCommandDTO.getSplitType())){
            if(blOption.isSet()){     
              parsedCommandDTO.setBookmarksLevel(new Integer(blOption.intValue()));
            }else{
              throw new ParseException(ParseException.ERR_NO_BL);
            }
          }else{
            if(blOption.isSet()){
              throw new ParseException(ParseException.ERR_BL_NOT_NEEDED);
              }
          }

          //-n        
          StringParam nOption = (StringParam) cmdLineHandler.getOption("n");
          if(SplitParsedCommand.S_NSPLIT.equals(parsedCommandDTO.getSplitType()) || SplitParsedCommand.S_SPLIT.equals(parsedCommandDTO.getSplitType())){
             if(nOption.isSet()){
               String nValue = nOption.getValue().trim().replaceAll(",","-").replaceAll(" ","-");
               if(SplitParsedCommand.S_NSPLIT.equals(parsedCommandDTO.getSplitType())){                
                 Pattern p = Pattern.compile("([0-9]+)*");
                         if (!(p.matcher(nValue).matches())){
                           throw new ParseException(ParseException.ERR_N_NOT_NUM);
                         }
                   }
               if(SplitParsedCommand.S_SPLIT.equals(parsedCommandDTO.getSplitType())){                
                 Pattern p = Pattern.compile("([0-9]+)([-][0-9]+)*");
                         if (!(p.matcher(nValue).matches())){
                           throw new ParseException(ParseException.ERR_N_NOT_NUM_OR_SEQ);
                         }
                   }
               parsedCommandDTO.setSplitPageNumbers(getSplitPageNumbers(nValue));
            }else{
                  throw new ParseException(ParseException.ERR_NO_N);
              }                      
          }else{
            if(nOption.isSet()){
              throw new ParseException(ParseException.ERR_N_NOT_NEEDED);
              }
          }
    }else{
      throw new ConsoleException(ConsoleException.CMD_LINE_HANDLER_NULL);
    }
View Full Code Here

      String[] limits = nValue.split("-");
      for(int i=0; i<limits.length; i++){
        retVal.add(new Integer(limits[i]));
        }
    }catch(NumberFormatException nfe){     
      throw new ParseException(ParseException.ERR_N_NOT_NUM_OR_SEQ, nfe);
    }
    return (Integer[]) retVal.toArray(new Integer[0]);
  }
View Full Code Here

              File outFile = oOption.getFile();
              //checking extension
              ValidationUtility.assertValidPdfExtension(outFile.getName());
              parsedCommandDTO.setOutputFile(outFile)
          }else{
            throw new ParseException(ParseException.ERR_NO_O);
          }

          //-f
          PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption("f");          
          if(fOption.isSet()){
            PdfFile inputFile = fOption.getPdfFile();
            ValidationUtility.assertValidPdfExtension(inputFile.getFile().getName());
              parsedCommandDTO.setInputFile(FileUtility.getPdfFile(inputFile));                 
          }else{
            throw new ParseException(ParseException.ERR_NO_F)
          }
         
          Map labels = new TreeMap();
          //-l
          StringParam lOption = (StringParam) cmdLineHandler.getOption(PageLabelsParsedCommand.L_ARG);
View Full Code Here

        // checking extension
        ValidationUtility.assertValidPdfExtension(outFile.getName());
        parsedCommandDTO.setOutputFile(outFile);

      } else {
        throw new ParseException(ParseException.ERR_NO_O);
      }
     
      //-f
          PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(DocumentInfoParsedCommand.F_ARG);          
          if(fOption.isSet()){
            PdfFile inputFile = fOption.getPdfFile();
            ValidationUtility.assertValidPdfExtension(inputFile.getFile().getName());
              parsedCommandDTO.setInputFile(FileUtility.getPdfFile(inputFile));                 
          }else{
            throw new ParseException(ParseException.ERR_NO_F)
          }
         
          //-author
          StringParam authorOption = (StringParam) cmdLineHandler.getOption(DocumentInfoParsedCommand.AUTHOR_ARG);
          if(authorOption.isSet()){
View Full Code Here

TOP

Related Classes of org.pdfsam.console.exceptions.console.ParseException

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.