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:com.github.lburgazzoli.quickfixj.osgi.FIXConnection.java

/**
 *
 * @param settings/*from   ww w  .  j  av a 2  s .  c o m*/
 * @return
 */
private boolean isAcceptor(final SessionSettings settings) throws Exception {
    return StringUtils.equalsIgnoreCase(SessionFactory.ACCEPTOR_CONNECTION_TYPE,
            settings.getString(SessionFactory.SETTING_CONNECTION_TYPE));
}

From source file:com.glaf.dts.util.XmlWriter.java

public Document write(List<DataTransfer> rows) {
    Document doc = DocumentHelper.createDocument();
    Element root = doc.addElement("mapping");
    for (DataTransfer dataTransfer : rows) {
        Element element = root.addElement("entity");
        element.addAttribute("name", dataTransfer.getEntityName());
        element.addAttribute("package", dataTransfer.getPackageName());
        element.addAttribute("entityName", dataTransfer.getEntityName());
        element.addAttribute("className", dataTransfer.getClassName());
        element.addAttribute("table", dataTransfer.getTableName());
        element.addAttribute("title", dataTransfer.getTitle());
        element.addAttribute("englishTitle", dataTransfer.getEnglishTitle());
        element.addAttribute("parseType", dataTransfer.getParseType());
        element.addAttribute("parseClass", dataTransfer.getParseClass());
        element.addAttribute("filePrefix", dataTransfer.getFilePrefix());
        element.addAttribute("aggregationKeys", dataTransfer.getAggregationKeys());
        element.addAttribute("deleteFetch", dataTransfer.getDeleteFetch());
        element.addAttribute("insertOnly", dataTransfer.getInsertOnly());
        element.addAttribute("primaryKey", dataTransfer.getPrimaryKey());
        element.addAttribute("queryIds", dataTransfer.getQueryIds());
        element.addAttribute("split", dataTransfer.getSplit());
        element.addAttribute("stopWord", dataTransfer.getStopWord());
        element.addAttribute("temporaryFlag", dataTransfer.getTemporaryFlag());
        element.addAttribute("batchSize", String.valueOf(dataTransfer.getBatchSize()));
        element.addAttribute("startRow", String.valueOf(dataTransfer.getStartRow()));
        element.addAttribute("stopSkipRow", String.valueOf(dataTransfer.getStopSkipRow()));
        element.addAttribute("systemFlag", dataTransfer.getSystemFlag());

        ColumnDefinition idField = dataTransfer.getIdColumn();
        if (idField != null) {
            Element idElement = element.addElement("id");
            idElement.addAttribute("name", idField.getName());
            idElement.addAttribute("column", idField.getColumnName());
            idElement.addAttribute("type", idField.getType());
            idElement.addAttribute("title", idField.getTitle());
            idElement.addAttribute("englishTitle", idField.getEnglishTitle());
            if (idField.getLength() > 0) {
                idElement.addAttribute("length", String.valueOf(idField.getLength()));
            }//from  w  ww  .j  a v  a  2  s.  com
            if (idField.getValueExpression() != null) {
                idElement.addAttribute("valueExpression", idField.getValueExpression());
            }
        }

        List<ColumnDefinition> columns = dataTransfer.getColumns();
        for (ColumnDefinition field : columns) {
            if (idField != null
                    && StringUtils.equalsIgnoreCase(idField.getColumnName(), field.getColumnName())) {
                continue;
            }
            Element elem = element.addElement("property");
            elem.addAttribute("name", field.getName());
            elem.addAttribute("column", field.getColumnName());
            elem.addAttribute("type", field.getType());
            if (field.getTitle() != null) {
                elem.addAttribute("title", field.getTitle());
            }
            if (field.getEnglishTitle() != null) {
                elem.addAttribute("englishTitle", field.getEnglishTitle());
            }
            if (field.getValueExpression() != null) {
                elem.addAttribute("valueExpression", field.getValueExpression());
            }

            if (field.getLength() > 0) {
                elem.addAttribute("length", String.valueOf(field.getLength()));
            }
            if (field.getPosition() != null && field.getPosition() > 0) {
                elem.addAttribute("position", String.valueOf(field.getPosition()));
            }
            if (field.getPrecision() > 0) {
                elem.addAttribute("precision", String.valueOf(field.getPrecision()));
            }
            if (field.isUnique()) {
                elem.addAttribute("unique", String.valueOf(field.isUnique()));
            }
            if (field.isSearchable()) {
                elem.addAttribute("searchable", String.valueOf(field.isSearchable()));
            }
            if (!field.isNullable()) {
                elem.addAttribute("nullable", String.valueOf(field.isNullable()));
            }
            if (field.isEditable()) {
                elem.addAttribute("editable", String.valueOf(field.isEditable()));
            }
            elem.addAttribute("displayType", String.valueOf(field.getDisplayType()));
        }
    }
    return doc;
}

