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

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

Introduction

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

Prototype

public static boolean contains(final CharSequence seq, final CharSequence searchSeq) 

Source Link

Document

Checks if CharSequence contains a search CharSequence, handling null .

Usage

From source file:com.mirth.connect.plugins.dashboardstatus.DashboardConnectorStatusServlet.java

@Override
public Map<String, String> getChannelStates() {
    Map<String, Object[]> connectorStates = redactChannelIds(
            monitor.getConnectorListener().getConnectorStateMap());
    Map<String, String> channelStates = new HashMap<String, String>();

    for (Entry<String, Object[]> entry : connectorStates.entrySet()) {
        if (StringUtils.contains(entry.getKey(), "_0")) {
            String channelId = StringUtils.remove(entry.getKey(), "_0");
            if (!isChannelRedacted(channelId)) {
                channelStates.put(channelId, (String) entry.getValue()[1]);
            }//  w  w w .  j  a va2s . c om
        }
    }

    return channelStates;
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.oracle.PhoneNumberMsRestOracle.java

@Override
protected boolean needSuggest(final String pentry) {
    return StringUtils.isNotEmpty(pentry) && !StringUtils.contains(pentry, ')');
}

From source file:com.github.fengtan.sophie.validators.FieldValidator.java

@Override
public String isValid(String fieldNameCandidate) {
    // A glob itself is not a valid field name.
    if (StringUtils.contains(fieldNameCandidate, "*")) {
        return "Field name should not contain any asterisk (\"*\").";
    }/*from w  ww .jav  a 2s  . co  m*/
    // User should not be able to add a field already listed in the table.
    if (excludedFieldNames.contains(fieldNameCandidate)) {
        return "Field \"" + fieldNameCandidate + "\" already exists.";
    }
    // The value entered by the user should match one of the fields.
    if (getMatchingField(fieldNameCandidate) == null) {
        return "\"" + fieldNameCandidate + "\" is not a valid field name.";
    }
    return null;
}

From source file:com.threewks.thundr.view.handlebars.HandlebarsView.java

private String completeViewName(String view) {
    if (!StringUtils.startsWith(view, "/")) {
        view = "/WEB-INF/hbs/" + view;
    }//w w  w.  jav  a 2s . c  om
    if (!StringUtils.contains(view, ".")) {
        view = view + ".hbs";
    }
    return view;
}

From source file:com.u2apple.tool.service.DeviceServiceImpl.java

private List<String> v2() {
    Set<String> productIds = new HashSet<>();
    StaticMapFile staticMapFile = deviceXmlDao.getStaticMapFile();
    List<VID> vids = staticMapFile.getVids();
    for (VID vid : vids) {
        for (Modal model : vid.getModals()) {
            for (ProductId productId : model.getProductId()) {
                if (StringUtils.contains(productId.getCondition(), "type")) {
                    productIds.add(productId.getValue());
                }// www  .j a v a2s  . c  o  m
            }
        }
    }

    Set<String> knockOffProductIds = new HashSet<>();
    Set<String> disknockOffProductIds = new HashSet<>();

    Set<String> pIds = new HashSet<>();
    for (String productId : productIds) {
        if (isKnockOff(productId)) {
            knockOffProductIds.add(productId);
        } else {
            disknockOffProductIds.add(productId);
        }
    }

    //remove the same product id.
    for (String productId : disknockOffProductIds) {
        String kp = toKnockOff(productId);
        {
            if (!knockOffProductIds.contains(kp)) {
                pIds.add(productId);
            }
        }
    }

    knockOffProductIds.addAll(pIds);
    for (String productId : knockOffProductIds) {
        pIds.add(toReal(productId));
    }
    List<String> list = new ArrayList<>(pIds);
    Collections.sort(list);
    return list;
}

From source file:kenh.xscript.elements.Accum.java

public void process(@Attribute(ATTRIBUTE_VARIABLE) String var, @Attribute(ATTRIBUTE_STEP) int step)
        throws UnsupportedScriptException {
    var = StringUtils.trimToEmpty(var);

    if (StringUtils.isBlank(var)) {
        UnsupportedScriptException ex = new UnsupportedScriptException(this, "Variable name is empty.");
        throw ex;
    }//from www .j  av a2 s .  com

    String thisVar = var;
    if (StringUtils.contains(var, " ")) {
        thisVar = StringUtils.substringAfterLast(var, " ");
    }

    int defaultValue = 0;
    if (this.getEnvironment().containsVariable(thisVar)) {
        Object obj = this.getEnvironment().getVariable(thisVar);
        if (obj instanceof Integer) {
            defaultValue = ((Integer) obj).intValue();
        } else if (obj instanceof String) {
            if (StringUtils.isNumeric((String) obj)) {
                defaultValue = Integer.parseInt((String) obj);
            }

        } else {
            UnsupportedScriptException ex = new UnsupportedScriptException(this,
                    "Only support integer variable.");
            throw ex;
        }
    }
    defaultValue += step;

    saveVariable(var, defaultValue, defaultValue);
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.oracle.PhoneNumberE123RestOracle.java

@Override
protected boolean needSuggest(final String pentry) {
    return StringUtils.isNotEmpty(pentry) && StringUtils.countMatches(pentry, " ") < 2
            && !StringUtils.contains(pentry, ')');
}

From source file:io.wcm.devops.conga.generator.plugins.fileheader.ConfFileHeaderTest.java

@Test
public void testApply() throws Exception {
    File file = new File("target/generation-test/fileHeader.conf");
    FileUtils.write(file, "myscript");

    List<String> lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim.");
    FileHeaderContext context = new FileHeaderContext().commentLines(lines);
    FileContext fileContext = new FileContext().file(file);

    assertTrue(underTest.accepts(fileContext, context));
    underTest.apply(fileContext, context);

    assertTrue(StringUtils.contains(FileUtils.readFileToString(file),
            "# Der Jodelkaiser\n# aus dem Oetztal\n# ist wieder daheim.\n"));

    FileHeaderContext extractContext = underTest.extract(fileContext);
    assertEquals(lines, extractContext.getCommentLines());

    file.delete();//  ww  w  . j  av  a  2  s  .c o  m
}

From source file:io.wcm.devops.conga.model.util.MapExpander.java

private static Map.Entry<String, Object> expandEntry(Map.Entry<String, Object> entry) {
    if (!StringUtils.contains(entry.getKey(), ".")) {
        return new MapEntry<String, Object>(entry.getKey(), expandDeep(entry.getValue()));
    }//from ww  w. jav a2  s  . c om

    String key = StringUtils.substringBefore(entry.getKey(), ".");
    String remaining = StringUtils.substringAfter(entry.getKey(), ".");

    Map<String, Object> map = new HashMap<>();
    map.put(remaining, expandDeep(entry.getValue()));
    Map<String, Object> expandedMap = expand(map);

    return new MapEntry<String, Object>(key, expandedMap);
}

From source file:io.wcm.devops.conga.plugins.sling.fileheader.OsgiConfigFileHeader.java

@Override
protected String sanitizeComment(String line) {
    if (StringUtils.equals(line, "") || StringUtils.contains(line, "*****")) {
        return null;
    }/*from w  ww.  j  av a 2 s.  co  m*/
    return StringUtils.trim(line);
}