[freenet-cvs] r15200 - trunk/plugins/Echo/src/plugins/echo

fred at freenetproject.org fred at freenetproject.org
Sun Sep 16 10:54:51 UTC 2007


Author: fred
Date: 2007-09-16 10:54:51 +0000 (Sun, 16 Sep 2007)
New Revision: 15200

Modified:
   trunk/plugins/Echo/src/plugins/echo/Nodes.java
   trunk/plugins/Echo/src/plugins/echo/NodesManager.java
   trunk/plugins/Echo/src/plugins/echo/Project.java
   trunk/plugins/Echo/src/plugins/echo/ProjectManager.java
   trunk/plugins/Echo/src/plugins/echo/SimpleDirectoryInserter.java
   trunk/plugins/Echo/src/plugins/echo/Util.java
Log:
javadoc


Modified: trunk/plugins/Echo/src/plugins/echo/Nodes.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Nodes.java	2007-09-15 19:51:30 UTC (rev 15199)
+++ trunk/plugins/Echo/src/plugins/echo/Nodes.java	2007-09-16 10:54:51 UTC (rev 15200)
@@ -12,6 +12,9 @@
 
 	private Vector<Node> nodes;
 	
+	/** 
+    	* Class constructor.
+	*/
 	public Nodes() {
 		
 		nodes = new Vector<Node>();
@@ -93,7 +96,10 @@
 		Collections.sort(nodes, new CreationDateComparator());
 
 	}
