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:adalid.util.velocity.MavenArchetypeBuilder.java
private boolean copyTextFiles() { Collection<File> files = FileUtils.listFiles(projectFolder, textFileFilter(), textDirFilter()); // ColUtils.sort(files); String source, target, targetParent, template, clazz; boolean java; Charset cs;//w ww . j av a2 s. com SmallFile smallSource; for (File file : files) { source = file.getPath(); java = StringUtils.endsWithIgnoreCase(source, ".java"); target = source.replace(projectFolderPath, velocityTemplatesTargetFolderPath); template = StringUtils.removeStart(target, velocityTemplatesTargetFolderPath + FS).replace('\\', '/'); clazz = StringUtils .removeStartIgnoreCase(StringUtils.removeEndIgnoreCase(template, ".java"), "src/main/java/") .replace('/', '.'); if (java) { classes.add(clazz); sources.add(template); } else { resources.add(template); } } String alias = alias(false); String ALIAS = alias(true); String packageX1 = packageName + "."; String packageX2 = packageName + ";"; List<String> sourceLines; List<String> targetLines = new ArrayList<>(); for (File file : files) { source = file.getPath(); java = StringUtils.endsWithIgnoreCase(source, ".java"); target = source.replace(projectFolderPath, velocityTemplatesTargetFolderPath); targetParent = StringUtils.substringBeforeLast(target, FS); targetLines.clear(); FilUtils.mkdirs(targetParent); smallSource = new SmallFile(source); sourceLines = smallSource.read(); check(smallSource); if (smallSource.isNotEmpty()) { for (String line : sourceLines) { if (StringUtils.isNotBlank(line)) { line = line.replace(group, "${groupId}"); line = line.replace(artifact, "${artifactId}"); line = line.replace(project + "ap", alias + "ap"); line = line.replace(PROJECT + "AP", ALIAS + "AP"); line = line.replace("package " + packageX1, "package ${package}." + packageX1); line = line.replace("package " + packageX2, "package ${package}." + packageX2); for (String name : classes) { if (name.startsWith(packageX1)) { line = line.replace(name, "${package}." + name); } } } targetLines.add(line); } } cs = java ? StandardCharsets.UTF_8 : WINDOWS_CHARSET; if (write(target, targetLines, cs)) { textFilesCopied++; } } return true; }
From source file:adalid.commons.util.ObjUtils.java
public static Boolean endsWith(Object x, Object y) { if (x == null || y == null) { return false; } else if (x instanceof String) { return y instanceof String ? StringUtils.endsWithIgnoreCase(((String) x), ((String) y)) : StringUtils.endsWithIgnoreCase(((String) x), toString(y)); }//w ww. j a v a 2s .c o m return endsWith(toString(x), y); }
From source file:com.activecq.tools.flipbook.components.impl.FlipbookServiceImpl.java
public String yesNo(Object o) { final String YES = "Yes"; final String NO = "No"; if (o == null) { return NO; } else if (o instanceof String) { String tmp = (String) o; if (StringUtils.equalsIgnoreCase(tmp, "true") || StringUtils.endsWithIgnoreCase(tmp, "yes")) { return YES; } else {/*from w w w. j a va2s .c om*/ return NO; } } else if (o instanceof Boolean) { if (((Boolean) o).booleanValue()) { return YES; } else { return NO; } } return NO; }
From source file:com.alibaba.otter.node.etl.select.selector.MessageParser.java
/** * <pre>//from w w w . ja v a2 s . c o m * the table def: * channel_info varchar * channel_id varchar * ???? retl_mark channel_info channel_id ? * a. channel_info '_SYNC' ?? * b. ?? * i. channel_id = "xx"channel_id???channelId * ii. ??? * </pre> */ private int checkLoopback(Pipeline pipeline, RowData rowData) { // channel_info // after? Column infokColumn = getColumnIgnoreCase(rowData.getAfterColumnsList(), pipeline.getParameters().getSystemMarkTableInfo()); // ?channelInfo_SYNC? if (infokColumn != null && StringUtils.endsWithIgnoreCase(infokColumn.getValue(), RETL_CLIENT_FLAG)) { return 1; } // ?channelInfo??2?check?otter if (infokColumn != null && StringUtils.equalsIgnoreCase(infokColumn.getValue(), pipeline.getParameters().getChannelInfo())) { return 2; } infokColumn = getColumnIgnoreCase(rowData.getBeforeColumnsList(), pipeline.getParameters().getSystemMarkTableInfo()); // ?channelInfo_SYNC? if (infokColumn != null && StringUtils.endsWithIgnoreCase(infokColumn.getValue(), RETL_CLIENT_FLAG)) { return 1; } // ?channelInfo??2?check?otter if (infokColumn != null && StringUtils.equalsIgnoreCase(infokColumn.getValue(), pipeline.getParameters().getChannelInfo())) { return 2; } // channel_id Column markColumn = getColumnIgnoreCase(rowData.getAfterColumnsList(), pipeline.getParameters().getSystemMarkTableColumn()); // ?channel id if (markColumn != null && pipeline.getChannelId().equals(Long.parseLong(markColumn.getValue()))) { return 2; } markColumn = getColumnIgnoreCase(rowData.getBeforeColumnsList(), pipeline.getParameters().getSystemMarkTableColumn()); if (markColumn != null && pipeline.getChannelId().equals(Long.parseLong(markColumn.getValue()))) { return 2; } return 0; }
From source file:com.taobao.android.builder.tools.solib.NativeSoFilter.java
@Override public boolean accept(File file) { if (file.isDirectory()) { return true; } else {/*from www. j a v a 2s . com*/ String fileName = file.getName(); if (null != removeSoFiles && removeSoFiles.size() > 0) { if (removeSoFiles.contains(fileName)) { return false; } } String path = file.getAbsolutePath(); boolean isSupportAbi = false; if (null != supportAbis && supportAbis.size() > 0) { for (String supportAbi : supportAbis) { String abi = File.separator + supportAbi + File.separator + fileName; if (path.indexOf(abi) > 0) { isSupportAbi = true; break; } } } else { isSupportAbi = true; } if (isSupportAbi && (StringUtils.endsWithIgnoreCase(fileName, ".so") || "gdbserver".equalsIgnoreCase(fileName))) { return true; } } return false; }
From source file:adalid.util.velocity.SecondBaseBuilder.java
private boolean copyTextFiles() { Collection<File> files = FileUtils.listFiles(projectFolder, textFileFilter(), textDirFilter()); // ColUtils.sort(files); String source, target, targetParent; boolean java, jrxml, properties, sh, bat, xml; String[] precedingWords = { "extends", "import", "new", "@see", "@throws" }; SmallFile smallSource;//from w w w. ja v a 2s .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"); properties = StringUtils.endsWithIgnoreCase(source, ".properties"); sh = StringUtils.endsWithIgnoreCase(source, ".sh"); bat = StringUtils.endsWithIgnoreCase(source, ".bat"); xml = StringUtils.endsWithIgnoreCase(source, ".xml"); target = source.replace(projectFolderPath, velocityTemplatesTargetFolderPath) + VM; targetParent = StringUtils.substringBeforeLast(target, FS); targetLines.clear(); 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(", "."); } if (jrxml) { line = replaceAliasWithRootPackageName(line, "<import value=\"", "."); } 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; }
From source file:com.haulmont.cuba.core.sys.dbupdate.DbUpdaterEngine.java
protected boolean executeGroovyScript(ScriptResource file) { try {/* ww w . ja v a2 s . c om*/ ClassLoader classLoader = getClass().getClassLoader(); CompilerConfiguration cc = new CompilerConfiguration(); cc.setRecompileGroovySource(true); Binding bind = new Binding(); bind.setProperty("ds", getDataSource()); bind.setProperty("log", LoggerFactory.getLogger(String.format("%s$%s", DbUpdaterEngine.class.getName(), StringUtils.removeEndIgnoreCase(file.getName(), ".groovy")))); if (!StringUtils.endsWithIgnoreCase(file.getName(), "." + UPGRADE_GROOVY_EXTENSION)) { bind.setProperty("postUpdate", new PostUpdateScripts() { @Override public void add(Closure closure) { super.add(closure); log.warn("Added post update action will be ignored"); } }); } GroovyShell shell = new GroovyShell(classLoader, bind, cc); //noinspection UnnecessaryLocalVariable Script script = shell.parse(file.getContent()); script.run(); } catch (Exception e) { throw new RuntimeException(ERROR + "Error executing Groovy script " + file.name + "\n" + e.getMessage(), e); } return true; }
From source file:com.taobao.android.builder.tools.bundleinfo.ApkFileListUtils.java
private static boolean isImageFile(String name) { for (String imgExt : IMG_EXTENSIONS) { if (StringUtils.endsWithIgnoreCase(name, imgExt)) { return true; }// w w w . j a v a 2 s .c o m } return false; }
From source file:com.adobe.acs.commons.images.impl.NamedTransformImageServlet.java
/** * Gets the mimeType of the image.//from ww w.j a va 2s .c om * - The last segments suffix is looked at first and used * - if the last suffix segment's "extension" is .orig or .original then use the underlying resources mimeType * - else look up the mimeType to use based on this "extension" * - default to the resource's mimeType if the requested mimeType by extension is not supported. * * @param image the image to get the mimeType for * @return the string representation of the image's mimeType */ private String getMimeType(final SlingHttpServletRequest request, final Image image) { final String lastSuffix = PathInfoUtil.getLastSuffixSegment(request); final String mimeType = mimeTypeService.getMimeType(lastSuffix); if (!StringUtils.endsWithIgnoreCase(lastSuffix, ".orig") && !StringUtils.endsWithIgnoreCase(lastSuffix, ".original") && (ImageIO.getImageWritersByMIMEType(mimeType).hasNext())) { return mimeType; } else { try { return image.getMimeType(); } catch (final RepositoryException e) { return MIME_TYPE_PNG; } } }
From source file:adalid.util.velocity.BaseBuilder.java
private void createTextFilePropertiesFile(String source, String target) { boolean java = StringUtils.endsWithIgnoreCase(source, ".java"); boolean bundle = StringUtils.endsWithIgnoreCase(source, ".properties"); File sourceFile = new File(source); String sourceFileName = sourceFile.getName(); String sourceFileSimpleName = StringUtils.substringBeforeLast(sourceFileName, "."); String sourceFolderName = sourceFile.getParentFile().getName(); String sourceFolderSimpleName = StringUtils.substringBeforeLast(sourceFolderName, "."); String sourceEntityName = getOptionalEntityName(sourceFileSimpleName, sourceFolderSimpleName); String properties = source.replace(projectFolderPath, velocityPlatformsTargetFolderPath) + ".properties"; String folder = StringUtils.substringBeforeLast(properties, FS); String template = StringUtils.substringAfter(target, velocityFolderPath + FS).replace(FS, "/"); String path = StringUtils.substringBeforeLast(StringUtils.substringAfter(source, projectFolderPath), FS) .replace(FS, "/").replace(project, PROJECT_ALIAS).replace("eclipse.settings", ".settings"); path = replaceAliasWithRootFolderName(path); String pack = null;// w w w .ja va2 s .c o m if (java || bundle) { String s1 = StringUtils.substringAfter(path, SRC); if (StringUtils.contains(s1, PROJECT_ALIAS)) { String s2 = StringUtils.substringBefore(s1, PROJECT_ALIAS); String s3 = SRC + s2; String s4 = StringUtils.substringBefore(path, s3) + s3; String s5 = StringUtils.substringAfter(s1, PROJECT_ALIAS).replace("/", "."); path = StringUtils.removeEnd(s4, "/"); pack = ROOT_PACKAGE_NAME + s5; } } path = finalisePath(path); String file = StringUtils.substringAfterLast(source, FS).replace(project, PROJECT_ALIAS) .replace("eclipse.project", ".project"); List<String> lines = new ArrayList<>(); lines.add("template = " + template); // lines.add("template-type = velocity"); lines.add("path = " + path); if (StringUtils.isNotBlank(pack)) { lines.add("package = " + pack); } lines.add("file = " + file); if (sourceFileSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("nbproject")) { lines.add("disabled = true"); } else if (sourceEntityName != null) { lines.add("disabled-when-missing = " + sourceEntityName); } if (source.endsWith(".css") || source.endsWith(".jrtx")) { lines.add("preserve = true"); } else if (ArrayUtils.contains(preservableFiles, sourceFileName)) { lines.add("preserve = true"); } lines.add("dollar.string = $"); lines.add("pound.string = #"); lines.add("backslash.string = \\\\"); FilUtils.mkdirs(folder); if (write(properties, lines, WINDOWS_CHARSET)) { propertiesFilesCreated++; } }