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:de.jcup.egradle.eclipse.ui.AbstractMarkerHelper.java

private IMarker findMarker(IResource resource, String message, int lineNumber, String type)
        throws CoreException {
    IMarker[] marker = resource.findMarkers(type, true, IResource.DEPTH_ZERO);
    for (int i = 0; i < marker.length; i++) {
        IMarker currentMarker = marker[i];
        if (currentMarker == null) {
            continue;
        }//from  ww  w.ja  v a 2  s .  co m
        Object lineNrAttribute = currentMarker.getAttribute(IMarker.LINE_NUMBER);
        String markerLineNumber = null;
        if (lineNrAttribute != null) {
            markerLineNumber = lineNrAttribute.toString();
        }
        Object messageAttribute = currentMarker.getAttribute(IMarker.MESSAGE);
        String markerMessage = null;
        if (messageAttribute != null) {
            markerMessage = messageAttribute.toString();
        }
        boolean sameMessageAndLineNr = StringUtils.equals(markerLineNumber, String.valueOf(lineNumber))
                && StringUtils.equals(markerMessage, message);
        if (sameMessageAndLineNr) {
            return currentMarker;
        }
    }
    return null;
}

From source file:ee.ria.xroad.proxy.testsuite.testcases.SplitHeaderMessage.java

@SuppressWarnings("unchecked")
private static void validateFieldValue(Message message) throws Exception {
    SoapMessageImpl msg = (SoapMessageImpl) new SoapParserImpl().parse(message.getContentType(),
            new ByteArrayInputStream(((SoapMessageImpl) message.getSoap()).getBytes()));
    String value = null;/*w ww  .  j ava2 s . co m*/
    Iterator<SOAPHeaderElement> h = msg.getSoap().getSOAPHeader().examineAllHeaderElements();
    while (h.hasNext()) {
        SOAPHeaderElement header = h.next();
        if (header.getElementName().getLocalName().equals("issue")) {
            value = header.getValue();
        }
    }
    if (!StringUtils.equals(EXPECTED_VALUE, value)) {
        String diff = StringUtils.difference(EXPECTED_VALUE, value);
        throw new Exception(
                "Unexpected field value (difference starting at" + " index : " + value.indexOf(diff) + ")");
    }
}

From source file:de.micromata.genome.gwiki.plugin.forum_1_0.GWikiForumDescription.java

public GWikiForumDescription(GWikiContext wikiContext, GWikiElementInfo elementInfo) {
    this.wikiContext = wikiContext;
    this.elementInfo = elementInfo;

    List<GWikiElementInfo> eis = wikiContext.getElementFinder().getPageDirectPages(elementInfo.getId());
    for (GWikiElementInfo ei : eis) {
        String mtid = "";
        if (ei.getMetaTemplate() != null) {
            mtid = ei.getMetaTemplate().getPageId();
        }//from   w ww  .j  a  v  a 2 s . co  m
        if (StringUtils.equals(mtid, "admin/templates/Forum1_0MetaTemplate") == true) {
            GWikiForumDescription fd = new GWikiForumDescription(wikiContext, ei);
            childForums.add(fd);
        } else if (StringUtils.equals(mtid, "admin/templates/ForumPost1_0MetaTemplate") == true) {
            GWikiForumPostDescription postdesc = new GWikiForumPostDescription(elementInfo, ei);
            posts.add(postdesc);
        }
    }
}

From source file:com.neophob.sematrix.gui.callback.GuiState.java

/**
 * /*from w  ww  . jav  a2s  .  com*/
 * @param currentState
 * @param newState
 * @return
 */
private Map<String, String> getDifference(Map<String, String> newState) {
    Map<String, String> ret = new HashMap<String, String>();

    for (Map.Entry<String, String> e : newState.entrySet()) {
        if (state.containsKey(e.getKey())) {
            String currentValue = state.get(e.getKey());
            if (!StringUtils.equals(e.getValue(), currentValue)) {
                //value differs, add it
                ret.put(e.getKey(), e.getValue());
            }
        } else {
            //new value was not part of the old state - add it
            ret.put(e.getKey(), e.getValue());
        }
    }

    return ret;
}

From source file:com.glaf.activiti.xml.BpmnXmlReader.java

public List<ActivityInfo> read(Element root, String processDefinitionKey) {
    List<ActivityInfo> activities = new java.util.ArrayList<ActivityInfo>();
    Element element = root.element("BPMNDiagram");
    if (element != null) {
        List<?> elements = element.elements("BPMNPlane");
        if (elements != null && !elements.isEmpty()) {
            Iterator<?> iterator = elements.iterator();
            while (iterator.hasNext()) {
                Element elem = (Element) iterator.next();
                String attr = elem.attributeValue("bpmnElement");
                if (StringUtils.equals(attr, processDefinitionKey)) {
                    List<?> elems = elem.elements("BPMNShape");
                    if (elems != null && !elems.isEmpty()) {
                        Iterator<?> iter = elems.iterator();
                        while (iter.hasNext()) {
                            Element em = (Element) iter.next();
                            Element e = em.element("Bounds");
                            if (e != null) {
                                ActivityInfo info = new ActivityInfo();
                                info.setActivityId(em.attributeValue("bpmnElement"));
                                ActivityCoordinates coord = new ActivityCoordinates();
                                coord.setHeight(Double.valueOf(e.attributeValue("height")));
                                coord.setWidth(Double.valueOf(e.attributeValue("width")));
                                coord.setX(Double.valueOf(e.attributeValue("x")));
                                coord.setY(Double.valueOf(e.attributeValue("y")));
                                info.setCoordinates(coord);
                                activities.add(info);
                            }//from  w w  w. j  a v  a2s  .c  o  m
                        }
                    }
                }
            }
        }
    }

    return activities;
}

