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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr) 

Source Link

Document

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

Usage

From source file:com.jerrellmardis.amphitheatre.util.Utils.java

public static int getPaletteColor(Palette palette, String colorType, int defaultColor) {
    if (colorType.equals("")) {
        return defaultColor;
    }/*  w ww.  ja  va 2s.c  o m*/

    Method[] paletteMethods = palette.getClass().getDeclaredMethods();

    for (Method method : paletteMethods) {
        if (StringUtils.containsIgnoreCase(method.getName(), colorType)) {
            try {
                Palette.Swatch item = (Palette.Swatch) method.invoke(palette);
                if (item != null) {
                    return item.getRgb();
                } else {
                    return defaultColor;
                }
            } catch (Exception ex) {
                Log.d("getPaletteColor", ex.getMessage());
                return defaultColor;
            }
        }
    }

    return defaultColor;
}

From source file:com.intuit.wasabi.email.impl.EmailTextProcessorImplTest.java

@Test
public void testAccessTemplateForApp() {
    links.add("https://wasabi.you.org/");
    String msg = textProcessor.getMessage(appName, UserInfo.Username.valueOf("Jabb0r"),
            EmailLinksList.withEmailLinksList(links).build());
    assertTrue(StringUtils.containsIgnoreCase(msg, appName.toString()));
    assertTrue(StringUtils.containsIgnoreCase(msg, "Jabb0r"));
}

From source file:com.synopsys.integration.blackduck.service.model.ScannerSplitStream.java

private void writeToConsole(final String line) {
    final String trimmedLine = line.trim();
    if (trimmedLine.startsWith(DEBUG) || trimmedLine.startsWith(TRACE)) {
        // We dont want to print Debug or Trace logs to the logger
        return;//from  ww  w  . java  2s. com
    }
    final StringBuilder outputBuilder = new StringBuilder();
    outputBuilder.append(output);
    if (trimmedLine.startsWith(ERROR)) {
        outputBuilder.append(trimmedLine);
        outputBuilder.append(LINE_SEPARATOR);
        logger.error(trimmedLine);
    } else if (trimmedLine.startsWith(WARN)) {
        outputBuilder.append(trimmedLine);
        outputBuilder.append(LINE_SEPARATOR);
        logger.warn(trimmedLine);
    } else if (trimmedLine.startsWith(INFO)) {
        outputBuilder.append(trimmedLine);
        outputBuilder.append(LINE_SEPARATOR);
        logger.info(trimmedLine);
    } else if (StringUtils.containsIgnoreCase(trimmedLine, EXCEPTION)) {
        // looking for 'Exception in thread' type messages
        outputBuilder.append(trimmedLine);
        outputBuilder.append(LINE_SEPARATOR);
        logger.error(trimmedLine);
    } else if (StringUtils.containsIgnoreCase(trimmedLine, FINISHED)) {
        outputBuilder.append(trimmedLine);
        outputBuilder.append(LINE_SEPARATOR);
        logger.info(trimmedLine);
    }

    output = outputBuilder.toString();
}

From source file:com.microsoft.azure.vmagent.test.ITAzureVMAgentCleanUpTask.java

@Test
public void cleanLeakedResourcesRemovesDeployedResources() {
    final AzureUtil.DeploymentTag tagValue = new AzureUtil.DeploymentTag("some_value/123");
    final AzureUtil.DeploymentTag matchingTagValue = new AzureUtil.DeploymentTag("some_value/9999123");
    final String cloudName = "some_cloud_name";
    try {/*from   www  .j a  v a2s .  c o  m*/

        final DeploymentRegistrar deploymentRegistrarMock = mock(DeploymentRegistrar.class);
        when(deploymentRegistrarMock.getDeploymentTag()).thenReturn(tagValue);
        final DeploymentRegistrar deploymentRegistrarMock_matching = mock(DeploymentRegistrar.class);
        when(deploymentRegistrarMock_matching.getDeploymentTag()).thenReturn(matchingTagValue);

        final AzureVMDeploymentInfo deployment = createDefaultDeployment(2, deploymentRegistrarMock);
        final List<String> validVMs = Arrays.asList(new Object[] { deployment.getVmBaseName() + "0" });

        AzureVMAgentCleanUpTask cleanUpTask = spy(AzureVMAgentCleanUpTask.class);
        when(cleanUpTask.getValidVMs(cloudName)).thenReturn(validVMs);

        cleanUpTask.cleanLeakedResources(testEnv.azureResourceGroup, servicePrincipal, cloudName,
                deploymentRegistrarMock_matching); //should remove second deployment

        Thread.sleep(20 * 1000); // give time for azure to realize that some resources are missing
        StorageAccount jenkinsStorage = null;
        PagedList<GenericResource> resources = customTokenCache.getAzureClient().genericResources()
                .listByGroup(testEnv.azureResourceGroup);
        for (GenericResource resource : resources) {
            if (StringUtils.containsIgnoreCase(resource.type(), "storageAccounts")) {
                jenkinsStorage = customTokenCache.getAzureClient().storageAccounts().getById(resource.id());
            }
            if (resource.tags().get(Constants.AZURE_RESOURCES_TAG_NAME) != null && matchingTagValue.matches(
                    new AzureUtil.DeploymentTag(resource.tags().get(Constants.AZURE_RESOURCES_TAG_NAME)))) {
                String resourceName = resource.name();
                String depl = deployment.getVmBaseName() + "0";
                Assert.assertTrue("Resource shouldn't exist: " + resourceName + " (vmbase: " + depl + " )",
                        resourceName.contains(depl));
            }
        }

        //check the OS disk was removed
        Assert.assertNotNull("The resource group doesn't have any storage account", jenkinsStorage);
        final String storageKey = jenkinsStorage.getKeys().get(0).value();
        CloudStorageAccount account = new CloudStorageAccount(
                new StorageCredentialsAccountAndKey(jenkinsStorage.name(), storageKey));
        CloudBlobClient blobClient = account.createCloudBlobClient();
        CloudBlobContainer container = blobClient.getContainerReference("vhds");
        Assert.assertTrue(container.exists());
        for (ListBlobItem blob : container.listBlobs()) {
            final String u = blob.getUri().toString();
            Assert.assertTrue("Blobl shouldn't exist: " + u, u.contains(deployment.getVmBaseName() + "0"));
        }

    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, null, e);
        Assert.assertTrue(e.getMessage(), false);
    }
}

From source file:net.java.sip.communicator.plugin.propertieseditor.SearchField.java

/**
 * Runs in {@link #filterThread} to apply {@link #filter} to the displayed
 * <tt>ConfigurationService</tt> properties.
 *///from w  w w .  j  av  a  2s . c  o m
private void runInFilterThread() {
    String prevFilter = null;
    long prevFilterTime = 0;

    do {
        final String filter;

        synchronized (filterSyncRoot) {
            filter = this.filter;

            /*
             * If the currentThread is idle for too long (which also means
             * that the filter has not been changed), kill it because we do
             * not want to keep it alive forever.
             */
            if ((prevFilterTime != 0) && StringUtils.equalsIgnoreCase(filter, prevFilter)) {
                long timeout = FILTER_THREAD_TIMEOUT - (System.currentTimeMillis() - prevFilterTime);

                if (timeout > 0) {
                    // The currentThread has been idle but not long enough.
                    try {
                        filterSyncRoot.wait(timeout);
                        continue;
                    } catch (InterruptedException ie) {
                        // The currentThread will die bellow at the break.
                    }
                }
                // Commit suicide.
                if (Thread.currentThread().equals(filterThread))
                    filterThread = null;
                break;
            }
        }

        List<String> properties = confService.getAllPropertyNames();
        final List<Object[]> rows = new ArrayList<Object[]>(properties.size());

        for (String property : properties) {
            String value = (String) confService.getProperty(property);
            if ((filter == null) || StringUtils.containsIgnoreCase(property, filter)
                    || StringUtils.containsIgnoreCase(value, filter)) {
                rows.add(new Object[] { property, confService.getProperty(property) });
            }
        }

        // If in the meantime someone has changed the filter, we don't want
        // to update the GUI but filter the results again.
        if (StringUtils.equalsIgnoreCase(filter, this.filter)) {
            LowPriorityEventQueue.invokeLater(new Runnable() {
                public void run() {
                    DefaultTableModel model = (DefaultTableModel) table.getModel();

                    model.setRowCount(0);
                    for (Object[] row : rows) {
                        model.addRow(row);
                        if (filter != SearchField.this.filter)
                            return;
                    }
                }
            });
        }

        prevFilter = filter;
        prevFilterTime = System.currentTimeMillis();
    } while (true);
}

