List of usage examples for org.apache.commons.lang3 StringUtils contains
public static boolean contains(final CharSequence seq, final CharSequence searchSeq)
Checks if CharSequence contains a search CharSequence, handling null .
From source file:org.exist.mongodb.xquery.gridfs.Stream.java
/** * Verify if HTTP agent supports GZIP content encoding. *//*from ww w . j av a 2 s . c o m*/ private boolean isGzipEncodingSupported(XQueryContext context) { try { RequestWrapper request = getRequestWrapper(context); String content = request.getHeader(ACCEPT_ENCODING); if (StringUtils.contains(content, GZIP)) { return true; } } catch (XPathException ex) { LOG.error(ex.getMessage(), ex); } return false; }
From source file:org.flowable.common.engine.impl.el.function.VariableContainsAnyExpressionFunction.java
@SuppressWarnings({ "rawtypes" }) public static boolean containsAny(VariableScope variableScope, String variableName, Object... values) { Object variableValue = getVariableValue(variableScope, variableName); if (variableValue != null) { if (variableValue instanceof String) { String variableStringValue = (String) variableValue; for (Object value : values) { String stringValue = (String) value; if (StringUtils.contains(variableStringValue, stringValue)) { return true; }/*from w w w . ja v a 2 s. c o m*/ } return false; } else if (variableValue instanceof Collection) { Collection collectionVariableValue = (Collection) variableValue; for (Object value : values) { if (VariableContainsExpressionFunction.collectionContains(collectionVariableValue, value)) { return true; } } return false; } else if (variableValue instanceof ArrayNode) { ArrayNode arrayNodeVariableValue = (ArrayNode) variableValue; for (Object value : values) { if (VariableContainsExpressionFunction.arrayNodeContains(arrayNodeVariableValue, value)) { return true; } } return false; } } return false; }
From source file:org.flowable.common.engine.impl.el.function.VariableContainsExpressionFunction.java
@SuppressWarnings({ "rawtypes" }) public static boolean contains(VariableScope variableScope, String variableName, Object... values) { Object variableValue = getVariableValue(variableScope, variableName); if (variableValue != null) { if (variableValue instanceof String) { String variableStringValue = (String) variableValue; for (Object value : values) { String stringValue = (String) value; if (!StringUtils.contains(variableStringValue, stringValue)) { return false; }/*from ww w .ja va 2s .co m*/ } return true; } else if (variableValue instanceof Collection) { Collection collectionVariableValue = (Collection) variableValue; for (Object value : values) { if (!collectionContains(collectionVariableValue, value)) { return false; } } return true; } else if (variableValue instanceof ArrayNode) { ArrayNode arrayNodeVariableValue = (ArrayNode) variableValue; for (Object value : values) { if (!arrayNodeContains(arrayNodeVariableValue, value)) { return false; } } return true; } } return false; }
From source file:org.goko.core.common.measure.quantity.AbstractQuantity.java
protected Q parse(String value, List<Unit<Q>> lstUnit) throws GkException { // Try to extract unit String leftNumericValue = value; Unit<Q> foundUnit = null;/*from w w w . ja v a 2s .c om*/ for (Unit<Q> existingUnit : lstUnit) { if (StringUtils.contains(value, existingUnit.getSymbol())) { leftNumericValue = StringUtils.remove(value, existingUnit.getSymbol()).trim(); foundUnit = (Unit<Q>) existingUnit; break; } } if (foundUnit == null) { throw new GkTechnicalException("No unit found in quantity [" + leftNumericValue + "]"); } return createQuantity(new BigDecimal(leftNumericValue), foundUnit); }
From source file:org.graylog.plugins.pipelineprocessor.functions.strings.Contains.java
@Override public Boolean evaluate(FunctionArgs args, EvaluationContext context) { final String value = valueParam.required(args, context); final String search = searchParam.required(args, context); final boolean ignoreCase = ignoreCaseParam.optional(args, context).orElse(false); if (ignoreCase) { return StringUtils.containsIgnoreCase(value, search); } else {/*w w w. j a va 2 s .c o m*/ return StringUtils.contains(value, search); } }
From source file:org.gvnix.addon.jpa.addon.entitylistener.JpaOrmEntityListenerMetadata.java
/** * @param metadataIdentificationString//w w w . j a va 2s .c om * @return if metadata is valid */ public static boolean isValid(String metadataIdentificationString) { return PhysicalTypeIdentifierNamingUtils.isValid(PROVIDES_TYPE_STRING, StringUtils.substringBefore(metadataIdentificationString, METADATA_SOURCE_DELIMITER)) && StringUtils.contains(metadataIdentificationString, METADATA_SOURCE_DELIMITER) && StringUtils.isNotBlank( StringUtils.substringAfter(metadataIdentificationString, METADATA_SOURCE_DELIMITER)); }
From source file:org.gvnix.web.json.BindingResultSerializer.java
/** * Loads an object field error in errors map. * <p/>/*from www. ja v a 2s. c o m*/ * This method identifies if referred object property is an array, an object * or a simple property to decide how to store the error message. * * @param error * @param fieldNamePath * @param objectErrors */ @SuppressWarnings("unchecked") private void loadObjectError(FieldError error, String fieldNamePath, Map<String, Object> objectErrors) { String propertyName; boolean isObject = false; boolean isList = false; // Get this property name and if is a object property if (StringUtils.contains(fieldNamePath, ".")) { isObject = true; propertyName = StringUtils.substringBefore(fieldNamePath, "."); } else { isObject = false; propertyName = fieldNamePath; } // Check if property is an array or a list isList = StringUtils.contains(propertyName, "["); // Process a list item property if (isList) { // Get property name String listPropertyName = StringUtils.substringBefore(propertyName, "["); // Get referred item index String index = StringUtils.substringBefore(StringUtils.substringAfter(propertyName, "["), "]"); // Get item path String itemPath = StringUtils.substringAfter(fieldNamePath, "."); // Get container of list property errors Map<String, Object> listErrors = (Map<String, Object>) objectErrors.get(listPropertyName); if (listErrors == null) { // property has no errors yet: create a container for it listErrors = new HashMap<String, Object>(); objectErrors.put(listPropertyName, listErrors); } // Get current item errors Map<String, Object> itemErrors = (Map<String, Object>) listErrors.get(index); if (itemErrors == null) { // item has no errors yet: create a container for it itemErrors = new HashMap<String, Object>(); listErrors.put(index, itemErrors); } // Load error in item property path loadObjectError(error, itemPath, itemErrors); } else if (isObject) { // It's not a list but it has properties in it value // Get current property errors Map<String, Object> propertyErrors = (Map<String, Object>) objectErrors.get(propertyName); if (propertyErrors == null) { // item has no errors yet: create a container for it propertyErrors = new HashMap<String, Object>(); objectErrors.put(propertyName, propertyErrors); } // Get error sub path String subFieldPath = StringUtils.substringAfter(fieldNamePath, "."); // Load error in container loadObjectError(error, subFieldPath, propertyErrors); } else { // standard property with no children value // Store error message in container objectErrors.put(propertyName, error.getDefaultMessage()); } }
From source file:org.jbb.lib.logging.health.LogbackStatusHealthCheck.java
private boolean fallbackWasBeingRegistered(Status status) { return StringUtils.contains(status.getMessage(), REGISTERING_FALLBACK_MESSAGE); }
From source file:org.jboss.windup.rules.apps.java.scan.provider.DiscoverArchiveLicenseFilesRuleProvider.java
@Override public void perform(GraphRewrite event, EvaluationContext context, ArchiveModel payload) { Rule rule = (Rule) context.get(Rule.class); Set<FileModel> licenseFiles = findLicense(payload); if (licenseFiles.isEmpty()) { // no licenses found, skip this one return;//from ww w. ja va2s . c o m } TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext()); GraphService<LicenseModel> licenseService = new GraphService<>(event.getGraphContext(), LicenseModel.class); for (FileModel license : licenseFiles) { LOG.info("Classifying: " + license.getFileName() + " as License within archive: " + payload.getArchiveName()); // http://opensource.org/licenses/ try (InputStream stream = license.asInputStream()) { String content = IOUtils.toString(stream); if (StringUtils.containsIgnoreCase(content, "Apache License, Version 2.0")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Apache License 2.0", "Apache License 2.0 File", "http://www.apache.org/licenses/LICENSE-2.0"); } else if (StringUtils.containsIgnoreCase(content, "Apache Software License, Version 1.1")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Apache License 1.1", "Apache License 1.1 File", "http://www.apache.org/licenses/LICENSE-1.1"); } else if (StringUtils.containsIgnoreCase(content, "Copyright (c) 1995-1999 The Apache Group. All rights reserved.")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Apache License 1.0", "Apache License 1.0 File", "http://www.apache.org/licenses/LICENSE-1.0"); } else if (StringUtils.containsIgnoreCase(content, "GNU General Public License")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "GNU GPL", "GNU General Public License File", "http://opensource.org/licenses/gpl-license"); } else if (StringUtils.containsIgnoreCase(content, "The MIT License (MIT)")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "MIT License", "MIT License File", "http://opensource.org/licenses/MIT"); } else if (StringUtils.containsIgnoreCase(content, "Mozilla Public License, version 2.0")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Mozilla Public License 2.0", "Mozilla Public License 2.0 File", "http://opensource.org/licenses/MPL-2.0"); } else if (StringUtils.containsIgnoreCase(content, "GNU Lesser General Public License")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "GNU LGPL", "GNU LGPL File", "http://opensource.org/licenses/lgpl-license"); } else if (StringUtils.contains(content, "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "CDDL", "CDDL License File", "http://opensource.org/licenses/CDDL-1.0"); } else if (StringUtils.containsIgnoreCase(content, "Eclipse Public License")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Eclipse Public License 1.0", "Eclipse Public License 1.0 File", "http://opensource.org/licenses/EPL-1.0"); } else if (StringUtils.containsIgnoreCase(content, "Redistribution and use in source and binary forms")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "BSD License", "BSD License File", "http://opensource.org/licenses/"); } else if (StringUtils.containsIgnoreCase(content, "the work of authorship identified is in the public domain of the country")) { tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Public Domain License", "Creative Commons Public Domain License File", "http://creativecommons.org/licenses/publicdomain/"); } else { LOG.warning("Must be unknown license type: " + license.getFileName()); tagLicenseByTechnologyTag(rule, licenseService, technologyTagService, license, "Unknown License", "Unknown License File", "Unknown License File"); } } catch (IOException e) { LOG.fine("Error while opening License file: " + license.getFileName() + " with error: " + e.getLocalizedMessage()); } } }
From source file:org.jevis.commons.unit.UnitFormula.java
private boolean hasSubParts(String formula) { if (StringUtils.contains(formula, PUNCTUATION_START) || StringUtils.contains(formula, PUNCTUATION_END)) { // System.out.println("hasPuctuation"); int counterStart = 0; int counterEnd = 0; for (int i = 0; i < formula.length(); i++) { if (formula.charAt(i) == PUNCTUATION_START.charAt(0)) { counterStart++;/* w w w. ja va2 s . c om*/ } else if (formula.charAt(i) == PUNCTUATION_END.charAt(0)) { counterEnd++; } } // System.out.println("count: " + counterStart + " " + counterEnd); //Check if this is the outer punctuation of this formula if (counterStart == 1 && formula.charAt(0) != PUNCTUATION_START.charAt(0)) { // System.out.println("hasSubParts.isstart"); return false; } else { // System.out.println("llllllllll"); return true; } } // System.out.println("hasNOSubParts"); return false; }