當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayUtils.isNotEmpty方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.ArrayUtils.isNotEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayUtils.isNotEmpty方法的具體用法?Java ArrayUtils.isNotEmpty怎麽用?Java ArrayUtils.isNotEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils.isNotEmpty方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
@Override
public void configure(Context context) {
    String[] hosts = getHosts(context);
    if(ArrayUtils.isNotEmpty(hosts)) {
        TransportClient client = new ElasticsearchClientBuilder(
                context.getString(PREFIX + ES_CLUSTER_NAME, DEFAULT_ES_CLUSTER_NAME), hosts)
                .setTransportSniff(context.getBoolean(
                        PREFIX + ES_TRANSPORT_SNIFF, false))
                .setIgnoreClusterName(context.getBoolean(
                        PREFIX + ES_IGNORE_CLUSTER_NAME, false))
                .setTransportPingTimeout(Util.getTimeValue(context.getString(
                        PREFIX + ES_TRANSPORT_PING_TIMEOUT), DEFAULT_ES_TIME))
                .setNodeSamplerInterval(Util.getTimeValue(context.getString(
                        PREFIX + ES_TRANSPORT_NODE_SAMPLER_INTERVAL), DEFAULT_ES_TIME))
                .build();
        buildIndexBuilder(context);
        buildSerializer(context);
        bulkProcessor = new BulkProcessorBuilder().buildBulkProcessor(context, client);
    } else {
        logger.error("Could not create transport client, No host exist");
    }
}
 
開發者ID:cognitree,項目名稱:flume-elasticsearch-sink,代碼行數:23,代碼來源:ElasticSearchSink.java

示例2: getMetadataForContainersEntries

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
 * Lookup entry metadata for all given entries and all given containers and then build a map of data,
 * the outer map will include an entry for every input container, however, 
 * the second map will ONLY contain the entries which actually have metadata entered for them
 * (therefore it is unlikely to contain the same number of values as the entryIds input value)
 * 
 * This differs from {@link #getMetadataForEntry(String, String...)} which always returns a map of the same size
 * as the input set of entry ids.
 * 
 * OPTIMIZATION method (fetch lots of metadata at once)
 * 
 * @param containerIds the set of collection (or site) ids to fetch metadata for the input entries
 * @param entryIds the id of the entry (can be 1 or many values)
 * @return Map of the {containerId -> Map of {entryId -> Map of metadata {key -> value} } }
 */
protected Map<String, Map<String, Map<String, String>>> getMetadataForContainersEntries(Set<String> containerIds, String... entryIds) {
    if (containerIds == null || containerIds.isEmpty()) {
        throw new IllegalArgumentException("playlist ids must be set and not empty");
    }
    if (entryIds == null) {
        throw new IllegalArgumentException("entry ids must be set");
    }
    if (log.isDebugEnabled()) log.debug("getMetadataForContainersEntries(containerIds="+containerIds+", entryIds="+ArrayUtils.toString(entryIds)+")");
    Map<String, Map<String, Map<String, String>>> metadata = new LinkedHashMap<String, Map<String, Map<String, String>>>(containerIds.size());
    // pre-populate the metadata map to ensure every passed in playlist id has an entry
    for (String playlistId : containerIds) {
        metadata.put(playlistId, new LinkedHashMap<String, Map<String, String>>());
    }
    if (ArrayUtils.isNotEmpty(entryIds)) {
        Map<String, List<String>> metadataFieldsMap = getEntryMetadataFields(entryIds);
        for (Map.Entry<String, List<String>> entry : metadataFieldsMap.entrySet()) {
            String entryId = entry.getKey();
            List<String> metadataList = entry.getValue();
            for (String entryMetadata : metadataList) {
                // search for the matching container Id in the decoded metadata and only use the results if it was found
                Map<String, String> metadataMap = decodeMetadataPermissions(entryMetadata, false);
                String containerId = metadataMap.get(METADATA_CONTAINER_ID);
                if (containerIds.contains(containerId)) {
                    metadata.get(containerId).put(entryId, metadataMap);
                }
            }
        }
    }
    return metadata;
}
 
開發者ID:ITYug,項目名稱:kaltura-ce-sakai-extension,代碼行數:46,代碼來源:KalturaAPIService.java

示例3: postHandle

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
		ModelAndView modelAndView) throws Exception {
	
	if (modelAndView!=null && ArrayUtils.isNotEmpty(request.getCookies())) {
		HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
		for (Cookie ck : request.getCookies()) {
			cookieMap.put(ck.getName(), ck);
		}
		modelAndView.addObject("cookieMap", cookieMap);
	}
	
	super.postHandle(request, response, handler, modelAndView);
}
 
開發者ID:mmwhd,項目名稱:stage-job,代碼行數:15,代碼來源:CookieInterceptor.java

示例4: sendMailSpring

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
 * 發送郵件 (完整版)(結合Spring)
 * 
 * //@param javaMailSender: 發送Bean
 * //@param sendFrom		: 發送人郵箱
 * //@param sendNick		: 發送人昵稱
 * @param toAddress		: 收件人郵箱
 * @param mailSubject	: 郵件主題
 * @param mailBody		: 郵件正文
 * @param mailBodyIsHtml: 郵件正文格式,true:HTML格式;false:文本格式
 * @param attachments	: 附件
 */
@SuppressWarnings("null")
public static boolean sendMailSpring(String toAddress, String mailSubject, String mailBody, boolean mailBodyIsHtml,File[] attachments) {
	JavaMailSender javaMailSender = null;//ResourceBundle.getInstance().getJavaMailSender();
	try {
		MimeMessage mimeMessage = javaMailSender.createMimeMessage();
		MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, ArrayUtils.isNotEmpty(attachments), "UTF-8"); // 設置utf-8或GBK編碼,否則郵件會有亂碼;multipart,true表示文件上傳


		helper.setFrom(username, sendNick);
		helper.setTo(toAddress);

		// 設置收件人抄送的名片和地址(相當於群發了)
		//helper.setCc(InternetAddress.parse(MimeUtility.encodeText("郵箱001") + " <@163.com>," + MimeUtility.encodeText("郵箱002") + " <@foxmail.com>"));

		helper.setSubject(mailSubject);
		helper.setText(mailBody, mailBodyIsHtml);
		
		// 添加附件
		if (ArrayUtils.isNotEmpty(attachments)) {
			for (File file : attachments) {
				helper.addAttachment(MimeUtility.encodeText(file.getName()), file);	
			}
		}
		
		// 群發
		//MimeMessage[] mailMessages = { mimeMessage };
		
		javaMailSender.send(mimeMessage);
		return true;
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return false;
}
 
開發者ID:mmwhd,項目名稱:stage-job,代碼行數:47,代碼來源:MailUtil.java

示例5: sendMailSpring

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
 * 發送郵件 (完整版)(結合Spring)
 * 
 * //@param javaMailSender: 發送Bean
 * //@param sendFrom		: 發送人郵箱
 * //@param sendNick		: 發送人昵稱
 * @param toAddress		: 收件人郵箱
 * @param mailSubject	: 郵件主題
 * @param mailBody		: 郵件正文
 * @param mailBodyIsHtml: 郵件正文格式,true:HTML格式;false:文本格式
 * @param attachments	: 附件
 */
@SuppressWarnings("null")
public static boolean sendMailSpring(String toAddress, String mailSubject, String mailBody, boolean mailBodyIsHtml,File[] attachments) {
	JavaMailSender javaMailSender = null;//ResourceBundle.getInstance().getJavaMailSender();
	try {
		MimeMessage mimeMessage = javaMailSender.createMimeMessage();
		MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, ArrayUtils.isNotEmpty(attachments), "UTF-8"); // 設置utf-8或GBK編碼,否則郵件會有亂碼;multipart,true表示文件上傳
		
		helper.setFrom(sendFrom, sendNick);
		helper.setTo(toAddress);

		// 設置收件人抄送的名片和地址(相當於群發了)
		//helper.setCc(InternetAddress.parse(MimeUtility.encodeText("郵箱001") + " <@163.com>," + MimeUtility.encodeText("郵箱002") + " <@foxmail.com>"));

		helper.setSubject(mailSubject);
		helper.setText(mailBody, mailBodyIsHtml);
		
		// 添加附件
		if (ArrayUtils.isNotEmpty(attachments)) {
			for (File file : attachments) {
				helper.addAttachment(MimeUtility.encodeText(file.getName()), file);	
			}
		}
		
		// 群發
		//MimeMessage[] mailMessages = { mimeMessage };
		
		javaMailSender.send(mimeMessage);
		return true;
	} catch (Exception e) {
		logger.info("{}", e);
	}
	return false;
}
 
開發者ID:kevinKaiF,項目名稱:xxl-job,代碼行數:46,代碼來源:MailUtil.java

