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

Java NameScope类代码示例

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

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



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

示例1: save

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public synchronized void save(Note note) throws IOException {
  GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.setPrettyPrinting();
  Gson gson = gsonBuilder.create();
  String json = gson.toJson(note);

  FileObject rootDir = getRootDir();

  FileObject noteDir = rootDir.resolveFile(note.id(), NameScope.CHILD);

  if (!noteDir.exists()) {
    noteDir.createFolder();
  }
  if (!isDirectory(noteDir)) {
    throw new IOException(noteDir.getName().toString() + " is not a directory");
  }

  FileObject noteJson = noteDir.resolveFile(".note.json", NameScope.CHILD);
  // false means not appending. creates file if not exists
  OutputStream out = noteJson.getContent().getOutputStream(false);
  out.write(json.getBytes(conf.getString(ConfVars.ZEPPELIN_ENCODING)));
  out.close();
  noteJson.moveTo(noteDir.resolveFile("note.json", NameScope.CHILD));
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:26,代码来源:VFSNotebookRepo.java


示例2: remove

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public void remove(String noteId) throws IOException {
  FileObject rootDir = fsManager.resolveFile(getPath("/"));
  FileObject noteDir = rootDir.resolveFile(noteId, NameScope.CHILD);

  if (!noteDir.exists()) {
    // nothing to do
    return;
  }

  if (!isDirectory(noteDir)) {
    // it is not look like zeppelin note savings
    throw new IOException("Can not remove " + noteDir.getName().toString());
  }

  noteDir.delete(Selectors.SELECT_SELF_AND_CHILDREN);
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:18,代码来源:VFSNotebookRepo.java


示例3: save

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public synchronized void save(Note note, AuthenticationInfo subject) throws IOException {
  LOG.info("Saving note:" + note.getId());
  String json = note.toJson();

  FileObject rootDir = getRootDir();

  FileObject noteDir = rootDir.resolveFile(note.getId(), NameScope.CHILD);

  if (!noteDir.exists()) {
    noteDir.createFolder();
  }
  if (!isDirectory(noteDir)) {
    throw new IOException(noteDir.getName().toString() + " is not a directory");
  }

  FileObject noteJson = noteDir.resolveFile(".note.json", NameScope.CHILD);
  // false means not appending. creates file if not exists
  OutputStream out = noteJson.getContent().getOutputStream(false);
  out.write(json.getBytes(conf.getString(ConfVars.ZEPPELIN_ENCODING)));
  out.close();
  noteJson.moveTo(noteDir.resolveFile("note.json", NameScope.CHILD));
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:24,代码来源:VFSNotebookRepo.java


示例4: remove

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public void remove(String noteId, AuthenticationInfo subject) throws IOException {
  FileObject rootDir = fsManager.resolveFile(getPath("/"));
  FileObject noteDir = rootDir.resolveFile(noteId, NameScope.CHILD);

  if (!noteDir.exists()) {
    // nothing to do
    return;
  }

  if (!isDirectory(noteDir)) {
    // it is not look like zeppelin note savings
    throw new IOException("Can not remove " + noteDir.getName().toString());
  }

  noteDir.delete(Selectors.SELECT_SELF_AND_CHILDREN);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:18,代码来源:VFSNotebookRepo.java


示例5: loadResource

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Searches through the search path of for the first class or resource
 * with specified name.
 * @param name The resource to load.
 * @return The Resource.
 * @throws FileSystemException if an error occurs.
 */
private Resource loadResource(final String name) throws FileSystemException
{
    final Iterator<FileObject> it = resources.iterator();
    while (it.hasNext())
    {
        final FileObject baseFile = it.next();
        final FileObject file =
            baseFile.resolveFile(name, NameScope.DESCENDENT_OR_SELF);
        if (file.exists())
        {
            return new Resource(name, baseFile, file);
        }
    }

    return null;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:24,代码来源:VFSClassLoader.java


示例6: createFile

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Creates a file object.  This method is called only if the requested
 * file is not cached.
 */
@Override
protected FileObject createFile(final AbstractFileName name) throws Exception
{
    // Find the file that the name points to
    final FileName junctionPoint = getJunctionForFile(name);
    final FileObject file;
    if (junctionPoint != null)
    {
        // Resolve the real file
        final FileObject junctionFile = junctions.get(junctionPoint);
        final String relName = junctionPoint.getRelativeName(name);
        file = junctionFile.resolveFile(relName, NameScope.DESCENDENT_OR_SELF);
    }
    else
    {
        file = null;
    }

    // Return a wrapper around the file
    return new DelegateFileObject(name, this, file);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:26,代码来源:VirtualFileSystem.java


示例7: assertSameContent

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Asserts every file in a folder exists and has the expected content.
 */
private void assertSameContent(final FileInfo expected,
                               final FileObject folder) throws Exception
{
    for (Iterator<FileInfo> iterator = expected.children.values().iterator(); iterator.hasNext();)
    {
        final FileInfo fileInfo = iterator.next();
        final FileObject child = folder.resolveFile(fileInfo.baseName, NameScope.CHILD);

        assertTrue(child.getName().toString(), child.exists());
        if (fileInfo.type == FileType.FILE)
        {
            assertSameContent(fileInfo.content, child);
        }
        else
        {
            assertSameContent(fileInfo, child);
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:23,代码来源:ContentTests.java


示例8: testChildName

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Tests child file names.
 */
public void testChildName() throws Exception
{
    final FileName baseName = getReadFolder().getName();
    final String basePath = baseName.getPath();
    final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD);

    // Test path is absolute
    assertTrue("is absolute", basePath.startsWith("/"));

    // Test base name
    assertEquals("base name", "some-child", name.getBaseName());

    // Test absolute path
    assertEquals("absolute path", basePath + "/some-child", name.getPath());

    // Test parent path
    assertEquals("parent absolute path", basePath, name.getParent().getPath());

    // Try using a compound name to find a child
    assertBadName(name, "a/b", NameScope.CHILD);

    // Check other invalid names
    checkDescendentNames(name, NameScope.CHILD);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:28,代码来源:NamingTests.java


示例9: assertSameName

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Checks that a relative name resolves to the expected absolute path.
 * Tests both forward and back slashes.
 */
private void assertSameName(final String expectedPath,
                            final FileName baseName,
                            final String relName,
                            final NameScope scope)
    throws Exception
{
    // Try the supplied name
    FileName name = getManager().resolveName(baseName, relName, scope);
    assertEquals(expectedPath, name.getPath());

    String temp;

    // Replace the separators
    temp = relName.replace('\\', '/');
    name = getManager().resolveName(baseName, temp, scope);
    assertEquals(expectedPath, name.getPath());

    // And again
    temp = relName.replace('/', '\\');
    name = getManager().resolveName(baseName, temp, scope);
    assertEquals(expectedPath, name.getPath());
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:27,代码来源:NamingTests.java


示例10: testDescendentName

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Tests descendent name resolution.
 */
public void testDescendentName()
    throws Exception
{
    final FileName baseName = getReadFolder().getName();

    // Test direct child
    String path = baseName.getPath() + "/some-child";
    assertSameName(path, baseName, "some-child", NameScope.DESCENDENT);

    // Test compound name
    path = path + "/grand-child";
    assertSameName(path, baseName, "some-child/grand-child", NameScope.DESCENDENT);

    // Test relative names
    assertSameName(path, baseName, "./some-child/grand-child", NameScope.DESCENDENT);
    assertSameName(path, baseName, "./nada/../some-child/grand-child", NameScope.DESCENDENT);
    assertSameName(path, baseName, "some-child/./grand-child", NameScope.DESCENDENT);

    // Test badly formed descendent names
    checkDescendentNames(baseName, NameScope.DESCENDENT);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:25,代码来源:NamingTests.java


示例11: checkAbsoluteNames

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Tests resolution of absolute names.
 */
private void checkAbsoluteNames(final FileName name) throws Exception
{
    // Root
    assertSameName("/", name, "/");
    assertSameName("/", name, "//");
    assertSameName("/", name, "/.");
    assertSameName("/", name, "/some file/..");

    // Some absolute names
    assertSameName("/a", name, "/a");
    assertSameName("/a", name, "/./a");
    assertSameName("/a", name, "/a/.");
    assertSameName("/a/b", name, "/a/b");

    // Some bad names
    assertBadName(name, "/..", NameScope.FILE_SYSTEM);
    assertBadName(name, "/a/../..", NameScope.FILE_SYSTEM);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:NamingTests.java


示例12: resolveFile

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public FileObject resolveFile(String name, NameScope scope) {
    try {
        return FileObject.TO_DA_FILE_OBJECT.valueOf(this.fileObject.resolveFile(name, scope));
    } catch (FileSystemException e) {
        throw new VFSFileSystemException(e);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:9,代码来源:FileObject.java


示例13: getNote

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
private Note getNote(FileObject noteDir) throws IOException {
    if (!isDirectory(noteDir)) {
      throw new IOException(noteDir.getName().toString() + " is not a directory");
    }

    FileObject noteJson = noteDir.resolveFile("note.json", NameScope.CHILD);
    if (!noteJson.exists()) {
      throw new IOException(noteJson.getName().toString() + " not found");
    }

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setPrettyPrinting();
    Gson gson = gsonBuilder.create();

    FileContent content = noteJson.getContent();
    InputStream ins = content.getInputStream();
    String json = IOUtils.toString(ins, conf.getString(ConfVars.ZEPPELIN_ENCODING));
    ins.close();

    Note note = gson.fromJson(json, Note.class);
//    note.setReplLoader(replLoader);
//    note.jobListenerFactory = jobListenerFactory;

    for (Paragraph p : note.getParagraphs()) {
      if (p.getStatus() == Status.PENDING || p.getStatus() == Status.RUNNING) {
        p.setStatus(Status.ABORT);
      }
    }

    return note;
  }
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:32,代码来源:VFSNotebookRepo.java


示例14: get

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public Note get(String noteId) throws IOException {
  FileObject rootDir = fsManager.resolveFile(getPath("/"));
  FileObject noteDir = rootDir.resolveFile(noteId, NameScope.CHILD);

  return getNote(noteDir);
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:8,代码来源:VFSNotebookRepo.java


示例15: getNote

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
private Note getNote(FileObject noteDir) throws IOException {
  if (!isDirectory(noteDir)) {
    throw new IOException(noteDir.getName().toString() + " is not a directory");
  }

  FileObject noteJson = noteDir.resolveFile("note.json", NameScope.CHILD);
  if (!noteJson.exists()) {
    throw new IOException(noteJson.getName().toString() + " not found");
  }
  
  FileContent content = noteJson.getContent();
  InputStream ins = content.getInputStream();
  String json = IOUtils.toString(ins, conf.getString(ConfVars.ZEPPELIN_ENCODING));
  ins.close();

  Note note = Note.fromJson(json);

  for (Paragraph p : note.getParagraphs()) {
    if (p.getStatus() == Status.PENDING || p.getStatus() == Status.RUNNING) {
      p.setStatus(Status.ABORT);
    }

    List<ApplicationState> appStates = p.getAllApplicationStates();
    if (appStates != null) {
      for (ApplicationState app : appStates) {
        if (app.getStatus() != ApplicationState.Status.ERROR) {
          app.setStatus(ApplicationState.Status.UNLOADED);
        }
      }
    }
  }

  return note;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:35,代码来源:VFSNotebookRepo.java


示例16: get

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
public Note get(String noteId, AuthenticationInfo subject) throws IOException {
  FileObject rootDir = fsManager.resolveFile(getPath("/"));
  FileObject noteDir = rootDir.resolveFile(noteId, NameScope.CHILD);

  return getNote(noteDir);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:8,代码来源:VFSNotebookRepo.java


示例17: isAncestor

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Determines if another file name is an ancestor of this file name.
 * @param ancestor The FileName to check.
 * @return true if the FileName is an ancestor, false otherwise.
 */
public boolean isAncestor(final FileName ancestor)
{
    if (!ancestor.getRootURI().equals(getRootURI()))
    {
        return false;
    }
    return checkName(ancestor.getPath(), getPath(), NameScope.DESCENDENT);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:14,代码来源:AbstractFileName.java


示例18: isDescendent

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Determines if another file name is a descendent of this file name.
 * @param descendent The FileName to check.
 * @param scope The NameScope.
 * @return true if the FileName is a descendent, false otherwise.
 */
public boolean isDescendent(final FileName descendent,
                            final NameScope scope)
{
    if (!descendent.getRootURI().equals(getRootURI()))
    {
        return false;
    }
    return checkName(getPath(), descendent.getPath(), scope);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:16,代码来源:AbstractFileName.java


示例19: resolveFile

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
@Override
    public FileObject resolveFile(String name, NameScope scope) throws FileSystemException
    {
    synchronized (this)
    {
            return super.resolveFile(name, scope);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:9,代码来源:SynchronizedFileObject.java


示例20: checkDescendentNames

import org.apache.commons.vfs2.NameScope; //导入依赖的package包/类
/**
 * Name resolution tests that are common for CHILD or DESCENDENT scope.
 */
private void checkDescendentNames(final FileName name,
                                  final NameScope scope)
    throws Exception
{
    // Make some assumptions about the name
    assertTrue(!name.getPath().equals("/"));
    assertTrue(!name.getPath().endsWith("/a"));
    assertTrue(!name.getPath().endsWith("/a/b"));

    // Test names with the same prefix
    String path = name.getPath() + "/a";
    assertSameName(path, name, path, scope);
    assertSameName(path, name, "../" + name.getBaseName() + "/a", scope);

    // Test an empty name
    assertBadName(name, "", scope);

    // Test . name
    assertBadName(name, ".", scope);
    assertBadName(name, "./", scope);

    // Test ancestor names
    assertBadName(name, "..", scope);
    assertBadName(name, "../a", scope);
    assertBadName(name, "../" + name.getBaseName() + "a", scope);
    assertBadName(name, "a/..", scope);

    // Test absolute names
    assertBadName(name, "/", scope);
    assertBadName(name, "/a", scope);
    assertBadName(name, "/a/b", scope);
    assertBadName(name, name.getPath(), scope);
    assertBadName(name, name.getPath() + "a", scope);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:38,代码来源:NamingTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ElGamalPublicKeyParameters类代码示例发布时间:2022-05-22
下一篇:
Java DecoratedRandomTextPaster类代码示例发布时间: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