Package jcmdline

Examples of jcmdline.StringParam


              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()){
View Full Code Here


          }else{
            throw new ParseException(ParseException.ERR_NO_O);
          }
     
      //-p
          StringParam pOption = (StringParam) cmdLineHandler.getOption(RotateParsedCommand.P_ARG);
          if(pOption.isSet()){
            parsedCommandDTO.setOutputFilesPrefix(pOption.getValue());
          }         
         
          //-f
          PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(RotateParsedCommand.F_ARG);
          if(fOption.isSet()){
        //validate file extensions
            for(Iterator fIterator = fOption.getPdfFiles().iterator(); fIterator.hasNext();){
              PdfFile currentFile = (PdfFile) fIterator.next();
                //checking extension
                ValidationUtility.assertValidPdfExtension(currentFile.getFile().getName());
            }
            parsedCommandDTO.setInputFileList(FileUtility.getPdfFiles(fOption.getPdfFiles()));
          }
         
          //-r
          StringParam rOption = (StringParam) cmdLineHandler.getOption(RotateParsedCommand.R_ARG);
          if(rOption.isSet()){
            PageRotation[] rotations = ValidationUtility.getPagesRotation(rOption.getValue(), false);
            if(rotations.length == 1){
              parsedCommandDTO.setRotation(rotations[0]);
            }else{
              throw new RotateException(RotateException.ERR_NOT_SINGLE_ROTATION, new String[]{rOption.getValue()});
            }         
          }
    }else{
      throw new ConsoleException(ConsoleException.CMD_LINE_HANDLER_NULL);
    }
View Full Code Here

            }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);
