本文整理匯總了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;
}