From source file:com.murrayc.murraycgwtpexample.server.ThingServiceImpl.java

@Override
public SubmissionResult submitAnswer(final String thingId, final String answer)
        throws IllegalArgumentException {
    final ThingAndAnswer thingAndAnswer = getThingAndAnswer(thingId);
    if (thingAndAnswer == null) {
        throw new IllegalArgumentException("Unknown ThingAndAnswer ID");
    }/*from www  .j  a va2  s.  c  om*/

    //Store whether we got the thing right or wrong:
    final boolean result = StringUtils.equalsIgnoreCase(thingAndAnswer.getAnswer(), answer);
    storeAnswer(result, thingAndAnswer.getThing());

    return createSubmissionResult(result, thingId);
}

From source file:com.glaf.dts.util.XmlReader.java

public DataTransfer read(java.io.InputStream inputStream) {
    DataTransfer tableModel = new DataTransfer();
    SAXReader xmlReader = new SAXReader();
    try {// ww w  . ja va2  s . c o  m
        Document doc = xmlReader.read(inputStream);
        Element root = doc.getRootElement();
        Element element = root.element("entity");
        if (element != null) {
            List<?> attrs = element.attributes();
            if (attrs != null && !attrs.isEmpty()) {
                Map<String, Object> dataMap = new java.util.HashMap<String, Object>();
                Iterator<?> iter = attrs.iterator();
                while (iter.hasNext()) {
                    Attribute attr = (Attribute) iter.next();
                    dataMap.put(attr.getName(), attr.getStringValue());
                    tableModel.addProperty(attr.getName(), attr.getStringValue());
                }
                Tools.populate(tableModel, dataMap);
            }

            tableModel.setEntityName(element.attributeValue("name"));
            tableModel.setPrimaryKey(element.attributeValue("primaryKey"));
            tableModel.setTableName(element.attributeValue("table"));
            tableModel.setTitle(element.attributeValue("title"));
            tableModel.setStopWord(element.attributeValue("stopWord"));
            tableModel.setPackageName(element.attributeValue("package"));
            tableModel.setEnglishTitle(element.attributeValue("englishTitle"));
            tableModel.setFilePrefix(element.attributeValue("filePrefix"));
            tableModel.setParseType(element.attributeValue("parseType"));
            tableModel.setParseClass(element.attributeValue("parseClass"));
            tableModel.setAggregationKeys(element.attributeValue("aggregationKeys"));
            tableModel.setSplit(element.attributeValue("split"));
            if (StringUtils.equals(element.attributeValue("insertOnly"), "true")) {
                tableModel.setInsertOnly("true");
            }

            String startRow = element.attributeValue("startRow");
            if (StringUtils.isNotEmpty(startRow) && StringUtils.isNumeric(startRow)) {
                tableModel.setStartRow(Integer.parseInt(startRow));
            }

            String stopSkipRow = element.attributeValue("stopSkipRow");
            if (StringUtils.isNotEmpty(stopSkipRow) && StringUtils.isNumeric(stopSkipRow)) {
                tableModel.setStopSkipRow(Integer.parseInt(stopSkipRow));
            }

            String batchSize = element.attributeValue("batchSize");
            if (StringUtils.isNotEmpty(batchSize) && StringUtils.isNumeric(batchSize)) {
                tableModel.setBatchSize(Integer.parseInt(batchSize));
            }

            List<?> excludes = element.elements("excludes");
            if (excludes != null && excludes.size() > 0) {
                Iterator<?> iterator = excludes.iterator();
                while (iterator.hasNext()) {
                    Element elem = (Element) iterator.next();
                    tableModel.addExclude(elem.getStringValue());
                }
            }

            List<?> rows = element.elements("property");
            if (rows != null && rows.size() > 0) {
                Iterator<?> iterator = rows.iterator();
                while (iterator.hasNext()) {
                    Element elem = (Element) iterator.next();
                    ColumnDefinition field = new ColumnDefinition();
                    this.readField(elem, field);
                    tableModel.addColumn(field);
                    if (StringUtils.equalsIgnoreCase(tableModel.getPrimaryKey(), field.getColumnName())) {
                        tableModel.setIdColumn(field);
                    }
                }
            }
        }

    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    return tableModel;
}

From source file:com.nike.cerberus.operation.core.EnableConfigReplicationOperation.java

@Override
public boolean isRunnable(final EnableConfigReplicationCommand command) {
    boolean isRunnable = true;
    final String baseStackId = configStore.getStackId(StackName.BASE);

    if (StringUtils.isBlank(baseStackId)) {
        isRunnable = false;/*from  www . j av a2  s  .  c  o  m*/
        logger.error("Base components must be initialized before creating the replication bucket!");
    }

    if (StringUtils.equalsIgnoreCase(environmentMetadata.getRegionName(), command.getReplicationRegion())) {
        isRunnable = false;
        logger.error("Replication region must be different than Cerberus hosted region!");
    }

    if (StringUtils.isNotBlank(configStore.getReplicationBucketName())) {
        isRunnable = false;
        logger.error("Replicaton bucket already exists, aborting...");
    }

    return isRunnable;
}

From source file:io.github.moosbusch.lumpi.util.LumpiUtil.java

public static Class<?> getPropertyType(Class<?> type, String propertyName) {
    String[] propertyTokens = StringUtils.split(propertyName, ".");
    Class<?> result = type;

    for (String propertyToken : propertyTokens) {
        PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(result);

        for (PropertyDescriptor descriptor : descriptors) {
            if (StringUtils.equalsIgnoreCase(propertyToken, descriptor.getName())) {
                result = descriptor.getPropertyType();
                break;
            } else {
                result = null;//from ww w.  j a v a2s .  com
            }
        }
    }

    return result;
}

From source file:com.glaf.dts.web.rest.MxTableResource.java

@POST
@Path("/deleteColumn")
@ResponseBody//w  w w  . j a  v a  2 s . c o  m
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public byte[] deleteColumn(@Context HttpServletRequest request, @Context UriInfo uriInfo) {
    String columnId = request.getParameter("columnId");
    if (StringUtils.isNotEmpty(columnId)) {
        columnId = RequestUtils.decodeString(columnId);
        columnId = columnId.toLowerCase();
        if (StringUtils.equalsIgnoreCase("ID", columnId)
                || StringUtils.equalsIgnoreCase("AGGREGATIONKEY", columnId)) {
            return ResponseUtils.responseJsonResult(false);
        }
        tableDefinitionService.deleteColumn(columnId);
        return ResponseUtils.responseJsonResult(true);
    }
    return ResponseUtils.responseJsonResult(false);
}

From source file:com.mirth.connect.donkey.server.Donkey.java

private void initDaoFactory() throws StartException {
    Properties dbProperties = donkeyConfiguration.getDonkeyProperties();
    String database = dbProperties.getProperty("database");
    String driver = dbProperties.getProperty("database.driver");
    String url = dbProperties.getProperty("database.url");
    String username = dbProperties.getProperty("database.username");
    String password = dbProperties.getProperty("database.password");
    String pool = dbProperties.getProperty("database.pool");
    boolean jdbc4 = Boolean.parseBoolean(dbProperties.getProperty("database.jdbc4"));
    String testQuery = dbProperties.getProperty("database.test-query");
    int maxConnections;

    try {// w  ww .j av  a2s.c  o  m
        maxConnections = Integer.parseInt(dbProperties.getProperty("database.max-connections"));
    } catch (NumberFormatException e) {
        throw new StartException("Failed to read the database.max-connections configuration property");
    }

    if (driver != null) {
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            throw new StartException(e);
        }
    }

    JdbcDaoFactory jdbcDaoFactory = JdbcDaoFactory.getInstance(database);
    jdbcDaoFactory.setStatsServerId(donkeyConfiguration.getServerId());

    if (StringUtils.equalsIgnoreCase(pool, "DBCP")) {
        logger.debug("Initializing DBCP");
        jdbcDaoFactory.setConnectionPool(new DBCPConnectionPool(url, username, password, maxConnections));
    } else {
        logger.debug("Initializing HikariCP");
        jdbcDaoFactory.setConnectionPool(
                new HikariConnectionPool(driver, url, username, password, maxConnections, jdbc4, testQuery));
    }

    jdbcDaoFactory.setSerializerProvider(new SerializerProvider() {
        @Override
        public Serializer getSerializer(Integer metaDataId) {
            return serializer;
        }
    });

    XmlQuerySource xmlQuerySource = new XmlQuerySource();

    try {
        xmlQuerySource.load("default.xml");
        xmlQuerySource.load(dbProperties.getProperty("database") + ".xml");
    } catch (XmlQuerySourceException e) {
        throw new StartException(e);
    }

    jdbcDaoFactory.setQuerySource(xmlQuerySource);

    JdbcDao dao = jdbcDaoFactory.getDao();

    try {
        if (dao.initTableStructure()) {
            dao.commit();
        }
    } finally {
        dao.close();
    }

    daoFactory = jdbcDaoFactory;
}