View Full Code Here

          }else{
            throw new ParseException(ParseException.ERR_NO_O);
          }
     
      //-p
          StringParam pOption = (StringParam) cmdLineHandler.getOption(DecryptParsedCommand.P_ARG);
          if(pOption.isSet()){
            parsedCommandDTO.setOutputFilesPrefix(pOption.getValue());
          }         
         
          //-f
          PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(DecryptParsedCommand.F_ARG);
          if(fOption.isSet()){
View Full Code Here

          }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

            throw new ParseException(ParseException.ERR_NO_F)
          }
         
          Map labels = new TreeMap();
          //-l
          StringParam lOption = (StringParam) cmdLineHandler.getOption(PageLabelsParsedCommand.L_ARG);
          if(lOption.isSet()){
            for(Iterator lIterator = lOption.getValues().iterator(); lIterator.hasNext();){
              String currentLabel = (String) lIterator.next();
              PageLabel currentPageLabel = ValidationUtility.getPageLabel(currentLabel);
              if(labels.containsKey(new Integer(currentPageLabel.getPageNumber()))){
                log.warn("Duplicate label starting at page "+currentPageLabel.getPageNumber()+" will be ignored.");
              }else{
                labels.put(new Integer(currentPageLabel.getPageNumber()), currentPageLabel);
              }
            }
          }
         
          //-lp
          StringParam lpOption = (StringParam) cmdLineHandler.getOption(PageLabelsParsedCommand.LP_ARG);
          if(lpOption.isSet()){
            for(Iterator lpIterator = lpOption.getValues().iterator(); lpIterator.hasNext();){
              String currentPrefix = (String) lpIterator.next();
              String[] values = currentPrefix.split(":", 2);
              if(values.length == 2){
                Integer page = null;
                try{
View Full Code Here

          }else{
            throw new ParseException(ParseException.ERR_NO_F)
          }
         
          //-author
          StringParam authorOption = (StringParam) cmdLineHandler.getOption(DocumentInfoParsedCommand.AUTHOR_ARG);
          if(authorOption.isSet()){
            parsedCommandDTO.setAuthor(authorOption.getValue());        
          }
         
          //-title
          StringParam titleOption = (StringParam) cmdLineHandler.getOption(DocumentInfoParsedCommand.TITLE_ARG);
          if(titleOption.isSet()){
            parsedCommandDTO.setTitle(titleOption.getValue());        
          }
         
          //-subject
          StringParam subjectOption = (StringParam) cmdLineHandler.getOption(DocumentInfoParsedCommand.SUBJECT_ARG);
          if(subjectOption.isSet()){
            parsedCommandDTO.setSubject(subjectOption.getValue());        
          }
         
          //-keywords
          StringParam keywordsOption = (StringParam) cmdLineHandler.getOption(DocumentInfoParsedCommand.KEYWORDS_ARG);
          if(keywordsOption.isSet()){
            parsedCommandDTO.setKeywords(keywordsOption.getValue());        
          }
         
    } else {
      throw new ConsoleException(ConsoleException.CMD_LINE_HANDLER_NULL);
    }
View Full Code Here

          }else{
            throw new ParseException(ParseException.ERR_NO_O);
          }
     
      //-p
          StringParam pOption = (StringParam) cmdLineHandler.getOption(EncryptParsedCommand.P_ARG);
          if(pOption.isSet()){
            parsedCommandDTO.setOutputFilesPrefix(pOption.getValue());
          }
         
          //-apwd
          StringParam apwdOption = (StringParam) cmdLineHandler.getOption(EncryptParsedCommand.APWD_ARG);
          if(apwdOption.isSet()){
            parsedCommandDTO.setOwnerPwd(apwdOption.getValue());
          }
         
          //-upwd
          StringParam upwdOption = (StringParam) cmdLineHandler.getOption(EncryptParsedCommand.UPWD_ARG);
          if(upwdOption.isSet()){
            parsedCommandDTO.setUserPwd(upwdOption.getValue());
          }
         
          //-etype
          StringParam etypeOption = (StringParam) cmdLineHandler.getOption(EncryptParsedCommand.ETYPE_ARG);
          if(etypeOption.isSet()){
            parsedCommandDTO.setEncryptionType(etypeOption.getValue());
          }
         
          //-f - d
      PdfFileParam fOption = (PdfFileParam) cmdLineHandler.getOption(EncryptParsedCommand.F_ARG);
      FileParam dOption = (FileParam) cmdLineHandler.getOption(EncryptParsedCommand.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);
      }
         
          //-allow
          StringParam allowOption = (StringParam) cmdLineHandler.getOption(EncryptParsedCommand.ALLOW_ARG);
          if(allowOption.isSet()){
            Hashtable permissionsMap = getPermissionsMap(parsedCommandDTO.getEncryptionType());
            int permissions = 0;
            if(!permissionsMap.isEmpty()){
              for(Iterator permIterator = allowOption.getValues().iterator(); permIterator.hasNext();){
                String currentPermission = (String) permIterator.next();
                Object value = permissionsMap.get(currentPermission);
                if(value != null){
                  permissions |= ((Integer)value).intValue();
              }
View Full Code Here

      }else{
        throw new ParseException(ParseException.ERR_NO_F_OR_L_OR_D);
      }
 
      //-u
      StringParam uOption = (StringParam) cmdLineHandler.getOption(ConcatParsedCommand.U_ARG);           
          //if it's set we proceed with validation
          if (uOption.isSet()){
            String[] selections = StringUtils.split(uOption.getValue(), ":");
            String[] trimmedSelection = new String[selections.length];
            for(int i = 0; i<selections.length; i++){
              trimmedSelection[i] = selections[i].trim();
            }
              ValidationUtility.assertValidPageSelectionsArray(trimmedSelection);
              parsedCommandDTO.setPageSelections(trimmedSelection);
          }
 
          //-copyfields
          parsedCommandDTO.setCopyFields(((BooleanParam) cmdLineHandler.getOption(ConcatParsedCommand.COPYFIELDS_ARG)).isTrue());
         
          //-r
          StringParam rOption = (StringParam) cmdLineHandler.getOption(ConcatParsedCommand.R_ARG);
          if(rOption.isSet()){
            PageRotation[] rotations = ValidationUtility.getPagesRotation(rOption.getValue());
            parsedCommandDTO.setRotations(rotations);
          }
    }else{
      throw new ConsoleException(ConsoleException.CMD_LINE_HANDLER_NULL);
    }
View Full Code Here

    }
    if(cmdLineHandler.getOption(AbstractParsedCommand.COMPRESSED_ARG) != null){
      parsedCommand.setCompress(((BooleanParam) cmdLineHandler.getOption(AbstractParsedCommand.COMPRESSED_ARG)).isTrue());
    }
    if(cmdLineHandler.getOption(AbstractParsedCommand.PDFVERSION_ARG) != null){
          StringParam pdfversionOption = (StringParam) cmdLineHandler.getOption(AbstractParsedCommand.PDFVERSION_ARG);
          if (pdfversionOption.isSet()){
            parsedCommand.setOutputPdfVersion(pdfversionOption.getValue().charAt(0));
          }
        }
    return parsedCommand;
  }
View Full Code Here

TOP

Related Classes of jcmdline.StringParam

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.