Skip to content
Browse files

stupid doc hack

  • Loading branch information...
1 parent aeb491e commit db835dfcefefeade0e000d79ced164861d9d916c Dave Parfitt committed Mar 23, 2013
Showing with 260 additions and 72 deletions.
  1. +126 −21 README.md
  2. +6 −0 pom.xml
  3. +0 −24 src/main/java/com/basho/contact/Contact.java
  4. +1 −0 src/main/java/com/basho/contact/actions/Binding.java
  5. +1 −9 src/main/java/com/basho/contact/actions/ContactActionListener.java
  6. +1 −6 src/main/java/com/basho/contact/actions/JSActionListener.java
  7. +1 −0 src/main/java/com/basho/contact/commands/ConnectCommand.java
  8. +1 −0 src/main/java/com/basho/contact/commands/DeleteCommand.java
  9. +1 −0 src/main/java/com/basho/contact/commands/FetchCommand.java
  10. +1 −0 src/main/java/com/basho/contact/commands/GetBucketPropsCommand.java
  11. +1 −0 src/main/java/com/basho/contact/commands/ListBucketsCommand.java
  12. +1 −0 src/main/java/com/basho/contact/commands/ListKeysCommand.java
  13. +1 −0 src/main/java/com/basho/contact/commands/MapredCommand.java
  14. +1 −0 src/main/java/com/basho/contact/commands/Query2iCommand.java
  15. +1 −0 src/main/java/com/basho/contact/commands/StoreCommand.java
  16. +3 −3 src/main/java/com/basho/contact/commands/{ → params}/ConnectParams.java
  17. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/DeleteParams.java
  18. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/FetchParams.java
  19. +104 −0 src/main/java/com/basho/contact/commands/params/GenDocs.java
  20. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/GetBucketPropsParams.java
  21. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/ListBucketsParams.java
  22. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/ListKeysParams.java
  23. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/MapRedParams.java
  24. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/Query2iParams.java
  25. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/SetBucketPropsParams.java
  26. +1 −1 src/main/java/com/basho/contact/commands/{ → params}/StoreParams.java
