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

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

Introduction

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

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:hr.fer.zemris.vhdllab.service.ci.CircuitInterface.java

public Port getPort(String portName) {
    Validate.notNull(portName, "Port name can't be null");
    for (Port p : ports) {
        if (StringUtils.equalsIgnoreCase(p.getName(), portName)) {
            return p;
        }/*from   w ww. j  a va  2  s  . c  o  m*/
    }
    return null;
}

From source file:com.hangum.tadpole.sql.query.TadpoleSystem_SchemaHistory.java

/**
 * save schema_history /*  ww w . ja v a 2 s . c  o m*/
 * 
 * @param user_seq
 * @param userDB
 * @param strSQL
 */
public static SchemaHistoryDAO save(int user_seq, UserDBDAO userDB, String strSQL) {
    SchemaHistoryDAO schemaDao = new SchemaHistoryDAO();

    try {
        //
        //
        //
        String strWorkSQL = strSQL.replaceAll("(\r\n|\n|\r)", ""); // ? .
        strWorkSQL = strWorkSQL.replaceAll("\\p{Space}", " "); // ?  .
        if (logger.isDebugEnabled())
            logger.debug("[start sql]\t" + strWorkSQL);

        String[] arrSQL = StringUtils.split(strWorkSQL);
        String strWorkType = arrSQL[0];

        // object type
        String strObjecType = arrSQL[1];

        // objectId
        String strObjectId = StringUtils.remove(arrSQL[2], "(");

        if (StringUtils.equalsIgnoreCase("or", strObjecType)) {
            strObjecType = arrSQL[3];
            strObjectId = StringUtils.remove(arrSQL[4], "(");
        }

        schemaDao = new SchemaHistoryDAO();
        schemaDao.setDb_seq(userDB.getSeq());
        schemaDao.setUser_seq(user_seq);

        schemaDao.setWork_type(strWorkType);
        schemaDao.setObject_type(strObjecType);
        schemaDao.setObject_id(strObjectId);

        schemaDao.setCreate_date(new Timestamp(System.currentTimeMillis()));

        SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
        SchemaHistoryDAO schemaHistoryDao = (SchemaHistoryDAO) sqlClient.insert("sqlHistoryInsert", schemaDao); //$NON-NLS-1$

        insertResourceData(schemaHistoryDao, strSQL);
    } catch (Exception e) {
        logger.error("Schema histor save error", e);
    }

    return schemaDao;
}

From source file:com.pedra.storefront.filters.UrlEncoderFilter.java

@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws ServletException, IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug(" The incoming URL : [" + request.getRequestURL().toString() + "]");
    }/*  www.j a v  a  2s. c o  m*/
    final List<UrlEncoderData> urlEncodingAttributes = getUrlEncoderFacade().variablesForUrlEncoding();
    if (urlEncodingAttributes != null && !urlEncodingAttributes.isEmpty()) {
        final HttpSession session = request.getSession(false);
        final UrlEncoderPatternData patternData = getUrlEncoderFacade().patternForUrlEncoding(
                request.getRequestURL().toString(), request.getContextPath(),
                (session != null && session.isNew()));
        final String patternBeforeProcessing = getSessionService()
                .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
        final String pattern = "/" + patternData.getPattern();
        if (!StringUtils.equalsIgnoreCase(patternBeforeProcessing, pattern)) {
            if (patternData.isRedirectRequired()) {
                String redirectUrl = StringUtils.replace(request.getRequestURL().toString(),
                        patternBeforeProcessing, pattern);
                final String queryString = request.getQueryString();
                if (StringUtils.isNotBlank(queryString)) {
                    redirectUrl = redirectUrl + "?" + queryString;
                }
                response.sendRedirect(redirectUrl);
            } else {
                getUrlEncoderFacade().updateUrlEncodingData();
            }
        }
        getSessionService().setAttribute(WebConstants.URL_ENCODING_ATTRIBUTES, pattern);
        final UrlEncodeHttpRequestWrapper wrappedRequest = new UrlEncodeHttpRequestWrapper(request,
                patternData.getPattern());
        wrappedRequest.setAttribute(WebConstants.URL_ENCODING_ATTRIBUTES, pattern);
        wrappedRequest.setAttribute("originalContextPath", request.getContextPath());
        if (LOG.isDebugEnabled()) {
            LOG.debug("ContextPath=[" + wrappedRequest.getContextPath() + "]" + " Servlet Path= ["
                    + wrappedRequest.getServletPath() + "]" + " Request Url= [" + wrappedRequest.getRequestURL()
                    + "]");
        }
        filterChain.doFilter(wrappedRequest, response);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug(" No URL attributes defined");
        }
        request.setAttribute(WebConstants.URL_ENCODING_ATTRIBUTES, "");
        filterChain.doFilter(request, response);
    }
}

