All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.javadpkg.plugin.io.FileSystemNode Maven / Gradle / Ivy

The newest version!
/*
 * dpkg - Debian Package library and the Debian Package Maven plugin
 * (c) Copyright 2016 Gerrit Hohl
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package net.sourceforge.javadpkg.plugin.io;

import java.io.IOException;
import java.util.List;

import net.sourceforge.javadpkg.io.FileMode;
import net.sourceforge.javadpkg.io.FileOwner;

/**
 * 

* A node representing a file or directory in the file system. *

* * @param * The type of the attachment. * @author Gerrit Hohl ([email protected]) * @version 1.0, 10.05.2016 by Gerrit Hohl */ public interface FileSystemNode { /** *

* Returns the parent. *

* * @return The parent or null, if this node is the root node. */ FileSystemNode
getParent(); /** *

* Sets the parent. *

* * @param parent * The parent or null, if this node should be the * root node. * @return The previous parent or null, if this node wasn't a * child node before. */ FileSystemNode
setParent(FileSystemNode parent); /** *

* Returns the name of the node. *

* * @return The name. */ String getName(); /** *

* Returns the path of the node. *

* * @return The path. */ Path getPath(); /** *

* Returns the path of the target of the symbolic link. *

* * @return The path or null, if the node doesn't represent a * symbolic link. * @see #isSymLink() */ Path getSymLinkTarget(); /** *

* Returns the owner. *

* * @return The owner. */ FileOwner getOwner(); /** *

* Returns the mode. *

* * @return The mode. */ FileMode getMode(); /** *

* Returns the flag if the node represents a directory. *

* * @return The flag: true, if the node represents a directory, * false otherwise. */ boolean isDirectory(); /** *

* Returns the flag if the node represents a file. *

*

* Symbolic links are handled as files. *

* * @return The flag: true, if the node represents a file, * false otherwise. * @see #isSymLink() */ boolean isFile(); /** *

* Returns the flag if the node represents a symbolic link. *

* * @return The flag: true, if the node represents a symbolic * link, false otherwise. * @see #getSymLinkTarget() */ boolean isSymLink(); /** *

* Returns the attachment. *

* * @return The attachment file or null, if no attachment is * set. */ A getAttachment(); /** *

* Sets the attachment. *

* * @param attachment * The attachment. */ void setAttachment(A attachment); /** *

* Creates a child node within this node representing a directory. *

* * @param name * The name. * @param owner * The owner. * @param mode * The mode. * @param attachment * The attachment (optional). * @return The child node. * @throws IllegalArgumentException * If any of the non-optional parameters are null. * @throws IllegalStateException * If this node does not represents a directory or if a child * node with the specified name already exists. */ FileSystemNode
createChildDirectory(String name, FileOwner owner, FileMode mode, A attachment); /** *

* Creates a child node within this node representing a file. *

* * @param name * The name. * @param owner * The owner. * @param mode * The mode. * @param attachment * The attachment (optional). * @return The child node. * @throws IllegalArgumentException * If any of the non-optional parameters are null. * @throws IllegalStateException * If this node does not represents a directory or if a child * node with the specified name already exists. */ FileSystemNode
createChildFile(String name, FileOwner owner, FileMode mode, A attachment); /** *

* Creates a child node within this node representing a file. *

* * @param name * The name. * @param target * The path of the target. * @param owner * The owner. * @param mode * The mode. * @param attachment * The attachment (optional). * @return The child node. * @throws IllegalArgumentException * If any of the non-optional parameters are null. * @throws IllegalStateException * If this node does not represents a directory or if a child * node with the specified name already exists. */ FileSystemNode
createChildSymLink(String name, Path target, FileOwner owner, FileMode mode, A attachment); /** *

* Adds a child node to this node. *

* * @param child * The child node. * @return The child node which was replaced by the specified child node or * null, if no child node with the same name exists. * @throws IllegalArgumentException * If the child node is null. * @throws IllegalStateException * If this node does not represent a directory. */ FileSystemNode
addChild(FileSystemNode child); /** *

* Returns the child node with the specified name. *

* * @param name * The name. * @return The child node or null, if no child node with the * specified name exists. * @throws IllegalArgumentException * If the name is null. * @throws IllegalStateException * If this node does not represent a directory. */ FileSystemNode
getChild(String name); /** *

* Removes the child node with the specified name. *

* * @param name * The name. * @return The removed child node or null, if no child node * with the specified name exists. * @throws IllegalArgumentException * If the name is null. * @throws IllegalStateException * If this node does not represent a directory. */ FileSystemNode
removeChild(String name); /** *

* Removes the specified child node. *

* * @param child * The child node. * @return true, if the child node was successfully removed, * false, if the specified node is not a child node of * this node. * @throws IllegalArgumentException * If the child node is null. * @throws IllegalStateException * If this node does not represent a directory. */ boolean removeChild(FileSystemNode
child); /** *

* Moves all child nodes of this node to the specified node. *

* * @param node * The node. * @return All child nodes which were replaced in the specified node by the * child nodes of this node. * @throws IllegalArgumentException * If the node is null. * @throws IllegalStateException * If this node or the specified node do not represent a * directory. */ List> moveChildrenTo(FileSystemNode
node); /** *

* Creates a node for the directory specified by the path and all * directories on the path there. *

*

* All created directories are marked as created by a dependency. *

* * @param path * The path. * @return The node representing the directory. * @throws IllegalArgumentException * If the path is null. * @throws IllegalStateException * If this node does not represent a directory or any of the * already existing nodes along the path. */ FileSystemNode
createDirectories(Path path); /** *

* Returns the node for the specified path. *

* * @param path * The path. * @return The node or null, if the node or any nodes on path * to it don't exist. * @throws IllegalArgumentException * If the path is null. * @throws IllegalStateException * If any node along the path - except the node of the last part * - does not represent a directory. */ FileSystemNode
getNode(Path path); /** *

* Returns the flag if this node was created by a dependency. *

*

* This is the case if a sub-folder was added, but the parent weren't added * before and created automatically. *

* * @return The flag: true, if this node was created by a * dependency, false otherwise. * @see #containsOnlyCreatedByDependency() */ boolean isCreatedByDependency(); /** *

* Returns the flag if the child nodes (recursively) are all created by * dependency. *

*

* This method doesn't check the flag of this node. *

* * @return The flag: true, if all child nodes were created by a * dependency, false otherwise. * @see #isCreatedByDependency() */ boolean containsOnlyCreatedByDependency(); /** *

* Walks the node tree starting at this node. *

* * @param visitor * The visitor to invoke for each node. * @return The visit result of this node. * @throws IllegalArgumentException * If the visitor is null. * @throws IOException * If an I/O error occurs. */ FileSystemNodeVisitResult walkNodeTree(FileSystemNodeVisitor
visitor) throws IOException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy