Permalink
Browse files

update doclet

  • Loading branch information...
ylimit committed Aug 24, 2017
1 parent 0ac62ba commit 9946e7b81092b19000723b1d774fbad099c52549
@@ -15,8 +15,8 @@
public static final String TYPE_ITEM = "io.github.privacystreams.core.Item";
public static final String TYPE_P_STREAM = "io.github.privacystreams.core.PStream";
public static final String OPERATORS_TABLE_HEADER = "| Type | Reference & Description |\n|----|----|\n";
public static final String FIELDS_TABLE_HEADER = "| Reference | Name | Type | Description |\n|----|----|----|----|\n";
public static final String OPERATORS_TABLE_HEADER = "| Type | API & Description |\n|----|----|\n";
public static final String FIELDS_TABLE_HEADER = "| Name | Type | Description |\n|----|----|----|\n";
public static final String PIPELINE_TABLE_HEADER = "| Input -> Output | Tag | Reference & Description |\n|----|----|----|\n";
public static final String PIPELINE_TABLE_HEADER = "| Input,Output | API & Description |\n|----|----|\n";
}
@@ -55,7 +55,9 @@ private boolean build(RootDoc rootDoc) {
if (Utils.instanceOf(classDoc, Consts.TYPE_P_STREAM)) {
for (MethodDoc methodDoc : classDoc.methods()) {
PSPipelineDoc pipelineDoc = PSPipelineDoc.build(classDoc, methodDoc);
if (pipelineDoc != null) this.psPipelines.add(pipelineDoc);
if (pipelineDoc != null) {
this.psPipelines.add(pipelineDoc);
}
}
}
}
@@ -75,7 +75,7 @@ public String toString() {
itemDocStr += this.description + "\n\n";
if (this.itemFieldDocs.size() > 0) {
itemDocStr += "### Fields\n\n";
itemDocStr += "#### Fields of *" + this.name + "*\n\n";
itemDocStr += Consts.FIELDS_TABLE_HEADER;
for (PSItemFieldDoc itemFieldDoc : this.itemFieldDocs) {
@@ -84,7 +84,7 @@ public String toString() {
}
if (this.providerDocs.size() > 0) {
itemDocStr += "\n### Providers\n\n";
itemDocStr += "\n#### Providers of *" + this.name + "*\n\n";
itemDocStr += Consts.OPERATORS_TABLE_HEADER;
for (PSOperatorDoc providerDoc : this.providerDocs) {
@@ -21,7 +21,7 @@
private PSItemFieldDoc(PSItemDoc psItemDoc, FieldDoc fieldDoc, AnnotationDesc annotation) {
this.psItemDoc = psItemDoc;
this.reference = psItemDoc.name + "." + fieldDoc.name();
this.reference = fieldDoc.name();
this.name = fieldDoc.constantValue().toString();
this.description = fieldDoc.commentText().replace('\n', ' ');
@@ -45,7 +45,7 @@ public static PSItemFieldDoc build(PSItemDoc psItemDoc, FieldDoc fieldDoc) {
}
public String toString() {
return "| `" + this.reference + "` | `\"" + this.name + "\"` | `" + Utils.getSimpleTypeName(this.type) + "` | " + this.description + " |";
return "| `" + this.reference + "` | `" + Utils.getSimpleTypeName(this.type) + "` | " + this.description + " |";
}
}
@@ -6,6 +6,8 @@
import com.sun.javadoc.Tag;
import com.sun.javadoc.Type;
import java.util.Objects;
/**
* Created by yuanchun on 11/03/2017.
*/
@@ -15,24 +17,25 @@
ClassDoc declaringClassDoc;
MethodDoc methodDoc;
String description;
String paramDesc;
String shortSignature;
// String completeSignature;
Type returnType;
Type inputType;
Type outputType;
private PSOperatorDoc(ClassDoc classDoc, MethodDoc methodDoc) {
this.declaringClassDoc = classDoc;
this.methodDoc = methodDoc;
this.description = methodDoc.commentText().replace('\n', ' ');;
this.description = methodDoc.commentText().replace('\n', ' ');
this.paramDesc = "";
Tag[] paramTags = methodDoc.tags("param");
for (Tag paramTag : paramTags) {
String paraStr = paramTag.text();
String paraName = paraStr.substring(0, paraStr.indexOf(' ')).replace('\n', ' ');;
String paraDesc = paraStr.substring(paraStr.indexOf(' ') + 1).replace('\n', ' ');;
this.description += "<br> - `" + paraName + "`: " + paraDesc;
this.paramDesc += "<br> - `" + paraName + "`: " + paraDesc;
}
this.returnType = methodDoc.returnType();
@@ -47,8 +50,7 @@ private PSOperatorDoc(ClassDoc classDoc, MethodDoc methodDoc) {
if (firstParameter) {
shortSignature += Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
firstParameter = false;
}
else {
} else {
shortSignature += ", " + Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
}
}
@@ -65,7 +67,7 @@ public static PSOperatorDoc build(ClassDoc classDoc, MethodDoc methodDoc) {
}
public String toString() {
String operatorDocStr = "| `" + Utils.getSimpleTypeName(this.returnType) + "` | `" + this.shortSignature + "` <br> " + this.description + " |";
String operatorDocStr = "| `" + Utils.getSimpleTypeName(this.returnType) + "` | **`" + this.shortSignature + "`** <br> " + this.description + this.paramDesc + " |";
return operatorDocStr;
}
@@ -64,23 +64,23 @@ private PSPipelineDoc(ClassDoc classDoc, MethodDoc methodDoc, AnnotationDesc ann
this.type = type;
if (type == TYPE_TRANSFORMATION) {
// this.tag = "Keep order";
// for (AnnotationDesc.ElementValuePair elementValuePair : annotation.elementValues()) {
// if ("changeOrder".equals(elementValuePair.element().name())) {
// boolean typeValue = (boolean) elementValuePair.value().value();
// if (typeValue) this.tag = "Change order";
// else this.tag = "Keep order";
// }
// }
this.tag = "Keep order";
for (AnnotationDesc.ElementValuePair elementValuePair : annotation.elementValues()) {
if ("changeOrder".equals(elementValuePair.element().name())) {
boolean typeValue = (boolean) elementValuePair.value().value();
if (typeValue) this.description += "<br>This transformation will change the order of items.";
else this.description += "<br>This transformation will NOT change the order of items.";
}
}
this.tag = "";
}
else if (type == TYPE_ACTION) {
this.tag = "Blocking";
for (AnnotationDesc.ElementValuePair elementValuePair : annotation.elementValues()) {
if ("blocking".equals(elementValuePair.element().name())) {
boolean typeValue = (boolean) elementValuePair.value().value();
if (typeValue) this.tag = "Blocking";
else this.tag = "Non-blocking";
if (typeValue) this.description += "<br>This action will block current thread.";
else this.description += "<br>This action will NOT block current thread.";
}
}
}
@@ -102,11 +102,10 @@ else if (Consts.ACTION_ANNOTATION.equals(annotationType.toString())) {
public String toString() {
String operatorDocStr = String.format(Locale.ENGLISH,
"| `%s->%s` | %s | `%s` <br> %s |",
"| `%s,%s` | **`%s`** <br> %s |",
// this.type == TYPE_TRANSFORMATION ? "transform" : "output",
Utils.getSimpleTypeName(this.declaringClassDoc),
Utils.getSimpleTypeName(this.returnType),
this.tag,
this.shortSignature,
this.description
);
@@ -66,7 +66,7 @@ dependencies {
// third-party packages
provided 'com.dropbox.core:dropbox-core-sdk:2.1.1'
provided 'com.google.android.gms:play-services:10.2.4'
provided 'com.google.android.gms:play-services:11.0.4'
provided ('com.google.api-client:google-api-client-android:1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
@@ -176,16 +176,17 @@ bintray {
githubReleaseNotesFile = 'README.md' //Optional Github readme file
publish = false
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
sign = true // Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") // Optional. The passphrase for GPG signing'
}
}
}
}
repositories {
mavenCentral()
}
@@ -16,7 +16,7 @@
* The list of currently scanned bluetooth device.
*/
@PSItemField(type = List.class)
public static final String BLUETOOTH_DEVICE_LIST = "bluetooth_device_list";
public static final String BT_DEVICE_LIST = "bt_device_list";
/**
* The list of currently scanned Wifi APs.
@@ -60,7 +60,7 @@
* Provide a live stream of device states, including bluetooth, wifi, battery level, and/or foreground apps etc.
*
* @param interval the interval between each two device state snapshots
* @param mask the mask of device state type, could be `DeviceState.Masks.BLUETOOTH_DEVICE_LIST`, `DeviceState.Masks.WIFI_AP_LIST`, etc.
* @param mask the mask of device state type, could be `DeviceState.Masks.BT_DEVICE_LIST`, `DeviceState.Masks.WIFI_AP_LIST`, etc.
* @return the provider function
*/
public static PStreamProvider asUpdates(long interval, int mask) {
@@ -72,7 +72,7 @@ private void getBluetoothDeviceList(Item deviceState) {
List<Item> bluetoothList = this.getUQI()
.getData(BluetoothDevice.getScanResults(), Purpose.LIB_INTERNAL("DeviceStateUpdatesProvider"))
.asList();
deviceState.setFieldValue(DeviceState.BLUETOOTH_DEVICE_LIST, bluetoothList);
deviceState.setFieldValue(DeviceState.BT_DEVICE_LIST, bluetoothList);
} catch (PSException e) {
e.printStackTrace();
}
@@ -80,7 +80,6 @@ protected void provide() {
.build();
client.connect();
walkingFence = DetectedActivityFence.during(DetectedActivityFence.WALKING); //Create Fence
tiltingFence = DetectedActivityFence.during(DetectedActivityFence.TILTING);
onFootFence = DetectedActivityFence.during(DetectedActivityFence.ON_FOOT);
runningFence = DetectedActivityFence.during(DetectedActivityFence.RUNNING);
@@ -51,6 +51,8 @@
import java.util.Map;
import static io.github.privacystreams.commons.statistic.StatisticOperators.count;
import static io.github.privacystreams.commons.statistic.StatisticOperators.sum;
import static io.github.privacystreams.commons.string.StringOperators.sha1;
import static io.github.privacystreams.commons.time.TimeOperators.recent;
/**
@@ -445,17 +447,34 @@ void getTotalNumberOfCallsPerPerson() throws PSException {
.getData(Call.getLogs(), Purpose.FEATURE("get the tie relationship with people"))
.groupBy(Call.CONTACT)
.setGroupField("num_of_calls", StatisticOperators.count())
.setGroupField("length_of_calls", StatisticOperators.sum(Call.DURATION))
.setGroupField("length_of_calls", sum(Call.DURATION))
.project(Call.CONTACT, "num_of_calls", "length_of_calls")
.asList();
Callback<Item> callback = new Callback<Item>() {
@Override
protected void onInput(Item input) {
}
};
uqi.getData(Call.getLogs(), Purpose.SOCIAL("Infer social relationship"))
.filter(recent(Call.TIMESTAMP, 365*24*60*60*1000L))
.groupBy(Call.CONTACT)
.setGroupField("#calls", count())
.setGroupField("Dur.calls", sum(Call.DURATION))
.setField("hashed_phone", sha1(Call.CONTACT))
.project("hashed_phone", "#calls", "Dur.calls")
.forEach(callback);
}
// hash the names or phone#s in Message or call logs, so we can get data like above while mitigating privacy concerns
List<String> getHashedPhoneNumbersInSMS() throws PSException {
return uqi
.getData(Message.getAllSMS(), Purpose.FEATURE("get hashed phone numbers."))
.setField("hashed_phone_number", StringOperators.sha1(Message.CONTACT))
.setField("hashed_phone_number", sha1(Message.CONTACT))
.asList("hashed_phone_number");
}

0 comments on commit 9946e7b

Please sign in to comment.