Example usage for org.apache.commons.lang3 StringUtils equalsIgnoreCase

List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.

null s are handled without exceptions.

Usage

From source file:io.wcm.handler.richtext.impl.RichTextRewriteContentHandlerImpl.java

/**
 * Checks if the given element has to be rewritten.
 * Is called for every child single element of the parent given to rewriteContent method.
 * @param element Element to check/*from w w w  .  j  a  va  2 s  .  co m*/
 * @return null if nothing is to do with this element.
 *         Return empty list to remove this element.
 *         Return list with other content to replace element with new content.
 */
@Override
public List<Content> rewriteElement(Element element) {

    // rewrite anchor elements
    if (StringUtils.equalsIgnoreCase(element.getName(), "a")) {
        return rewriteAnchor(element);
    }

    // rewrite image elements
    else if (StringUtils.equalsIgnoreCase(element.getName(), "img")) {
        return rewriteImage(element);
    }

    // detect BR elements and turn those into "self-closing" elements
    // since the otherwise generated <br> </br> structures are illegal and
    // are not handled correctly by Internet Explorers
    else if (StringUtils.equalsIgnoreCase(element.getName(), "br")) {
        if (element.getContent().size() > 0) {
            element.removeContent();
        }
        return null;
    }

    // detect empty elements and insert at least an empty string to avoid "self-closing" elements
    // that are not handled correctly by most browsers
    else if (NONSELFCLOSING_TAGS.contains(StringUtils.lowerCase(element.getName()))) {
        if (element.getContent().isEmpty()) {
            element.setText("");
        }
        return null;
    }

    return null;
}

From source file:$.RoleAction.java

private void validateRole(Role role, String rolename) {
        if (StringUtils.isBlank(role.getName())) {
            addFieldError("role.name", getText("message.admin.role.name.notempty"));
        } else if (!StringUtils.equalsIgnoreCase(role.getName(), rolename)) {
            if (roleManager.getRoleByName(role.getName()) != null) {
                addFieldError("role.name", getText("message.admin.role.name.exist"));
            }/*from w w  w  .j  av  a2  s  .  co  m*/
        }
    }

From source file:gov.nih.nci.caintegrator.common.QueryUtil.java

private static boolean checkImageSeriesMatch(ResultRow rowToTest, ResultRow curRow) {
    if (curRow.getImageSeries() == null && rowToTest.getImageSeries() == null) { // both null
        return true;
    }//from w  w  w. j  a v a2s.  c om
    if (curRow.getImageSeries() == null || rowToTest.getImageSeries() == null) { // only one is null
        return false;
    }
    return StringUtils.equalsIgnoreCase(curRow.getImageSeries().getIdentifier(),
            rowToTest.getImageSeries().getIdentifier());
}

From source file:io.wcm.handler.media.impl.ImageFileServlet.java

/**
 * Get image filename to be used for the URL with file extension matching the image format which is produced by this
 * servlet./*from  www  .j a  v  a  2s. c  o  m*/
 * @param pOriginalFilename Original filename of the image to render.
 * @return Filename to be used for URL.
 */
public static String getImageFileName(String pOriginalFilename) {
    String namePart = StringUtils.substringBeforeLast(pOriginalFilename, ".");
    String extensionPart = StringUtils.substringAfterLast(pOriginalFilename, ".");

    // use PNG format if original image is PNG, otherwise always use JPEG
    if (StringUtils.equalsIgnoreCase(extensionPart, FileExtension.PNG)) {
        extensionPart = FileExtension.PNG;
    } else {
        extensionPart = FileExtension.JPEG;
    }
    return namePart + "." + extensionPart;
}

From source file:jp.co.golorp.emarf.tag.lib.base.model.property.Legend.java

@Override
public String doStart() throws JspException {

    ServletRequest request = this.pageContext.getRequest();

    String pageName = RequestUtil.getPathPageName(request);

    boolean notnull = false;

    ColumnInfo columnInfo = MetaData.getColumnInfo(this.modelName, this.propertyName);
    if (columnInfo != null) {
        // ???//from  ww w . j a v a2s .  c o m

        boolean isIndex = StringUtils.equalsIgnoreCase(pageName, EmarfServlet.PAGE_INDEX);
        if (!isIndex) {
            // ?????

            boolean readonly = Taglib.isReadonly(request, this.modelName, this.propertyName);
            if (!readonly) {
                // ??????

                // NOT NULL?
                notnull = columnInfo.getNullable() != 1;
            }
        }
    }

    return Legend.render(this.modelName, this.propertyName, pageName, notnull);
}

