Example usage for org.apache.commons.lang StringUtils containsIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils containsIgnoreCase.

Prototype

public static boolean containsIgnoreCase(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String irrespective of case, handling null.

Usage

From source file:org.eclipse.gyrex.jobs.internal.commands.LsCmd.java

private void printJobsQueue() {
    if (!IdHelper.isValidId(queueId)) {
        printf("ERROR: invalid queueId: %s", queueId);
        return;//from ww w  .  ja  v  a  2  s.c om
    }

    // get the queue
    final IQueue queue = JobsActivator.getInstance().getQueueService().getQueue(queueId, null);
    if (queue == null) {
        printf("ERROR: queue not found: %s", queueId);
        return;
    }

    // get message
    final HashMap<String, Object> properties = new HashMap<>(2);
    properties.put(IQueueServiceProperties.MESSAGE_RECEIVE_TIMEOUT, new Long(0));
    final List<IMessage> message = queue.receiveMessages(500, properties);
    if (message.isEmpty()) {
        printf("Queue '%s' is empty!", queueId);
        return;
    }

    printf("Found %d messages:", message.size());
    for (final IMessage m : message) {
        try {
            final JobInfo jobInfo = JobInfo.parse(m);
            if ((searchString == null) || StringUtils.containsIgnoreCase(jobInfo.getJobId(), searchString)
                    || StringUtils.containsIgnoreCase(jobInfo.getContextPath().toString(), searchString)) {
                printf("  %s (%s, %s, %s)", jobInfo.getJobId(), jobInfo.getContextPath(),
                        toRelativeTime(System.currentTimeMillis() - jobInfo.getQueueTimestamp()),
                        jobInfo.getQueueTrigger());
            }
        } catch (final IOException e) {
            printf("  %s", e.getMessage());
        }
    }
}

From source file:org.eclipse.gyrex.logback.config.model.Appender.java

private void writeEncoder(final XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("encoder");
    writer.writeStartElement("pattern");
    String text = getPattern();/*from   www.  ja  v a2  s  .  c o m*/
    if (StringUtils.isBlank(text)) {
        text = preferShortPattern() ? "${PATTERN_SHORT}" : "${PATTERN_LONG}";
    } else if (StringUtils.containsIgnoreCase(text, "PATTERN_LONG")) {
        text = "${PATTERN_LONG}";
    } else if (StringUtils.containsIgnoreCase(text, "PATTERN_SHORT")) {
        text = "${PATTERN_SHORT}";
    }
    writer.writeCharacters(text);
    writer.writeEndElement();
    writer.writeEndElement();
}

From source file:org.eclipse.gyrex.p2.internal.commands.ListCommand.java

private void listArtifacts() throws Exception {
    IProvisioningAgent agent = null;/*from   w  w  w  . j  a  v a2s. c  om*/
    try {
        // get agent
        agent = P2Activator.getInstance().getService(IProvisioningAgentProvider.class).createAgent(null);
        if (agent == null)
            throw new IllegalStateException(
                    "The current system has not been provisioned using p2. Unable to acquire provisioning agent.");

        final IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent
                .getService(IMetadataRepositoryManager.SERVICE_NAME);
        if (manager == null)
            throw new IllegalStateException(
                    "The provision system is broken. Unable to acquire metadata repository service.");

        // sync repos
        RepoUtil.configureRepositories(manager,
                (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME));

        // load repos
        final URI[] knownRepositories = manager
                .getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
        for (final URI uri : knownRepositories) {
            printf("Loading %s", uri.toString());
            manager.loadRepository(uri, new NullProgressMonitor());
        }

        // query for everything that provides an OSGi bundle and features
        IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery(
                "properties[$0] == true || providedCapabilities.exists(p | p.namespace == 'osgi.bundle')", //$NON-NLS-1$
                new Object[] { MetadataFactory.InstallableUnitDescription.PROP_TYPE_GROUP });

        // wrap query if necessary
        if (latestVersionOnly) {
            query = QueryUtil.createPipeQuery(query, QueryUtil.createLatestIUQuery());
        }

        // execute
        printf("Done loading. Searching...");
        final SortedSet<String> result = new TreeSet<>();
        for (final Iterator stream = manager.query(query, new NullProgressMonitor()).iterator(); stream
                .hasNext();) {
            final IInstallableUnit iu = (IInstallableUnit) stream.next();

            // exclude fragments
            if ((iu.getFragments() != null) && (iu.getFragments().size() > 0)) {
                continue;
            }

            final String id = iu.getId();

            // exclude source IUs
            if (StringUtils.endsWith(id, ".source") || StringUtils.endsWith(id, ".source.feature.group")) {
                continue;
            }

            // get name
            String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
            if ((name == null) || name.startsWith("%")) {
                name = ""; //$NON-NLS-1$
            }

            // check if filter is provided
            if (StringUtils.isBlank(filterString) || StringUtils.containsIgnoreCase(id, filterString)
                    || StringUtils.containsIgnoreCase(name, filterString)) {
                result.add(String.format("%s (%s, %s)", name, id, iu.getVersion()));
            }
        }

        if (result.isEmpty()) {
            printf("No artifacts found!");
        } else {
            printf("Found %d artifacts:", result.size());
            for (final String artifact : result) {
                printf(artifact);
            }
        }
    } finally {
        if (null != agent) {
            agent.stop();
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonyaudio.internal.discovery.SonyAudioDiscoveryParticipant.java

@Override
public ThingUID getThingUID(RemoteDevice device) {
    ThingUID result = null;//from   ww  w . j  a  v a2 s.co  m

    if (!StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
            SonyAudioBindingConstants.MANUFACTURER)) {
        return result;
    }

    logger.debug("Manufacturer matched: search: {}, device value: {}.", SonyAudioBindingConstants.MANUFACTURER,
            device.getDetails().getManufacturerDetails().getManufacturer());
    if (!StringUtils.containsIgnoreCase(device.getType().getType(),
            SonyAudioBindingConstants.UPNP_DEVICE_TYPE)) {
        return result;
    }
    logger.debug("Device type matched: search: {}, device value: {}.",
            SonyAudioBindingConstants.UPNP_DEVICE_TYPE, device.getType().getType());
    logger.debug("Device services: {}", device.getServices().toString());
    String deviceModel = device.getDetails().getModelDetails() != null
            ? device.getDetails().getModelDetails().getModelName()
            : null;
    logger.debug("Device model: {}.", deviceModel);
    ThingTypeUID thingTypeUID = findThingType(deviceModel);
    if (thingTypeUID != null) {
        result = new ThingUID(thingTypeUID, device.getIdentity().getUdn().getIdentifierString());
    }
    return result;
}

From source file:org.eclipse.sw360.portal.portlets.Sw360Portlet.java

public void dealWithLicenseAction(ResourceRequest request, ResourceResponse response, String action)
        throws IOException, PortletException {
    if (PortalConstants.LICENSE_SEARCH.equals(action)) {
        final String searchText = request.getParameter(PortalConstants.WHAT);

        try {/*from   w  w w.  jav  a2 s .  c o m*/
            LicenseService.Iface client = thriftClients.makeLicenseClient();
            List<License> licenses = client.getLicenseSummary();

            licenses = FluentIterable.from(licenses).filter(new Predicate<License>() {
                @Override
                public boolean apply(License input) {
                    String fullname = input.getFullname();
                    String shortname = input.getShortname();
                    return (StringUtils.containsIgnoreCase(fullname, searchText)
                            || StringUtils.containsIgnoreCase(shortname, searchText));
                }
            }).toList();

            request.setAttribute(PortalConstants.LICENSE_LIST, licenses);
            include("/html/utils/ajax/licenseListAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
        } catch (TException e) {
            log.error("Error getting licenses", e);
        }

    }
}

From source file:org.eclipse.wb.internal.swing.utils.SwingScreenshotMaker.java

/**
 * Fix for {@link JLabel} with "html" as text.
 *///from  ww w .  j  a va  2s .c  om
private static void fixJLabelWithHTML(Component component) throws Exception {
    if (component instanceof JLabel) {
        JLabel label = (JLabel) component;
        String text = label.getText();
        if (StringUtils.containsIgnoreCase(text, "<html>")) {
            SwingImageUtils.createComponentShotAWT(component);
        }
    }
    // process children
    if (component instanceof Container) {
        Container container = (Container) component;
        for (Component childComponent : container.getComponents()) {
            fixJLabelWithHTML(childComponent);
        }
    }
}

From source file:org.eurekastreams.server.persistence.mappers.ldap.templateretrievers.LdapGroupDnLdapTemplateRetriever.java

/**
 * Uses specified template key to return an LdapTemplate used to make query.
 * /*from   w w w  . j a v a2 s. c  om*/
 * @param inLdapLookupRequest
 *            {@link LdapLookupRequest}.
 * @return LdapTemplate based on provided template key, or default template if none found.
 */
@Override
protected LdapTemplate retrieveLdapTemplate(final LdapLookupRequest inLdapLookupRequest) {
    String testString = inLdapLookupRequest.getTemplateKey();

    if (testString != null && !testString.isEmpty()) {
        for (String key : getLdapTemplates().keySet()) {
            if (StringUtils.containsIgnoreCase(testString, "dc=" + key)) {
                return getLdapTemplates().get(key);
            }
        }
    }

    return getDefaultLdapTemplate();
}

From source file:org.eurekastreams.server.service.actions.strategies.MembershipCriteriaPersonPropertyGenerator.java

@SuppressWarnings("unchecked")
@Override/* ww  w.  j  ava  2 s.  c  o  m*/
public PersonPropertiesResponse getPersonProperties(final Map<String, Serializable> inParameters) {
    ArrayList<TabTemplate> tabTemplateResults = new ArrayList<TabTemplate>();
    Theme themeResult = null;

    // if params contain source list and it's not empty, try to create tab templates by matching against
    // membership criteria.
    if (inParameters.containsKey(sourceListKey)
            && !((ArrayList<String>) inParameters.get(sourceListKey)).isEmpty()) {
        // grab source list from params.
        ArrayList<String> sourceList = (ArrayList<String>) inParameters.get(sourceListKey);

        // grab all membershipCriteria from datastore.
        List<MembershipCriteria> membershipCriteria = membershipCriteriaDAO.execute(null);

        // loop through criteria checking against the persons source list values to see if the criteria applies, if
        // so, create copy of MC's tab template (if present) and put in result list.
        for (MembershipCriteria mc : membershipCriteria) {
            for (String source : sourceList) {
                if (StringUtils.containsIgnoreCase(source, mc.getCriteria())) {
                    // if criteria has tab template specified add it to results.
                    if (mc.getGalleryTabTemplate() != null) {
                        // These tabs create their own templates based on other templates.
                        tabTemplateResults.add(new TabTemplate(mc.getGalleryTabTemplate().getTabTemplate()));
                    }

                    // set theme.
                    themeResult = mc.getTheme();
                }
            }
        }
    }

    // if no tab templates were found via matching membership criteria, return default tab.
    if (tabTemplateResults.size() == 0) {
        tabTemplateResults.add(getDefaultTabTemplate());
    }

    return new PersonPropertiesResponse(tabTemplateResults, themeResult);
}

From source file:org.executequery.gui.resultset.AbstractRecordDataItem.java

public boolean valueContains(String pattern) {

    if (isLob() || isValueNull()) {

        return false;
    }//w w w. j a v  a 2  s  . c o  m
    return StringUtils.containsIgnoreCase(getValue().toString(), pattern);
}

From source file:org.exoplatform.forum.common.UserHelper.java

/**
 * Match user with user filter//from   w  ww  .ja  v a2  s. com
 * 
 * @param userFilter The user filter
 * @param user the user
 * @return
 */
public static boolean matchUser(UserFilter userFilter, User user) {
    if (user == null) {
        return false;
    }
    if (FilterType.USER_NAME == userFilter.getFilterType()
            && StringUtils.containsIgnoreCase(user.getUserName(), userFilter.getKeyword())) {
        return true;
    }
    if (FilterType.LAST_NAME == userFilter.getFilterType()
            && StringUtils.containsIgnoreCase(user.getLastName(), userFilter.getKeyword())) {
        return true;
    }
    if (FilterType.FIRST_NAME == userFilter.getFilterType()
            && StringUtils.containsIgnoreCase(user.getFirstName(), userFilter.getKeyword())) {
        return true;
    }
    if (FilterType.EMAIL == userFilter.getFilterType()
            && StringUtils.containsIgnoreCase(user.getEmail(), userFilter.getKeyword())) {
        return true;
    }
    return false;
}