本文整理汇总了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;
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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\" : [] }";
}
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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());
}