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

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

Introduction

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

Prototype

public static int indexOfAny(String str, String[] searchStrs) 

Source Link

Document

Find the first index of any of a set of potential substrings.

Usage

From source file:org.kuali.ole.select.lookup.DocLookupServiceImpl.java

@Override
public boolean allPrimaryKeyValuesPresentAndNotWildcard(Class boClass, Map formProps) {
    List pkFields = KNSServiceLocator.getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(boClass);
    Iterator pkIter = pkFields.iterator();
    boolean returnVal = true;
    while (returnVal && pkIter.hasNext()) {
        String pkName = (String) pkIter.next();
        String pkValue = (String) formProps.get(pkName);

        if (StringUtils.isBlank(pkValue)) {
            returnVal = false;/*from   www  .  j  a  v  a  2  s. com*/
        } else if (StringUtils.indexOfAny(pkValue,
                SearchOperator.QUERY_CHARACTERS.toArray().toString()) != -1) {
            returnVal = false;
        }
    }
    return returnVal;
}

From source file:org.nuclos.common.collect.collectable.searchcondition.CollectableLikeCondition.java

/**
 * @param sLikeComparand//from w  ww  .  j a v  a  2 s  .  c o  m
 * @return Does the given text contain any of the valid wildcards?
 */
public static boolean containsWildcard(String sLikeComparand) {
    return StringUtils.indexOfAny(sLikeComparand, new char[] { '%', '_', '*', '?' }) >= 0;
}

From source file:org.pentaho.di.trans.steps.annotation.BaseAnnotationMeta.java

public void checkValidName(final String name) throws KettleException {
    // potentially problematic characters in filesystem/repository metastores
    char[] fileSystemReservedChars = new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|', '\t', '\r',
            '\n' };
    if (StringUtils.isBlank(name)) {
        throw new KettleException(BaseMessages.getString(PKG,
                isSharedDimension() ? "ModelAnnotation.SharedDimensionMissingName.Message"
                        : "ModelAnnotation.ModelAnnotationGroupMissingName.Message"));
    }//  ww  w.  j  av  a 2  s . c  om
    if (StringUtils.indexOfAny(name, fileSystemReservedChars) >= 0 || StringUtils.startsWith(name, ".")) {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (char ch : fileSystemReservedChars) {
            if (first) {
                first = false;
            } else {
                sb.append(" ");
            }
            if (Character.isWhitespace(ch)) {
                sb.append(StringEscapeUtils.escapeJava(Character.toString(ch)));
            } else {
                sb.append(ch);
            }
        }
        throw new KettleException(BaseMessages.getString(PKG,
                isSharedDimension() ? "ModelAnnotation.MetaStoreInvalidName.SharedDimension.Message"
                        : "ModelAnnotation.MetaStoreInvalidName.Message",
                sb.toString()));
    }
}

From source file:org.polymap.core.data.feature.lucene.QueryFieldSelector.java

public FieldSelectorResult accept(String fieldName) {
    FieldSelectorResult result = FieldSelectorResult.NO_LOAD;
    if (propNames == null) {
        result = FieldSelectorResult.LOAD;
    } else if (StringUtils.indexOfAny(fieldName, propNames) == 0) {
        result = FieldSelectorResult.LOAD;
    }/*from  w  w  w .ja v  a  2  s. c  om*/
    return result;
}

From source file:org.sakaiproject.lti.impl.ExporterCSV.java

private String escapeText(String text) {
    if (text == null)
        return "";

    if (text.contains("\""))
        text = text.replace("\"", "\"\"");
    if (StringUtils.indexOfAny(text, new String[] { "\"", "\n", "\r", csvSeparator }) > -1)
        text = '"' + text + '"';

    return text;/*  w  w  w  . jav a2s .c om*/
}

From source file:org.skb.util.io.dirwalker.FindPackageDirectories.java

protected boolean handleDirectory(File directory, int depth, Collection results) {
    String fn = new String();
    try {//from www. j ava  2s  .c om
        fn = FilenameUtils.separatorsToUnix(directory.getCanonicalPath());
    } catch (Exception e) {
        System.err.println(e);
    }
    if (StringUtils.indexOfAny(fn, new String[] { "/core", "/dist", "/" + this.site_id }) != -1)
        results.add(fn);
    return true;
}

From source file:pt.ist.bennu.core.presentationTier.actions.ConfigurationAction.java

public ActionForward viewSystemConfig(final ActionMapping mapping, final ActionForm form,
        final HttpServletRequest request, final HttpServletResponse response) {

    ArrayList<String> modulesList = new ArrayList<String>();
    for (Project artifact : FenixFramework.getProject().getProjects()) {
        modulesList.add(artifact.getName());
    }/*from  w  w w. j a  v  a  2 s. c o m*/
    //       Properties projectProperties = new Properties();
    //       projectProperties.load(getClass().getResourceAsStream(propertiesLocation));

    //       final String[] modules = projectProperties.getProperty("depends").split(",");
    final String[] modules = modulesList.toArray(new String[0]);

    File[] listModulesFiles = new File(request.getServletContext().getRealPath("/WEB-INF/lib"))
            .listFiles(new FilenameFilter() {

                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith("jar") && StringUtils.indexOfAny(name, modules) >= 0;
                }
            });

    List<File> modulesFileList = new ArrayList<File>(Arrays.asList(listModulesFiles));

    File[] listFiles = new File(request.getServletContext().getRealPath("/WEB-INF/lib"))
            .listFiles(new FilenameFilter() {

                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith("jar");
                }
            });

    List<File> listFilesList = new ArrayList<File>(Arrays.asList(listFiles));
    listFilesList.removeAll(modulesFileList);

    Collections.sort(modulesFileList);
    Collections.sort(listFilesList);

    setAttribute(request, "AllOtherJars", listFilesList);
    setAttribute(request, "AllModuleJars", modulesFileList);
    return getContext(request).forward("/bennu-core/systemInfo.jsp");
}

