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

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

Introduction

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

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:com.bluexml.xforms.servlets.ReadServlet.java

/**
 * Read./*w  ww.  j a va  2s.  c  o m*/
 * 
 * @param req
 *            the req
 * @param resp
 *            the resp
 * 
 * @throws ServletException
 *             the servlet exception
 */
protected void read(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
    AlfrescoController controller = AlfrescoController.getInstance();
    String dataType = StringUtils.trimToNull(req.getParameter(DATA_TYPE));
    if (dataType != null) {
        dataType = dataType.replace('_', '.');
    }
    String dataId = StringUtils.trimToNull(req.getParameter(DATA_ID));
    dataId = controller.patchDataId(dataId);

    String skipIdStr = StringUtils.trimToNull(req.getParameter(ID_AS_SERVLET));
    boolean idAsServlet = !StringUtils.equals(skipIdStr, "false");

    try {
        String userName = req.getParameter(MsgId.PARAM_USER_NAME.getText());
        AlfrescoTransaction transaction = createTransaction(controller, userName);
        Document node = controller.getMappingAgent().getInstanceClass(transaction, dataType, dataId, false,
                idAsServlet);
        Source xmlSource = new DOMSource(node);
        Result outputTarget = new StreamResult(resp.getOutputStream());
        documentTransformer.transform(xmlSource, outputTarget);
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:net.erdfelt.android.sdkfido.project.JavaPathValidator.java

private void validateJavaPackage(Dir sourceDir, String javapath) throws IOException {
    File javafile = sourceDir.getFile(javapath);
    FileReader reader = null;//from   w  ww  .ja  v  a 2s. com
    BufferedReader buf = null;
    try {
        reader = new FileReader(javafile);
        buf = new BufferedReader(reader);
        String line;
        String actualPackage;
        String expectedPackage = javapath.substring(0, javapath.length() - javafile.getName().length());
        expectedPackage = expectedPackage.replace(File.separatorChar, '.');
        Matcher mat;

        while ((line = buf.readLine()) != null) {
            mat = packagePat.matcher(line);
            if (mat.matches()) {
                actualPackage = mat.group(1);
                if (!StringUtils.equals(actualPackage, expectedPackage)) {
                    LOG.warning("" + javapath + " - NO MATCH TO " + expectedPackage);
                }
            }
        }
    } finally {
        IOUtils.closeQuietly(buf);
        IOUtils.closeQuietly(reader);
    }
}

From source file:it.updateCenter.UpdateCenterTest.java

private Plugin findPlugin(List<Plugin> plugins, String pluginKey) {
    for (Plugin plugin : plugins) {
        if (StringUtils.equals(pluginKey, plugin.getKey())) {
            return plugin;
        }/*from w  ww .  jav a 2s . co m*/
    }
    return null;
}

From source file:com.microsoft.alm.plugin.idea.common.ui.common.LoginPageModelImpl.java

@Override
public void setServerName(final String serverName) {
    if (!StringUtils.equals(this.serverName, serverName)) {
        final String newServerName;
        // Allow just the server name as a short hand
        if (StringUtils.isNotEmpty(serverName) && !StringUtils.contains(serverName, UrlHelper.URL_SEPARATOR)
                && !StringUtils.equals(serverName,
                        TfPluginBundle.message(TfPluginBundle.KEY_USER_ACCOUNT_PANEL_VSO_SERVER_NAME))
                && !StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_VSO)
                && !StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_TFS_ALL_IN)) {
            // no slash, not "Microsoft Account" and does not contain visualstudio.com or tfsallin.net
            // means it must just be a on-premise TFS server name, so add all the normal stuff
            newServerName = String.format(DEFAULT_SERVER_FORMAT, serverName);
        } else if (!StringUtils.contains(serverName, UrlHelper.URL_SEPARATOR)
                && (StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_VSO)
                        || StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_TFS_ALL_IN))) {
            //no slash and contains visualstudio.com or tfsallin.net
            // means it must be a VSTS account
            newServerName = String.format(DEFAULT_VSTS_ACCOUNT_FORMAT, serverName);
        } else {//from w w w.j  av  a  2  s  .  c o  m
            newServerName = serverName;
        }
        setServerNameInternal(newServerName);
    }
}

