List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:com.alibaba.otter.node.etl.common.db.dialect.mysql.MysqlDialect.java
public MysqlDialect(JdbcTemplate jdbcTemplate, LobHandler lobHandler, String name, String databaseVersion, int majorVersion, int minorVersion) { super(jdbcTemplate, lobHandler, name, majorVersion, minorVersion); sqlTemplate = new MysqlSqlTemplate(); if (StringUtils.contains(databaseVersion, "-TDDL-")) { isDRDS = true;/*ww w . j a v a2 s . co m*/ initShardColumns(); } }
From source file:com.googlecode.jtiger.modules.ecside.util.ExportViewUtils.java
public static String replaceNonBreakingSpaces(String value) { if (StringUtils.isBlank(value)) return ""; if (StringUtils.contains(value, " ")) { value = StringUtils.replace(value, " ", ""); }// w w w . j av a2s. co m return value; }
From source file:com.jgui.ttscrape.ConfigurableSportsPostProcessor.java
/** * Write the show to the show writer if it matches. */// www . j a v a 2s . co m @Override public void postProcess(Show s) { // make sure the category matches. if (StringUtils.equals(category, s.getCategory())) { String subtitle = s.getSubtitle(); // for each entry in the contains list, // see if the subtitle contains the string // (or doesn't if first char is bang char) boolean writeIt = false; for (String str : contains) { if (str.charAt(0) == '!') { String s1 = str.substring(1); if (StringUtils.contains(subtitle, s1)) { writeIt = false; break; } } else { if (StringUtils.contains(subtitle, str)) { writeIt = true; } } } if (writeIt) { writer.writeShow(WRITER_NAME, s); } } }
From source file:com.mmounirou.spotirss.spotify.tracks.XTracks.java
private String cleanTrackName(String trackName) { String[] spotifyExtensions = new String[] { " - Explicit Version", " - Live", " - Radio Edit" }; String strSong = trackName;//www . j a v a 2s . c o m for (String extensions : spotifyExtensions) { if (StringUtils.contains(strSong, extensions)) { strSong = "X " + StringUtils.remove(trackName, extensions); } } String[] braces = { "[]", "()" }; for (String brace : braces) { String extendedinfo = null; do { extendedinfo = StringUtils.defaultString( StringUtils.substringBetween(strSong, brace.charAt(0) + "", brace.charAt(1) + "")); if (StringUtils.isNotBlank(extendedinfo)) { if (StringUtils.startsWith(extendedinfo, "feat.")) { String strArtist = StringUtils.removeStart("feat.", extendedinfo); strSong = StringUtils.replace(strSong, String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), ""); m_artistsInTrackName.addAll(cleanArtist(strArtist)); } else { strSong = StringUtils.replace(strSong, String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), ""); strSong = "X " + strSong; } } } while (StringUtils.isNotBlank(extendedinfo)); } String[] strSongSplitted = strSong.split("featuring"); if (strSongSplitted.length > 1) { strSong = strSongSplitted[0]; m_artistsInTrackName.add(strSongSplitted[1]); } String[] strSongWithFeaturing = strSong.split("-"); if (strSongWithFeaturing.length > 1 && strSongWithFeaturing[1].contains("feat.")) { strSong = strSongWithFeaturing[0]; m_artistsInTrackName.addAll(cleanArtist(StringUtils.remove(strSongWithFeaturing[1], "feat."))); } else { strSongWithFeaturing = strSong.split("feat."); if (strSongWithFeaturing.length > 1) { strSong = strSongWithFeaturing[0]; m_artistsInTrackName.addAll(cleanArtist(strSongWithFeaturing[1])); } } return strSong.trim().toLowerCase(); }
From source file:gemlite.shell.converters.JobStatusConverter.java
@Override public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData, String optionContext, MethodTarget target) { if ((String.class.equals(targetType)) && (StringUtils.contains(optionContext, "param.context.job.status"))) { Set<String> status = new HashSet<String>(); status.add("STARTED"); status.add("COMPLETED"); for (String regionPath : status) { if (existingData != null) { if (regionPath.startsWith(existingData)) { completions.add(new Completion(regionPath)); }//ww w . ja v a2s . c o m } else { completions.add(new Completion(regionPath)); } } } return !completions.isEmpty(); }
From source file:gemlite.shell.converters.RegionConverter.java
public boolean supports(Class<?> type, String optionContext) { return (String.class.equals(type)) && (StringUtils.contains(optionContext, "param.context.region")); }
From source file:com.yahoo.flowetl.core.util.RegexUtil.java
/** * Gets the pattern for the given string by providing the rules to do * extraction./*from w ww .j av a 2s . c om*/ * * This is similar to how php does regex to match you provide in the format * /REGEX/options where options currently are "i" for case insensitive and * "u" for unicode and "m" for multiline and "s" for dotall and the value * inside the // is the regex to use * * @param str * the string to parsed the pattern out of * * @param cache * whether to cache the compiled pattern * * @return the pattern * * @throws PatternSyntaxException * * the pattern syntax exception if it has wrong syntax */ public static Pattern getPattern(String str, boolean cache) throws PatternSyntaxException { if (str == null) { return null; } // see if we made it before... Pattern p = compiledPats.get(str); if (p != null) { return p; } Matcher mat = patExtractor.matcher(str); if (mat.matches() == false) { throw new PatternSyntaxException("Invalid syntax provided", str, -1); } String regex = mat.group(1); String opts = mat.group(2); int optsVal = 0; if (StringUtils.contains(opts, "i")) { optsVal |= Pattern.CASE_INSENSITIVE; } if (StringUtils.contains(opts, "u")) { optsVal |= Pattern.UNICODE_CASE; } if (StringUtils.contains(opts, "m")) { optsVal |= Pattern.MULTILINE; } if (StringUtils.contains(opts, "s")) { optsVal |= Pattern.DOTALL; } // compile and store it p = Pattern.compile(regex, optsVal); if (cache) { compiledPats.put(str, p); } return p; }
From source file:info.magnolia.module.files.ModuleFileExtractorTransformer.java
@Override public String accept(String resourcePath) { final boolean thisIsAFileWeWant = resourcePath.startsWith("/mgnl-files/") && StringUtils.contains(resourcePath, "/" + moduleName + "/"); if (!thisIsAFileWeWant) { return null; }/*from ww w . ja v a2 s . c o m*/ final String relTargetPath = StringUtils.removeStart(resourcePath, "/mgnl-files/"); return Path.getAbsoluteFileSystemPath(relTargetPath); }
From source file:hydrograph.ui.validators.impl.IntegerOrParameterValidationRule.java
@Override public boolean validate(Object object, String propertyName, Map<String, List<FixedWidthGridRow>> inputSchemaMap, boolean isJobImported) { String value = (String) object; if (StringUtils.isNotBlank(value)) { Matcher matcher = Pattern.compile("[\\d]*").matcher(value); if ((matcher.matches()) || ((StringUtils.startsWith(value, "@{") && StringUtils.endsWith(value, "}")) && !StringUtils.contains(value, "@{}"))) { return true; }/* w w w . jav a2s .com*/ errorMessage = propertyName + " is mandatory"; } errorMessage = propertyName + " is not integer value or valid parameter"; return false; }
From source file:com.fengduo.bee.commons.core.lang.ClassLoaderUtils.java
public static List<?> load(String classpath, ClassFilter filter) throws Exception { List<Object> objs = new ArrayList<Object>(); URL resource = ClassLoaderUtils.class.getClassLoader().getResource(classpath); logger.debug("Search from {} ...", resource.getPath()); List<String> classnameArray; if ("jar".equalsIgnoreCase(resource.getProtocol())) { String file = resource.getFile(); String jarName = file.substring(file.indexOf("/"), (file.lastIndexOf("jar") + 3)); classnameArray = getClassNamesInPackage(jarName, classpath); } else {//from w w w .ja va 2 s . c o m Collection<File> listFiles = FileUtils.listFiles(new File(resource.getPath()), null, false); String classNamePrefix = classpath.replaceAll("/", "."); classnameArray = new ArrayList<String>(); for (File file : listFiles) { String name = file.getName(); if (name.endsWith(".class") == false) { continue; } if (StringUtils.contains(name, '$')) { logger.warn("NOT SUPPORT INNERT CLASS" + file.getAbsolutePath()); continue; } String classname = classNamePrefix + "." + StringUtils.remove(name, ".class"); classnameArray.add(classname); } } for (String classname : classnameArray) { try { Class<?> loadClass = ClassLoaderUtils.class.getClassLoader().loadClass(classname); if (filter != null && !filter.filter(loadClass)) { logger.error("{} {} ", classname, filter); continue; } // if (ClassLoaderUtil.class.isAssignableFrom(loadClass) == false) { // logger.error("{} ?????", classname); // continue; // } Object newInstance = loadClass.newInstance(); objs.add(newInstance); logger.debug("load {}/{}.class success", resource.getPath(), classname); } catch (Exception e) { e.printStackTrace(); logger.error("load " + resource.getPath() + "/" + classname + ".class failed", e); } } return objs; }