--- /dev/null
+/*
+ * jFCPlib-high-level-client - GetRequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import net.pterodactylus.fcp.Persistence;
+import net.pterodactylus.fcp.PersistentGet;
+import net.pterodactylus.fcp.Priority;
+import net.pterodactylus.fcp.ReturnType;
+import net.pterodactylus.fcp.Verbosity;
+
+/**
+ * A Get result result is generated by {@link HighLevelClient#getRequests()}.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class GetRequestResult extends RequestResult {
+
+ /** The PersistentGet FCP message. */
+ private final PersistentGet persistentGet;
+
+ /**
+ * Creates a new Get request result.
+ *
+ * @param persistentGet
+ * The PersistentGet message wrapped by this result
+ */
+ public GetRequestResult(PersistentGet persistentGet) {
+ super(persistentGet.getIdentifier());
+ this.persistentGet = persistentGet;
+ }
+
+ /**
+ * Returns the client token associated with the request.
+ *
+ * @return The client token
+ * @see net.pterodactylus.fcp.PersistentGet#getClientToken()
+ */
+ public String getClientToken() {
+ return persistentGet.getClientToken();
+ }
+
+ /**
+ * Returns the filename of the request.
+ *
+ * @return The filename
+ * @see net.pterodactylus.fcp.PersistentGet#getFilename()
+ */
+ public String getFilename() {
+ return persistentGet.getFilename();
+ }
+
+ /**
+ * Returns the maximum number of retries for the request.
+ *
+ * @return The maximum number of retries
+ * @see net.pterodactylus.fcp.PersistentGet#getMaxRetries()
+ */
+ public int getMaxRetries() {
+ return persistentGet.getMaxRetries();
+ }
+
+ /**
+ * Returns the persistence level of the request
+ *
+ * @return The persistence level
+ * @see net.pterodactylus.fcp.PersistentGet#getPersistence()
+ */
+ public Persistence getPersistence() {
+ return persistentGet.getPersistence();
+ }
+
+ /**
+ * Returns the priority of the request.
+ *
+ * @return The priority
+ * @see net.pterodactylus.fcp.PersistentGet#getPriority()
+ */
+ public Priority getPriority() {
+ return persistentGet.getPriority();
+ }
+
+ /**
+ * Returns the return type of the request.
+ *
+ * @return The return type of the request
+ * @see net.pterodactylus.fcp.PersistentGet#getReturnType()
+ */
+ public ReturnType getReturnType() {
+ return persistentGet.getReturnType();
+ }
+
+ /**
+ * Returns the temporary filename of the request.
+ *
+ * @return The temporary filename
+ * @see net.pterodactylus.fcp.PersistentGet#getTempFilename()
+ */
+ public String getTempFilename() {
+ return persistentGet.getTempFilename();
+ }
+
+ /**
+ * Returns the URI of the request.
+ *
+ * @return The URI of the request
+ * @see net.pterodactylus.fcp.PersistentGet#getURI()
+ */
+ public String getURI() {
+ return persistentGet.getURI();
+ }
+
+ /**
+ * Returns the verbosity of the request.
+ *
+ * @return The verbosity of the request
+ * @see net.pterodactylus.fcp.PersistentGet#getVerbosity()
+ */
+ public Verbosity getVerbosity() {
+ return persistentGet.getVerbosity();
+ }
+
+ /**
+ * Returns whether this request is on the global queue.
+ *
+ * @return <code>true</code> if the request is on the global queue,
+ * <code>false</code> if it is on the client-local queue
+ * @see net.pterodactylus.fcp.PersistentGet#isGlobal()
+ */
+ public boolean isGlobal() {
+ return persistentGet.isGlobal();
+ }
+
+}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.logging.Level;
import java.util.logging.Logger;
import net.pterodactylus.fcp.AddPeer;
import net.pterodactylus.fcp.GetFailed;
import net.pterodactylus.fcp.IdentifierCollision;
import net.pterodactylus.fcp.ListPeers;
+import net.pterodactylus.fcp.ListPersistentRequests;
import net.pterodactylus.fcp.NodeData;
import net.pterodactylus.fcp.NodeHello;
import net.pterodactylus.fcp.NodeRef;
/**
* A high-level client that allows simple yet full-featured access to a Freenet
* node.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
/** Mapping from request identifiers to download callbacks. */
private Map<String, HighLevelProgressCallback<DownloadResult>> downloadCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelProgressCallback<DownloadResult>>());
+ /** The callback for {@link #getRequests()}. */
+ private HighLevelCallback<RequestListResult> requestListCallback;
+
/**
* Creates a new high-level client that connects to a node on
* <code>localhost</code>.
- *
+ *
* @param clientName
* The name of the client
* @throws UnknownHostException
/**
* Creates a new high-level client that connects to a node on the given
* host.
- *
+ *
* @param clientName
* The name of the client
* @param host
/**
* Creates a new high-level client that connects to a node on the given
* host.
- *
+ *
* @param clientName
* The name of the client
* @param host
/**
* Creates a new high-level client that connects to a node at the given
* address.
- *
+ *
* @param clientName
* The name of the client
* @param address
/**
* Adds the given high-level client listener to list of listeners.
- *
+ *
* @param highLevelClientListener
* The listener to add
*/
/**
* Removes the given high-level client listener from the list of listeners.
- *
+ *
* @param highLevelClientListener
* The listener to remove
*/
/**
* Notifies all listeners that a client has disconnected.
- *
+ *
* @param throwable
* The exception that caused the disconnect, or <code>null</code>
* if there was no exception
* Returns the FCP connection that backs this high-level client. This method
* should be used with care as fiddling around with the FCP connection can
* easily break the high-level client if you don’t know what you’re doing!
- *
+ *
* @return The FCP connection of this client
*/
public FcpConnection getFcpConnection() {
/**
* Connects the client.
- *
+ *
* @return A callback with a connection result
* @throws IOException
* if an I/O error occurs communicating with the node
/**
* Generates a new SSK keypair.
- *
+ *
* @return A callback with the keypair
* @throws IOException
* if an I/O error occurs communicating with the node
/**
* Gets a list of all peers from the node.
- *
+ *
* @return A callback with the peer list
* @throws IOException
* if an I/O error occurs with the node
/**
* Adds the peer whose noderef is stored in the given file.
- *
+ *
* @param nodeRefFile
* The name of the file the peer’s noderef is stored in
* @return A peer callback
/**
* Adds the peer whose noderef is stored in the given file.
- *
+ *
* @param nodeRefURL
* The URL where the peer’s noderef is stored
* @return A peer callback
/**
* Adds the peer whose noderef is stored in the given file.
- *
+ *
* @param nodeRef
* The peer’s noderef
* @return A peer callback
* Checks whether direct disk access for the given directory is possible.
* You have to perform this check before you can upload or download anything
* from or the disk directly!
- *
+ *
* @param directory
* The directory to check
* @param wantRead
* Starts a download. Files can either be download to disk or streamed from
* the node. When downloading to disk you have to perform a direct disk
* access check for the directory you want to put the downloaded file in!
- *
+ *
* @see #checkDirectDiskAccess(String, boolean, boolean)
* @param uri
* The URI to get
return downloadCallback;
}
+ /**
+ * Requests a list of all running requests from the node.
+ *
+ * @return The request list result
+ * @throws IOException
+ * if an I/O errors communicating with the node
+ */
+ public HighLevelCallback<RequestListResult> getRequests() throws IOException {
+ String identifier = generateIdentifier("list-persistent-requests");
+ ListPersistentRequests listPersistentRequests = new ListPersistentRequests();
+ synchronized (syncObject) {
+ if (requestListCallback != null) {
+ logger.log(Level.SEVERE, "getRequests() called with request still running!");
+ }
+ requestListCallback = new HighLevelCallback<RequestListResult>(new RequestListResult(identifier));
+ }
+ fcpConnection.sendMessage(listPersistentRequests);
+ return requestListCallback;
+ }
+
//
// PRIVATE METHODS
//
/**
* Generates an identifier for the given function.
- *
+ *
* @param function
* The name of the function
* @return An identifier
/**
* Disconnects the client from the node, handing the given Throwable to
* {@link #fireClientDisconnected(Throwable)}.
- *
+ *
* @param throwable
* The exception that caused the disconnect, or <code>null</code>
* if there was no exception
/**
* FCP listener for {@link HighLevelClient}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
/**
* Searches all callback collections for a callback with the given
* identifier and cancels it.
- *
+ *
* @param identifier
* The identifier to search for, or <code>null</code> to
* cancel all pending requests
connectCallback.setDone();
connectCallback = null;
}
+ if (requestListCallback != null) {
+ requestListCallback.getIntermediaryResult().setFailed(true);
+ requestListCallback.setDone();
+ requestListCallback = null;
+ }
}
if (identifier == null) {
/* key generation callbacks */
/**
* Reads the given file and returns the first line of the file.
- *
+ *
* @param readFilename
* The name of the file to read
* @return The content of the file
/**
* Writes the given content to the given file.
- *
+ *
* @param directDiskAccessResult
* The DDA result
* @param writeFilename
/**
* Cleans up any files that written for the given result.
- *
+ *
* @param directDiskAccessResult
* The direct disk access result
*/
* @see net.pterodactylus.fcp.FcpListener#receivedEndListPersistentRequests(net.pterodactylus.fcp.FcpConnection,
* net.pterodactylus.fcp.EndListPersistentRequests)
*/
+ @SuppressWarnings("synthetic-access")
public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests) {
- /* TODO */
+ if (fcpConnection != HighLevelClient.this.fcpConnection) {
+ return;
+ }
+ synchronized (syncObject) {
+ if (HighLevelClient.this.requestListCallback == null) {
+ logger.log(Level.WARNING, "got EndListPersistentRequests without running request!");
+ return;
+ }
+ requestListCallback.setDone();
+ requestListCallback = null;
+ }
}
/**
if (fcpConnection != HighLevelClient.this.fcpConnection) {
return;
}
+ synchronized (syncObject) {
+ if (requestListCallback != null) {
+ RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
+ requestListResult.addRequestResult(new GetRequestResult(persistentGet));
+ return;
+ }
+ }
String identifier = persistentGet.getIdentifier();
if (downloadCallbacks.containsKey(identifier)) {
- /* ignore, because a download does not care about this. */
+ /* TODO */
return;
}
}
* @see net.pterodactylus.fcp.FcpListener#receivedPersistentPut(net.pterodactylus.fcp.FcpConnection,
* net.pterodactylus.fcp.PersistentPut)
*/
+ @SuppressWarnings("synthetic-access")
public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut) {
- /* TODO */
+ if (fcpConnection != HighLevelClient.this.fcpConnection) {
+ return;
+ }
+ synchronized (syncObject) {
+ if (requestListCallback != null) {
+ RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
+ requestListResult.addRequestResult(new PutRequestResult(persistentPut));
+ return;
+ }
+ }
}
/**
* @see net.pterodactylus.fcp.FcpListener#receivedPersistentPutDir(net.pterodactylus.fcp.FcpConnection,
* net.pterodactylus.fcp.PersistentPutDir)
*/
+ @SuppressWarnings("synthetic-access")
public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir) {
- /* TODO */
+ if (fcpConnection != HighLevelClient.this.fcpConnection) {
+ return;
+ }
+ synchronized (syncObject) {
+ if (requestListCallback != null) {
+ RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
+ requestListResult.addRequestResult(new PutDirRequestResult(persistentPutDir));
+ return;
+ }
+ }
}
/**
--- /dev/null
+/*
+ * jFCPlib-high-level-client - PutDirRequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import net.pterodactylus.fcp.PersistentPutDir;
+import net.pterodactylus.fcp.Priority;
+import net.pterodactylus.fcp.UploadFrom;
+import net.pterodactylus.fcp.Verbosity;
+
+/**
+ * A PutDir request result is generated by {@link HighLevelClient#getRequests()}.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class PutDirRequestResult extends RequestResult {
+
+ /** The wrapped PersistentPutDir FCP message. */
+ private final PersistentPutDir persistentPutDir;
+
+ /**
+ * Creates a new PutDir request result.
+ *
+ * @param persistentPutDir
+ * The PersistentPutDir FCP message to wrap
+ */
+ public PutDirRequestResult(PersistentPutDir persistentPutDir) {
+ super(persistentPutDir.getIdentifier());
+ this.persistentPutDir = persistentPutDir;
+ }
+
+ /**
+ * Returns the number of files in the request.
+ *
+ * @return The number of files
+ * @see net.pterodactylus.fcp.PersistentPutDir#getFileCount()
+ */
+ public int getFileCount() {
+ return persistentPutDir.getFileCount();
+ }
+
+ /**
+ * Returns the length of the file at the given index.
+ *
+ * @param fileIndex
+ * The index of the file
+ * @return The length of the file
+ * @see net.pterodactylus.fcp.PersistentPutDir#getFileDataLength(int)
+ */
+ public long getFileDataLength(int fileIndex) {
+ return persistentPutDir.getFileDataLength(fileIndex);
+ }
+
+ /**
+ * Returns the name of the file at the given index.
+ *
+ * @param fileIndex
+ * The index of the file
+ * @return The name of the file
+ * @see net.pterodactylus.fcp.PersistentPutDir#getFileFilename(int)
+ */
+ public String getFileFilename(int fileIndex) {
+ return persistentPutDir.getFileFilename(fileIndex);
+ }
+
+ /**
+ * Returns the content type of the file at the given index.
+ *
+ * @param fileIndex
+ * The index of the file
+ * @return The content type of the file
+ * @see net.pterodactylus.fcp.PersistentPutDir#getFileMetadataContentType(int)
+ */
+ public String getFileMetadataContentType(int fileIndex) {
+ return persistentPutDir.getFileMetadataContentType(fileIndex);
+ }
+
+ /**
+ * Returns the name of the file at the given index.
+ *
+ * @param fileIndex
+ * The index of the file
+ * @return The name of the file
+ * @see net.pterodactylus.fcp.PersistentPutDir#getFileName(int)
+ */
+ public String getFileName(int fileIndex) {
+ return persistentPutDir.getFileName(fileIndex);
+ }
+
+ /**
+ * Returns the upload source of the file at the given index.
+ *
+ * @param fileIndex
+ * The index of the file
+ * @return The upload source of the file
+ * @see net.pterodactylus.fcp.PersistentPutDir#getFileUploadFrom(int)
+ */
+ public UploadFrom getFileUploadFrom(int fileIndex) {
+ return persistentPutDir.getFileUploadFrom(fileIndex);
+ }
+
+ /**
+ * Returns the maximum number of retries for failed blocks.
+ *
+ * @return The maximum number of retries
+ * @see net.pterodactylus.fcp.PersistentPutDir#getMaxRetries()
+ */
+ public int getMaxRetries() {
+ return persistentPutDir.getMaxRetries();
+ }
+
+ /**
+ * Returns the priority of the request.
+ *
+ * @return The priority
+ * @see net.pterodactylus.fcp.PersistentPutDir#getPriority()
+ */
+ public Priority getPriority() {
+ return persistentPutDir.getPriority();
+ }
+
+ /**
+ * Returns the URI of the request.
+ *
+ * @return The URI of the request
+ * @see net.pterodactylus.fcp.PersistentPutDir#getURI()
+ */
+ public String getURI() {
+ return persistentPutDir.getURI();
+ }
+
+ /**
+ * Returns the verbosity of the request.
+ *
+ * @return The verbosity
+ * @see net.pterodactylus.fcp.PersistentPutDir#getVerbosity()
+ */
+ public Verbosity getVerbosity() {
+ return persistentPutDir.getVerbosity();
+ }
+
+ /**
+ * Returns whether the request is on the global queue.
+ *
+ * @return <code>true</code> if the request is on the global queue,
+ * <code>false</code> if it is on the client-local queue
+ * @see net.pterodactylus.fcp.PersistentPutDir#isGlobal()
+ */
+ public boolean isGlobal() {
+ return persistentPutDir.isGlobal();
+ }
+
+}
--- /dev/null
+/*
+ * jFCPlib-high-level-client - PutRequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import net.pterodactylus.fcp.Persistence;
+import net.pterodactylus.fcp.PersistentPut;
+import net.pterodactylus.fcp.Priority;
+import net.pterodactylus.fcp.UploadFrom;
+import net.pterodactylus.fcp.Verbosity;
+
+/**
+ * A put request result will be contained in a {@link RequestListResult}.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class PutRequestResult extends RequestResult {
+
+ /** The wrapped PersistentPut FCP message. */
+ private final PersistentPut persistentPut;
+
+ /**
+ * Creates a new put request result.
+ *
+ * @param persistentPut
+ * The PersistentPut FCP message to wrap
+ */
+ public PutRequestResult(PersistentPut persistentPut) {
+ super(persistentPut.getIdentifier());
+ this.persistentPut = persistentPut;
+ }
+
+ /**
+ * Returns the client token associated with the request.
+ *
+ * @return The client token
+ * @see net.pterodactylus.fcp.PersistentPut#getClientToken()
+ */
+ public String getClientToken() {
+ return persistentPut.getClientToken();
+ }
+
+ /**
+ * Returns the length of the data to be inserted.
+ *
+ * @return The length of the data
+ * @see net.pterodactylus.fcp.PersistentPut#getDataLength()
+ */
+ public long getDataLength() {
+ return persistentPut.getDataLength();
+ }
+
+ /**
+ * Returns the maximum number of retries for failed blocks.
+ *
+ * @return The maximum number of retries
+ * @see net.pterodactylus.fcp.PersistentPut#getMaxRetries()
+ */
+ public int getMaxRetries() {
+ return persistentPut.getMaxRetries();
+ }
+
+ /**
+ * Returns the content type of the data.
+ *
+ * @return The content type of the data
+ * @see net.pterodactylus.fcp.PersistentPut#getMetadataContentType()
+ */
+ public String getMetadataContentType() {
+ return persistentPut.getMetadataContentType();
+ }
+
+ /**
+ * Returns the persistence level of the request.
+ *
+ * @return The persistence level
+ * @see net.pterodactylus.fcp.PersistentPut#getPersistence()
+ */
+ public Persistence getPersistence() {
+ return persistentPut.getPersistence();
+ }
+
+ /**
+ * Returns the priority of the request.
+ *
+ * @return The priority
+ * @see net.pterodactylus.fcp.PersistentPut#getPriority()
+ */
+ public Priority getPriority() {
+ return persistentPut.getPriority();
+ }
+
+ /**
+ * Returns the target filename of the request
+ *
+ * @return The target filename
+ * @see net.pterodactylus.fcp.PersistentPut#getTargetFilename()
+ */
+ public String getTargetFilename() {
+ return persistentPut.getTargetFilename();
+ }
+
+ /**
+ * Returns the upload source of the request.
+ *
+ * @return The upload source
+ * @see net.pterodactylus.fcp.PersistentPut#getUploadFrom()
+ */
+ public UploadFrom getUploadFrom() {
+ return persistentPut.getUploadFrom();
+ }
+
+ /**
+ * Returns the URI of the request.
+ *
+ * @return The URI
+ * @see net.pterodactylus.fcp.PersistentPut#getURI()
+ */
+ public String getURI() {
+ return persistentPut.getURI();
+ }
+
+ /**
+ * Returns the verbosity of the request.
+ *
+ * @return The verbosity
+ * @see net.pterodactylus.fcp.PersistentPut#getVerbosity()
+ */
+ public Verbosity getVerbosity() {
+ return persistentPut.getVerbosity();
+ }
+
+ /**
+ * Returns whether the request is on the global queue.
+ *
+ * @return <code>true</code> if the request is on the global queue,
+ * <code>false</code> if it is on the client-local queue
+ * @see net.pterodactylus.fcp.PersistentPut#isGlobal()
+ */
+ public boolean isGlobal() {
+ return persistentPut.isGlobal();
+ }
+
+ /**
+ * Returns whether the request has already started.
+ *
+ * @return <code>true</code> if the request has started,
+ * <code>false</code> otherwise
+ * @see net.pterodactylus.fcp.PersistentPut#isStarted()
+ */
+ public boolean isStarted() {
+ return persistentPut.isStarted();
+ }
+
+}
--- /dev/null
+/*
+ * jFCPlib-high-level-client - RequestListResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The request list results lists all currently running requests on a node.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class RequestListResult extends HighLevelResult implements Iterable<RequestResult> {
+
+ /** The request results. */
+ private List<RequestResult> requestResults = Collections.synchronizedList(new ArrayList<RequestResult>());
+
+ /**
+ * Creates a new request list result.
+ *
+ * @param identifier
+ * The identifier of the request
+ */
+ RequestListResult(String identifier) {
+ super(identifier);
+ }
+
+ /**
+ * Adds a request result.
+ *
+ * @param requestResult
+ * The request result to add
+ */
+ void addRequestResult(RequestResult requestResult) {
+ requestResults.add(requestResult);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Iterator<RequestResult> iterator() {
+ return requestResults.iterator();
+ }
+
+ /**
+ * Returns the request result at the given index.
+ *
+ * @param index
+ * The index of the request result
+ * @return The request result
+ */
+ public RequestResult get(int index) {
+ return requestResults.get(index);
+ }
+
+ /**
+ * Returns the number of request results in this request list.
+ *
+ * @return The number of request results
+ */
+ public int size() {
+ return requestResults.size();
+ }
+
+}
--- /dev/null
+/*
+ * jFCPlib-high-level-client - RequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+/**
+ * A request result is the result of different operations, e.g.
+ * {@link HighLevelClient#getRequests()}.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class RequestResult extends HighLevelResult {
+
+ /**
+ * Creates a new request result.
+ *
+ * @param identifier
+ * The identifier of the request
+ */
+ RequestResult(String identifier) {
+ super(identifier);
+ }
+
+}