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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

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

null s are handled without exceptions.

Usage

From source file:com.glaf.core.xml.XmlMappingReader.java

public TableModel read(java.io.InputStream inputStream) {
    TableModel tableModel = new TableModel();
    SAXReader xmlReader = new SAXReader();
    try {/*from www .j  av a  2s .c o m*/
        Document doc = xmlReader.read(inputStream);
        Element root = doc.getRootElement();
        Element element = root.element("entity");
        if (element != null) {
            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.setAggregationKey(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.isNumeric(startRow)) {
                tableModel.setStartRow(Integer.parseInt(startRow));
            }
            String stopSkipRow = element.attributeValue("stopSkipRow");
            if (StringUtils.isNumeric(stopSkipRow)) {
                tableModel.setStopSkipRow(Integer.parseInt(stopSkipRow));
            }

            String minLength = element.attributeValue("minLength");
            if (StringUtils.isNumeric(minLength)) {
                tableModel.setMinLength(Integer.parseInt(minLength));
            }

            String batchSize = element.attributeValue("batchSize");
            if (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();
                    ColumnModel field = new ColumnModel();
                    this.readField(elem, field);
                    tableModel.addColumn(field);
                    if (StringUtils.equals(tableModel.getPrimaryKey(), field.getColumnName())) {
                        tableModel.setIdColumn(field);
                    }
                }
            }

            Element idElem = element.element("id");
            if (idElem != null) {
                ColumnModel idField = new ColumnModel();
                this.readField(idElem, idField);
                tableModel.setIdColumn(idField);
            }
        }

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

    return tableModel;
}

From source file:alfio.model.transaction.PaymentProxy.java

public static Optional<PaymentProxy> safeValueOf(String name) {
    return Arrays.stream(values()).filter(p -> StringUtils.equals(p.name(), name)).findFirst();
}

From source file:com.mirth.connect.plugins.httpauth.basic.BasicAuthenticator.java

@Override
public AuthenticationResult authenticate(RequestInfo request) {
    BasicHttpAuthProperties properties = getReplacedProperties(request);
    List<String> authHeaderList = request.getHeaders().get(HttpHeader.AUTHORIZATION.asString());

    if (CollectionUtils.isNotEmpty(authHeaderList)) {
        String authHeader = StringUtils.trimToEmpty(authHeaderList.iterator().next());

        int index = authHeader.indexOf(' ');
        if (index > 0) {
            String method = authHeader.substring(0, index);
            if (StringUtils.equalsIgnoreCase(method, "Basic")) {
                // Get Base64-encoded credentials
                String credentials = StringUtils.trim(authHeader.substring(index));
                // Get the raw, colon-separated credentials
                credentials = new String(Base64.decodeBase64(credentials), StandardCharsets.ISO_8859_1);

                // Split on ':' to get the username and password
                index = credentials.indexOf(':');
                if (index > 0) {
                    String username = credentials.substring(0, index);
                    String password = credentials.substring(index + 1);

                    // Return successful result if the passwords match
                    if (StringUtils.equals(password, properties.getCredentials().get(username))) {
                        return AuthenticationResult.Success(username, properties.getRealm());
                    }/*  w  w w  . j a v a2 s .  com*/
                }
            }
        }
    }

    // Return authentication challenge
    return AuthenticationResult.Challenged("Basic realm=\"" + properties.getRealm() + "\"");
}

From source file:com.glaf.core.service.impl.MxSysKeyServiceImpl.java

public SysKey getSysKey(String id) {
    if (id == null) {
        return null;
    }// w  w  w.  j  a v  a2 s. c  om
    if (StringUtils.equals(DBUtils.POSTGRESQL, DBConnectionFactory.getDatabaseType())) {
        SysKey sysKey = sysKeyMapper.getSysKeyById_postgres(id);
        return sysKey;
    }
    SysKey sysKey = sysKeyMapper.getSysKeyById(id);
    return sysKey;
}

From source file:com.github.fengtan.sophie.tables.FieldsTable.java

@Override
protected void populate() throws SophieException {
    // Get remote fields + unique key.
    String uniqueField = SolrUtils.getRemoteUniqueField();
    List<FieldInfo> fields = SolrUtils.getRemoteFields();

    // Populate table.
    for (FieldInfo field : fields) {
        Map<String, String> values = new HashMap<String, String>();
        values.put("Name", field.getName());
        values.put("Type", field.getType());
        values.put("Unique", Boolean.toString(StringUtils.equals(field.getName(), uniqueField)));
        values.put("Distinct", Integer.toString(field.getDistinct()));
        values.put("Schema", field.getSchema());
        for (FieldFlag flag : FieldFlag.values()) {
            EnumSet<FieldFlag> flags = SolrUtils.getFlags(field);
            values.put(flag.getDisplay(), Boolean.toString(flags.contains(flag)));
        }//from  w w  w. j  a  va2s .c o  m
        addRow(values);
    }
}

