Example usage for org.apache.commons.lang StringUtils removeEndIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils removeEndIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils removeEndIgnoreCase.

Prototype

public static String removeEndIgnoreCase(String str, String remove) 

Source Link

Document

Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.

Usage

From source file:adalid.util.info.JavaInfo.java

public static void printManifestInfo(String extension, boolean details, URL url) throws IOException {
    InputStream stream = url.openStream();
    if (stream == null) {
        return;/*from  w  w w  .jav  a  2s. com*/
    }
    //      String file = url.getFile();
    String path = StringUtils.removeEndIgnoreCase(url.getPath(), "!/" + JarFile.MANIFEST_NAME);
    String name = StringUtils.substringAfterLast(path, "/");
    Manifest manifest = new Manifest(stream);
    if (!extensionNameMatches(manifest, extension)) {
        return;
    }
    //      out.println(file);
    printManifestInfo(path, name, details, manifest);
}

From source file:hudson.plugins.sonar.utils.LibraryPathResolver.java

protected String checkAndFixPattern(String pattern) {
    if (pattern.endsWith(LIBRARY_PATTERN)) {
        return pattern;
    }//w  w  w . java  2  s.co  m

    String clearedPattern = pattern;

    if (StringUtils.endsWithIgnoreCase(clearedPattern, LIBRARY_EXTENSION)) {
        clearedPattern = StringUtils.removeEndIgnoreCase(clearedPattern, LIBRARY_EXTENSION);
    }

    return clearedPattern + LIBRARY_PATTERN;
}

From source file:adalid.util.info.JavaInfo.java

public static void printManifestInfo(String extension, boolean details, File file) throws IOException {
    //      String absolutePath = file.getAbsolutePath();
    //      String canonicalPath = file.getCanonicalPath();
    String path = StringUtils.removeEndIgnoreCase(file.getPath(), FILE_SEP + MANIFEST_NAME);
    String name = StringUtils.substringAfterLast(path, FILE_SEP);
    InputStream stream = new FileInputStream(file);
    Manifest manifest = new Manifest(stream);
    if (!extensionNameMatches(manifest, extension)) {
        return;//ww w  .  ja  va  2 s .  com
    }
    //      out.println(absolutePath);
    //      out.println(canonicalPath);
    printManifestInfo(path, name, details, manifest);
}

From source file:com.google.gdt.eclipse.designer.uibinder.editor.UiBinderPairResourceProvider.java

/**
 * @return the Java {@link IFile} for given ui.xml one.
 *//* www.j av a 2  s  .co  m*/
private IFile getJavaFile(IFile uiFile) throws Exception {
    IProject project = uiFile.getProject();
    IJavaProject javaProject = JavaCore.create(project);
    // try to find Java file in same package
    {
        IFolder folder = (IFolder) uiFile.getParent();
        IPackageFragment packageFragment = (IPackageFragment) JavaCore.create(folder);
        // find IType
        String formName = StringUtils.removeEndIgnoreCase(uiFile.getName(), ".ui.xml");
        String typeName = packageFragment.getElementName() + "." + formName;
        IType type = javaProject.findType(typeName);
        if (type != null) {
            return (IFile) type.getCompilationUnit().getUnderlyingResource();
        }
    }
    // no Java file
    return null;
}

From source file:com.google.gdt.eclipse.designer.uibinder.editor.UiBinderPairResourceProvider.java

/**
 * @return the ui.xml {@link IFile} for given Java one.
 *//*w w w  .j a  va 2  s  .  c o m*/
private IFile getUIFile(IFile javaFile) throws Exception {
    IProject project = javaFile.getProject();
    IJavaProject javaProject = JavaCore.create(project);
    // prepare form name
    String javaFormName = StringUtils.removeEnd(javaFile.getName(), ".java");
    // prepare package name
    String packageName;
    {
        IFolder folder = (IFolder) javaFile.getParent();
        IPackageFragment packageFragmentJava = (IPackageFragment) JavaCore.create(folder);
        packageName = packageFragmentJava.getElementName();
    }
    // try to find ui.xml file in package with same name
    for (IPackageFragmentRoot packageFragmentRoot : javaProject.getPackageFragmentRoots()) {
        IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(packageName);
        if (packageFragment.exists()) {
            for (Object object : packageFragment.getNonJavaResources()) {
                if (object instanceof IFile) {
                    IFile uiFile = (IFile) object;
                    String uiFileName = uiFile.getName();
                    if (StringUtils.endsWithIgnoreCase(uiFileName, ".ui.xml")) {
                        String uiFormName = StringUtils.removeEndIgnoreCase(uiFileName, ".ui.xml");
                        if (uiFormName.equals(javaFormName)) {
                            return uiFile;
                        }
                    }
                }
            }
        }
    }
    // no ui.xml file
    return null;
}

From source file:com.haulmont.cuba.core.sys.dbupdate.DbUpdaterImpl.java

@Override
protected boolean executeGroovyScript(final ScriptResource file) {
    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//from ww  w .  j  a v  a 2  s  .com
            public void add(Closure closure) {
                postUpdateScripts.put(closure, file);

                postUpdate.add(closure);
            }

            @Override
            public List<Closure> getUpdates() {
                return postUpdate.getUpdates();
            }
        });
    }

    try {
        scripting.evaluateGroovy(file.getContent(), bind, ScriptExecutionPolicy.DO_NOT_USE_COMPILE_CACHE);
    } catch (Exception e) {
        throw new RuntimeException(ERROR + "Error executing Groovy script " + file.name + "\n" + e.getMessage(),
                e);
    }
    return !postUpdateScripts.containsValue(file);
}

From source file:hydrograph.ui.expression.editor.datastructure.ClassDetails.java

private void intialize(IClassFile classFile, String jarFileName, String packageName, boolean isUserDefined) {
    this.cName = StringUtils.removeEndIgnoreCase(classFile.getElementName(), Constants.CLASS_EXTENSION);
    displayName = cName;/*from  w w w .j  a  va2  s.co m*/
    if (StringUtils.isNotBlank(jarFileName)) {
        jarName = jarFileName;
    }
    if (StringUtils.isNotBlank(packageName)) {
        this.packageName = packageName;
    }
    if (StringUtils.isBlank(javaDoc)) {
        javaDoc = Constants.EMPTY_STRING;
    }
    if (isUserDefined) {
        isUserDefined = true;
        displayName = cName + Constants.USER_DEFINED_SUFFIX;
        updateJavaDoc(jarFileName, packageName);
    }
}

From source file:hydrograph.ui.expression.editor.jar.util.BuildExpressionEditorDataSturcture.java

private boolean isValidCLassName(String className) {
    className = StringUtils.removeEndIgnoreCase(className, Constants.CLASS_EXTENSION);
    Matcher matchs = Pattern.compile(Constants.ALPHANUMERIC_REGEX).matcher(className);
    if (!matchs.matches())
        return false;
    return true;//from  www .  java  2  s  .  co m
}

From source file:com.google.gdt.eclipse.designer.model.widgets.support.CssSupport.java

/**
 * @return the name of CSS class to use for waiting given CSS file which is referred by
 *         {@link IFile} or public resource path.
 */// w  w  w .jav a2 s  . c  om
private static String getWaitRequestName(String path) {
    String name = path;
    name = StringUtils.replace(name, "/", "_");
    name = StringUtils.removeEndIgnoreCase(name, ".css");
    return "wbp__wait_stylesheet_" + name;
}

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;//from ww  w .  j  av a 2  s.  c o m
    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;
}