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.iggroup.oss.restdoclet.doclet.util.DocTypeUtils.java

/**
 * Return a string array of deprecated URIs for this element, searching for
 * DEPRECATED_TAG in the method comment/*from w w  w.  j  a  va  2 s.  co m*/
 * 
 * @param element javadoc element
 * @return a string array of deprecated URIs for this element
 */
public static String[] getDeprecatedURIs(final ProgramElementDoc element) {
    String[] uris = null;

    Tag[] tags = element.tags();

    for (final Tag tag : tags) {
        final String name = tag.name();
        if (StringUtils.contains(name, DEPRECATED_TAG)) {
            uris = parseMultiUri(tag.text());
            LOG.debug("deprecated uris" + tag.text());
            break;
        }
    }

    return uris;
}

From source file:net.librec.util.DriverClassUtil.java

/**
 * get Class by driver name.//from w  ww  .jav a  2s.c o m
 *
 * @param driver driver name
 * @return  Class object
 * @throws ClassNotFoundException  if can't find the Class
 */
public static Class<?> getClass(String driver) throws ClassNotFoundException {
    if (StringUtils.isBlank(driver)) {
        return null;
    } else if (StringUtils.contains(driver, ".")) {
        return Class.forName(driver);
    } else {
        String fullName = driverClassBiMap.get(driver);
        return Class.forName(fullName);
    }
}

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

public boolean supports(Class<?> type, String optionContext) {
    return (String.class.equals(type)) && (StringUtils.contains(optionContext, "param.context.service.name"));
}

From source file:com.enonic.cms.core.search.query.QueryValue.java

boolean isWildcardValue() {
    return StringUtils.contains(this.stringValue, "%");
}

From source file:edu.jhu.pha.vospace.node.VospaceId.java

public VospaceId(String idStr) throws URISyntaxException {
    URI voURI = new URI(idStr);

    if (!validId(voURI)) {
        throw new URISyntaxException(idStr, "InvalidURI");
    }//w  w w . j av  a 2 s .  com

    if (!StringUtils.contains(idStr, "vospace")) {
        throw new URISyntaxException(idStr, "InvalidURI");
    }

    this.uri = StringUtils.substringBetween(idStr, "vos://", "!vospace");

    if (this.uri == null)
        throw new URISyntaxException(idStr, "InvalidURI");

    try {
        String pathStr = URLDecoder.decode(StringUtils.substringAfter(idStr, "!vospace"), "UTF-8");
        this.nodePath = new NodePath(pathStr);
    } catch (UnsupportedEncodingException e) {
        // should not happen
        logger.error(e.getMessage());
    }

}

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

/**
 * Distributes the tweets to all target accounts.
 *
 * @return//from  w ww  . java 2  s.c  o m
 * @throws TwitterException
 */
public int distribute() throws TwitterException {
    if (!getConfig().isDistributorConfigValid()) {
        return Integer.MIN_VALUE;
    }
    Twitter twitter = getTwitter();
    String search = buildSearchString();
    Query query = new Query(search);
    QueryResult result = twitter.search(query);
    int count = 0;
    // Iterate through results
    for (Tweet tweet : result.getTweets()) {
        // Check if already distributed
        if (!distributedTweets.contains(tweet.getId())
                && StringUtils.contains(tweet.getText(), getConfig().getDistributorConfig().getHashtag())) {
            // Retweet each result to all targetaccounts
            for (String targetaccount : getConfig().getDistributorConfig().getTargetaccounts()) {
                // Dont distribute to yourself
                if (!StringUtils.equalsIgnoreCase(tweet.getFromUser(), targetaccount)) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("@");
                    sb.append(targetaccount);
                    sb.append(": RT @");
                    sb.append(tweet.getFromUser());
                    sb.append(" ");
                    sb.append(tweet.getText());
                    String text = sb.toString();
                    // try to tweet, might cause an exception (status duplicate) if already tweeted
                    logger.debug("Distributing tweet {} to {}", tweet.toString(), targetaccount);
                    try {
                        twitter.updateStatus(text.length() < 140 ? text : text.substring(0, 140));
                        count++;
                    } catch (TwitterException te) {
                        logger.warn("distribute of tweet " + tweet.toString() + "failed " + text, te);
                    }
                    distributedTweets.add(tweet.getId());
                }
            }
        }
    }
    return count;
}

From source file:com.glaf.core.test.MongoDBGridFSThread.java

