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

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

Introduction

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

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:com.glaf.core.xml.XmlBuilder.java

protected void processTextNode(Element element, Map<String, DatasetModel> dataSetMap,
        Map<String, Object> dataMap, String systemName, Map<String, Object> params) {
    //LOG.debug("---------------------processTextNode-----------------------");
    if (StringUtils.equals(element.getName(), "foreach")) {
        this.processForEachNode(element, dataSetMap, dataMap, systemName, params);
        return;//from w  ww.j ava 2s  .co m
    }
    String dsId = element.attributeValue("DataSetId");
    if (StringUtils.isNotEmpty(dsId)) {
        if (dataMap != null && !dataMap.isEmpty()) {
            params.putAll(dataMap);
        }
        this.processNode(element, dataSetMap, systemName, params);
        return;
    }

    if (element.isTextOnly()) {
        String value = element.getStringValue();
        if (StringUtils.contains(value, "#{") && StringUtils.contains(value, "}")) {
            String text = QueryUtils.replaceBlankParas(value, dataMap);
            element.setText(text);
        }
    }

    List<?> attrs = element.attributes();
    Iterator<?> iter = attrs.iterator();
    while (iter.hasNext()) {
        Attribute attr = (Attribute) iter.next();
        String value = attr.getValue();
        if (StringUtils.contains(value, "#{") && StringUtils.contains(value, "}")) {
            String text = QueryUtils.replaceBlankParas(value, dataMap);
            attr.setValue(text);
        }
    }

    List<?> elements = element.elements();
    Iterator<?> iterator = elements.iterator();
    while (iterator.hasNext()) {
        Element elem = (Element) iterator.next();
        if (StringUtils.equals(elem.getName(), "foreach")) {
            this.processForEachNode(elem, dataSetMap, dataMap, systemName, params);
        } else {
            String dsId2 = elem.attributeValue("DataSetId");
            if (StringUtils.isNotEmpty(dsId2)) {
                if (dataMap != null && !dataMap.isEmpty()) {
                    params.putAll(dataMap);
                }
                this.processNode(elem, dataSetMap, systemName, params);
            } else {
                this.processTextNode(elem, dataSetMap, dataMap, systemName, params);
            }
        }
    }
}

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.LocalityCleanupIndexer.java

/**
 * @param localityStr// www .j a  v  a2s  . co  m
 * @return
 */
protected static String getMiles(final String localityStr) {
    String locStr = localityStr.toString();
    if (StringUtils.contains(locStr, " mi") || StringUtils.contains(locStr, " km")) {
        String[] tokens = StringUtils.split(locStr, ' ');
        for (int i = 0; i < tokens.length; i++) {
            if (tokens[i].equals("mi") || tokens[i].equals("km")) {

                if (i > 0 && StringUtils.isNumeric(tokens[i - 1])) {
                    return tokens[i - 1];
                }
            }
        }
    }
    return null;
}

From source file:eu.europeana.uim.plugin.solr.service.SolrWorkflowPlugin.java

