Add default constructor that creates a random ID.
[jSite2.git] / src / net / pterodactylus / jsite / core / Request.java
index 6aa9018..15dae81 100644 (file)
@@ -19,6 +19,9 @@
 
 package net.pterodactylus.jsite.core;
 
+import net.pterodactylus.jsite.util.IdGenerator;
+import net.pterodactylus.util.number.Hex;
+
 /**
  * Wraps a request that is executed by the Freenet node.
  *
@@ -29,6 +32,16 @@ public class Request {
        /** The ID of the request. */
        private final String id;
 
+       /** The client token of the request. */
+       private String clientToken;
+
+       /**
+        * Creates a new request with a random ID.
+        */
+       public Request() {
+               this(Hex.toHex(IdGenerator.generateId()));
+       }
+
        /**
         * Creates a new request.
         *
@@ -48,4 +61,23 @@ public class Request {
                return id;
        }
 
+       /**
+        * Returns the client token of the request.
+        *
+        * @return The request’s client token
+        */
+       public String getClientToken() {
+               return clientToken;
+       }
+
+       /**
+        * Sets the client token of the request
+        *
+        * @param clientToken
+        *            The request’s new client token
+        */
+       public void setClientToken(String clientToken) {
+               this.clientToken = clientToken;
+       }
+
 }