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.thinkbiganalytics.jobrepo.rest.controller.QueryUtils.java

/**
 * This will evaluate the {@code incomingFilter} and append/set the value including the {@code defaultFilter} and return a new String with the updated filter
 *///from  ww w  .  j  ava 2 s .  co  m
public static String ensureDefaultFilter(String incomingFilter, String defaultFilter) {
    String filter = incomingFilter;
    if (StringUtils.isBlank(filter) || !StringUtils.containsIgnoreCase(filter, defaultFilter)) {
        if (StringUtils.isNotBlank(filter)) {
            if (StringUtils.endsWith(filter, ",")) {
                filter += defaultFilter;
            } else {
                filter += "," + defaultFilter;
            }
        } else {
            filter = defaultFilter;
        }
    }
    return filter;
}

From source file:com.bellman.bible.service.format.osistohtml.taghandler.TagHandlerHelper.java

/** Return true if attribute contains the desiredValue in any case
 *//*from   w w  w.j a  v  a  2  s .c o  m*/
public static boolean contains(String attributeName, Attributes attrs, String desiredValue) {
    boolean attribContainsExpectedValue = false;
    String attrValue = attrs.getValue(attributeName);
    if (attrValue != null) {
        attribContainsExpectedValue = StringUtils.containsIgnoreCase(attrValue, desiredValue);
    }
    return attribContainsExpectedValue;
}

From source file:cz.muni.expense.data.RuleRepository.java

public Category findCategory(Payment p) {
    if (p.getUser() == null) {
        throw new IllegalArgumentException("User can not be null");
    }/*  ww w.  ja v a 2 s .  co  m*/
    List<Rule> rules = this.findRulesByUserId(p.getUser().getId());
    for (Rule rule : rules) {
        if (StringUtils.containsIgnoreCase(p.getAdditionalInfo(), rule.getRuleString())) {
            return rule.getCategory();
        }
    }
    return null;
}

From source file:com.u2apple.rt.util.AndroidDeviceUtils.java

public static String getProductName(String brand, String model) {
    if (StringUtils.isNotBlank(brand) && StringUtils.isNotBlank(model)) {
        String productName;/*from   w  w w.  j  a va 2 s .c om*/
        if (StringUtils.containsIgnoreCase(model, brand)) {
            int index = model.toLowerCase().indexOf(brand.toLowerCase());
            productName = model.substring(index + brand.length());
        } else {
            productName = model;
        }
        //Remove prefix -.
        productName = StringUtils.removeStart(productName, "-");
        productName = StringUtils.removeStart(productName, "_");
        return productName.replace("_", "-").trim();
    } else {
        return null;
    }
}

From source file:com.outcastgeek.traversal.TraverseUtils.java

/**
 * @param pojo is the POJO to be traversed
 * @param pathSteps is traversal path// w  w  w.  j a v a  2s .c  o m
 * @return true or false
 * @throws TraverseException
 */
public static boolean isNullPath(Object pojo, String... pathSteps) throws TraverseException {

    boolean isNullPath = false;

    try {
        Class pojoClass = pojo.getClass();
        Method[] declaredMethods = pojoClass.getDeclaredMethods();
        int pathStepLength = pathSteps.length;
        logger.debug("Traversing {}...", pojo);
        for (int i = 0; i < pathStepLength; i++) {
            String step = pathSteps[i];
            logger.debug("Step: {}", step);
            Object value = null;
            for (Method method : declaredMethods) {
                String methodName = method.getName();
                if (StringUtils.containsIgnoreCase(methodName, step)) {
                    value = pojoClass.getDeclaredMethod(methodName).invoke(pojo);
                    break;
                }
            }
            if (value != null) {
                if (i == pathStepLength - 1) {
                    break;
                } else {
                    String[] followingSteps = ArrayUtils.removeElement(pathSteps, step);
                    return isNullPath(value, followingSteps);
                }
            } else {
                isNullPath = true;
                break;
            }
        }
    } catch (Exception e) {
        throw new TraverseException(e);
    }

    return isNullPath;
}

From source file:city_planning.initialize_fields.Initialize_search_record_field_types.java

