private String trimMegaFromSize(String sizeInMega) { return StringUtils.removeEndIgnoreCase(sizeInMega, "M"); }
@Test public void testRemoveEndIgnoreCase() { // StringUtils.removeEndIgnoreCase("", *) = "" assertNull("removeEndIgnoreCase(null, null)", StringUtils.removeEndIgnoreCase(null, null)); assertNull("removeEndIgnoreCase(null, \"\")", StringUtils.removeEndIgnoreCase(null, "")); assertNull("removeEndIgnoreCase(null, \"a\")", StringUtils.removeEndIgnoreCase(null, "a")); // StringUtils.removeEnd(*, null) = * assertEquals("removeEndIgnoreCase(\"\", null)", StringUtils.removeEndIgnoreCase("", null), ""); assertEquals("removeEndIgnoreCase(\"\", \"\")", StringUtils.removeEndIgnoreCase("", ""), ""); assertEquals("removeEndIgnoreCase(\"\", \"a\")", StringUtils.removeEndIgnoreCase("", "a"), ""); // All others: assertEquals("removeEndIgnoreCase(\"www.domain.com.\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.com.", ".com"), "www.domain.com."); assertEquals("removeEndIgnoreCase(\"www.domain.com\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.com", ".com"), "www.domain"); assertEquals("removeEndIgnoreCase(\"www.domain\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain", ".com"), "www.domain"); assertEquals("removeEndIgnoreCase(\"domain.com\", \"\")", StringUtils.removeEndIgnoreCase("domain.com", ""), "domain.com"); assertEquals("removeEndIgnoreCase(\"domain.com\", null)", StringUtils.removeEndIgnoreCase("domain.com", null), "domain.com"); // Case insensitive: assertEquals("removeEndIgnoreCase(\"www.domain.com\", \".COM\")", StringUtils.removeEndIgnoreCase("www.domain.com", ".COM"), "www.domain"); assertEquals("removeEndIgnoreCase(\"www.domain.COM\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.COM", ".com"), "www.domain"); }
public void deploy(String resource) throws IOException, URISyntaxException { int lastSeparator = resource.lastIndexOf(File.separator); String appName = removeEndIgnoreCase(resource.substring(lastSeparator + 1), JAR_FILE_SUFFIX); deploy(resource, appName); }
@Override public T deployPackagedArtifact(String zip, Optional<Properties> deploymentProperties) throws DeploymentException { URI uri; File artifactZip; try { final String artifactName = removeEndIgnoreCase(zip, JAR_FILE_SUFFIX); artifactZip = new File(artifactDir, zip); uri = artifactZip.toURI(); return deployPackagedArtifact(uri, artifactName, deploymentProperties); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw new DeploymentException(createStaticMessage("Failed to deploy from zip: " + zip), e); } }
private File installArtifact(URI artifactAchivedUri) throws IOException { File artifactLocation; try { artifactLocation = installFrom(artifactAchivedUri); } catch (Throwable t) { File artifactArchive = new File(artifactAchivedUri); String artifactName = removeEndIgnoreCase(artifactArchive.getName(), JAR_FILE_SUFFIX); // error text has been created by the deployer already logDeploymentFailure(t, artifactName); addZombieFile(artifactName, artifactArchive); deploymentListener.onDeploymentFailure(artifactName, t); throw t; } return artifactLocation; }
LOGGER.info("deploying artifact: " + uri); File bundleFile = new File(uri); final String bundleName = removeEndIgnoreCase(bundleFile.getName(), ZIP_FILE_SUFFIX); deploymentListener.onDeploymentStart(bundleName);
/** * This method perform the sample work of removing ".html" from the Location header value. * @param value the original location value * @return the updated location value */ private String getUpdatedLocation(String value) { return StringUtils.removeEndIgnoreCase(value, ".html"); } }
@VisibleForTesting public static String simplifyPluginName(String name) { name = StringUtils.removeStart(name, "Jenkins "); name = StringUtils.removeStart(name, "Hudson "); name = StringUtils.removeEndIgnoreCase(name, " for Jenkins"); name = StringUtils.removeEndIgnoreCase(name, " Jenkins Plugin"); name = StringUtils.removeEndIgnoreCase(name, " Plugin"); name = StringUtils.removeEndIgnoreCase(name, " Plug-In"); name = name.replaceAll("[- .!]+$", ""); // remove trailing punctuation e.g. for 'Acme Foo - Jenkins Plugin' return name; }
private String getServiceName(String edmxfileName) { /*-- Returns the Service Name --*/ if (StringUtils.endsWithIgnoreCase(edmxfileName, v4_default_xml)) { return StringUtils.removeEndIgnoreCase(edmxfileName, v4_default_xml); } return StringUtils.removeEndIgnoreCase(edmxfileName, xml); }
/** * Quick and dirty singular to plural conversion. * @param singul a word * @return a guess of its plural form */ public static String singularToPlural(String singul) { return StringUtils.isBlank(singul) ? singul : (singul.endsWith("s") ? singul + "es" : (singul.endsWith("y") ? StringUtils.removeEndIgnoreCase(singul, "y") + "ies" : singul + "s")); }
/** * Quick and dirty singular to plural conversion. * @param singul a word * @return a guess of its plural form */ public static String singularToPlural(String singul) { return (StringUtils.isBlank(singul) || singul.endsWith("es") || singul.endsWith("ies")) ? singul : (singul.endsWith("s") ? singul + "es" : (singul.endsWith("y") ? StringUtils.removeEndIgnoreCase(singul, "y") + "ies" : singul + "s")); }
public static String nameFromUrl(String gitUrl) { String name = StringUtils.removeEndIgnoreCase(StringUtils.removeEnd(gitUrl, "/"), ".git"); name = name.substring(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1); return name; } }
@Override public String getName() { if (StringUtils.isBlank(name)) { String simpleName = getClass().getSimpleName(); simpleName = StringUtils.removeStartIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE); simpleName = StringUtils.removeEndIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE); return simpleName; } return name; }
@Override public String getName() { if (StringUtils.isBlank(name)) { String simpleName = getClass().getSimpleName(); simpleName = StringUtils.removeStartIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE); simpleName = StringUtils.removeEndIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE); return simpleName; } return name; }
/** * Removes the last occurrence of the word "or" from the given string, * including potential trailing spaces, case-insensitive. * * @param string the string. * @return the chopped string. */ public static String removeLastOr( String string ) { string = StringUtils.stripEnd( string, " " ); return StringUtils.removeEndIgnoreCase( string, "or" ); }
/** * Removes the last occurrence of the word "and" from the given string, * including potential trailing spaces, case-insensitive. * * @param string the string. * @return the chopped string. */ public static String removeLastAnd( String string ) { string = StringUtils.stripEnd( string, " " ); return StringUtils.removeEndIgnoreCase( string, "and" ); }
/** * Removes the last occurrence of the the given string, including potential * trailing spaces. * * @param string the string, without potential trailing spaces. * @param remove the text to remove. * @return the chopped string. */ public static String removeLast( String string, String remove ) { string = StringUtils.stripEnd( string, " " ); return StringUtils.removeEndIgnoreCase( string, remove ); }
public static String getDriver(Object obj) { Map<String, Object> fields = DataUtils.getFields(obj); for (Map.Entry<String, Object> field : fields.entrySet()) { if (StringUtils.endsWithIgnoreCase(field.getKey(), MachineConstants.CONFIG_FIELD_SUFFIX) && field.getValue() != null) { return StringUtils.removeEndIgnoreCase(field.getKey(), MachineConstants.CONFIG_FIELD_SUFFIX); } } return null; }
private String requireGitHubRepoExistence(String url) { GitHubSource gh = GitHubSource.getInstance(); String shortenedUrl = StringUtils.removeEndIgnoreCase(url, "-plugin"); return gh.isRepoExisting(url) ? url : (gh.isRepoExisting(shortenedUrl) ? shortenedUrl : null); }
public static String removeEndIgnoreCase(ActionContext actionContext){ Thing self = actionContext.getObject("self"); String str = (String) self.doAction("getStr", actionContext); String remove = (String) self.doAction("getRemove", actionContext); return StringUtils.removeEndIgnoreCase(str, remove); }