List of usage examples for org.apache.commons.lang StringUtils equals
public static boolean equals(String str1, String str2)
Compares two Strings, returning true
if they are equal.
From source file:com.voa.weixin.handler.Router.java
/** * ??ReciveMessage/*from ww w .ja v a 2 s. c o m*/ * @param recieveMsg * @return */ public static RecieveMessage generateMsg(String recieveMsg) { RecieveMessage message = null; try { Document doc = DocumentHelper.parseText(recieveMsg); Element root = doc.getRootElement(); String type = root.elementText("MsgType"); if (StringUtils.equals(type, MessageType.TYPE_TEXT)) { message = new RecieveTxtMessage(recieveMsg, root); } else if (StringUtils.equals(type, MessageType.TYPE_IMAGE)) { message = new RecieveImgMessage(recieveMsg, root); } else if (StringUtils.equals(type, MessageType.TYPE_VOICE)) { message = new RecieveVoiceMessage(recieveMsg, root); } else if (StringUtils.equals(type, MessageType.TYPE_VIDEO)) { message = new RecieveVedioMessage(recieveMsg, root); } else if (StringUtils.equals(type, MessageType.TYPE_LOCATION)) { message = new RecieveLocationMessage(recieveMsg, root); } else if (StringUtils.equals(type, MessageType.TYPE_LINK)) { message = new RecieveLinkMessage(recieveMsg, root); } else if (StringUtils.equals(type, MessageType.TYPE_EVENT)) { String event = root.elementText("Event"); if (StringUtils.equals(event, MessageType.EVENT_SUBSCRIBE)) { if (root.elementText("EventKey") == null) message = new RecieveEvent(recieveMsg, root); else message = new RecieveTicketEvent(recieveMsg, root); } else if (StringUtils.equals(event, MessageType.EVENT_SCAN)) { message = new RecieveTicketEvent(recieveMsg, root); } else if (StringUtils.equals(event, MessageType.EVENT_LOCATION)) { message = new RecieveLocationEvent(recieveMsg, root); } else if (StringUtils.equals(event, MessageType.EVENT_CLICK)) { message = new RecieveMenuEvent(recieveMsg, root); } } } catch (Exception e) { throw new HandlerException("RecieveMessage parse error.", e); } return message; }
From source file:com.qualitesys.sonarqcr4pblplugin.pbl.PblPackage.java
public boolean isDefault() { return StringUtils.equals(getKey(), DEFAULT_PACKAGE_NAME); }
From source file:net.shopxx.interceptor.TokenInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String token = WebUtils.getCookie(request, TOKEN_COOKIE_NAME); if (StringUtils.equalsIgnoreCase(request.getMethod(), "POST")) { if (StringUtils.isNotEmpty(token)) { String requestType = request.getHeader("X-Requested-With"); if (StringUtils.equalsIgnoreCase(requestType, "XMLHttpRequest")) { if (StringUtils.equals(token, request.getHeader(TOKEN_PARAMETER_NAME))) { return true; } else { response.addHeader("tokenStatus", "accessDenied"); }//ww w . ja v a2s .com } else { if (StringUtils.equals(token, request.getParameter(TOKEN_PARAMETER_NAME))) { return true; } } } else { WebUtils.addCookie(request, response, TOKEN_COOKIE_NAME, DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30))); } response.sendError(HttpServletResponse.SC_FORBIDDEN, ERROR_MESSAGE); return false; } else { if (StringUtils.isEmpty(token)) { token = DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30)); WebUtils.addCookie(request, response, TOKEN_COOKIE_NAME, token); } request.setAttribute(TOKEN_ATTRIBUTE_NAME, token); return true; } }
From source file:com.adobe.acs.commons.util.CookieUtil.java
/** * Get the named cookie from the HTTP Request * * @param request Request to get the Cookie from * @param cookieName name of Cookie to get * @return the named Cookie, null if the named Cookie cannot be found *//*from w w w . ja v a2s. c o m*/ public static Cookie getCookie(final HttpServletRequest request, final String cookieName) { if (StringUtils.isBlank(cookieName)) { return null; } final Cookie[] cookies = request.getCookies(); if (cookies == null) { return null; } if (cookies.length > 0) { for (final Cookie cookie : cookies) { if (StringUtils.equals(cookieName, cookie.getName())) { return cookie; } } } return null; }
From source file:mitm.application.djigzo.impl.NamedCertificateUtils.java
/** * Returns a set of Certificates from the provided namedCertificate with the given name. * If namedCertificates is null an empty set is returned. *///from w w w . j a va 2 s . c o m public static Set<X509Certificate> getByName(String name, Collection<NamedCertificate> namedCertificates) { Set<X509Certificate> matching = new HashSet<X509Certificate>(); if (namedCertificates != null) { for (NamedCertificate namedCertificate : namedCertificates) { if (StringUtils.equals(name, namedCertificate.getName())) { X509Certificate certificate = namedCertificate.getCertificate(); if (certificate != null) { matching.add(certificate); } } } } return matching; }
From source file:eu.europeana.corelib.edm.utils.construct.LicenseUpdater.java
@Override public LicenseImpl update(LicenseImpl mongoEntity, LicenseImpl newEntity, MongoServer mongoServer) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Query<LicenseImpl> updateQuery = mongoServer.getDatastore().createQuery(LicenseImpl.class).field("about") .equal(mongoEntity.getAbout()); UpdateOperations<LicenseImpl> ops = mongoServer.getDatastore().createUpdateOperations(LicenseImpl.class); boolean update = false; if (mongoEntity.getCcDeprecatedOn() != newEntity.getCcDeprecatedOn()) { if (mongoEntity.getCcDeprecatedOn() == null) { newEntity.setCcDeprecatedOn(null); ops.unset("ccDeprecatedOn"); update = true;//from ww w. j ava 2 s. com } else { newEntity.setCcDeprecatedOn(mongoEntity.getCcDeprecatedOn()); ops.set("ccDeprecatedOn", mongoEntity.getCcDeprecatedOn()); update = true; } } if (!StringUtils.equals(mongoEntity.getOdrlInheritFrom(), newEntity.getOdrlInheritFrom())) { if (mongoEntity.getOdrlInheritFrom() == null) { newEntity.setOdrlInheritFrom(null); ops.unset("odrlInheritFrom"); update = true; } else { newEntity.setOdrlInheritFrom(mongoEntity.getOdrlInheritFrom()); ops.set("odrlInheritFrom", mongoEntity.getOdrlInheritFrom()); update = true; } } if (update) { mongoServer.getDatastore().update(updateQuery, ops); } return mongoEntity; }
From source file:com.opengamma.language.install.ConfigureMain.java
@Override public void run() { final ConfigurationUrlDialog dialog = new ConfigurationUrlDialog(); final String urlOriginal = getProperty("opengamma.configuration.url"); if (urlOriginal != null) { dialog.setUrl(urlOriginal);/*from w w w. j a v a 2s .co m*/ } dialog.setAlwaysOnTop(true); dialog.setVisible(true); final String urlNew = dialog.getUrl(); if (urlNew != null) { if (!StringUtils.equals(urlOriginal, urlNew)) { setProperty("opengamma.configuration.url", urlNew); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaUpload.java
/** * Note: this is just a hint for browser, user may select files that do not meet this property * * @param accept mime types, comma separated *///from w w w.java2 s. c o m @Override public void setAccept(String accept) { if (!StringUtils.equals(accept, getAccept())) { getState().accept = accept; } }
From source file:com.cloudera.nav.sdk.model.custom.Namespace.java
public boolean isDefaultNamespace() { return StringUtils.equals(DEFAULT_NAMESPACE_NAME, getName()); }
From source file:ddf.registry.service.internal.DynamicServiceResolverRegistry.java
@Override public String getFactoryPid(String serviceType) { for (DynamicServiceIdentifier identifier : identifiers) { if (StringUtils.equals(serviceType, identifier.getServiceType())) { return identifier.getFactoryIdentifier(); }/*from w ww . j a v a2 s . co m*/ } LOGGER.info("No Factory PID found for {}, returning a 'null' PID.", serviceType); return null; }