public static void init_regions(final JTextField tf) {

    Object[][] obj = null;// w  w w  .  j a v a  2s  .  co m
    int i = 0;
    if (tf.getText().isEmpty()) {
        obj = new Object[regions.size()][1];
        for (Regions.to_regions to : regions) {
            obj[i][0] = " " + to.region;
            i++;
        }
    } else {
        List<Regions.to_regions> in_search = new ArrayList();
        for (Regions.to_regions to : regions) {
            boolean contains = StringUtils.containsIgnoreCase(to.region, tf.getText());
            if (contains) {
                in_search.add(to);
            }
        }
        obj = new Object[in_search.size()][1];
        for (Regions.to_regions to : in_search) {
            obj[i][0] = " " + to.region;
            i++;
        }
    }

    JLabel[] labels = {};
    int[] tbl_widths_customers = { tf.getWidth() };
    String[] col_names = { "Name" };
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(tf, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(new TableRenderer.Callback() {
        @Override
        public void ok(TableRenderer.OutputData data) {
            Regions.to_regions to = regions.get(data.selected_row);
            Field.Combo field = (Field.Combo) tf;
            field.setText(to.region);
            field.setId("" + to.id);
        }
    });
}

From source file:de.dominikschadow.duke.encounters.services.SecurityValidationService.java

public boolean hasXssPayload(@NotNull String payload) {
    return StringUtils.containsIgnoreCase(payload, "<") || StringUtils.containsIgnoreCase(payload, "javascript")
            || StringUtils.containsIgnoreCase(payload, "onload")
            || StringUtils.containsIgnoreCase(payload, "eval")
            || StringUtils.containsIgnoreCase(payload, "document.cookie");
}

From source file:com.catexpress.gui.tools.AutoCompletarCellRenderer.java

@Override
public Component getListCellRendererComponent(JList list, Cliente cliente, int index, boolean isSelected,
        boolean cellHasFocus) {
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    if (cliente == null) {
        setText("Ningun resultado encontrado");
        return this;
    }/*from www  . j a  va2s  . c o  m*/

    String replace = "<html>";

    if (StringUtils.containsIgnoreCase(String.valueOf(cliente.getId()), regex.getText())) {
        replace += String.valueOf(cliente.getId()).replaceAll("(?i)" + regex.getText(),
                "<font color='" + MATCH_COLOR + "'>" + regex.getText() + "</font>");
    } else {
        replace += cliente.getId();
    }

    if (StringUtils.containsIgnoreCase(cliente.getNombre(), regex.getText())) {
        replace += " - " + cliente.getNombre().replaceAll("(?i)" + regex.getText(),
                "<font color='" + MATCH_COLOR + "'>" + regex.getText() + "</font>");
    } else {
        replace += " - " + cliente.getNombre();
    }

    if (StringUtils.containsIgnoreCase(cliente.getApPaterno(), regex.getText())) {
        replace += " " + cliente.getApPaterno().replaceAll("(?i)" + regex.getText(),
                "<font color='" + MATCH_COLOR + "'>" + regex.getText() + "</font>");
    } else {
        replace += " " + cliente.getApPaterno();
    }

    if (StringUtils.containsIgnoreCase(cliente.getApMaterno(), regex.getText())) {
        replace += " " + cliente.getApMaterno().replaceAll("(?i)" + regex.getText(),
                "<font color='" + MATCH_COLOR + "'>" + regex.getText() + "</font>");
    } else {
        replace += " " + cliente.getApMaterno();
    }

    setText(replace);
    return this;
}

From source file:com.mirth.connect.server.migration.Migrate3_4_0.java

@Override
public void updateConfiguration(PropertiesConfiguration configuration) {
    if (StringUtils.containsIgnoreCase(configuration.getLayout().getComment("database"), "sqlserver2000")) {
        configuration.getLayout().setComment("database", "options: derby, mysql, postgres, oracle, sqlserver");

        try {// www  .j  a  va 2  s .c o m
            configuration.save();
        } catch (ConfigurationException e) {
            logger.warn("An error occurred updating the database property comment.");
        }
    }
}

From source file:de.micromata.genome.util.matcher.string.ContainsIgnoreCaseMatcher.java

@Override
public boolean matchString(String token) {
    return StringUtils.containsIgnoreCase(token, pattern);
}