From source file:raptor.connector.ics.bughouse.BugWhoPParser.java

private Bugger parseBugger(RaptorStringTokenizer tok) {
    Bugger bugger = new Bugger();
    String rating = tok.nextToken();
    int specialCharIndex = StringUtils.indexOfAny(rating, new char[] { '^', '~', ':', '#', '.', '&' });
    if (specialCharIndex != -1) {
        // This is the case where everything runs together.
        bugger.setRating(rating.substring(0, specialCharIndex));
        bugger.setStatus(IcsUtils.getBuggserStatus(rating.substring(specialCharIndex, specialCharIndex + 1)));
        bugger.setName(IcsUtils.stripTitles(rating.substring(specialCharIndex + 1, rating.length())));
    } else {//  ww  w .  j  av  a  2  s.c  o  m
        // This is the case where status could be the first char of the
        // name.
        bugger.setRating(rating);
        String name = tok.nextToken();
        specialCharIndex = StringUtils.indexOfAny(name, new char[] { '^', '~', ':', '#', '.', '&' });
        if (specialCharIndex != -1) {
            bugger.setStatus(IcsUtils.getBuggserStatus(name.substring(0, 1)));
            bugger.setName(IcsUtils.stripTitles(name.substring(1, name.length())));
        } else {
            bugger.setStatus(BuggerStatus.Available);
            bugger.setName(IcsUtils.stripTitles(name));

        }
    }
    return bugger;
}

From source file:raptor.connector.ics.bughouse.BugWhoUParser.java

public Bugger[] process(String message) {
    if (StringUtils.isBlank(message)) {
        return new Bugger[0];
    }/*from   ww  w .j a  va2s. co m*/
    RaptorStringTokenizer tok = new RaptorStringTokenizer(message, " \n", true);
    List<Bugger> result = new ArrayList<Bugger>(30);
    while (tok.hasMoreTokens()) {
        Bugger bugger = new Bugger();
        String rating = tok.nextToken();
        int specialCharIndex = StringUtils.indexOfAny(rating, new char[] { '^', '~', ':', '#', '.', '&' });
        if (specialCharIndex != -1) {
            // This is the case where everything runs together.
            bugger.setRating(rating.substring(0, specialCharIndex));
            bugger.setStatus(
                    IcsUtils.getBuggserStatus(rating.substring(specialCharIndex, specialCharIndex + 1)));
            bugger.setName(IcsUtils.stripTitles(rating.substring(specialCharIndex + 1, rating.length())));
        } else {
            // This is the case where status could be the first char of the
            // name.
            bugger.setRating(rating);
            String name = tok.nextToken();
            specialCharIndex = StringUtils.indexOfAny(name, new char[] { '^', '~', ':', '#', '.', '&' });
            if (specialCharIndex != -1) {
                bugger.setStatus(IcsUtils.getBuggserStatus(name.substring(0, 1)));
                bugger.setName(IcsUtils.stripTitles(name.substring(1, name.length())));
            } else {
                bugger.setStatus(BuggerStatus.Available);
                bugger.setName(IcsUtils.stripTitles(name));

            }
        }

        result.add(bugger);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("processed buggers = " + result);
    }
    return result.toArray(new Bugger[0]);
}

From source file:uk.ac.ebi.embl.api.validation.check.genomeassembly.ChromosomeFieldandValueCheck.java

public ValidationResult check(GenomeAssemblyRecord chromosomeRecord) {
    result = new ValidationResult();

    if (chromosomeRecord == null) {
        return result;
    }/*from   w w w  .ja  v a2s . co m*/
    @SuppressWarnings("unchecked")
    ArrayList<ChromosomeDataRow> rows = (ArrayList<ChromosomeDataRow>) chromosomeRecord.getFields();

    for (DataRow dataRow : locationSet.getRows()) {
        String location = Utils.parseTSVString(dataRow.getString(0));
        locations.add(location);
    }
    for (ChromosomeDataRow row : rows) {

        object_name = row.get_object_name();
        chromosome_name = row.get_chromosome_name();
        type = row.get_type();
        location = row.get_location();
        if (!row.isValid()) {
            reportError(row.getOrigin(), INVALID_ROW_ID);
            continue;
        }
        if (object_name == null || chromosome_name == null || type == null) {
            reportError(row.getOrigin(), MISSING_MANDATORY_ID);
        }

        if (object_name != null && object_name.split(" ").length > 1) {
            reportError(row.getOrigin(), INVALID_VALUE_ID, ChromosomeRecord.OBJECT_NAME_KEYWORD, object_name);
        }
        if (chromosome_name != null && StringUtils.indexOfAny(chromosome_name.toLowerCase(),
                ChromosomeRecord.INVALID_CHNAME_VALUES) != -1) {
            reportError(row.getOrigin(), INVALID_VALUE_ID, ChromosomeRecord.CHROMOSOME_NAME_KEYWORD,
                    chromosome_name);
        }
        if (type != null
                && StringUtils.indexOfAny(type.toLowerCase(), ChromosomeRecord.VALID_TYPE_VALUE) == -1) {
            reportError(row.getOrigin(), INVALID_VALUE_ID, ChromosomeRecord.TYPE_KEYWORD, type);
        }

        if (location != null && !ArrayUtils.contains(locations.toArray(), location.toLowerCase())) {
            reportError(row.getOrigin(), INVALID_VALUE_ID, ChromosomeRecord.LOCATION_KEYWORD, location);
        }
    }
    return result;
}