public String[] getProfiled(String[] templates) { String[] array = new String[templates.length]; for(int i=0;i<array.length;i++) { array[i] = Strings.replace(templates[i], "{profile}", profile); } return array; }
@Override public String escape(String string) { if (null == string) { return null; } return Strings.replace(string, "'", "''"); }
public static String replaceOnce(String text, String oldString, String newString) { return replace(text, oldString, newString, 1); }
public static String replace(String text, String oldString, String newString) { return replace(text, oldString, newString, -1); }
/** * Create a URI instance for the given location String, replacing spaces with "%20" quotes first. */ public static URI toURI(String location) throws URISyntaxException { return new URI(Strings.replace(location, " ", "%20")); }
@Override public String generateAuthorizationCode(AuthzAuthentication authc) { return Strings.replace(UUID.randomUUID().toString(), "-", ""); }
@Override public String generateAuthorizationCode(AuthzAuthentication authc) { return Strings.replace(UUID.randomUUID().toString(), "-", ""); }
public static String applyRelative(String parentPath, String relativePath) { if(null == parentPath) { return relativePath; } parentPath = Strings.replace(parentPath, WINDOWS_SEPARATOR, UNIX_SEPARATOR); int separatorIndex = parentPath.lastIndexOf(Paths.UNIX_SEPARATOR_STR); if (separatorIndex != -1) { String newPath = parentPath.substring(0, separatorIndex); if (!relativePath.startsWith(Paths.UNIX_SEPARATOR_STR)) { newPath += Paths.UNIX_SEPARATOR_STR; } return newPath + relativePath; } else { return relativePath; } }
protected String[] parseProducesOrConsumes(String expr) { return Strings.splitWhitespaces(Strings.replace(expr, ",", " ")); } }
private Map<String, AppProperty> initProperties(Map<String, String> externalProperties) { Map<String, AppProperty> props = new HashMap<>(); if(null != externalProperties) { if(!externalProperties.isEmpty()) { Maps.resolveValues(externalProperties, new DefaultPlaceholderResolver(SystemPropertyAccessor.INSTANCE)); } externalProperties.forEach((k,v) -> props.put(k, new SimpleAppProperty("<external>", k, v))); } Map<String,String> env = System.getenv(); if(null != env) { env.forEach((name, value) -> { //converts all '_' -> '.' if the first character is lower case. if(Character.isLowerCase(name.charAt(0))) { name = Strings.replace(name, '_', '.'); } props.put(name, new SimpleAppProperty("<env>", name, value, true)); }); } Properties sysProps = System.getProperties(); for(Object key : sysProps.keySet()) { String name = key.toString(); props.put(name, new SimpleAppProperty("<sys>", name, System.getProperty(name), true)); } return props; }
return Strings.EMPTY; String pathToUse = Strings.replace(path, WINDOWS_SEPARATOR, UNIX_SEPARATOR);
public Map<String, MetaSql> read(Resource resource) { String content = resource.getContent(); Map<String, MetaSql> sqls = SqlsParser.parseWithoutPrefix(content); if(!sqls.isEmpty()) { PathDefParser.PathDef pd = PathDefParser.parse("/app/sqls/", resource); String prefix = Strings.replace(Strings.removeStart(pd.path, "/"), "/", ".") + "."; Map<String, MetaSql> keySqls = new LinkedHashMap<>(); sqls.forEach((k,sql) -> { //process key keySqls.put(prefix + k, sql); //source withSource(sql, resource); }); return keySqls; } return sqls; }
String fullPattern = Strings.replace(rootDir.getAbsolutePath(), File.separator, "/"); if (!pattern.startsWith("/")) { fullPattern += "/"; fullPattern = fullPattern + Strings.replace(pattern, File.separator, "/"); Set<File> result = new LinkedHashSet<File>(8); doRetrieveMatchingFiles(fullPattern, rootDir, result);
return replace(string, remove, EMPTY, -1);
protected String parseUrl(String url,ServerInfo serverInfo){ if(!needParse(url)){ return url; } URI uri = URI.create(Strings.replace(serverInfo.getServerUrl(), " ", "%20")); String resolvedUrl = Urls.resolveUrlExpr(url, uri); if(needParse(resolvedUrl)){ return serverInfo.getServerUrl()+Paths.prefixWithSlash(resolvedUrl); } return resolvedUrl; }
protected void addReplacedText(SqlStatementBuilder stm,Params params, Object p) throws IOException { Object value = eval(stm,params); String string = Converts.toString(value); if(!Strings.isEmpty(string)){ Scope scope = getScope(); if(scope == Scope.STRING){ string = Strings.replace(string, "'", "''"); } stm.append(string); } }
String currPath = Strings.replace(content.getAbsolutePath(), File.separator, "/"); if (content.isDirectory() && getPathMatcher().matchStart(fullPattern, currPath + "/")) { if (!content.canRead()) {
protected PrintProperty toPrintProperty(AppProperty p) { PrintProperty pp = new PrintProperty(); String value = protectSecret(p.getName(), p.getUnprocessedValue()); pp.name = p.getName(); pp.value = Strings.abbreviateMiddle(value, "...", 50); pp.value = Strings.replace(pp.value, "\r", "\\r"); pp.value = Strings.replace(pp.value, "\n", "\\n"); if(null == p.getSource()) { pp.source = "(n/a)"; }else if(p.getSource() instanceof Resource) { pp.source = LogUtils.getUrl((Resource)p.getSource()); }else if(p.getSource() instanceof Class) { pp.source = ((Class) p.getSource()).getSimpleName(); }else if(p.getSource() instanceof String) { pp.source = (String)p.getSource(); }else { pp.source = p.getSource().getClass().getSimpleName(); } pp.source = Strings.abbreviatePrefix(pp.source, 10, 80, "..."); pp.system = p.isSystem(); return pp; }
sqlWithOrderBy = Strings.replace(sqlWithoutOrderBy, ORDER_BY_PLACEHOLDER, orderBy); }else{ sqlWithOrderBy = db.getDialect().addOrderBy(sqlWithoutOrderBy, orderBy);