本文整理汇总了Java中org.apache.commons.lang3.StringUtils.prependIfMissing方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.prependIfMissing方法的具体用法?Java StringUtils.prependIfMissing怎么用?Java StringUtils.prependIfMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.prependIfMissing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatPostContent
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String formatPostContent(Post post) {
String content = post.getPostContent();
String imageHtml = "<img alt=\"\" src=\"%s\" class=\"%s-image\"/>\n";
String thumbnail = String.format(imageHtml, post.getPostImage(), "thumbnail");
String feature = String.format(imageHtml, post.getPostImage(), "feature");
switch (post.getDisplayType()) {
case LINK_SUMMARY:
content = StringUtils.prependIfMissing(content, thumbnail);
break;
case LINK_FEATURE:
content = StringUtils.appendIfMissing(content, feature);
break;
case LINK:
break;
}
return content;
}
示例2: getCanonicalizedResourcePath
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Returns the canonicalized resource path for the service endpoint.
*/
protected String getCanonicalizedResourcePath(final String path) {
try {
return StringUtils.prependIfMissing(urlCodec.encode(StringUtils.trimToEmpty(path)).replace("%2F", "/"), "/");
} catch (final EncoderException e) {
throw new TechnicalException("Error during resource path encoding", e);
}
}
示例3: buildLink
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Convert a site-relative link to absolute, because in emails we can't use @{}.
* Example: th:href="${beans.yadaEmailService.buildLink('/read/234')}"
* @param relativeLink
* @return absolute link
*/
public String buildLink(String relativeLink) {
String myServerAddress = config.getServerAddress();
String relative = StringUtils.prependIfMissing(relativeLink, "/");
return myServerAddress + relative;
}