*/
public class Request {
+ /**
+ * The type of a request.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+ public enum Type {
+
+ /** Type of request is unknown. */
+ unknown,
+
+ /** The request is a Get request. */
+ get,
+
+ /** The request is a Put request. */
+ put,
+
+ /** The request is a PutDir request. */
+ putDir
+
+ }
+
+ /** Name of the “type” property. */
+ public static final String PROPERTY_TYPE = "type";
+
/** Name of the “client token” property. */
public static final String PROPERTY_CLIENT_TOKEN = "clientToken";
/** The identifier of the request. */
private final String identifier;
+ /** The type of the request. */
+ private Type type;
+
/** The client token of the request. */
private String clientToken;
/** Whether the total number has been finalized. */
private boolean totalFinalized;
+ /**
+ * Creates a new request with the given identifier.
+ *
+ * @param node
+ * The node the request belongs to
+ * @param identifier
+ * The identifier of the request
+ */
+ Request(Node node, String identifier) {
+ this.node = node;
+ this.identifier = identifier;
+ }
+
//
// EVENT MANAGEMENT
//
for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
propertyChangeListener.propertyChange(propertyChangeEvent);
}
-
}
- /**
- * Creates a new request with the given identifier.
- *
- * @param node
- * The node the request belongs to
- * @param identifier
- * The identifier of the request
- */
- Request(Node node, String identifier) {
- this.node = node;
- this.identifier = identifier;
- }
+ //
+ // ACCESSORS
+ //
/**
* Returns the node the request belongs to.
}
/**
+ * Returns the type of the request.
+ *
+ * @return The type of the request
+ */
+
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * Sets the type of the request.
+ *
+ * @param type
+ * The type of the request
+ */
+
+ public void setType(Type type) {
+ Type oldType = this.type;
+ this.type = type;
+ if (((oldType == null) && (type != null)) || ((oldType != null) && (type == null)) || ((type != null) && !type.equals(oldType))) {
+ firePropertyChange(PROPERTY_TYPE, oldType, type);
+ }
+ }
+
+ /**
* Returns the client token of the request.
*
* @return The client token of the request