From source file:com.acc.storefront.filters.UrlEncoderFilter.java

@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws ServletException, IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug(" The incoming URL : [" + request.getRequestURL().toString() + "]");
    }//  www  .ja va2  s .c om
    final List<UrlEncoderData> urlEncodingAttributes = getUrlEncoderFacade().variablesForUrlEncoding();
    if (urlEncodingAttributes != null && !urlEncodingAttributes.isEmpty()) {
        final HttpSession session = request.getSession(false);
        final UrlEncoderPatternData patternData = getUrlEncoderFacade().patternForUrlEncoding(
                request.getRequestURI().toString(), request.getContextPath(),
                (session != null && session.isNew()));
        final String patternBeforeProcessing = getSessionService()
                .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
        final String pattern = "/" + patternData.getPattern();
        if (!StringUtils.equalsIgnoreCase(patternBeforeProcessing, pattern)) {
            if (patternData.isRedirectRequired()) {
                String redirectUrl = StringUtils.replace(request.getRequestURL().toString(),
                        patternBeforeProcessing + "/", pattern + "/");
                final String queryString = request.getQueryString();
                if (StringUtils.isNotBlank(queryString)) {
                    redirectUrl = redirectUrl + "?" + queryString;
                }
                response.sendRedirect(redirectUrl);
            } else {
                getUrlEncoderFacade().updateUrlEncodingData();
            }
        }
        getSessionService().setAttribute(WebConstants.URL_ENCODING_ATTRIBUTES, pattern);
        final UrlEncodeHttpRequestWrapper wrappedRequest = new UrlEncodeHttpRequestWrapper(request,
                patternData.getPattern());
        wrappedRequest.setAttribute(WebConstants.URL_ENCODING_ATTRIBUTES, pattern);
        wrappedRequest.setAttribute("originalContextPath",
                StringUtils.isBlank(request.getContextPath()) ? "/" : request.getContextPath());
        if (LOG.isDebugEnabled()) {
            LOG.debug("ContextPath=[" + wrappedRequest.getContextPath() + "]" + " Servlet Path= ["
                    + wrappedRequest.getServletPath() + "]" + " Request Url= [" + wrappedRequest.getRequestURL()
                    + "]");
        }
        filterChain.doFilter(wrappedRequest, response);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug(" No URL attributes defined");
        }
        request.setAttribute(WebConstants.URL_ENCODING_ATTRIBUTES, "");
        filterChain.doFilter(request, response);
    }
}

From source file:com.kixeye.chassis.support.logging.LoggingConfiguration.java

