List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:com.inkubator.hrm.web.workingtime.EmpCorrectionAttendanceApprovalFormController.java
@PostConstruct @Override//from w w w .jav a2 s . c o m public void initialization() { try { super.initialization(); /** initial data for approval activity tracking */ String id = FacesUtil.getRequestParameter("execution"); currentActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1))); askingRevisedActivity = approvalActivityService.getEntityByActivityNumberAndSequence( currentActivity.getActivityNumber(), currentActivity.getSequence() - 1); isWaitingApproval = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isWaitingRevised = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getRequestBy()); /** start binding data that needed (from json) to object */ Gson gson = JsonUtil.getHibernateEntityGsonBuilder() .registerTypeAdapter(Date.class, new DateJsonDeserializer()).create(); empCorrectionAttendance = gson.fromJson(currentActivity.getPendingData(), WtEmpCorrectionAttendance.class); JsonObject jsonObject = gson.fromJson(currentActivity.getPendingData(), JsonObject.class); listDetail = gson.fromJson(jsonObject.get("listDetail").getAsString(), new TypeToken<List<WtEmpCorrectionAttendanceDetail>>() { }.getType()); //relational object EmpData empData = empDataService.getByEmpIdWithDetail(empCorrectionAttendance.getEmpData().getId()); empCorrectionAttendance.setEmpData(empData); } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:io.wcm.handler.media.markup.AbstractImageMediaMarkupBuilder.java
/** * Set additional attributes on the media element from the MediaArgs properties. * @param mediaElement Media element/*from w w w .j a v a 2 s .co m*/ * @param media Media */ protected void setAdditionalAttributes(HtmlElement<?> mediaElement, Media media) { MediaArgs mediaArgs = media.getMediaRequest().getMediaArgs(); for (Entry<String, Object> entry : mediaArgs.getProperties().entrySet()) { if (StringUtils.equals(entry.getKey(), MediaNameConstants.PROP_CSS_CLASS)) { mediaElement.addCssClass(entry.getValue().toString()); } else { mediaElement.setAttribute(entry.getKey(), entry.getValue().toString()); } } }
From source file:com.adguard.filter.http.HttpMethod.java
/** * Checks if this type of request could contain entity body * * @param method Http method//from ww w .java2 s .com * @return true if there is a body */ public static boolean hasEntityBody(String method) { return StringUtils.equals(method, POST) || StringUtils.equals(method, PUT) || StringUtils.equals(method, PATCH) || StringUtils.equals(method, DELETE) || isWebDavMethod(method); }
From source file:com.streamsets.pipeline.lib.csv.CsvMultiCharDelimitedParser.java
public CsvMultiCharDelimitedParser(Reader reader, char quoteChar, char escapeChar, String fieldSeparator, int maxInputBufferSize, int maxRecordSize, boolean headerRow, long initialPosition, int skipStartLines, String lineSeparator) {// www.j av a2s .c om this.inputReader = reader; if (inputReader != null) { if (StringUtils.equals(lineSeparator, "\n") || StringUtils.equals(lineSeparator, "\r\n")) { // we can use the OverrunLineReader implementation, since it will handle such line endings this.wrappingReader = new OverrunLineReader(inputReader, maxRecordSize); } else { // we should use the OverrunCustomDelimiterReader to handle arbitrary line endings this.wrappingReader = new OverrunCustomDelimiterReader(inputReader, maxRecordSize, lineSeparator, false); } } else { this.wrappingReader = null; } this.quoteChar = quoteChar; this.escapeChar = escapeChar; this.fieldSeparator = fieldSeparator; this.maxInputBufferSize = maxInputBufferSize; this.maxRecordSize = maxRecordSize; this.lineSeparator = lineSeparator; this.parser = fields(); if (initialPosition == 0) { if (headerRow) { Utils.checkNotNull(this.wrappingReader, "wrappingReader"); try { headers = read(); } catch (IOException e) { throw new RuntimeException( String.format("IOException attempting to parse header row: %s", e.getMessage()), e); } } else { headers = null; } for (int i = 0; i < skipStartLines; i++) { try { final int numRead = wrappingReader.readLine(new StringBuilder()); if (LOG.isTraceEnabled()) { LOG.trace("Read {} bytes in skipping line number {}", numRead, i); } } catch (IOException e) { throw new RuntimeException( String.format("IOException attempting to skip %d out of %d lines in reader: %s", i, skipStartLines, e.getMessage()), e); } } } else { if (headerRow) { try { headers = read(); initialPosition -= getUnadjustedReaderPosition(); } catch (IOException e) { throw new RuntimeException( String.format("IOException attempting to parse header row: %s", e.getMessage()), e); } } else { headers = null; } try { IOUtils.skipFully(wrappingReader, initialPosition); } catch (IOException e) { throw new RuntimeException(String.format( "IOException attempting to call IOUtils.skipFully to skip %d bytes (initialPosition): %s", initialPosition, e.getMessage()), e); } } readerPositionAfterHeaders = getUnadjustedReaderPosition(); }
From source file:ch.cyberduck.core.sds.SDSCopyFeature.java
@Override public boolean isSupported(final Path source, final Path target) { if (containerService.isContainer(source)) { // Rooms cannot be copied return false; }//from w ww .j a va 2s. c o m if (containerService.getContainer(source).getType().contains(Path.Type.vault) ^ containerService.getContainer(target).getType().contains(Path.Type.vault)) { // If source xor target is encrypted data room we cannot use server side copy return false; } if (!StringUtils.equals(source.getName(), target.getName())) { // Cannot rename node to be copied at the same time return false; } if (Objects.equals(source.getParent(), target.getParent())) { // Nodes must not have the same parent return false; } return true; }
From source file:com.jdy.ddj.common.orm.PageRequest.java
/** * ???./*from w ww . j a v a 2s. co m*/ * * @param orderDir ?descasc,?','. */ public void setOrderDir(final String orderDir) { if (orderDir == null) { return; } String lowcaseOrderDir = StringUtils.lowerCase(orderDir); //order? String[] orderDirs = StringUtils.split(lowcaseOrderDir, ','); for (String orderDirStr : orderDirs) { if (!StringUtils.equals(Sort.DESC, orderDirStr) && !StringUtils.equals(Sort.ASC, orderDirStr)) { throw new IllegalArgumentException("??" + orderDirStr + "??"); } } this.orderDir = lowcaseOrderDir; }
From source file:com.mgmtp.jfunk.web.step.CheckTableCell.java
private WebElement findTable(final String attributeKey, final String attributeValue) { List<WebElement> tables = getWebDriver().findElements(By.tagName(WebConstants.TABLE)); for (WebElement table : tables) { String value = table.getAttribute(attributeKey); if (StringUtils.equals(attributeValue, value)) { return table; }//from w ww . ja v a 2s. c o m } throw new StepException("Could not find table [" + attributeKey + "=" + attributeValue + "]"); }
From source file:com.adeptj.runtime.servlet.ErrorPages.java
static void renderErrorPage(HttpServletRequest req, HttpServletResponse resp) { String statusCode = StringUtils.substringAfterLast(req.getRequestURI(), Constants.SLASH); if (StringUtils.equals(TEMPLATE_ERROR, req.getRequestURI())) { ErrorPages.renderGenericErrorPage(req, resp); } else if (StringUtils.equals(STATUS_500, statusCode)) { ErrorPages.render500Page(req, resp); } else if (RequestUtil.hasException(req) && StringUtils.equals(STATUS_500, statusCode)) { ErrorPages.render500PageWithExceptionTrace(req, resp); } else if (Configs.of().undertow().getStringList(KEY_STATUS_CODES).contains(statusCode)) { ErrorPages.renderErrorPageForStatusCode(req, resp, statusCode); } else {/*from ww w . jav a 2s.c om*/ ResponseUtil.sendError(resp, HttpServletResponse.SC_NOT_FOUND); } }
From source file:ch.cyberduck.core.openstack.SwiftAttributesFinderFeature.java
@Override public PathAttributes find(final Path file) throws BackgroundException { if (file.isRoot()) { return PathAttributes.EMPTY; }/*from ww w .j a v a2 s . c om*/ final Region region = regionService.lookup(file); try { if (containerService.isContainer(file)) { final ContainerInfo info = session.getClient().getContainerInfo(region, containerService.getContainer(file).getName()); final PathAttributes attributes = new PathAttributes(); attributes.setSize(info.getTotalSize()); attributes.setRegion(info.getRegion().getRegionId()); return attributes; } final PathAttributes attributes = new PathAttributes(); final ObjectMetadata metadata = session.getClient().getObjectMetaData(region, containerService.getContainer(file).getName(), containerService.getKey(file)); if (file.isDirectory()) { if (!StringUtils.equals("application/directory", metadata.getMimeType())) { throw new NotfoundException(String.format("Path %s is file", file.getAbsolute())); } } if (file.isFile()) { if (StringUtils.equals("application/directory", metadata.getMimeType())) { throw new NotfoundException(String.format("Path %s is directory", file.getAbsolute())); } } attributes.setSize(Long.valueOf(metadata.getContentLength())); try { attributes.setModificationDate(dateParser.parse(metadata.getLastModified()).getTime()); } catch (InvalidDateException e) { log.warn(String.format("%s is not RFC 1123 format %s", metadata.getLastModified(), e.getMessage())); } if (StringUtils.isNotBlank(metadata.getETag())) { final String etag = StringUtils.removePattern(metadata.getETag(), "\""); attributes.setETag(etag); if (metadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.NONE); } else { attributes.setChecksum(Checksum.parse(etag)); } } return attributes; } catch (GenericException e) { throw new SwiftExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch (IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } }
From source file:de.micromata.genome.util.matcher.cls.ContainsMethod.java
/** * Match this class./* ww w. j a v a 2 s. c o m*/ * * @param cls the cls * @return true, if successful */ public boolean matchThisClass(Class<?> cls) { for (Method m : cls.getMethods()) { int mods = m.getModifiers(); if (staticMethod == true && (mods & Modifier.STATIC) != Modifier.STATIC) { continue; } if (staticMethod == false && (mods & Modifier.STATIC) == Modifier.STATIC) { continue; } if (publicMethod == true && (mods & Modifier.PUBLIC) != Modifier.PUBLIC) { continue; } if (name != null) { if (StringUtils.equals(m.getName(), name) == false) { continue; } } if (returnType != null) { if (m.getReturnType() != returnType) { continue; } } if (params != null) { Class<?>[] pt = m.getParameterTypes(); if (pt.length != params.length) { continue; } for (int i = 0; i < pt.length; ++i) { if (pt[i] != params[i]) { continue; } } } return true; } return false; }