public void run() {
    if (file.exists() && file.isFile()) {
        String path = file.getAbsolutePath();
        path = path.replace('\\', '/');
        if (StringUtils.contains(path, "/temp/") || StringUtils.contains(path, "/tmp/")
                || StringUtils.contains(path, "/logs/") || StringUtils.contains(path, "/work/")
                || StringUtils.endsWith(path, ".log") || StringUtils.endsWith(path, ".class")) {
            return;
        }/*  w  w  w.ja  v  a  2  s .  com*/
        int retry = 0;
        boolean success = false;
        byte[] bytes = null;
        GridFSInputFile inputFile = null;
        while (retry < 1 && !success) {
            try {
                retry++;
                bytes = FileUtils.getBytes(file);
                if (bytes != null) {
                    inputFile = gridFS.createFile(bytes);
                    DBObject metadata = new BasicDBObject();
                    metadata.put("path", path);
                    metadata.put("filename", file.getName());
                    metadata.put("size", bytes.length);
                    inputFile.setMetaData(metadata);
                    inputFile.setId(path);
                    inputFile.setFilename(file.getName());// ??
                    inputFile.save();// ?
                    bytes = null;
                    success = true;
                    logger.debug(file.getAbsolutePath() + " save ok.");
                }
            } catch (Exception ex) {
                logger.error(ex);
                ex.printStackTrace();
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            } finally {
                bytes = null;
                inputFile = null;
            }
        }
    }
}

From source file:com.cloud.utils.log.CglibThrowableRendererTest.java

private boolean isCgLibLogTrace(String s) {
    return StringUtils.contains(s, "net.sf.cglib.proxy");
}

From source file:com.shin1ogawa.appengine.marketplace.controller.ConfigureForAdminController.java

@Override
protected Navigation setUp() {
    domain = asString("domain");
    if (StringUtils.isEmpty(domain)) {
        return redirect(Configuration.get().getMarketplaceListingUrl());
    }//from   w  ww.  j  av a 2 s .c  o m
    UserService us = UserServiceFactory.getUserService();
    if (us.isUserLoggedIn() == false) {
        // if user had not been authenticated then send redirect to login url.
        String callbackURL = request.getRequestURL() + "?domain=" + domain;
        logger.log(Level.INFO, "had not been authenticated: callback=" + callbackURL);
        return redirect(us.createLoginURL(callbackURL, domain,
                "https://www.google.com/accounts/o8/site-xrds?hd=" + domain, null));
    }
    if (StringUtils.contains(us.getCurrentUser().getFederatedIdentity(), domain) == false) {
        // if user had been authenticated but invalid domain then send redirect to logout url.
        String callbackURL = request.getRequestURL() + "?domain=" + domain;
        logger.log(Level.INFO, "invalid domain: callback=" + callbackURL);
        return redirect(us.createLogoutURL(callbackURL, domain));
    }
    delegate = IncreaseURLFetchDeadlineDelegate.install();
    NamespaceManager.set(domain);
    return super.setUp();
}

From source file:gov.nih.nci.cacisweb.action.CdwPermissionAddAction.java

@Override
public String execute() {
    log.debug("execute() - START");
    DAOFactory daoFactory = DAOFactory.getDAOFactory();
    try {//from w  w  w  .ja va  2 s  . c  om
        ICDWUserPermissionDAO cdwUserPermissionDAO = daoFactory.getCDWUserPermissionDAO();
        if (!cdwUserPermissionDAO.isUserExists(getCdwUserBean())) {
            addActionError(getText("cdwUserBean.usernameDoesNotExist"));
            return INPUT;
        }
        if (cdwUserPermissionDAO.addUserPermission(getCdwUserBean(), getCdwPermissionBean())) {
            addActionMessage(getText("cdwUserBean.addPermissionSuccessful"));
        }
        cdwUserBean.setUserPermission(
                (ArrayList<CdwPermissionModel>) cdwUserPermissionDAO.searchUserPermissions(getCdwUserBean()));
        cdwPermissionBean = new CdwPermissionModel();
    } catch (DAOException e) {
        if (StringUtils.contains(e.getMessage(), "Non unique primary key")) {
            addActionMessage(getText("cdwUserBean.permissionAlreadyExists"));
            return INPUT;
        } else {
            addActionError(e.getMessage());
            return ERROR;
        }
    }
    log.debug("execute() - END");
    return INPUT;
}