private static ProfiledKey parse(String keyWithPrefix) { int index = keyWithPrefix.indexOf('.'); ProfiledKey pk = new ProfiledKey(); pk.profile = Strings.removeStart(keyWithPrefix.substring(0, index), PROFILE_PREFIX); pk.key = keyWithPrefix.substring(index+1); return pk; } }
protected MComplexTypeRef readRefType(String ref) { ref = Strings.removeStart(ref, "#/definitions/"); return new MComplexTypeRef(ref); }
protected String removePrefixAndSuffix(String expr) { if (expr.startsWith("#{")) { return Strings.removeEnd(Strings.removeStart(expr, "#{"), "}"); } else { return expr; } } }
@Override public String resolveDesc(String desc) { //todo : message key ? //todo : external doc if (desc.startsWith(EXTERNAL_DOC_PREFIX)) { return resolveDoc(Strings.removeStart(desc, EXTERNAL_DOC_PREFIX)); } return desc; }
jarFile = Strings.removeStart(jarFile, "war:"); separatorIndex = jarFile.indexOf("*/BOOT-INF/"); if(separatorIndex != -1) {
public String validate(Map params) throws Exception { final MetaDataSource mds = apiReader.readDb(params); return dsf.execWithResult(mds, db -> { String s = Strings.removeStart(mds.getJdbcUrl(), "jdbc:"); int index = s.indexOf('?'); if(index > 0) { s = s.substring(0, index); } return s; }); }
private static Map<String, String> scanAllIdentifiers(String rootPath, String suffix) { Map<String, String> map = new LinkedHashMap<>(); for(Resource resource : Resources.scan("classpath*:" + rootPath + "/**/*." + suffix)) { String name = Strings.removeStart(resource.getClasspath(), rootPath + "/"); name = Strings.removeEnd(name, "." + suffix); map.put(name, "classpath:" + resource.getClasspath()); } return map; } }
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; }
public static String path(Resource resource) { String url = resource.getURLString(); if(null != appDirectoryUrl && url.startsWith(appDirectoryUrl)) { return "~/" + Urls.decode(Strings.removeStart(url, appDirectoryUrl)); } if(resource.hasClasspath()) { return resource.getClasspath(); } return Urls.decode(url); }
public Resource[] getDirs(String name) { String path = Strings.removeStart(name, "./") + "/"; List<Resource> list = new ArrayList<>(); Collections2.addAll(list, Resources.scan("classpath*:META-INF/jmms/app/" + path)); Collections2.addAll(list, Resources.scan("classpath*:META-INF/app/" + path)); if(hasAppDirectory()) { Resource r = Resources.getResource(getAppDirectory(), path); if(null != r && r.exists()) { list.add(r); } } return list.toArray(new Resource[0]); }
private void loadServletContextResource(ServletContext sc, String path, String pathPrefix) { ServletResource resource = new SimpleServletResource(sc, path); if(!resource.isDirectory()) { add(resource, Strings.removeStart(path, pathPrefix)); }else{ loadServletContextResources(sc, path, pathPrefix); } }
sql.append(Strings.removeStart(line, "{{")).append('\n'); continue;
public Resource[] getResources(String path) { path = Strings.removeStart(path, "./"); List<Resource> list = new ArrayList<>(); Collections2.addAll(list, Resources.scan("classpath*:META-INF/jmms/app/" + path)); Collections2.addAll(list, Resources.scan("classpath*:META-INF/app/" + path)); //Collections2.addAll(list, Resources.scan("classpath:app/" + path)); if(hasAppDirectory()) { Collections2.addAll(list, Resources.scan(getAppDirectory(), path)); } return list.toArray(new Resource[0]); }
for(Resource r : rs) { if(r.exists()) { Path path = doc.resolve(Strings.removeStart(r.getClasspath(), root)); File file = path.toFile(); if(!file.exists()) {
public String getFilePath(Resource resource) { if(Config.hasAppDirectory()) { return Strings.removeStart(resource.getFilepath(), cfg.getAppDirectory().getFilepath() + "/"); }else if(resource.hasClasspath()) { return resource.getClasspath(); }else { return resource.getFilepath(); } }
public Resource getResource(String path) { try { Resource r = hasAppDirectory() ? getAppDirectory().createRelative(path) : null; if(null == r || !r.exists()) { ResourceSet rs = Resources.scan("classpath*:META-INF/app/" + Strings.removeStart(path, "./")); if(!rs.isEmpty()) { //todo: handle multi resources scanned. r = rs.get(0); } } return r; }catch (IOException e) { throw Exceptions.uncheck(e); } }
protected void createApiPath(ApiMetadataContext context, ApiMetadataBuilder md, Route route) { PathTemplate pt = route.getPathTemplate(); String pathTemplate = Strings.removeStart(pt.getTemplate(), md.getBasePath()); if(!Strings.startsWith(pathTemplate,"/")){ pathTemplate = "/"+pathTemplate; } MApiPathBuilder path = md.getPath(pathTemplate); if(null == path) { path = new MApiPathBuilder(); path.setPathTemplate(pathTemplate); md.addPath(path); } log.debug("Path {} -> {} :", pt, route.getAction()); path.addOperation(createOperation(context, md, route)); }