• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java VirtualFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中play.vfs.VirtualFile的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile类的具体用法?Java VirtualFile怎么用?Java VirtualFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VirtualFile类属于play.vfs包,在下文中一共展示了VirtualFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: prepare

import play.vfs.VirtualFile; //导入依赖的package包/类
@BeforeClass
public static void prepare() {
    try {
        Field f = Act.class.getDeclaredField("pluginManager");
        f.setAccessible(true);
        f.set(null, new GenericPluginManager());
    } catch (Exception e) {
        throw E.unexpected(e);
    }
    app = App.testInstance();
    config = app.config();
    RequestHandlerResolver controllerLookup = new MockRequestHandlerResolver();
    router = new Router(controllerLookup, app);
    InputStream is = TestBase.class.getResourceAsStream("/routes");
    String fc = IO.readContentAsString(is);
    builder = new RouteTableRouterBuilder(fc.split("[\r\n]+"));
    builder.build(router);
    Play.pluginCollection = new PluginCollection();
    URL url = TestBase.class.getResource("/routes");
    Play.applicationPath = new File(FastStr.of(url.getPath()).beforeLast('/').toString());
    Play.routes = VirtualFile.fromRelativePath("routes");
    play.mvc.Router.load("");
}
 
开发者ID:actframework,项目名称:actframework,代码行数:24,代码来源:RouterBenchmark.java


示例2: getAllTemplate

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * List all found templates
 * @return A list of executable templates
 */