From source file:com.nesscomputing.httpclient.response.ContentResponseHandler.java

/**
 * Processes the client response./* w  w w  .j ava 2s.co  m*/
 */
@Override
public T handle(final HttpClientResponse response) throws IOException {
    if (allowRedirect && response.isRedirected()) {
        LOG.debug("Redirecting based on '%d' response code", response.getStatusCode());
        throw new RedirectedException(response);
    } else {
        // Find the response stream - the error stream may be valid in cases
        // where the input stream is not.
        InputStream is = null;
        try {
            is = response.getResponseBodyAsStream();
        } catch (IOException e) {
            LOG.warnDebug(e, "Could not locate response body stream");
            // normal for 401, 403 and 404 responses, for example...
        }

        if (is == null) {
            // Fall back to zero length response.
            is = new NullInputStream(0);
        }

        try {
            final Long contentLength = response.getContentLength();

            if (maxBodyLength > 0) {
                if (contentLength != null && contentLength > maxBodyLength) {
                    throw new SizeExceededException("Content-Length: " + contentLength);
                }

                LOG.debug("Limiting stream length to '%d'", maxBodyLength);
                is = new SizeLimitingInputStream(is, maxBodyLength);
            }

            final String encoding = StringUtils.trimToEmpty(response.getHeader("Content-Encoding"));

            if (StringUtils.equalsIgnoreCase(encoding, "lz4")) {
                LOG.debug("Found LZ4 stream");
                is = new LZ4BlockInputStream(is);
            } else if (StringUtils.equalsIgnoreCase(encoding, "gzip")
                    || StringUtils.equalsIgnoreCase(encoding, "x-gzip")) {
                LOG.debug("Found GZIP stream");
                is = new GZIPInputStream(is);
            } else if (StringUtils.equalsIgnoreCase(encoding, "deflate")) {
                LOG.debug("Found deflate stream");
                final Inflater inflater = new Inflater(true);
                is = new InflaterInputStream(is, inflater);
            }

            return contentConverter.convert(response, is);
        } catch (IOException ioe) {
            return contentConverter.handleError(response, ioe);
        }
    }
}

