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.hangum.tadpole.rdb.core.editors.main.function.MainEditorBrowserFunctionService.java

@Override
protected void f4DMLOpen(Object[] arguments) {
    String strObject = parseLastObject((String) arguments[1]);
    if (StringUtils.contains(strObject, "."))
        strObject = StringUtils.substringAfter(strObject, ".");
    if (logger.isDebugEnabled())
        logger.debug("select editor content is '" + strObject + "'");

    DialogUtil.popupDMLDialog(editor.getUserDB(), strObject);
}

From source file:me.oriley.crate.CrateGenerator.java

private boolean isFileValid(@NonNull File crateOutputFile, @NonNull String[] comments) {
    if (comments.length <= 0) {
        return false;
    }//from ww w  .  j  a  v  a 2s .co  m

    boolean isValid = true;
    try {
        FileReader reader = new FileReader(crateOutputFile);
        BufferedReader input = new BufferedReader(reader);

        for (String comment : comments) {
            String fileLine = input.readLine();
            if (fileLine == null || comment == null || !StringUtils.contains(fileLine, comment)) {
                log("Aborting, comment: " + comment + ", fileLine: " + fileLine);
                isValid = false;
                break;
            } else {
                log("Line valid, comment: " + comment + ", fileLine: " + fileLine);
            }
        }

        input.close();
        reader.close();
    } catch (IOException e) {
        logError("Error parsing file", e, false);
        isValid = false;
    }

    log("File check result -- isValid ? " + isValid);
    return isValid;
}

From source file:com.ctc.storefront.filters.cms.CMSSiteFilter.java

@Override
protected void doFilterInternal(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse,
        final FilterChain filterChain) throws ServletException, IOException {
    final String requestURL = httpRequest.getRequestURL().toString();

    final CmsPageRequestContextData cmsPageRequestContextData = getCmsPageContextService()
            .initialiseCmsPageContextForRequest(httpRequest);

    // check whether exits valid preview data
    if (cmsPageRequestContextData.getPreviewData() == null) {
        // process normal request (i.e. normal browser non-cmscockpit request)
        if (processNormalRequest(httpRequest, httpResponse)) {
            // proceed filters
            filterChain.doFilter(httpRequest, httpResponse);
        }//from   www  .  j  a va 2  s  . co  m
    } else if (StringUtils.contains(requestURL, PREVIEW_TOKEN)) {
        final String redirectURL = processPreviewRequest(httpRequest, cmsPageRequestContextData);

        // redirect to computed URL
        if (redirectURL.charAt(0) == '/') {
            final String contextPath = httpRequest.getContextPath();
            final String encodedRedirectUrl = httpResponse.encodeRedirectURL(contextPath + redirectURL);
            httpResponse.sendRedirect(encodedRedirectUrl);
        } else {
            final String encodedRedirectUrl = httpResponse.encodeRedirectURL(redirectURL);
            httpResponse.sendRedirect(encodedRedirectUrl);
        }

        // next filter in chain won't be invoked!!!
    } else {
        if (httpRequest.getSession().isNew()) {
            processPreviewData(httpRequest, cmsPageRequestContextData.getPreviewData());
        }
        // proceed filters
        filterChain.doFilter(httpRequest, httpResponse);
    }
}

From source file:AIR.Common.Web.FileFtpHandler.java

public static boolean exists(URI requestUri) {
    try {/*from w  w  w.j  av  a  2s  . c  o m*/
        requestUri.toURL().openConnection();
    } catch (MalformedURLException e) {
        throw new FtpResourceException(e);
    } catch (IOException e) {
        final String NON_EXISTENT_MESSAGE = "The system cannot find the file specified";
        if (StringUtils.contains(e.getMessage(), NON_EXISTENT_MESSAGE)) {
            // TODO Shiva this part is highly specific to the ftp server AIR uses on
            // its webservices.
            return false;
        }
        throw new FtpResourceException(e);
    }
    return true;
}

From source file:com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.java

public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
    SMInputCursor testSuite = rootCursor.constructDescendantCursor(new ElementFilter("testsuite"));
    SMEvent testSuiteEvent;/*from   ww w. j av  a 2  s  . c  o m*/
    for (testSuiteEvent = testSuite.getNext(); testSuiteEvent != null; testSuiteEvent = testSuite.getNext()) {
        if (testSuiteEvent.compareTo(SMEvent.START_ELEMENT) == 0) {
            String testSuiteClassName = testSuite.getAttrValue("name");
            if (StringUtils.contains(testSuiteClassName, "$")) {
                // Test suites for inner classes are ignored
                return;
            }
            SMInputCursor testCase = testSuite.childCursor(new ElementFilter("testcase"));
            SMEvent event;
            for (event = testCase.getNext(); event != null; event = testCase.getNext()) {
                if (event.compareTo(SMEvent.START_ELEMENT) == 0) {
                    String testClassName = getClassname(testCase, testSuiteClassName);
                    UnitTestClassReport classReport = index.index(testClassName);
                    parseTestCase(testCase, classReport);
                }
            }
        }
    }
}

From source file:com.edgenius.wiki.render.macro.ImageSliderMacro.java

