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.apache.any23.extractor.calendar.BaseCalendarExtractor.java

private static IRI predicate(String originalName, ExtractionResult result) {
    if (originalName.regionMatches(true, 0, "X-", 0, 2)) {
        //non-standard property
        return f.createIRI(ICAL.NS, "x-" + localNameOfProperty(originalName.substring(2)));
    }//from w  w  w  .  ja  v a 2 s .co  m

    String name = localNameOfProperty(originalName);

    try {
        return Objects.requireNonNull(vICAL.getProperty(name));
    } catch (RuntimeException e) {
        IRI iri = f.createIRI(ICAL.NS, name);
        result.notifyIssue(IssueReport.IssueLevel.ERROR,
                "property " + iri + " (" + originalName + ") not defined in " + ICAL.class.getName(), -1, -1);
        return iri;
    }
}

From source file:Main.java

public static boolean containsIgnoreCase(String src, String what) {
    final int length = what.length();
    if (length == 0)
        return true; // Empty string is contained

    final char firstLo = Character.toLowerCase(what.charAt(0));
    final char firstUp = Character.toUpperCase(what.charAt(0));

    for (int i = src.length() - length; i >= 0; i--) {
        // Quick check before calling the more expensive regionMatches() method:
        final char ch = src.charAt(i);
        if (ch != firstLo && ch != firstUp)
            continue;

        if (src.regionMatches(true, i, what, 0, length))
            return true;
    }/*from   w w w. ja va  2 s.com*/

    return false;
}

From source file:com.adguard.commons.lang.StringHelperUtils.java

public static boolean containsIgnoreCase(String where, String what) {
    final int length = what.length();
    if (length == 0)
        return true; // Empty string is contained

    final char firstLo = Character.toLowerCase(what.charAt(0));
    final char firstUp = Character.toUpperCase(what.charAt(0));

    for (int i = where.length() - length; i >= 0; i--) {
        // Quick check before calling the more expensive regionMatches() method:
        final char ch = where.charAt(i);
        if (ch != firstLo && ch != firstUp)
            continue;

        if (where.regionMatches(true, i, what, 0, length))
            return true;
    }//from w ww.j  a  v a2 s  .c om

    return false;
}

From source file:org.apache.poi.util.StringUtil.java

/**
 * Tests if the string starts with the specified prefix, ignoring case consideration.
 *///from  www.j  a  v a 2  s  . c  o  m
public static boolean startsWithIgnoreCase(String haystack, String prefix) {
    return haystack.regionMatches(true, 0, prefix, 0, prefix.length());
}

From source file:org.chromium.chrome.browser.download.DownloadManagerService.java

/**
 * Returns true if the download meant to be treated as an attachment.
 *
 * @param contentDisposition Content disposition of the download.
 * @return true if the downloaded is an attachment, or false otherwise.
 *///w  ww  .j a  va  2  s  . co m
public static boolean isAttachment(String contentDisposition) {
    return contentDisposition != null && contentDisposition.regionMatches(true, 0, "attachment", 0, 10);
}

From source file:org.apache.poi.util.StringUtil.java

/**
 * Tests if the string ends with the specified suffix, ignoring case consideration.
 *//*  www. ja v  a2s  .  c  om*/
public static boolean endsWithIgnoreCase(String haystack, String suffix) {
    int length = suffix.length();
    int start = haystack.length() - length;
    return haystack.regionMatches(true, start, suffix, 0, length);
}

From source file:pt.webdetails.cdf.dd.util.Utils.java

public static IReadAccess getAppropriateReadAccess(String resource, String basePath,
        ICdeEnvironment environment) {/*w ww. j a  v a  2 s .  com*/

    if (StringUtils.isEmpty(resource)) {
        return null;
    }

    IContentAccessFactory factory = environment.getContentAccessFactory();

    String systemDir = environment.getSystemDir() + "/";
    String repoDir = environment.getPluginRepositoryDir() + "/";

    resource = StringUtils.strip(resource, "/");

    if (resource.regionMatches(true, 0, systemDir, 0, systemDir.length())) {

        resource = resource.replaceFirst(systemDir, "");

        String pluginId = environment.getPluginId() + "/";
        // system dir - this plugin
        if (resource.regionMatches(true, 0, pluginId, 0, pluginId.length())) {
            return factory.getPluginSystemReader(basePath);

        } else {
            // system dir - other plugin
            pluginId = resource.substring(0, resource.indexOf("/"));
            return factory.getOtherPluginSystemReader(pluginId, basePath);

        }

    } else if (resource.regionMatches(true, 0, repoDir, 0, repoDir.length())) {

        // plugin repository dir
        return factory.getPluginRepositoryReader(basePath);

    } else {

        // one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
        // or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')

        if (factory.getPluginSystemReader(basePath).fileExists(resource)) {
            return factory.getPluginSystemReader(basePath);
        } else {
            // user solution dir
            return factory.getUserContentAccess(basePath);
        }
    }
}

