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:com.adguard.android.service.FilterServiceImpl.java
/** * Checks the rules of non ascii symbols and control symbols * * @param userRule rule//from ww w . j a v a 2s .c o m * * @return true if correct rule or false */ private boolean validateRuleText(String userRule) { return StringUtils.isNotBlank(userRule) && userRule.matches(ASCII_SYMBOL) && StringUtils.length(userRule) > MIN_RULE_LENGTH && !StringUtils.startsWith(userRule, COMMENT) && !StringUtils.startsWith(userRule, ADBLOCK_META_START) && !StringUtils.contains(userRule, MASK_OBSOLETE_SCRIPT_INJECTION) && !StringUtils.contains(userRule, MASK_OBSOLETE_STYLE_INJECTION); }
From source file:com.frank.search.solr.core.query.Criteria.java
/** * Crates new {@link Criteria.Predicate} with trailing {@code ~} followed by * distance//from w ww . j a va2s . co m * * @param phrase * @param distance * @return */ public Criteria sloppy(String phrase, int distance) { if (distance <= 0) { throw new InvalidDataAccessApiUsageException("Slop distance has to be greater than 0."); } if (!StringUtils.contains(phrase, CRITERIA_VALUE_SEPERATOR)) { throw new InvalidDataAccessApiUsageException( "Phrase must consist of multiple terms, separated with spaces."); } predicates.add(new Predicate(OperationKey.SLOPPY, new Object[] { phrase, Integer.valueOf(distance) })); return this; }
From source file:kenh.expl.impl.ExpLParser.java
/** * Invoke functioin, support name space. For example, expl:contains(...). * @param function/*w ww . java 2 s . c om*/ * @return Return string or non-string object. Return empty string instead of null. */ private Object executeFunction(String function) throws UnsupportedExpressionException { // function should return a string object; if (StringUtils.isBlank(function)) { UnsupportedExpressionException e = new UnsupportedExpressionException("Function is null."); throw e; } logger.trace("Func: " + function); String parameter = StringUtils.substringBeforeLast(StringUtils.substringAfter(function, "("), ")"); String[] parts = splitParameter(parameter); String funcName = StringUtils.substringBetween(function, "#", "("); String nameSpace = null; if (StringUtils.contains(funcName, ":")) { nameSpace = StringUtils.substringBefore(funcName, ":"); funcName = StringUtils.substringAfter(funcName, ":"); } if (StringUtils.isBlank(funcName)) { UnsupportedExpressionException e = new UnsupportedExpressionException("Failure to get function name"); e.push(function); throw e; } Object[] objs = new Object[parts.length]; int i = 0; for (String part : parts) { if (part.indexOf('{') != -1) { Object obj = this.parseExpress(part); objs[i++] = obj; } else { objs[i++] = part; } } try { // instantiate it, and create the parameters Function func = this.getEnvironment().getFunction(nameSpace, funcName); if (func == null) throw new UnsupportedExpressionException("Can't find the function. [" + (StringUtils.isBlank(nameSpace) ? funcName : nameSpace + ":" + funcName) + "]"); func.setEnvironment(this.getEnvironment()); // invoke return func.invoke(objs); } catch (UnsupportedExpressionException e) { e.push(function); throw e; } catch (Exception ex) { UnsupportedExpressionException e = new UnsupportedExpressionException(ex); e.push(function); throw e; } }
From source file:com.nridge.ds.solr.SolrDS.java
/** * Returns the base Solr URL associated with the standalone/cloud search cluster. * * @param anIncludeCollection Should the collection name be included * * @return Base URL string./* w w w . j a v a 2s .co m*/ * * @throws DSException Data source exception. */ public String getBaseURL(boolean anIncludeCollection) throws DSException { String baseSolrURL; initialize(); if ((anIncludeCollection) && (StringUtils.isNotEmpty(mCollectionName))) { if (StringUtils.contains(mBaseSolrURL, mCollectionName)) baseSolrURL = mBaseSolrURL; else baseSolrURL = String.format("%s/%s", mBaseSolrURL, mCollectionName); } else { int solrOffset = StringUtils.indexOf(mBaseSolrURL, "solr"); if (solrOffset > 5) baseSolrURL = mBaseSolrURL.substring(0, solrOffset + 4); else baseSolrURL = mBaseSolrURL; } return baseSolrURL; }
From source file:com.feilong.core.net.URIUtil.java
/** * ?queryString./*from w w w . j av a 2s. c om*/ * * @param uriString * the uri string * @return <code>uriString</code> nullempty, {@link StringUtils#EMPTY} * @since 1.8.0 change to private */ // XXX private static boolean hasQueryString(String uriString) { return isNullOrEmpty(uriString) ? false : StringUtils.contains(uriString, QUESTIONMARK); }
From source file:fr.littlereddot.pocket.site.controller.account.ConnectAccountController.java
/** * Returns a RedirectView with the URL to redirect to after a connection is created or deleted. * Defaults to "/connect/{providerId}" relative to DispatcherServlet's path. * May be overridden to handle custom redirection needs. * * @param providerId the ID of the provider for which a connection was created or deleted. * @param request the NativeWebRequest used to access the servlet path when constructing the redirect path. *//* w w w . j a v a2 s .com*/ protected RedirectView connectionStatusRedirect(String providerId, NativeWebRequest request) { String origin = request.getParameter("origin"); String parameterSeparator = StringUtils.contains(origin, "?") ? "&" : "?"; return new RedirectView(origin + parameterSeparator + providerId + "=true"); }
From source file:com.utdallas.s3lab.smvhunter.monkey.MonkeyMe.java
/** * Install app in emulator. This repeats a maximum of two times in case of failure. * @param apkName// w ww.j av a 2 s . c o m * @param device * @param packageName * @param count * @throws IOException */ private void installApk(String apkName, IDevice device, String packageName, int count) throws IOException { if (count > 2) { throw new IOException("Install failed too many tries " + apkName); } //install the apk String result = execCommand( String.format("%s %s %s", getDeviceString(device), " install ", ROOT_DIRECTORY + apkName)); if (StringUtils.contains(result, "Failure")) { logger.error(String.format("%s Install failed for apk %s with reason ", device.getSerialNumber(), apkName, result)); if (!StringUtils.contains(result, "INSTALL_FAILED_ALREADY_EXISTS")) { throw new IOException("Install failed " + result); } else { //un-install it and install the same one uninstallApk(packageName, device); installApk(apkName, device, packageName, count++); } } if (logDebug) logger.debug(String.format("%s Install success for apk %s", device.getSerialNumber(), apkName)); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:com.dell.asm.asmcore.asmmanager.util.deployment.FilterEnvironment.java
public void initEnvironment(ServiceTemplateComponent component) { // By default require non-minimal server to be firmware compliant. compliantState = CompliantState.COMPLIANT; if (component == null) return;/* w w w.j av a2s .co m*/ setMinimalServer(component.checkMinimalServerComponent()); if (component.hasWindowsOS()) { setWindowsOS(true); } for (ServiceTemplateCategory resource : component.getResources()) { if (resource.getId() .equalsIgnoreCase(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_IDRAC_RESOURCE)) { List<ServiceTemplateSetting> parameters = resource.getParameters(); setClonedModelString(parameters); for (ServiceTemplateSetting param : parameters) { //check if the target boot device is SD if (param.getId().equalsIgnoreCase( ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_TARGET_BOOTDEVICE_ID)) { String targetBootDevice = param.getValue(); if (targetBootDevice .contains(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_TARGET_BOOTDEVICE_SD) || targetBootDevice.contains( ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_TARGET_BOOTDEVICE_SD_RAID_VSAN) || targetBootDevice.contains( ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_TARGET_BOOTDEVICE_SD_RAID)) setSDBoot(true); else if (targetBootDevice.equals( ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_TARGET_BOOTDEVICE_AHCI_VSAN)) setLocalDiskVSANBoot(true); } else if (ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_RAID_ID.equals(param.getId())) { // make sure boot type is HD/None ServiceTemplateSetting depTarget = resource.getParameter(param.getDependencyTarget()); if (depTarget == null || StringUtils.isEmpty(depTarget.getValue()) || Arrays .asList(param.getDependencyValue().split(",")).contains(depTarget.getValue())) { if (StringUtils.isBlank(param.getValue())) { logger.error("Raid configuration set but no configuration value found"); } else { try { String configString = "{ \"templateRaidConfiguration\" : " + param.getValue() + "}"; TemplateRaidConfiguration configuration = MarshalUtil .fromJSON(TemplateRaidConfiguration.class, configString); setRaidConfiguration(configuration); } catch (IllegalStateException e) { logger.error( "Raid configuration set but has invalid value: " + param.getValue()); } } } } } } else if (resource.getId() .equalsIgnoreCase(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_NETWORKING_COMP_ID)) { List<ServiceTemplateSetting> parameters = resource.getParameters(); setClonedModelString(parameters); for (ServiceTemplateSetting parama : parameters) { if (parama.getId().equalsIgnoreCase( ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_NETWORK_CONFIG_ID)) { NetworkConfiguration configuration = null; if (StringUtils.isBlank(parama.getValue())) { logger.error("Network configuration is blank"); } else { configuration = ServiceTemplateUtil.deserializeNetwork(parama.getValue()); } if (configuration != null) { List<Fabric> cards = configuration.getInterfaces(); if (cards != null) { for (int i = 0; i < cards.size(); i++) { int tempInterfaceValue = i; int tempI = ++tempInterfaceValue; List<String> ports = new ArrayList<String>(); if (Fabric.FC_TYPE.equals(cards.get(i).getFabrictype())) { addFCCard(makeCardKey(tempI, cards.get(i).getId())); // store # of the FC card in template } if (cards.get(i) != null && cards.get(i).getInterfaces() != null) { List<Interface> innerInterfaces = cards.get(i).getInterfaces(); if (cards.get(i).isPartitioned()) addPartitionedInterface(tempI, cards.get(i).getId()); for (int j = 0; j < cards.get(i).getNPorts(); j++) { int tempInnerInterfaceValue = j; if (innerInterfaces.get(j).getPartitions() != null && !innerInterfaces.get(j).getPartitions().isEmpty()) { ports.add(String.valueOf(++tempInnerInterfaceValue)); // walk through partitions and analyse networks for (Partition p : innerInterfaces.get(j).getPartitions()) { if (p.getNetworks() != null) { for (String networkId : p.getNetworks()) { com.dell.pg.asm.identitypool.api.network.model.Network network = getNetworkProxy() .getNetwork(networkId); if (network != null) { if (NetworkType.STORAGE_ISCSI_SAN .equals(network.getType())) { addIscsiInterface(tempI, cards.get(i).getId()); } else if ((NetworkType.PXE .equals(network.getType())) && network.isStatic()) { addStaticOSInstallInterface(tempI, cards.get(i).getId()); } } } } } } } if (!ports.isEmpty()) { addPortMapping(tempI, cards.get(i).getId(), ports); if (Interface.NIC_2_X_10GB_2_X_1GB .equals(cards.get(i).getNictypeSource())) { addTwoByTwoInterface(tempI, cards.get(i).getId()); } } } } } } } } } else if (ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_OS_RESOURCE.equals(resource.getId())) { ServiceTemplateSetting param = resource .getParameter(ServiceTemplateSettingIDs.LOCAL_STORAGE_TYPE_ID); if (param != null && ServiceTemplateSettingIDs.LOCAL_STORAGE_TYPE_FLASH.equals(param.getValue()) && ServiceTemplateUtil.checkDependency(component, param)) { setAllFlash(true); } param = resource.getParameter(ServiceTemplateSettingIDs.LOCAL_STORAGE_ID); if (param != null && ServiceTemplateSettingIDs.SERVICE_TEMPLATE_TRUE_VALUE.equals(param.getValue())) { setLocalStorageForVSANEnabled(true); } } } ServiceTemplateSetting serverOsType = component .getTemplateSetting(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_OS_TYPE_ID); if (serverOsType != null && serverOsType.getValue() != null && serverOsType.getValue().equals(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_HYPERV_VALUE)) { setHyperVUsed(true); } ServiceTemplateSetting iscsiInitiator = component.getParameter( ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_OS_RESOURCE, ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_OS_ISCSI_ID); if (iscsiInitiator != null && iscsiInitiator.getValue() != null) { ServiceTemplateSetting depTarget = component.getTemplateSetting(iscsiInitiator.getDependencyTarget()); if ((depTarget != null && StringUtils.contains(iscsiInitiator.getDependencyValue(), depTarget.getValue())) && iscsiInitiator.getValue() .equals(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_SERVER_OS_ISCSI_HARDWARE_ID)) { setHardwareISCSI(true); } } }
From source file:net.eledge.android.europeana.gui.activity.RecordActivity.java
private void handleIntent(Intent intent) { String id = null;/*from ww w. j av a2 s . c o m*/ if (intent != null) { if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); // only one message sent during the beam NdefMessage msg = (NdefMessage) rawMsgs[0]; // record 0 contains the MIME type, record 1 is the AAR, if present id = new String(msg.getRecords()[0].getPayload()); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { id = StringUtils.defaultIfBlank(intent.getDataString(), intent.getStringExtra(RECORD_ID)); } if (StringUtils.contains(id, "europeana.eu/")) { Uri uri = Uri.parse(id); List<String> paths = uri.getPathSegments(); if ((paths != null) && (paths.size() == 4)) { String collectionId = paths.get(paths.size() - 2); String recordId = StringUtils.removeEnd(paths.get(paths.size() - 1), ".html"); id = StringUtils.join("/", collectionId, "/", recordId); } else { // invalid url/id, cancel opening record id = null; } } if (StringUtils.isNotBlank(id)) { openRecord(id); } } }
From source file:com.ejushang.steward.common.genericdao.dao.hibernate.GeneralDAO.java
/** * hql?fetch,?fetch?,?//from ww w .ja v a 2s .c o m * @param countQL * @return */ private String removeFetchInCountQl(String countQL) { if (StringUtils.contains(countQL, " fetch ")) { countQL = (countQL.toString().replaceAll("fetch", "")); } return countQL; }