@Override
protected void replaceHTML(HTMLNode node, ListIterator<HTMLNode> iter, RenderContext context) {
    resetMacroMarkup(TIDY_STYLE_BLOCK, node, iter, getMacroMarkupString(node, "slider"), "{slider}");

    //Reset all notes, keep images, remove JS 
    //<div class=macroSlider> <div class=slider-wrapper><div class=nivoSlider> ( keep these parts as they are suppose to be images ) 
    //</div></div> (delete these part, suppose to be javascript </div>

    HTMLNode pair = node.getPair();/*from  w w  w  .  j a  v a 2  s.  c om*/
    if (pair == null) {
        AuditLogger.error("Slide macro doesn't find paired div");
        return;
    }
    boolean cleanJS = false;
    HTMLNode subnode = node.next();
    while (subnode != null) {
        if (subnode == pair)
            break;
        if (!subnode.isTextNode() && subnode.getAttributes() != null) {
            String clz = subnode.getAttributes().get(NameConstants.CLASS);
            if (StringUtils.contains(clz, "slider-wrapper")) {
                subnode.reset("", true);
                if (subnode.getPair() != null) {
                    subnode.getPair().reset("", true);
                }
            } else if ("nivoSlider".equals(clz)) {
                subnode.reset("", true);
                if (subnode.getPair() != null) {
                    subnode.getPair().reset("", true);
                    cleanJS = true;
                    //jump to this nivoSlider div end, in while() end, it suppose move to slider-wrapper end div.
                    subnode = subnode.getPair();
                }
            }
        }

        if (cleanJS) {
            //clean script tag, and inside text and link tag - but now clean all of them
            // ("script".equals(subnode.getTagName()) || "link".equals(subnode.getTagName()))
            subnode.reset("", true);
            if (subnode.getPair() != null) {
                subnode.getPair().reset("", true);
            }
        }

        subnode = subnode.next();
    }
}

From source file:com.floreantpos.license.FiveStarPOSLicenseManager.java

/**
 * Get the private key file based on command line arguments.
 * /*from w  w  w.j  a  v  a2  s .  c o  m*/
 * @param args
 * @return File
 */
private static File getPrivateKey(String[] args) {
    if (args != null) {
        for (String string : args) {
            if (StringUtils.contains(string, "-p=")) {
                return new File(StringUtils.split(string, "-p=")[1]);
            }
        }
    }
    return new File(PRIVATE_KEY_FILE);
}

From source file:crawl.SphinxWrapper.java

private static boolean containsAnyKeyword(String content, List<String> keywords, boolean caseSensitive) {
    if ((keywords == null) || keywords.isEmpty()) {
        return true;
    }/*from   w  ww  .  j av  a2  s  . c  om*/

    // implied else: test the keywords
    if (caseSensitive) {
        for (String kw : keywords) {
            if (StringUtils.contains(content, kw)) {
                return true;
            }
        }
    }

    else { // case-insensitive
        for (String kw : keywords) {
            if (StringUtils.containsIgnoreCase(content, kw)) {
                return true;
            }
        }
    }

    return false;
}

From source file:edu.ku.brc.specify.toycode.RegAdder.java

/**
 * @param trackItemId/* w w  w . j  a  va 2 s . c o m*/
 * @param value
 * @param pStmt
 */
private void doTrackUpdate(final int trackItemId, final String value, final PreparedStatement pStmt)
        throws SQLException {
    if (!StringUtils.contains(value, ".") && StringUtils.isNumeric(value) && value.length() < 10) {
        pStmt.setInt(1, Integer.parseInt(value));
        pStmt.setNull(2, java.sql.Types.VARCHAR);

    } else if (value.length() < STR_SIZE + 1) {
        pStmt.setNull(1, java.sql.Types.INTEGER);
        pStmt.setString(2, value);

    } else {
        String v = value.substring(0, STR_SIZE);
        System.err.println(
                "Error - On line " + lineNo + " Value[" + value + "] too big trunccating to[" + v + "]");

        pStmt.setNull(1, java.sql.Types.INTEGER);
        pStmt.setString(2, v);
    }
    pStmt.setInt(3, trackItemId);

    int rv = pStmt.executeUpdate();
    if (rv != 1) {
        throw new RuntimeException("Error insert trackitem for Id: " + trackItemId);
    }
}

From source file:gemlite.core.webapp.monitor.AsyncController.java

@RequestMapping(value = "/async/add", method = RequestMethod.POST)
@ResponseBody/*from  w  ww  . j av  a2s .  c  om*/
public boolean saveAsync(HttpServletRequest request) {
    String region = (String) request.getParameter("region");
    String queueId = (String) request.getParameter("queueId");
    boolean persistent = StringUtils.equals((String) request.getParameter("persistent"), "on");
    //      boolean parallel = StringUtils.equals((String)request.getParameter("parallel"),"on");
    String diskStoreName = (String) request.getParameter("diskstorename");
    String driver = (String) request.getParameter("driver");
    String url = (String) request.getParameter("url");
    String user = (String) request.getParameter("user");
    String password = (String) request.getParameter("password");
    String rs = async.addAsync(region, queueId, persistent, diskStoreName, driver, url, user, password);
    if (StringUtils.contains(rs, "successfully"))
        return true;
    return false;
}