当前位置: 首页>>代码示例>>Java>>正文


Java Capability类代码示例

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


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

示例1: createCommunicationLink

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
public Part createCommunicationLink() throws IOException, MessagingException
{
    if (mimeStream != null)
    {
        closeMimeStream();
    }

    FileObject parentLayer = getParentLayer();
    if (!parentLayer.exists())
    {
        return null;
    }

    if (parentLayer.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ))
    {
        mimeStream = new SharedRandomContentInputStream(parentLayer);
    }
    else
    {
        mimeStream = getParentLayer().getContent().getInputStream();
    }
    return new MimeMessage(null, mimeStream);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:24,代码来源:MimeFileSystem.java

示例2: SharedRandomContentInputStream

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
private SharedRandomContentInputStream(final Set<SharedRandomContentInputStream> createdStreams, final FileObject fo, final long fileStart, final long fileEnd, final InputStream is) throws FileSystemException
{
    super(is);

    if (!fo.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ))
    {
        throw new FileSystemException("vfs.util/missing-capability.error", Capability.RANDOM_ACCESS_READ);
    }

    this.fo = fo;
    this.fileStart = fileStart;
    this.fileEnd = fileEnd;
    this.createdStreams = createdStreams;

    synchronized(createdStreams)
    {
        createdStreams.add(this);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:20,代码来源:SharedRandomContentInputStream.java

示例3: handleOutOfDateFile

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Handles a single source file.
 */
@Override
protected void handleOutOfDateFile(final FileObject srcFile,
                                   final FileObject destFile)
    throws FileSystemException
{
    if (!tryRename || !srcFile.canRenameTo(destFile))
    {
        super.handleOutOfDateFile(srcFile, destFile);

        log("Deleting " + srcFile);
        srcFile.delete(Selectors.SELECT_SELF);
    }
    else
    {
        log("Rename " + srcFile + " to " + destFile);
        srcFile.moveTo(destFile);
        if (!isPreserveLastModified()
            && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE))
        {
            destFile.getContent().setLastModifiedTime(System.currentTimeMillis());
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:27,代码来源:MoveTask.java

示例4: handleOutOfDateFile

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Handles an out-of-date file.
 * @param srcFile The source FileObject.
 * @param destFile The destination FileObject.
 */
@Override
protected void handleOutOfDateFile(final FileObject srcFile,
                                   final FileObject destFile)
    throws FileSystemException
{
    log("Copying " + srcFile + " to " + destFile);
    destFile.copyFrom(srcFile, Selectors.SELECT_SELF);
    if (preserveLastModified
        && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED)
        && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE))
    {
        final long lastModTime = srcFile.getContent().getLastModifiedTime();
        destFile.getContent().setLastModifiedTime(lastModTime);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:21,代码来源:CopyTask.java

示例5: addCapabilities

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Adds the capabilities of this file system.
 */
@Override
protected void addCapabilities(final Collection<Capability> caps)
{
    // TODO - this isn't really true
    caps.add(Capability.ATTRIBUTES);
    caps.add(Capability.CREATE);
    caps.add(Capability.DELETE);
    caps.add(Capability.GET_TYPE);
    caps.add(Capability.JUNCTIONS);
    caps.add(Capability.GET_LAST_MODIFIED);
    caps.add(Capability.SET_LAST_MODIFIED_FILE);
    caps.add(Capability.SET_LAST_MODIFIED_FOLDER);
    caps.add(Capability.LIST_CHILDREN);
    caps.add(Capability.READ_CONTENT);
    caps.add(Capability.SIGNING);
    caps.add(Capability.WRITE_CONTENT);
    caps.add(Capability.APPEND_CONTENT);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:VirtualFileSystem.java

示例6: verifyPackage

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Verify the package loaded with class loader.
 */
private void verifyPackage(final Package pack,
                           final boolean sealed)
{
    if (getBaseFolder().getFileSystem().hasCapability(Capability.MANIFEST_ATTRIBUTES))
    {
        assertEquals("ImplTitle", pack.getImplementationTitle());
        assertEquals("ImplVendor", pack.getImplementationVendor());
        assertEquals("1.1", pack.getImplementationVersion());
        assertEquals("SpecTitle", pack.getSpecificationTitle());
        assertEquals("SpecVendor", pack.getSpecificationVendor());
        assertEquals("1.0", pack.getSpecificationVersion());
        assertEquals(sealed, pack.isSealed());
    }
    else
    {
        assertNull(pack.getImplementationTitle());
        assertNull(pack.getImplementationVendor());
        assertNull(pack.getImplementationVersion());
        assertNull(pack.getSpecificationTitle());
        assertNull(pack.getSpecificationVendor());
        assertNull(pack.getSpecificationVersion());
        assertFalse(pack.isSealed());
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:28,代码来源:VfsClassLoaderTests.java

示例7: testFolderContent

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Tests that folders have no content.
 */
public void testFolderContent() throws Exception
{
    if (getReadFolder().getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT))
    {
        // test wont fail
        return;
    }

    // Try getting the content of a folder
    FileObject folder = getReadFolder().resolveFile("dir1");
    try
    {
        folder.getContent().getInputStream();
        fail();
    }
    catch (FileSystemException e)
    {
        assertSameMessage("vfs.provider/read-not-file.error", folder, e);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:24,代码来源:ProviderReadTests.java

示例8: testFolderURL

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Tests that folders have no content.
 */
public void testFolderURL() throws Exception
{
    final FileObject folder = getReadFolder().resolveFile("dir1");
    if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT))
    {
        // test might not fail on e.g. HttpFileSystem as there are no direcotries.
        // A Directory do have a content on http. e.g a generated directory listing or the index.html page.
        return;
    }

    assertTrue(folder.exists());

    // Try getting the content of a folder
    try
    {
        folder.getURL().openConnection().getInputStream();
        fail();
    }
    catch (final IOException e)
    {
        assertSameMessage("vfs.provider/read-not-file.error", folder, e);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:27,代码来源:UrlStructureTests.java

示例9: getCapabilities

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
@Test
public void getCapabilities() throws FileSystemException {
  final AtomicBoolean called = new AtomicBoolean( false );
  String scheme = "scheme";
  HadoopConfiguration config =
    new HadoopConfiguration( VFS.getManager().resolveFile( "ram:///" ), "id", "name", new MockHadoopShim(), null,
      null, null );
  FileProvider provider = new MockFileProvider() {
    @Override
    public Collection<Capability> getCapabilities() {
      called.set( true );
      return null;
    }
  };

  HadoopConfigurationFileSystemManager fsm = createTestFileSystemManager( config, scheme, provider );
  ActiveHadoopShimFileProvider p = new ActiveHadoopShimFileProvider( fsm, scheme );
  p.getCapabilities();

  assertTrue( "Expected provider method not called", called.get() );
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:22,代码来源:ActiveHadoopShimFileProviderTest.java

示例10: CommonsVfsConnection

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
public CommonsVfsConnection(final ConnectionDescription desc, final FileSystemAuthProvider fsAuthProvider) throws FileSystemException {
	try {
		this.desc = desc;
		FileSystemOptions options = new FileSystemOptions();
		if (null != fsAuthProvider) {
			fsAuthProvider.authSetup(desc, options);
		}
		base = VFS.getManager().resolveFile(desc.getUri().toString(), options);
		root = new AbstractFile(this, ".", null, true, base.exists());
		canSetLastModifiedFile = base.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE);
		canSetLastModifiedFolder = base.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER);
	}
	catch (org.apache.commons.vfs2.FileSystemException e) {
		throw new FileSystemException(e);
	}
}
 
开发者ID:fullsync,项目名称:fullsync,代码行数:17,代码来源:CommonsVfsConnection.java

示例11: accept

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Checks to see if the file can be written to.
 * 
 * @param fileInfo
 *            the File to check
 * 
 * @return {@code true} if the file can be written to, otherwise
 *         {@code false}.
 */
@Override
public boolean accept(final FileSelectInfo fileInfo) {
    try {
        final FileSystem fileSystem = fileInfo.getFile().getFileSystem();
        if (fileInfo.getFile().exists()) {
            if (!fileSystem.hasCapability(Capability.WRITE_CONTENT)) {
                return false;
            }
            return fileInfo.getFile().isWriteable();
        } else {
            if (!fileSystem.hasCapability(Capability.CREATE)) {
                return false;
            }
            return fileInfo.getFile().getParent().isWriteable();
        }
    } catch (final FileSystemException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:29,代码来源:CanWriteFileFilter.java

示例12: testAddCapabilities

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
@Test
public void testAddCapabilities() throws Exception {
  Collection<Capability> capabilities = new ArrayList<>();
  fileSystem.addCapabilities( capabilities );
  assertTrue( capabilities.contains( Capability.CREATE ) );
  assertTrue( capabilities.contains( Capability.DELETE ) );
  assertTrue( capabilities.contains( Capability.RENAME ) );
  assertTrue( capabilities.contains( Capability.GET_TYPE ) );
  assertTrue( capabilities.contains( Capability.LIST_CHILDREN ) );
  assertTrue( capabilities.contains( Capability.READ_CONTENT ) );
  assertTrue( capabilities.contains( Capability.URI ) );
  assertTrue( capabilities.contains( Capability.WRITE_CONTENT ) );
  assertTrue( capabilities.contains( Capability.GET_LAST_MODIFIED ) );
  assertTrue( capabilities.contains( Capability.RANDOM_ACCESS_READ ) );
  assertFalse( capabilities.contains( Capability.RANDOM_ACCESS_WRITE ) );

}
 
开发者ID:pentaho,项目名称:pentaho-s3-vfs,代码行数:18,代码来源:S3FileSystemTest.java

示例13: addCapabilities

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Returns the capabilities of this file system.
 */
@Override
protected void addCapabilities(final Collection<Capability> caps)
{
    // super.addCapabilities(caps);
    caps.addAll(JarFileProvider.capabilities);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:10,代码来源:JarFileSystem.java

示例14: getProviderCapabilities

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Get the capabilities for a given scheme.
 *
 * @param scheme The scheme to located.
 * @return A Collection of capabilities.
 * @throws FileSystemException if the given scheme is not konwn
 */
public Collection<Capability> getProviderCapabilities(final String scheme)
        throws FileSystemException
{
    FileProvider provider = providers.get(scheme);
    if (provider == null)
    {
        throw new FileSystemException("vfs.impl/unknown-scheme.error",
                new Object[] {scheme});
    }

    return provider.getCapabilities();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:20,代码来源:DefaultFileSystemManager.java

示例15: getRequiredCaps

import org.apache.commons.vfs2.Capability; //导入依赖的package包/类
/**
 * Returns the capabilities required by the tests of this test case.
 */
@Override
protected Capability[] getRequiredCaps()
{
    return new Capability[]
    {
        Capability.READ_CONTENT,
        Capability.URI
    };
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:13,代码来源:VfsClassLoaderTests.java


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