示例6: doFilter

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
		FilterChain arg2) throws IOException, ServletException {
	
	if(AuthUtil.getAuthFlag()){
		 arg2.doFilter(arg0, arg1);
		 return ;
	}
	
	try{
		 HttpServletRequest request  = (HttpServletRequest) arg0;
	    WrapperResponse wrapper = new WrapperResponse((HttpServletResponse)arg1);
		boolean flag =  doGet(request, wrapper);
		log.info("HTTPAuthFilter uri {} doGet flag : {}",request.getRequestURI(),flag);
		if(flag){
			    arg2.doFilter(arg0, wrapper);
			    byte[] content = wrapper.getContent();
			    content = filterGroups(request, content);
                   if(ArrayUtils.isNotEmpty(content)){
                       ServletOutputStream out = arg1.getOutputStream();
    			        out.write(content);
    			        out.flush();
    			        out.close();
                   }
		}
	}catch(Exception e){
		log.error(e.getMessage(),e);
	}finally{
		AuthUtil.THREAD_LOCAL_USER.remove();
	}
	
}
 
開發者ID:xiaomin0322,項目名稱:marathon-auth-plugin,代碼行數:33,代碼來源:HTTPAuthFilter.java

示例7: getAPIResultsForQualityGates

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
public QualityGatesStatus getAPIResultsForQualityGates(JobConfigData jobConfigData, GlobalConfigDataForSonarInstance globalConfigDataForSonarInstance, BuildListener listener) throws JSONException, InterruptedException{

        GlobalConfigDataForSonarInstance validatedData = sonarInstanceValidationService.validateData(globalConfigDataForSonarInstance);

        boolean taskAnalysisRunning = true;

        int attemptsToRepeat = jobConfigData.getAttemptsToRepeat();
        int timeToWait = globalConfigDataForSonarInstance.getTimeToWait();
        if (timeToWait == 0) {
            timeToWait = MILLISECONDS_10_SECONDS;
        }

        if (attemptsToRepeat == 0) {
            attemptsToRepeat = 1;
        }

        if (attemptsToRepeat * timeToWait > MILLISECONDS_10_MINUTES) {
            attemptsToRepeat = MILLISECONDS_10_MINUTES / timeToWait;
        }

        int timesExecuted = 0;

        do {

            sonarHttpRequester.setLogged(false);
            String statusResultJson = sonarHttpRequester.getAPITaskInfo(jobConfigData, validatedData);

            Gson gson = new GsonBuilder().create();

            QualityGateTaskCE taskCE = gson.fromJson(statusResultJson, QualityGateTaskCE.class);

            if (ArrayUtils.isNotEmpty(taskCE.getQueue())) {

                listener.getLogger().println("Has build " + taskCE.getQueue()[0].getStatus() + " with id: " + taskCE.getQueue()[0].getId() + " - waiting " + timeToWait + " to execute next check.");

                Thread.sleep(timeToWait);
            } else {
                listener.getLogger().println("Status => " + taskCE.getCurrent().getStatus());

                if ("SUCCESS".equals(taskCE.getCurrent().getStatus())) {
                    taskAnalysisRunning = false;
                }
            }

            if (attemptsToRepeat < timesExecuted++) {
                throw new MaxExecutionTimeException("Max time to wait sonar job!");
            }
        } while (taskAnalysisRunning);

        String requesterResult = getRequesterResult(jobConfigData, validatedData);

        return qualityGateResponseParser.getQualityGateResultFromJSON(requesterResult);
    }
 
開發者ID:jenkinsci,項目名稱:sonar-quality-gates-plugin,代碼行數:54,代碼來源:QualityGatesProvider.java

示例8: sendMail

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
 * 發送郵件 (完整版) (純JavaMail)
 * 
 * @param toAddress		: 收件人郵箱
 * @param mailSubject	: 郵件主題
 * @param mailBody		: 郵件正文
 * @param mailBodyIsHtml: 郵件正文格式,true:HTML格式;false:文本格式
 * //@param inLineFile	: 內嵌文件
 * @param attachments	: 附件
 */