From source file:pt.webdetails.cdf.dd.util.Utils.java

public static IRWAccess getAppropriateWriteAccess(String resource, String basePath,
        ICdeEnvironment environment) {/*from  ww w .  java2  s .com*/

    if (StringUtils.isEmpty(resource)) {
        return null;
    }

    IContentAccessFactory factory = environment.getContentAccessFactory();

    String systemDir = environment.getSystemDir() + "/";
    String repoDir = environment.getPluginRepositoryDir() + "/";

    resource = StringUtils.strip(resource, "/");

    if (resource.regionMatches(true, 0, systemDir, 0, systemDir.length())) {

        resource = resource.replaceFirst(systemDir, "");

        String pluginId = environment.getPluginId() + "/";
        // system dir - this plugin
        if (resource.regionMatches(true, 0, pluginId, 0, pluginId.length())) {
            return factory.getPluginSystemWriter(basePath);

        } else {
            // system dir - other plugin
            pluginId = resource.substring(0, resource.indexOf("/"));
            return factory.getOtherPluginSystemWriter(pluginId, basePath);

        }

    } else if (resource.regionMatches(true, 0, repoDir, 0, repoDir.length())) {

        // plugin repository dir
        return factory.getPluginRepositoryWriter(basePath);

    } else {

        // one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
        // or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')

        if (factory.getPluginSystemReader(basePath).fileExists(resource)) {
            return factory.getPluginSystemWriter(basePath);
        } else {
            // user solution dir
            return factory.getUserContentAccess(basePath);
        }
    }
}

From source file:pt.webdetails.cdf.dd.util.Utils.java

public static IBasicFile getFileViaAppropriateReadAccess(String resource, String basePath,
        ICdeEnvironment environment) {/*  w w w  .  ja v a2s  . c o m*/
    if (StringUtils.isEmpty(resource)) {
        return null;
    }

    IContentAccessFactory factory = environment.getContentAccessFactory();

    String systemDir = environment.getSystemDir() + "/";
    String repoDir = environment.getPluginRepositoryDir() + "/";

    resource = StringUtils.strip(resource, "/");

    if (resource.regionMatches(true, 0, systemDir, 0, systemDir.length())) {

        resource = resource.replaceFirst(systemDir, "");

        String pluginId = environment.getPluginId() + "/";
        // system dir - this plugin
        if (resource.regionMatches(true, 0, pluginId, 0, pluginId.length())) {

            resource = resource.replaceFirst(pluginId, "");

            return factory.getPluginSystemReader(basePath).fetchFile(resource);

        } else {
            // system dir - other plugin
            pluginId = resource.substring(0, resource.indexOf("/"));
            resource = resource.replaceFirst(pluginId, "");

            return factory.getOtherPluginSystemReader(pluginId, basePath).fetchFile(resource);
        }

    } else if (resource.regionMatches(true, 0, repoDir, 0, repoDir.length())) {

        // plugin repository dir
        resource = resource.replaceFirst(repoDir, "");
        return factory.getPluginRepositoryReader(basePath).fetchFile(resource);

    } else {

        // one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
        // or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')

        if (factory.getPluginSystemReader(basePath).fileExists(resource)) {
            return factory.getPluginSystemReader(basePath).fetchFile(resource);

        } else if (factory.getUserContentAccess(basePath).fileExists(resource)) {
            // user solution dir
            return factory.getUserContentAccess(basePath).fetchFile(resource);
        }
    }
    return null;
}

From source file:org.globus.gatekeeper.jobmanager.AbstractJobManager.java

public static void setGlobusProperties(Map map) {
    String key = null;
    Properties props = System.getProperties();
    Enumeration e = props.keys();
    while (e.hasMoreElements()) {
        key = (String) e.nextElement();
        if (key.regionMatches(true, 0, "GLOBUS", 0, 6)) {
            map.put(key, props.getProperty(key));
        }//ww w .j a v  a 2  s .  c o m
    }
}