From source file:com.iyonger.apm.web.service.RegionService.java

/**
 * Verify duplicate region when starting with cluster mode.
 *
 * @since 3.2/*from   ww  w.java2 s  . c om*/
 */
private void verifyDuplicatedRegion() {
    Map<String, RegionInfo> regions = getAll();
    String localRegion = getCurrent();
    RegionInfo regionInfo = regions.get(localRegion);
    if (regionInfo != null && !StringUtils.equals(regionInfo.getIp(), config.getClusterProperties()
            .getProperty(ClusterConstants.PROP_CLUSTER_HOST, NetworkUtils.DEFAULT_LOCAL_HOST_ADDRESS))) {
        throw processException("The region name, " + localRegion + ", is already used by other controller "
                + regionInfo.getIp() + ". Please set the different region name in this controller.");
    }
}

From source file:com.vmware.appfactory.build.model.BuildFile.java

@Override
public int deepCopy(AbstractRecord record) {
    BuildFile other = (BuildFile) record;
    int numChanges = 0;

    if (!StringUtils.equals(getUrl(), other.getUrl())) {
        setUrl(other.getUrl());/*from  ww  w. ja v  a 2s  . c o m*/
        numChanges++;
    }

    if (getSize() != other.getSize()) {
        setSize(other.getSize());
        numChanges++;
    }

    if (!StringUtils.equals(getExeName(), other.getExeName())) {
        setExeName(other.getExeName());
        numChanges++;
    }

    return numChanges;
}

From source file:hudson.plugins.clearcase.history.FieldFilter.java

public boolean accept(String value) {
    switch (type) {
    case Equals:/*from  w  w w  . j  av a  2 s  .c o  m*/
        return StringUtils.equals(value, patternText);
    case EqualsIgnoreCase:
        return StringUtils.equalsIgnoreCase(value, patternText);
    case NotEquals:
        return !StringUtils.equals(value, patternText);
    case NotEqualsIgnoreCase:
        return !StringUtils.equalsIgnoreCase(value, patternText);
    case StartsWith:
        return value != null && value.startsWith(patternText);
    case StartsWithIgnoreCase:
        return value != null && value.toLowerCase().startsWith(patternText);
    case EndsWith:
        return value != null && value.endsWith(patternText);
    case EndsWithIgnoreCase:
        return value != null && value.toLowerCase().endsWith(patternText);
    case Contains:
        return StringUtils.contains(value, patternText);
    case ContainsIgnoreCase:
        return StringUtils.contains(StringUtils.lowerCase(value), patternText);
    case DoesNotContain:
        return !StringUtils.contains(value, patternText);
    case DoesNotContainIgnoreCase:
        LOGGER.fine(StringUtils.lowerCase(value) + " <>" + patternText);
        return !StringUtils.contains(StringUtils.lowerCase(value), patternText);
    case ContainsRegxp:
        Matcher m = pattern.matcher(StringUtils.defaultString(value));
        return m.find();
    case DoesNotContainRegxp:
        Matcher m2 = pattern.matcher(StringUtils.defaultString(value));
        return !m2.find();
    }
    return true;
}

From source file:com.htmlhifive.tools.jslint.actions.ActiveJSLintAction.java

/**
 * ????????.//from  w w  w. j  av  a  2s  .c  o m
 * 
 * @param action 
 */
private void checkAutoBuild(IAction action) {

    if (getResource() == null) {
        action.setChecked(true);
        return;
    }
    try {
        String[] ids = getResource().getProject().getDescription().getNatureIds();
        for (String id : ids) {
            if (StringUtils.equals(id, JSLintPluginNature.NATURE_ID)) {
                action.setChecked(true);
                return;
            }
        }
        action.setChecked(false);
    } catch (CoreException e) {
        logger.put(Messages.EM0011, e, getResource().getProject().getName());
    }

}

From source file:com.onehippo.gogreen.jaxrs.services.TopProductsResource.java

