本文整理汇总了Java中play.vfs.VirtualFile.child方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.child方法的具体用法?Java VirtualFile.child怎么用?Java VirtualFile.child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.vfs.VirtualFile
的用法示例。
在下文中一共展示了VirtualFile.child方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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();
}
};
}
示例5: getJava
import play.vfs.VirtualFile; //导入方法依赖的package包/类
/**
* Retrieve the corresponding source file for a given class name.
* It handles innerClass too !
* @param name The fully qualified class name
* @return The virtualFile if found
*/
public static VirtualFile getJava(String name) {
String fileName = name;
if (fileName.contains("$")) {
fileName = fileName.substring(0, fileName.indexOf("$"));
}
fileName = fileName.replace(".", "/") + ".java";
for (VirtualFile path : Play.javaPath) {
VirtualFile javaFile = path.child(fileName);
if (javaFile.exists()) {
return javaFile;
}
}
return null;
}
示例6: loadMetadata
import play.vfs.VirtualFile; //导入方法依赖的package包/类
private static Properties loadMetadata(VirtualFile dir) {
VirtualFile metaFile = dir.child("metadata.properties");
if (metaFile.exists()) {
try (Reader reader = new InputStreamReader(metaFile.inputstream(), "UTF-8")) {
Properties metadata = new Properties();
metadata.load(reader);
return metadata;
}
catch (IOException e) {
logger.error("Cannot load " + metaFile, e);
}
}
return new Properties();
}
示例7: mockChildDir
import play.vfs.VirtualFile; //导入方法依赖的package包/类
private VirtualFile mockChildDir(String name, String ... metadata) {
VirtualFile dir = mock(VirtualFile.class, RETURNS_DEEP_STUBS);
when(dir.isDirectory()).thenReturn(true);
when(dir.getName()).thenReturn(name);
when(dir.getRealFile().getPath()).thenReturn("/" + name);
VirtualFile metadataFile = dir.child("metadata.properties");
when(metadataFile.exists()).thenReturn(true);
String m = (metadata.length == 0) ? "a=b" : metadata[0];
when(metadataFile.inputstream()).thenReturn(new ByteArrayInputStream(m.getBytes()));
return dir;
}