@Test public void testRemoveStartIgnoreCase() { // StringUtils.removeStart("", *) = "" assertNull("removeStartIgnoreCase(null, null)", StringUtils.removeStartIgnoreCase(null, null)); assertNull("removeStartIgnoreCase(null, \"\")", StringUtils.removeStartIgnoreCase(null, "")); assertNull("removeStartIgnoreCase(null, \"a\")", StringUtils.removeStartIgnoreCase(null, "a")); // StringUtils.removeStart(*, null) = * assertEquals("removeStartIgnoreCase(\"\", null)", StringUtils.removeStartIgnoreCase("", null), ""); assertEquals("removeStartIgnoreCase(\"\", \"\")", StringUtils.removeStartIgnoreCase("", ""), ""); assertEquals("removeStartIgnoreCase(\"\", \"a\")", StringUtils.removeStartIgnoreCase("", "a"), ""); // All others: assertEquals("removeStartIgnoreCase(\"www.domain.com\", \"www.\")", StringUtils.removeStartIgnoreCase("www.domain.com", "www."), "domain.com"); assertEquals("removeStartIgnoreCase(\"domain.com\", \"www.\")", StringUtils.removeStartIgnoreCase("domain.com", "www."), "domain.com"); assertEquals("removeStartIgnoreCase(\"domain.com\", \"\")", StringUtils.removeStartIgnoreCase("domain.com", ""), "domain.com"); assertEquals("removeStartIgnoreCase(\"domain.com\", null)", StringUtils.removeStartIgnoreCase("domain.com", null), "domain.com"); // Case insensitive: assertEquals("removeStartIgnoreCase(\"www.domain.com\", \"WWW.\")", StringUtils.removeStartIgnoreCase("www.domain.com", "WWW."), "domain.com"); }
private CodeClimateIssue.Location getLocation(RuleViolation rv) { CodeClimateIssue.Location result; String pathWithoutCcRoot = StringUtils.removeStartIgnoreCase(rv.getFilename(), "/code/"); if (rule.hasDescriptor(CODECLIMATE_REMEDIATION_MULTIPLIER) && !rule.getProperty(CODECLIMATE_BLOCK_HIGHLIGHTING)) { result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getBeginLine()); } else { result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getEndLine()); } return result; }
public void setValue(final Object value) throws ConfigurationRuntimeException { try { if (!(value instanceof String)) { this.value = value; return; } final String val = (String) value; final String name = StringUtils.removeStartIgnoreCase(val, CLASS); final Class<?> clazz = ClassUtils.getClass(name); if (name.length() == val.length()) { this.value = clazz.newInstance(); } else { this.value = clazz; } } catch (final Exception e) { throw new ConfigurationRuntimeException("Unable to create " + value, e); } } }
/** * Remove prefix for dummy table */ private String removeDummyPrefixColumnName(String name) { return StringUtils.removeStartIgnoreCase(name, RESULTSET_COLUMN_PREFIX); }
private String extractColumnName(String name) { return StringUtils.removeStartIgnoreCase(name, SelectQueryBuilder.TEMP_TABLE_NAME + "."); }
@Override protected String handle(String input, String second) { return StringUtils.removeStartIgnoreCase(input, second); }
/** * Generate the authority string for a group, applies the prefix if is not yet present. * * @param group name of the group * @return authority string */ public static String authorityString( String group ) { return StringUtils.isBlank( group ) ? null : AUTHORITY_PREFIX + StringUtils.removeStartIgnoreCase( group, AUTHORITY_PREFIX ); } }
/** * Generate the authority string for a role, applies the prefix if is not yet present. * * @param role authority name of the role * @return authority string */ public static String authorityString( String role ) { return StringUtils.isBlank( role ) ? null : AUTHORITY_PREFIX + StringUtils.removeStartIgnoreCase( role, AUTHORITY_PREFIX ); } }
@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; }
public static String readBearerHeader(Request req) { String header = req.getHeader(Header.Authorization); return StringUtils.removeStartIgnoreCase(header, "Bearer "); } }
@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; }
public static String readBearerHeader(Request req) { String header = req.getHeader(Header.Authorization); return StringUtils.removeStartIgnoreCase(header, "Bearer "); } }
@Override public InputStream getInputStream() throws IOException { try { final URL aURL = getURL(); ClasspathConnection.validateURL(aURL); final String sURL = aURL.toURI().toString(); String sRes = StringUtils.removeStartIgnoreCase(sURL, PROTOCOL); sRes = StringUtils.removeStartIgnoreCase(sRes, ":"); final InputStream aStream = ClasspathConnection.class.getResourceAsStream(sRes); Validate.notNull(aStream, "Could not load resource '"+sRes+"' from classpath."); return aStream; } catch (final Throwable ex) { throw new IOException (ex); } }
@Override public InputStream getInputStream() throws IOException { try { final URL aURL = getURL(); ClasspathConnection.validateURL(aURL); final String sURL = aURL.toURI().toString(); String sRes = StringUtils.removeStartIgnoreCase(sURL, PROTOCOL); sRes = StringUtils.removeStartIgnoreCase(sRes, ":"); final InputStream aStream = ClasspathConnection.class.getResourceAsStream(sRes); Validate.notNull(aStream, "Could not load resource '"+sRes+"' from classpath."); return aStream; } catch (final Throwable ex) { throw new IOException (ex); } }
private List<String> getFilterableColumns(String statement) { List<String> columns = new ArrayList<>(); String selectClause = statement.substring("select ".length(), StringUtils.indexOfIgnoreCase(statement, " from ")).trim(); selectClause = StringUtils.removeStartIgnoreCase(selectClause, "distinct "); for (String column : COLUMN_SEPARATOR.split(selectClause)) { // Remove the column alias. String columnWithoutAlias = column; int aliasPosition = column.lastIndexOf(" as "); if (aliasPosition > 0) { columnWithoutAlias = column.substring(0, aliasPosition).trim(); String alias = column.substring(aliasPosition + 4).trim(); if (alias.startsWith("unfilterable")) { continue; } } columns.add(columnWithoutAlias); } return columns; } }
public static String removeStartIgnoreCase(ActionContext actionContext){ Thing self = actionContext.getObject("self"); String str = (String) self.doAction("getStr", actionContext); String remove = (String) self.doAction("getRemove", actionContext); return StringUtils.removeStartIgnoreCase(str, remove); }
scope -> authorities.add( new SimpleGrantedAuthority( ROLE_PREFIX + StringUtils.removeStartIgnoreCase(scope, GENIE_PREFIX).toUpperCase()
private CodeClimateIssue.Location getLocation(RuleViolation rv) { CodeClimateIssue.Location result; String pathWithoutCcRoot = StringUtils.removeStartIgnoreCase(rv.getFilename(), "/code/"); if (rule.hasDescriptor(CODECLIMATE_REMEDIATION_MULTIPLIER) && !rule.getProperty(CODECLIMATE_BLOCK_HIGHLIGHTING)) { result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getBeginLine()); } else { result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getEndLine()); } return result; }