@PostConstruct
public void initialize() {
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();

    if (config.containsKey(LOGBACK_CONFIG_NAME)) {
        System.out.println("Loading logging config.");

        reloadLogging(config.getString(LOGBACK_CONFIG_NAME));
    }/*from   w w w  .  j a v a  2s .  c  o  m*/

    config.addConfigurationListener(new ConfigurationListener() {
        @Override
        public synchronized void configurationChanged(ConfigurationEvent event) {
            if ((event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY
                    || event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY)
                    && StringUtils.equalsIgnoreCase(LOGBACK_CONFIG_NAME, event.getPropertyName())
                    && event.getPropertyValue() != null && !event.isBeforeUpdate()) {
                System.out.println("Reloading logging config.");

                reloadLogging((String) event.getPropertyValue());
            }
        }
    });

    ConfigurationListener flumeConfigListener = new ConfigurationListener() {
        private FlumeLoggerLoader loggerLoader = null;

        public synchronized void configurationChanged(ConfigurationEvent event) {
            if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY
                    || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY
                    || event.getType() == AbstractConfiguration.EVENT_CLEAR_PROPERTY)) {
                return;
            }

            if (FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY.equals(event.getPropertyName())) {
                if ("true".equals(event.getPropertyValue())) {
                    if (loggerLoader == null) {
                        // construct the bean
                        loggerLoader = (FlumeLoggerLoader) applicationContext
                                .getBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, "chassis");
                    } // else we already have one so we're cool
                } else {
                    if (loggerLoader != null) {
                        // delete the bean
                        ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) applicationContext
                                .getParentBeanFactory();
                        beanFactory.destroyBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, loggerLoader);
                        loggerLoader = null;
                    } // else we don't have any so we're cool
                }
            } else if (FlumeLoggerLoader.RELOAD_PROPERTIES.contains(event.getPropertyValue())) {
                // only reload if we're already running - otherwise ignore
                if (loggerLoader != null) {
                    // delete the bean
                    ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) applicationContext
                            .getParentBeanFactory();
                    beanFactory.destroyBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, loggerLoader);
                    loggerLoader = null;

                    // construct the bean
                    loggerLoader = (FlumeLoggerLoader) applicationContext
                            .getBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, "chassis");
                } // else we don't have any so we're cool
            }
        }
    };

    config.addConfigurationListener(flumeConfigListener);

    flumeConfigListener.configurationChanged(new ConfigurationEvent(this,
            AbstractConfiguration.EVENT_SET_PROPERTY, FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY,
            config.getProperty(FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY), false));
}

From source file:gov.nih.nci.cabig.caaers.utils.ranking.Ranker.java

/**
 * Will rank an object, based on the following rules :-
 *  1) If there is a full text match - Highest rank "WHOLE_SENTENCE_MATCH" is given.
 *  1) Starting of the sentence if match - 2nd Highest rank "BEGINING_OF_SENTENCE" is given.
 *  2) Begining of any word match, - 3rd Highest rank "BEGINING_OF_WORD" is given.
 *  3) Anywhere in the sentence match - The lowest rank PART_OF_SENTENCE is given.
 * //from ww w  . jav a2s. c om
 * @param obj
 * @return
 */