private RDF cleanRDF(RDF rdf) {
    RDF rdfFinal = new RDF();
    List<AgentType> agents = new ArrayList<AgentType>();
    List<TimeSpanType> timespans = new ArrayList<TimeSpanType>();
    List<PlaceType> places = new ArrayList<PlaceType>();
    List<Concept> concepts = new ArrayList<Concept>();
    JibxUtils utils = new JibxUtils();

    if (rdf.getAgentList() != null) {

        agents.addAll(rdf.getAgentList());

        for (int i = 0; i < agents.size() - 1; i++) {
            AgentType sAgent = agents.get(i);
            for (int k = i + 1; k < agents.size(); k++) {
                AgentType fAgent = agents.get(k);
                if (StringUtils.contains(fAgent.getAbout(), sAgent.getAbout())
                        || StringUtils.contains(fAgent.getAbout(), sAgent.getAbout())) {

                    agents.set(i, utils.mergeAgentFields(fAgent, sAgent));
                    sAgent = agents.get(i);
                    agents.remove(k);//  ww w.j a  va2s. co  m
                    k--;
                }
            }

        }
        rdfFinal.setAgentList(agents);
    }
    if (rdf.getConceptList() != null) {
        concepts.addAll(rdf.getConceptList());
        for (int i = 0; i < concepts.size() - 1; i++) {
            Concept sConcept = concepts.get(i);
            for (int k = i + 1; k < concepts.size(); k++) {
                Concept fConcept = concepts.get(k);
                if (StringUtils.contains(fConcept.getAbout(), sConcept.getAbout())
                        || StringUtils.contains(sConcept.getAbout(), fConcept.getAbout())) {
                    concepts.set(i, utils.mergeConceptsField(fConcept, sConcept));
                    sConcept = concepts.get(i);
                    concepts.remove(k);
                    k--;
                }
            }
        }

        rdfFinal.setConceptList(concepts);
    }
    if (rdf.getTimeSpanList() != null) {
        timespans.addAll(rdf.getTimeSpanList());
        for (int i = 0; i < timespans.size() - 1; i++) {
            TimeSpanType sTs = timespans.get(i);
            for (int k = i + 1; k < timespans.size(); k++) {
                TimeSpanType fTs = timespans.get(k);
                if (StringUtils.contains(fTs.getAbout(), sTs.getAbout())
                        || StringUtils.contains(sTs.getAbout(), fTs.getAbout())) {
                    timespans.set(i, utils.mergeTimespanFields(fTs, sTs));
                    sTs = timespans.get(i);
                    timespans.remove(k);
                    k--;
                }
            }
        }
        rdfFinal.setTimeSpanList(timespans);
    }
    if (rdf.getPlaceList() != null) {
        places.addAll(rdf.getPlaceList());

        for (int i = 0; i < places.size() - 1; i++) {
            PlaceType sPlace = places.get(i);
            for (int k = i + 1; k < places.size(); k++) {
                PlaceType fPlace = places.get(k);
                if (StringUtils.equals(fPlace.getAbout(), sPlace.getAbout())
                        || StringUtils.contains(sPlace.getAbout(), fPlace.getAbout())) {
                    if (fPlace.getAbout() != null && sPlace.getAbout() != null) {
                        places.set(i, utils.mergePlacesFields(fPlace, sPlace));
                    }
                    sPlace = places.get(i);
                    places.remove(k);
                    k--;

                }
            }
        }

        rdfFinal.setPlaceList(places);
    }
    rdfFinal.setAggregationList(rdf.getAggregationList());
    rdfFinal.setProxyList(rdf.getProxyList());
    rdfFinal.setProvidedCHOList(rdf.getProvidedCHOList());
    rdfFinal.setEuropeanaAggregationList(rdf.getEuropeanaAggregationList());
    rdfFinal.setWebResourceList(rdf.getWebResourceList());

    return rdfFinal;
}

From source file:adalid.util.velocity.SecondBaseBuilder.java

private void createTextFilePropertiesFile(String source, String target) {
    boolean java = StringUtils.endsWithIgnoreCase(source, ".java");
    boolean bundle = StringUtils.endsWithIgnoreCase(source, ".properties");
    File sourceFile = new File(source);
    String sourceFileName = sourceFile.getName();
    String sourceFileSimpleName = StringUtils.substringBeforeLast(sourceFileName, ".");
    String sourceFolderName = sourceFile.getParentFile().getName();
    String sourceFolderSimpleName = StringUtils.substringBeforeLast(sourceFolderName, ".");
    String sourceEntityName = getOptionalEntityName(sourceFileSimpleName, sourceFolderSimpleName);
    String properties = source.replace(projectFolderPath, velocityPlatformsTargetFolderPath) + ".properties";
    String folder = StringUtils.substringBeforeLast(properties, FS);
    String template = StringUtils.substringAfter(target, velocityFolderPath + FS).replace(FS, "/");
    String path = StringUtils.substringBeforeLast(StringUtils.substringAfter(source, projectFolderPath), FS)
            .replace(FS, "/").replace(project, PROJECT_ALIAS).replace("eclipse.settings", ".settings");
    path = replaceAliasWithRootFolderName(path);
    String pack = null;/*from  ww  w.j  ava  2s  .  c om*/
    if (java || bundle) {
        String s1 = StringUtils.substringAfter(path, SRC);
        if (StringUtils.contains(s1, PROJECT_ALIAS)) {
            String s2 = StringUtils.substringBefore(s1, PROJECT_ALIAS);
            String s3 = SRC + s2;
            String s4 = StringUtils.substringBefore(path, s3) + s3;
            String s5 = StringUtils.substringAfter(s1, PROJECT_ALIAS).replace("/", ".");
            path = StringUtils.removeEnd(s4, "/");
            pack = ROOT_PACKAGE_NAME + s5;
        }
    }
    path = finalisePath(path);
    String file = StringUtils.substringAfterLast(source, FS).replace(project, PROJECT_ALIAS)
            .replace("eclipse.project", ".project");
    List<String> lines = new ArrayList<>();
    lines.add("template = " + template);
    //      lines.add("template-type = velocity");
    lines.add("path = " + path);
    if (StringUtils.isNotBlank(pack)) {
        lines.add("package = " + pack);
    }
    lines.add("file = " + file);
    if (sourceFileSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("eclipse")
            || sourceFolderSimpleName.equals("nbproject")) {
        lines.add("disabled = true");
    } else if (sourceEntityName != null) {
        lines.add("disabled-when-missing = " + sourceEntityName);
    }
    if (preservable(sourceFile)) {
        lines.add("preserve = true");
    }
    lines.add("dollar.string = $");
    lines.add("pound.string = #");
    lines.add("backslash.string = \\\\");
    FilUtils.mkdirs(folder);
    if (write(properties, lines, WINDOWS_CHARSET)) {
        propertiesFilesCreated++;
    }
}