From source file:com.glaf.dts.bean.TransformBean.java

public boolean transformAllQueryToTable() {
    boolean result = true;
    QueryDefinitionQuery q = new QueryDefinitionQuery();
    q.locked(0);/*  w w  w. ja v a2s.c  om*/
    List<QueryDefinition> queries = getQueryDefinitionService().list(q);
    if (queries != null && !queries.isEmpty()) {
        for (QueryDefinition queryDefinition : queries) {
            String tableName = queryDefinition.getTargetTableName();
            if (StringUtils.isNotEmpty(tableName)) {
                tableName = tableName.toLowerCase();
                if (StringUtils.startsWith(tableName, "mx_") || StringUtils.startsWith(tableName, "sys_")
                        || StringUtils.startsWith(tableName, "act_")
                        || StringUtils.startsWith(tableName, "jbpm_")) {
                    continue;
                }
                MxTransformManager manager = new MxTransformManager();
                TableDefinition tableDefinition = null;
                if (!StringUtils.equalsIgnoreCase(queryDefinition.getRotatingFlag(), "R2C")) {
                    try {
                        tableDefinition = manager.toTableDefinition(queryDefinition);
                        tableDefinition.setTableName(tableName);
                        tableDefinition.setType("DTS");
                        tableDefinition.setNodeId(queryDefinition.getNodeId());
                        TransformTable tbl = new TransformTable();
                        tbl.createOrAlterTable(tableDefinition);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        logger.error(ex);
                    }
                }

                Long databaseId = queryDefinition.getDatabaseId();
                TransformTable transformTable = new TransformTable();
                try {
                    Database db = getDatabaseService().getDatabaseById(databaseId);
                    if (db != null) {
                        transformTable.transformQueryToTable(tableName, queryDefinition.getId(), db.getName());
                    } else {
                        transformTable.transformQueryToTable(tableName, queryDefinition.getId(),
                                Environment.DEFAULT_SYSTEM_NAME);
                    }
                } catch (Exception ex) {
                    result = false;
                    ex.printStackTrace();
                    logger.error(ex);
                }
            }
        }
    }
    return result;
}

From source file:io.wcm.handler.media.impl.ImageFileServlet.java

@Override
protected String getContentType(Resource resource, SlingHttpServletRequest request) {

    // get filename from suffix to get extension
    String fileName = request.getRequestPathInfo().getSuffix();
    if (StringUtils.isNotEmpty(fileName)) {
        // if extension is PNG use PNG content type, otherwise fallback to JPEG
        String fileExtension = StringUtils.substringAfterLast(fileName, ".");
        if (StringUtils.equalsIgnoreCase(fileExtension, FileExtension.PNG)) {
            return ContentType.PNG;
        }//  www. j  av a2 s .  c om
    }

    // for rendered images use JPEG mime type as default fallback
    return ContentType.JPEG;
}

From source file:hudson.tasks.CommandInterpreter.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }/*w ww . j av  a 2  s .co m*/
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    CommandInterpreter that = (CommandInterpreter) o;
    return StringUtils.equalsIgnoreCase(command, that.command);
}

From source file:com.glaf.mail.domain.MailAccount.java

public boolean authFlag() {
    if (StringUtils.equalsIgnoreCase(authFlag, "1") || StringUtils.equalsIgnoreCase(authFlag, "Y")
            || StringUtils.equalsIgnoreCase(authFlag, "true")) {
        return true;
    }//from   w  ww .ja va2s.  c om
    return false;
}

From source file:io.cloudslang.content.database.utils.SQLUtils.java

/**
 * Some databases (Sybase) throw exceptions during a database restore. This function processes that exception, and if it is that type, builds up the output of the command
 *
 * @param e The exception to analyze/*from  w w w. j  a  v  a 2 s .  c  o m*/
 * @return The output of the dump command
 * @throws java.sql.SQLException If it was not a successful load command's exception.
 */
public static String processLoadException(SQLException e) throws SQLException {
    final String sqlState = e.getSQLState();
    if (sqlState != null && StringUtils.equalsIgnoreCase(sqlState, "s1000")) {
        SQLException f = e;
        StringBuilder s = new StringBuilder();
        s.append(f.getMessage());
        while ((f = f.getNextException()) != null)
            s.append("\n").append(f.getMessage());
        String str = s.toString();
        if (StringUtils.containsIgnoreCase(str, "load is complete"))
            return str;
    }
    throw e;
}