public <T extends Object> RankedObject rank(T obj, Serializer<T> serializer) {
    RankedObject<T> rankedObject = new RankedObject(obj);
    String str = serializer.serialize(obj);
    int l = str.length();

    //whole sentence
    if (StringUtils.equalsIgnoreCase(str, searchStr)) {
        rankedObject.addToRank(WHOLE_SENTENCE_MATCH);
    }

    Matcher m = p.matcher(str);
    if (m.find()) {

        int start = m.start();
        if (start == 0) {
            //begining of sentence
            rankedObject.addToRank(BEGINING_OF_SENTENCE);
        } else {
            int i = start - 1;
            int j = start - 2;
            char iChar = str.charAt(i);

            //begining of sentence.
            if ((j == 0 && str.charAt(j) == '(') || (i == 0 && iChar == '('))
                rankedObject.addToRank(BEGINING_OF_SENTENCE);

            if (iChar == ' ' || iChar == '(') {

                int k = start + patternLength;
                if (k == l || (k < l && (str.charAt(k) == ' ' || str.charAt(k) == ')'))) {
                    //whole word match
                    rankedObject.addToRank(WHOLE_WORD_MATCH);
                }

                //begining of word
                rankedObject.addToRank(BEGINING_OF_WORD);
            }
        }

        //part of sentence
        rankedObject.addToRank(PART_OF_SENTENCE);

        rankedObject.substractFromRank(start);

    }

    return rankedObject;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.runtimeproperty.RunTimePropertyCellModifier.java

/**
 * Modifies the element//from  w ww .j  ava 2  s  . c  om
 * 
 * @param element
 *            the element
 * @param property
 *            the property
 * @param value
 *            the value
 */
public void modify(Object element, String property, Object value) {
    if (viewer.getData(Constants.WINDOW_TITLE) != null && StringUtils
            .equalsIgnoreCase((String) viewer.getData(Constants.WINDOW_TITLE), Constants.SUBJOB_WINDOW_LABEL))
        customizedModifyForSubgraph(element, property, value);
    else {
        if (element instanceof Item)
            element = ((Item) element).getData();

        RuntimeProperties runtimePropertyRow = (RuntimeProperties) element;

        if (StringUtils.equals(PROPERTY_NAME, property)) {
            if (ParameterUtil.isParameter((String) value)) {
                runtimePropertyRow.setPropertyValue((String) value);
            }
            runtimePropertyRow.setPropertyName(((String) value));
        } else if (StringUtils.equals(PROPERTY_VALUE, property)) {
            if (ParameterUtil.isParameter((String) value)) {
                runtimePropertyRow.setPropertyName((String) value);
            }
            runtimePropertyRow.setPropertyValue((String) value);
        }
    }
    // Force the viewer to refresh
    viewer.refresh();
}

From source file:com.xhm.longxin.qth.web.admin.module.action.AdminAction.java

public void doLogin(@FormGroup("login") LoginVO vo,
        @FormField(name = "validateStr", group = "login") CustomErrors validateField,
        @FormField(name = "loginError", group = "login") CustomErrors err, Navigator nav,
        ParameterParser params) {//from w  w  w .j av a 2s. com
    String validateCode = (String) session.getAttribute(AdminConstant.VALIDATE_CODE);
    if (validateCode == null || StringUtils.equalsIgnoreCase(validateCode, vo.getValidateStr()) == false) {
        validateField.setMessage("validateError");
        return;
    }

    AdminUser admin = adminService.login(vo);
    if (admin != null) {
        setSession(admin);

        redirectToReturnPage(nav, params);
    } else {
        err.setMessage("invalidUserOrPassword");
    }

}

From source file:cn.com.p2p.framework.util.Struts2Utils.java

/**
 * ./*w  w w. j  ava2 s.  co  m*/
 * 
 * eg. <br/>
 * render("text/plain", "hello", "encoding:GBK"); <br/>
 * render("text/plain", "hello", "no-cache:false"); <br/>
 * render("text/plain", "hello", "encoding:GBK", "no-cache:false");
 * 
 * @param headers
 *            ??header??"encoding:""no-cache:",UTF-8true.
 */
public static void render(final String contentType, final String content, final String... headers) {
    try {
        // ?headers?
        String encoding = ENCODING_DEFAULT;
        boolean noCache = NOCACHE_DEFAULT;
        for (String header : headers) {
            String headerName = StringUtils.substringBefore(header, ":");
            String headerValue = StringUtils.substringAfter(header, ":");

            if (StringUtils.equalsIgnoreCase(headerName, ENCODING_PREFIX)) {
                encoding = headerValue;
            } else if (StringUtils.equalsIgnoreCase(headerName, NOCACHE_PREFIX)) {
                noCache = Boolean.parseBoolean(headerValue);
            } else {
                throw new IllegalArgumentException(headerName + "??header");
            }
        }

        HttpServletResponse response = ServletActionContext.getResponse();

        // headers?
        String fullContentType = contentType + ";charset=" + encoding;
        response.setContentType(fullContentType);
        if (noCache) {
            response.setHeader("Pragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
        }

        response.getWriter().write(content);
        response.getWriter().flush();

    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:edu.monash.merc.wsclient.biomart.CSVProbGeneCreator.java

public ProbeGeneBean createProbeGeneBean() {
    ProbeGeneBean probeGeneBean = new ProbeGeneBean();

    for (CSVColumn csvColumn : columns) {
        String columnName = csvColumn.getColumnName();
        String columnValue = csvColumn.getColumnValue();
        if (StringUtils.equalsIgnoreCase(columnName, ProbeConsts.ENSG_ACCESSION)) {
            if (StringUtils.isNotBlank(columnValue) && !StringUtils.equals("\t", columnValue)) {
                probeGeneBean.setEnsgAccession(columnValue);
            }/*w w  w  . j a v a2  s. c  om*/
        } else {
            if (StringUtils.isNotBlank(columnValue) && !StringUtils.equals("\t", columnValue)) {
                probeGeneBean.setProbeId(columnValue);
            }
        }
    }
    return probeGeneBean;
}