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.sonicle.webtop.core.io.input.FileRowsReader.java

public List<FieldMapping> listFieldMappings(File file, String[] targetFields, boolean strict)
        throws IOException, FileReaderException {
    ArrayList<FieldMapping> mappings = new ArrayList<>();
    HashMap<String, String> cols = listColumnNames(file);

    String lwr, source = null;//  w  w w.j a v  a2  s .  c  o m
    for (int i = 0; i < targetFields.length; i++) {
        source = null;
        lwr = targetFields[i].toLowerCase();
        if (cols.containsKey(lwr)) {
            if (!strict || StringUtils.equals(targetFields[i], cols.get(lwr))) {
                source = cols.get(lwr);
            }
        }
        mappings.add(new FieldMapping(targetFields[i], source));
    }

    return mappings;
}

From source file:com.weibo.api.motan.util.MotanFrameworkUtil.java

/**
 * url:sourceurl:target??service channel(port) ???
 * //from ww w.  j  ava 2s.  c  o  m
 * <pre>
*       1 protocol
*       2 codec 
*       3 serialize
*       4 maxContentLength
*       5 maxServerConnection
*       6 maxWorkerThread
*       7 workerQueueSize
*       8 heartbeatFactory
* </pre>
 * 
 * @param source
 * @param target
 * @return
 */
public static boolean checkIfCanShallServiceChannel(URL source, URL target) {
    if (!StringUtils.equals(source.getProtocol(), target.getProtocol())) {
        return false;
    }

    if (!StringUtils.equals(source.getParameter(URLParamType.codec.getName()),
            target.getParameter(URLParamType.codec.getName()))) {
        return false;
    }

    if (!StringUtils.equals(source.getParameter(URLParamType.serialize.getName()),
            target.getParameter(URLParamType.serialize.getName()))) {
        return false;
    }

    if (!StringUtils.equals(source.getParameter(URLParamType.maxContentLength.getName()),
            target.getParameter(URLParamType.maxContentLength.getName()))) {
        return false;
    }

    if (!StringUtils.equals(source.getParameter(URLParamType.maxServerConnection.getName()),
            target.getParameter(URLParamType.maxServerConnection.getName()))) {
        return false;
    }

    if (!StringUtils.equals(source.getParameter(URLParamType.maxWorkerThread.getName()),
            target.getParameter(URLParamType.maxWorkerThread.getName()))) {
        return false;
    }

    if (!StringUtils.equals(source.getParameter(URLParamType.workerQueueSize.getName()),
            target.getParameter(URLParamType.workerQueueSize.getName()))) {
        return false;
    }

    return StringUtils.equals(source.getParameter(URLParamType.heartbeatFactory.getName()),
            target.getParameter(URLParamType.heartbeatFactory.getName()));

}

From source file:io.wcm.handler.url.impl.UrlHandlerImpl.java

@Override
public String rewritePathToContext(final String path, final String contextPath) {
    if (StringUtils.isEmpty(path) || StringUtils.isEmpty(contextPath)) {
        return path;
    }/* ww w  . j  a  v a 2 s. co  m*/

    // split up paths
    String[] contextPathParts = StringUtils.split(contextPath, "/");
    String[] pathParts = StringUtils.split(path, "/");

    // check if both paths are valid - return unchanged path if not
    int siteRootLevelContextPath = urlHandlerConfig.getSiteRootLevel(contextPath);
    int siteRootLevelPath = urlHandlerConfig.getSiteRootLevel(path);
    if ((contextPathParts.length <= siteRootLevelContextPath) || (pathParts.length <= siteRootLevelPath)
            || !StringUtils.equals(contextPathParts[0], "content")
            || !StringUtils.equals(pathParts[0], "content")) {
        return path;
    }

    // rewrite path to current context
    StringBuilder rewrittenPath = new StringBuilder();
    for (int i = 0; i <= siteRootLevelContextPath; i++) {
        rewrittenPath.append('/').append(contextPathParts[i]);
    }
    for (int i = siteRootLevelPath + 1; i < pathParts.length; i++) {
        rewrittenPath.append('/').append(pathParts[i]);
    }
    return rewrittenPath.toString();
}

From source file:ch.cyberduck.core.sds.SDSExceptionMappingService.java

