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:hydrograph.ui.expression.editor.evaluate.FieldNameAndValueCellModifier.java

/**
 * Modifies the element/* w ww  .  j av a  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 (element instanceof Item)
        element = ((Item) element).getData();

    FieldNameAndValue fieldNameAndValue = (FieldNameAndValue) element;

    if (StringUtils.equals(EvalDialogFieldTable.FIELD_NAME_PROPERTY, property)) {
        fieldNameAndValue.setFieldName((String) value);
    } else if (StringUtils.equals(EvalDialogFieldTable.FIELD_VALUE_PROPERTY, property)) {
        fieldNameAndValue.setFieldValue((String) value);
    }

    viewer.refresh();
}

From source file:com.sfs.whichdoctor.beans.PhoneBean.java

/**
 * Compare the existing phone number with the updated version. If the two
 * are different return true.//from w w  w. j  av  a2s. c o m
 *
 * @param updated the updated
 *
 * @return boolean different
 */
public final boolean compare(final PhoneBean updated) {
    boolean different = false;

    if (updated == null) {
        different = true;
    } else {
        if (!StringUtils.equals(OutputFormatter.getPhoneNumber(this, true),
                OutputFormatter.getPhoneNumber(updated, true))) {
            different = true;
        }
        if (this.getPrimary() != updated.getPrimary()) {
            different = true;
        }
        if (!StringUtils.equals(this.getContactType(), updated.getContactType())) {
            different = true;
        }
    }
    return different;
}

From source file:com.xx_dev.apn.proxy.ApnProxyPreHandler.java

private boolean preCheck(ChannelHandlerContext ctx, Object msg) {
    if (msg instanceof HttpRequest) {
        HttpRequest httpRequest = (HttpRequest) msg;

        String originalHost = HostNamePortUtil.getHostName(httpRequest);

        LoggerUtil.info(httpRestLogger, ctx.channel().remoteAddress().toString(),
                httpRequest.getMethod().name(), httpRequest.getUri(), httpRequest.getProtocolVersion().text(),
                httpRequest.headers().get(HttpHeaders.Names.USER_AGENT));

        isPacRequest = false;// w w w .j av a  2  s.c  om

        // pac request
        if (StringUtils.equals(originalHost, ApnProxyConfig.getConfig().getPacHost())) {
            isPacRequest = true;

            String pacContent = null;
            if (ApnProxyConfig.getConfig().getListenType() == ApnProxyListenType.SSL) {
                pacContent = buildPacForSsl();
            } else {
                pacContent = buildPacForPlain();
            }

            ByteBuf pacResponseContent = Unpooled.copiedBuffer(pacContent, CharsetUtil.UTF_8);
            FullHttpMessage pacResponseMsg = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
                    HttpResponseStatus.OK, pacResponseContent);
            HttpHeaders.setContentLength(pacResponseMsg, pacResponseContent.readableBytes());
            HttpHeaders.setHeader(pacResponseMsg, "X-APN-PROXY-PAC", "OK");
            HttpHeaders.setHeader(pacResponseMsg, "X-APN-PROXY-URL", "https://github.com/apn-proxy/apn-proxy");
            HttpHeaders.setHeader(pacResponseMsg, "X-APN-PROXY-MSG", "We need more commiters!");

            ctx.write(pacResponseMsg);
            ctx.flush();
            return false;
        }

        // forbid request to proxy server internal network
        for (String forbiddenIp : forbiddenIps) {
            if (StringUtils.startsWith(originalHost, forbiddenIp)) {
                String errorMsg = "Forbidden";
                ctx.write(HttpErrorUtil.buildHttpErrorMessage(HttpResponseStatus.FORBIDDEN, errorMsg));
                ctx.flush();
                return false;
            }
        }

        // forbid request to proxy server local
        if (StringUtils.equals(originalHost, "127.0.0.1") || StringUtils.equals(originalHost, "localhost")) {
            String errorMsg = "Forbidden Host";
            ctx.write(HttpErrorUtil.buildHttpErrorMessage(HttpResponseStatus.FORBIDDEN, errorMsg));
            ctx.flush();
            return false;
        }

        // forbid reqeust to some port
        int originalPort = HostNamePortUtil.getPort(httpRequest);
        for (int fobiddenPort : forbiddenPorts) {
            if (originalPort == fobiddenPort) {
                String errorMsg = "Forbidden Port";
                ctx.write(HttpErrorUtil.buildHttpErrorMessage(HttpResponseStatus.FORBIDDEN, errorMsg));
                ctx.flush();
                return false;
            }
        }

    } else {
        if (isPacRequest) {
            return false;
        }
    }

    return true;
}

