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


Java StringUtils.isEmpty方法代碼示例

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


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

示例1: addApplicationNameSuffix

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * Adds suffix to the application name, but not exceeding certain length().
 *
 * @param originalApplicationName
 *            Application provided application name.
 * @param suffixToAppend
 *            Suffix to append to the application name.
 * @return Application name with suffix appended.
 */
public static String addApplicationNameSuffix(String originalApplicationName,
        String suffixToAppend) {
    if (originalApplicationName == null || StringUtils.isEmpty(originalApplicationName)) {
        return suffixToAppend;
    }

    if (suffixToAppend == null || StringUtils.isEmpty(suffixToAppend)) {
        return originalApplicationName;
    }

    int maxAppNameSubStringAllowed = MAX_APPLICATION_NAME_LENGTH - suffixToAppend.length();

    if (originalApplicationName.length() <= maxAppNameSubStringAllowed) {
        return originalApplicationName + suffixToAppend;
    }
    else {
        // Take the substring of application name that will be fit within the 'program_name' column in dm_exec_sessions.
        return originalApplicationName.substring(0, maxAppNameSubStringAllowed) + suffixToAppend;
    }
}
 
開發者ID:Microsoft,項目名稱:elastic-db-tools-for-java,代碼行數:30,代碼來源:ApplicationNameHelper.java

示例2: loadFilter

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private void loadFilter(String filter, LoadBalancer lb) {
  String className = Configuration.getStringProperty(null,
      String.format(Configuration.SERVER_LIST_FILTER_CLASS_HOLDER, filter));
  if (!StringUtils.isEmpty(className)) {
    try {
      Class<?> filterClass = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
      if (ServerListFilterExt.class.isAssignableFrom(filterClass)) {
        ServerListFilterExt ext = (ServerListFilterExt) filterClass.newInstance();
        ext.setName(filter);
        ext.setLoadBalancer(lb);
        lb.putFilter(filter, ext);
      }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
      LOGGER.warn("Unable to load filter class: " + className);
    }
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:18,代碼來源:LoadbalanceHandler.java

示例3: addLibraryPath

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static void addLibraryPath(String path) {
	String javaLibraryPath = System.getProperty("java.library.path");
	String[] paths = new String[0];
	if (StringUtils.isNotEmpty(javaLibraryPath)) {
		paths = javaLibraryPath.split(File.pathSeparator, -1);
	}
	StringBuilder sb = new StringBuilder();
	sb.append(path);
	sb.append(File.pathSeparator);
	for (String p : paths) {
		if (StringUtils.isEmpty(p))
			continue;
		if (p.equals(path))
			continue;
		sb.append(p);
		sb.append(File.pathSeparator);
	}
	if (sb.length() > 0)
		sb.deleteCharAt(sb.length() - 1);
	javaLibraryPath = sb.toString();
	System.setProperty("java.library.path", javaLibraryPath);
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:23,代碼來源:PropsUtil.java

示例4: vulParameters

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public void vulParameters(final GeefDetailsPersoonVerzoek verzoek, final Node node, final XPath xPath) {
    super.vulParameters(verzoek, node, xPath);
    // Historiefilter
    final String historieVorm = getNodeTextContent(getPrefix() + "/brp:parameters/brp:historievorm", xPath, node);
    if (!StringUtils.isEmpty(historieVorm)) {
        verzoek.getParameters().setHistorieVorm(HistorieVorm.getByNaam(historieVorm));
    }
    //peilmoment formeel
    final String peilMomentFormeelResultaat = getNodeTextContent(getPrefix() + "/brp:parameters/brp:peilmomentFormeelResultaat", xPath, node);
    if (!StringUtils.isEmpty(peilMomentFormeelResultaat)) {
        verzoek.getParameters()
                .setPeilMomentFormeelResultaat(peilMomentFormeelResultaat);
    }
    //peilmoment materieel resultaat
    final String peilMomentMaterieelResultaat = getNodeTextContent(getPrefix() + "/brp:parameters/brp:peilmomentMaterieelResultaat", xPath, node);
    if (!StringUtils.isEmpty(peilMomentMaterieelResultaat)) {
        verzoek.getParameters()
                .setPeilMomentMaterieelResultaat(peilMomentMaterieelResultaat);
    }
    //verantwoording
    final String verantwoording = getNodeTextContent(getPrefix() + "/brp:parameters/brp:verantwoording", xPath, node);
    if (!StringUtils.isEmpty(verantwoording)) {
        verzoek.getParameters().setVerantwoording(verantwoording);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:27,代碼來源:GeefDetailsPersoonVerzoekParser.java

示例5: getIpAddr

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static String getIpAddr(HttpServletRequest request) {
	if (request != null) {
		String ip = request.getHeader("x-forwarded-for");
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("Proxy-Client-IP");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("WL-Proxy-Client-IP");
		}
		if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("X-Forwarded-For");
		}
		if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("HTTP_CLIENT_IP");
		}
		if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("HTTP_X_FORWARDED_FOR");
		}
		if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getRemoteAddr();
		}
		return ip;
	}
	return null;
}
 
