本文整理汇总了Java中org.apache.commons.lang3.StringUtils.isBlank方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isBlank方法的具体用法?Java StringUtils.isBlank怎么用?Java StringUtils.isBlank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isBlank方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveImages
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 保存房源图片
*
* @param dto
*/
private void saveImages(EstateItemDTO dto) {
List<EstateImageModel> imageList = dto.getEstateImageList();
if (CollectionUtils.isNotEmpty(imageList)) {
for (EstateImageModel image : imageList) {
// 普通图片
if (image.getPictureId() != null) {
estateFeignClient.saveImage(image.getHouseCode(), ProtoStuffUtil.serialize(image));
// 户型图
} else {
image.setPictureId(System.currentTimeMillis());
image.setHouseCode(dto.getHouseCode());
image.setPictureType(99);
if (StringUtils.isBlank(image.getPictureSourceUrl())) {
image.setPictureSourceUrl(image.getUrl());
}
estateFeignClient.saveImage(image.getHouseCode(), ProtoStuffUtil.serialize(image));
}
}
}
}
示例2: page
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 自定义页面,如关于的页面
*/
@GetMapping(value = "/{pagename}")
public String page(@PathVariable String pagename, HttpServletRequest request) {
ContentVo contents = contentService.getContents(pagename);
if (null == contents) {
return this.render_404();
}
if (contents.getAllowComment()) {
String cp = request.getParameter("cp");
if (StringUtils.isBlank(cp)) {
cp = "1";
}
PageInfo<CommentBo> commentsPaginator = commentService.getComments(contents.getCid(), Integer.parseInt(cp), 6);
request.setAttribute("comments", commentsPaginator);
}
request.setAttribute("article", contents);
updateArticleHit(contents.getCid(), contents.getHits());
return this.render("page");
}
示例3: addCategory
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public ServerResponse addCategory(String categoryName, Integer parentId) {
if (parentId == null || StringUtils.isBlank(categoryName)) {
return ServerResponse.createByErrorMessage("添加品类参数错误");
}
Category category = new Category();
category.setName(categoryName);
category.setParentId(parentId);
category.setStatus(true);//这个分类是可用的
int rowCount = categoryMapper.insert(category);
if (rowCount > 0) {
return ServerResponse.createBySuccess("添加品类成功");
}
return ServerResponse.createByErrorMessage("添加品类失败");
}
示例4: getRemoteIp
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Pulls the remote IP from the current HttpServletRequest, or grabs the value
* for the specified alternative attribute (say, for proxied requests). Falls
* back to providing the "normal" remote address if no value can be retrieved
* from the specified alternative header value.
* @param context the context
* @return the remote ip
*/
private String getRemoteIp(@NotNull final RequestContext context) {
final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
String userAddress = request.getRemoteAddr();
logger.debug("Remote Address = {}", userAddress);
if (StringUtils.isNotBlank(this.alternativeRemoteHostAttribute)) {
userAddress = request.getHeader(this.alternativeRemoteHostAttribute);
logger.debug("Header Attribute [{}] = [{}]", this.alternativeRemoteHostAttribute, userAddress);
if (StringUtils.isBlank(userAddress)) {
userAddress = request.getRemoteAddr();
logger.warn("No value could be retrieved from the header [{}]. Falling back to [{}].",
this.alternativeRemoteHostAttribute, userAddress);
}
}
return userAddress;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:BaseSpnegoKnownClientSystemsFilterAction.java
示例5: getUpdateYamlScript
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Parse file to updater node
*
* @param scriptClass class to use for source
* @return Node object representing the groovy updater to marshall to xml
*/
public static Map<String, Map<String, Object>> getUpdateYamlScript(final ScriptClass scriptClass) {
final Updater updater = scriptClass.getUpdater();
Map<String, Object> properties = new LinkedHashMap<>();
addNotEmptyProperty(JCR_PRIMARY_TYPE, HIPPOSYS_UPDATERINFO, properties);
addNotEmptyProperty(HIPPOSYS_BATCHSIZE, updater.batchSize(), properties);
addNotEmptyProperty(HIPPOSYS_DESCRIPTION, updater.description(), properties);
addNotEmptyProperty(HIPPOSYS_DRYRUN, updater.dryRun(), properties);
addNotEmptyProperty(HIPPOSYS_PARAMETERS, updater.parameters(), properties);
if (StringUtils.isBlank(updater.xpath())) {
addNotEmptyProperty(HIPPOSYS_PATH, updater.path(), properties);
}
addNotEmptyProperty(HIPPOSYS_QUERY, updater.xpath(), properties);
addNotEmptyProperty(HIPPOSYS_SCRIPT, removeEmptyIndents(scriptClass.getContent()), properties);
addNotEmptyProperty(HIPPOSYS_THROTTLE, updater.throttle(), properties);
return Collections.singletonMap(getBootstrapPath(scriptClass), properties);
}
示例6: update
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public int update(long id, ReviewStatus reviewStatus, String reviewer, long zkMtime) throws ShepherException {
if (StringUtils.isBlank(reviewer) || reviewStatus == null) {
throw ShepherException.createIllegalParameterException();
}
try {
return snapshotMapper.update(id, reviewStatus.getValue(), reviewer, new Date(zkMtime));
} catch (Exception e) {
throw ShepherException.createDBUpdateErrorException();
}
}
示例7: processCommentsForPageUpdate
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Processes comments for page update.
*
* @param page
* the specified page to update
* @throws Exception
* exception
*/
public void processCommentsForPageUpdate(final JSONObject page) throws Exception {
final String pageId = page.getString(Keys.OBJECT_ID);
final List<JSONObject> comments = commentDao.getComments(pageId, 1, Integer.MAX_VALUE);
for (final JSONObject comment : comments) {
final String commentId = comment.getString(Keys.OBJECT_ID);
final String sharpURL = Comments.getCommentSharpURLForPage(page, commentId);
comment.put(Comment.COMMENT_SHARP_URL, sharpURL);
if (StringUtils.isBlank(comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID))) {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
}
if (StringUtils.isBlank(comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_NAME))) {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
}
commentDao.update(commentId, comment);
}
}
示例8: process
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public FResult<JSONObject> process(UploadRequest request) throws Exception {
Long commonFileId = null;
try {
File temporaryFile = new File(request.getTemporaryFilePath());
if (temporaryFile == null || !temporaryFile.isFile() || !temporaryFile.exists()) {
return FResult.newFailure(HttpResponseCode.SERVER_IO_READ, "上传失败");
}
String currentFileMd5 = request.getTemporaryFileMd5();
String fileId = uploadFileReturnFileId(request.getTemporaryFilePath(), request.getSuffix());
if (StringUtils.isBlank(fileId)) {
return FResult.newFailure(HttpResponseCode.SERVER_IO_WRITE, "上传文件到FastDFS失败,请检查FastDFS日志");
}
long nowTimestamp = System.currentTimeMillis();
// 要保存的对象
UploadFile commonFile = new UploadFile();
commonFile.setFilemd5(currentFileMd5);
// 保存主文件后,返回住表ID
log.debug("你可以控制是否要持久化这个文件");
commonFileId = commonFileService.addUploadFile(nowTimestamp, commonFile, temporaryFile, request, fileId);
if (commonFileId == null || commonFileId == 0) {
log.error("insert common_file failed,record:" + JSON.toJSONString(commonFile));
FileUtils.forceDelete(temporaryFile);
return FResult.newFailure(HttpResponseCode.SERVER_DB_ERROR, "保存上传记录失败");
}
return buildResult(request.getOriginalFilename(), request.getTemporaryFileSize(), request.getTemporaryFileMd5(), commonFile.getUrl(),
commonFile.getId());
} catch (Exception uploadException) {
log.error("普通文件上传过程中发生错误", uploadException);
return FResult.newFailure(HttpResponseCode.SERVER_ERROR, "文件上传过程中发生错误");
}
}
示例9: assertNonBlankArgs
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void assertNonBlankArgs(String elbName, String ec2InstanceId)
{
if (StringUtils.isBlank(elbName))
{
throw new IllegalArgumentException("Blank elbName");
}
if (StringUtils.isBlank(ec2InstanceId))
{
throw new IllegalArgumentException("Blank ec2InstanceId");
}
}
示例10: getHostByServer
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public InstanceInfo getHostByServer(Server server) {
InstanceInfo instanceInfo;
// TODO: check if redundant
if (server == null) {
loggingHelper.warn("No server found");
return null;
} else if (StringUtils.isBlank(server.getPath())) { // TODO: should we check that url is without templates instead?
instanceInfo = getAdvancedServiceInstance(server);
} else {
boolean applyFilter = true; // all traffic should go to whitelisted stacks
instanceInfo = getSimpleHostByServer(server, applyFilter);
if (isServerInstanceInvalid(instanceInfo)) {
// fallback from distribution
if (server.getReturnStatementType() == ReturnStatementType.DISTRIBUTION_RULE
|| server.getReturnStatementType() == ReturnStatementType.PATH_RULE) {
String logMessage = "falling back to default server";
sessionLog.write(sessionId.get(), logMessage);
log.info(logMessage);
instanceInfo = getDefaultHost();
}
}
}
if (instanceInfo == null) {
// TODO: builder
instanceInfo = new InstanceInfo(server, null);
}
return instanceInfo;
}
示例11: packageSign
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 组装签名的字段
*
* @param params
* 参数
* @param urlEncoder
* 是否urlEncoder
* @return String
*/
public static String packageSign(Map<String, String> params, boolean urlEncoder) {
// 先将参数以其参数名的字典序升序进行排序
TreeMap<String, String> sortedParams = new TreeMap<String, String>(params);
// 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Entry<String, String> param : sortedParams.entrySet()) {
String value = param.getValue();
if (StringUtils.isBlank(value)) {
continue;
}
if (first) {
first = false;
} else {
sb.append("&");
}
sb.append(param.getKey()).append("=");
if (urlEncoder) {
try {
value = urlEncode(value);
} catch (UnsupportedEncodingException e) {
}
}
sb.append(value);
}
return sb.toString();
}
示例12: checkIfEmptyPathExists
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private boolean checkIfEmptyPathExists(List<File> files){
boolean emptyPathExists = false;
if (files.size() > 0){
for (int i=0; i<files.size(); i++){
//Check if current folder of file is same as source folder
if(StringUtils.isBlank(files.get(i).getParent().toStringRelativeTo(sourceFolder))){
emptyPathExists = true;
break;
}
}
}
return emptyPathExists;
}
示例13: isNumeric
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 功能:数字判断
* @param str
* @return
*/
public static boolean isNumeric(String str) {
if (StringUtils.isBlank(str)) {
return false;
}
if (str.matches("\\d*")) {
return true;
} else {
return false;
}
}
示例14: appendItem
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void appendItem() {
String value = getStringByDialog("");
if (StringUtils.isBlank(value)) {
return;
}
JedisManager.withJedis(jedis -> jedis.lpush(currentKey, value));
refreshList();
}
示例15: get
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public Bucket get(final String bucketId) throws NiFiRegistryException, IOException {
if (StringUtils.isBlank(bucketId)) {
throw new IllegalArgumentException("Bucket ID cannot be blank");
}
return executeAction("Error retrieving bucket", () -> {
final WebTarget target = bucketsTarget
.path("/{bucketId}")
.resolveTemplate("bucketId", bucketId);
return getRequestBuilder(target).get(Bucket.class);
});
}