当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils类代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringUtils类属于org.apache.commons.lang3包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrentUser

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
public static User getCurrentUser(String username)
{
	User user = new User();
	try
	{
		if (StringUtils.isNotBlank(username))
		{
			user = (User)getJdbcTemplate().queryForObject(
					GET_CURRENT_USER_INFO,
					new UserRowMapper(),
					username);
		}
	}
	catch(EmptyResultDataAccessException e)
	{
		Logger.error("UserDAO getCurrentUser failed, username = " + username);
		Logger.error("Exception = " + e.getMessage());
	}

	return user;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:22,代码来源:UserDAO.java

示例2: getLinkList

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
/**
 * @desc 分页查询所有链路列表
 *
 * @author liuliang
 *
 * @param pageIndex 当前页
 * @param pageSize 每页条数
 * @return List<LinkBO> 链路BO集合
 * @throws Exception
 */
@Override
public List<LinkBO> getLinkList(String linkName,int pageIndex, int pageSize) throws Exception{
	//1、查询
	List<Link> linkList = null;
	if(StringUtils.isBlank(linkName)){
		linkList = linkDao.queryLinkByPage(pageIndex, pageSize);
	}else{
		linkList = linkDao.queryLinkByPage(linkName,pageIndex, pageSize);
	}
	//2、转换
	List<LinkBO> linkBOList = new ArrayList<LinkBO>();
	if((null != linkList) && (0 < linkList.size())){
		LinkBO linkBO = null;
		for(Link link:linkList){
			linkBO = new LinkBO();
			BeanUtils.copyProperties(link, linkBO);
			linkBOList.add(linkBO);
		}
	}
	//3、返回
	return linkBOList;
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:33,代码来源:LinkServiceImpl.java

示例3: solrInputField

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
public static <T> Matcher<SolrInputField> solrInputField(String fieldName, Matcher<T> valueMatcher) {
    return new TypeSafeMatcher<SolrInputField>() {
        @Override
        protected boolean matchesSafely(SolrInputField item) {
            return StringUtils.equals(fieldName, item.getName()) && valueMatcher.matches(item.getValue());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("SolrInputField(")
                    .appendValue(fieldName)
                    .appendText(" value matching ")
                    .appendDescriptionOf(valueMatcher)
                    .appendText(")");
        }
    };
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:18,代码来源:SolrSearchServerTest.java

示例4: toXml

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
/**
 * 微信下单map to xml
 * 
 * @param params
 *            参数
 * @return String
 */
public static String toXml(Map<String, String> params) {
	StringBuilder xml = new StringBuilder();
	xml.append("<xml>");
	for (Entry<String, String> entry : params.entrySet()) {
		String key = entry.getKey();
		String value = entry.getValue();
		// 略过空值
		if (StringUtils.isBlank(value))
			continue;
		xml.append("<").append(key).append(">");
		xml.append(entry.getValue());
		xml.append("</").append(key).append(">");
	}
	xml.append("</xml>");
	return xml.toString();
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:24,代码来源:WxPayment.java

示例5: init

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
public static void init(Context ctx){
    context = ctx;

    preferences = ctx.getSharedPreferences(CHAT_SDK_SHRED_PREFS, Context.MODE_PRIVATE);
    VolleyUtils.init(ctx);
    DaoCore.init(ctx);

    BFacebookManager.init(context.getString(R.string.facebook_id), ctx);

    
    //Bug Sense
    if (BNetworkManager.BUGSENSE_ENABLED && StringUtils.isNotEmpty( context.getString(R.string.bug_sense_key) )) {
        BugSenseHandler.initAndStartSession(ctx, context.getString(R.string.bug_sense_key));
        BugSenseHandler.addCrashExtraData("Version", BuildConfig.VERSION_NAME);
    }
}
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:17,代码来源:BNetworkManager.java

示例6: searchInBody

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
public void searchInBody(String pattern) {
  httpCallBodyView.removeOldHighlightedSpans();
  if (StringUtils.isEmpty(pattern)) {
    return;
  }
  ArrayList<Bound> bounds = new ArrayList<>();
  int indexOfKeyword = formattedBodyLowerCase.indexOf(pattern);
  while (indexOfKeyword > -1) {
    int rightBound = indexOfKeyword + pattern.length();
    bounds.add(new Bound(indexOfKeyword, rightBound));
    indexOfKeyword = formattedBodyLowerCase.indexOf(pattern, rightBound);
  }
  if (!bounds.isEmpty()) {
    httpCallBodyView.highlightBounds(bounds);
  }
}
 
开发者ID:jainsahab,项目名称:AndroidSnooper,代码行数:17,代码来源:HttpCallFragmentPresenter.java

示例7: notifyNewYear

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
private void notifyNewYear(NewYearNotification baseNotification, Guild guild) {
    NewYearNotification notification = repository.findOneByGuildId(guild.getId());
    if (notification == null) {
        notification = baseNotification;
    }
    if (notification == null || !notification.isEnabled() || StringUtils.isEmpty(notification.getMessage())) {
        return;
    }
    TextChannel channel = getChannel(notification, guild);
    if (channel == null) {
        return;
    }

    String message = notification.getMessage();
    MapPlaceholderResolver resolver = new MapPlaceholderResolver();
    resolver.put("name", guild.getName());
    message = placeholderHelper.replacePlaceholders(message, resolver);

    EmbedBuilder builder = messageService.getBaseEmbed();
    if (StringUtils.isNotEmpty(notification.getImageUrl())) {
        builder.setImage(notification.getImageUrl());
    }
    builder.setDescription(message);
    messageService.sendMessageSilent(channel::sendMessage, builder.build());
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:26,代码来源:HolidayService.java

示例8: get

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
/**
 * 根据key和类的类别获取缓存对象
 * 
 * @param key
 *            键
 * @param value
 *            值
 * @param <T>
 *            泛型对象
 * @return json字符串
 */
@Override
public <T> T get(final String bizkey, final String nameSpace, Class<T> value, final GetDataCallBack<T> gbs) {
    final String key = CacheUtils.getKeyByNamespace(bizkey, nameSpace);
    String res = get(bizkey, nameSpace, null);
    T rtn = null;
    if (StringUtils.isNotEmpty(res)) {
        rtn = CacheUtils.parseObject(key, res, value);
    } else {
        if (gbs != null) {
            rtn = gbs.invoke();
            // 取出的数据要set回去
            if (null != rtn) {
                set(bizkey, nameSpace, rtn, gbs.getExpiredTime());
            }
        }
    }
    return rtn;
}
 
开发者ID:ningyu1,项目名称:redis-client,代码行数:30,代码来源:RedisClientImpl.java

示例9: flowLineage

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
@Security.Authenticated(Secured.class)
public static Result flowLineage(String application, String project, String flow)
{
    String username = session("user");
    if (username == null)
    {
        username = "";
    }
    String type = "azkaban";
    if (StringUtils.isNotBlank(application) && (application.toLowerCase().indexOf("appworx") != -1))
    {
        type = "appworx";

    }
    return ok(lineage.render(username, type, 0, application.replace(" ", "."), project, flow));
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:17,代码来源:Application.java

示例10: run

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
@Override
public void run() {
	if (GenerationUtils.validate(containerName)) {
		Shell shell = Display.getDefault().getActiveShell();
		boolean confirm = MessageDialog.openQuestion(shell, "Confirm Create", "Existing Files will be cleared. Do you wish to continue?");
		if (confirm) {
			wsRoot = ResourcesPlugin.getWorkspace().getRoot();
			names = StringUtils.split(containerName, "/");
			wsRootRes = wsRoot.findMember(new Path("/" + names[0]));
			prj = wsRootRes.getProject();
			steps = prj.getFolder("target/Steps");
			File root = new File(steps.getLocation().toOSString());
			if (root.exists()) {
				GenerationUtils.clearCreatedFolders(root);
			}
			for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
				try {
					project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
				} catch (CoreException e) {
				}
			}
		}
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:25,代码来源:ClearTargetAction.java

示例11: 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

示例12: addProxyHeaders

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
@Override
protected void addProxyHeaders(final HttpServletRequest clientRequest, final Request proxyRequest) {
	super.addProxyHeaders(clientRequest, proxyRequest);

	// Forward security identifier if defined
	proxyRequest.header("SM_UNIVERSALID", clientRequest.getUserPrincipal() == null
			? StringUtils.trimToNull(clientRequest.getParameter(apiUserParameter)) : clientRequest.getUserPrincipal().getName());

	// Forward original SESSIONID
	proxyRequest.header("SM_SESSIONID", clientRequest.getSession(false) == null ? null : clientRequest.getSession(false).getId());

	// Forward API key, if defined.
	proxyRequest.header(apiKeyHeader, StringUtils.trimToNull(clientRequest.getParameter(apiKeyParameter)));

	// Forward all cookies but JSESSIONID.
	final String cookies = clientRequest.getHeader(HEADER_COOKIE);
	if (cookies != null) {
		proxyRequest.header(HEADER_COOKIE, StringUtils.trimToNull(
				Arrays.stream(cookies.split("; ")).filter(cookie -> !cookie.split("=")[0].equals(COOKIE_JEE)).collect(Collectors.joining("; "))));
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:22,代码来源:BackendProxyServlet.java

示例13: updateDatasetSecurity

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
public static Promise<Result> updateDatasetSecurity(int datasetId) {
    String username = session("user");
    if (StringUtils.isNotBlank(username)) {
        final String queryUrl = BACKEND_URL + DATASET_SECURITY_PATH;

        final JsonNode queryNode = Json.newObject()
            .put("datasetId", datasetId)
            .set("securitySpecification", request().body().asJson());

        return WS.url(queryUrl)
            .setRequestTimeout(1000)
            .post(queryNode)
            .map(response ->
                ok(response.asJson())
            );
    } else {
        final JsonNode result = Json.newObject()
            .put("status", "failed")
            .put("error", "true")
            .put("msg", "Unauthorized User.");

        return Promise.promise(() -> ok(result));
    }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:25,代码来源:Dataset.java

示例14: processRow

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
	meta = (EasyExpandMeta) smi;
	data = (EasyExpandData) sdi;
	if(StringUtils.isNotBlank(meta.getClassName())){
           try {
               //实例化配置的类
               if(first){
                   kui = (EasyExpandRunBase) Class.forName(
                           environmentSubstitute(meta.getClassName())).newInstance();
                   kui.setKu(this);
                   kui.setMeta(meta,this);
               }
               kui.setData(data);
               return kui.run();
           } catch (Exception e) {
               setErrors(getErrors()+1);
               logError("运行失败,"+meta.getClassName()+","
               +environmentSubstitute(meta.getConfigInfo()), e);
               return defaultRun();
           }
	}else{
        return defaultRun();
	}

}
 
开发者ID:majinju,项目名称:KettleUtil,代码行数:26,代码来源:EasyExpand.java

示例15: isValid

import org.apache.commons.lang3.StringUtils; //导入依赖的package包/类
/**
 * Checks if a Displayname is valid according to the configuration
 * <br /><br /><b>Note: </b> Field is also valid if it is null or blank
 * <br />Also set {@link RequiredValidator} for to validate mandantory fields
 */
@Override
public boolean isValid(final String displayName) {
	if (StringUtils.isBlank(displayName)) {
		return true;
	}

	if (displayName.length() < c.getIntProperty("validation.displayname.minLength") || displayName.length() > c.getIntProperty("validation.displayname.maxLength")) {
		return false;
	}
	if (!c.getBooleanProperty("validation.displayname.allowSpecial")) {
		if (displayName.matches(CONTAINS_SPECIALCHARS_REGEX)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:22,代码来源:DisplayNameValidator.java


注:本文中的org.apache.commons.lang3.StringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。