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.nagarro.core.util.ws.impl.AddonAwareMessageSource.java

public AddonAwareMessageSource() {
    this.scanForAddons = true;
    this.dirFilter = n -> {
        final String base = StringUtils.substringAfterLast(n, baseAddonDir.getPathWithinContext());
        return StringUtils.contains(base, File.separator);
    };//from   www  .  j a va  2s . c  o m
    this.fileFilter = n -> StringUtils.endsWithIgnoreCase(n, "xml")
            || StringUtils.endsWithIgnoreCase(n, "properties");
}

From source file:com.onehippo.gogreen.components.ComponentUtil.java

public static void doRedirectionOnWrongLandingMount(HstRequest request, HstResponse response) {
    HstRequestContext requestContext = request.getRequestContext();

    if (requestContext.getAttribute(REDIRECTION_ON_WRONG_LANDING_MOUNT_DONE_ATTR) != null) {
        return;// ww w  .ja v  a2s .  co  m
    }

    requestContext.setAttribute(REDIRECTION_ON_WRONG_LANDING_MOUNT_DONE_ATTR, Boolean.TRUE);

    boolean isMobileUserAgent = UserAgentUtils.isMobile(request);
    ResolvedMount resolvedMount = requestContext.getResolvedMount();
    boolean isMountForMobile = resolvedMount.getMount().isOfType(DEFAULT_MOUNT_TYPE_MOBILE);

    if (!isMountForMobile) {
        for (String type : resolvedMount.getMount().getTypes()) {
            if (StringUtils.contains(type, DEFAULT_MOUNT_TYPE_MOBILE)) {
                isMountForMobile = true;
                break;
            }
        }
    }

    if (isMobileUserAgent && !isMountForMobile) {
        if (log.isDebugEnabled()) {
            log.debug("Redirecting to mobile mount for User-Agent: '{}'.", request.getHeader("User-Agent"));
        }
        sendRedirectToMount(request, response, DEFAULT_MOUNT_ALIAS_MOBILE);
    }
}

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

@Override
public String convertFromText(String value, Class<?> targetType, String optionContext) {
    if (LogUtil.getCoreLog().isDebugEnabled())
        LogUtil.getCoreLog().debug("JobIdConverter->convertFromText" + value);
    if ((String.class.equals(targetType)) && (StringUtils.contains(optionContext, "param.context.job.id"))) {
        //???Long,?,??
        String arr[] = value.split("_");
        if (arr.length == 3) {
            String idstr = arr[1];
            return idstr;
        }//from   w w  w  . ja va  2 s  .c  o m
        //
        else if (arr.length == 1) {
            return value;
        } else {
            LogUtil.getCoreLog().error("error input :" + value + " must Long or get by TAB completion");
            return "0";
        }
    } else {
        return value;
    }
}

From source file:info.magnolia.cms.beans.runtime.MultipartForm.java

public void addDocument(String atomName, String fileName, String type, File file) {
    if (StringUtils.isEmpty(fileName)) {
        return;/*from   w ww.ja v a 2 s . c om*/
    }
    Document document = new Document();
    document.setAtomName(atomName);
    document.setType(type);
    document.setFile(file);
    if (!StringUtils.contains(fileName, ".")) { //$NON-NLS-1$
        document.setExtention(StringUtils.EMPTY);
        document.setFileName(fileName);
    } else {
        document.setExtention(StringUtils.substringAfterLast(fileName, ".")); //$NON-NLS-1$
        document.setFileName(StringUtils.substringBeforeLast(fileName, ".")); //$NON-NLS-1$
    }
    this.documents.put(atomName, document);
}

From source file:hydrograph.ui.expression.editor.datastructure.MethodDetails.java

private void createPlaceHolderFromSource(IMethod iMethod, String className) throws JavaModelException {
    StringBuffer buffer = new StringBuffer(iMethod.getSource());
    int indexOfPlaceHolder = buffer.lastIndexOf("@see");
    if (indexOfPlaceHolder != -1 && iMethod.getParameterNames() != null
            && iMethod.getParameterNames().length > 0) {
        buffer = buffer.delete(0, indexOfPlaceHolder + 4);
        buffer = buffer.delete(buffer.indexOf("\n") + 1, buffer.capacity());
        if (StringUtils.contains(buffer.toString(), className + Constants.DOT + iMethod.getElementName())) {
            placeHolder = StringUtils.trim(buffer.toString());
        } else//from  ww  w.j  av a  2  s .  co m
            placeHolder = createDefaultPlaceHolder(iMethod, className);
    } else {
        placeHolder = createDefaultPlaceHolder(iMethod, className);
    }
}