From source file:edu.ku.kuali.kra.negotiations.service.NegotiationServiceImpl.java

@Override
public List<NegotiationActivityHistoryLineBean> getNegotiationActivityHistoryLineBeans(
        List<NegotiationActivity> activities) {
    List<NegotiationActivityHistoryLineBean> beans = new ArrayList<NegotiationActivityHistoryLineBean>();
    for (NegotiationActivity activity : activities) {
        if (activity.getLocation() != null && activity.getActivityType() != null) {
            NegotiationActivityHistoryLineBean bean = new NegotiationActivityHistoryLineBean(activity);
            beans.add(bean);/*ww  w . ja va2  s .c  o  m*/
        }
    }
    Collections.sort(beans);

    // now set the effective dates and calculate the location days.
    Date previousStartDate = null;
    Date previousEndDate = null;
    String previousLocation = "";
    int counter = 1;
    List<NegotiationActivityHistoryLineBean> beansToReturn = new ArrayList<NegotiationActivityHistoryLineBean>();
    for (NegotiationActivityHistoryLineBean bean : beans) {
        if (StringUtils.equals(previousLocation, bean.getLocation())) {
            if (isDateBetween(bean.getStartDate(), previousStartDate, previousEndDate)
                    && isDateBetween(bean.getEndDate(), previousStartDate, previousEndDate)) {
                // current date range lies within the previous date range
                setBeanStuff(bean, null, null, "0 Days");
                // leave previous alone
            } else if (isDateBetween(bean.getStartDate(), previousStartDate, previousEndDate)
                    && (bean.getEndDate() != null) && bean.getEndDate().after(previousEndDate)) {
                // current date range starts within the previous range, but
                // finishes past it.
                Date previousEndDatePlusOneDay = new Date(
                        previousEndDate.getTime() + NegotiationActivity.MILLISECS_PER_DAY);
                previousEndDate = bean.getEndDate();
                setBeanStuff(bean, previousEndDatePlusOneDay, bean.getEndDate(),
                        NegotiationActivity.getNumberOfDays(previousEndDatePlusOneDay, bean.getEndDate()));
            } else {
                // completely separate range.
                previousStartDate = bean.getStartDate();
                previousEndDate = bean.getEndDate();
                setBeanStuff(bean, bean.getStartDate(), bean.getEndDate(),
                        NegotiationActivity.getNumberOfDays(bean.getStartDate(), bean.getEndDate()));
            }
        } else {
            // new location so set the effective date
            previousStartDate = bean.getStartDate();
            previousEndDate = bean.getEndDate();
            previousLocation = bean.getLocation();
            setBeanStuff(bean, bean.getStartDate(), bean.getEndDate(),
                    NegotiationActivity.getNumberOfDays(bean.getStartDate(), bean.getEndDate()));

            // BUKC-0150: Negotiation - Line skip on Activity/Location History page (Neg. QA Testing Issue 13)
            /*
             * if (!beansToReturn.isEmpty()) {
             * beansToReturn.add(new NegotiationActivityHistoryLineBean());
             * }
             */
        }
        bean.setLineNumber(String.valueOf(counter));
        beansToReturn.add(bean);
        counter++;
    }
    return beansToReturn;
}

From source file:com.anrisoftware.sscontrol.httpd.nginx.nginx.linux.SimpleDurationRenderer.java

@Override
public String toString(Object o, String formatString, Locale locale) {
    Duration duration = (Duration) o;
    if (StringUtils.equals(formatString, SIMPLE_ROUND_KEY)) {
        return DurationSimpleFormat.roundSizeUnit(duration.getMillis());
    }/* w  ww.  j a  v a 2 s.  co m*/
    if (startsWith(formatString, SIMPLE_KEY)) {
        return toStringSimple(formatString, duration);
    } else {
        return duration.toString();
    }
}

From source file:de.micromata.tpsb.doc.parser.JavaDocInfo.java

public String getParamDoc(String paramName) {
    if (tags.get("@param") == null) {
        return StringUtils.EMPTY;
    }/*from  ww  w  .j  av  a2 s. c o  m*/
    List<Pair<String, String>> params = tags.get("@param");
    for (Pair<String, String> param : params) {
        if (StringUtils.equals(paramName, param.getFirst()) == true) {
            return param.getSecond();
        }
    }
    return StringUtils.EMPTY;
}

From source file:com.stefanbrenner.droplet.ui.actions.StartAction.java

@Override
public void actionPerformed(final ActionEvent event) {
    ISerialCommunicationService serialCommProvider = Configuration.getSerialCommProvider();
    IDropletMessageProtocol messageProtocolProvider = Configuration.getMessageProtocolProvider();

    // send configuration if it changed since last send
    String setMessage = messageProtocolProvider.createSetMessage(getDroplet());
    if (!StringUtils.equals(setMessage, getDropletContext().getLastSetMessage())) {
        String resetMessage = messageProtocolProvider.createResetMessage();
        serialCommProvider.sendData(resetMessage);
        serialCommProvider.sendData(setMessage);
        getDropletContext().setLastSetMessage(setMessage);
    }//from w w  w .  ja  v a2  s  . c o  m

    Integer rounds = getDropletContext().getRounds();
    Integer roundDelay = getDropletContext().getRoundDelay();

    String message = messageProtocolProvider.createStartMessage(rounds, roundDelay);
    serialCommProvider.sendData(message);
}

From source file:de.knightsoftnet.navigation.shared.models.MinimumUser.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//  w  w  w.  j ava  2  s .c  o  m
    if (obj == null) {
        return false;
    }
    if (this.getClass() != obj.getClass()) {
        return false;
    }
    final MinimumUser other = (MinimumUser) obj;
    return StringUtils.equals(this.userName, other.userName);
}