X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FRequest.java;h=e3240b5e240b2c2c78a5ae728c97574a967e50d3;hb=52f29c032eb637965d5342d3bd45843774d926b5;hp=6f8afa1a5dd858f176c4952c157cfcf1e553a570;hpb=a6d31fa9f170c57ba80b0f5ede4ef9bcbe3c9375;p=jSite2.git 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