Example usage for java.lang String regionMatches

List of usage examples for java.lang String regionMatches

Introduction

In this page you can find the example usage for java.lang String regionMatches.

Prototype

public boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) 

Source Link

Document

Tests if two string regions are equal.

Usage

From source file:org.lockss.util.StringUtil.java

/** Like startsWith except is case-independent */
public static boolean startsWithIgnoreCase(String str, String start) {
    return str.regionMatches(true, 0, start, 0, start.length());
}

From source file:org.talend.camel.designer.ui.wizards.JavaCamelJobScriptsExportWSWizardPage.java

@Override
public boolean finish() {

    String version = getSelectedJobVersion();
    String destinationKar = getDestinationValue();
    JavaCamelJobScriptsExportWSAction action = null;
    IRunnableWithProgress actionMS = null;
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
    boolean needMavenScript = exportChoiceMap.containsKey(ExportChoice.needMavenScript)
            && exportChoiceMap.get(ExportChoice.needMavenScript) == Boolean.TRUE;

    if (needMavenScript && destinationKar.regionMatches(true, destinationKar.length() - 4, ".kar", 0, 4)) {
        destinationKar = destinationKar.substring(0, destinationKar.length() - 3) + "zip";
    }/* w  ww .j av a  2s  .co m*/

    if (exportAsZip) {
        exportChoiceMap.put(ExportChoice.needAssembly, Boolean.TRUE);
    }

    if (new File(destinationKar).exists()) {
        boolean yes = MessageDialog.openQuestion(getShell(),
                Messages.getString("JavaCamelJobScriptsExportWSWizardPage.OverwriteKarTitle"),
                Messages.getString("JavaCamelJobScriptsExportWSWizardPage.OverwriteKarMessage"));
        if (!yes) {
            return false;
        }
    }

    IESBMicroService microService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBMicroService.class)) {
        microService = (IESBMicroService) GlobalServiceRegister.getDefault().getService(IESBMicroService.class);
    }

    IBuildJobHandler buildJobHandler = null;

    if (exportTypeCombo.getText().equals(EXPORTTYPE_SPRING_BOOT)) {

        try {
            if (microService != null) {

                buildJobHandler = microService.createBuildJobHandler(getProcessItem(), version, destinationKar,
                        exportChoiceMap);

                Map<String, Object> prepareParams = new HashMap<String, Object>();
                prepareParams.put(IBuildResourceParametes.OPTION_ITEMS, true);
                prepareParams.put(IBuildResourceParametes.OPTION_ITEMS_DEPENDENCIES, true);

                try {
                    buildJobHandler.prepare(new NullProgressMonitor(), prepareParams);
                } catch (Exception e) {
                    MessageBoxExceptionHandler.process(e.getCause() == null ? e : e.getCause(), getShell());
                    return false;
                }

                actionMS = microService.createRunnableWithProgress(exportChoiceMap,
                        Arrays.asList(getCheckNodes()), version, destinationKar, "");
            }

        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e.getCause() == null ? e : e.getCause(), getShell());
            e.printStackTrace();
        }

        try {
            getContainer().run(false, true, actionMS);
            buildJobHandler.build(new NullProgressMonitor());
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e.getCause() == null ? e : e.getCause(), getShell());
            return false;
        }

    } else {

        if (getProcessItem() instanceof CamelProcessItem) {
            CamelProcessItem camelProcessItem = (CamelProcessItem) getProcessItem();
            if (camelProcessItem.isExportMicroService()) {
                camelProcessItem.setExportMicroService(false);
            }
        }

        if (needMavenScript) {
            action = new JavaCamelJobScriptsExportWithMavenAction(exportChoiceMap, nodes[0], version,
                    destinationKar, false);
        } else {

            exportChoiceMap.put(ExportChoice.esbExportType, "kar");

            buildJobHandler = BuildJobFactory.createBuildJobHandler(getProcessItem(), getContextName(), version,
                    exportChoiceMap, "ROUTE");

            Map<String, Object> prepareParams = new HashMap<String, Object>();
            prepareParams.put(IBuildResourceParametes.OPTION_ITEMS, true);
            prepareParams.put(IBuildResourceParametes.OPTION_ITEMS_DEPENDENCIES, true);

            try {
                buildJobHandler.prepare(new NullProgressMonitor(), prepareParams);
            } catch (Exception e) {
                MessageBoxExceptionHandler.process(e.getCause() == null ? e : e.getCause(), getShell());
                return false;
            }

            action = new JavaCamelJobScriptsExportWSAction(nodes[0], version, destinationKar, false);

            ProcessorUtilities.setExportAsOSGI(true);
        }

        try {
            getContainer().run(false, true, action);

            buildJobHandler.build(new NullProgressMonitor());
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        }

    }

    IFile targetFile = buildJobHandler.getJobTargetFile();

    if (targetFile != null && targetFile.exists()) {
        try {
            FilesUtils.copyFile(targetFile.getLocation().toFile(), new File(getDestinationValue()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    return true;
}

From source file:org.lockss.util.StringUtil.java

/** Like endsWith except is case-independent */
public static boolean endsWithIgnoreCase(String str, String end) {
    int lend = end.length();
    return str.regionMatches(true, str.length() - lend, end, 0, lend);
}

From source file:org.lockss.util.StringUtil.java

/**
 * Trim a hostname, removing "www." from the front, if present, and the
 * TLD from the end.  If this would result in an empty string, the entire
 * name is returned./*from  www  .j  a  v  a  2 s  .  com*/
 * @param hostname a hostname string
 * @return the trimmed hostname
 */
public static String trimHostName(String hostname) {
    if (hostname == null)
        return null;
    int start = 0;
    if (hostname.regionMatches(true, 0, "www.", 0, 4)) {
        start = 4;
    }
    int end = hostname.lastIndexOf('.');
    if (end <= start) {
        // if trimming www left nothing but TLD, return whole name
        return hostname;
    }
    return hostname.substring(start, end);
}

From source file:org.lockss.util.StringUtil.java

/** Like indexOf except is case-independent */
public static int indexOfIgnoreCase(String str, String substr, int fromIndex) {
    if (str == null || substr == null) {
        return -1;
    }//from w ww .  j a v a 2  s . c o  m
    int sublen = substr.length();
    int last = str.length() - sublen;
    for (int ix = fromIndex; ix <= last; ix++) {
        if (str.regionMatches(true, ix, substr, 0, sublen)) {
            return ix;
        }
    }
    return -1;
}

From source file:org.sakaiproject.james.SakaiMailet.java

/**
 * Process incoming mail.//  w w w . java 2s. com
 * 
 * @param mail
 *        ...
 */
public void service(Mail mail) throws MessagingException {
    // get the postmaster user
    User postmaster = null;
    try {
        postmaster = userDirectoryService.getUser(POSTMASTER);
    } catch (UserNotDefinedException e) {
        M_log.warn("service(): no postmaster, incoming mail will not be processed until a postmaster user (id="
                + POSTMASTER + ") exists in this Sakai instance");
        mail.setState(Mail.GHOST);
        return;
    }

    try {
        // set the current user to postmaster
        Session s = sessionManager.getCurrentSession();
        if (s != null) {
            s.setUserId(postmaster.getId());
        } else {
            M_log.warn(
                    "service - no SessionManager.getCurrentSession, cannot set to postmaser user, attempting to use the current user ("
                            + sessionManager.getCurrentSessionUserId() + ") and session ("
                            + sessionManager.getCurrentSession().getId() + ")");
        }

        MimeMessage msg = mail.getMessage();
        String id = msg.getMessageID();

        Address[] fromAddresses = msg.getFrom();
        String from = null;
        String fromAddr = null;
        if ((fromAddresses != null) && (fromAddresses.length == 1)) {
            from = fromAddresses[0].toString();
            if (fromAddresses[0] instanceof InternetAddress) {
                fromAddr = ((InternetAddress) (fromAddresses[0])).getAddress();
            }
        } else {
            from = mail.getSender().toString();
            fromAddr = mail.getSender().toInternetAddress().getAddress();
        }

        Collection<MailAddress> to = mail.getRecipients();

        Date sent = msg.getSentDate();

        String subject = StringUtils.trimToNull(msg.getSubject());

        Enumeration<String> headers = msg.getAllHeaderLines();
        List<String> mailHeaders = new Vector<String>();
        while (headers.hasMoreElements()) {
            String line = (String) headers.nextElement();
            // check if string starts with "Content-Type", ignoring case
            if (line.regionMatches(true, 0, MailArchiveService.HEADER_CONTENT_TYPE, 0,
                    MailArchiveService.HEADER_CONTENT_TYPE.length())) {
                String contentType = line.substring(0, MailArchiveService.HEADER_CONTENT_TYPE.length());
                mailHeaders.add(line.replaceAll(contentType, MailArchiveService.HEADER_OUTER_CONTENT_TYPE));
            }
            // don't copy null subject lines. we'll add a real one below
            if (!(line.regionMatches(true, 0, MailArchiveService.HEADER_SUBJECT, 0,
                    MailArchiveService.HEADER_SUBJECT.length()) && subject == null))
                mailHeaders.add(line);

        }

        //Add headers for a null subject, keep null in DB
        if (subject == null) {
            mailHeaders.add(MailArchiveService.HEADER_SUBJECT + ": <" + rb.getString("err_no_subject") + ">");
        }

        if (M_log.isDebugEnabled()) {
            M_log.debug(id + " : mail: from:" + from + " sent: "
                    + timeService.newTime(sent.getTime()).toStringLocalFull() + " subject: " + subject);
        }

        // process for each recipient
        Iterator<MailAddress> it = to.iterator();
        while (it.hasNext()) {
            String mailId = null;
            try {
                MailAddress recipient = (MailAddress) it.next();
                if (M_log.isDebugEnabled()) {
                    M_log.debug(id + " : checking to: " + recipient);
                }

                // the recipient's mail id
                mailId = recipient.getUser();

                // eat the no-reply
                if ("no-reply".equalsIgnoreCase(mailId)) {
                    mail.setState(Mail.GHOST);
                    if (M_log.isInfoEnabled()) {
                        M_log.info("Incoming message mailId (" + mailId
                                + ") set to no-reply, mail processing cancelled");
                    }
                    /* NOTE: this doesn't make a lot of sense to me, once the mail is ghosted 
                     * then it won't be processed anymore so continuing is kind of a waste of time,
                     * shouldn't this just break instead?
                     */
                    continue;
                }

                // find the channel (mailbox) that this is addressed to
                // for now, check only for it being a site or alias to a site.
                // %%% - add user and other later -ggolden
                MailArchiveChannel channel = null;

                // first, assume the mailId is a site id
                String channelRef = MailArchiveService.channelReference(mailId, SiteService.MAIN_CONTAINER);
                try {
                    channel = MailArchiveService.getMailArchiveChannel(channelRef);
                    if (M_log.isDebugEnabled()) {
                        M_log.debug(
                                "Incoming message mailId (" + mailId + ") IS a valid site channel reference");
                    }
                } catch (IdUnusedException goOn) {
                    // INDICATES the incoming message is NOT for a currently valid site
                    if (M_log.isDebugEnabled()) {
                        M_log.debug("Incoming message mailId (" + mailId
                                + ") is NOT a valid site channel reference, will attempt more matches");
                    }
                } catch (PermissionException e) {
                    // INDICATES the channel is valid but the user has no permission to access it
                    // This generally should not happen because the current user should be the postmaster
                    M_log.warn(
                            "mailarchive failure: message processing cancelled: PermissionException with channelRef ("
                                    + channelRef + ") - user not allowed to get this mail archive channel: (id="
                                    + id + ") (mailId=" + mailId + ") (user="
                                    + sessionManager.getCurrentSessionUserId() + ") (session="
                                    + sessionManager.getCurrentSession().getId() + "): " + e,
                            e);
                    // BOUNCE REPLY - send a message back to the user to let them know their email failed
                    String errMsg = rb.getString("err_not_member") + "\n\n";
                    String mailSupport = StringUtils
                            .trimToNull(serverConfigurationService.getString("mail.support"));
                    if (mailSupport != null) {
                        errMsg += (String) rb.getFormattedMessage("err_questions", new Object[] { mailSupport })
                                + "\n";
                    }
                    mail.setErrorMessage(errMsg);
                    mail.setState(userNotAllowedToPostProcessor);
                    continue;
                }

                // next, if not a site, see if it's an alias to a site or channel
                if (channel == null) {
                    // if not an alias, it will throw the IdUnusedException caught below
                    Reference ref = entityManager.newReference(aliasService.getTarget(mailId));

                    if (ref.getType().equals(SiteService.APPLICATION_ID)) {
                        // ref is a site
                        // now we have a site reference, try for it's channel
                        channelRef = MailArchiveService.channelReference(ref.getId(),
                                SiteService.MAIN_CONTAINER);
                        if (M_log.isDebugEnabled()) {
                            M_log.debug("Incoming message mailId (" + mailId + ") IS a valid site reference ("
                                    + ref.getId() + ")");
                        }
                    } else if (ref.getType().equals(MailArchiveService.APPLICATION_ID)) {
                        // ref is a channel
                        channelRef = ref.getReference();
                        if (M_log.isDebugEnabled()) {
                            M_log.debug("Incoming message mailId (" + mailId
                                    + ") IS a valid channel reference (" + ref.getId() + ")");
                        }
                    } else {
                        // ref cannot be be matched
                        if (M_log.isInfoEnabled()) {
                            M_log.info(id + " : mail rejected: unknown address: " + mailId + " : mailId ("
                                    + mailId + ") does NOT match site, alias, or other current channel");
                        }
                        if (M_log.isDebugEnabled()) {
                            M_log.debug("Incoming message mailId (" + mailId
                                    + ") is NOT a valid does NOT match site, alias, or other current channel reference ("
                                    + ref.getId() + "), message rejected");
                        }
                        throw new IdUnusedException(mailId);
                    }

                    // if there's no channel for this site, it will throw the IdUnusedException caught below
                    try {
                        channel = MailArchiveService.getMailArchiveChannel(channelRef);
                    } catch (PermissionException e) {
                        // INDICATES the channel is valid but the user has no permission to access it
                        // This generally should not happen because the current user should be the postmaster
                        M_log.warn(
                                "mailarchive failure: message processing cancelled: PermissionException with channelRef ("
                                        + channelRef
                                        + ") - user not allowed to get this mail archive channel: (id=" + id
                                        + ") (mailId=" + mailId + ") (user="
                                        + sessionManager.getCurrentSessionUserId() + ") (session="
                                        + sessionManager.getCurrentSession().getId() + "): " + e,
                                e);
                        // BOUNCE REPLY - send a message back to the user to let them know their email failed
                        String errMsg = rb.getString("err_not_member") + "\n\n";
                        String mailSupport = StringUtils
                                .trimToNull(serverConfigurationService.getString("mail.support"));
                        if (mailSupport != null) {
                            errMsg += (String) rb.getFormattedMessage("err_questions",
                                    new Object[] { mailSupport }) + "\n";
                        }
                        mail.setErrorMessage(errMsg);
                        mail.setState(userNotAllowedToPostProcessor);
                        continue;
                    }
                    if (M_log.isDebugEnabled()) {
                        M_log.debug("Incoming message mailId (" + mailId + ") IS a valid channel (" + channelRef
                                + "), found channel: " + channel);
                    }
                }
                if (channel == null) {
                    if (M_log.isDebugEnabled()) {
                        M_log.debug("Incoming message mailId (" + mailId + "), channelRef (" + channelRef
                                + ") could not be resolved and is null: " + channel);
                    }
                    // this should never happen but it is here just in case
                    throw new IdUnusedException(mailId);
                }

                // skip disabled channels
                if (!channel.getEnabled()) {
                    // INDICATES that the channel is NOT currently enabled so no messages can be received
                    if (from.startsWith(POSTMASTER)) {
                        mail.setState(Mail.GHOST);
                    } else {
                        // BOUNCE REPLY - send a message back to the user to let them know their email failed
                        String errMsg = rb.getString("err_email_off") + "\n\n";
                        String mailSupport = StringUtils
                                .trimToNull(serverConfigurationService.getString("mail.support"));
                        if (mailSupport != null) {
                            errMsg += (String) rb.getFormattedMessage("err_questions",
                                    new Object[] { mailSupport }) + "\n";
                        }
                        mail.setErrorMessage(errMsg);
                        mail.setState(courseMailArchiveDisabledProcessor);
                    }

                    if (M_log.isInfoEnabled()) {
                        M_log.info(
                                id + " : mail rejected: channel (" + channelRef + ") not enabled: " + mailId);
                    }
                    continue;
                }

                // for non-open channels, make sure the from is a member
                if (!channel.getOpen()) {
                    // see if our fromAddr is the email address of any of the users who are permitted to add messages to the channel.
                    if (!fromValidUser(fromAddr, channel)) {
                        // INDICATES user is not allowed to send messages to this group
                        if (M_log.isInfoEnabled()) {
                            M_log.info(id + " : mail rejected: from: " + fromAddr + " not authorized for site: "
                                    + mailId + " and channel (" + channelRef + ")");
                        }
                        // BOUNCE REPLY - send a message back to the user to let them know their email failed
                        String errMsg = rb.getString("err_not_member") + "\n\n";
                        String mailSupport = StringUtils
                                .trimToNull(serverConfigurationService.getString("mail.support"));
                        if (mailSupport != null) {
                            errMsg += (String) rb.getFormattedMessage("err_questions",
                                    new Object[] { mailSupport }) + "\n";
                        }
                        mail.setErrorMessage(errMsg);
                        mail.setState(userNotAllowedToPostProcessor);
                        continue;
                    }
                }

                // prepare the message 
                StringBuilder bodyBuf[] = new StringBuilder[2];
                bodyBuf[0] = new StringBuilder();
                bodyBuf[1] = new StringBuilder();
                List<Reference> attachments = entityManager.newReferenceList();
                String siteId = null;
                if (siteService.siteExists(channel.getContext())) {
                    siteId = channel.getContext();
                }

                try {
                    StringBuilder bodyContentType = new StringBuilder();
                    parseParts(siteId, msg, id, bodyBuf, bodyContentType, attachments, Integer.valueOf(-1));

                    if (bodyContentType.length() > 0) {
                        // save the content type of the message body - which may be different from the
                        // overall MIME type of the message (multipart, etc)
                        mailHeaders.add(MailArchiveService.HEADER_INNER_CONTENT_TYPE + ": " + bodyContentType);
                    }
                } catch (MessagingException e) {
                    // NOTE: if this happens it just means we don't get the extra header, not the end of the world
                    //e.printStackTrace();
                    M_log.warn("MessagingException: service(): msg.getContent() threw: " + e, e);
                } catch (IOException e) {
                    // NOTE: if this happens it just means we don't get the extra header, not the end of the world
                    //e.printStackTrace();
                    M_log.warn("IOException: service(): msg.getContent() threw: " + e, e);
                }

                mailHeaders.add("List-Id: <" + channel.getId() + "." + channel.getContext() + "."
                        + serverConfigurationService.getServerName() + ">");

                // post the message to the group's channel
                String body[] = new String[2];
                body[0] = bodyBuf[0].toString(); // plain/text
                body[1] = bodyBuf[1].toString(); // html/text

                try {
                    if (channel.getReplyToList()) {
                        List<String> modifiedHeaders = new Vector<String>();
                        for (String header : (List<String>) mailHeaders) {
                            if (header != null && !header.startsWith("Reply-To:")) {
                                modifiedHeaders.add(header);
                            }
                        }
                        // Note: can't use recipient, since it's host may be configured as mailId@myhost.james
                        String mailHost = serverConfigurationService.getServerName();
                        if (mailHost == null || mailHost.trim().equals(""))
                            mailHost = mail.getRemoteHost();

                        MailAddress replyTo = new MailAddress(mailId, mailHost);
                        if (M_log.isDebugEnabled()) {
                            M_log.debug("Set Reply-To address to " + replyTo.toString());
                        }
                        modifiedHeaders.add("Reply-To: " + replyTo.toString());

                        // post the message to the group's channel
                        channel.addMailArchiveMessage(subject, from.toString(),
                                timeService.newTime(sent.getTime()), modifiedHeaders, attachments, body);
                    } else {
                        // post the message to the group's channel
                        channel.addMailArchiveMessage(subject, from.toString(),
                                timeService.newTime(sent.getTime()), mailHeaders, attachments, body);
                    }
                } catch (PermissionException pe) {
                    // INDICATES that the current user does not have permission to add or get the mail archive message from the current channel
                    // This generally should not happen because the current user should be the postmaster
                    M_log.warn("mailarchive PermissionException message service failure: (id=" + id
                            + ") (mailId=" + mailId + ") : " + pe, pe);
                    mail.setState(Mail.GHOST); // ghost out the message because this should not happen
                }

                if (M_log.isDebugEnabled()) {
                    M_log.debug(id + " : delivered to:" + mailId);
                }

                // all is happy - ghost the message to stop further processing
                mail.setState(Mail.GHOST);
            } catch (IdUnusedException goOn) {
                // INDICATES that the channelReference found above was actually invalid OR that no channel reference could be identified

                // if this is to the postmaster, and there's no site, channel or alias for the postmaster, then quietly eat the message
                if (POSTMASTER.equals(mailId) || from.startsWith(POSTMASTER + "@")) {
                    mail.setState(Mail.GHOST);
                    continue;
                }

                // BOUNCE REPLY - send a message back to the user to let them know their email failed
                if (M_log.isInfoEnabled()) {
                    M_log.info("mailarchive invalid or unusable channel reference (" + mailId + "): " + id
                            + " : mail rejected: " + goOn.toString());
                }
                String errMsg = rb.getString("err_addr_unknown") + "\n\n";
                String mailSupport = StringUtils
                        .trimToNull(serverConfigurationService.getString("mail.support"));
                if (mailSupport != null) {
                    errMsg += (String) rb.getFormattedMessage("err_questions", new Object[] { mailSupport })
                            + "\n";
                }
                mail.setErrorMessage(errMsg);
                mail.setState(courseMailArchiveNotExistsProcessor);
            } catch (Exception ex) {
                // INDICATES that some general exception has occurred which we did not expect
                // This definitely should NOT happen
                M_log.error("mailarchive General message service exception: (id=" + id + ") (mailId=" + mailId
                        + ") : " + ex, ex);
                mail.setState(Mail.GHOST); // ghost the message to stop it from being further processed
            }
        }
    } finally {
        // clear out any current current bindings
        threadLocalManager.clear();
    }
}

From source file:cn.sinobest.jzpt.framework.utils.string.StringUtils.java

/**
 * Determines whether or not the string 'searchIn' contains the string
 * 'searchFor', dis-regarding case starting at 'startAt' Shorthand for a
 * String.regionMatch(...)//from w w  w  .  j  a  va2  s.co  m
 *
 * @param searchIn
 *            the string to search in
 * @param startAt
 *            the position to start at
 * @param searchFor
 *            the string to search for
 *
 * @return whether searchIn starts with searchFor, ignoring case
 */
public static boolean startsWithIgnoreCase(String searchIn, int startAt, String searchFor) {
    return searchIn.regionMatches(true, startAt, searchFor, 0, searchFor.length());
}

From source file:org.globus.myproxy.MyProxy.java

private boolean matches(String line, int pos, String arg) {
    return line.regionMatches(true, pos - arg.length(), arg, 0, arg.length());
}

From source file:FilenameUtils.java

/**
 * Checks if one string starts with another using the case-sensitivity rule.
 * <p>/*from   w w w .j  av  a  2s. c  o  m*/
 * This method mimics {@link String#startsWith(String)} but takes case-sensitivity
 * into account.
 * 
 * @param str  the string to check, not null
 * @param start  the start to compare against, not null
 * @return true if equal using the case rules
 * @throws NullPointerException if either string is null
 */
public boolean checkStartsWith(String str, String start) {
    return str.regionMatches(!sensitive, 0, start, 0, start.length());
}

From source file:FilenameUtils.java

/**
 * Checks if one string contains another at a specific index using the case-sensitivity rule.
 * <p>//  w w w.j  av  a  2  s.c o m
 * This method mimics parts of {@link String#regionMatches(boolean, int, String, int, int)} 
 * but takes case-sensitivity into account.
 * 
 * @param str  the string to check, not null
 * @param strStartIndex  the index to start at in str
 * @param search  the start to search for, not null
 * @return true if equal using the case rules
 * @throws NullPointerException if either string is null
 */
public boolean checkRegionMatches(String str, int strStartIndex, String search) {
    return str.regionMatches(!sensitive, strStartIndex, search, 0, search.length());
}