From source file:hydrograph.ui.engine.parsing.XMLHandler.java

/**
 * @param uri//  ww w.ja v  a 2 s.com
 * @param localName
 * @param qName
 * @param attributes
 * @throws SAXException
 */
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    List<ParameterData> tempParammeterList;
    Matcher matcher = null;
    if (isComponent(qName)) {
        currentComponent = attributes.getValue(ID);
        List<ParameterData> emptyList = new ArrayList<>();
        componentRepo.getParammeterFactory().put(currentComponent, emptyList);
    }
    if (qName.equalsIgnoreCase(INSOCKET_TAG)) {
        storeInSocket(attributes);
    }

    if (attributes.getValue(VALUE) != null) {
        matcher = Pattern.compile(REGEX).matcher(attributes.getValue(VALUE));
        if (matcher.matches()) {
            tempParammeterList = componentRepo.getParammeterFactory().get(currentComponent);
            if (tempParammeterList != null) {
                if (StringUtils.equals(qName, PropertyNameConstants.PROPERTY_TAG.value())) {
                    tempParammeterList.add(new ParameterData(qName,
                            attributes.getValue(NAME) + "=" + attributes.getValue(VALUE)));
                } else
                    tempParammeterList.add(new ParameterData(qName, attributes.getValue(VALUE)));
            }
        }
    }
}

From source file:de.csdev.ebus.command.datatypes.ext.EBusTypeDate.java

@Override
public EBusDateTime decodeInt(byte[] data) throws EBusTypeException {

    if (data == null) {
        // TODO replace value
        return null;
    }//from   ww w .  ja va 2s . c o  m

    IEBusType<BigDecimal> bcdType = types.getType(EBusTypeBCD.TYPE_BCD);
    IEBusType<BigDecimal> wordType = types.getType(EBusTypeWord.TYPE_WORD);
    IEBusType<BigDecimal> charType = types.getType(EBusTypeChar.TYPE_CHAR);

    Calendar calendar = new GregorianCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    BigDecimal day = null;
    BigDecimal month = null;
    BigDecimal year = null;

    if (data.length != getTypeLength()) {
        throw new EBusTypeException(
                String.format("Input byte array must have a length of %d bytes!", getTypeLength()));
    }

    if (StringUtils.equals(variant, SHORT)) {
        day = bcdType.decode(new byte[] { data[0] });
        month = bcdType.decode(new byte[] { data[1] });
        year = bcdType.decode(new byte[] { data[2] });

    } else if (StringUtils.equals(variant, DEFAULT)) {
        day = bcdType.decode(new byte[] { data[0] });
        month = bcdType.decode(new byte[] { data[1] });
        year = bcdType.decode(new byte[] { data[3] });

    } else if (StringUtils.equals(variant, HEX_SHORT)) {
        day = charType.decode(new byte[] { data[0] });
        month = charType.decode(new byte[] { data[1] });
        year = charType.decode(new byte[] { data[2] });

    } else if (StringUtils.equals(variant, HEX)) {
        day = charType.decode(new byte[] { data[0] });
        month = charType.decode(new byte[] { data[1] });
        year = charType.decode(new byte[] { data[3] });

    } else if (StringUtils.equals(variant, DAYS)) {
        BigDecimal daysSince1900 = wordType.decode(data);
        calendar.set(1900, 0, 1, 0, 0);
        calendar.add(Calendar.DAY_OF_YEAR, daysSince1900.intValue());
    }

    if (day != null && month != null && year != null) {
        if (day.intValue() < 1 || day.intValue() > 31) {
            throw new EBusTypeException("A valid day must be in a range between 1-31 !");
        }
        if (month.intValue() < 1 || month.intValue() > 12) {
            throw new EBusTypeException("A valid day must be in a range between 1-12 !");
        }
    }

    if (year != null) {
        if (year.intValue() < 70) {
            year = year.add(new BigDecimal(2000));
        } else {
            year = year.add(new BigDecimal(1900));
        }
        calendar.set(Calendar.YEAR, year.intValue());
    }

    if (month != null) {
        calendar.set(Calendar.MONTH, month.intValue() - 1);
    }

    if (day != null && day.intValue() > 0 && day.intValue() < 32) {
        calendar.set(Calendar.DAY_OF_MONTH, day.intValue());
    }

    return new EBusDateTime(calendar, false, true);
}