-	
+	/**
+	*	Returns a iterator of the elements in this list.
+	*	@return a iterator of the elements in this list.
+	*/
 	public Iterator<Node> iterator() {
 			
 		return nodes.iterator();

Modified: trunk/plugins/Echo/src/plugins/echo/NodesManager.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/NodesManager.java	2007-09-15 19:51:30 UTC (rev 15199)
+++ trunk/plugins/Echo/src/plugins/echo/NodesManager.java	2007-09-16 10:54:51 UTC (rev 15200)
@@ -19,6 +19,9 @@
 // * nodesDirectory -> ..dir
 // * Exceptions !!
 
+/**
+*	This class provides methods to manage nodes
+*/
 public class NodesManager {
 
 	private Builder parser;
@@ -27,6 +30,9 @@
 	private HashMap<String, File> nodes;
 	private HashMap<String, String> categories;
 
+	/**
+	*	Class constructor specifying the nodes directory to use
+	*/
 	public NodesManager(File nodesDirectory) throws IOException, ParsingException{
 
 		nodesDir = nodesDirectory;
@@ -52,7 +58,11 @@
 		} else 
 			writeCategories();
 	}
-	
+
+	/**
+	*	Loads the node referenced by this id
+	*	@return the node referenced by this id
+	*/
 	public Node getNodeById(String nodeId) throws IOException, ParsingException {
 
 		File file = nodes.get(nodeId);
@@ -62,7 +72,11 @@
 		return new Node(parser.build(file));
 
 	}
-	
+
+	/**
+	*	Load all the nodes
+	*	@return a list of all the nodes
+	*/
 	public Nodes getNodes() throws IOException, ParsingException {
 	
 		Nodes nodes = new Nodes();
@@ -74,12 +88,20 @@
 
 	}
 
+	/**
+	*	Returns the number of nodes referenced in this nodes manager
+	*	@return the number of nodes
+	*/
 	public int size() {
 
 		return nodes.size();
 
 	} 
 
+	/**
+	*	Gets a list of all the post nodes
+	*	@return a list of the post nodes
+	*/
 	public Nodes getPosts() throws IOException, ParsingException {
 		
 		Nodes posts = new Nodes();
@@ -110,15 +132,20 @@
 		return "9999";	// Suxx
 	}
 
-	
+	/**
+	*	Tests whether the node denoted by this id exists.
+	*	@return true if and only if the node denoted by this id exists; false otherwise
+	*/
 	public boolean nodeExists(String nodeId) {
 		
 		return nodes.containsKey(nodeId);
 		
 	}
 
-	
-	
+	/**
+	*	Removes the node denoted by this id.
+	*	@param the id of the node to remove
+	*/
 	public void deleteNode(String nodeId) throws IOException {
 
 		File file = nodes.get(nodeId);

Modified: trunk/plugins/Echo/src/plugins/echo/Project.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Project.java	2007-09-15 19:51:30 UTC (rev 15199)
+++ trunk/plugins/Echo/src/plugins/echo/Project.java	2007-09-16 10:54:51 UTC (rev 15200)
@@ -14,6 +14,9 @@
 
 import nu.xom.ParsingException;
 
+/**
+*	This class represents a project and provides basics methods to manage it.
+*/
 public class Project {
 
 	private File projectDir;
@@ -22,7 +25,9 @@
 	private NodesManager nodesManager;
 	private BlockManager blockManager;
 	
-
+	/**
+	* Class constructor specifying the base dir of the project.
+	*/
 	public Project(File projectDir) throws FileNotFoundException, ParsingException, IOException {
 		
 		this.projectDir = projectDir;
@@ -34,43 +39,46 @@
 		blockManager = new BlockManager(new File(projectDir.getPath() + File.separator + "blocks"));
 		
 	}
-	
+	/**
+	*	Returns the project base dir
+	*	@return the project base dir
+	*/
 	public File getProjectDir() {
 	
 		return projectDir;
 	
 	}
 	
+	/**
+	*	Returns the title of this project
+	*	@return the title of this project
+	*/
 	public String getTitle() {
 	
 		return projectConfig.getProperty("title");
 	
 	}
 	
+	/**
+	*	Returns the insert URI of this project
+	*	@return the insert URI of this project
+	*/
 	public FreenetURI getInsertURI() {
 		
 		return getURI("insertURI");
 		
 	}
-	
+
+	/**
+	*	Returns the request URI of this project
+	*	@return the request URI of this project
+	*/
 	public FreenetURI getRequestURI() {
 		
 		return getURI("requestURI");
 	
 	}
-	
-	public void setInsertURI(FreenetURI uri) {
-	
-		projectConfig.setProperty("insertURI", uri.toString());
-	
-	}
-	
-	public void setRequestURI(FreenetURI uri) {
-	
-		projectConfig.setProperty("requestURI", uri.toString());
-	
-	}
-	
+
 	private FreenetURI getURI(String key) {
 		
 		String str = projectConfig.getProperty(key);
@@ -84,19 +92,51 @@
 			return null;
 		}
 	}
+
+	/**
+	*	Registers the URI to insert this project
+	*	@param uri the new insert URI
+	*/
+	public void setInsertURI(FreenetURI uri) {
 	
+		projectConfig.setProperty("insertURI", uri.toString());
+	
+	}
+	
+	/**
+	*	Registers the URI to request the generated files of this project
+	*	@param uri the new request URI
+	*/
+	public void setRequestURI(FreenetURI uri) {
+	
+		projectConfig.setProperty("requestURI", uri.toString());
+	
+	}
+	
+	/**
+	*	Returns a NodesManager instance for this project
+	*	@return a NodesManager instance for this project
+	*/
 	public NodesManager getNodesManager() {
 	
 		return nodesManager;
 	
 	}
+
 	
+	/**
+	*	Returns a BlockManager instance for this project
+	*	@return a BlockManager instance for this project
+	*/
 	public BlockManager getBlockManager() {
 	
 		return blockManager;
 	
 	}
-	
+
+	/**
+	*	Stores the project config into the file conf.xml
+	*/
 	public void writeConfig() throws FileNotFoundException, IOException {
 	
 		FileOutputStream out = new FileOutputStream(projectConfigFile);

Modified: trunk/plugins/Echo/src/plugins/echo/ProjectManager.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/ProjectManager.java	2007-09-15 19:51:30 UTC (rev 15199)
+++ trunk/plugins/Echo/src/plugins/echo/ProjectManager.java	2007-09-16 10:54:51 UTC (rev 15200)
@@ -13,6 +13,9 @@
 
 import nu.xom.ParsingException;
 
+/**
+*	This class provides methods to manage projects
+*/
 public class ProjectManager {
 
 	private File baseDir;
@@ -20,6 +23,9 @@
 	private RandomSource randomSource;
 	private Project currentProject;
 
+	/**
+	*	Class constructor specifying the projects base dir and the random source used to generate the projects keys.
+	*/
 	public ProjectManager(File baseDir, RandomSource randomSource) {
 	
 		this.baseDir= baseDir;
@@ -33,7 +39,12 @@
 		}	
 		
 	}
-	
+	/**
+	*	Loads a project
+	*	@param projectId the id of the project to load
+	*	@return an instance of this project or null if the project does not exist
+	*	@see #getCurrentProject()
+	*/
 	public Project loadProject(String projectId) throws FileNotFoundException, ParsingException, IOException {
 	
 		if(projects.containsKey(projectId)) {
@@ -46,12 +57,21 @@
 		return null;
 	}
 
+	/**
+	*	Gets an instance of the current project
+	*	@return an instance of the current project
+	*/
 	public Project getCurrentProject() {
 
 		return currentProject;
 
 	}
-	
+
+	/**
+	*	Creates a new project
+	*	@param projectTitle the title of the project to create
+	*	@return an instance of this new project
+	*/
 	public Project newProject(String projectTitle) throws IOException, ParsingException {
 	
 		String id = "";
@@ -91,7 +111,11 @@
 			throw new IOException("Unable to make the project directory");
 		
 	}
-	
+
+	/**
+	*	Removes the project referenced by this id
+	*	@param projectId the id of the project to remove
+	*/
 	public void removeProject(String projectId) {
 	
 		if(projects.containsKey(projectId)) {
@@ -100,13 +124,21 @@
 		
 		}		
 	}
-	
+
+	/**
+	*	Counts the number of projects
+	*	@return the number of projects
+	*/
 	public int countProjects() {
 	
 		return projects.size();
 	
 	}
-	
+
+	/**
+	*	Returns the ids of all the referenced projects
+	*	@return the ids of all the referenced projects
+	*/
 	public String[] getProjectsIds() {
 	
 		return projects.keySet().toArray(new String[]{});

Modified: trunk/plugins/Echo/src/plugins/echo/SimpleDirectoryInserter.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/SimpleDirectoryInserter.java	2007-09-15 19:51:30 UTC (rev 15199)
+++ trunk/plugins/Echo/src/plugins/echo/SimpleDirectoryInserter.java	2007-09-16 10:54:51 UTC (rev 15200)
@@ -12,18 +12,29 @@
 import java.io.FileNotFoundException;
 import java.net.MalformedURLException;
 
-
+/**
+*	A façade class that provides a easy way to insert a directory on Freenet
+*/
 public class SimpleDirectoryInserter {
 
 	private FCPServer fcpServer;
 	public ClientPutDir clientPutDir;
-	
+
+	/**
+	* Class constructor specifying the FCP server to use
+	*/
 	public SimpleDirectoryInserter(FCPServer fcpServer) {
 	
 		this.fcpServer = fcpServer;
 	
 	}
-	
+	/**
+	*	Inserts a directory on Freenet
+	*	@param dir the directory to insert
+	*	@param defaultName the name of the default file of the directory
+	*	@param insertURI the Freenet URI to insert to
+	*	@return a ClientPutDir instance (see freenet.node.fcp.ClientPutDir)
+	*/
 	public ClientPutDir insert(File dir, String defaultName, FreenetURI insertURI) throws FileNotFoundException, IdentifierCollisionException, MalformedURLException{
 		
 		FCPClient client = fcpServer.getGlobalClient();

Modified: trunk/plugins/Echo/src/plugins/echo/Util.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Util.java	2007-09-15 19:51:30 UTC (rev 15199)
+++ trunk/plugins/Echo/src/plugins/echo/Util.java	2007-09-16 10:54:51 UTC (rev 15200)
@@ -2,6 +2,9 @@
 
 import java.io.File;
 
+/**
+*	Provides utility methods that can be used to perform common operations.
+*/
 public class Util {
 
 	
@@ -24,6 +27,4 @@
 		return success & path.delete();
 		
 	}
-
-
 }
\ No newline at end of file




More information about the cvs mailing list