From: David ‘Bombe’ Roden Date: Wed, 14 May 2008 20:11:21 +0000 (+0000) Subject: add type to request X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e99f6d1dafdf8733125537e8ab36d0fedc325630;p=jSite2.git add type to request git-svn-id: http://trooper/svn/projects/jSite/trunk@883 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/core/Request.java b/src/net/pterodactylus/jsite/core/Request.java index 6f8afa1..e3240b5 100644 --- a/src/net/pterodactylus/jsite/core/Request.java +++ b/src/net/pterodactylus/jsite/core/Request.java @@ -33,6 +33,31 @@ import java.util.List; */ 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"; @@ -63,6 +88,9 @@ public class Request { /** 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; @@ -84,6 +112,19 @@ public class Request { /** 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 // @@ -123,21 +164,11 @@ public class Request { 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. @@ -158,6 +189,31 @@ public class Request { } /** + * 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