This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,98 @@ StatementClient client = new StatementClient(url, username, password); | |
|
||
This has the possiblitiy of throwing a ```MalformedURLException``` if an invalid URL is passed it. | ||
|
||
## Creating a Statement | ||
|
||
This library has some overloaded model constructors to simplify building common parts of a statement. | ||
|
||
```java | ||
// create an activity with just an id | ||
Activity activity = new Activity("http://activity.com"); | ||
System.out.println("Activity"); | ||
System.out.println( "\t" + activity ); | ||
|
||
// prints... | ||
// Activity | ||
// http://activity.com | ||
|
||
// create an agent with name and mbox | ||
Agent agent = new Agent("tommy", "mailto:[email protected]"); | ||
System.out.println("Agent - name & mbox"); | ||
System.out.println("\t" + agent); | ||
|
||
// prints... | ||
// Agent - name & mbox | ||
// tommy | ||
|
||
// create an agent with just an mbox | ||
Agent agent = new Agent(null, "mailto:[email protected]") | ||
System.out.println("Agent - mbox"); | ||
System.out.println("\t" + agent); | ||
|
||
// prints... | ||
// Agent - mbox | ||
// mailto:[email protected] | ||
|
||
// create an agent with openid | ||
Agent agent = new Agent(null, new URI("http://tom-is-me"))); | ||
System.out.println("Agent - openid"); | ||
System.out.println("\t" + agent); | ||
|
||
// prints... | ||
// Agent - openid | ||
// http://tom-is-me | ||
|
||
// create an agent with an account | ||
Agent agent = new Agent("", new Account("joe", "http://joe.com")); | ||
System.out.println("Agent - account"); | ||
System.out.println("\t" + agent); | ||
|
||
// prints... | ||
// Agent - account | ||
// joe (http://joe.com) | ||
|
||
|
||
// use an ADL verb | ||
System.out.println("ADL verb"); | ||
System.out.println("\t" + Verbs.answered()); | ||
|
||
// prints... | ||
// ADL verb | ||
// answered | ||
|
||
// create a verb | ||
Verb verb = new Verb("http://my.verb/didsomething"); | ||
System.out.println("my verb"); | ||
System.out.println("\t" + verb); | ||
|
||
// prints... | ||
// my verb | ||
// http://my.verb/didsomething | ||
|
||
|
||
// create a verb with display | ||
HashMap<String, String> disp = new HashMap<String, String>(); | ||
disp.put("fr", "le ran"); | ||
disp.put("en-US", "ran"); | ||
Verb verb = new Verb("http://my.verb/ran", disp); | ||
System.out.println("my ran verb"); | ||
System.out.println("\t" + verb); | ||
|
||
// prints... | ||
// my ran verb | ||
// ran | ||
|
||
// create a basic statement | ||
System.out.println("Statement "); | ||
System.out.println("\t" + new Statement(new Agent("tom", "mailto:[email protected]"), | ||
new Verb("http://verb.com/did", getVerbDisp()), | ||
new Activity("act:id"))); | ||
|
||
// prints... | ||
// Statement | ||
// 7fdbc0cc-aef8-47d6-97ad-b1929afc34b5: tom did act:id | ||
``` | ||
|
||
## Publishing a Statement | ||
|
||
To publish a statement you'll need a Verb (There is a predefined list of ADL verbs available in ```gov.adlnet.xapi.model.Verbs``` class), an Actor who compled the activity the statment describes, and the Statement object, which can be an Activity, a SubStatement, or a StatementRef | ||
|