開發者ID:wenjian-li,項目名稱:spring_mybatis_shiro,代碼行數:26,代碼來源:IpUtil.java

示例6: createWebSocket

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
@UnitOfWork
public Object createWebSocket(
    ServletUpgradeRequest servletUpgradeRequest,
    ServletUpgradeResponse servletUpgradeResponse) {

    String path = servletUpgradeRequest.getRequestPath();

    if(!StringUtils.isEmpty(path)) {
        String[] paths = servletUpgradeRequest.getRequestPath().split("/");

        String userID = paths[paths.length - 1];
        try {
            long id = Long.parseLong(userID);
            Optional<User> optionalUser = userRepository.getUserWithGroups(id);
            if (optionalUser.isPresent())
                return new ChatSocketListener(optionalUser.get(), this.messageHandler);
            log.error("Invalid user id was passed in");
        } catch (NumberFormatException exception) {
            log.error("Value passed in for user id is not a number", exception);
        }
    }

    return null;
}
 
開發者ID:tosinoni,項目名稱:SECP,代碼行數:26,代碼來源:ChatSocketCreator.java

示例7: chunkify

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * Chunkify strings to a set length, but do not break words
 *
 * @param string The string to chunkify
 * @param length The max length of the chunks
 * @return A list containing the resulting chunks
 */
public static List<String> chunkify(String string, int length) {
  List<String> chunks = new ArrayList<>();

  if (StringUtils.isEmpty(string) || string.length() <= length) {
    chunks.add(string);
    return chunks;
  }

  Iterator<String> words = Iterators.forArray(string.split(" "));
  int chunkCount = (int) Math.ceil(((double) string.length()) / length);

  IntStream.rangeClosed(1, chunkCount).forEach(ci -> {
    StringBuilder newChunk = new StringBuilder();

    while (newChunk.length() < length) {
      if (!words.hasNext()) break;
      newChunk.append(" ").append(words.next());
    }

    if (StringUtils.isNotEmpty(newChunk)) chunks.add(newChunk.toString().trim());
  });

  return chunks;
}
 
開發者ID:Juraji,項目名稱:Biliomi,代碼行數:32,代碼來源:TextUtils.java

示例8: data

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@SystemControllerLog(description="權限管理-角色列表")
@RequestMapping(value = "/data")
@ResponseBody
public String data(String params) {
	try {
		ObjectMapper om = new ObjectMapper();
		Map<String, Object> map = new HashMap<String, Object>();
		if (!StringUtils.isEmpty(params)) {
			// 參數處理
			map = om.readValue(params, new TypeReference<Map<String, Object>>() {});
		}
		PagerModel<Role> pg = roleService.findPaginated(map);
		// 序列化查詢結果為JSON
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("total", pg.getTotal());
		result.put("rows", pg.getData());
		return om.writeValueAsString(result);
	} catch (Exception e) {
		e.printStackTrace();
		return "{ \"total\" : 0, \"rows\" : [] }";
	}
}
 
開發者ID:ranji1221,項目名稱:clemon,代碼行數:23,代碼來源:RoleController.java

示例9: addSimilarityFields

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public MltConfig addSimilarityFields(String lang, String field){
    if(StringUtils.isEmpty(field)){
        return this;
    }
    lang = StringUtils.lowerCase(lang, Locale.ROOT);
    Collection<String> langFields = langSimilarityFields.get(lang);
    if(langFields == null){
        langFields = new LinkedHashSet<>();
        langSimilarityFields.put(lang, langFields);
    }
    langFields.add(field);
    return this;
}
 
開發者ID:redlink-gmbh,項目名稱:smarti,代碼行數:14,代碼來源:MltConfig.java

示例10: loadData

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
protected void loadData() {
    // 初始化類別下拉列表選項
    initCollections(new String[] { "collectionProperties.user.sex", "collectionProperties.user.type" });
    UserSearchBean searchBean = new UserSearchBean();
    if (StringUtils.isEmpty(pagination.getSortColumn())) {
        pagination.setSortColumn("userno");
    }
    searchBean.setPagination(pagination);
    // 總件數設置
    pagination.setPreperties(userService.getCount(searchBean));
    userList = userService.find(searchBean);
    // Setting number of records in the particular page
    pagination.setPageRecords(userList.size());
}
 
開發者ID:Chihpin,項目名稱:Yidu,代碼行數:16,代碼來源:UserListAction.java