View
147 README.md
@@ -348,33 +348,138 @@ Dave Parfitt
Address:
1000 Big Nosk drive
Buffalo, NY 14222
->```
+```
The key function in the postfetch action above is `JSON.parse(v)`, which turns evaluates a string and returns a Javascript object.
I hope to have a "Cookbook" section on the Contact wiki eventually, but in the meantime, you can check out the [Javadocs for the Riak Java Client](http://basho.github.com/riak-java-client/1.1.0/index.html) for available methods.
-####Available actions:
- * preconnect
- * postconnect
- * prefetch
- * postfetch
- * prestore
- * poststore
- * predelete
- * postdelete
- * prequery2i
- * postquery2i
- * premapred
- * postmapred
- * prelistbuckets
- * postlistbuckets
- * prelistkeys
- * postlistkeys
- * pregetbucketprops
- * postgetbucketprops
-
+####Available actions
+
+* **listkeys**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * keys : *[java.util.List](http://docs.oracle.com/javase/7/docs/api/java/util/List.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)>*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **fetch**
+ * **Pre** parameters
+ * fetchObj : *[com.basho.riak.client.operations.FetchObject](http://basho.github.com/riak-java-client/1.1.0/com/basho/riak/client/operations/FetchObject.html)<[com.basho.riak.client.IRiakObject](http://basho.github.com/riak-java-client/1.1.0/com/basho/riak/client/IRiakObject.html)>*
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * key : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * key : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * riak_object : *[com.basho.riak.client.IRiakObject](http://basho.github.com/riak-java-client/1.1.0/com/basho/riak/client/IRiakObject.html)*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **mapred**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **connect**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * riak_host : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * riak_pb_port : *[int]()*
+ * **Post** parameters
+ * riak_pb_port : *[int]()*
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * riak_client : *[com.basho.riak.client.IRiakClient](http://basho.github.com/riak-java-client/1.1.0/com/basho/riak/client/IRiakClient.html)*
+ * riak_host : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **store**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * indexes : *[java.util.List](http://docs.oracle.com/javase/7/docs/api/java/util/List.html)<[com.basho.contact.Pair](http://basho.github.com/riak-java-client/1.1.0/com/basho/contact/Pair.html)>*
+ * key : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * content : *[com.basho.contact.Content](http://basho.github.com/riak-java-client/1.1.0/com/basho/contact/Content.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * riak_object : *[com.basho.riak.client.IRiakObject](http://basho.github.com/riak-java-client/1.1.0/com/basho/riak/client/IRiakObject.html)*
+
+* **setbucketprops**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **getbucketprops**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **delete**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+
+* **query2i**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * index_max : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * index_min : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * index_val : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * index_name : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * index_name : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * index_val : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * index_max : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * index_min : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * results : *[java.util.List](http://docs.oracle.com/javase/7/docs/api/java/util/List.html)<?>*
+
+* **listbuckets**
+ * **Pre** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
+ * **Post** parameters
+ * options : *[java.util.Map](http://docs.oracle.com/javase/7/docs/api/java/util/Map.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html), [java.lang.Object](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)>*
+ * buckets : *[java.util.Set](http://docs.oracle.com/javase/7/docs/api/java/util/Set.html)<[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)>*
+ * contact : *[com.basho.contact.RuntimeContext]()*
+ * bucket : *[java.lang.String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html)*
View
6 pom.xml
@@ -66,6 +66,12 @@
<version>3.8.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.8</version>
+ </dependency>
+
</dependencies>
<build>
<plugins>
View
24 src/main/java/com/basho/contact/Contact.java
@@ -1,24 +0,0 @@
-package com.basho.contact;
-
-
-public class Contact {
-// public static void main(String[] args) throws Exception {
-// ANTLRInputStream input = new ANTLRInputStream(System.in);
-// ContactLexer lexer = new ContactLexer(input);
-// CommonTokenStream tokens = new CommonTokenStream(lexer);
-// ContactParser parser = new ContactParser(tokens);
-// RuntimeContext ctx = new RuntimeContext();
-// parser.addErrorListener(new ContactErrorListener(ctx));
-// ParseTreeWalker walker = new ParseTreeWalker();
-//
-//
-// ContactWalker cw = new ContactWalker(ctx);
-// ContactMapredWalker mapredcw = new ContactMapredWalker(ctx);
-//
-// ProgContext pc = parser.prog();
-// walker.walk(cw, pc);
-// walker.walk(mapredcw, pc);
-//
-// System.out.println("Done!");
-// }
-}
View
1 src/main/java/com/basho/contact/actions/Binding.java
@@ -10,4 +10,5 @@
public @interface Binding {
String name() default "";
boolean copy() default true;
+ boolean javadoc() default false;
}
View
10 src/main/java/com/basho/contact/actions/ContactActionListener.java
@@ -1,14 +1,6 @@
package com.basho.contact.actions;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.basho.contact.commands.*;
-import com.basho.riak.client.IRiakClient;
-import com.basho.riak.client.IRiakObject;
-import com.basho.riak.client.operations.StoreObject;
-import com.basho.riak.client.query.indexes.FetchIndex;
+import com.basho.contact.commands.params.*;
public interface ContactActionListener{
public void init();
View
7 src/main/java/com/basho/contact/actions/JSActionListener.java
@@ -3,20 +3,15 @@
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
-import com.basho.contact.commands.*;
+import com.basho.contact.commands.params.*;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import com.basho.contact.RuntimeContext;
-import com.basho.riak.client.IRiakClient;
-import com.basho.riak.client.IRiakObject;
-import com.basho.riak.client.operations.StoreObject;
-import com.basho.riak.client.query.indexes.FetchIndex;
public class JSActionListener implements ContactActionListener {
View
1 src/main/java/com/basho/contact/commands/ConnectCommand.java
@@ -2,6 +2,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.ConnectParams;
import com.basho.contact.symbols.ConnectionSymbol;
import com.basho.riak.client.IRiakClient;
View
1 src/main/java/com/basho/contact/commands/DeleteCommand.java
@@ -2,6 +2,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.DeleteParams;
import com.basho.contact.symbols.ResultSymbol;
public class DeleteCommand extends RiakCommand<ResultSymbol, DeleteParams.Pre> {
View
1 src/main/java/com/basho/contact/commands/FetchCommand.java
@@ -5,6 +5,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.FetchParams;
import com.basho.contact.symbols.ResultSymbol;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.IRiakObject;
View
1 src/main/java/com/basho/contact/commands/GetBucketPropsCommand.java
@@ -2,6 +2,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.GetBucketPropsParams;
import com.basho.contact.symbols.ResultSymbol;
public class GetBucketPropsCommand extends RiakCommand<ResultSymbol, GetBucketPropsParams.Pre> {
View
1 src/main/java/com/basho/contact/commands/ListBucketsCommand.java
@@ -4,6 +4,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.ListBucketsParams;
import com.basho.contact.symbols.ResultSymbol;
import com.basho.riak.client.RiakException;
View
1 src/main/java/com/basho/contact/commands/ListKeysCommand.java
@@ -5,6 +5,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.ListKeysParams;
import com.basho.contact.symbols.ResultSymbol;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.RiakException;
View
1 src/main/java/com/basho/contact/commands/MapredCommand.java
@@ -2,6 +2,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.MapRedParams;
import com.basho.contact.symbols.ResultsSymbol;
public class MapredCommand extends RiakCommand<ResultsSymbol, MapRedParams.Pre> {
View
1 src/main/java/com/basho/contact/commands/Query2iCommand.java
@@ -2,6 +2,7 @@
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.Query2iParams;
import com.basho.contact.symbols.Query2IResultsSymbol;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.RiakException;
View
1 src/main/java/com/basho/contact/commands/StoreCommand.java
@@ -6,6 +6,7 @@
import com.basho.contact.Pair;
import com.basho.contact.RiakCommand;
import com.basho.contact.RuntimeContext;
+import com.basho.contact.commands.params.StoreParams;
import com.basho.contact.symbols.ResultSymbol;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.IRiakObject;
View
6 ...basho/contact/commands/ConnectParams.java → ...ontact/commands/params/ConnectParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
@@ -19,7 +19,7 @@
public String host;
@Binding(name = "riak_pb_port")
public int pbPort;
- @Binding(name = "riak_client")
- IRiakClient client;
+ @Binding(name = "riak_client", javadoc = true)
+ public IRiakClient client;
}
}
View
2 .../basho/contact/commands/DeleteParams.java → ...contact/commands/params/DeleteParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
View
2 ...m/basho/contact/commands/FetchParams.java → .../contact/commands/params/FetchParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
View
104 src/main/java/com/basho/contact/commands/params/GenDocs.java
@@ -0,0 +1,104 @@
+package com.basho.contact.commands.params;
+
+import com.basho.contact.actions.ActionParams;
+import com.basho.contact.actions.Binding;
+import com.google.common.base.Predicate;
+import org.reflections.ReflectionUtils;
+import org.reflections.Reflections;
+import static org.reflections.Reflections.*;
+import javax.annotation.Nullable;
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class GenDocs {
+ //http://basho.github.com/riak-java-client/1.1.0/com/basho/riak/client/IRiakClient.html
+ public static class Doc {
+ public Doc(String id) {
+ this.id = id;
+ }
+
+ public Doc(String id, String clazz) {
+ this.id = id;
+ this.clazz = clazz;
+ }
+ String id;
+ String clazz;
+ List<Doc> pres = new ArrayList<Doc>();
+ List<Doc> posts = new ArrayList<Doc>();
+ }
+
+ public static String linkifyClasses(String s) {
+ if(s.startsWith("class")) {
+ s = s.substring(6);
+ } else if(s.startsWith("interface")) {
+ s = s.substring(10);
+ }
+ Pattern p = Pattern.compile("([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*");
+ Matcher m = p.matcher(s);
+
+ StringBuffer docString = new StringBuffer();
+ while(m.find()) {
+ String classname = m.group();
+ String url = "";
+ if(classname.startsWith("java")) {
+ // http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
+ url = "http://docs.oracle.com/javase/7/docs/api/" + classname.replace(".", "/") + ".html";
+ } else if(classname.startsWith("com.basho")) {
+ if(!classname.endsWith("RuntimeContext")) {
+ url = "http://basho.github.com/riak-java-client/1.1.0/" + classname.replace(".", "/") + ".html";
+ }
+ }
+ String data = "[" + s.substring(m.start(), m.end()) + "]("+url+")";
+ // [example](http://url.com/ "Title")
+ m.appendReplacement(docString, data);
+ }
+ m.appendTail(docString);
+ return docString.toString();
+ }
+ public static void main(String args[]) {
+ //linkifyClasses("java.util.Map<java.lang.String, java.lang.Object>");
+ //linkifyClasses("class com.basho.contact.RuntimeContext");
+ //linkifyClasses("interface com.basho.riak.client.IRiakObject");
+ Reflections reflections = new Reflections("com.basho.contact.commands.params");
+ Map<String, Doc> params = new HashMap<String, Doc>();
+ Set<Class<? extends ActionParams>> subTypes =
+ reflections.getSubTypesOf(ActionParams.class);
+ for(Class<? extends ActionParams> c : subTypes) {
+ Set<Field> fields = ReflectionUtils.getAllFields(c, withAnnotation(Binding.class));
+ for(Field f : fields) {
+ String cname = c.getName().substring(c.getName().lastIndexOf(".")+1);
+ String xname = c.getEnclosingClass().getName().substring(c.getEnclosingClass().getName().lastIndexOf(".")+1).toLowerCase();
+ String name = xname.substring(0, xname.indexOf("params"));
+ if(!params.containsKey(name)) {
+ params.put(name, new Doc(name));
+ }
+ Doc doc = params.get(name);
+ Binding b = f.getAnnotation(Binding.class);
+ Doc item = new Doc(b.name(), f.getGenericType().toString());
+ if(cname.endsWith("Pre")) {
+ doc.pres.add(item);
+ } else {
+ Doc post = new Doc(b.name());
+ doc.posts.add(item);
+ }
+ //System.out.println(cname + ":" + );
+ //params.put(cname, f.getName());
+ }
+ }
+ for(String k : params.keySet()) {
+ System.out.println("* **" + k + "**");
+ System.out.println(" * **Pre** parameters");
+ for(Doc d : params.get(k).pres) {
+ System.out.println(" * " + d.id + " : *" + linkifyClasses(d.clazz) + "*");
+ }
+ System.out.println(" * **Post** parameters");
+ for(Doc d : params.get(k).posts) {
+ System.out.println(" * " + d.id + " : *" + linkifyClasses(d.clazz) + "*");
+ }
+ System.out.println("");
+ }
+ }
+
+}
View
2 ...ontact/commands/GetBucketPropsParams.java → ...commands/params/GetBucketPropsParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
View
2 ...o/contact/commands/ListBucketsParams.java → ...ct/commands/params/ListBucketsParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
import com.basho.contact.actions.Binding;
View
2 ...asho/contact/commands/ListKeysParams.java → ...ntact/commands/params/ListKeysParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
import com.basho.contact.actions.Binding;
View
2 .../basho/contact/commands/MapRedParams.java → ...contact/commands/params/MapRedParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
View
2 ...basho/contact/commands/Query2iParams.java → ...ontact/commands/params/Query2iParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
View
2 ...ontact/commands/SetBucketPropsParams.java → ...commands/params/SetBucketPropsParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.actions.ActionParams;
View
2 ...m/basho/contact/commands/StoreParams.java → .../contact/commands/params/StoreParams.java
@@ -1,4 +1,4 @@
-package com.basho.contact.commands;
+package com.basho.contact.commands.params;
import com.basho.contact.Content;
import com.basho.contact.Pair;

0 comments on commit db835df

Please sign in to comment.
Something went wrong with that request. Please try again.