From source file:eu.operando.operandoapp.service.ProxyService.java

private HttpFiltersSource getFiltersSource() {
    return new HttpFiltersSourceAdapter() {
        @Override//w w w  .  jav  a  2s  .  c  om
        public HttpFilters filterRequest(HttpRequest originalRequest) {
            return new HttpFiltersAdapter(originalRequest) {
                @Override
                public HttpObject serverToProxyResponse(HttpObject httpObject) {
                    //check for proxy running
                    if (MainUtil.isProxyPaused(mainContext))
                        return httpObject;

                    if (httpObject instanceof HttpMessage) {
                        HttpMessage response = (HttpMessage) httpObject;
                        response.headers().set(HttpHeaderNames.CACHE_CONTROL,
                                "no-cache, no-store, must-revalidate");
                        response.headers().set(HttpHeaderNames.PRAGMA, "no-cache");
                        response.headers().set(HttpHeaderNames.EXPIRES, "0");
                    }
                    try {
                        Method content = httpObject.getClass().getMethod("content");
                        if (content != null) {
                            ByteBuf buf = (ByteBuf) content.invoke(httpObject);
                            boolean flag = false;
                            List<ResponseFilter> responseFilters = db.getAllResponseFilters();
                            if (responseFilters.size() > 0) {
                                String contentStr = buf.toString(Charset.forName("UTF-8")); //Charset.forName(Charset.forName("UTF-8")
                                for (ResponseFilter responseFilter : responseFilters) {
                                    String toReplace = responseFilter.getContent();
                                    if (StringUtils.containsIgnoreCase(contentStr, toReplace)) {
                                        contentStr = contentStr.replaceAll("(?i)" + toReplace,
                                                StringUtils.leftPad("", toReplace.length(), '#'));
                                        flag = true;
                                    }
                                }
                                if (flag) {
                                    buf.clear().writeBytes(contentStr.getBytes(Charset.forName("UTF-8")));
                                }
                            }
                        }
                    } catch (IndexOutOfBoundsException ex) {
                        ex.printStackTrace();
                        Log.e("Exception", ex.getMessage());
                    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
                        //ignore
                    }
                    return httpObject;
                }

                @Override
                public HttpResponse clientToProxyRequest(HttpObject httpObject) {
                    //check for proxy running
                    if (MainUtil.isProxyPaused(mainContext)) {
                        return null;
                    }

                    //check for trusted access point
                    String ssid = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).getConnectionInfo()
                            .getSSID();
                    String bssid = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).getConnectionInfo()
                            .getBSSID();
                    boolean trusted = false;
                    TrustedAccessPoint curr_tap = new TrustedAccessPoint(ssid, bssid);
                    for (TrustedAccessPoint tap : db.getAllTrustedAccessPoints()) {
                        if (curr_tap.isEqual(tap)) {
                            trusted = true;
                        }
                    }
                    if (!trusted) {
                        return getUntrustedGatewayResponse();
                    }

                    //check for blocked url

                    //check for exfiltration
                    requestFilterUtil = new RequestFilterUtil(getApplicationContext());
                    locationInfo = requestFilterUtil.getLocationInfo();
                    contactsInfo = requestFilterUtil.getContactsInfo();
                    IMEI = requestFilterUtil.getIMEI();
                    phoneNumber = requestFilterUtil.getPhoneNumber();
                    subscriberID = requestFilterUtil.getSubscriberID();
                    carrierName = requestFilterUtil.getCarrierName();
                    androidID = requestFilterUtil.getAndroidID();
                    macAdresses = requestFilterUtil.getMacAddresses();

                    if (httpObject instanceof HttpMessage) {
                        HttpMessage request = (HttpMessage) httpObject;
                        if (request.headers().contains(CustomHeaderField)) {
                            applicationInfo = request.headers().get(CustomHeaderField);
                            request.headers().remove(CustomHeaderField);
                        }
                        if (request.headers().contains(HttpHeaderNames.ACCEPT_ENCODING)) {
                            request.headers().remove(HttpHeaderNames.ACCEPT_ENCODING);
                        }
                        if (!ProxyUtils.isCONNECT(request)
                                && request.headers().contains(HttpHeaderNames.HOST)) {
                            String hostName = ((HttpRequest) request).uri(); //request.headers().get(HttpHeaderNames.HOST).toLowerCase();
                            if (db.isDomainBlocked(hostName))
                                return getBlockedHostResponse(hostName);
                        }
                    }

                    String requestURI;
                    Set<RequestFilterUtil.FilterType> exfiltrated = new HashSet<>();

                    if (httpObject instanceof HttpRequest) {
                        HttpRequest request = (HttpRequest) httpObject;
                        requestURI = request.uri();
                        try {
                            requestURI = URLDecoder.decode(requestURI, "UTF-8");
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        }
                        if (locationInfo.length > 0) {
                            //tolerate location miscalculation
                            float latitude = Float.parseFloat(locationInfo[0]);
                            float longitude = Float.parseFloat(locationInfo[1]);
                            Matcher m = Pattern.compile("\\d+\\.\\d+").matcher(requestURI);
                            List<String> floats_in_uri = new ArrayList();
                            while (m.find()) {
                                floats_in_uri.add(m.group());
                            }
                            for (String s : floats_in_uri) {
                                if (Math.abs(Float.parseFloat(s) - latitude) < 0.5
                                        || Math.abs(Float.parseFloat(s) - longitude) < 0.1) {
                                    exfiltrated.add(RequestFilterUtil.FilterType.LOCATION);
                                }
                            }
                        }
                        if (StringUtils.containsAny(requestURI, contactsInfo)) {
                            exfiltrated.add(RequestFilterUtil.FilterType.CONTACTS);
                        }
                        if (StringUtils.containsAny(requestURI, macAdresses)) {
                            exfiltrated.add(RequestFilterUtil.FilterType.MACADRESSES);
                        }
                        if (requestURI.contains(IMEI) && !IMEI.equals("")) {
                            exfiltrated.add(RequestFilterUtil.FilterType.IMEI);
                        }
                        if (requestURI.contains(phoneNumber) && !phoneNumber.equals("")) {
                            exfiltrated.add(RequestFilterUtil.FilterType.PHONENUMBER);
                        }
                        if (requestURI.contains(subscriberID) && !subscriberID.equals("")) {
                            exfiltrated.add(RequestFilterUtil.FilterType.IMSI);
                        }
                        if (requestURI.contains(carrierName) && !carrierName.equals("")) {
                            exfiltrated.add(RequestFilterUtil.FilterType.CARRIERNAME);
                        }
                        if (requestURI.contains(androidID) && !androidID.equals("")) {
                            exfiltrated.add(RequestFilterUtil.FilterType.ANDROIDID);
                        }
                    }
                    try {
                        Method content = httpObject.getClass().getMethod("content");
                        if (content != null) {
                            ByteBuf buf = (ByteBuf) content.invoke(httpObject);
                            String contentStr = buf.toString(Charset.forName("UTF-8"));
                            if (locationInfo.length > 0) {
                                //tolerate location miscalculation
                                float latitude = Float.parseFloat(locationInfo[0]);
                                float longitude = Float.parseFloat(locationInfo[1]);
                                Matcher m = Pattern.compile("\\d+\\.\\d+").matcher(contentStr);
                                List<String> floats_in_uri = new ArrayList();
                                while (m.find()) {
                                    floats_in_uri.add(m.group());
                                }
                                for (String s : floats_in_uri) {
                                    if (Math.abs(Float.parseFloat(s) - latitude) < 0.5
                                            || Math.abs(Float.parseFloat(s) - longitude) < 0.1) {
                                        exfiltrated.add(RequestFilterUtil.FilterType.LOCATION);
                                    }
                                }
                            }
                            if (StringUtils.containsAny(contentStr, contactsInfo)) {
                                exfiltrated.add(RequestFilterUtil.FilterType.CONTACTS);
                            }
                            if (StringUtils.containsAny(contentStr, macAdresses)) {
                                exfiltrated.add(RequestFilterUtil.FilterType.MACADRESSES);
                            }
                            if (contentStr.contains(IMEI) && !IMEI.equals("")) {
                                exfiltrated.add(RequestFilterUtil.FilterType.IMEI);
                            }
                            if (contentStr.contains(phoneNumber) && !phoneNumber.equals("")) {
                                exfiltrated.add(RequestFilterUtil.FilterType.PHONENUMBER);
                            }
                            if (contentStr.contains(subscriberID) && !subscriberID.equals("")) {
                                exfiltrated.add(RequestFilterUtil.FilterType.IMSI);
                            }
                            if (contentStr.contains(carrierName) && !carrierName.equals("")) {
                                exfiltrated.add(RequestFilterUtil.FilterType.CARRIERNAME);
                            }
                            if (contentStr.contains(androidID) && !androidID.equals("")) {
                                exfiltrated.add(RequestFilterUtil.FilterType.ANDROIDID);
                            }
                        }
                    } catch (IndexOutOfBoundsException ex) {
                        ex.printStackTrace();
                        Log.e("Exception", ex.getMessage());
                    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
                        //ignore
                    }

                    //check exfiltrated list
                    if (!exfiltrated.isEmpty()) {
                        //retrieve all blocked and allowed domains
                        List<BlockedDomain> blocked = db.getAllBlockedDomains();
                        List<AllowedDomain> allowed = db.getAllAllowedDomains();
                        //get application name from app info
                        String appName = applicationInfo.replaceAll("\\(.+?\\)", "");
                        //check blocked domains
                        //if domain is stored as blocked, return a forbidden response
                        for (BlockedDomain b_dmn : blocked) {
                            if (b_dmn.info.equals(appName)) {
                                return getForbiddenRequestResponse(applicationInfo, exfiltrated);
                            }
                        }
                        //if domain is stored as allowed, return null for actual response
                        for (AllowedDomain a_dmn : allowed) {
                            if (a_dmn.info.equals(appName)) {
                                return null;
                            }
                        }
                        //get exfiltrated info to string array
                        String[] exfiltrated_array = new String[exfiltrated.size()];
                        int i = 0;
                        for (RequestFilterUtil.FilterType filter_type : exfiltrated) {
                            exfiltrated_array[i] = filter_type.name();
                            i++;
                        }
                        //retrieve all pending notifications
                        List<PendingNotification> pending = db.getAllPendingNotifications();
                        for (PendingNotification pending_notification : pending) {
                            //if pending notification includes specific app name and app permissions return response that a pending notification exists
                            if (pending_notification.app_info.equals(applicationInfo)) {
                                return getPendingResponse();
                            }
                        }
                        //if none pending notification exists, display a new notification
                        int notificationId = mainContext.getNotificationId();
                        mainContext.getNotificationUtil().displayExfiltratedNotification(getBaseContext(),
                                applicationInfo, exfiltrated, notificationId);
                        mainContext.setNotificationId(notificationId + 3);
                        //and update statistics
                        db.updateStatistics(exfiltrated);
                        return getAwaitingResponse();
                    }
                    return null;
                }
            };
        }
    };
}