From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java

private static void setCellValuePlateNumberFormat(HSSFWorkbook wb, Cell cell, Object oneCellValue,
        String vendor) {/*from w  ww  .j  a  v  a 2  s .  c o m*/
    if (oneCellValue == null) {
        cell.setCellValue(StringUtils.EMPTY);
        return;
    }

    String plateNum = StringUtils.trimToEmpty(oneCellValue.toString());
    plateNum = plateNum.replaceAll("\u00a0", StringUtils.EMPTY);
    if (StringUtils.isEmpty(plateNum)) {
        cell.setCellValue(StringUtils.EMPTY);
        return;
    }

    if (StringUtils.contains(vendor, TOLL_COMPANY_EZ_PASS_NY)) {
        plateNum = StringUtils.stripStart(plateNum, "0");
        plateNum = StringUtils.substring(plateNum, 2);
    } else if (StringUtils.contains(vendor, TOLL_COMPANY_EZ_PASS_PA)) {
        plateNum = StringUtils.substring(plateNum, 3);
    }
    cell.setCellValue(plateNum);
}

From source file:com.cubusmail.mail.imap.IMAPMailbox.java

/**
 * @param mailFolder// w  w  w.j  a v a2  s  . c om
 * @return
 * @throws MessagingException
 */
private List<IMailFolder> getSubfolders(IMailFolder mailFolder) throws MessagingException {

    List<IMailFolder> subfolders = new ArrayList<IMailFolder>();
    String searchKey = mailFolder.getId() + getFolderSeparator();

    Set<String> keys = this.mailFolderMap.keySet();
    for (String key : keys) {
        if (key.startsWith(searchKey)
                && !StringUtils.contains(StringUtils.substringAfter(key, searchKey), getFolderSeparator())) {

            IMailFolder subfolder = this.mailFolderMap.get(key);
            subfolders.add(subfolder);
            if (subfolder.hasChildren()) {
                subfolder.setSubfolders(getSubfolders(subfolder));
            }
        }
    }

    return subfolders;
}

From source file:com.activecq.tools.errorpagehandler.impl.ErrorPageHandlerImpl.java

/**
 * Determines if the request originated from a Browser
 *
 * @param request/*from w  w w.  j a v a  2s  . c  o  m*/
 * @return
 */
protected boolean isBrowserRequest(SlingHttpServletRequest request) {
    final String userAgent = request.getHeader(USER_AGENT);
    return !StringUtils.isBlank(userAgent)
            && (StringUtils.contains(userAgent, MOZILLA) || StringUtils.contains(userAgent, OPERA));
}

From source file:com.perceptive.epm.perkolcentral.action.ajax.EmployeeDetailsAction.java

