List of usage examples for org.apache.commons.lang StringUtils endsWithIgnoreCase
public static boolean endsWithIgnoreCase(String str, String suffix)
Case insensitive check if a String ends with a specified suffix.
From source file:azkaban.reportal.util.ReportalHelper.java
public static String[] filterCSVFile(String[] files) { List<String> result = new ArrayList<String>(); for (int i = 0; i < files.length; i++) { if (StringUtils.endsWithIgnoreCase(files[i], ".csv")) { result.add(files[i]);/*from w w w .j a v a 2s . c o m*/ } } return result.toArray(new String[result.size()]); }
From source file:com.iyonger.apm.web.service.AgentManagerService.java
@Override public Map<String, MutableInt> getAvailableAgentCountMap(User user) { int availableShareAgents = 0; int availableUserOwnAgent = 0;//debug TODO String myAgentSuffix = "owned_" + user.getUserId(); for (GrinderAgentInfo grinderAgentInfo : getAllActive()) { // Skip all agents which are disapproved, inactive or // have no region prefix. if (!grinderAgentInfo.isApproved()) { continue; }/*from w w w .j ava 2 s . co m*/ String fullRegion = grinderAgentInfo.getRegion(); // It's this controller's agent if (StringUtils.endsWithIgnoreCase(fullRegion, myAgentSuffix)) { availableUserOwnAgent++; } else if (!StringUtils.containsIgnoreCase(fullRegion, "owned_")) { availableShareAgents++; } } int maxAgentSizePerConsole = getMaxAgentSizePerConsole(); availableShareAgents = (Math.min(availableShareAgents, maxAgentSizePerConsole)); Map<String, MutableInt> result = new HashMap<String, MutableInt>(1); result.put(Config.NONE_REGION, new MutableInt(availableShareAgents + availableUserOwnAgent)); return result; }
From source file:hydrograph.ui.graph.handler.JobCreationPage.java
protected boolean validatePage() { boolean returnCode = super.validatePage() && validateFilename(); if (returnCode) { IPath iPath = new Path(getContainerFullPath() + JOBS_FOLDER_NAME); IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(iPath); if (!StringUtils.endsWithIgnoreCase(getFileName(), Constants.JOB_EXTENSION)) { IFile newFile = folder.getFile(getFileName() + Constants.JOB_EXTENSION); if (newFile.exists()) { setErrorMessage("'" + newFile.getName() + "'" + Constants.ALREADY_EXISTS); return false; }//from ww w . j a v a2 s . co m } } return returnCode; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.payments.SIBSPaymentsDA.java
private void recursiveZipProcess(File unzipDir, HttpServletRequest request) { File[] filesInZip = unzipDir.listFiles(); Arrays.sort(filesInZip);// w w w . j a v a 2 s . c o m for (File file : filesInZip) { if (file.isDirectory()) { recursiveZipProcess(file, request); } else { if (!StringUtils.endsWithIgnoreCase(file.getName(), PAYMENT_FILE_EXTENSION)) { file.delete(); continue; } try { processFile(file, request); } catch (FileNotFoundException e) { addActionMessage("message", request, "error.manager.SIBS.zipException", getMessage(e)); } catch (IOException e) { addActionMessage("message", request, "error.manager.SIBS.IOException", getMessage(e)); } catch (Exception e) { addActionMessage("message", request, "error.manager.SIBS.fileException", getMessage(e)); } finally { file.delete(); } } } unzipDir.delete(); }
From source file:de.iteratec.iteraplan.presentation.dialog.ExcelImport.ImportFrontendServiceImpl.java
/** * @param fileName// ww w . j ava2s . c o m * @return {@code true} if the file name extension is either xls, xlsx or xlsm (case-insensitve) */ protected boolean hasAcceptableExcelFileExtension(String fileName) { return StringUtils.endsWithIgnoreCase(fileName, ".xls") || StringUtils.endsWithIgnoreCase(fileName, ".xlsx") || StringUtils.endsWithIgnoreCase(fileName, ".xlsm"); }
From source file:adalid.commons.util.FilUtils.java
public static FileFilter nameEndsWithFilter(final String suffix) { return new FileFilter() { @Override/* w w w.j ava2 s .c om*/ public boolean accept(File file) { return isVisibleFile(file) && StringUtils.endsWithIgnoreCase(file.getName(), suffix); } }; }
From source file:com.activecq.tools.flipbook.components.impl.FlipbookServiceImpl.java
public List<String> getImagePaths(final Component component, final ResourceResolver resourceResolver) { List<String> paths = new ArrayList<String>(); final Resource cr = resourceResolver.resolve(component.getPath()); if (cr == null) { return paths; }/*ww w . j a v a 2 s. co m*/ final Resource flipbook = cr.getChild(COMPONENT_FLIPBOOK_NODE); if (flipbook == null) { return paths; } final List<Resource> children = IteratorUtils.toList(flipbook.listChildren()); for (final Resource child : children) { if (ResourceUtil.isA(child, JcrConstants.NT_FILE)) { for (final String ext : IMAGE_EXTENSIONS) { if (StringUtils.endsWithIgnoreCase(child.getName(), ext)) { paths.add(child.getPath()); break; } } } } return paths; }
From source file:com.jd.bdp.hydra.hbase.service.impl.QueryServiceImpl.java
private boolean isClientSpan(KeyValue kv) { return StringUtils.endsWithIgnoreCase(new String(kv.getQualifier()), "c"); }
From source file:com.sfs.whichdoctor.beans.TransactionSummaryBean.java
/** * Gets the credit value.//from w w w. jav a2s . c om * * @return the credit value */ public final double getCredit() { double creditValue = 0; if (StringUtils.endsWithIgnoreCase(this.category, "Receipt")) { creditValue = this.netValue; } if (StringUtils.endsWithIgnoreCase(this.category, "Credit") && !StringUtils.endsWithIgnoreCase(this.financialType, "Cash")) { // Not a "Credit" of financial type "Cash" - has a credit value creditValue = this.netValue; } return creditValue; }
From source file:adalid.util.velocity.BaseBuilder.java
private boolean copyTextFiles() { Collection<File> files = FileUtils.listFiles(projectFolder, textFileFilter(), textDirFilter()); // ColUtils.sort(files); final String oldJava1 = "textoFilasPorPagina1Validator1.setMaximum(50L);"; final String newJava1 = "textoFilasPorPagina1Validator1.setMaximum(${Constants.getDefaultRowsPerPageLimit()}L);"; final String oldJSP01 = "id=\"table1\" width=\"1200\""; final String newJSP01 = "id=\"table1\" width=\"${project_max_view_width}\""; final String oldJSP02 = "id=\"tableRowGroup1\" rows=\"10\""; final String newJSP02 = "id=\"tableRowGroup1\" rows=\"${Constants.getDefaultRowsPerPage()}\""; final String oldJSP03 = "style=\"width: 1200px\" styleClass=\"pdq-grid-detalle-1\""; final String newJSP03 = "style=\"width: ${project_max_view_width}px\" styleClass=\"pdq-grid-detalle-1\""; final String oldJSPF1 = "id=\"messageGroup1\" style=\"width: 1200px"; final String newJSPF1 = "id=\"messageGroup1\" style=\"width: ${project_max_view_width}px"; String source, target, targetParent; boolean java, jrxml, jsp, jspf, properties, sh, bat, sql, xml; String[] precedingWords = { "extends", "import", "new", "@see", "@throws" }; SmallFile smallSource;//from ww w . j a v a 2 s.c o m List<String> sourceLines; List<String> targetLines = new ArrayList<>(); for (File file : files) { source = file.getPath(); java = StringUtils.endsWithIgnoreCase(source, ".java"); jrxml = StringUtils.endsWithIgnoreCase(source, ".jrxml"); jsp = StringUtils.endsWithIgnoreCase(source, ".jsp"); jspf = StringUtils.endsWithIgnoreCase(source, ".jspf"); properties = StringUtils.endsWithIgnoreCase(source, ".properties"); sh = StringUtils.endsWithIgnoreCase(source, ".sh"); bat = StringUtils.endsWithIgnoreCase(source, ".bat"); sql = StringUtils.endsWithIgnoreCase(source, ".sql"); xml = StringUtils.endsWithIgnoreCase(source, ".xml"); target = source.replace(projectFolderPath, velocityTemplatesTargetFolderPath); targetParent = StringUtils.substringBeforeLast(target, FS); targetLines.clear(); if (java) { javaHeading(targetLines); } else if (jsp || jspf) { jspHeading(targetLines); } else if (properties) { propertiesHeading(targetLines); } else if (sql) { sqlHeading(targetLines); } else if (xml || jrxml) { xmlHeading(targetLines); } else { genericHeading(targetLines); } FilUtils.mkdirs(targetParent); smallSource = new SmallFile(source); sourceLines = smallSource.read(); check(smallSource); if (smallSource.isNotEmpty()) { for (String line : sourceLines) { if (StringUtils.isNotBlank(line)) { if (java && line.matches(PACKAGE_REGEX)) { line = "package $package;"; } else { line = line.replace("$", "${dollar}"); line = line.replace("#", "${pound}"); line = line.replace("\\", "${backslash}"); line = line.replace(project, PROJECT_ALIAS); line = line.replace(PROJECT, PROJECT_ALIAS_UPPER_CASE); if (java) { for (String word : precedingWords) { line = replaceAliasWithRootPackageName(line, word + " ", "."); } line = replaceAliasWithRootPackageName(line, "String BASE_NAME = ", "."); line = replaceAliasWithRootPackageName(line, "new ResourceBundleHandler(", "."); line = line.replace(oldJava1, newJava1); } if (jrxml) { line = replaceAliasWithRootPackageName(line, "<import value=\"", "."); } if (jsp) { line = replaceAliasWithRootPackageName(line, "<%@ page import=\"", "."); line = line.replace(oldJSP01, newJSP01); line = line.replace(oldJSP02, newJSP02); line = line.replace(oldJSP03, newJSP03); } if (jspf) { line = line.replace(oldJSPF1, newJSPF1); } if (properties) { line = StrUtils.replaceAfter(line, PROJECT_ALIAS + ".", ROOT_PACKAGE_NAME + ".", "${pound}"); line = StrUtils.replaceAfter(line, PROJECT_ALIAS + ".", ROOT_PACKAGE_NAME + ".", "file.resource.loader.class"); line = replaceAliasWithRootPackageName(line, "log4j.category.", "="); line = replaceAliasWithRootPackageName(line, "log4j.additivity.", "="); } if (sh) { line = StrUtils.replaceAfter(line, PROJECT_ALIAS, DATABASE_NAME, "dbname="); } if (bat) { line = StrUtils.replaceAfter(line, PROJECT_ALIAS, DATABASE_NAME, "dbname="); } if (xml) { line = replaceAliasWithDatabaseName(line, "jdbc/", ""); line = replaceAliasWithDatabaseName(line, "localhost:5432/", ""); line = StrUtils.replaceAfter(line, PROJECT_ALIAS + "-pool", DATABASE_NAME + "-pool", "pool-name="); line = replaceAliasWithRootPackageName(line, "<logger category=\"", "\">"); } } } targetLines.add(line); } } if (write(target, targetLines, WINDOWS_CHARSET)) { textFilesCopied++; createTextFilePropertiesFile(source, target); } } return true; }