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

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

Introduction

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

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:com.glaf.core.util.AnnotationUtils.java

public static Collection<String> findMapper(String packagePrefix) {
    AnnotationDB db = getAnnotationDB(packagePrefix);
    Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
    Set<String> entities = annotationIndex.get("org.springframework.stereotype.Component");
    Collection<String> sortSet = new TreeSet<String>();
    if (entities != null && !entities.isEmpty()) {
        for (String str : entities) {
            if (packagePrefix != null && str.contains(packagePrefix) && StringUtils.contains(str, ".mapper.")) {
                sortSet.add(str);//from   w  w  w  .j av a 2  s  .  com
            }
        }
    }
    return sortSet;
}

From source file:com.haulmont.cuba.web.exception.DefaultExceptionHandler.java

@Override
public boolean handle(ErrorEvent event, App app) {
    // Copied from com.vaadin.server.DefaultErrorHandler.doDefault()

    //noinspection ThrowableResultOfMethodCallIgnored
    Throwable t = event.getThrowable();
    //noinspection ThrowableResultOfMethodCallIgnored
    if (t instanceof SocketException || ExceptionUtils.getRootCause(t) instanceof SocketException) {
        // Most likely client browser closed socket
        return true;
    }//from   ww  w .j a v a2 s .  com

    // Support Tomcat 8 ClientAbortException
    if (StringUtils.contains(ExceptionUtils.getMessage(t), "ClientAbortException")) {
        // Most likely client browser closed socket
        return true;
    }

    AppUI ui = AppUI.getCurrent();
    if (ui == null) {
        // there is no UI, just add error to log
        return true;
    }

    if (t != null) {
        if (app.getConnection().getSession() != null) {
            showDialog(app, t);
        } else {
            showNotification(app, t);
        }
    }

    return true;
}

From source file:io.wcm.tooling.netbeans.sightly.completion.classLookup.RequestAttributeResolver.java

public Set<String> resolve(String filter) {
    Set<String> ret = new LinkedHashSet<>();
    // only display results if filter contains @
    if (!StringUtils.contains(text, "@") || !StringUtils.contains(text, "data-sly-use")) {
        return ret;
    }//from  ww  w  .j a  va 2 s. c o  m
    ElementUtilities.ElementAcceptor acceptor = new ElementUtilities.ElementAcceptor() {
        @Override
        public boolean accept(Element e, TypeMirror type) {
            // we are looking for the annotations
            for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
                if (mirror.getAnnotationType() != null && mirror.getAnnotationType().asElement() != null
                        && StringUtils.equalsIgnoreCase(REQUEST_ATTRIBUTE_CLASSNAME,
                                mirror.getAnnotationType().asElement().toString())) {
                    return true;
                }
            }
            return false;
        }
    };
    String clazz = StringUtils.substringBetween(text, "'");

    Set<Element> elems = getMembersFromJavaSource(clazz, acceptor);
    for (Element elem : elems) {
        if (StringUtils.startsWithIgnoreCase(elem.getSimpleName().toString(), filter)
                && !StringUtils.contains(text, elem.getSimpleName().toString() + " ")
                && !StringUtils.contains(text, elem.getSimpleName().toString() + "=")) {
            ret.add(elem.getSimpleName().toString());
        }
    }
    if (ret.isEmpty()) {
        for (String att : getAttributesFromClassLoader(clazz)) {
            if (StringUtils.startsWithIgnoreCase(att, filter) && !StringUtils.contains(text, att + " ")
                    && !StringUtils.contains(text, att + "=")) {
                ret.add(att);
            }
        }
    }
    return ret;
}

From source file:ch.cyberduck.core.cloud.CloudPath.java

@Override
public boolean isContainer() {
    return !StringUtils.contains(StringUtils.substring(this.getAbsolute(), 1), this.getPathDelimiter());
}

From source file:hydrograph.ui.perspective.dialog.PreStartActivity.java

/**
 * Checks whether tool is launched in development mode.
 * /*from  www.  j  a va  2 s. c o m*/
 * @param argumentsMap
 * @return true if tool is launched in development mode, else returns false
 */
@SuppressWarnings("unchecked")
public static boolean isDevLaunchMode(Map argumentsMap) {
    logger.debug("Checking whether tool is launched in development mode");
    for (Entry<Object, String[]> entry : ((Map<Object, String[]>) argumentsMap).entrySet()) {
        for (String value : entry.getValue()) {
            if (StringUtils.contains(value, DOSGI_REQUIRED_JAVA_VERSION_PARAMETER_IN_INI_FILE)) {
                return false;
            }
        }
    }
    return true;
}

From source file:gemlite.shell.converters.JobIdConverter.java

