summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2016-02-19 15:10:29 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2016-02-29 11:09:07 (GMT)
commit2de569d23468c94fdcf1adc336a580b053423fd7 (patch)
treef34fff273c65be6006c9de34c6903ad8db553118 /src/com/isode/stroke/base/JavaRandomGenerator.java
parent3bfe54c141dd3fa20e391312a0a84c75731e2b2a (diff)
downloadstroke-2de569d23468c94fdcf1adc336a580b053423fd7.zip
stroke-2de569d23468c94fdcf1adc336a580b053423fd7.tar.bz2
Add sort method for ServiceQuery and add Tests
Add the sortResult static method to the DomainNameServiceQuery class. This required adding a few equivalances for C++ std library methods to the class. And add a test for the new method too. Test-information: All unit tests pass ok. Change-Id: Idee0888f7ea140d35a971414fc2fd3cbcdfc337f
Diffstat (limited to 'src/com/isode/stroke/base/JavaRandomGenerator.java')
-rw-r--r--src/com/isode/stroke/base/JavaRandomGenerator.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/com/isode/stroke/base/JavaRandomGenerator.java b/src/com/isode/stroke/base/JavaRandomGenerator.java
new file mode 100644
index 0000000..09d389d
--- /dev/null
+++ b/src/com/isode/stroke/base/JavaRandomGenerator.java
@@ -0,0 +1,31 @@
+/* Copyright (c) 2016, Isode Limited, London, England.
+ * All rights reserved.
+ *
+ * Acquisition and use of this software and related materials for any
+ * purpose requires a written license agreement from Isode Limited,
+ * or a written license from an organisation licensed by Isode Limited
+ * to grant such a license.
+ *
+ */
+package com.isode.stroke.base;
+
+import java.util.Random;
+
+/**
+ * A {@link RandomGenerator} that generates integers with a uniform
+ * distribution (using the java {@link Random} class).
+ */
+public final class JavaRandomGenerator implements RandomGenerator {
+
+ /**
+ * {@link Random} to use to generate the numbers
+ */
+ private final Random rng = new Random();
+
+ @Override
+ public int generateRandomInteger(int max) {
+ // Random.nextInt(bound) is exclusive of bound
+ return rng.nextInt(max+1);
+ }
+
+}