Java Code Examples for org.apache.commons.lang3.StringUtils.contains()

The following are Jave code examples for showing how to use contains() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: tasfe-framework   File: JPAUtil.java   View Source Code Vote up 8 votes
/**
 * 获取数据库类型
 */
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);
}
 
Example 2
Project: cyberduck   File: IRODSHomeFinderService.java   View Source Code Vote up 7 votes
@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;
}
 
Example 3
Project: cyberduck   File: DefaultIOExceptionMappingService.java   View Source Code Vote up 7 votes
@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);
}
 
Example 4
Project: cyberduck   File: Preferences.java   View Source Code Vote up 6 votes
/**
 * @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));
}
 
Example 5
Project: HL7Receiver   File: DateParser.java   View Source Code Vote up 6 votes
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;
}
 
Example 6
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesUtil.java   View Source Code Vote up 6 votes
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;
}
 
Example 7
Project: ja-micro   File: RegistrationManager.java   View Source Code Vote up 6 votes
private String getLastComponent(String fullName) {
    if (! StringUtils.contains(fullName, ".")) {
        return fullName;
    }
    int index = fullName.lastIndexOf('.');
    return fullName.substring(index + 1);
}
 
Example 8
Project: Open_Source_ECOA_Toolset_AS5   File: CompDefUtil.java   View Source Code Vote up 6 votes
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;
}
 
Example 9
Project: YiDu-Novel   File: LoginManager.java   View Source Code Vote up 6 votes
/**
 * 设置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);
}
 
Example 10
Project: cyberduck   File: PathRelativizer.java   View Source Code Vote up 6 votes
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;
}
 
Example 11
Project: Open_Source_ECOA_Toolset_AS5   File: ParseUtil.java   View Source Code Vote up 6 votes
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;
}
 
Example 12
Project: SVNAutoMerger   File: UpdateBranch.java   View Source Code Vote up 5 votes
@Override
public boolean wasSuccessful() {
  return StringUtils.contains(output, SvnUtils.REVISION)
      && !StringUtils.contains(output, SvnUtils.SVN_ERROR_PREFIX);
}
 
Example 13
Project: cyberduck   File: IRODSSession.java   View Source Code Vote up 5 votes
protected String getRegion() {
    if(StringUtils.contains(host.getRegion(), ':')) {
        return StringUtils.splitPreserveAllTokens(host.getRegion(), ':')[0];
    }
    return host.getRegion();
}
 
Example 14
Project: Open_Source_ECOA_Toolset_AS5   File: CopyrightAmend.java   View Source Code Vote up 5 votes
@Override
public boolean accept(File arg0) {
	return !(StringUtils.contains(arg0.getAbsolutePath(), "model"));
}
 
Example 15
Project: Open_Source_ECOA_Toolset_AS5   File: CopyrightAmend.java   View Source Code Vote up 5 votes
@Override
public boolean accept(File arg0) {
	return !(StringUtils.contains(arg0.getAbsolutePath(), "jaxbclasses"));
}
 
Example 16
Project: dcs-sdk-java   File: MultipartParser.java   View Source Code Vote up 5 votes
private boolean isPartJSON(Map<String, String> headers) {
    String contentType = getMultipartHeaderValue(headers, HttpConfig.HttpHeaders.CONTENT_TYPE);
    return StringUtils.contains(contentType, HttpConfig.ContentTypes.JSON);
}
 
Example 17
Project: unitstack   File: ListObjectsResponder.java   View Source Code Vote up 5 votes
private boolean isPartUploadRequest(MockRequest request) {
  String action = request.getBodyParameters().get(S3RequestTransformer.ACTION);
  return StringUtils.contains(action, "uploads&");
}
 
Example 18
Project: Open_Source_ECOA_Toolset_AS5   File: CopyrightAmend.java   View Source Code Vote up 5 votes
@Override
public boolean accept(File arg0, String arg1) {
	return !(StringUtils.contains(arg0.getAbsolutePath(), "model"));
}
 
Example 19
Project: iab-spiders-and-robots-java-client   File: IncludeRecord.java   View Source Code Vote up 5 votes
public boolean isPresent(String userAgentLowCase) {
    return startOfStringFlag ? StringUtils.startsWith(userAgentLowCase, userAgentPattern) :
            StringUtils.contains(userAgentLowCase, userAgentPattern);
}
 
Example 20
Project: unitstack   File: MultipartUploadResponder.java   View Source Code Vote up 5 votes
private boolean isActionInitialize(MockRequest request) {
  String url = request.getBodyParameters().get(S3RequestTransformer.PARAMETER_URL_NAME);
  return StringUtils.contains(url, "?uploads");
}