@Override
public boolean supports(Class<?> type, String optionContext) {
    if (LogUtil.getCoreLog().isDebugEnabled())
        LogUtil.getCoreLog().debug("JobIdConverter->supports?param.context.job.id=>" + optionContext);
    return (String.class.equals(type)) && (StringUtils.contains(optionContext, "param.context.job.id"));
}

From source file:com.htmlhifive.tools.codeassist.core.proposal.checker.ControllerProposalChecker.java

@Override
public boolean existDefaultCodeAssist() {

    if (!StringUtils.contains(getCodeAssistStr(), '.')) {
        return true;
    }//from  w  w w . j av  a2s.co  m
    String str = StringUtils.substringAfterLast(getCodeAssistStr(), ".");
    return getBean().getRegExPattern().matcher(str).matches();
}

From source file:io.wcm.tooling.netbeans.sightly.completion.classLookup.MemberLookupResult.java

/**
 *
 * @param variableName//from   w  w  w  .ja v  a2s  .  c  om
 * @param methodName
 * @param returnType
 */
public MemberLookupResult(String variableName, String methodName, String returnType) {
    this.variableName = variableName;
    this.methodName = methodName;

    //TODO: this is a hack to get support for list, set, map, enumeration, array and collection
    String tmp = returnType;
    if (StringUtils.startsWith(returnType, List.class.getName())
            || StringUtils.startsWith(returnType, Set.class.getName())
            || StringUtils.startsWith(returnType, Map.class.getName())
            || StringUtils.startsWith(returnType, Iterator.class.getName())
            || StringUtils.startsWith(returnType, Enum.class.getName())
            || StringUtils.startsWith(returnType, Collection.class.getName())) {
        while (StringUtils.contains(tmp, "<") && StringUtils.contains(tmp, ">")) {
            tmp = StringUtils.substringBetween(tmp, "<", ">");
        }
        if (StringUtils.contains(tmp, ",")) {
            // we want the first variable
            tmp = StringUtils.substringBefore(tmp, ",");
        }
    } else if (StringUtils.endsWith(returnType, "[]")) {
        tmp = StringUtils.substringBeforeLast(returnType, "[]");
    }

    this.returnType = tmp;
}

From source file:com.wenzani.maven.mongodb.StartMongoDb.java

public void execute() throws MojoExecutionException {
    port = null == port ? "27017" : port;
    try {//from www  . jav a2 s .co  m
        chmodMongoD();
        String executable = String.format("%s --dbpath %s --port %s", getMongoD(), mongoDbDir, port);
        Process process = Runtime.getRuntime().exec(executable);
        BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = input.readLine()) != null) {
            getLog().info("Waiting for MongoDB to start...");
            if (StringUtils.contains(line,
                    String.format("waiting for connections on port %s", port).toString())) {
                getLog().info("MongoDB startup complete.");
                break;
            }
        }
        getLog().info(String.format("Started mongod on port %s", port));

    } catch (IOException e) {
        getLog().error(ExceptionUtils.getFullStackTrace(e));
    } catch (InterruptedException ex) {
        getLog().error(ExceptionUtils.getFullStackTrace(ex));
    }
}

From source file:de.dev.eth0.retweeter.Retweeter.java

/**
 * Performs the retweet-action and returns the number of tweets found with the configured hashtag
 *
 * @return number of retweeted tweets/*  ww w . j a  v  a2  s  . c  o m*/
 * @throws TwitterException
 */
public int retweet() throws TwitterException {
    if (!getConfig().isRetweeterConfigValid()) {
        return Integer.MIN_VALUE;
    }
    Twitter twitter = getTwitter();
    String search = buildSearchString();
    Query query = new Query(search);
    QueryResult result = twitter.search(query);

    List<Status> lastretweets = twitter.getRetweetedByMe();
    int count = 0;
    for (Tweet tweet : result.getTweets()) {
        // ignore retweets and check if the hashtag is really in the tweet's text
        if (!StringUtils.startsWith(tweet.getText(), "RT @")
                && StringUtils.contains(tweet.getText(), getConfig().getRetweeterConfig().getHashtag())
                && !ALREADY_RETWEETED.contains(tweet.getId())) {
            boolean retweeted = false;
            for (Status retweet : lastretweets) {
                if (tweet.getId() == retweet.getRetweetedStatus().getId()) {
                    retweeted = true;
                    break;
                }
            }
            if (!retweeted) {
                // try to retweet, might fail
                logger.debug("found new tweet to retweet: {}", tweet.toString());
                try {
                    twitter.retweetStatus(tweet.getId());
                    count++;
                } catch (TwitterException te) {
                    logger.debug("retweet failed", te);
                } finally {
                    ALREADY_RETWEETED.add(tweet.getId());
                }
            }
        }
    }
    return count;
}