List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:exec.csharp.statistics.UsageToMicroCommitRatioCalculator.java
private static boolean isDatev(ITypeName t) { return StringUtils.containsIgnoreCase(t.toString(), "datev"); }
From source file:com.adguard.filter.proxy.ProtocolDetector.java
/** * Checks first TCP packet - if it is a HTTP protocol or not * * @param packet First packet bytes/*w w w. j av a 2 s.c om*/ * @return true for HTTP */ private static boolean isHttpProtocol(byte[] packet) { if (packet == null || packet.length == 0) { return false; } int firstLineIndex = ArrayUtils.indexOf(packet, (byte) IoUtils.LF); // Minimum line length: "GET / HTTP/1.1" is 14 symbols if (firstLineIndex >= 14) { // We have a line in first packet, so we should check HTTP version // That must have been at the end of line String line = new String(packet, firstLineIndex - 10, 10, CharsetUtils.DEFAULT_HTTP_ENCODING); return StringUtils.containsIgnoreCase(line, "HTTP/"); } int firstSpaceIndex = ArrayUtils.indexOf(packet, (byte) IoUtils.SP); // Maybe packet was too small for whole packet to come in. // So we should check for valid HTTP method if (firstSpaceIndex <= 0) { return false; } String method = (new String(packet, 0, firstSpaceIndex)).trim().toUpperCase(); return HttpMethod.isValidMethod(method); }
From source file:de.micromata.genome.gwiki.page.search.SearchFoundHighlighterFilter.java
public Void filter(GWikiFilterChain<Void, GWikiServeElementFilterEvent, GWikiServeElementFilter> chain, GWikiServeElementFilterEvent event) { String words = event.getWikiContext().getRequestParameter("_gwhiwords"); if (StringUtils.isEmpty(words) == true) { return chain.nextFilter(event); }//from ww w . j a va2 s .com GWikiElement el = event.getElement(); if (el == null || (el instanceof GWikiWikiPage) == false) { return chain.nextFilter(event); } // el.getElementInfo().get HttpServletResponse resp = event.getWikiContext().getResponse(); final StringWriter sout = new StringWriter(); final PrintWriter pout = new PrintWriter(sout); final Holder<Boolean> skip = new Holder<Boolean>(Boolean.FALSE); HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(resp) { @Override public void sendRedirect(String location) throws IOException { skip.set(Boolean.TRUE); super.sendRedirect(location); } @Override public ServletOutputStream getOutputStream() throws IOException { skip.set(Boolean.TRUE); return super.getOutputStream(); } @Override public PrintWriter getWriter() throws IOException { return pout; } @Override public void resetBuffer() { sout.getBuffer().setLength(0); } }; event.getWikiContext().setResponse(wrapper); chain.nextFilter(event); if (skip.get() == Boolean.TRUE) { return null; } try { PrintWriter pr = resp.getWriter(); String orgString = sout.getBuffer().toString(); if (StringUtils.containsIgnoreCase(orgString, "<html") == false) { pr.print(orgString); return null; } StringWriter filteredContent = new StringWriter(); SearchHilightHtmlFilter filter = new SearchHilightHtmlFilter(filteredContent, Converter.parseStringTokens(words, ", ", false)); filter.doFilter(orgString); // System.out.println("\n\nOrig:\n" + sout.getBuffer().toString() + "\n\nFiltered:\n" + filteredContent.getBuffer().toString()); // pr // .println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); pr.print(filteredContent.getBuffer().toString()); } catch (IOException ex) { throw new RuntimeIOException(ex); } return null; }
From source file:io.cloudslang.content.database.utils.SQLUtils.java
/** * Some databases (Sybase) throw exceptions during a database dump. This function processes that exception, and if it is that type, builds up the output of the command * * @param sqlException The exception to analyze * @return The output of the dump command * @throws java.sql.SQLException If it was not a successful dump command's exception. *///from ww w.j a va 2 s. c o m public static String processDumpException(SQLException sqlException) throws SQLException { final String sqlState = sqlException.getSQLState(); if (sqlState != null && StringUtils.equalsIgnoreCase(sqlState, "s1000")) { SQLException f = sqlException; StringBuilder s = new StringBuilder(); s.append(f.getMessage()); while ((f = f.getNextException()) != null) { s.append("\n").append(f.getMessage()); } String str = s.toString(); if (StringUtils.containsIgnoreCase(str, "dump is complete")) return str; } throw sqlException; }
From source file:forge.gui.ImportSourceAnalyzer.java
private void identifyAndAnalyze(final File root) { // see if we can figure out the likely identity of the source folder and // dispatch to the best analysis subroutine to handle it final String dirname = root.getName(); if ("res".equalsIgnoreCase(dirname)) { analyzeOldResDir(root);/*from w w w. j av a 2s. co m*/ } else if ("constructed".equalsIgnoreCase(dirname)) { analyzeConstructedDeckDir(root); } else if ("draft".equalsIgnoreCase(dirname)) { analyzeDraftDeckDir(root); } else if ("plane".equalsIgnoreCase(dirname) || "planar".equalsIgnoreCase(dirname)) { analyzePlanarDeckDir(root); } else if ("scheme".equalsIgnoreCase(dirname)) { analyzeSchemeDeckDir(root); } else if ("sealed".equalsIgnoreCase(dirname)) { analyzeSealedDeckDir(root); } else if (StringUtils.containsIgnoreCase(dirname, "deck")) { analyzeDecksDir(root); } else if ("gauntlet".equalsIgnoreCase(dirname)) { analyzeGauntletDataDir(root); } else if ("layouts".equalsIgnoreCase(dirname)) { analyzeLayoutsDir(root); } else if ("pics".equalsIgnoreCase(dirname)) { analyzeCardPicsDir(root); } else if ("pics_product".equalsIgnoreCase(dirname)) { analyzeProductPicsDir(root); } else if ("preferences".equalsIgnoreCase(dirname)) { analyzePreferencesDir(root); } else if ("quest".equalsIgnoreCase(dirname)) { analyzeQuestDir(root); } else if (null != FModel.getMagicDb().getEditions().get(dirname)) { analyzeCardPicsSetDir(root); } else { // look at files in directory and make a semi-educated guess based on file extensions int numUnhandledFiles = 0; File[] files = root.listFiles(); assert files != null; for (final File file : files) { if (cb.checkCancel()) { return; } if (file.isFile()) { final String filename = file.getName(); if (StringUtils.endsWithIgnoreCase(filename, ".dck")) { analyzeDecksDir(root); numUnhandledFiles = 0; break; } else if (StringUtils.endsWithIgnoreCase(filename, ".jpg")) { analyzeCardPicsDir(root); numUnhandledFiles = 0; break; } ++numUnhandledFiles; } else if (file.isDirectory()) { identifyAndAnalyze(file); } } numFilesAnalyzed += numUnhandledFiles; } }
From source file:com.sketchy.server.UpgradeUploadServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONServletResult jsonServletResult = new JSONServletResult(Status.SUCCESS); try {//w w w. j a v a2s . co m boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setRepository(FileUtils.getTempDirectory()); factory.setSizeThreshold(MAX_SIZE); ServletFileUpload servletFileUpload = new ServletFileUpload(factory); List<FileItem> files = servletFileUpload.parseRequest(request); String version = ""; for (FileItem fileItem : files) { String uploadFileName = fileItem.getName(); if (StringUtils.isNotBlank(uploadFileName)) { JarInputStream jarInputStream = null; try { // check to make sure it's a Sketchy File with a Manifest File jarInputStream = new JarInputStream(fileItem.getInputStream(), true); Manifest manifest = jarInputStream.getManifest(); if (manifest == null) { throw new Exception("Invalid Upgrade File!"); } Attributes titleAttributes = manifest.getMainAttributes(); if ((titleAttributes == null) || (!StringUtils.containsIgnoreCase( titleAttributes.getValue("Implementation-Title"), "Sketchy"))) { throw new Exception("Invalid Upgrade File!"); } version = titleAttributes.getValue("Implementation-Version"); } catch (Exception e) { throw new Exception("Invalid Upgrade File!"); } finally { IOUtils.closeQuietly(jarInputStream); } // save new .jar file as "ready" fileItem.write(new File("Sketchy.jar.ready")); jsonServletResult.put("version", version); } } } } catch (Exception e) { jsonServletResult = new JSONServletResult(Status.ERROR, e.getMessage()); } response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().print(jsonServletResult.toJSONString()); }
From source file:net.gtaun.wl.race.track.TrackManagerImpl.java
@Override public List<Track> searchTrackByName(String text) { String[] keywords = text.split(" "); List<Track> list = new ArrayList<>(); for (Track track : tracks.values()) { String name = track.getName(); for (String word : keywords) if (!StringUtils.containsIgnoreCase(name, word)) continue; list.add(track);//from w w w . j a va 2s . c o m } return list; }
From source file:br.com.ararati.faces.cadastros.ProdutoFaces.java
public List<String> completeCEST(String query) { List<String> listaString = new ArrayList<>(); listaString.add("COOOOD1"); listaString.add("COOOOD2"); listaString.add("COOOOD3"); return listaString.stream().filter(v -> StringUtils.containsIgnoreCase(v, query)) .collect(Collectors.toList()); }
From source file:com.bmw.spdxeditor.editors.spdx.SPDXEditorUtility.java
/** * Determine whether licInfo represents a license considered as GPL-Like/Copyleft. * Currently these are MPL, GPL, LGPL/*ww w . ja v a 2s . co m*/ * @param licInfo * @return */ public static boolean isCopyleftLicense(SPDXLicenseInfo licInfo) { if (licInfo == null) return false; if (licInfo instanceof SPDXStandardLicense) { SPDXStandardLicense stdLic = (SPDXStandardLicense) licInfo; if (StringUtils.containsIgnoreCase(stdLic.getId(), "GPL") || StringUtils.containsIgnoreCase(stdLic.getId(), "MPL")) { return true; } } else if (licInfo instanceof SPDXLicenseSet) { SPDXLicenseSet licSet = (SPDXLicenseSet) licInfo; SPDXLicenseInfo[] licenses = licSet.getSPDXLicenseInfos(); boolean result = false; for (SPDXLicenseInfo license : licenses) { result = isCopyleftLicense(license); if (result) return true; } } return false; }
From source file:com.glaf.core.util.UploadUtils.java
/** * ????/*from w ww.j a v a2s. c o m*/ * * @param request * @param fileParam * @param fileType * ?:jpg,gif,png,jpeg,swf * @param fileSize * MB?? * @return status=0 ?<br/> * status=1 <br/> * status=2 ?<br/> */ public static int getUploadStatus(HttpServletRequest request, String fileParam, String fileType, long fileSize) { int status = 0; MultipartFile mFile = getMultipartFile(request, fileParam); if (!mFile.isEmpty()) { String ext = FileUtils.getFileExt(mFile.getOriginalFilename()); if (!StringUtils.containsIgnoreCase(fileType, ext)) { status = 1; } long size = mFile.getSize(); if (fileSize != -1 && size > FileUtils.MB_SIZE * fileSize) { status = 2; } } return status; }