本文整理汇总了Java中org.apache.commons.lang3.StringUtils.contains方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.contains方法的具体用法?Java StringUtils.contains怎么用?Java StringUtils.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public Path find() throws BackgroundException {
final Path home = super.find();
if(home == DEFAULT_HOME) {
final String user;
final Credentials credentials = session.getHost().getCredentials();
if(StringUtils.contains(credentials.getUsername(), ':')) {
user = StringUtils.splitPreserveAllTokens(credentials.getUsername(), ':')[1];
}
else {
user = credentials.getUsername();
}
return new Path(new StringBuilder()
.append(Path.DELIMITER).append(session.getRegion())
.append(Path.DELIMITER).append("home")
.append(Path.DELIMITER).append(user)
.toString(), EnumSet.of(Path.Type.directory, Path.Type.volume));
}
return home;
}
示例2: map
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public BackgroundException map(final IOException failure) {
final Throwable[] stack = ExceptionUtils.getThrowables(failure);
for(Throwable t : stack) {
if(t instanceof BackgroundException) {
return (BackgroundException) t;
}
}
if(failure instanceof SSLException) {
return new SSLExceptionMappingService().map((SSLException) failure);
}
final StringBuilder buffer = new StringBuilder();
this.append(buffer, failure.getMessage());
for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
if(!StringUtils.contains(failure.getMessage(), cause.getMessage())) {
this.append(buffer, cause.getMessage());
}
}
return this.wrap(failure, buffer);
}
示例3: getDBType
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 获取数据库类型
*/
public static Database getDBType(DataSource dataSource){
String jdbcUrl = getJdbcUrlFromDataSource(dataSource);
if (StringUtils.contains(jdbcUrl, ":h2:")) {
return Database.H2 ;
} else if (StringUtils.contains(jdbcUrl, ":mysql:")) {
return Database.MYSQL ;
} else if (StringUtils.contains(jdbcUrl, ":oracle:")) {
return Database.ORACLE ;
} else if (StringUtils.contains(jdbcUrl, ":postgresql:")) {
return Database.POSTGRESQL ;
} else if (StringUtils.contains(jdbcUrl, ":sqlserver:")) {
return Database.SQL_SERVER ;
}
throw new IllegalArgumentException("Unknown Database of " + jdbcUrl);
}
示例4: getDisplayName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* @param locale ISO Language identifier
* @return Human readable language name in the target language
*/
public String getDisplayName(final String locale) {
java.util.Locale l;
if(StringUtils.contains(locale, "_")) {
l = new java.util.Locale(locale.split("_")[0], locale.split("_")[1]);
}
else {
l = new java.util.Locale(locale);
}
return StringUtils.capitalize(l.getDisplayName(l));
}
示例5: removeTimeZone
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String removeTimeZone(String dateTime) {
if (dateTime == null)
return null;
if (StringUtils.contains(dateTime, "+"))
return Helpers.split(dateTime, "+").get(0);
else if (StringUtils.contains(dateTime, "-"))
return Helpers.split(dateTime, "-").get(0);
return dateTime;
}
示例6: getByName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public ServiceDefinition getByName(String name) throws JAXBException, IOException {
ServiceDefinition data = new ServiceDefinition();
ArrayList<String> sDefs = util.getResourcesWithExtension("srvc", containerName);
Unmarshaller unmarshaller = JAXBContext.newInstance(ServiceDefinition.class).createUnmarshaller();
for (String sDef : sDefs) {
File file = new File(sDef);
if (file.exists() && StringUtils.contains(file.getName(), name)) {
String content = FileUtils.readFileToString(file);
data = (ServiceDefinition) unmarshaller.unmarshal(new StringReader(content));
break;
}
}
return data;
}
示例7: getLastComponent
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getLastComponent(String fullName) {
if (! StringUtils.contains(fullName, ".")) {
return fullName;
}
int index = fullName.lastIndexOf('.');
return fullName.substring(index + 1);
}
示例8: getByName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public ComponentType getByName(String name) throws JAXBException, IOException {
ComponentType data = new ComponentType();
ArrayList<String> cDefs = util.getResourcesWithExtension("cdef", containerName);
Unmarshaller unmarshaller = JAXBContext.newInstance(ComponentType.class).createUnmarshaller();
for (String cDef : cDefs) {
File file = new File(cDef);
if (file.exists() && StringUtils.contains(file.getName(), name)) {
String content = FileUtils.readFileToString(file);
data = ((JAXBElement<ComponentType>) unmarshaller.unmarshal(new StringReader(content))).getValue();
break;
}
}
return data;
}
示例9: setReferer
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 设置Referer
*
*/
public static void setReferer() {
String refererPath = (String) ServletActionContext.getRequest().getHeader(REFERER_KEY);
// 如果URL里没有本站域名的话,设置本站域名为默认值
if (!(StringUtils.contains(refererPath, YiDuConstants.yiduConf.getString(YiDuConfig.URI)) && StringUtils
.contains(refererPath, YiDuConstants.yiduConf.getString(YiDuConfig.URI)))) {
refererPath = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
}
HttpSession session = getSession(true);
logger.debug("REFERER_KEY : " + refererPath);
session.setAttribute(REFERER_KEY, refererPath);
}
示例10: relativize
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String relativize(String root, final String path) {
if(StringUtils.isBlank(root)) {
return path;
}
if(!StringUtils.equals(root, String.valueOf(Path.DELIMITER))) {
root = root + String.valueOf(Path.DELIMITER);
}
if(StringUtils.contains(path, root)) {
return StringUtils.substring(path, path.indexOf(root) + root.length());
}
return path;
}
示例11: removeEmptyTags
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String removeEmptyTags(String string, Class clazz) {
String ret = "";
ArrayList<String> fin = new ArrayList<String>();
if (StringUtils.contains(string, "\"\"")) {
String[] brk = StringUtils.split(string, " ");
for (String str : brk) {
if (!StringUtils.contains(str, "\"\""))
fin.add(str);
else if (StringUtils.contains(str, "/>"))
fin.add("/>");
else if (StringUtils.contains(str, ">"))
fin.add(">");
}
}
if (fin.size() > 0)
for (String val : fin) {
ret += val + " ";
}
else
ret = string;
try {
JAXBContext ctx = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
MarshallerImpl marshaller = (MarshallerImpl) ctx.createMarshaller();
marshaller.setProperty(MarshallerImpl.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new NamespacePrefixMapper());
StringWriter writer = new StringWriter();
marshaller.marshal(unmarshaller.unmarshal(new StringReader(ret)), writer);
ret = writer.toString();
} catch (Exception e) {
}
return ret;
}
示例12: wasSuccessful
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public boolean wasSuccessful() {
return StringUtils.contains(output, SvnUtils.REVISION)
&& !StringUtils.contains(output, SvnUtils.SVN_ERROR_PREFIX);
}
示例13: getRegion
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected String getRegion() {
if(StringUtils.contains(host.getRegion(), ':')) {
return StringUtils.splitPreserveAllTokens(host.getRegion(), ':')[0];
}
return host.getRegion();
}
示例14: accept
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public boolean accept(File arg0) {
return !(StringUtils.contains(arg0.getAbsolutePath(), "model"));
}
示例15: isPartJSON
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private boolean isPartJSON(Map<String, String> headers) {
String contentType = getMultipartHeaderValue(headers, HttpConfig.HttpHeaders.CONTENT_TYPE);
return StringUtils.contains(contentType, HttpConfig.ContentTypes.JSON);
}