From source file:gov.va.isaac.gui.listview.operations.FindAndReplace.java

/**
 * @see gov.va.isaac.gui.listview.operations.Operation#createTask()
 *//*from w w  w  . j av a  2  s .  co  m*/
@Override
public CustomTask<OperationResult> createTask() {
    return new CustomTask<OperationResult>(FindAndReplace.this) {
        private Matcher matcher;

        @Override
        protected OperationResult call() throws Exception {
            double i = 0;
            successCons.clear();
            Set<SimpleDisplayConcept> modifiedConcepts = new HashSet<SimpleDisplayConcept>();
            for (SimpleDisplayConcept c : conceptList_) {
                if (cancelRequested_) {
                    return new OperationResult(FindAndReplace.this.getTitle(), cancelRequested_);
                }

                String newTxt = null;
                Set<String> successMatches = new HashSet<>();

                updateProgress(i, conceptList_.size());
                updateMessage("Processing " + c.getDescription());

                // For each concept, filter the descriptions to be changed based on user selected DescType
                ConceptVersionBI con = OTFUtility.getConceptVersion(c.getNid());
                Set<DescriptionVersionBI<?>> descsToChange = getDescsToChange(con);

                for (DescriptionVersionBI<?> desc : descsToChange) {
                    // First see if text is found in desc before moving onward
                    if (frc_.isRegExp() && hasRegExpMatch(desc) || !frc_.isRegExp() && hasGenericMatch(desc)) {

                        // Now check if language is selected, that it exists in language refset
                        if (frc_.getLanguageRefset().getNid() == 0
                                || !desc.getAnnotationsActive(OTFUtility.getViewCoordinate(),
                                        frc_.getLanguageRefset().getNid()).isEmpty()) {

                            // Replace Text
                            if (frc_.isRegExp()) {
                                newTxt = replaceRegExp();
                            } else {
                                newTxt = replaceGeneric(desc);
                            }

                            DescriptionType descType = getDescType(con, desc);
                            successMatches.add("    --> '" + desc.getText() + "' changed to '" + newTxt
                                    + "' ..... of type: " + descType);
                            updateDescription(desc, newTxt);
                        }
                    }
                }
                if (successMatches.size() > 0) {
                    modifiedConcepts.add(c);
                    successCons.put(c.getDescription() + " --- " + con.getPrimordialUuid().toString(),
                            successMatches);
                }

                updateProgress(++i, conceptList_.size());
            }

            return new OperationResult(FindAndReplace.this.getTitle(), modifiedConcepts, getMsgBuffer());
        }

        private boolean hasRegExpMatch(DescriptionVersionBI<?> desc) {
            Pattern pattern = Pattern.compile(frc_.getSearchText());

            matcher = pattern.matcher(desc.getText());

            if (matcher.find()) {
                return true;
            } else {
                return false;
            }
        }

        private String replaceRegExp() {
            // Replace all occurrences of pattern in input
            return matcher.replaceAll(frc_.getReplaceText());
        }

        private String replaceGeneric(DescriptionVersionBI<?> desc) {
            String txt = desc.getText();

            if (frc_.isCaseSens()) {
                while (txt.contains(frc_.getSearchText())) {
                    txt = txt.replace(frc_.getSearchText(), frc_.getReplaceText());
                }
            } else {
                int startIdx = StringUtils.indexOfIgnoreCase(txt, frc_.getSearchText());
                int endIdx = startIdx + frc_.getSearchText().length();

                while (startIdx >= 0) {
                    StringBuffer buf = new StringBuffer(txt);
                    buf.replace(startIdx, endIdx, frc_.getReplaceText());
                    txt = buf.toString();

                    startIdx = StringUtils.indexOfIgnoreCase(txt, frc_.getSearchText());
                }
            }

            return txt;
        }

        private boolean hasGenericMatch(DescriptionVersionBI<?> desc) {
            String txt = desc.getText();

            if (frc_.isCaseSens()) {
                if (!txt.contains(frc_.getSearchText())) {
                    return false;
                }
            } else {
                if (!StringUtils.containsIgnoreCase(txt, frc_.getSearchText())) {
                    return false;
                }
            }

            return true;
        }

        private void updateDescription(DescriptionVersionBI<?> desc, String newTxt)
                throws IOException, InvalidCAB, ContradictionException {
            DescriptionCAB dcab = desc.makeBlueprint(OTFUtility.getViewCoordinate(), IdDirective.PRESERVE,
                    RefexDirective.INCLUDE);
            dcab.setText(newTxt);
            DescriptionChronicleBI dcbi = OTFUtility.getBuilder().constructIfNotCurrent(dcab);
            ExtendedAppContext.getDataStore()
                    .addUncommitted(ExtendedAppContext.getDataStore().getConceptForNid(dcbi.getConceptNid()));
        }

        private Set<DescriptionVersionBI<?>> getDescsToChange(ConceptVersionBI con) {
            Set<DescriptionVersionBI<?>> descsToChange = new HashSet<>();

            try {
                for (DescriptionVersionBI<?> desc : con.getDescriptionsActive()) {

                    if (frc_.getSelectedDescTypes().contains(DescriptionType.FSN)
                            && con.getFullySpecifiedDescription().getNid() == desc.getNid()) {
                        descsToChange.add(desc);
                    } else if (frc_.getSelectedDescTypes().contains(DescriptionType.PT)
                            && con.getPreferredDescription().getNid() == desc.getNid()) {
                        descsToChange.add(desc);
                    } else if (frc_.getSelectedDescTypes().contains(DescriptionType.SYNONYM)
                            && con.getFullySpecifiedDescription().getNid() != desc.getNid()
                            && con.getPreferredDescription().getNid() != desc.getNid()) {
                        descsToChange.add(desc);
                    }
                }
            } catch (IOException | ContradictionException e) {
                // TODO (artf231875) Auto-generated catch block
                e.printStackTrace();
            }

            return descsToChange;
        }

        private DescriptionType getDescType(ConceptVersionBI con, DescriptionVersionBI<?> desc)
                throws IOException, ContradictionException {
            // TODO (artf231875) Auto-generated method stub
            if (con.getFullySpecifiedDescription().getNid() == desc.getNid()) {
                return DescriptionType.FSN;
            } else if (con.getPreferredDescription().getNid() == desc.getNid()) {
                return DescriptionType.PT;
            } else {
                return DescriptionType.SYNONYM;
            }
        }
    };
}