public String executeGetAllEmployeesAtOnce() throws ExceptionWrapper {
    try {/*from ww  w .j a  va2  s .  co  m*/
        LinkedHashMap<Long, EmployeeBO> employeeLinkedHashMap = new LinkedHashMap<Long, EmployeeBO>();

        employeeLinkedHashMap = employeeBL.getAllEmployees();
        gridModel = new ArrayList<EmployeeBO>(employeeLinkedHashMap.values());
        CollectionUtils.filter(gridModel, new Predicate() {
            @Override
            public boolean evaluate(Object o) {
                return StringUtils.contains(((EmployeeBO) o).getEmployeeName().toLowerCase(),
                        term.toLowerCase());
            }
        });
    } catch (Exception ex) {
        throw new ExceptionWrapper(ex);
    }
    return SUCCESS;
}

From source file:jp.primecloud.auto.ui.WinServiceEdit.java

public void valueChangeValidate(ValueChangeEvent event, final ServerSelect serverSelect) {
    Set<String> selectedItemsProperty = (Set<String>) event.getProperty().getValue();
    final Collection<String> notSelectedList = new ArrayList<String>();
    for (Object item : serverSelect.getItemIds()) {
        notSelectedList.add(item.toString());
    }/* w  ww . j  a  va 2s  .  co  m*/
    notSelectedList.removeAll(selectedItemsProperty);

    Collection<Object> moveList = new ArrayList<Object>();
    //?STOPPED?????????
    for (String notSelectedItem : notSelectedList) {
        if (!StringUtils.contains(notSelectedItem.toUpperCase(),
                "(" + ComponentInstanceStatus.STOPPED.toString() + ")")
                && StringUtils.contains(notSelectedItem, "(")) {
            moveList.add(notSelectedItem);
        }
    }
    //?????????
    serverSelect.select(moveList);

    //?????????
    if (!moveList.isEmpty()) {
        String message = ViewMessages.getMessage("IUI-000039");
        DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message,
                Buttons.OK);
        dialog.setCallback(new DialogConfirm.Callback() {
            @Override
            public void onDialogResult(Result result) {
                if (result != Result.OK) {
                    return;
                }
            }
        });
        getApplication().getMainWindow().addWindow(dialog);
        return;
    }

    // ????????????????????????
    notSelectedList.removeAll(moveList);
    moveList = new ArrayList<Object>();

    for (String notSelectedItem : notSelectedList) {
        int index = notSelectedItem.indexOf(" ");
        String instanceName = index == -1 ? notSelectedItem : notSelectedItem.substring(0, index);
        // pcc-api??????????
        ComponentService componentService = BeanContext.getBean(ComponentService.class);
        moveList = componentService.checkAttachDisk(ViewContext.getFarmNo(), componentNo, instanceName,
                notSelectedItem, moveList);
    }

    if (!moveList.isEmpty()) {
        // ?????????????
        serverSelect.select(moveList);

        // 
        String message = ViewMessages.getMessage("IUI-000096");
        DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message,
                Buttons.OK);
        dialog.setCallback(new DialogConfirm.Callback() {
            @Override
            public void onDialogResult(Result result) {
                if (result != Result.OK) {
                    return;
                }
            }
        });
        getApplication().getMainWindow().addWindow(dialog);
        return;
    }
}

From source file:com.impetus.client.cassandra.query.ResultIterator.java

/**
 * Gets the condition on id column./*from  www . j a va2 s.  co  m*/
 * 
 * @param idColumn
 *            the id column
 * @return the condition on id column
 */
private Map<Boolean, String> getConditionOnIdColumn(String idColumn) {

    Map<Boolean, String> filterIdResult = new HashMap<Boolean, String>();

    MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
            .getMetamodel(entityMetadata.getPersistenceUnit());

    EmbeddableType keyObj = null;
    if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
        keyObj = metaModel.embeddable(entityMetadata.getIdAttribute().getBindableJavaType());
    }

    for (Object o : query.getKunderaQuery().getFilterClauseQueue()) {
        if (o instanceof FilterClause) {
            FilterClause clause = ((FilterClause) o);
            String fieldName = clause.getProperty();
            String condition = clause.getCondition();

            if (keyObj != null && fieldName.equals(idColumn)
                    || (keyObj != null && StringUtils.contains(fieldName, '.'))
                    || (idColumn.equals(fieldName))) {
                filterIdResult.put(true, condition);
                break;
            }
        }
    }
    return filterIdResult;
}