List of usage examples for org.apache.commons.lang3 StringUtils containsNone
public static boolean containsNone(final CharSequence cs, final String invalidChars)
Checks that the CharSequence does not contain certain characters.
A null CharSequence will return true .
From source file:kenh.expl.functions.ContainsNone.java
public boolean process(String cs, String invalidChars) { return StringUtils.containsNone(cs, invalidChars); }
From source file:com.xpn.xwiki.render.XWikiVelocityRenderer.java
/** * {@inheritDoc}//from www . j a v a 2s. c o m * * @see XWikiRenderer#render(String,XWikiDocument,XWikiDocument,XWikiContext) */ public String render(String content, XWikiDocument contentdoc, XWikiDocument contextdoc, XWikiContext context) { // If there are no # or $ characters than the content doesn't contain any velocity code // see: http://velocity.apache.org/engine/releases/velocity-1.5/vtl-reference-guide.html if (StringUtils.containsNone(content, VELOCITY_CHARACTERS)) { return content; } VelocityManager velocityManager = Utils.getComponent(VelocityManager.class); VelocityContext vcontext = velocityManager.getVelocityContext(); Document previousdoc = (Document) vcontext.get("doc"); content = context.getUtil().substitute("s/#include\\(/\\\\#include\\(/go", content); try { vcontext.put("doc", contextdoc.newDocument(context)); try { // We need to do this in case there are any macros in the content List<String> macrolist = context.getWiki().getIncludedMacros(contentdoc.getSpace(), content, context); if (macrolist != null) { com.xpn.xwiki.XWiki xwiki = context.getWiki(); for (String docname : macrolist) { LOGGER.debug( "Pre-including macro topic " + docname + " in context " + contextdoc.getFullName()); xwiki.include(docname, true, context); } } } catch (Exception e) { // Make sure we never fail LOGGER.warn("Exception while pre-including macro topics", e); } return evaluate(content, contextdoc.getPrefixedFullName(), vcontext, context); } finally { if (previousdoc != null) { vcontext.put("doc", previousdoc); } } }
From source file:com.intuit.wasabi.api.pagination.filters.PaginationFilter.java
/** * Tests an object's properties according the current filter. * * @param object the object to test/*from ww w. j a va 2 s . co m*/ * @param enumType the possible properties * @param <V> the enum's type * @return true or false depending on the test result. For details see this class' documentation * {@link PaginationFilter}. */ public final <V extends Enum<V> & PaginationFilterProperty> boolean test(T object, Class<V> enumType) { if (StringUtils.isBlank(filter)) { return true; } else if (filter.contains(SEPARATOR)) { if (StringUtils.containsNone(StringUtils.substringBefore(filter, SEPARATOR), DELIMITER)) { return testFields(object, enumType); } return testFields(object, enumType) && testFulltext(object, enumType); } return testFulltext(object, enumType); }
From source file:com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.java
private Optional<String> parseValidVersion(final String version) { String validVersion = null;//from w ww. j a v a2 s. c om if (version.endsWith(VERSION_SUFFIX) && StringUtils.containsNone(version, FUZZY_VERSION_CHARACTERS)) { validVersion = StringUtils.replaceChars(version, VERSION_CHARACTERS, "").trim(); } return Optional.ofNullable(validVersion); }
From source file:com.moviejukebox.plugin.ImdbPlugin.java
private boolean extractDirectorsFromFullCredits(Movie movie, String fullcreditsXML, boolean overrideNormal, boolean overridePeople) { // count for already set directors int count = 0; // flag to indicate if directors must be cleared boolean clearDirectors = Boolean.TRUE; boolean clearPeopleDirectors = Boolean.TRUE; // flag to indicate if match has been found boolean found = Boolean.FALSE; for (String directorMatch : new String[] { "Directed by", "Director", "Directors" }) { if (fullcreditsXML.contains(HTML_GT + directorMatch + " </h4>")) { for (String member : HTMLTools.extractTags(fullcreditsXML, HTML_GT + directorMatch + " </h4>", HTML_TABLE_END, HTML_A_START, HTML_A_END, Boolean.FALSE)) { int beginIndex = member.indexOf("href=\"/name/"); if (beginIndex > -1) { String personID = member.substring(beginIndex + 12, member.indexOf("/", beginIndex + 12)); String director = member.substring(member.indexOf(HTML_GT, beginIndex) + 1).trim(); if (overrideNormal) { // clear directors if not already done if (clearDirectors) { movie.clearDirectors(); clearDirectors = Boolean.FALSE; }/*from www.ja va 2s . c o m*/ // add director movie.addDirector(director, IMDB_PLUGIN_ID); } if (overridePeople) { // clear directors if not already done if (clearPeopleDirectors) { movie.clearPeopleDirectors(); clearPeopleDirectors = Boolean.FALSE; } // add director, but check that there are no invalid characters in the name which may indicate a bad scrape if (StringUtils.containsNone(director, "<>:/")) { movie.addDirector(IMDB_PLUGIN_ID + ":" + personID, director, imdbInfo.getImdbSite() + IMDB_NAME + personID + "/", IMDB_PLUGIN_ID); found = Boolean.TRUE; count++; } else { LOG.debug("Invalid director name found: '{}'", director); } } if (count == directorMax) { break; } } } } if (found) { // We found a match, so stop search. break; } } return found; }
From source file:org.apache.jmeter.save.CSVSaveService.java
/** * <p> Returns a <code>String</code> value for a character-delimited column * value enclosed in the quote character, if required. </p> * // w w w .ja v a 2 s . com * <p> If the value contains a special character, then the String value is * returned enclosed in the quote character. </p> * * <p> Any quote characters in the value are doubled up. </p> * * <p> If the value does not contain any special characters, then the String * value is returned unchanged. </p> * * <p> N.B. The list of special characters includes the quote character. * </p> * * @param input the input column String, may be null (without enclosing * delimiters) * * @param specialChars special characters; second one must be the quote * character * * @return the input String, enclosed in quote characters if the value * contains a special character, <code>null</code> for null string input */ public static String quoteDelimiters(String input, char[] specialChars) { if (StringUtils.containsNone(input, specialChars)) { return input; } StringBuilder buffer = new StringBuilder(input.length() + 10); final char quote = specialChars[1]; buffer.append(quote); for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == quote) { buffer.append(quote); // double the quote char } buffer.append(c); } buffer.append(quote); return buffer.toString(); }
From source file:org.duracloud.storage.domain.ContentByteRange.java
/** * Parses the Range HTTP header value. Only a single range is supported (others are dropped). * * @param range Range header included in HTTP request * @throws IllegalArgumentException if range value is not valid *///from www . j a va 2s .co m protected void parseRange(String range) { String prefix = "bytes="; if (!range.startsWith(prefix) || StringUtils.containsNone(range, "-")) { throw new IllegalArgumentException(getUsage(range)); } else { // Strip the prefix and drop all but the first range (if there is a list) String byteRange = range.substring(prefix.length()).split(",")[0]; try { // Parse out the range values setRangeStart(byteRange.substring(0, byteRange.indexOf("-"))); setRangeEnd(byteRange.substring(byteRange.indexOf("-") + 1, byteRange.length())); } catch (NumberFormatException e) { throw new IllegalArgumentException(getUsage(range)); } // Verify that there is either a start or end value for the range (or both) if (null == getRangeStart() && null == getRangeEnd()) { throw new IllegalArgumentException(getUsage(range)); } } }
From source file:org.easyxml.xml.Attribute.java
/** * Constructor of a new Attribute of a XmlElemwent. Notice that for * simplicity, there is no checking of if there is already an attribute with * the same name existed within the element. * // ww w. j av a 2 s .c o m * @param element * - Element containing the attribute. * @param name * - Name of the new attribute. * @param value * - Value of the new attribute. */ public Attribute(Element element, String name, String value) { if (StringUtils.isBlank(name)) { throw new InvalidParameterException("Name of an attribute cannot be null or blank!"); } if (value == null) { throw new InvalidParameterException("Value of an attribute cannot be null!"); } if (!StringUtils.containsNone(name, Element.EntityReferenceKeys)) { throw new InvalidParameterException(String.format( "\"{s}\" cannot contain any of the 5 chars: \'<\', \'>\', \'&\', \'\'\', \'\"\'", name)); } this.name = name; setValue(value); }
From source file:org.easyxml.xml.Element.java
/** * //from w ww.j av a2 s .c o m * Constructor with Element tag name, its parent element and innerText. * * @param name * - Tag name of the element. * * @param parent * - Container of this element. * * @param value * - InnerText, notice that is would be escaped before stored to * this.value. */ public Element(String name, Element parent, String value) { if (StringUtils.isBlank(name)) { throw new InvalidParameterException("Name of an element cannot be null or blank!"); } if (!StringUtils.containsNone(name, EntityReferenceKeys)) { throw new InvalidParameterException( String.format("\"{s}\" cannot contain any of the 5 chars: \'<\', \'>\', \'&\', \'\'\', \'\"\'" , name)); } this.name = name; setValue(value); if (parent != null) { setParent(parent); // Update the Children map of the parent element after setting name this.parent.addChildElement(this); } }
From source file:org.polymap.rhei.fulltext.SearchDispatcher.java
@Override public Iterable<String> propose(final String term, final int maxResults, final String field) throws Exception { // call searches in separate threads // XXX score results List<Future<List<String>>> results = new ArrayList(); for (final FulltextIndex searcher : searchers) { results.add(executorService.submit(new Callable<List<String>>() { @Override/*w w w .ja v a 2 s .c o m*/ public List<String> call() throws Exception { log.info("Searcher started: " + searcher.getClass().getSimpleName()); Iterable<String> records = searcher.propose(term, maxResults, field); // use real list (not Iterables) in order to make sure // this processing is done inside the thread List<String> result = new ArrayList(maxResults); Iterator<String> it = records.iterator(); while (it.hasNext() && result.size() <= maxResults) { String record = it.next(); // has the record any result anyway? if (StringUtils.containsNone(term, SEPARATOR_CHARS) || !search(record, 1).iterator().hasNext()) { result.add(record); } } return result; } })); } // wait for threads; concat all records return concat(transform(results, new Function<Future<List<String>>, List<String>>() { public List<String> apply(Future<List<String>> future) { try { return future.get(); } catch (Exception e) { log.warn("", e); return new ArrayList(); } } })); }