@Override
public BackgroundException map(final ApiException failure) {
    for (Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if (cause instanceof SocketException) {
            // Map Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Broken pipe
            return new DefaultSocketExceptionMappingService().map((SocketException) cause);
        }//  w  w  w  . j a  va 2 s  . c o  m
        if (cause instanceof HttpResponseException) {
            return new HttpResponseExceptionMappingService().map((HttpResponseException) cause);
        }
        if (cause instanceof IOException) {
            return new DefaultIOExceptionMappingService().map((IOException) cause);
        }
    }
    final StringBuilder buffer = new StringBuilder();
    if (null != failure.getResponseBody()) {
        final JsonParser parser = new JsonParser();
        try {
            final JsonObject json = parser.parse(new StringReader(failure.getResponseBody())).getAsJsonObject();
            if (json.has("errorCode")) {
                if (json.get("errorCode").isJsonPrimitive()) {
                    final int errorCode = json.getAsJsonPrimitive("errorCode").getAsInt();
                    if (log.isDebugEnabled()) {
                        log.debug(String.format("Failure with errorCode %s", errorCode));
                    }
                    final String key = String.format("Error %d", errorCode);
                    final String localized = LocaleFactory.get().localize(key, "SDS");
                    this.append(buffer, localized);
                    if (StringUtils.equals(localized, key)) {
                        log.warn(String.format("Missing user message for error code %d", errorCode));
                        if (json.has("debugInfo")) {
                            if (json.get("debugInfo").isJsonPrimitive()) {
                                this.append(buffer, json.getAsJsonPrimitive("debugInfo").getAsString());
                            }
                        }
                    }
                    switch (failure.getCode()) {
                    case HttpStatus.SC_NOT_FOUND:
                        switch (errorCode) {
                        case -70501:
                            // [-70501] User not found
                            return new AccessDeniedException(buffer.toString(), failure);
                        case -40761:
                            // [-40761] Filekey not found for encrypted file
                            return new AccessDeniedException(buffer.toString(), failure);
                        }
                        break;
                    case HttpStatus.SC_PRECONDITION_FAILED:
                        switch (errorCode) {
                        case -10108:
                            // [-10108] Radius Access-Challenge required.
                            if (json.has("replyMessage")) {
                                if (json.get("replyMessage").isJsonPrimitive()) {
                                    final JsonPrimitive replyMessage = json.getAsJsonPrimitive("replyMessage");
                                    if (log.isDebugEnabled()) {
                                        log.debug(String.format("Failure with replyMessage %s", replyMessage));
                                    }
                                    buffer.append(replyMessage.getAsString());
                                }
                            }
                            return new PartialLoginFailureException(buffer.toString(), failure);
                        }
                        break;
                    case HttpStatus.SC_UNAUTHORIZED:
                        switch (errorCode) {
                        case -10012:
                            // [-10012] Wrong token.
                            return new ExpiredTokenException(buffer.toString(), failure);
                        }
                        break;
                    }
                }
            } else {
                switch (failure.getCode()) {
                case HttpStatus.SC_INTERNAL_SERVER_ERROR:
                    break;
                default:
                    if (json.has("debugInfo")) {
                        log.warn(String.format("Missing error code for failure %s", json));
                        if (json.get("debugInfo").isJsonPrimitive()) {
                            this.append(buffer, json.getAsJsonPrimitive("debugInfo").getAsString());
                        }
                    }
                }
            }
        } catch (JsonParseException e) {
            // Ignore
            this.append(buffer, failure.getMessage());
        }
    }
    switch (failure.getCode()) {
    case HttpStatus.SC_PRECONDITION_FAILED:
        // [-10103] EULA must be accepted
        // [-10104] Password must be changed
        // [-10106] Username must be changed
        return new LoginFailureException(buffer.toString(), failure);
    }
    return new HttpResponseExceptionMappingService().map(failure, buffer, failure.getCode());
}

From source file:com.neophob.sematrix.core.generator.Blinkenlights.java

/**
 * load a new file.//from w w  w  . jav  a2s  .  c o  m
 *
 * @param file the file
 */
public synchronized void loadFile(String file) {
    if (StringUtils.isBlank(file)) {
        LOG.log(Level.INFO, "Empty filename provided, call ignored!");
        return;
    }

    //only load if needed
    if (!StringUtils.equals(file, this.filename)) {
        String fileToLoad = fileUtils.getBmlDir() + file;
        LOG.log(Level.INFO, "Load blinkenlights file {0}.", fileToLoad);
        if (blinken.loadFile(fileToLoad)) {
            this.filename = file;
            LOG.log(Level.INFO, "DONE");
            currentFrame = 0;
        } else {
            LOG.log(Level.INFO, "NOT DONE");
        }
    }
}