示例11: validateMessage

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Deprecated
public boolean validateMessage(PushMessage pushMessage)
{
	//校驗必選參數
	if (null == pushMessage || StringUtils.isEmpty(pushMessage.getText()) 
			|| StringUtils.isEmpty(pushMessage.getClientType().name())
			|| null == pushMessage.getPushChannel())
	{
		LOGGER.error("Invalid request params.");
		return false;
	}
	
	// 安卓推送, ticker和title不能為空
	if ("ANDROID".equals(pushMessage.getClientType().name()) 
			&& StringUtils.isEmpty(pushMessage.getTicker()) && StringUtils.isEmpty(pushMessage.getTitle()))
	{
		LOGGER.error("Invalid request params. ticker or title is empty");
		return false;
	}
	
	// 如果是單播, topicList參數必須不能為空
	if (PushMessage.PushType.UNICAST == pushMessage.getPushType()
			&& CollectionUtils.isEmpty(pushMessage.getAudiences()))
	{
		LOGGER.error("Invalid request params. topicList is empty.");
		return false;
	}
	return true;
}
 
開發者ID:marlonwang,項目名稱:raven,代碼行數:30,代碼來源:PushMessageService.java

示例12: parseVkLinks

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static String parseVkLinks(String string, boolean noLink) {
    if (StringUtils.isEmpty(string)) return string;
    Matcher m = VK_LINK_TAG.matcher(string);
    StringBuffer sb = new StringBuffer(string.length());
    while (m.find()) {
        m.appendReplacement(sb, noLink ? m.group(2)
                : String.format("[%s](https://vk.com/%s)", m.group(2), m.group(1)));
    }
    m.appendTail(sb);

    string = sb.toString();

    if (!noLink) {
        try {
            m = VK_HASH_TAG.matcher(string);
            sb = new StringBuffer(string.length());
            while (m.find()) {
                m.appendReplacement(sb, noLink ? m.group(2)
                        : String.format("[%s](https://vk.com/feed?section=search&q=%s)", m.group(1), UriUtils.encode(m.group(1), "UTF-8")));
            }
            m.appendTail(sb);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        string = sb.toString();
    }
    return maskDiscordFormat(string);
}
 
開發者ID:GoldRenard,項目名稱:JuniperBotJ,代碼行數:29,代碼來源:CommonUtils.java

示例13: updateRoles

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public Response updateRoles(RolesOrPermissionDTO request, String id) {
    if(StringUtils.isEmpty(request.getColor()))
    {
        throw new WebApplicationException(AdminErrorMessage.REGISTER_ROLES_FAIL_INVALID_COLOR, Response.Status.BAD_REQUEST);
    }

    Role role = getRoleFromID(id);
    role.setColor(request.getColor());
    Role savedRole = rolesDAO.save(role);


    return Response.status(Response.Status.CREATED).
        entity(new RolesOrPermissionDTO(savedRole.getId(),savedRole.getRole(),savedRole.getColor())).build();
}
 
開發者ID:tosinoni,項目名稱:SECP,代碼行數:15,代碼來源:AdminController.java

示例14: onMessage

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 消息處理
 * 
 * @param request
 *            HTTP請求對象
 * @return 解析後的消息對象,如果不能解析則返回null。
 */
public UserMsg onMessage(HttpServletRequest request) {
	String openid = request.getParameter("openid");
	String appid = request.getParameter("appid");

	final UserMsg msg = parseMessage(request);
	if (msg == null) {
		log.warn(String.format("未能解析消息請求"));
		return null;
	}

	// 消息ID去重
	String msgid = msg.getMsgId();
	if (StringUtils.isEmpty(msgid)) {
		msgid = String.format("%s_%s", msg.getFromUserName(), msg.getCreateTime());
	}
	if (distinctMsgIdCache.containsKey(msgid)) {
		if (log.isInfoEnabled()) {
			log.info(String.format("丟棄重複消息[%s],", msgid));
		}
		return null;
	}
	distinctMsgIdCache.put(msgid, null);

	if (log.isInfoEnabled()) {
		log.info(String.format("消息 %s", new Gson().toJson(msg)));
	}

	msg.setAppid(appid);
	msg.setOpenid(openid);
	return msg;
}
 
開發者ID:AlexLee-CN,項目名稱:weixin_api,代碼行數:39,代碼來源:OpenApi.java

示例15: getMD5Encode

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * @param fields {@link String []}
 * @return md5
 * @description MD5 33位加密
 */
public static String getMD5Encode(String... fields) {
    if (ArrayUtils.isEmpty(fields)) {
        return null;
    }
    StringBuilder builder = new StringBuilder(60);
    for (String field : fields) {
        if (!StringUtils.isEmpty(field)) {
            builder.append(field);
        }
    }
    return DigestUtils.md5Hex(builder.toString());
}
 
開發者ID:tong12580,項目名稱:OutsourcedProject,代碼行數:18,代碼來源:MD5Util.java


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