From source file:com.alipay.mile.benchmark.Workload.java

public boolean doTransaction(ClientWrapper db) {
    String op = operationChooser.nextString();
    boolean result = false;
    for (Entry<String, CmdProvider> entry : operations.entrySet()) {
        if (StringUtils.equals(entry.getKey(), op)) {
            result = db.execute(entry.getValue());
            break;
        }// ww  w .  ja  va 2s  . c  om
    }
    return result;
}

From source file:com.adobe.acs.samples.resources.impl.SampleResourceDecorator.java

private boolean accepts(final Resource resource) {
    if (resource == null) {
        return false;
    }//w  ww.  j  a  v  a 2s  . c om

    if (StringUtils.equals(resource.getPath(), "/some/path")) {
        return true;
    } else {
        return false;
    }

    // Note: If you are checking if a resource should be decorated based on resource type,
    // Using ResourceUtil.isA(..) will send this into an infinite recursive lookup loop
}

From source file:gov.nih.nci.cabig.caaers.domain.SAEReportPreExistingCondition.java

/**
 * Will return true, if this object has the same 'other' and 'preexistingcondition'.
 *
 * @param cond the cond/* w ww .  ja  va  2  s.  c o  m*/
 * @param other the other
 * @return true, if successful
 */
public boolean equals(PreExistingCondition cond, String other) {
    return StringUtils.equals(this.other, other) && ObjectUtils.equals(cond, this.preExistingCondition);
}

From source file:jp.co.opentone.bsol.linkbinder.subscriber.ElasticsearchDocumentSubscriber.java

@Override
public void onMessage(String channel, String message) {
    log.info("[{}] RECEIVED: {}, {}", new Object[] { getClass().getSimpleName(), channel, message });
    CorresponEvent event = parseJsonMessage(message, CorresponEvent.class);
    try {/*from   w w w.java 2 s. c  o m*/
        setupProcessContext(event.getProjectId());

        Correspon correspon = corresponService.find(event.getId());
        List<Attachment> attachments = corresponService.findAttachments(correspon.getId());

        if (StringUtils.equals(CorresponDeleted.NAME, event.getEventName())) {
            log.info("[{}] DELETE from index: {}", getClass().getSimpleName(), correspon.getId());
            service.deleteFromIndex(correspon, attachments);
        } else {
            log.info("[{}] ADD to index: {}", getClass().getSimpleName(), correspon.getId());
            imageTextDetectionService.detectTextAndFill(attachments);
            service.addToIndex(correspon, attachments);
        }

    } catch (ServiceAbortException | RuntimeException e) {
        log.error("index??????", e);
    }
}

From source file:com.funambol.framework.tools.beans.SimpleCloneableBean.java

@Override
public boolean equals(Object o) {
    if (!(o instanceof SimpleCloneableBean)) {
        return false;
    }/* w w  w.jav a2 s . co m*/
    SimpleCloneableBean clBean = (SimpleCloneableBean) o;
    return (StringUtils.equals(prop1, clBean.prop1) && StringUtils.equals(prop2, clBean.prop2));
}