From source file:name.martingeisse.admin.navigation.NavigationMountedRequestMapper.java

@Override
protected Url buildUrl(final UrlInfo info) {
    /* This methods performs an additional check so it only maps page/parameter combinations
     * back to URLs that have the implicit navigation path parameter set to the value
     * stored in this mapper./*  w w w  .  ja v a 2 s  . c o m*/
     */
    if (StringUtils.equals(getNavigationPath(), NavigationUtil.getParameterValue(info.getPageParameters()))) {
        return super.buildUrl(info);
    } else {
        return null;
    }
}

From source file:io.kamax.mxisd.backend.rest.RestDirectoryProviderTest.java

@Test
public void byNameFound() {
    stubFor(post(urlEqualTo(endpoint))// w w  w  .j  av  a  2s  . c om
            .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(byNameResponse)));

    UserDirectorySearchResult result = p.searchByDisplayName(byNameSearch);
    assertTrue(!result.isLimited());
    assertEquals(1, result.getResults().size());
    UserDirectorySearchResult.Result entry = result.getResults().iterator().next();
    assertNotNull(entry);
    assertTrue(StringUtils.equals(byNameAvatar, entry.getAvatarUrl()));
    assertTrue(StringUtils.equals(byNameDisplay, entry.getDisplayName()));
    assertTrue(StringUtils.equals(new MatrixID(byNameId, domain).getId(), entry.getUserId()));

    verify(postRequestedFor(urlMatching(endpoint)).withHeader("Content-Type", containing("application/json"))
            .withRequestBody(equalTo(byNameRequest)));
}

From source file:net.gplatform.sudoor.server.security.model.auth.SSAuth.java

public boolean getIsPostLogin() {
    boolean result = false;
    String currentUser = getCurrentUser();
    result = StringUtils.isNotEmpty(currentUser) && !StringUtils.equals("anonymousUser", currentUser);
    return result;
}

From source file:com.sungtech.goodTeacher.action.TeacherInfoAction.java

@Override
public String execute() throws Exception {
    Map<String, Object> teacherMap = null, temp;
    temp = Util.resultMap.get(openId);
    if (temp != null) {
        Map<String, Object> categoryMap = (Map<String, Object>) temp.get("data");
        List<Map<String, Object>> teacherList = (List<Map<String, Object>>) categoryMap.get("userList");
        for (int i = 0; i < teacherList.size(); i++) {
            temp = teacherList.get(i);//from   www .j ava  2  s.  c  om
            if (StringUtils.equals(temp.get("userId").toString(), userId.trim()))
                teacherMap = temp;
        }
    }
    if (teacherMap != null) {
        this.setTeacherInfo(teacherMap);
    } else
        this.loadTeacherInfo(this.userId);

    String url = "http://www.kaopuu.com/gtapi/app/get_teach_course_list?format=json&count=10&page=1&userId="
            + userId;
    String teacherInfo = Util.httpUrlRequest(url);
    Map<String, Object> tempMap = gson.fromJson(teacherInfo, new TypeToken<Map<String, Object>>() {
    }.getType());
    List<Map<String, String>> glist = (List<Map<String, String>>) tempMap.get("data");
    if (glist != null && !glist.isEmpty()) {
        for (int i = 0; i < glist.size(); i++) {
            Map<String, String> map = glist.get(i);
            String dt = map.get("teachTime");
            map.put("teachTime", setTeachTime(dt));
            dt = map.get("unit");
            map.put("unit", setPriceUnit(dt));
        }
    }
    this.dataList = glist;
    if (StringUtils.isEmpty(this.college))
        this.college = "";
    if (StringUtils.isEmpty(this.description))
        this.description = "";
    // else
    // this.description = this.description.replace("\n", "<br/>");
    return SUCCESS;
}

From source file:de.knightsoftnet.validationexample.shared.models.LoginData.java

@Override
public final boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//from www .  ja  va2s .c o  m
    if (obj == null) {
        return false;
    }
    if (this.getClass() != obj.getClass()) {
        return false;
    }
    final LoginData other = (LoginData) obj;
    return StringUtils.equals(this.userName, other.userName);
}