From source file:de.knightsoftnet.validators.shared.impl.PhoneNumberValueRestValidator.java

/**
 * {@inheritDoc} check if given string is a valid gln.
 *
 * @see javax.validation.ConstraintValidator#isValid(java.lang.Object,
 *      javax.validation.ConstraintValidatorContext)
 *///w w  w .j  a  va2  s  .  c om
@Override
public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);

    if (StringUtils.isEmpty(valueAsString)) {
        // empty field is ok
        return true;
    }
    try {
        String countryCode = BeanUtils.getProperty(pvalue, this.fieldCountryCode);
        final String phoneNumber = BeanUtils.getProperty(pvalue, this.fieldPhoneNumber);
        if (StringUtils.isEmpty(phoneNumber)) {
            return true;
        }

        if (this.allowLowerCaseCountryCode) {
            countryCode = StringUtils.upperCase(countryCode);
        }
        final String url = StringUtils
                .removeEnd(StringUtils.removeEnd(StringUtils.removeEnd(GWT.getModuleBaseURL(), "/"),
                        GWT.getModuleName()), "/")
                + PhoneNumber.ROOT + PhoneNumber.VALIDATE //
                + "?" + Parameters.COUNTRY + "=" + countryCode //
                + "&" + Parameters.PHONE_NUMBER + "=" + this.urlEncode(phoneNumber) //
                + "&" + Parameters.DIN_5008 + "=" + PhoneNumberValueRestValidator.this.allowDin5008 //
                + "&" + Parameters.E123 + "=" + PhoneNumberValueRestValidator.this.allowE123 //
                + "&" + Parameters.URI + "=" + PhoneNumberValueRestValidator.this.allowUri //
                + "&" + Parameters.MS + "=" + PhoneNumberValueRestValidator.this.allowMs //
                + "&" + Parameters.COMMON + "=" + PhoneNumberValueRestValidator.this.allowCommon;
        final String restResult = CachedSyncHttpGetCall.syncRestCall(url);
        if (StringUtils.equalsIgnoreCase("TRUE", restResult)) {
            return true;
        }
        this.switchContext(pcontext);
        return false;
    } catch (final Exception ignore) {
        this.switchContext(pcontext);
        return false;
    }
}