From source file:com.neophob.sematrix.generator.Image.java

/**
 * load a new file.//w w  w  . j  av a  2 s. c  o m
 *
 * @param filename the filename
 */
public void loadFile(String filename) {
    //only load if needed
    if (StringUtils.equals(filename, this.filename)) {
        LOG.log(Level.INFO, "new filename does not differ from old: " + Image.PREFIX + filename);
        return;
    }

    this.filename = filename;
    try {
        PImage img = Collector.getInstance().getPapplet().loadImage(Image.PREFIX + filename);
        if (img == null || img.height < 2) {
            LOG.log(Level.WARNING, "could not load " + Image.PREFIX + filename + " " + img);
            return;
        }

        LOG.log(Level.INFO,
                "resize to img " + filename + " " + internalBufferXSize + ", " + internalBufferYSize);
        PixelControllerResize res = Collector.getInstance().getPixelControllerResize();
        img.loadPixels();
        this.internalBuffer = res.resizeImage(RESIZE_TYP, img.pixels, img.width, img.height,
                internalBufferXSize, internalBufferYSize);
        img.updatePixels();

        //this.internalBuffer = ColorSet.convertToColorSetImage(internalBuffer, cs);
        short r, g, b;
        int rgbColor;

        //greyscale it
        for (int i = 0; i < internalBuffer.length; i++) {
            rgbColor = internalBuffer[i];
            r = (short) ((rgbColor >> 16) & 255);
            g = (short) ((rgbColor >> 8) & 255);
            b = (short) (rgbColor & 255);
            int val = (int) (r * 0.3f + g * 0.59f + b * 0.11f);
            internalBuffer[i] = val;
        }

    } catch (Exception e) {
        LOG.log(Level.WARNING, "Failed to load image {0}: {1}", new Object[] { Image.PREFIX + filename, e });
    }
}

From source file:com.inkubator.hrm.web.lazymodel.AppraisalProgramLazyDataModel.java

@Override
public AppraisalProgram getRowData(String id) {
    for (AppraisalProgram appraisalProgram : list) {
        if (StringUtils.equals(id, String.valueOf(appraisalProgram.getId()))) {
            return appraisalProgram;
        }/*from w w w.  j a  v a  2s. com*/
    }
    return null;
}

From source file:io.wcm.devops.conga.generator.util.AbstractConfigurableObjectTreeProcessor.java

private void resolveNestedObjects(Object object, ConfigurableProcessor<T> processor, T parentPayload) {
    if (object == null || object.getClass().isEnum()) {
        return;/*from  w w  w .ja va 2  s.  co m*/
    }
    try {
        Map<String, String> description = BeanUtils.describe(object);
        for (String propertyName : description.keySet()) {
            Object propertyValue = PropertyUtils.getProperty(object, propertyName);
            if (!StringUtils.equals(propertyName, "class")) {
                process(propertyValue, processor, parentPayload);
            }
        }
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new RuntimeException("Unable to get bean properties from '" + object.getClass().getName() + "'.",
                ex);
    }
}

From source file:edu.sabanciuniv.sentilab.sare.controllers.entitymanagers.AspectOpinionMinedCorpusController.java

/**
 * Finds the opinion mined corpus associated with a given corpus, lexicon, and engine code.
 * @param em the {@link EntityManager} to use.
 * @param corpus the {@link DocumentCorpus} being used to mine opinion.
 * @param lexicon the {@link AspectLexicon} being built.
 * @return the {@link AspectOpinionMinedCorpus} object found, if any; {@code null} otherwise.
 *//* w  w w .j  a  va2s.  c  o m*/
public AspectOpinionMinedCorpus findMinedCorpus(EntityManager em, DocumentCorpus corpus, AspectLexicon lexicon,
        String engineCode) {
    Validate.notNull(em, CannedMessages.NULL_ARGUMENT, "em");
    Validate.notNull(corpus, CannedMessages.NULL_ARGUMENT, "corpus");
    Validate.notNull(lexicon, CannedMessages.NULL_ARGUMENT, "lexicon");

    TypedQuery<AspectOpinionMinedCorpus> query = em.createQuery(
            "SELECT mc FROM AspectOpinionMinedCorpus mc "
                    + "WHERE mc.baseStore=:corpus AND :lexicon MEMBER OF mc.referencedObjects",
            AspectOpinionMinedCorpus.class);
    query.setParameter("corpus", corpus).setParameter("lexicon", lexicon);

    for (AspectOpinionMinedCorpus minedCorpus : query.getResultList()) {
        if (StringUtils.equals(engineCode, minedCorpus.getEngineCode())) {
            return minedCorpus;
        }
    }

    return null;
}

From source file:com.github.ferstl.depgraph.graph.style.StyleKey.java

private static boolean match(String value1, String value2) {
    return StringUtils.equals(value1, value2);
}