public static boolean sendMail (String toAddress, String mailSubject, String mailBody, 
		boolean mailBodyIsHtml, File[] attachments){
       try {
		// 創建郵件發送類 JavaMailSender (用於發送多元化郵件,包括附件,圖片,html 等)
       	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
       	mailSender.setHost(host); 			// 設置郵件服務主機    
       	mailSender.setUsername(username); 	// 發送者郵箱的用戶名    
       	mailSender.setPassword(password); 	// 發送者郵箱的密碼    
       	
		// 配置文件,用於實例化java.mail.session
		Properties pro = new Properties();
		pro.put("mail.transport.protocol", "smtp");
		pro.put("mail.smtp.auth", "true");		// 登錄SMTP服務器,需要獲得授權 (網易163郵箱新近注冊的郵箱均不能授權,測試 sohu 的郵箱可以獲得授權)
		pro.put("mail.smtp.socketFactory.port", port);
		pro.put("mail.smtp.socketFactory.fallback", "false");
		mailSender.setJavaMailProperties(pro);
		
		// 創建多元化郵件 (創建 mimeMessage 幫助類,用於封裝信息至 mimeMessage)
		MimeMessage mimeMessage = mailSender.createMimeMessage();						
		MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, ArrayUtils.isNotEmpty(attachments), "UTF-8");
		
		helper.setFrom(username, sendNick);
		helper.setTo(toAddress);

		helper.setSubject(mailSubject);
		helper.setText(mailBody, mailBodyIsHtml); 
		
		// 設置收件人抄送的名片和地址(相當於群發)
		//helper.setCc(InternetAddress.parse(MimeUtility.encodeText("郵箱001") + " <@163.com>," + MimeUtility.encodeText("郵箱002") + " <@foxmail.com>"));

		// 內嵌文件,第1個參數為cid標識這個文件,第2個參數為資源
		//helper.addInline(MimeUtility.encodeText(inLineFile.getName()), inLineFile);
		
		// 添加附件
		/*if (ArrayUtils.isNotEmpty(attachments)) {
			for (File file : attachments) {
				helper.addAttachment(MimeUtility.encodeText(file.getName()), file);	
			}
		}*/

		// 群發
		//MimeMessage[] mailMessages = { mimeMessage };
		
		mailSender.send(mimeMessage);
		return true;
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return false;
}
 
開發者ID:mmwhd,項目名稱:stage-job,代碼行數:61,代碼來源:MailUtil.java

示例9: sendMail

import org.apache.commons.lang.ArrayUtils; //導入方法依賴的package包/類
/**
 * 發送郵件 (完整版) (純JavaMail)
 * 
 * @param toAddress		: 收件人郵箱
 * @param mailSubject	: 郵件主題
 * @param mailBody		: 郵件正文
 * @param mailBodyIsHtml: 郵件正文格式,true:HTML格式;false:文本格式
 * //@param inLineFile	: 內嵌文件
 * @param attachments	: 附件
 */
public static boolean sendMail (String toAddress, String mailSubject, String mailBody, 
		boolean mailBodyIsHtml, File[] attachments){
       try {
		// 創建郵件發送類 JavaMailSender (用於發送多元化郵件,包括附件,圖片,html 等    )
       	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
       	mailSender.setHost(host); 			// 設置郵件服務主機    
       	mailSender.setUsername(username); 	// 發送者郵箱的用戶名    
       	mailSender.setPassword(password); 	// 發送者郵箱的密碼    
       	
		//配置文件,用於實例化java.mail.session    
		Properties pro = new Properties();
		pro.put("mail.smtp.auth", "true");		// 登錄SMTP服務器,需要獲得授權 (網易163郵箱新近注冊的郵箱均不能授權,測試 sohu 的郵箱可以獲得授權)
		pro.put("mail.smtp.socketFactory.port", port);
		pro.put("mail.smtp.socketFactory.fallback", "false");
		mailSender.setJavaMailProperties(pro);
		
		//創建多元化郵件 (創建 mimeMessage 幫助類,用於封裝信息至 mimeMessage)
		MimeMessage mimeMessage = mailSender.createMimeMessage();						
		MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, ArrayUtils.isNotEmpty(attachments), "UTF-8");
		
		helper.setFrom(sendFrom, sendNick);
		helper.setTo(toAddress);

		helper.setSubject(mailSubject);
		helper.setText(mailBody, mailBodyIsHtml); 
		
		// 添加內嵌文件,第1個參數為cid標識這個文件,第2個參數為資源
		//helper.addInline(MimeUtility.encodeText(inLineFile.getName()), inLineFile);	
		
		// 添加附件    
		if (ArrayUtils.isNotEmpty(attachments)) {
			for (File file : attachments) {
				helper.addAttachment(MimeUtility.encodeText(file.getName()), file);	
			}
		}
		
		mailSender.send(mimeMessage);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return false;
}
 
開發者ID:kevinKaiF,項目名稱:xxl-job,代碼行數:54,代碼來源:MailUtil.java


注:本文中的org.apache.commons.lang.ArrayUtils.isNotEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。