List of usage examples for org.apache.commons.lang3 StringUtils removeEnd
public static String removeEnd(final String str, final String remove)
Removes a substring only if it is at the end of a source string, otherwise returns the source string.
A null source string will return null .
From source file:com.netflix.spinnaker.fiat.model.resources.ResourceType.java
public static ResourceType parse(@NonNull String pluralOrKey) { if (pluralOrKey.contains(":")) { pluralOrKey = StringUtils.substringAfterLast(pluralOrKey, ":"); }//from w ww . j a v a 2s .c o m String singular = StringUtils.removeEnd(pluralOrKey, "s"); return ResourceType.valueOf(singular.toUpperCase()); }
From source file:gobblin.data.management.ConversionHiveTestUtils.java
public static Schema readSchemaFromJsonFile(String directory, String filename) throws IOException { return new Schema.Parser().parse(ConversionHiveTestUtils.class.getClassLoader() .getResourceAsStream(StringUtils.removeEnd(directory, Path.SEPARATOR) + Path.SEPARATOR + filename)); }
From source file:net.lmxm.ute.utils.PathUtils.java
/** * Builds the full path./*from ww w. j av a 2 s . c o m*/ * * @param rootPath the root path * @param relativePath the relative path * @return the string */ public static String buildFullPath(final String rootPath, final String relativePath) { final String prefix = "buildFullPath() :"; LOGGER.debug("{} entered, root={}, relativepath=" + relativePath, prefix, rootPath); final String root = StringUtils.removeEnd(StringUtils.trimToEmpty(rootPath), "/"); final String relative = StringUtils.removeStart(StringUtils.trimToEmpty(relativePath), "/"); String fullPath; if (StringUtils.isBlank(relative)) { fullPath = root; } else { fullPath = StringUtils.join(new Object[] { root, "/", relative }); } LOGGER.debug("{} returning {}", prefix, fullPath); return fullPath; }
From source file:com.github.riccardove.easyjasub.commons.CommonsLangStringUtils.java
public static String removeEnd(String str, String remove) { return StringUtils.removeEnd(str, remove); }
From source file:gobblin.data.management.ConversionHiveTestUtils.java
public static String readQueryFromFile(String directory, String filename) throws IOException { InputStream is = ConversionHiveTestUtils.class.getClassLoader() .getResourceAsStream(StringUtils.removeEnd(directory, Path.SEPARATOR) + Path.SEPARATOR + filename); return IOUtils.toString(is, "UTF-8"); }
From source file:com.aqnote.app.wifianalyzer.wifi.model.WiFiUtils.java
public static String convertSSID(@NonNull String SSID) { return StringUtils.removeEnd(StringUtils.removeStart(SSID, QUOTE), QUOTE); }
From source file:io.lavagna.web.security.login.oauth.GitlabHandler.java
private static String getProfileUrl(OAuthProvider provider) { return provider.profileUrlOrDefault( StringUtils.removeEnd(provider.baseUrlOrDefault("https://gitlab.com"), "/") + "/api/v3/user"); }
From source file:com.mirth.connect.server.util.DatabaseUtil.java
public static void executeScript(String script, boolean ignoreErrors) throws Exception { SqlSessionManager sqlSessionManger = SqlConfig.getSqlSessionManager(); Connection conn = null;//from www.j a va2s. c om ResultSet resultSet = null; Statement statement = null; try { sqlSessionManger.startManagedSession(); conn = sqlSessionManger.getConnection(); /* * Set auto commit to false or an exception will be thrown when trying to rollback */ conn.setAutoCommit(false); statement = conn.createStatement(); Scanner s = new Scanner(script); while (s.hasNextLine()) { StringBuilder sb = new StringBuilder(); boolean blankLine = false; while (s.hasNextLine() && !blankLine) { String temp = s.nextLine(); if (temp.trim().length() > 0) sb.append(temp + " "); else blankLine = true; } // Trim ending semicolons so Oracle doesn't throw // "java.sql.SQLException: ORA-00911: invalid character" String statementString = StringUtils.removeEnd(sb.toString().trim(), ";"); if (statementString.length() > 0) { try { statement.execute(statementString); conn.commit(); } catch (SQLException se) { if (!ignoreErrors) { throw se; } else { logger.error("Error was encountered and ignored while executing statement: " + statementString, se); conn.rollback(); } } } } } catch (Exception e) { throw new Exception(e); } finally { DbUtils.closeQuietly(statement); DbUtils.closeQuietly(resultSet); DbUtils.closeQuietly(conn); sqlSessionManger.close(); } }
From source file:io.lavagna.web.security.login.oauth.Gitlab20Api.java
public Gitlab20Api(String baseUrl) { this.baseUrl = StringUtils.removeEnd(baseUrl, "/"); }
From source file:hoot.services.utils.PostgresUtils.java
static Map<String, String> parseTags(String tagsStr) { Map<String, String> tagsMap = new HashMap<>(); if ((tagsStr != null) && (!tagsStr.isEmpty())) { Pattern regex = Pattern.compile("(\"[^\"]*\")=>(\"(?:\\\\.|[^\"\\\\]+)*\"|[^,\"]*)"); Matcher regexMatcher = regex.matcher(tagsStr); while (regexMatcher.find()) { String key = regexMatcher.group(1); key = StringUtils.removeStart(key, "\""); key = StringUtils.removeEnd(key, "\""); String val = regexMatcher.group(2); val = StringUtils.removeStart(val, "\""); val = StringUtils.removeEnd(val, "\""); tagsMap.put(key, val); }// ww w . j a v a2 s .com } return tagsMap; }