List of usage examples for org.apache.commons.lang StringUtils containsAny
public static boolean containsAny(String str, String searchChars)
Checks if the String contains any character in the given set of characters.
From source file:de.tudarmstadt.ukp.csniper.resbuild.stuff.FilterPipe.java
public static void main(String[] args) throws IOException { List<String> files = new ArrayList<String>(); int i = 0;// www . j av a 2 s . c o m for (File file : FileUtils.listFiles(new File(base), new String[] { "csv" }, true)) { String text = FileUtils.readFileToString(file, "UTF-8"); files.add(StringUtils.substringBeforeLast(file.getName(), ".") + ".xml"); if (StringUtils.containsAny(text, "")) { files.remove(StringUtils.substringBeforeLast(file.getName(), ".") + ".xml"); } i++; if (i % 100 == 0) { System.out.println("ok:" + i); } } FileUtils.writeLines(new File("D:\\hadoop\\output\\BNC_new\\exclusions.txt"), "UTF-8", files); }
From source file:com.enonic.cms.business.core.content.ContentNameValidator.java
public static void validate(String contentName) { if (StringUtils.isEmpty(contentName)) { throw new ContentNameValidatorException("Content name cannot be empty"); }/*from w w w .j a v a 2 s . co m*/ if (StringUtils.startsWith(contentName, " ") || StringUtils.endsWith(contentName, " ")) { throw new ContentNameValidatorException("Content name cannot start or end with whitespace"); } if (StringUtils.containsAny(contentName, FORBIDDEN_CHARS)) { throw new ContentNameValidatorException( "Content name cannot contain any of these characters: " + FORBIDDEN_CHARS); } if (contentName.length() > CONTENT_NAME_MAX_LENGTH) { throw new ContentNameValidatorException("Content name is too long: " + contentName.length() + " . Maximum length is " + CONTENT_NAME_MAX_LENGTH + " characters."); } }
From source file:com.backbase.expert.extensions.sushi.util.Base64Serializer.java
/** * Checks if an Base64 encoded string is also URL encoded. * Base64 characters which will change during URL encoding are =, + and /. * This will result in a % sign//from w w w . ja v a2s .c om * * @param base64 * @return */ public static boolean isBase64StringURLEncoded(String base64) { if (StringUtils.containsAny(base64, "=+/")) { return false; } return true; }
From source file:com.bstek.dorado.util.PathUtils.java
public static boolean isSafePath(String path) { boolean dangerous = (path.contains("..") || StringUtils.containsAny(path, ",: \n\r")); return !dangerous; }
From source file:gov.nih.nci.cabig.caaers.utils.ranking.Ranker.java
public Ranker(String searchStr) { this.searchStr = searchStr; patternLength = searchStr.length();//w w w .j a va2 s .c o m escapedSearchStr = searchStr; //11 characters with special meanings: the opening square bracket [, the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar // or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening round bracket ( and the closing round bracket ). // These special characters are often called "metacharacters". char[] metachars = new char[] { '\\', '(', ')', '[', ']', '^', '$', '.', '?', '+', '*', '|' }; if (StringUtils.containsAny(searchStr, metachars)) { String[] metaStr = { "\\", "(", ")", "[", "]", "^", "$", ".", "?", "+", "*", "|" }; String[] metaEscapedStr = { "\\\\", "\\(", "\\)", "\\[", "\\]", "\\^", "\\$", "\\.", "\\?", "\\+", "\\*", "\\|" }; escapedSearchStr = StringUtils.replaceEach(searchStr, metaStr, metaEscapedStr); } p = Pattern.compile(escapedSearchStr, Pattern.CASE_INSENSITIVE); }
From source file:eu.esdihumboldt.hale.io.xsd.reader.internal.constraint.XLinkReference.java
@Override public Object idToReference(Object id) { if (id == null || id.toString().isEmpty()) { throw new IllegalArgumentException("ID must not be null or empty"); }/*www . j a v a2 s .co m*/ // XXX possible performance impact? this check is done for every // reference... if (!StringUtils.isNumeric(id.toString().substring(0, 1)) && !StringUtils.containsAny(id.toString(), "\"\\ !#$%&'()*+,/:;<=>?@[]^`{|}~")) { // if the ID is a valid NCName convert it to a local XPointer return "#" + id.toString(); } else { return super.idToReference(id); } }
From source file:com.smartitengineering.cms.api.impl.workspace.WorkspaceIdImpl.java
public void setGlobalNamespace(String globalNamespace) { if (StringUtils.isBlank(globalNamespace) || StringUtils.containsAny(globalNamespace, new char[] { ':' })) { throw new IllegalArgumentException( String.format(ContentTypeIdImpl.STANDARD_ERROR_MSG, "Global Namespace")); }/*from ww w. j a v a2s . c o m*/ this.globalNamespace = globalNamespace; }
From source file:com.smartitengineering.cms.api.impl.type.ContentTypeIdImpl.java
@Override public void setNamespace(String newNamespace) { if (StringUtils.isBlank(newNamespace) || StringUtils.containsAny(newNamespace, new char[] { ':' })) { throw new IllegalArgumentException(String.format(STANDARD_ERROR_MSG, "Namespace")); }/*from w w w.j av a 2 s .c o m*/ this.newNamespace = newNamespace; }
From source file:com.smartitengineering.cms.api.impl.workspace.WorkspaceIdImpl.java
public void setName(String name) { if (StringUtils.isBlank(name) || StringUtils.containsAny(name, new char[] { ':' })) { throw new IllegalArgumentException( String.format(ContentTypeIdImpl.STANDARD_ERROR_MSG, "Workspace name")); }//w w w.ja v a 2s . c o m this.name = name; }
From source file:com.smartitengineering.cms.api.impl.type.ContentTypeIdImpl.java
@Override public void setName(String newContentTypeName) throws IllegalArgumentException { if (StringUtils.isBlank(newContentTypeName) || StringUtils.containsAny(newContentTypeName, new char[] { ':' })) { throw new IllegalArgumentException(String.format(STANDARD_ERROR_MSG, "Content Type Name")); }//w w w . j a v a 2 s . co m this.newContentTypeName = newContentTypeName; }