@GET
@Path("/")
public List<ProductLinkRepresentation> getProductResources(@Context HttpServletRequest servletRequest,
        @Context HttpServletResponse servletResponse, @Context UriInfo uriInfo,
        @QueryParam("sortby") @DefaultValue("hippogogreen:rating") String sortBy,
        @QueryParam("sortdir") @DefaultValue("descending") String sortDirection,
        @QueryParam("max") @DefaultValue("10") String maxParam) {

    List<ProductLinkRepresentation> productRepList = new ArrayList<ProductLinkRepresentation>();
    HstRequestContext requestContext = getRequestContext(servletRequest);

    try {// w  ww. j  ava 2s  .c om
        String mountContentPath = requestContext.getResolvedMount().getMount().getContentPath();
        Node mountContentNode = requestContext.getSession().getRootNode()
                .getNode(PathUtils.normalizePath(mountContentPath));

        HstQueryManager manager = getHstQueryManager(requestContext.getSession(), requestContext);
        HstQuery hstQuery = manager.createQuery(mountContentNode, Product.class, true);

        if (!StringUtils.isBlank(sortBy)) {
            if (StringUtils.equals("descending", sortDirection)) {
                hstQuery.addOrderByDescending(sortBy);
            } else {
                hstQuery.addOrderByAscending(sortBy);
            }
        }

        hstQuery.setLimit(NumberUtils.toInt(maxParam, 10));

        HstQueryResult result = hstQuery.execute();
        HippoBeanIterator iterator = result.getHippoBeans();

        while (iterator.hasNext()) {
            Product productBean = (Product) iterator.nextHippoBean();

            if (productBean != null) {
                ProductLinkRepresentation productRep = new ProductLinkRepresentation(requestContext)
                        .represent(productBean);
                productRep.addLink(getNodeLink(requestContext, productBean));
                productRep.addLink(getSiteLink(requestContext, productBean));
                productRepList.add(productRep);
            }
        }
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.warn("Failed to retrieve top products.", e);
        } else {
            log.warn("Failed to retrieve top products. {}", e.toString());
        }

        throw new WebApplicationException(e);
    }

    return productRepList;
}

From source file:gov.nih.nci.cabig.caaers.web.admin.AgentImporter.java

/**
 * This method accepts the file selected by the user, which is agents.txt file from CTEP and process each record.
 * //w w w  . j a v  a 2s.  c o m
 * @param ctepAgentsFile
 * @param command
 */
public void processEntities(File ctepAgentsFile, ImportCommand command) {

    agentMap = getAgentMap();
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new FileReader(ctepAgentsFile));
        String line = null;
        // skip first 5 lines
        reader.readLine();
        reader.readLine();
        reader.readLine();
        reader.readLine();
        reader.readLine();
        int lineNumber = 5;

        while ((line = reader.readLine()) != null) {
            lineNumber = lineNumber + 1;
            //Process each line. If agents exists add it to updateable list else add it to Importable list.
            DomainObjectImportOutcome<Agent> agentImportOutcome = processAgent(line, lineNumber);
            if (agentImportOutcome != null) {
                if (!agentImportOutcome.isSavable()) {
                    command.addNonImportableAgent(agentImportOutcome);
                } else {
                    if (agentImportOutcome.getImportedDomainObject() != null) {
                        Agent dbAgent = agentMap
                                .get(agentImportOutcome.getImportedDomainObject().getNscNumber());
                        if (dbAgent != null) {
                            if (!StringUtils.equals(dbAgent.getName(),
                                    agentImportOutcome.getImportedDomainObject().getName())) {
                                dbAgent.setName(agentImportOutcome.getImportedDomainObject().getName());
                                agentImportOutcome.setImportedDomainObject(dbAgent);
                                command.addUpdateableAgent(agentImportOutcome);
                            }
                        } else {
                            command.addImportableAgent(agentImportOutcome);
                        }
                    }
                }
            }
        }
        reader.close();
    } catch (Exception e) {
        throw new CaaersSystemException("There was an error, while importing Agents from the file provided", e);
    }
}