From source file:edu.ku.brc.specify.toycode.mexconabio.AgentNames.java

private void parseForFirstLastName(final String str) {
    if (StringUtils.contains(str, ',')) {
        String[] toks = StringUtils.split(str, ',');
        String lastName = toks[0].trim();
        String first = "";
        if (toks.length > 1) {
            first = toks[1].trim();//w  w w .j a va2 s  .  co m
            //if (StringUtils.contains(first, '.'))
        }
        System.out.println(
                "    [" + first + "][" + lastName + "] " + (StringUtils.contains(first, '.') ? "*" : ""));
    } else {
        System.out.println("    [" + str.trim() + "]");
    }
}

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

@Override
protected Navigation setUp() {
    domain = asString("domain");
    UserService us = UserServiceFactory.getUserService();
    currentUser = us.getCurrentUser();//from   ww  w .  j  a  v  a2  s.  c  om
    if (currentUser == null) {
        if (StringUtils.isEmpty(domain)) {
            return redirect(Configuration.get().getMarketplaceListingUrl());
        }
        // 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));
    } else {
        if (StringUtils.isEmpty(domain)) {
            String id = currentUser.getFederatedIdentity();
            int beginIndex = id.indexOf("://") + "://".length();
            int endIndex = id.indexOf('/', beginIndex);
            domain = id.substring(beginIndex, endIndex);
        } else if (StringUtils.contains(currentUser.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:com.ms.commons.standalone.pojo.StandaloneJob.java

/**
 * fullClassName conf????job/*from w  w  w  .j ava  2  s . c  o m*/
 */
private synchronized void modifyDataSourceProperties(String fullClassName, String identity,
        String baseStandalonePath) throws Exception {
    if (StringUtils.contains(fullClassName, "msun")) {
        String filePath = baseStandalonePath + "/conf/msun.datasource.properties";
        String tmpFile = filePath + ".tmp";
        File file = new File(filePath);
        File tmp = new File(tmpFile);
        tmp.createNewFile();
        if (file.exists()) {
            BufferedReader buffRead = new BufferedReader(new FileReader(file));
            BufferedWriter write = new BufferedWriter(new FileWriter(tmp));
            String content = null;
            while ((content = buffRead.readLine()) != null) {
                if (StringUtils.contains(content, "nisa.client.appname")) {
                    content = "nisa.client.appname=" + identity;
                }
                write.write(content);
                write.newLine();
            }
            write.close();
            buffRead.close();
        }
        tmp.renameTo(file);
    }
}

From source file:com.kinglcc.spring.jms.core.listener.DynamicJmsListenerContainerFactory.java

private String resolveClientId(JmsListenerEndpoint endpoint) {
    if (StringUtils.contains(endpoint.getId(), DEFAULT_ENDPOITID)) {
        return clientIdGenerator.generateId();
    }/* w  ww .  j  a v  a2 s . c o m*/
    return clientIdGenerator.generateId(endpoint.getId());
}

From source file:com.safetys.framework.jmesa.core.filter.DateTimeFilterMatcher.java

@Override
public boolean evaluate(Object itemValue, String filterValue) {
    if (itemValue == null) {
        return false;
    }//from   w w w  . j  ava 2  s  .com

    String pattern = getPattern();
    if (pattern == null) {
        logger.debug("The filter (value " + filterValue + ") is trying to match against a date column using "
                + "the DateTimeFilterMatcher, but there is no pattern defined. You need to register a "
                + "DateTimeFilterMatcher to be able to filter against this column.");
        return false;
    }

    Locale locale = null;

    WebContext webContext = getWebContext();
    if (webContext != null) {
        locale = webContext.getLocale();
    }

    DateTime dateTime = (DateTime) itemValue;
    if (locale != null) {
        itemValue = dateTime.toString(pattern, locale);
    } else {
        itemValue = dateTime.toString(pattern);
    }

    String item = String.valueOf(itemValue);
    String filter = String.valueOf(filterValue);
    if (StringUtils.contains(item, filter)) {
        return true;
    }

    return false;
}