public static List<Template> getAllTemplate() {
    List<Template> res = new ArrayList<Template>();
    for (VirtualFile virtualFile : Play.templatesPath) {
        scan(res, virtualFile);
    }
    for (VirtualFile root : Play.roots) {
        VirtualFile vf = root.child("conf/routes");
        if (vf != null && vf.exists()) {
            Template template = load(vf);
            if (template != null) {
                template.compile();
            }
        }
    }
    return res;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:21,代码来源:TemplateLoader.java


示例3: scan

import play.vfs.VirtualFile; //导入依赖的package包/类
private static void scan(List<Template> templates, VirtualFile current) {
    if (!current.isDirectory() && !current.getName().startsWith(".") && !current.getName().endsWith(".scala.html")) {
        long start = System.currentTimeMillis();
        Template template = load(current);
        if (template != null) {
            try {
                template.compile();
                if (Logger.isTraceEnabled()) {
                    Logger.trace("%sms to load %s", System.currentTimeMillis() - start, current.getName());
                }
            } catch (TemplateCompilationException e) {
                Logger.error("Template %s does not compile at line %d", e.getTemplate().name, e.getLineNumber());
                throw e;
            }
            templates.add(template);
        }
    } else if (current.isDirectory() && !current.getName().startsWith(".")) {
        for (VirtualFile virtualFile : current.list()) {
            scan(templates, virtualFile);
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:TemplateLoader.java


示例4: detectChanges

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * In PROD mode and if the routes are already loaded, this does nothing.
 * <p/>
 * <p>In DEV mode, this checks each routes file's "last modified" time to see if the routes need updated.
 *
 * @param prefix The prefix that the path of all routes in this route file start with. This prefix should not end with a '/' character.
 */
public static void detectChanges(String prefix) {
    if (Play.mode == Mode.PROD && lastLoading > 0) {
        return;
    }
    if (Play.routes.lastModified() > lastLoading) {
        load(prefix);
    } else {
        for (VirtualFile file : Play.modulesRoutes.values()) {
            if (file.lastModified() > lastLoading) {
                load(prefix);
                return;
            }
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:Router.java


示例5: redirectToStatic

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * Send a 302 redirect response.
 * @param file The Location to redirect
 */
protected static void redirectToStatic(String file) {
    try {
        VirtualFile vf = Play.getVirtualFile(file);
        if (vf == null || !vf.exists()) {
            throw new NoRouteFoundException(file);
        }
        throw new RedirectToStatic(Router.reverse(Play.getVirtualFile(file)));
    } catch (NoRouteFoundException e) {
        StackTraceElement element = PlayException.getInterestingStrackTraceElement(e);
        if (element != null) {
            throw new NoRouteFoundException(file, Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber());
        } else {
            throw e;
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:21,代码来源:Controller.java


示例6: addModule

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * Add a play application (as plugin)
 *
 * @param path The application path
 */
public static void addModule(String name, File path) {
    VirtualFile root = VirtualFile.open(path);
    modules.put(name, root);
    if (root.child("app").exists()) {
        javaPath.add(root.child("app"));
    }
    if (root.child("app/views").exists()) {
        templatesPath.add(root.child("app/views"));
    }
    if (root.child("conf/routes").exists()) {
        modulesRoutes.put(name, root.child("conf/routes"));
    }
    roots.add(root);
    if (!name.startsWith("_")) {
        Logger.info("Module %s is available (%s)", name, path.getAbsolutePath());
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:Play.java


示例7: getTransformedFilesRelativeURLs

import play.vfs.VirtualFile; //导入依赖的package包/类
ArrayList<String> getTransformedFilesRelativeURLs() throws IOException {
	ArrayList<JSSourceDatabaseEntry> all_entries = getDatabase().getSortedEntries();
	ArrayList<String> results = new ArrayList<String>(all_entries.size() + 1);
	String url;
	
	if (reduced_declaration_file.exists()) {
		try {
			url = Router.reverse(VirtualFile.open(reduced_declaration_file));
			results.add(url);
		} catch (NoRouteFoundException e) {
			throw new IOException("Play can't resolve route for " + reduced_declaration_file.getPath());
		}
	}
	
	File transformed_file;
	for (int pos = 0; pos < all_entries.size(); pos++) {
		transformed_file = all_entries.get(pos).computeTransformedFilepath(module_path, transformed_directory);
		if (transformed_file.exists() == false) {
			Loggers.Play_JSSource.warn("A transformed file don't exists: " + transformed_file);
			continue;
		}
		url = Router.reverse(VirtualFile.open(transformed_file));
		results.add(url);
	}
	return results;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:27,代码来源:JSSourceModule.java


示例8: addNews

import play.vfs.VirtualFile; //导入依赖的package包/类
public void addNews(@Required String path, @Required String title, @Required Date date, String tags) {
  checkAuthenticity();
  if (validation.hasErrors()) forbidden(validation.errorsMap().toString());
  WebPage.News parent = WebPage.forPath(path);
  if (parent.isStory()) parent = (WebPage.News) parent.parent();
  if (parent.isMonth()) parent = (WebPage.News) parent.parent();
  if (parent.isYear()) parent = (WebPage.News) parent.parent();

  String pathSuffix = new SimpleDateFormat("yyyy/MM/dd").format(date);
  File dir = new File(parent.dir.getRealFile(), pathSuffix);
  while (dir.exists()) dir = new File(dir.getPath() + "-1");
  dir.mkdirs();

  VirtualFile vdir = VirtualFile.open(dir);
  vdir.child("metadata.properties").write("title: " + title + "\ntags: " + defaultString(tags) + "\n");
  vdir.child("content.html").write(Messages.get("web.admin.defaultContent"));

  WebPage.News page = WebPage.forPath(vdir);
  redirect(page.path);
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:21,代码来源:WebAdmin.java


示例9: WebPage

import play.vfs.VirtualFile; //导入依赖的package包/类
WebPage(VirtualFile dir, String path) {
  this.dir = dir;
  this.path = path.endsWith("/") ? path : path + "/";
  level = countMatches(this.path, "/") - 1;

  metadata = loadMetadata(dir);
  title = metadata.getProperty("title");
  if (isEmpty(title)) title = generateTitle();
  template = metadata.getProperty("template", "custom");

  try {
    order = parseInt(metadata.getProperty("order", "99"));
  }
  catch (NumberFormatException e) {
    order = 99;
  }
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:18,代码来源:WebPage.java


示例10: mailLinksAreProtectedFromSpamBots

import play.vfs.VirtualFile; //导入依赖的package包/类
@Test
public void mailLinksAreProtectedFromSpamBots() {
  VirtualFile dir = mock(VirtualFile.class, RETURNS_DEEP_STUBS);
  WebPage page = new WebPage(dir, "/page");

  assertEquals("<a class=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">736f6d65626f6479406578616d706c652e636f6d</a>",
      page.processContent("<a href=\"mailto:[email protected]\">[email protected]</a>"));

  assertEquals("<a\nclass=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">736f6d65626f6479406578616d706c652e636f6d</a>",
      page.processContent("<a\nhref=\"mailto:[email protected]\">[email protected]</a>"));

  assertEquals("<a class=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">Ivan Examploff</a>",
      page.processContent("<a href=\"mailto:[email protected]\">Ivan Examploff</a>"));

  assertEquals("<a class=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">Ivan\nExamploff</a>",
      page.processContent("<a href=\"mailto:[email protected]\">Ivan\nExamploff</a>"));
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:18,代码来源:WebPageTest.java


示例11: onLoad

import play.vfs.VirtualFile; //导入依赖的package包/类
@Override
public void onLoad() {
    VirtualFile appRoot = VirtualFile.open(Play.applicationPath);
    Play.javaPath.add(appRoot.child("test"));
    for (VirtualFile module : Play.modules.values()) {
        File modulePath = module.getRealFile();
        if (!modulePath.getAbsolutePath().startsWith(Play.frameworkPath.getAbsolutePath()) && !Play.javaPath.contains(module.child("test"))) {
            Play.javaPath.add(module.child("test"));
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:12,代码来源:TestRunnerPlugin.java


示例12: CompilationException

import play.vfs.VirtualFile; //导入依赖的package包/类
public CompilationException(VirtualFile source, String problem, int line, int start, int end) {
    super(problem);
    this.problem = problem;
    this.line = line;
    this.source = source;
    this.start = start;
    this.end = end;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:9,代码来源:CompilationException.java


示例13: parse

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * Parse a route file.
 * If an action starts with <i>"plugin:name"</i>, replace that route by the ones declared
 * in the plugin route file denoted by that <i>name</i>, if found.
 *
 * @param routeFile
 * @param prefix    The prefix that the path of all routes in this route file start with. This prefix should not
 *                  end with a '/' character.
 */
static void parse(VirtualFile routeFile, String prefix) {
    String fileAbsolutePath = routeFile.getRealFile().getAbsolutePath();
    String content = routeFile.contentAsString();
    if (content.indexOf("${") > -1 || content.indexOf("#{") > -1 || content.indexOf("%{") > -1) {
        // Mutable map needs to be passed in.
        content = TemplateLoader.load(routeFile).render(new HashMap<String, Object>(16));
    }
    parse(content, prefix, fileAbsolutePath);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:19,代码来源:Router.java


示例14: getResourceAsStream

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * You know ...
 */
@Override
public InputStream getResourceAsStream(String name) {
    for (VirtualFile vf : Play.javaPath) {
        VirtualFile res = vf.child(name);
        if (res != null && res.exists()) {
            return res.inputstream();
        }
    }
    return super.getResourceAsStream(name);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:14,代码来源:ApplicationClassloader.java


示例15: getResource

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * You know ...
 */
@Override
public URL getResource(String name) {
    for (VirtualFile vf : Play.javaPath) {
        VirtualFile res = vf.child(name);
        if (res != null && res.exists()) {
            try {
                return res.getRealFile().toURI().toURL();
            } catch (MalformedURLException ex) {
                throw new UnexpectedException(ex);
            }
        }
    }
    return super.getResource(name);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:18,代码来源:ApplicationClassloader.java


示例16: getResources

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * You know ...
 */
@Override
public Enumeration<URL> getResources(String name) throws IOException {
    List<URL> urls = new ArrayList<URL>();
    for (VirtualFile vf : Play.javaPath) {
        VirtualFile res = vf.child(name);
        if (res != null && res.exists()) {
            try {
                urls.add(res.getRealFile().toURI().toURL());
            } catch (MalformedURLException ex) {
                throw new UnexpectedException(ex);
            }
        }
    }
    Enumeration<URL> parent = super.getResources(name);
    while (parent.hasMoreElements()) {
        URL next = parent.nextElement();
        if (!urls.contains(next)) {
            urls.add(next);
        }
    }
    final Iterator<URL> it = urls.iterator();
    return new Enumeration<URL>() {

        public boolean hasMoreElements() {
            return it.hasNext();
        }

        public URL nextElement() {
            return it.next();
        }
    };
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:36,代码来源:ApplicationClassloader.java


示例17: getAllClasses

import play.vfs.VirtualFile; //导入依赖的package包/类
List<ApplicationClass> getAllClasses(String basePackage) {
    List<ApplicationClass> res = new ArrayList<ApplicationClass>();
    for (VirtualFile virtualFile : Play.javaPath) {
        res.addAll(getAllClasses(virtualFile, basePackage));
    }
    return res;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:8,代码来源:ApplicationClassloader.java


示例18: scan

import play.vfs.VirtualFile; //导入依赖的package包/类
void scan(List<ApplicationClass> classes, String packageName, VirtualFile current) {
    if (!current.isDirectory()) {
        if (current.getName().endsWith(".java") && !current.getName().startsWith(".")) {
            String classname = packageName + current.getName().substring(0, current.getName().length() - 5);
            classes.add(Play.classes.getApplicationClass(classname));
        }
    } else {
        for (VirtualFile virtualFile : current.list()) {
            scan(classes, packageName + current.getName() + ".", virtualFile);
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:13,代码来源:ApplicationClassloader.java


示例19: scanPrecompiled

import play.vfs.VirtualFile; //导入依赖的package包/类
void scanPrecompiled(List<ApplicationClass> classes, String packageName, VirtualFile current) {
    if (!current.isDirectory()) {
        if (current.getName().endsWith(".class") && !current.getName().startsWith(".")) {
            String classname = packageName.substring(5) + current.getName().substring(0, current.getName().length() - 6);
            classes.add(new ApplicationClass(classname));
        }
    } else {
        for (VirtualFile virtualFile : current.list()) {
            scanPrecompiled(classes, packageName + current.getName() + ".", virtualFile);
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:13,代码来源:ApplicationClassloader.java


示例20: computePathHash

import play.vfs.VirtualFile; //导入依赖的package包/类
public synchronized int computePathHash(List<VirtualFile> paths) {
    StringBuffer buf = new StringBuffer();
    for (VirtualFile virtualFile : paths) {
        scan(buf, virtualFile);
    }
    // TODO: should use better hashing-algorithm.. MD5? SHA1?
    // I think hashCode() has too many collisions..
    return buf.toString().hashCode();
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:10,代码来源:ClassStateHashCreator.java



注:本文中的play.vfs.VirtualFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JSONScanner类代码示例发布时间:2022-05-22
下一篇:
Java RefreshSuperUserGroupsConfigurationRequestProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap