Package org.apache.commons.vfs2

Examples of org.apache.commons.vfs2.FileListener


     * @param event The FileChangeEvent.
     * @throws Exception if an error occurs.
     */
    public void fileDeleted(final FileChangeEvent event) throws Exception
    {
        FileListener listener = getListener();
        if (listener == null)
        {
            return;
        }
        listener.fileDeleted(event);
    }
View Full Code Here


     * @param event The FileChangeEvent.
     * @throws Exception if an error occurs.
     */
    public void fileChanged(FileChangeEvent event) throws Exception
    {
        FileListener listener = getListener();
        if (listener == null)
        {
            return;
        }
        listener.fileChanged(event);
    }
View Full Code Here

     * @return The FileListener.
     * @throws Exception if an error occurs.
     */
    protected FileListener getListener() throws Exception
    {
        final FileListener listener = this.listener.get();
        if (listener == null)
        {
            final FileObject file = fs.resolveFile(name);
            file.getFileSystem().removeListener(file, this);
        }
View Full Code Here

     * @throws Exception if an error occurs.
     */
    @Override
    public void fileCreated(final FileChangeEvent event) throws Exception
    {
        final FileListener listener = getListener();
        if (listener == null)
        {
            return;
        }
        listener.fileCreated(event);
    }
View Full Code Here

     * @throws Exception if an error occurs.
     */
    @Override
    public void fileDeleted(final FileChangeEvent event) throws Exception
    {
        final FileListener listener = getListener();
        if (listener == null)
        {
            return;
        }
        listener.fileDeleted(event);
    }
View Full Code Here

     * @throws Exception if an error occurs.
     */
    @Override
    public void fileChanged(final FileChangeEvent event) throws Exception
    {
        final FileListener listener = getListener();
        if (listener == null)
        {
            return;
        }
        listener.fileChanged(event);
    }
View Full Code Here

     * Tests the root file name.
     */
    public void testRootFileName() throws Exception
    {
        // Locate the root file
        final FileName rootName = getReadFolder().getFileSystem().getRoot().getName();

        // Test that the root path is "/"
        assertEquals("root path", "/", rootName.getPath());

        // Test that the root basname is ""
        assertEquals("root base name", "", rootName.getBaseName());

        // Test that the root name has no parent
        assertNull("root parent", rootName.getParent());
    }
View Full Code Here

    /**
     * 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
View Full Code Here

    {
        FileSystemManager mgr = VFS.getManager();

        FileObject root = mgr
                .resolveFile("smb://HOME\\vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfsusr");
        FileName rootName = root.getName();

        testNames(mgr, rootName);

        testChildren(root);
View Full Code Here

                                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());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.FileListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.