From source file:com.none.tom.simplerssreader.feed.CurrentFeed.java

public static SearchResults getSearchResultsFor(final String query, final int position) {
    final List<Integer> positions = new ArrayList<>();
    final List<LinkedHashMap<Integer, Integer>> indicesTitle = new ArrayList<>();

    int i = 0;//from   w  ww .j  ava 2s . c  om

    for (final SyndEntry entry : sCurrentFeed.getEntries()) {
        final String title = entry.getTitle();

        if (StringUtils.containsIgnoreCase(title, query)) {
            indicesTitle.add(SearchUtils.getIndicesForQuery(title, query));
            positions.add(i);
        }
        i++;
    }

    return new SearchResults(position, positions, indicesTitle);
}

From source file:com.ibm.soatf.tool.ValidateTransferedValues.java

private static String getElementFromFile(String messageElementName, File file, boolean ignoreCase) {
    BufferedReader br = null;/* w  ww.  j  ava 2 s . c  om*/
    String searchFor = ":" + messageElementName + ">";
    String elementValue = null;
    String sCurrentLine;
    try {
        br = new BufferedReader(new FileReader(file));
        while ((sCurrentLine = br.readLine()) != null) {
            if (ignoreCase) {
                if (StringUtils.containsIgnoreCase(sCurrentLine, searchFor)) {
                    int indexBegin = sCurrentLine.toLowerCase().indexOf(searchFor.toLowerCase());
                    int indexEnd = sCurrentLine.substring(indexBegin).indexOf("<");
                    elementValue = sCurrentLine.substring(indexBegin + searchFor.length(),
                            indexBegin + indexEnd);
                    break;
                }
            } else {
                if (sCurrentLine.contains(searchFor)) {
                    int indexBegin = sCurrentLine.indexOf(searchFor);
                    int indexEnd = sCurrentLine.substring(indexBegin).indexOf("<");
                    elementValue = sCurrentLine.substring(indexBegin + searchFor.length(),
                            indexBegin + indexEnd);
                    break;
                    //System.out.println(elementValue);
                }
                // System.out.println(sCurrentLine);                   
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (br != null) {
                br.close();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    return elementValue;
}

From source file:com.glaf.oa.assessresult.web.springmvc.AssessresultController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");

    Assessresult assessresult = assessresultService.getAssessresult(RequestUtils.getLong(request, "resultid"));
    if (assessresult != null) {
        request.setAttribute("assessresult", assessresult);
        JSONObject rowJSON = assessresult.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    }/*from   w  ww. j  ava 2  s. c o  m*/

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (assessresult != null) {
            canUpdate = true;
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("assessresult.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/assessresult/edit", modelMap);
}