List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:com.lily.dap.web.util.WebUtils.java
/** * gzip./*from w w w. jav a 2s .c o m*/ */ public static boolean checkAccetptGzip(HttpServletRequest request) { // Http1.1 header String acceptEncoding = request.getHeader("Accept-Encoding"); if (StringUtils.contains(acceptEncoding, "gzip")) { return true; } else { return false; } }
From source file:com.hiperium.web.common.dto.PopupMessageDTO.java
/** * // ww w .j a v a2 s .co m * @param clientId * @param message * @param severity * @param label */ public PopupMessageDTO(String clientId, String message, Severity severity, String label) { this.clientId = clientId; this.message = message; this.severity = severity; if (StringUtils.contains(this.message, REPLACEMENT) && StringUtils.isNotBlank(label)) { this.message = this.message.replaceFirst(REPLACEMENT, label); } }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.procedure.ProcedureFunctionLabelProvicer.java
@Override public Image getColumnImage(Object element, int columnIndex) { ProcedureFunctionDAO procDao = (ProcedureFunctionDAO) element; switch (columnIndex) { case 0://w ww.j a v a 2s .co m if (procDao.isValid()) { if (StringUtils.contains(procDao.getType(), "PROCEDURE")) { return ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/objectExplorer/procedure.png"); //$NON-NLS-1$ } else if (StringUtils.contains(procDao.getType(), "FUNCTION")) { return ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/objectExplorer/function.png"); //$NON-NLS-1$ } else if (StringUtils.contains(procDao.getType(), "PACKAGE")) { return ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/objectExplorer/package.png"); //$NON-NLS-1$ } else { return ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/state/normalcy.png"); } } else { return ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/state/warning.png"); } } return null; }
From source file:com.sfs.beans.DetectBrowserBean.java
/** * Sets the request.// w w w. j a v a 2 s . c om * * @param req the new request */ public void setRequest(final HttpServletRequest req) { final String ua = req.getHeader("User-Agent"); final UserAgent userAgent = UserAgent.parseUserAgentString(ua); this.browserName = userAgent.getBrowser().getName(); if (StringUtils.contains(this.browserName, "Safari")) { this.version = "safari"; } if (StringUtils.contains(this.browserName, "Chrome")) { this.version = "chrome"; } if (StringUtils.contains(this.browserName, "Internet Explorer")) { // Assume IE8 unless proven otherwise later this.version = "ie8"; } if (StringUtils.contains(this.browserName, "Internet Explorer 7")) { this.version = "ie7"; } if (StringUtils.contains(this.browserName, "Internet Explorer 6") || StringUtils.contains(this.browserName, "Internet Explorer 5")) { this.version = "ie6"; } }
From source file:com.github.ipaas.ideploy.agent.util.ZipUtil.java
/** * // ww w . j av a 2 s . c o m * @param srcFile ? * @param targetDir * @throws Exception */ public static void unZip(String zipFile, String targetDir) throws Exception { ZipFile zipfile = new ZipFile(zipFile); try { Enumeration<ZipEntry> entries = zipfile.getEntries(); if (entries == null || !entries.hasMoreElements()) { return; } // FileUtils.forceMkdir(new File(targetDir)); // ?? while (entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); String fname = zipEntry.getName(); // if (zipEntry.isDirectory()) { String fpath = FilenameUtils.normalize(targetDir + "/" + fname); FileUtils.forceMkdir(new File(fpath)); continue; } // ? if (StringUtils.contains(fname, "/")) { String tpath = StringUtils.substringBeforeLast(fname, "/"); String fpath = FilenameUtils.normalize(targetDir + "/" + tpath); FileUtils.forceMkdir(new File(fpath)); } // ? InputStream input = null; OutputStream output = null; try { input = zipfile.getInputStream(zipEntry); String file = FilenameUtils.normalize(targetDir + "/" + fname); output = new FileOutputStream(file); IOUtils.copy(input, output); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } } finally { ZipFile.closeQuietly(zipfile); } }
From source file:com.cnd.greencube.web.base.interceptor.ListInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (modelAndView != null && modelAndView.isReference()) { String viewName = modelAndView.getViewName(); if (StringUtils.startsWith(viewName, REDIRECT_VIEW_NAME_PREFIX)) { String listQuery = WebUtils.getCookie(request, LIST_QUERY_COOKIE_NAME); if (StringUtils.isNotEmpty(listQuery)) { if (StringUtils.startsWith(listQuery, "?")) { listQuery = listQuery.substring(1); }//www .j a v a 2s. co m if (StringUtils.contains(viewName, "?")) { modelAndView.setViewName(viewName + "&" + listQuery); } else { modelAndView.setViewName(viewName + "?" + listQuery); } } } } }
From source file:com.kinglcc.spring.jms.core.DestinationType.java
private static DestinationType asTopicType(String destinationName) { if (StringUtils.contains(destinationName, SHARED_PREFIX)) { if (StringUtils.contains(destinationName, DURABLE_PREFIX)) { return SHAREDDURABLETOPIC; }//w w w . j a va2 s .co m return SHAREDTOPIC; } else if (StringUtils.contains(destinationName, DURABLE_PREFIX)) { return DURABLETOPIC; } return TOPIC; }
From source file:com.itbeyond.common.EOTrackMe.java
public static void removeSentLines(String lines) { int WriteLock_Timeout = 10; while (WriteLock_Timeout > 0) { try {/*from ww w . j a v a 2s . c o m*/ if (StringUtils.countMatches(lines, "|") == getLogFileLines()) { // Delete the log file EOTrackMe.getLogFile().delete(); } else { File logFile = EOTrackMe.getLogFile(); // We must remove already processed lines // As the file is appended String thisline; StringBuilder fullfile = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(logFile), 8192); while ((thisline = br.readLine()) != null) { if (!StringUtils.contains(lines, thisline)) { fullfile.append(thisline + "\n"); } } br.close(); logFile.delete(); logFile.createNewFile(); FileOutputStream writer = new FileOutputStream(EOTrackMe.getLogFile(), false); BufferedOutputStream output = new BufferedOutputStream(writer); output.write(fullfile.toString().getBytes()); output.flush(); output.close(); } break; } catch (IOException e) { if (WriteLock_Timeout < 5) { Utilities.LogError("EOTrackMe.removeSentLines - Write Lock", e); } try { Thread.sleep(500); } catch (InterruptedException e1) { } WriteLock_Timeout -= 1; } } }
From source file:gov.nih.nci.cabig.caaers.web.table.SortRowsCallbackImpl.java
public Collection sortRows(TableModel model, Collection rows) throws Exception { boolean sorted = model.getLimit().isSorted(); if (!sorted) { return rows; }/* w w w. jav a2 s .c o m*/ Sort sort = model.getLimit().getSort(); String property = sort.getProperty(); String sortOrder = sort.getSortOrder(); if (StringUtils.contains(property, ".")) { try { if (sortOrder.equals(TableConstants.SORT_ASC)) { Collections.sort((List) rows, new NullSafeBeanComparator(property, new NullStringComparator())); } else if (sortOrder.equals(TableConstants.SORT_DESC)) { NullSafeBeanComparator reversedNaturalOrderBeanComparator = new NullSafeBeanComparator(property, new ReverseComparator(new NullStringComparator())); Collections.sort((List) rows, reversedNaturalOrderBeanComparator); } } catch (NoClassDefFoundError e) { String msg = "The column property [" + property + "] is nested and requires BeanUtils 1.7 or greater for proper sorting."; logger.error(msg); throw new NoClassDefFoundError(msg); //just rethrow so it is not hidden } } else { if (sortOrder.equals(TableConstants.SORT_ASC)) { BeanComparator comparator = new BeanComparator(property, new NullStringComparator()); Collections.sort((List) rows, comparator); } else if (sortOrder.equals(TableConstants.SORT_DESC)) { BeanComparator reversedNaturalOrderBeanComparator = new BeanComparator(property, new ReverseComparator(new NullStringComparator())); Collections.sort((List) rows, reversedNaturalOrderBeanComparator); } } return rows; }
From source file:de.thischwa.pmcms.tool.swt.FileNameVerifier.java
@Override public void verifyText(VerifyEvent e) { String string = e.text;//from www . j av a 2 s . co m char[] chars = new char[string.length()]; string.getChars(0, chars.length, chars, 0); for (char chr : chars) { if (!(StringUtils.contains(Constants.ALLOWED_CHARS_FOR_FILES, chr))) { e.doit = false; return; } } }