id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
157,800
|
uwolfer/gerrit-rest-java-client
|
src/main/java/com/urswolfer/gerrit/client/rest/http/PreemptiveAuthHttpRequestInterceptor.java
|
PreemptiveAuthHttpRequestInterceptor.isForGerritHost
|
private boolean isForGerritHost(HttpRequest request) {
if (!(request instanceof HttpRequestWrapper)) return false;
HttpRequest originalRequest = ((HttpRequestWrapper) request).getOriginal();
if (!(originalRequest instanceof HttpRequestBase)) return false;
URI uri = ((HttpRequestBase) originalRequest).getURI();
URI authDataUri = URI.create(authData.getHost());
if (uri == null || uri.getHost() == null) return false;
boolean hostEquals = uri.getHost().equals(authDataUri.getHost());
boolean portEquals = uri.getPort() == authDataUri.getPort();
return hostEquals && portEquals;
}
|
java
|
private boolean isForGerritHost(HttpRequest request) {
if (!(request instanceof HttpRequestWrapper)) return false;
HttpRequest originalRequest = ((HttpRequestWrapper) request).getOriginal();
if (!(originalRequest instanceof HttpRequestBase)) return false;
URI uri = ((HttpRequestBase) originalRequest).getURI();
URI authDataUri = URI.create(authData.getHost());
if (uri == null || uri.getHost() == null) return false;
boolean hostEquals = uri.getHost().equals(authDataUri.getHost());
boolean portEquals = uri.getPort() == authDataUri.getPort();
return hostEquals && portEquals;
}
|
[
"private",
"boolean",
"isForGerritHost",
"(",
"HttpRequest",
"request",
")",
"{",
"if",
"(",
"!",
"(",
"request",
"instanceof",
"HttpRequestWrapper",
")",
")",
"return",
"false",
";",
"HttpRequest",
"originalRequest",
"=",
"(",
"(",
"HttpRequestWrapper",
")",
"request",
")",
".",
"getOriginal",
"(",
")",
";",
"if",
"(",
"!",
"(",
"originalRequest",
"instanceof",
"HttpRequestBase",
")",
")",
"return",
"false",
";",
"URI",
"uri",
"=",
"(",
"(",
"HttpRequestBase",
")",
"originalRequest",
")",
".",
"getURI",
"(",
")",
";",
"URI",
"authDataUri",
"=",
"URI",
".",
"create",
"(",
"authData",
".",
"getHost",
"(",
")",
")",
";",
"if",
"(",
"uri",
"==",
"null",
"||",
"uri",
".",
"getHost",
"(",
")",
"==",
"null",
")",
"return",
"false",
";",
"boolean",
"hostEquals",
"=",
"uri",
".",
"getHost",
"(",
")",
".",
"equals",
"(",
"authDataUri",
".",
"getHost",
"(",
")",
")",
";",
"boolean",
"portEquals",
"=",
"uri",
".",
"getPort",
"(",
")",
"==",
"authDataUri",
".",
"getPort",
"(",
")",
";",
"return",
"hostEquals",
"&&",
"portEquals",
";",
"}"
] |
Checks if request is intended for Gerrit host.
|
[
"Checks",
"if",
"request",
"is",
"intended",
"for",
"Gerrit",
"host",
"."
] |
fa66cd76270cd12cff9e30e0d96826fe0253d209
|
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/urswolfer/gerrit/client/rest/http/PreemptiveAuthHttpRequestInterceptor.java#L54-L64
|
157,801
|
cloudfoundry/cf-java-client
|
cloudfoundry-util/src/main/java/org/cloudfoundry/util/FileUtils.java
|
FileUtils.getRelativePathName
|
public static String getRelativePathName(Path root, Path path) {
Path relative = root.relativize(path);
return Files.isDirectory(path) && !relative.toString().endsWith("/") ? String.format("%s/", relative.toString()) : relative.toString();
}
|
java
|
public static String getRelativePathName(Path root, Path path) {
Path relative = root.relativize(path);
return Files.isDirectory(path) && !relative.toString().endsWith("/") ? String.format("%s/", relative.toString()) : relative.toString();
}
|
[
"public",
"static",
"String",
"getRelativePathName",
"(",
"Path",
"root",
",",
"Path",
"path",
")",
"{",
"Path",
"relative",
"=",
"root",
".",
"relativize",
"(",
"path",
")",
";",
"return",
"Files",
".",
"isDirectory",
"(",
"path",
")",
"&&",
"!",
"relative",
".",
"toString",
"(",
")",
".",
"endsWith",
"(",
"\"/\"",
")",
"?",
"String",
".",
"format",
"(",
"\"%s/\"",
",",
"relative",
".",
"toString",
"(",
")",
")",
":",
"relative",
".",
"toString",
"(",
")",
";",
"}"
] |
Get the relative path of an application
@param root the root to relativize against
@param path the path to relativize
@return the relative path
|
[
"Get",
"the",
"relative",
"path",
"of",
"an",
"application"
] |
caa1cb889cfe8717614c071703d833a1540784df
|
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/FileUtils.java#L108-L111
|
157,802
|
cloudfoundry/cf-java-client
|
cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java
|
_DefaultConnectionContext.dispose
|
@PreDestroy
public final void dispose() {
getConnectionPool().ifPresent(PoolResources::dispose);
getThreadPool().dispose();
try {
ObjectName name = getByteBufAllocatorObjectName();
if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
}
} catch (JMException e) {
this.logger.error("Unable to register ByteBufAllocator MBean", e);
}
}
|
java
|
@PreDestroy
public final void dispose() {
getConnectionPool().ifPresent(PoolResources::dispose);
getThreadPool().dispose();
try {
ObjectName name = getByteBufAllocatorObjectName();
if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
}
} catch (JMException e) {
this.logger.error("Unable to register ByteBufAllocator MBean", e);
}
}
|
[
"@",
"PreDestroy",
"public",
"final",
"void",
"dispose",
"(",
")",
"{",
"getConnectionPool",
"(",
")",
".",
"ifPresent",
"(",
"PoolResources",
"::",
"dispose",
")",
";",
"getThreadPool",
"(",
")",
".",
"dispose",
"(",
")",
";",
"try",
"{",
"ObjectName",
"name",
"=",
"getByteBufAllocatorObjectName",
"(",
")",
";",
"if",
"(",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"isRegistered",
"(",
"name",
")",
")",
"{",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"unregisterMBean",
"(",
"name",
")",
";",
"}",
"}",
"catch",
"(",
"JMException",
"e",
")",
"{",
"this",
".",
"logger",
".",
"error",
"(",
"\"Unable to register ByteBufAllocator MBean\"",
",",
"e",
")",
";",
"}",
"}"
] |
Disposes resources created to service this connection context
|
[
"Disposes",
"resources",
"created",
"to",
"service",
"this",
"connection",
"context"
] |
caa1cb889cfe8717614c071703d833a1540784df
|
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java#L70-L84
|
157,803
|
cloudfoundry/cf-java-client
|
cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java
|
ResourceUtils.getEntity
|
public static <T, R extends Resource<T>> T getEntity(R resource) {
return resource.getEntity();
}
|
java
|
public static <T, R extends Resource<T>> T getEntity(R resource) {
return resource.getEntity();
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
"extends",
"Resource",
"<",
"T",
">",
">",
"T",
"getEntity",
"(",
"R",
"resource",
")",
"{",
"return",
"resource",
".",
"getEntity",
"(",
")",
";",
"}"
] |
Return the entity of a resource
@param resource the resource
@param <T> the type of the resource's entity
@param <R> the resource type
@return the resource's entity
|
[
"Return",
"the",
"entity",
"of",
"a",
"resource"
] |
caa1cb889cfe8717614c071703d833a1540784df
|
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java#L39-L41
|
157,804
|
cloudfoundry/cf-java-client
|
cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java
|
ResourceUtils.getResources
|
public static <R extends Resource<?>, U extends PaginatedResponse<R>> Flux<R> getResources(U response) {
return Flux.fromIterable(response.getResources());
}
|
java
|
public static <R extends Resource<?>, U extends PaginatedResponse<R>> Flux<R> getResources(U response) {
return Flux.fromIterable(response.getResources());
}
|
[
"public",
"static",
"<",
"R",
"extends",
"Resource",
"<",
"?",
">",
",",
"U",
"extends",
"PaginatedResponse",
"<",
"R",
">",
">",
"Flux",
"<",
"R",
">",
"getResources",
"(",
"U",
"response",
")",
"{",
"return",
"Flux",
".",
"fromIterable",
"(",
"response",
".",
"getResources",
"(",
")",
")",
";",
"}"
] |
Return a stream of resources from a response
@param response the response
@param <R> the resource type
@param <U> the response type
@return a stream of resources from the response
|
[
"Return",
"a",
"stream",
"of",
"resources",
"from",
"a",
"response"
] |
caa1cb889cfe8717614c071703d833a1540784df
|
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java#L61-L63
|
157,805
|
cloudfoundry/cf-java-client
|
cloudfoundry-util/src/main/java/org/cloudfoundry/util/JobUtils.java
|
JobUtils.waitForCompletion
|
public static Mono<Void> waitForCompletion(CloudFoundryClient cloudFoundryClient, Duration completionTimeout, String jobId) {
return requestJobV3(cloudFoundryClient, jobId)
.filter(job -> JobState.PROCESSING != job.getState())
.repeatWhenEmpty(exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15), completionTimeout))
.filter(job -> JobState.FAILED == job.getState())
.flatMap(JobUtils::getError);
}
|
java
|
public static Mono<Void> waitForCompletion(CloudFoundryClient cloudFoundryClient, Duration completionTimeout, String jobId) {
return requestJobV3(cloudFoundryClient, jobId)
.filter(job -> JobState.PROCESSING != job.getState())
.repeatWhenEmpty(exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15), completionTimeout))
.filter(job -> JobState.FAILED == job.getState())
.flatMap(JobUtils::getError);
}
|
[
"public",
"static",
"Mono",
"<",
"Void",
">",
"waitForCompletion",
"(",
"CloudFoundryClient",
"cloudFoundryClient",
",",
"Duration",
"completionTimeout",
",",
"String",
"jobId",
")",
"{",
"return",
"requestJobV3",
"(",
"cloudFoundryClient",
",",
"jobId",
")",
".",
"filter",
"(",
"job",
"->",
"JobState",
".",
"PROCESSING",
"!=",
"job",
".",
"getState",
"(",
")",
")",
".",
"repeatWhenEmpty",
"(",
"exponentialBackOff",
"(",
"Duration",
".",
"ofSeconds",
"(",
"1",
")",
",",
"Duration",
".",
"ofSeconds",
"(",
"15",
")",
",",
"completionTimeout",
")",
")",
".",
"filter",
"(",
"job",
"->",
"JobState",
".",
"FAILED",
"==",
"job",
".",
"getState",
"(",
")",
")",
".",
"flatMap",
"(",
"JobUtils",
"::",
"getError",
")",
";",
"}"
] |
Waits for a job V3 to complete
@param cloudFoundryClient the client to use to request job status
@param completionTimeout the amount of time to wait for the job to complete.
@param jobId the id of the job
@return {@code onComplete} once job has completed
|
[
"Waits",
"for",
"a",
"job",
"V3",
"to",
"complete"
] |
caa1cb889cfe8717614c071703d833a1540784df
|
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/JobUtils.java#L93-L99
|
157,806
|
cloudfoundry/cf-java-client
|
cloudfoundry-util/src/main/java/org/cloudfoundry/util/TimeUtils.java
|
TimeUtils.asTime
|
public static String asTime(long time) {
if (time > HOUR) {
return String.format("%.1f h", (time / HOUR));
} else if (time > MINUTE) {
return String.format("%.1f m", (time / MINUTE));
} else if (time > SECOND) {
return String.format("%.1f s", (time / SECOND));
} else {
return String.format("%d ms", time);
}
}
|
java
|
public static String asTime(long time) {
if (time > HOUR) {
return String.format("%.1f h", (time / HOUR));
} else if (time > MINUTE) {
return String.format("%.1f m", (time / MINUTE));
} else if (time > SECOND) {
return String.format("%.1f s", (time / SECOND));
} else {
return String.format("%d ms", time);
}
}
|
[
"public",
"static",
"String",
"asTime",
"(",
"long",
"time",
")",
"{",
"if",
"(",
"time",
">",
"HOUR",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%.1f h\"",
",",
"(",
"time",
"/",
"HOUR",
")",
")",
";",
"}",
"else",
"if",
"(",
"time",
">",
"MINUTE",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%.1f m\"",
",",
"(",
"time",
"/",
"MINUTE",
")",
")",
";",
"}",
"else",
"if",
"(",
"time",
">",
"SECOND",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%.1f s\"",
",",
"(",
"time",
"/",
"SECOND",
")",
")",
";",
"}",
"else",
"{",
"return",
"String",
".",
"format",
"(",
"\"%d ms\"",
",",
"time",
")",
";",
"}",
"}"
] |
Renders a time period in human readable form
@param time the time in milliseconds
@return the time in human readable form
|
[
"Renders",
"a",
"time",
"period",
"in",
"human",
"readable",
"form"
] |
caa1cb889cfe8717614c071703d833a1540784df
|
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/TimeUtils.java#L41-L51
|
157,807
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/View.java
|
View.buildMatcher
|
private ClassMatcher buildMatcher(String tagText) {
// check there are at least @match <type> and a parameter
String[] strings = StringUtil.tokenize(tagText);
if (strings.length < 2) {
System.err.println("Skipping uncomplete @match tag, type missing: " + tagText + " in view " + viewDoc);
return null;
}
try {
if (strings[0].equals("class")) {
return new PatternMatcher(Pattern.compile(strings[1]));
} else if (strings[0].equals("context")) {
return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(),
false);
} else if (strings[0].equals("outgoingContext")) {
return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(),
false);
} else if (strings[0].equals("interface")) {
return new InterfaceMatcher(root, Pattern.compile(strings[1]));
} else if (strings[0].equals("subclass")) {
return new SubclassMatcher(root, Pattern.compile(strings[1]));
} else {
System.err.println("Skipping @match tag, unknown match type, in view " + viewDoc);
}
} catch (PatternSyntaxException pse) {
System.err.println("Skipping @match tag due to invalid regular expression '" + tagText
+ "'" + " in view " + viewDoc);
} catch (Exception e) {
System.err.println("Skipping @match tag due to an internal error '" + tagText
+ "'" + " in view " + viewDoc);
e.printStackTrace();
}
return null;
}
|
java
|
private ClassMatcher buildMatcher(String tagText) {
// check there are at least @match <type> and a parameter
String[] strings = StringUtil.tokenize(tagText);
if (strings.length < 2) {
System.err.println("Skipping uncomplete @match tag, type missing: " + tagText + " in view " + viewDoc);
return null;
}
try {
if (strings[0].equals("class")) {
return new PatternMatcher(Pattern.compile(strings[1]));
} else if (strings[0].equals("context")) {
return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(),
false);
} else if (strings[0].equals("outgoingContext")) {
return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(),
false);
} else if (strings[0].equals("interface")) {
return new InterfaceMatcher(root, Pattern.compile(strings[1]));
} else if (strings[0].equals("subclass")) {
return new SubclassMatcher(root, Pattern.compile(strings[1]));
} else {
System.err.println("Skipping @match tag, unknown match type, in view " + viewDoc);
}
} catch (PatternSyntaxException pse) {
System.err.println("Skipping @match tag due to invalid regular expression '" + tagText
+ "'" + " in view " + viewDoc);
} catch (Exception e) {
System.err.println("Skipping @match tag due to an internal error '" + tagText
+ "'" + " in view " + viewDoc);
e.printStackTrace();
}
return null;
}
|
[
"private",
"ClassMatcher",
"buildMatcher",
"(",
"String",
"tagText",
")",
"{",
"// check there are at least @match <type> and a parameter",
"String",
"[",
"]",
"strings",
"=",
"StringUtil",
".",
"tokenize",
"(",
"tagText",
")",
";",
"if",
"(",
"strings",
".",
"length",
"<",
"2",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Skipping uncomplete @match tag, type missing: \"",
"+",
"tagText",
"+",
"\" in view \"",
"+",
"viewDoc",
")",
";",
"return",
"null",
";",
"}",
"try",
"{",
"if",
"(",
"strings",
"[",
"0",
"]",
".",
"equals",
"(",
"\"class\"",
")",
")",
"{",
"return",
"new",
"PatternMatcher",
"(",
"Pattern",
".",
"compile",
"(",
"strings",
"[",
"1",
"]",
")",
")",
";",
"}",
"else",
"if",
"(",
"strings",
"[",
"0",
"]",
".",
"equals",
"(",
"\"context\"",
")",
")",
"{",
"return",
"new",
"ContextMatcher",
"(",
"root",
",",
"Pattern",
".",
"compile",
"(",
"strings",
"[",
"1",
"]",
")",
",",
"getGlobalOptions",
"(",
")",
",",
"false",
")",
";",
"}",
"else",
"if",
"(",
"strings",
"[",
"0",
"]",
".",
"equals",
"(",
"\"outgoingContext\"",
")",
")",
"{",
"return",
"new",
"ContextMatcher",
"(",
"root",
",",
"Pattern",
".",
"compile",
"(",
"strings",
"[",
"1",
"]",
")",
",",
"getGlobalOptions",
"(",
")",
",",
"false",
")",
";",
"}",
"else",
"if",
"(",
"strings",
"[",
"0",
"]",
".",
"equals",
"(",
"\"interface\"",
")",
")",
"{",
"return",
"new",
"InterfaceMatcher",
"(",
"root",
",",
"Pattern",
".",
"compile",
"(",
"strings",
"[",
"1",
"]",
")",
")",
";",
"}",
"else",
"if",
"(",
"strings",
"[",
"0",
"]",
".",
"equals",
"(",
"\"subclass\"",
")",
")",
"{",
"return",
"new",
"SubclassMatcher",
"(",
"root",
",",
"Pattern",
".",
"compile",
"(",
"strings",
"[",
"1",
"]",
")",
")",
";",
"}",
"else",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Skipping @match tag, unknown match type, in view \"",
"+",
"viewDoc",
")",
";",
"}",
"}",
"catch",
"(",
"PatternSyntaxException",
"pse",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Skipping @match tag due to invalid regular expression '\"",
"+",
"tagText",
"+",
"\"'\"",
"+",
"\" in view \"",
"+",
"viewDoc",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Skipping @match tag due to an internal error '\"",
"+",
"tagText",
"+",
"\"'\"",
"+",
"\" in view \"",
"+",
"viewDoc",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Factory method that builds the appropriate matcher for @match tags
|
[
"Factory",
"method",
"that",
"builds",
"the",
"appropriate",
"matcher",
"for"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/View.java#L85-L118
|
157,808
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ContextMatcher.java
|
ContextMatcher.addToGraph
|
private void addToGraph(ClassDoc cd) {
// avoid adding twice the same class, but don't rely on cg.getClassInfo
// since there are other ways to add a classInfor than printing the class
if (visited.contains(cd.toString()))
return;
visited.add(cd.toString());
cg.printClass(cd, false);
cg.printRelations(cd);
if (opt.inferRelationships)
cg.printInferredRelations(cd);
if (opt.inferDependencies)
cg.printInferredDependencies(cd);
}
|
java
|
private void addToGraph(ClassDoc cd) {
// avoid adding twice the same class, but don't rely on cg.getClassInfo
// since there are other ways to add a classInfor than printing the class
if (visited.contains(cd.toString()))
return;
visited.add(cd.toString());
cg.printClass(cd, false);
cg.printRelations(cd);
if (opt.inferRelationships)
cg.printInferredRelations(cd);
if (opt.inferDependencies)
cg.printInferredDependencies(cd);
}
|
[
"private",
"void",
"addToGraph",
"(",
"ClassDoc",
"cd",
")",
"{",
"// avoid adding twice the same class, but don't rely on cg.getClassInfo",
"// since there are other ways to add a classInfor than printing the class",
"if",
"(",
"visited",
".",
"contains",
"(",
"cd",
".",
"toString",
"(",
")",
")",
")",
"return",
";",
"visited",
".",
"add",
"(",
"cd",
".",
"toString",
"(",
")",
")",
";",
"cg",
".",
"printClass",
"(",
"cd",
",",
"false",
")",
";",
"cg",
".",
"printRelations",
"(",
"cd",
")",
";",
"if",
"(",
"opt",
".",
"inferRelationships",
")",
"cg",
".",
"printInferredRelations",
"(",
"cd",
")",
";",
"if",
"(",
"opt",
".",
"inferDependencies",
")",
"cg",
".",
"printInferredDependencies",
"(",
"cd",
")",
";",
"}"
] |
Adds the specified class to the internal class graph along with its
relations and dependencies, eventually inferring them, according to the
Options specified for this matcher
@param cd
|
[
"Adds",
"the",
"specified",
"class",
"to",
"the",
"internal",
"class",
"graph",
"along",
"with",
"its",
"relations",
"and",
"dependencies",
"eventually",
"inferring",
"them",
"according",
"to",
"the",
"Options",
"specified",
"for",
"this",
"matcher"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ContextMatcher.java#L104-L117
|
157,809
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
|
UmlGraphDoc.optionLength
|
public static int optionLength(String option) {
int result = Standard.optionLength(option);
if (result != 0)
return result;
else
return UmlGraph.optionLength(option);
}
|
java
|
public static int optionLength(String option) {
int result = Standard.optionLength(option);
if (result != 0)
return result;
else
return UmlGraph.optionLength(option);
}
|
[
"public",
"static",
"int",
"optionLength",
"(",
"String",
"option",
")",
"{",
"int",
"result",
"=",
"Standard",
".",
"optionLength",
"(",
"option",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"return",
"result",
";",
"else",
"return",
"UmlGraph",
".",
"optionLength",
"(",
"option",
")",
";",
"}"
] |
Option check, forwards options to the standard doclet, if that one refuses them,
they are sent to UmlGraph
|
[
"Option",
"check",
"forwards",
"options",
"to",
"the",
"standard",
"doclet",
"if",
"that",
"one",
"refuses",
"them",
"they",
"are",
"sent",
"to",
"UmlGraph"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L36-L42
|
157,810
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
|
UmlGraphDoc.start
|
public static boolean start(RootDoc root) {
root.printNotice("UmlGraphDoc version " + Version.VERSION + ", running the standard doclet");
Standard.start(root);
root.printNotice("UmlGraphDoc version " + Version.VERSION + ", altering javadocs");
try {
String outputFolder = findOutputPath(root.options());
Options opt = UmlGraph.buildOptions(root);
opt.setOptions(root.options());
// in javadoc enumerations are always printed
opt.showEnumerations = true;
opt.relativeLinksForSourcePackages = true;
// enable strict matching for hide expressions
opt.strictMatching = true;
// root.printNotice(opt.toString());
generatePackageDiagrams(root, opt, outputFolder);
generateContextDiagrams(root, opt, outputFolder);
} catch(Throwable t) {
root.printWarning("Error: " + t.toString());
t.printStackTrace();
return false;
}
return true;
}
|
java
|
public static boolean start(RootDoc root) {
root.printNotice("UmlGraphDoc version " + Version.VERSION + ", running the standard doclet");
Standard.start(root);
root.printNotice("UmlGraphDoc version " + Version.VERSION + ", altering javadocs");
try {
String outputFolder = findOutputPath(root.options());
Options opt = UmlGraph.buildOptions(root);
opt.setOptions(root.options());
// in javadoc enumerations are always printed
opt.showEnumerations = true;
opt.relativeLinksForSourcePackages = true;
// enable strict matching for hide expressions
opt.strictMatching = true;
// root.printNotice(opt.toString());
generatePackageDiagrams(root, opt, outputFolder);
generateContextDiagrams(root, opt, outputFolder);
} catch(Throwable t) {
root.printWarning("Error: " + t.toString());
t.printStackTrace();
return false;
}
return true;
}
|
[
"public",
"static",
"boolean",
"start",
"(",
"RootDoc",
"root",
")",
"{",
"root",
".",
"printNotice",
"(",
"\"UmlGraphDoc version \"",
"+",
"Version",
".",
"VERSION",
"+",
"\", running the standard doclet\"",
")",
";",
"Standard",
".",
"start",
"(",
"root",
")",
";",
"root",
".",
"printNotice",
"(",
"\"UmlGraphDoc version \"",
"+",
"Version",
".",
"VERSION",
"+",
"\", altering javadocs\"",
")",
";",
"try",
"{",
"String",
"outputFolder",
"=",
"findOutputPath",
"(",
"root",
".",
"options",
"(",
")",
")",
";",
"Options",
"opt",
"=",
"UmlGraph",
".",
"buildOptions",
"(",
"root",
")",
";",
"opt",
".",
"setOptions",
"(",
"root",
".",
"options",
"(",
")",
")",
";",
"// in javadoc enumerations are always printed",
"opt",
".",
"showEnumerations",
"=",
"true",
";",
"opt",
".",
"relativeLinksForSourcePackages",
"=",
"true",
";",
"// enable strict matching for hide expressions",
"opt",
".",
"strictMatching",
"=",
"true",
";",
"//\t root.printNotice(opt.toString());",
"generatePackageDiagrams",
"(",
"root",
",",
"opt",
",",
"outputFolder",
")",
";",
"generateContextDiagrams",
"(",
"root",
",",
"opt",
",",
"outputFolder",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"root",
".",
"printWarning",
"(",
"\"Error: \"",
"+",
"t",
".",
"toString",
"(",
")",
")",
";",
"t",
".",
"printStackTrace",
"(",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Standard doclet entry point
@param root
@return
|
[
"Standard",
"doclet",
"entry",
"point"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L49-L73
|
157,811
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
|
UmlGraphDoc.generateContextDiagrams
|
private static void generateContextDiagrams(RootDoc root, Options opt, String outputFolder)
throws IOException {
Set<ClassDoc> classDocs = new TreeSet<ClassDoc>(new Comparator<ClassDoc>() {
public int compare(ClassDoc cd1, ClassDoc cd2) {
return cd1.name().compareTo(cd2.name());
}
});
for (ClassDoc classDoc : root.classes())
classDocs.add(classDoc);
ContextView view = null;
for (ClassDoc classDoc : classDocs) {
try {
if(view == null)
view = new ContextView(outputFolder, classDoc, root, opt);
else
view.setContextCenter(classDoc);
UmlGraph.buildGraph(root, view, classDoc);
runGraphviz(opt.dotExecutable, outputFolder, classDoc.containingPackage().name(), classDoc.name(), root);
alterHtmlDocs(opt, outputFolder, classDoc.containingPackage().name(), classDoc.name(),
classDoc.name() + ".html", Pattern.compile(".*(Class|Interface|Enum) " + classDoc.name() + ".*") , root);
} catch (Exception e) {
throw new RuntimeException("Error generating " + classDoc.name(), e);
}
}
}
|
java
|
private static void generateContextDiagrams(RootDoc root, Options opt, String outputFolder)
throws IOException {
Set<ClassDoc> classDocs = new TreeSet<ClassDoc>(new Comparator<ClassDoc>() {
public int compare(ClassDoc cd1, ClassDoc cd2) {
return cd1.name().compareTo(cd2.name());
}
});
for (ClassDoc classDoc : root.classes())
classDocs.add(classDoc);
ContextView view = null;
for (ClassDoc classDoc : classDocs) {
try {
if(view == null)
view = new ContextView(outputFolder, classDoc, root, opt);
else
view.setContextCenter(classDoc);
UmlGraph.buildGraph(root, view, classDoc);
runGraphviz(opt.dotExecutable, outputFolder, classDoc.containingPackage().name(), classDoc.name(), root);
alterHtmlDocs(opt, outputFolder, classDoc.containingPackage().name(), classDoc.name(),
classDoc.name() + ".html", Pattern.compile(".*(Class|Interface|Enum) " + classDoc.name() + ".*") , root);
} catch (Exception e) {
throw new RuntimeException("Error generating " + classDoc.name(), e);
}
}
}
|
[
"private",
"static",
"void",
"generateContextDiagrams",
"(",
"RootDoc",
"root",
",",
"Options",
"opt",
",",
"String",
"outputFolder",
")",
"throws",
"IOException",
"{",
"Set",
"<",
"ClassDoc",
">",
"classDocs",
"=",
"new",
"TreeSet",
"<",
"ClassDoc",
">",
"(",
"new",
"Comparator",
"<",
"ClassDoc",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"ClassDoc",
"cd1",
",",
"ClassDoc",
"cd2",
")",
"{",
"return",
"cd1",
".",
"name",
"(",
")",
".",
"compareTo",
"(",
"cd2",
".",
"name",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"for",
"(",
"ClassDoc",
"classDoc",
":",
"root",
".",
"classes",
"(",
")",
")",
"classDocs",
".",
"(",
"classDoc",
")",
";",
"ContextView",
"view",
"=",
"null",
";",
"for",
"(",
"ClassDoc",
"classDoc",
":",
"classDocs",
")",
"{",
"try",
"{",
"if",
"(",
"view",
"==",
"null",
")",
"view",
"=",
"new",
"ContextView",
"(",
"outputFolder",
",",
"classDoc",
",",
"root",
",",
"opt",
")",
";",
"else",
"view",
".",
"setContextCenter",
"(",
"classDoc",
")",
";",
"UmlGraph",
".",
"buildGraph",
"(",
"root",
",",
"view",
",",
"classDoc",
")",
";",
"runGraphviz",
"(",
"opt",
".",
"dotExecutable",
",",
"outputFolder",
",",
"classDoc",
".",
"containingPackage",
"(",
")",
".",
"name",
"(",
")",
",",
"classDoc",
".",
"name",
"(",
")",
",",
"root",
")",
";",
"alterHtmlDocs",
"(",
"opt",
",",
"outputFolder",
",",
"classDoc",
".",
"containingPackage",
"(",
")",
".",
"name",
"(",
")",
",",
"classDoc",
".",
"name",
"(",
")",
",",
"classDoc",
".",
"name",
"(",
")",
"+",
"\".html\"",
",",
"Pattern",
".",
"compile",
"(",
"\".*(Class|Interface|Enum) \"",
"+",
"classDoc",
".",
"name",
"(",
")",
"+",
"\".*\"",
")",
",",
"root",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error generating \"",
"+",
"classDoc",
".",
"name",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Generates the context diagram for a single class
|
[
"Generates",
"the",
"context",
"diagram",
"for",
"a",
"single",
"class"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L106-L131
|
157,812
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
|
UmlGraphDoc.alterHtmlDocs
|
private static void alterHtmlDocs(Options opt, String outputFolder, String packageName, String className,
String htmlFileName, Pattern insertPointPattern, RootDoc root) throws IOException {
// setup files
File output = new File(outputFolder, packageName.replace(".", "/"));
File htmlFile = new File(output, htmlFileName);
File alteredFile = new File(htmlFile.getAbsolutePath() + ".uml");
if (!htmlFile.exists()) {
System.err.println("Expected file not found: " + htmlFile.getAbsolutePath());
return;
}
// parse & rewrite
BufferedWriter writer = null;
BufferedReader reader = null;
boolean matched = false;
try {
writer = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream(alteredFile), opt.outputEncoding));
reader = new BufferedReader(new InputStreamReader(new
FileInputStream(htmlFile), opt.outputEncoding));
String line;
while ((line = reader.readLine()) != null) {
writer.write(line);
writer.newLine();
if (!matched && insertPointPattern.matcher(line).matches()) {
matched = true;
String tag;
if (opt.autoSize)
tag = String.format(UML_AUTO_SIZED_DIV_TAG, className);
else
tag = String.format(UML_DIV_TAG, className);
if (opt.collapsibleDiagrams)
tag = String.format(EXPANDABLE_UML, tag, "Show UML class diagram", "Hide UML class diagram");
writer.write("<!-- UML diagram added by UMLGraph version " +
Version.VERSION +
" (http://www.spinellis.gr/umlgraph/) -->");
writer.newLine();
writer.write(tag);
writer.newLine();
}
}
} finally {
if (writer != null)
writer.close();
if (reader != null)
reader.close();
}
// if altered, delete old file and rename new one to the old file name
if (matched) {
htmlFile.delete();
alteredFile.renameTo(htmlFile);
} else {
root.printNotice("Warning, could not find a line that matches the pattern '" + insertPointPattern.pattern()
+ "'.\n Class diagram reference not inserted");
alteredFile.delete();
}
}
|
java
|
private static void alterHtmlDocs(Options opt, String outputFolder, String packageName, String className,
String htmlFileName, Pattern insertPointPattern, RootDoc root) throws IOException {
// setup files
File output = new File(outputFolder, packageName.replace(".", "/"));
File htmlFile = new File(output, htmlFileName);
File alteredFile = new File(htmlFile.getAbsolutePath() + ".uml");
if (!htmlFile.exists()) {
System.err.println("Expected file not found: " + htmlFile.getAbsolutePath());
return;
}
// parse & rewrite
BufferedWriter writer = null;
BufferedReader reader = null;
boolean matched = false;
try {
writer = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream(alteredFile), opt.outputEncoding));
reader = new BufferedReader(new InputStreamReader(new
FileInputStream(htmlFile), opt.outputEncoding));
String line;
while ((line = reader.readLine()) != null) {
writer.write(line);
writer.newLine();
if (!matched && insertPointPattern.matcher(line).matches()) {
matched = true;
String tag;
if (opt.autoSize)
tag = String.format(UML_AUTO_SIZED_DIV_TAG, className);
else
tag = String.format(UML_DIV_TAG, className);
if (opt.collapsibleDiagrams)
tag = String.format(EXPANDABLE_UML, tag, "Show UML class diagram", "Hide UML class diagram");
writer.write("<!-- UML diagram added by UMLGraph version " +
Version.VERSION +
" (http://www.spinellis.gr/umlgraph/) -->");
writer.newLine();
writer.write(tag);
writer.newLine();
}
}
} finally {
if (writer != null)
writer.close();
if (reader != null)
reader.close();
}
// if altered, delete old file and rename new one to the old file name
if (matched) {
htmlFile.delete();
alteredFile.renameTo(htmlFile);
} else {
root.printNotice("Warning, could not find a line that matches the pattern '" + insertPointPattern.pattern()
+ "'.\n Class diagram reference not inserted");
alteredFile.delete();
}
}
|
[
"private",
"static",
"void",
"alterHtmlDocs",
"(",
"Options",
"opt",
",",
"String",
"outputFolder",
",",
"String",
"packageName",
",",
"String",
"className",
",",
"String",
"htmlFileName",
",",
"Pattern",
"insertPointPattern",
",",
"RootDoc",
"root",
")",
"throws",
"IOException",
"{",
"// setup files",
"File",
"output",
"=",
"new",
"File",
"(",
"outputFolder",
",",
"packageName",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
")",
";",
"File",
"htmlFile",
"=",
"new",
"File",
"(",
"output",
",",
"htmlFileName",
")",
";",
"File",
"alteredFile",
"=",
"new",
"File",
"(",
"htmlFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"\".uml\"",
")",
";",
"if",
"(",
"!",
"htmlFile",
".",
"exists",
"(",
")",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Expected file not found: \"",
"+",
"htmlFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
";",
"}",
"// parse & rewrite",
"BufferedWriter",
"writer",
"=",
"null",
";",
"BufferedReader",
"reader",
"=",
"null",
";",
"boolean",
"matched",
"=",
"false",
";",
"try",
"{",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"alteredFile",
")",
",",
"opt",
".",
"outputEncoding",
")",
")",
";",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"htmlFile",
")",
",",
"opt",
".",
"outputEncoding",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"line",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"if",
"(",
"!",
"matched",
"&&",
"insertPointPattern",
".",
"matcher",
"(",
"line",
")",
".",
"matches",
"(",
")",
")",
"{",
"matched",
"=",
"true",
";",
"String",
"tag",
";",
"if",
"(",
"opt",
".",
"autoSize",
")",
"tag",
"=",
"String",
".",
"format",
"(",
"UML_AUTO_SIZED_DIV_TAG",
",",
"className",
")",
";",
"else",
"tag",
"=",
"String",
".",
"format",
"(",
"UML_DIV_TAG",
",",
"className",
")",
";",
"if",
"(",
"opt",
".",
"collapsibleDiagrams",
")",
"tag",
"=",
"String",
".",
"format",
"(",
"EXPANDABLE_UML",
",",
"tag",
",",
"\"Show UML class diagram\"",
",",
"\"Hide UML class diagram\"",
")",
";",
"writer",
".",
"write",
"(",
"\"<!-- UML diagram added by UMLGraph version \"",
"+",
"Version",
".",
"VERSION",
"+",
"\" (http://www.spinellis.gr/umlgraph/) -->\"",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"writer",
".",
"write",
"(",
"tag",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"if",
"(",
"writer",
"!=",
"null",
")",
"writer",
".",
"close",
"(",
")",
";",
"if",
"(",
"reader",
"!=",
"null",
")",
"reader",
".",
"close",
"(",
")",
";",
"}",
"// if altered, delete old file and rename new one to the old file name",
"if",
"(",
"matched",
")",
"{",
"htmlFile",
".",
"delete",
"(",
")",
";",
"alteredFile",
".",
"renameTo",
"(",
"htmlFile",
")",
";",
"}",
"else",
"{",
"root",
".",
"printNotice",
"(",
"\"Warning, could not find a line that matches the pattern '\"",
"+",
"insertPointPattern",
".",
"pattern",
"(",
")",
"+",
"\"'.\\n Class diagram reference not inserted\"",
")",
";",
"alteredFile",
".",
"delete",
"(",
")",
";",
"}",
"}"
] |
Takes an HTML file, looks for the first instance of the specified insertion point, and
inserts the diagram image reference and a client side map in that point.
|
[
"Takes",
"an",
"HTML",
"file",
"looks",
"for",
"the",
"first",
"instance",
"of",
"the",
"specified",
"insertion",
"point",
"and",
"inserts",
"the",
"diagram",
"image",
"reference",
"and",
"a",
"client",
"side",
"map",
"in",
"that",
"point",
"."
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L199-L258
|
157,813
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
|
UmlGraphDoc.findOutputPath
|
private static String findOutputPath(String[][] options) {
for (int i = 0; i < options.length; i++) {
if (options[i][0].equals("-d"))
return options[i][1];
}
return ".";
}
|
java
|
private static String findOutputPath(String[][] options) {
for (int i = 0; i < options.length; i++) {
if (options[i][0].equals("-d"))
return options[i][1];
}
return ".";
}
|
[
"private",
"static",
"String",
"findOutputPath",
"(",
"String",
"[",
"]",
"[",
"]",
"options",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"options",
"[",
"i",
"]",
"[",
"0",
"]",
".",
"equals",
"(",
"\"-d\"",
")",
")",
"return",
"options",
"[",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"return",
"\".\"",
";",
"}"
] |
Returns the output path specified on the javadoc options
|
[
"Returns",
"the",
"output",
"path",
"specified",
"on",
"the",
"javadoc",
"options"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L263-L269
|
157,814
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/Options.java
|
Options.setAll
|
public void setAll() {
showAttributes = true;
showEnumerations = true;
showEnumConstants = true;
showOperations = true;
showConstructors = true;
showVisibility = true;
showType = true;
}
|
java
|
public void setAll() {
showAttributes = true;
showEnumerations = true;
showEnumConstants = true;
showOperations = true;
showConstructors = true;
showVisibility = true;
showType = true;
}
|
[
"public",
"void",
"setAll",
"(",
")",
"{",
"showAttributes",
"=",
"true",
";",
"showEnumerations",
"=",
"true",
";",
"showEnumConstants",
"=",
"true",
";",
"showOperations",
"=",
"true",
";",
"showConstructors",
"=",
"true",
";",
"showVisibility",
"=",
"true",
";",
"showType",
"=",
"true",
";",
"}"
] |
Most complete output
|
[
"Most",
"complete",
"output"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L149-L157
|
157,815
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/Options.java
|
Options.optionLength
|
public static int optionLength(String option) {
if(matchOption(option, "qualify", true) ||
matchOption(option, "qualifyGenerics", true) ||
matchOption(option, "hideGenerics", true) ||
matchOption(option, "horizontal", true) ||
matchOption(option, "all") ||
matchOption(option, "attributes", true) ||
matchOption(option, "enumconstants", true) ||
matchOption(option, "operations", true) ||
matchOption(option, "enumerations", true) ||
matchOption(option, "constructors", true) ||
matchOption(option, "visibility", true) ||
matchOption(option, "types", true) ||
matchOption(option, "autosize", true) ||
matchOption(option, "commentname", true) ||
matchOption(option, "nodefontabstractitalic", true) ||
matchOption(option, "postfixpackage", true) ||
matchOption(option, "noguillemot", true) ||
matchOption(option, "views", true) ||
matchOption(option, "inferrel", true) ||
matchOption(option, "useimports", true) ||
matchOption(option, "collapsible", true) ||
matchOption(option, "inferdep", true) ||
matchOption(option, "inferdepinpackage", true) ||
matchOption(option, "hideprivateinner", true) ||
matchOption(option, "compact", true))
return 1;
else if(matchOption(option, "nodefillcolor") ||
matchOption(option, "nodefontcolor") ||
matchOption(option, "nodefontsize") ||
matchOption(option, "nodefontname") ||
matchOption(option, "nodefontclasssize") ||
matchOption(option, "nodefontclassname") ||
matchOption(option, "nodefonttagsize") ||
matchOption(option, "nodefonttagname") ||
matchOption(option, "nodefontpackagesize") ||
matchOption(option, "nodefontpackagename") ||
matchOption(option, "edgefontcolor") ||
matchOption(option, "edgecolor") ||
matchOption(option, "edgefontsize") ||
matchOption(option, "edgefontname") ||
matchOption(option, "shape") ||
matchOption(option, "output") ||
matchOption(option, "outputencoding") ||
matchOption(option, "bgcolor") ||
matchOption(option, "hide") ||
matchOption(option, "include") ||
matchOption(option, "apidocroot") ||
matchOption(option, "apidocmap") ||
matchOption(option, "d") ||
matchOption(option, "view") ||
matchOption(option, "inferreltype") ||
matchOption(option, "inferdepvis") ||
matchOption(option, "collpackages") ||
matchOption(option, "nodesep") ||
matchOption(option, "ranksep") ||
matchOption(option, "dotexecutable") ||
matchOption(option, "link"))
return 2;
else if(matchOption(option, "contextPattern") ||
matchOption(option, "linkoffline"))
return 3;
else
return 0;
}
|
java
|
public static int optionLength(String option) {
if(matchOption(option, "qualify", true) ||
matchOption(option, "qualifyGenerics", true) ||
matchOption(option, "hideGenerics", true) ||
matchOption(option, "horizontal", true) ||
matchOption(option, "all") ||
matchOption(option, "attributes", true) ||
matchOption(option, "enumconstants", true) ||
matchOption(option, "operations", true) ||
matchOption(option, "enumerations", true) ||
matchOption(option, "constructors", true) ||
matchOption(option, "visibility", true) ||
matchOption(option, "types", true) ||
matchOption(option, "autosize", true) ||
matchOption(option, "commentname", true) ||
matchOption(option, "nodefontabstractitalic", true) ||
matchOption(option, "postfixpackage", true) ||
matchOption(option, "noguillemot", true) ||
matchOption(option, "views", true) ||
matchOption(option, "inferrel", true) ||
matchOption(option, "useimports", true) ||
matchOption(option, "collapsible", true) ||
matchOption(option, "inferdep", true) ||
matchOption(option, "inferdepinpackage", true) ||
matchOption(option, "hideprivateinner", true) ||
matchOption(option, "compact", true))
return 1;
else if(matchOption(option, "nodefillcolor") ||
matchOption(option, "nodefontcolor") ||
matchOption(option, "nodefontsize") ||
matchOption(option, "nodefontname") ||
matchOption(option, "nodefontclasssize") ||
matchOption(option, "nodefontclassname") ||
matchOption(option, "nodefonttagsize") ||
matchOption(option, "nodefonttagname") ||
matchOption(option, "nodefontpackagesize") ||
matchOption(option, "nodefontpackagename") ||
matchOption(option, "edgefontcolor") ||
matchOption(option, "edgecolor") ||
matchOption(option, "edgefontsize") ||
matchOption(option, "edgefontname") ||
matchOption(option, "shape") ||
matchOption(option, "output") ||
matchOption(option, "outputencoding") ||
matchOption(option, "bgcolor") ||
matchOption(option, "hide") ||
matchOption(option, "include") ||
matchOption(option, "apidocroot") ||
matchOption(option, "apidocmap") ||
matchOption(option, "d") ||
matchOption(option, "view") ||
matchOption(option, "inferreltype") ||
matchOption(option, "inferdepvis") ||
matchOption(option, "collpackages") ||
matchOption(option, "nodesep") ||
matchOption(option, "ranksep") ||
matchOption(option, "dotexecutable") ||
matchOption(option, "link"))
return 2;
else if(matchOption(option, "contextPattern") ||
matchOption(option, "linkoffline"))
return 3;
else
return 0;
}
|
[
"public",
"static",
"int",
"optionLength",
"(",
"String",
"option",
")",
"{",
"if",
"(",
"matchOption",
"(",
"option",
",",
"\"qualify\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"qualifyGenerics\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"hideGenerics\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"horizontal\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"all\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"attributes\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"enumconstants\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"operations\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"enumerations\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"constructors\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"visibility\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"types\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"autosize\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"commentname\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontabstractitalic\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"postfixpackage\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"noguillemot\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"views\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"inferrel\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"useimports\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"collapsible\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"inferdep\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"inferdepinpackage\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"hideprivateinner\"",
",",
"true",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"compact\"",
",",
"true",
")",
")",
"return",
"1",
";",
"else",
"if",
"(",
"matchOption",
"(",
"option",
",",
"\"nodefillcolor\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontcolor\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontsize\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontname\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontclasssize\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontclassname\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefonttagsize\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefonttagname\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontpackagesize\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodefontpackagename\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"edgefontcolor\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"edgecolor\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"edgefontsize\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"edgefontname\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"shape\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"output\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"outputencoding\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"bgcolor\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"hide\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"include\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"apidocroot\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"apidocmap\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"d\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"view\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"inferreltype\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"inferdepvis\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"collpackages\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"nodesep\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"ranksep\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"dotexecutable\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"link\"",
")",
")",
"return",
"2",
";",
"else",
"if",
"(",
"matchOption",
"(",
"option",
",",
"\"contextPattern\"",
")",
"||",
"matchOption",
"(",
"option",
",",
"\"linkoffline\"",
")",
")",
"return",
"3",
";",
"else",
"return",
"0",
";",
"}"
] |
Return the number of arguments associated with the specified option.
The return value includes the actual option.
Will return 0 if the option is not supported.
|
[
"Return",
"the",
"number",
"of",
"arguments",
"associated",
"with",
"the",
"specified",
"option",
".",
"The",
"return",
"value",
"includes",
"the",
"actual",
"option",
".",
"Will",
"return",
"0",
"if",
"the",
"option",
"is",
"not",
"supported",
"."
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L192-L257
|
157,816
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/Options.java
|
Options.addApiDocRoots
|
private void addApiDocRoots(String packageListUrl) {
BufferedReader br = null;
packageListUrl = fixApiDocRoot(packageListUrl);
try {
URL url = new URL(packageListUrl + "/package-list");
br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while((line = br.readLine()) != null) {
line = line + ".";
Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*");
apiDocMap.put(pattern, packageListUrl);
}
} catch(IOException e) {
System.err.println("Errors happened while accessing the package-list file at "
+ packageListUrl);
} finally {
if(br != null)
try {
br.close();
} catch (IOException e) {}
}
}
|
java
|
private void addApiDocRoots(String packageListUrl) {
BufferedReader br = null;
packageListUrl = fixApiDocRoot(packageListUrl);
try {
URL url = new URL(packageListUrl + "/package-list");
br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while((line = br.readLine()) != null) {
line = line + ".";
Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*");
apiDocMap.put(pattern, packageListUrl);
}
} catch(IOException e) {
System.err.println("Errors happened while accessing the package-list file at "
+ packageListUrl);
} finally {
if(br != null)
try {
br.close();
} catch (IOException e) {}
}
}
|
[
"private",
"void",
"addApiDocRoots",
"(",
"String",
"packageListUrl",
")",
"{",
"BufferedReader",
"br",
"=",
"null",
";",
"packageListUrl",
"=",
"fixApiDocRoot",
"(",
"packageListUrl",
")",
";",
"try",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"packageListUrl",
"+",
"\"/package-list\"",
")",
";",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"url",
".",
"openStream",
"(",
")",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"line",
"=",
"line",
"+",
"\".\"",
";",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"line",
".",
"replace",
"(",
"\".\"",
",",
"\"\\\\.\"",
")",
"+",
"\"[^\\\\.]*\"",
")",
";",
"apiDocMap",
".",
"put",
"(",
"pattern",
",",
"packageListUrl",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Errors happened while accessing the package-list file at \"",
"+",
"packageListUrl",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"br",
"!=",
"null",
")",
"try",
"{",
"br",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"}",
"}",
"}"
] |
Adds api doc roots from a link. The folder reffered by the link should contain a package-list
file that will be parsed in order to add api doc roots to this configuration
@param packageListUrl
|
[
"Adds",
"api",
"doc",
"roots",
"from",
"a",
"link",
".",
"The",
"folder",
"reffered",
"by",
"the",
"link",
"should",
"contain",
"a",
"package",
"-",
"list",
"file",
"that",
"will",
"be",
"parsed",
"in",
"order",
"to",
"add",
"api",
"doc",
"roots",
"to",
"this",
"configuration"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L459-L481
|
157,817
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/Options.java
|
Options.fixApiDocRoot
|
private String fixApiDocRoot(String str) {
if (str == null)
return null;
String fixed = str.trim();
if (fixed.isEmpty())
return "";
if (File.separatorChar != '/')
fixed = fixed.replace(File.separatorChar, '/');
if (!fixed.endsWith("/"))
fixed = fixed + "/";
return fixed;
}
|
java
|
private String fixApiDocRoot(String str) {
if (str == null)
return null;
String fixed = str.trim();
if (fixed.isEmpty())
return "";
if (File.separatorChar != '/')
fixed = fixed.replace(File.separatorChar, '/');
if (!fixed.endsWith("/"))
fixed = fixed + "/";
return fixed;
}
|
[
"private",
"String",
"fixApiDocRoot",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"return",
"null",
";",
"String",
"fixed",
"=",
"str",
".",
"trim",
"(",
")",
";",
"if",
"(",
"fixed",
".",
"isEmpty",
"(",
")",
")",
"return",
"\"\"",
";",
"if",
"(",
"File",
".",
"separatorChar",
"!=",
"'",
"'",
")",
"fixed",
"=",
"fixed",
".",
"replace",
"(",
"File",
".",
"separatorChar",
",",
"'",
"'",
")",
";",
"if",
"(",
"!",
"fixed",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"fixed",
"=",
"fixed",
"+",
"\"/\"",
";",
"return",
"fixed",
";",
"}"
] |
Trim and append a file separator to the string
|
[
"Trim",
"and",
"append",
"a",
"file",
"separator",
"to",
"the",
"string"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L564-L575
|
157,818
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/Options.java
|
Options.setOptions
|
public void setOptions(Doc p) {
if (p == null)
return;
for (Tag tag : p.tags("opt"))
setOption(StringUtil.tokenize(tag.text()));
}
/**
* Check if the supplied string matches an entity specified
* with the -hide parameter.
* @return true if the string matches.
*/
public boolean matchesHideExpression(String s) {
for (Pattern hidePattern : hidePatterns) {
// micro-optimization because the "all pattern" is heavily used in UmlGraphDoc
if(hidePattern == allPattern)
return true;
Matcher m = hidePattern.matcher(s);
if (strictMatching ? m.matches() : m.find())
return true;
}
return false;
}
/**
* Check if the supplied string matches an entity specified
* with the -include parameter.
* @return true if the string matches.
*/
public boolean matchesIncludeExpression(String s) {
for (Pattern includePattern : includePatterns) {
Matcher m = includePattern.matcher(s);
if (strictMatching ? m.matches() : m.find())
return true;
}
return false;
}
/**
* Check if the supplied string matches an entity specified
* with the -collpackages parameter.
* @return true if the string matches.
*/
public boolean matchesCollPackageExpression(String s) {
for (Pattern collPattern : collPackages) {
Matcher m = collPattern.matcher(s);
if (strictMatching ? m.matches() : m.find())
return true;
}
return false;
}
// ----------------------------------------------------------------
// OptionProvider methods
// ----------------------------------------------------------------
public Options getOptionsFor(ClassDoc cd) {
Options localOpt = getGlobalOptions();
localOpt.setOptions(cd);
return localOpt;
}
public Options getOptionsFor(String name) {
return getGlobalOptions();
}
public Options getGlobalOptions() {
return (Options) clone();
}
public void overrideForClass(Options opt, ClassDoc cd) {
// nothing to do
}
|
java
|
public void setOptions(Doc p) {
if (p == null)
return;
for (Tag tag : p.tags("opt"))
setOption(StringUtil.tokenize(tag.text()));
}
/**
* Check if the supplied string matches an entity specified
* with the -hide parameter.
* @return true if the string matches.
*/
public boolean matchesHideExpression(String s) {
for (Pattern hidePattern : hidePatterns) {
// micro-optimization because the "all pattern" is heavily used in UmlGraphDoc
if(hidePattern == allPattern)
return true;
Matcher m = hidePattern.matcher(s);
if (strictMatching ? m.matches() : m.find())
return true;
}
return false;
}
/**
* Check if the supplied string matches an entity specified
* with the -include parameter.
* @return true if the string matches.
*/
public boolean matchesIncludeExpression(String s) {
for (Pattern includePattern : includePatterns) {
Matcher m = includePattern.matcher(s);
if (strictMatching ? m.matches() : m.find())
return true;
}
return false;
}
/**
* Check if the supplied string matches an entity specified
* with the -collpackages parameter.
* @return true if the string matches.
*/
public boolean matchesCollPackageExpression(String s) {
for (Pattern collPattern : collPackages) {
Matcher m = collPattern.matcher(s);
if (strictMatching ? m.matches() : m.find())
return true;
}
return false;
}
// ----------------------------------------------------------------
// OptionProvider methods
// ----------------------------------------------------------------
public Options getOptionsFor(ClassDoc cd) {
Options localOpt = getGlobalOptions();
localOpt.setOptions(cd);
return localOpt;
}
public Options getOptionsFor(String name) {
return getGlobalOptions();
}
public Options getGlobalOptions() {
return (Options) clone();
}
public void overrideForClass(Options opt, ClassDoc cd) {
// nothing to do
}
|
[
"public",
"void",
"setOptions",
"(",
"Doc",
"p",
")",
"{",
"if",
"(",
"p",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Tag",
"tag",
":",
"p",
".",
"tags",
"(",
"\"opt\"",
")",
")",
"setOption",
"(",
"StringUtil",
".",
"tokenize",
"(",
"tag",
".",
"text",
"(",
")",
")",
")",
";",
"}",
"/**\n * Check if the supplied string matches an entity specified\n * with the -hide parameter.\n * @return true if the string matches.\n */",
"public",
"boolean",
"matchesHideExpression",
"(",
"String",
"s",
")",
"{",
"for",
"(",
"Pattern",
"hidePattern",
":",
"hidePatterns",
")",
"{",
"// micro-optimization because the \"all pattern\" is heavily used in UmlGraphDoc",
"if",
"(",
"hidePattern",
"==",
"allPattern",
")",
"return",
"true",
";",
"Matcher",
"m",
"=",
"hidePattern",
".",
"matcher",
"(",
"s",
")",
";",
"if",
"(",
"strictMatching",
"?",
"m",
".",
"matches",
"(",
")",
":",
"m",
".",
"find",
"(",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"/**\n * Check if the supplied string matches an entity specified\n * with the -include parameter.\n * @return true if the string matches.\n */",
"public",
"boolean",
"matchesIncludeExpression",
"",
"(",
"String",
"s",
")",
"{",
"for",
"(",
"Pattern",
"includePattern",
":",
"includePatterns",
")",
"{",
"Matcher",
"m",
"=",
"includePattern",
".",
"matcher",
"(",
"s",
")",
";",
"if",
"(",
"strictMatching",
"?",
"m",
".",
"matches",
"(",
")",
":",
"m",
".",
"find",
"(",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"/**\n * Check if the supplied string matches an entity specified\n * with the -collpackages parameter.\n * @return true if the string matches.\n */",
"public",
"boolean",
"matchesCollPackageExpression",
"",
"(",
"String",
"s",
")",
"{",
"for",
"(",
"Pattern",
"collPattern",
":",
"collPackages",
")",
"{",
"Matcher",
"m",
"=",
"collPattern",
".",
"matcher",
"(",
"s",
")",
";",
"if",
"(",
"strictMatching",
"?",
"m",
".",
"matches",
"(",
")",
":",
"m",
".",
"find",
"(",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"// ---------------------------------------------------------------- ",
"// OptionProvider methods",
"// ---------------------------------------------------------------- ",
"public",
"Options",
"getOptionsFor",
"",
"(",
"ClassDoc",
"cd",
")",
"{",
"Options",
"localOpt",
"=",
"getGlobalOptions",
"(",
")",
";",
"localOpt",
".",
"setOptions",
"(",
"cd",
")",
";",
"return",
"localOpt",
";",
"}",
"public",
"Options",
"getOptionsFor",
"",
"(",
"String",
"name",
")",
"{",
"return",
"getGlobalOptions",
"(",
")",
";",
"}",
"public",
"Options",
"getGlobalOptions",
"",
"(",
")",
"{",
"return",
"(",
"Options",
")",
"clone",
"(",
")",
";",
"}",
"public",
"void",
"overrideForClass",
"",
"(",
"Options",
"opt",
",",
"ClassDoc",
"cd",
")",
"{",
"// nothing to do",
"}"
] |
Set the options based on the tag elements of the ClassDoc parameter
|
[
"Set",
"the",
"options",
"based",
"on",
"the",
"tag",
"elements",
"of",
"the",
"ClassDoc",
"parameter"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L585-L659
|
157,819
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/RelationPattern.java
|
RelationPattern.addRelation
|
public void addRelation(RelationType relationType, RelationDirection direction) {
int idx = relationType.ordinal();
directions[idx] = directions[idx].sum(direction);
}
|
java
|
public void addRelation(RelationType relationType, RelationDirection direction) {
int idx = relationType.ordinal();
directions[idx] = directions[idx].sum(direction);
}
|
[
"public",
"void",
"addRelation",
"(",
"RelationType",
"relationType",
",",
"RelationDirection",
"direction",
")",
"{",
"int",
"idx",
"=",
"relationType",
".",
"ordinal",
"(",
")",
";",
"directions",
"[",
"idx",
"]",
"=",
"directions",
"[",
"idx",
"]",
".",
"sum",
"(",
"direction",
")",
";",
"}"
] |
Adds, eventually merging, a direction for the specified relation type
@param relationType
@param direction
|
[
"Adds",
"eventually",
"merging",
"a",
"direction",
"for",
"the",
"specified",
"relation",
"type"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/RelationPattern.java#L30-L33
|
157,820
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.qualifiedName
|
private static String qualifiedName(Options opt, String r) {
if (opt.hideGenerics)
r = removeTemplate(r);
// Fast path - nothing to do:
if (opt.showQualified && (opt.showQualifiedGenerics || r.indexOf('<') < 0))
return r;
StringBuilder buf = new StringBuilder(r.length());
qualifiedNameInner(opt, r, buf, 0, !opt.showQualified);
return buf.toString();
}
|
java
|
private static String qualifiedName(Options opt, String r) {
if (opt.hideGenerics)
r = removeTemplate(r);
// Fast path - nothing to do:
if (opt.showQualified && (opt.showQualifiedGenerics || r.indexOf('<') < 0))
return r;
StringBuilder buf = new StringBuilder(r.length());
qualifiedNameInner(opt, r, buf, 0, !opt.showQualified);
return buf.toString();
}
|
[
"private",
"static",
"String",
"qualifiedName",
"(",
"Options",
"opt",
",",
"String",
"r",
")",
"{",
"if",
"(",
"opt",
".",
"hideGenerics",
")",
"r",
"=",
"removeTemplate",
"(",
"r",
")",
";",
"// Fast path - nothing to do:",
"if",
"(",
"opt",
".",
"showQualified",
"&&",
"(",
"opt",
".",
"showQualifiedGenerics",
"||",
"r",
".",
"indexOf",
"(",
"'",
"'",
")",
"<",
"0",
")",
")",
"return",
"r",
";",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"r",
".",
"length",
"(",
")",
")",
";",
"qualifiedNameInner",
"(",
"opt",
",",
"r",
",",
"buf",
",",
"0",
",",
"!",
"opt",
".",
"showQualified",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] |
Return the class's name, possibly by stripping the leading path
|
[
"Return",
"the",
"class",
"s",
"name",
"possibly",
"by",
"stripping",
"the",
"leading",
"path"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L136-L145
|
157,821
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.visibility
|
private String visibility(Options opt, ProgramElementDoc e) {
return opt.showVisibility ? Visibility.get(e).symbol : " ";
}
|
java
|
private String visibility(Options opt, ProgramElementDoc e) {
return opt.showVisibility ? Visibility.get(e).symbol : " ";
}
|
[
"private",
"String",
"visibility",
"(",
"Options",
"opt",
",",
"ProgramElementDoc",
"e",
")",
"{",
"return",
"opt",
".",
"showVisibility",
"?",
"Visibility",
".",
"get",
"(",
"e",
")",
".",
"symbol",
":",
"\" \"",
";",
"}"
] |
Print the visibility adornment of element e prefixed by
any stereotypes
|
[
"Print",
"the",
"visibility",
"adornment",
"of",
"element",
"e",
"prefixed",
"by",
"any",
"stereotypes"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L177-L179
|
157,822
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.parameter
|
private String parameter(Options opt, Parameter p[]) {
StringBuilder par = new StringBuilder(1000);
for (int i = 0; i < p.length; i++) {
par.append(p[i].name() + typeAnnotation(opt, p[i].type()));
if (i + 1 < p.length)
par.append(", ");
}
return par.toString();
}
|
java
|
private String parameter(Options opt, Parameter p[]) {
StringBuilder par = new StringBuilder(1000);
for (int i = 0; i < p.length; i++) {
par.append(p[i].name() + typeAnnotation(opt, p[i].type()));
if (i + 1 < p.length)
par.append(", ");
}
return par.toString();
}
|
[
"private",
"String",
"parameter",
"(",
"Options",
"opt",
",",
"Parameter",
"p",
"[",
"]",
")",
"{",
"StringBuilder",
"par",
"=",
"new",
"StringBuilder",
"(",
"1000",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"p",
".",
"length",
";",
"i",
"++",
")",
"{",
"par",
".",
"append",
"(",
"p",
"[",
"i",
"]",
".",
"name",
"(",
")",
"+",
"typeAnnotation",
"(",
"opt",
",",
"p",
"[",
"i",
"]",
".",
"type",
"(",
")",
")",
")",
";",
"if",
"(",
"i",
"+",
"1",
"<",
"p",
".",
"length",
")",
"par",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"return",
"par",
".",
"toString",
"(",
")",
";",
"}"
] |
Print the method parameter p
|
[
"Print",
"the",
"method",
"parameter",
"p"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L182-L190
|
157,823
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.type
|
private String type(Options opt, Type t, boolean generics) {
return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? //
t.qualifiedTypeName() : t.typeName()) //
+ (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType()));
}
|
java
|
private String type(Options opt, Type t, boolean generics) {
return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? //
t.qualifiedTypeName() : t.typeName()) //
+ (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType()));
}
|
[
"private",
"String",
"type",
"(",
"Options",
"opt",
",",
"Type",
"t",
",",
"boolean",
"generics",
")",
"{",
"return",
"(",
"(",
"generics",
"?",
"opt",
".",
"showQualifiedGenerics",
":",
"opt",
".",
"showQualified",
")",
"?",
"//",
"t",
".",
"qualifiedTypeName",
"(",
")",
":",
"t",
".",
"typeName",
"(",
")",
")",
"//",
"+",
"(",
"opt",
".",
"hideGenerics",
"?",
"\"\"",
":",
"typeParameters",
"(",
"opt",
",",
"t",
".",
"asParameterizedType",
"(",
")",
")",
")",
";",
"}"
] |
Print a a basic type t
|
[
"Print",
"a",
"a",
"basic",
"type",
"t"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L193-L197
|
157,824
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.typeParameters
|
private String typeParameters(Options opt, ParameterizedType t) {
if (t == null)
return "";
StringBuffer tp = new StringBuffer(1000).append("<");
Type args[] = t.typeArguments();
for (int i = 0; i < args.length; i++) {
tp.append(type(opt, args[i], true));
if (i != args.length - 1)
tp.append(", ");
}
return tp.append(">").toString();
}
|
java
|
private String typeParameters(Options opt, ParameterizedType t) {
if (t == null)
return "";
StringBuffer tp = new StringBuffer(1000).append("<");
Type args[] = t.typeArguments();
for (int i = 0; i < args.length; i++) {
tp.append(type(opt, args[i], true));
if (i != args.length - 1)
tp.append(", ");
}
return tp.append(">").toString();
}
|
[
"private",
"String",
"typeParameters",
"(",
"Options",
"opt",
",",
"ParameterizedType",
"t",
")",
"{",
"if",
"(",
"t",
"==",
"null",
")",
"return",
"\"\"",
";",
"StringBuffer",
"tp",
"=",
"new",
"StringBuffer",
"(",
"1000",
")",
".",
"append",
"(",
"\"<\"",
")",
";",
"Type",
"args",
"[",
"]",
"=",
"t",
".",
"typeArguments",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"tp",
".",
"append",
"(",
"type",
"(",
"opt",
",",
"args",
"[",
"i",
"]",
",",
"true",
")",
")",
";",
"if",
"(",
"i",
"!=",
"args",
".",
"length",
"-",
"1",
")",
"tp",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"return",
"tp",
".",
"append",
"(",
"\">\"",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Print the parameters of the parameterized type t
|
[
"Print",
"the",
"parameters",
"of",
"the",
"parameterized",
"type",
"t"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L200-L211
|
157,825
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.attributes
|
private void attributes(Options opt, FieldDoc fd[]) {
for (FieldDoc f : fd) {
if (hidden(f))
continue;
stereotype(opt, f, Align.LEFT);
String att = visibility(opt, f) + f.name();
if (opt.showType)
att += typeAnnotation(opt, f.type());
tableLine(Align.LEFT, att);
tagvalue(opt, f);
}
}
|
java
|
private void attributes(Options opt, FieldDoc fd[]) {
for (FieldDoc f : fd) {
if (hidden(f))
continue;
stereotype(opt, f, Align.LEFT);
String att = visibility(opt, f) + f.name();
if (opt.showType)
att += typeAnnotation(opt, f.type());
tableLine(Align.LEFT, att);
tagvalue(opt, f);
}
}
|
[
"private",
"void",
"attributes",
"(",
"Options",
"opt",
",",
"FieldDoc",
"fd",
"[",
"]",
")",
"{",
"for",
"(",
"FieldDoc",
"f",
":",
"fd",
")",
"{",
"if",
"(",
"hidden",
"(",
"f",
")",
")",
"continue",
";",
"stereotype",
"(",
"opt",
",",
"f",
",",
"Align",
".",
"LEFT",
")",
";",
"String",
"att",
"=",
"visibility",
"(",
"opt",
",",
"f",
")",
"+",
"f",
".",
"name",
"(",
")",
";",
"if",
"(",
"opt",
".",
"showType",
")",
"att",
"+=",
"typeAnnotation",
"(",
"opt",
",",
"f",
".",
"type",
"(",
")",
")",
";",
"tableLine",
"(",
"Align",
".",
"LEFT",
",",
"att",
")",
";",
"tagvalue",
"(",
"opt",
",",
"f",
")",
";",
"}",
"}"
] |
Print the class's attributes fd
|
[
"Print",
"the",
"class",
"s",
"attributes",
"fd"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L221-L232
|
157,826
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.operations
|
private boolean operations(Options opt, ConstructorDoc m[]) {
boolean printed = false;
for (ConstructorDoc cd : m) {
if (hidden(cd))
continue;
stereotype(opt, cd, Align.LEFT);
String cs = visibility(opt, cd) + cd.name() //
+ (opt.showType ? "(" + parameter(opt, cd.parameters()) + ")" : "()");
tableLine(Align.LEFT, cs);
tagvalue(opt, cd);
printed = true;
}
return printed;
}
|
java
|
private boolean operations(Options opt, ConstructorDoc m[]) {
boolean printed = false;
for (ConstructorDoc cd : m) {
if (hidden(cd))
continue;
stereotype(opt, cd, Align.LEFT);
String cs = visibility(opt, cd) + cd.name() //
+ (opt.showType ? "(" + parameter(opt, cd.parameters()) + ")" : "()");
tableLine(Align.LEFT, cs);
tagvalue(opt, cd);
printed = true;
}
return printed;
}
|
[
"private",
"boolean",
"operations",
"(",
"Options",
"opt",
",",
"ConstructorDoc",
"m",
"[",
"]",
")",
"{",
"boolean",
"printed",
"=",
"false",
";",
"for",
"(",
"ConstructorDoc",
"cd",
":",
"m",
")",
"{",
"if",
"(",
"hidden",
"(",
"cd",
")",
")",
"continue",
";",
"stereotype",
"(",
"opt",
",",
"cd",
",",
"Align",
".",
"LEFT",
")",
";",
"String",
"cs",
"=",
"visibility",
"(",
"opt",
",",
"cd",
")",
"+",
"cd",
".",
"name",
"(",
")",
"//",
"+",
"(",
"opt",
".",
"showType",
"?",
"\"(\"",
"+",
"parameter",
"(",
"opt",
",",
"cd",
".",
"parameters",
"(",
")",
")",
"+",
"\")\"",
":",
"\"()\"",
")",
";",
"tableLine",
"(",
"Align",
".",
"LEFT",
",",
"cs",
")",
";",
"tagvalue",
"(",
"opt",
",",
"cd",
")",
";",
"printed",
"=",
"true",
";",
"}",
"return",
"printed",
";",
"}"
] |
Print the class's constructors m
|
[
"Print",
"the",
"class",
"s",
"constructors",
"m"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L241-L254
|
157,827
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.operations
|
private boolean operations(Options opt, MethodDoc m[]) {
boolean printed = false;
for (MethodDoc md : m) {
if (hidden(md))
continue;
// Filter-out static initializer method
if (md.name().equals("<clinit>") && md.isStatic() && md.isPackagePrivate())
continue;
stereotype(opt, md, Align.LEFT);
String op = visibility(opt, md) + md.name() + //
(opt.showType ? "(" + parameter(opt, md.parameters()) + ")" + typeAnnotation(opt, md.returnType())
: "()");
tableLine(Align.LEFT, (md.isAbstract() ? Font.ABSTRACT : Font.NORMAL).wrap(opt, op));
printed = true;
tagvalue(opt, md);
}
return printed;
}
|
java
|
private boolean operations(Options opt, MethodDoc m[]) {
boolean printed = false;
for (MethodDoc md : m) {
if (hidden(md))
continue;
// Filter-out static initializer method
if (md.name().equals("<clinit>") && md.isStatic() && md.isPackagePrivate())
continue;
stereotype(opt, md, Align.LEFT);
String op = visibility(opt, md) + md.name() + //
(opt.showType ? "(" + parameter(opt, md.parameters()) + ")" + typeAnnotation(opt, md.returnType())
: "()");
tableLine(Align.LEFT, (md.isAbstract() ? Font.ABSTRACT : Font.NORMAL).wrap(opt, op));
printed = true;
tagvalue(opt, md);
}
return printed;
}
|
[
"private",
"boolean",
"operations",
"(",
"Options",
"opt",
",",
"MethodDoc",
"m",
"[",
"]",
")",
"{",
"boolean",
"printed",
"=",
"false",
";",
"for",
"(",
"MethodDoc",
"md",
":",
"m",
")",
"{",
"if",
"(",
"hidden",
"(",
"md",
")",
")",
"continue",
";",
"// Filter-out static initializer method",
"if",
"(",
"md",
".",
"name",
"(",
")",
".",
"equals",
"(",
"\"<clinit>\"",
")",
"&&",
"md",
".",
"isStatic",
"(",
")",
"&&",
"md",
".",
"isPackagePrivate",
"(",
")",
")",
"continue",
";",
"stereotype",
"(",
"opt",
",",
"md",
",",
"Align",
".",
"LEFT",
")",
";",
"String",
"op",
"=",
"visibility",
"(",
"opt",
",",
"md",
")",
"+",
"md",
".",
"name",
"(",
")",
"+",
"//",
"(",
"opt",
".",
"showType",
"?",
"\"(\"",
"+",
"parameter",
"(",
"opt",
",",
"md",
".",
"parameters",
"(",
")",
")",
"+",
"\")\"",
"+",
"typeAnnotation",
"(",
"opt",
",",
"md",
".",
"returnType",
"(",
")",
")",
":",
"\"()\"",
")",
";",
"tableLine",
"(",
"Align",
".",
"LEFT",
",",
"(",
"md",
".",
"isAbstract",
"(",
")",
"?",
"Font",
".",
"ABSTRACT",
":",
"Font",
".",
"NORMAL",
")",
".",
"wrap",
"(",
"opt",
",",
"op",
")",
")",
";",
"printed",
"=",
"true",
";",
"tagvalue",
"(",
"opt",
",",
"md",
")",
";",
"}",
"return",
"printed",
";",
"}"
] |
Print the class's operations m
|
[
"Print",
"the",
"class",
"s",
"operations",
"m"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L257-L275
|
157,828
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.nodeProperties
|
private void nodeProperties(Options opt) {
Options def = opt.getGlobalOptions();
if (opt.nodeFontName != def.nodeFontName)
w.print(",fontname=\"" + opt.nodeFontName + "\"");
if (opt.nodeFontColor != def.nodeFontColor)
w.print(",fontcolor=\"" + opt.nodeFontColor + "\"");
if (opt.nodeFontSize != def.nodeFontSize)
w.print(",fontsize=" + fmt(opt.nodeFontSize));
w.print(opt.shape.style);
w.println("];");
}
|
java
|
private void nodeProperties(Options opt) {
Options def = opt.getGlobalOptions();
if (opt.nodeFontName != def.nodeFontName)
w.print(",fontname=\"" + opt.nodeFontName + "\"");
if (opt.nodeFontColor != def.nodeFontColor)
w.print(",fontcolor=\"" + opt.nodeFontColor + "\"");
if (opt.nodeFontSize != def.nodeFontSize)
w.print(",fontsize=" + fmt(opt.nodeFontSize));
w.print(opt.shape.style);
w.println("];");
}
|
[
"private",
"void",
"nodeProperties",
"(",
"Options",
"opt",
")",
"{",
"Options",
"def",
"=",
"opt",
".",
"getGlobalOptions",
"(",
")",
";",
"if",
"(",
"opt",
".",
"nodeFontName",
"!=",
"def",
".",
"nodeFontName",
")",
"w",
".",
"print",
"(",
"\",fontname=\\\"\"",
"+",
"opt",
".",
"nodeFontName",
"+",
"\"\\\"\"",
")",
";",
"if",
"(",
"opt",
".",
"nodeFontColor",
"!=",
"def",
".",
"nodeFontColor",
")",
"w",
".",
"print",
"(",
"\",fontcolor=\\\"\"",
"+",
"opt",
".",
"nodeFontColor",
"+",
"\"\\\"\"",
")",
";",
"if",
"(",
"opt",
".",
"nodeFontSize",
"!=",
"def",
".",
"nodeFontSize",
")",
"w",
".",
"print",
"(",
"\",fontsize=\"",
"+",
"fmt",
"(",
"opt",
".",
"nodeFontSize",
")",
")",
";",
"w",
".",
"print",
"(",
"opt",
".",
"shape",
".",
"style",
")",
";",
"w",
".",
"println",
"(",
"\"];\"",
")",
";",
"}"
] |
Print the common class node's properties
|
[
"Print",
"the",
"common",
"class",
"node",
"s",
"properties"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L278-L288
|
157,829
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.tagvalue
|
private void tagvalue(Options opt, Doc c) {
Tag tags[] = c.tags("tagvalue");
if (tags.length == 0)
return;
for (Tag tag : tags) {
String t[] = tokenize(tag.text());
if (t.length != 2) {
System.err.println("@tagvalue expects two fields: " + tag.text());
continue;
}
tableLine(Align.RIGHT, Font.TAG.wrap(opt, "{" + t[0] + " = " + t[1] + "}"));
}
}
|
java
|
private void tagvalue(Options opt, Doc c) {
Tag tags[] = c.tags("tagvalue");
if (tags.length == 0)
return;
for (Tag tag : tags) {
String t[] = tokenize(tag.text());
if (t.length != 2) {
System.err.println("@tagvalue expects two fields: " + tag.text());
continue;
}
tableLine(Align.RIGHT, Font.TAG.wrap(opt, "{" + t[0] + " = " + t[1] + "}"));
}
}
|
[
"private",
"void",
"tagvalue",
"(",
"Options",
"opt",
",",
"Doc",
"c",
")",
"{",
"Tag",
"tags",
"[",
"]",
"=",
"c",
".",
"tags",
"(",
"\"tagvalue\"",
")",
";",
"if",
"(",
"tags",
".",
"length",
"==",
"0",
")",
"return",
";",
"for",
"(",
"Tag",
"tag",
":",
"tags",
")",
"{",
"String",
"t",
"[",
"]",
"=",
"tokenize",
"(",
"tag",
".",
"text",
"(",
")",
")",
";",
"if",
"(",
"t",
".",
"length",
"!=",
"2",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"@tagvalue expects two fields: \"",
"+",
"tag",
".",
"text",
"(",
")",
")",
";",
"continue",
";",
"}",
"tableLine",
"(",
"Align",
".",
"RIGHT",
",",
"Font",
".",
"TAG",
".",
"wrap",
"(",
"opt",
",",
"\"{\"",
"+",
"t",
"[",
"0",
"]",
"+",
"\" = \"",
"+",
"t",
"[",
"1",
"]",
"+",
"\"}\"",
")",
")",
";",
"}",
"}"
] |
Return as a string the tagged values associated with c
@param opt the Options used to guess font names
@param c the Doc entry to look for @tagvalue
@param prevterm the termination string for the previous element
@param term the termination character for each tagged value
|
[
"Return",
"as",
"a",
"string",
"the",
"tagged",
"values",
"associated",
"with",
"c"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L297-L310
|
157,830
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.stereotype
|
private void stereotype(Options opt, Doc c, Align align) {
for (Tag tag : c.tags("stereotype")) {
String t[] = tokenize(tag.text());
if (t.length != 1) {
System.err.println("@stereotype expects one field: " + tag.text());
continue;
}
tableLine(align, guilWrap(opt, t[0]));
}
}
|
java
|
private void stereotype(Options opt, Doc c, Align align) {
for (Tag tag : c.tags("stereotype")) {
String t[] = tokenize(tag.text());
if (t.length != 1) {
System.err.println("@stereotype expects one field: " + tag.text());
continue;
}
tableLine(align, guilWrap(opt, t[0]));
}
}
|
[
"private",
"void",
"stereotype",
"(",
"Options",
"opt",
",",
"Doc",
"c",
",",
"Align",
"align",
")",
"{",
"for",
"(",
"Tag",
"tag",
":",
"c",
".",
"tags",
"(",
"\"stereotype\"",
")",
")",
"{",
"String",
"t",
"[",
"]",
"=",
"tokenize",
"(",
"tag",
".",
"text",
"(",
")",
")",
";",
"if",
"(",
"t",
".",
"length",
"!=",
"1",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"@stereotype expects one field: \"",
"+",
"tag",
".",
"text",
"(",
")",
")",
";",
"continue",
";",
"}",
"tableLine",
"(",
"align",
",",
"guilWrap",
"(",
"opt",
",",
"t",
"[",
"0",
"]",
")",
")",
";",
"}",
"}"
] |
Return as a string the stereotypes associated with c
terminated by the escape character term
|
[
"Return",
"as",
"a",
"string",
"the",
"stereotypes",
"associated",
"with",
"c",
"terminated",
"by",
"the",
"escape",
"character",
"term"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L316-L325
|
157,831
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.hidden
|
private boolean hidden(ProgramElementDoc c) {
if (c.tags("hidden").length > 0 || c.tags("view").length > 0)
return true;
Options opt = optionProvider.getOptionsFor(c instanceof ClassDoc ? (ClassDoc) c : c.containingClass());
return opt.matchesHideExpression(c.toString()) //
|| (opt.hidePrivateInner && c instanceof ClassDoc && c.isPrivate() && ((ClassDoc) c).containingClass() != null);
}
|
java
|
private boolean hidden(ProgramElementDoc c) {
if (c.tags("hidden").length > 0 || c.tags("view").length > 0)
return true;
Options opt = optionProvider.getOptionsFor(c instanceof ClassDoc ? (ClassDoc) c : c.containingClass());
return opt.matchesHideExpression(c.toString()) //
|| (opt.hidePrivateInner && c instanceof ClassDoc && c.isPrivate() && ((ClassDoc) c).containingClass() != null);
}
|
[
"private",
"boolean",
"hidden",
"(",
"ProgramElementDoc",
"c",
")",
"{",
"if",
"(",
"c",
".",
"tags",
"(",
"\"hidden\"",
")",
".",
"length",
">",
"0",
"||",
"c",
".",
"tags",
"(",
"\"view\"",
")",
".",
"length",
">",
"0",
")",
"return",
"true",
";",
"Options",
"opt",
"=",
"optionProvider",
".",
"getOptionsFor",
"(",
"c",
"instanceof",
"ClassDoc",
"?",
"(",
"ClassDoc",
")",
"c",
":",
"c",
".",
"containingClass",
"(",
")",
")",
";",
"return",
"opt",
".",
"matchesHideExpression",
"(",
"c",
".",
"toString",
"(",
")",
")",
"//",
"||",
"(",
"opt",
".",
"hidePrivateInner",
"&&",
"c",
"instanceof",
"ClassDoc",
"&&",
"c",
".",
"isPrivate",
"(",
")",
"&&",
"(",
"(",
"ClassDoc",
")",
"c",
")",
".",
"containingClass",
"(",
")",
"!=",
"null",
")",
";",
"}"
] |
Return true if c has a @hidden tag associated with it
|
[
"Return",
"true",
"if",
"c",
"has",
"a"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L328-L334
|
157,832
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.hidden
|
private boolean hidden(String className) {
className = removeTemplate(className);
ClassInfo ci = classnames.get(className);
return ci != null ? ci.hidden : optionProvider.getOptionsFor(className).matchesHideExpression(className);
}
|
java
|
private boolean hidden(String className) {
className = removeTemplate(className);
ClassInfo ci = classnames.get(className);
return ci != null ? ci.hidden : optionProvider.getOptionsFor(className).matchesHideExpression(className);
}
|
[
"private",
"boolean",
"hidden",
"(",
"String",
"className",
")",
"{",
"className",
"=",
"removeTemplate",
"(",
"className",
")",
";",
"ClassInfo",
"ci",
"=",
"classnames",
".",
"get",
"(",
"className",
")",
";",
"return",
"ci",
"!=",
"null",
"?",
"ci",
".",
"hidden",
":",
"optionProvider",
".",
"getOptionsFor",
"(",
"className",
")",
".",
"matchesHideExpression",
"(",
"className",
")",
";",
"}"
] |
Return true if the class name is associated to an hidden class or matches a hide expression
|
[
"Return",
"true",
"if",
"the",
"class",
"name",
"is",
"associated",
"to",
"an",
"hidden",
"class",
"or",
"matches",
"a",
"hide",
"expression"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L356-L360
|
157,833
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.allRelation
|
private void allRelation(Options opt, RelationType rt, ClassDoc from) {
String tagname = rt.lower;
for (Tag tag : from.tags(tagname)) {
String t[] = tokenize(tag.text()); // l-src label l-dst target
t = t.length == 1 ? new String[] { "-", "-", "-", t[0] } : t; // Shorthand
if (t.length != 4) {
System.err.println("Error in " + from + "\n" + tagname + " expects four fields (l-src label l-dst target): " + tag.text());
return;
}
ClassDoc to = from.findClass(t[3]);
if (to != null) {
if(hidden(to))
continue;
relation(opt, rt, from, to, t[0], t[1], t[2]);
} else {
if(hidden(t[3]))
continue;
relation(opt, rt, from, from.toString(), to, t[3], t[0], t[1], t[2]);
}
}
}
|
java
|
private void allRelation(Options opt, RelationType rt, ClassDoc from) {
String tagname = rt.lower;
for (Tag tag : from.tags(tagname)) {
String t[] = tokenize(tag.text()); // l-src label l-dst target
t = t.length == 1 ? new String[] { "-", "-", "-", t[0] } : t; // Shorthand
if (t.length != 4) {
System.err.println("Error in " + from + "\n" + tagname + " expects four fields (l-src label l-dst target): " + tag.text());
return;
}
ClassDoc to = from.findClass(t[3]);
if (to != null) {
if(hidden(to))
continue;
relation(opt, rt, from, to, t[0], t[1], t[2]);
} else {
if(hidden(t[3]))
continue;
relation(opt, rt, from, from.toString(), to, t[3], t[0], t[1], t[2]);
}
}
}
|
[
"private",
"void",
"allRelation",
"(",
"Options",
"opt",
",",
"RelationType",
"rt",
",",
"ClassDoc",
"from",
")",
"{",
"String",
"tagname",
"=",
"rt",
".",
"lower",
";",
"for",
"(",
"Tag",
"tag",
":",
"from",
".",
"tags",
"(",
"tagname",
")",
")",
"{",
"String",
"t",
"[",
"]",
"=",
"tokenize",
"(",
"tag",
".",
"text",
"(",
")",
")",
";",
"// l-src label l-dst target",
"t",
"=",
"t",
".",
"length",
"==",
"1",
"?",
"new",
"String",
"[",
"]",
"{",
"\"-\"",
",",
"\"-\"",
",",
"\"-\"",
",",
"t",
"[",
"0",
"]",
"}",
":",
"t",
";",
"// Shorthand",
"if",
"(",
"t",
".",
"length",
"!=",
"4",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Error in \"",
"+",
"from",
"+",
"\"\\n\"",
"+",
"tagname",
"+",
"\" expects four fields (l-src label l-dst target): \"",
"+",
"tag",
".",
"text",
"(",
")",
")",
";",
"return",
";",
"}",
"ClassDoc",
"to",
"=",
"from",
".",
"findClass",
"(",
"t",
"[",
"3",
"]",
")",
";",
"if",
"(",
"to",
"!=",
"null",
")",
"{",
"if",
"(",
"hidden",
"(",
"to",
")",
")",
"continue",
";",
"relation",
"(",
"opt",
",",
"rt",
",",
"from",
",",
"to",
",",
"t",
"[",
"0",
"]",
",",
"t",
"[",
"1",
"]",
",",
"t",
"[",
"2",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"hidden",
"(",
"t",
"[",
"3",
"]",
")",
")",
"continue",
";",
"relation",
"(",
"opt",
",",
"rt",
",",
"from",
",",
"from",
".",
"toString",
"(",
")",
",",
"to",
",",
"t",
"[",
"3",
"]",
",",
"t",
"[",
"0",
"]",
",",
"t",
"[",
"1",
"]",
",",
"t",
"[",
"2",
"]",
")",
";",
"}",
"}",
"}"
] |
Print all relations for a given's class's tag
@param tagname the tag containing the given relation
@param from the source class
@param edgetype the dot edge specification
|
[
"Print",
"all",
"relations",
"for",
"a",
"given",
"s",
"class",
"s",
"tag"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L495-L515
|
157,834
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.printRelations
|
public void printRelations(ClassDoc c) {
Options opt = optionProvider.getOptionsFor(c);
if (hidden(c) || c.name().equals("")) // avoid phantom classes, they may pop up when the source uses annotations
return;
// Print generalization (through the Java superclass)
Type s = c.superclassType();
ClassDoc sc = s != null && !s.qualifiedTypeName().equals(Object.class.getName()) ? s.asClassDoc() : null;
if (sc != null && !c.isEnum() && !hidden(sc))
relation(opt, RelationType.EXTENDS, c, sc, null, null, null);
// Print generalizations (through @extends tags)
for (Tag tag : c.tags("extends"))
if (!hidden(tag.text()))
relation(opt, RelationType.EXTENDS, c, c.findClass(tag.text()), null, null, null);
// Print realizations (Java interfaces)
for (Type iface : c.interfaceTypes()) {
ClassDoc ic = iface.asClassDoc();
if (!hidden(ic))
relation(opt, RelationType.IMPLEMENTS, c, ic, null, null, null);
}
// Print other associations
allRelation(opt, RelationType.COMPOSED, c);
allRelation(opt, RelationType.NAVCOMPOSED, c);
allRelation(opt, RelationType.HAS, c);
allRelation(opt, RelationType.NAVHAS, c);
allRelation(opt, RelationType.ASSOC, c);
allRelation(opt, RelationType.NAVASSOC, c);
allRelation(opt, RelationType.DEPEND, c);
}
|
java
|
public void printRelations(ClassDoc c) {
Options opt = optionProvider.getOptionsFor(c);
if (hidden(c) || c.name().equals("")) // avoid phantom classes, they may pop up when the source uses annotations
return;
// Print generalization (through the Java superclass)
Type s = c.superclassType();
ClassDoc sc = s != null && !s.qualifiedTypeName().equals(Object.class.getName()) ? s.asClassDoc() : null;
if (sc != null && !c.isEnum() && !hidden(sc))
relation(opt, RelationType.EXTENDS, c, sc, null, null, null);
// Print generalizations (through @extends tags)
for (Tag tag : c.tags("extends"))
if (!hidden(tag.text()))
relation(opt, RelationType.EXTENDS, c, c.findClass(tag.text()), null, null, null);
// Print realizations (Java interfaces)
for (Type iface : c.interfaceTypes()) {
ClassDoc ic = iface.asClassDoc();
if (!hidden(ic))
relation(opt, RelationType.IMPLEMENTS, c, ic, null, null, null);
}
// Print other associations
allRelation(opt, RelationType.COMPOSED, c);
allRelation(opt, RelationType.NAVCOMPOSED, c);
allRelation(opt, RelationType.HAS, c);
allRelation(opt, RelationType.NAVHAS, c);
allRelation(opt, RelationType.ASSOC, c);
allRelation(opt, RelationType.NAVASSOC, c);
allRelation(opt, RelationType.DEPEND, c);
}
|
[
"public",
"void",
"printRelations",
"(",
"ClassDoc",
"c",
")",
"{",
"Options",
"opt",
"=",
"optionProvider",
".",
"getOptionsFor",
"(",
"c",
")",
";",
"if",
"(",
"hidden",
"(",
"c",
")",
"||",
"c",
".",
"name",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"// avoid phantom classes, they may pop up when the source uses annotations",
"return",
";",
"// Print generalization (through the Java superclass)",
"Type",
"s",
"=",
"c",
".",
"superclassType",
"(",
")",
";",
"ClassDoc",
"sc",
"=",
"s",
"!=",
"null",
"&&",
"!",
"s",
".",
"qualifiedTypeName",
"(",
")",
".",
"equals",
"(",
"Object",
".",
"class",
".",
"getName",
"(",
")",
")",
"?",
"s",
".",
"asClassDoc",
"(",
")",
":",
"null",
";",
"if",
"(",
"sc",
"!=",
"null",
"&&",
"!",
"c",
".",
"isEnum",
"(",
")",
"&&",
"!",
"hidden",
"(",
"sc",
")",
")",
"relation",
"(",
"opt",
",",
"RelationType",
".",
"EXTENDS",
",",
"c",
",",
"sc",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"// Print generalizations (through @extends tags)",
"for",
"(",
"Tag",
"tag",
":",
"c",
".",
"tags",
"(",
"\"extends\"",
")",
")",
"if",
"(",
"!",
"hidden",
"(",
"tag",
".",
"text",
"(",
")",
")",
")",
"relation",
"(",
"opt",
",",
"RelationType",
".",
"EXTENDS",
",",
"c",
",",
"c",
".",
"findClass",
"(",
"tag",
".",
"text",
"(",
")",
")",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"// Print realizations (Java interfaces)",
"for",
"(",
"Type",
"iface",
":",
"c",
".",
"interfaceTypes",
"(",
")",
")",
"{",
"ClassDoc",
"ic",
"=",
"iface",
".",
"asClassDoc",
"(",
")",
";",
"if",
"(",
"!",
"hidden",
"(",
"ic",
")",
")",
"relation",
"(",
"opt",
",",
"RelationType",
".",
"IMPLEMENTS",
",",
"c",
",",
"ic",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}",
"// Print other associations",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"COMPOSED",
",",
"c",
")",
";",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"NAVCOMPOSED",
",",
"c",
")",
";",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"HAS",
",",
"c",
")",
";",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"NAVHAS",
",",
"c",
")",
";",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"ASSOC",
",",
"c",
")",
";",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"NAVASSOC",
",",
"c",
")",
";",
"allRelation",
"(",
"opt",
",",
"RelationType",
".",
"DEPEND",
",",
"c",
")",
";",
"}"
] |
Print a class's relations
|
[
"Print",
"a",
"class",
"s",
"relations"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L573-L600
|
157,835
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.printExtraClasses
|
public void printExtraClasses(RootDoc root) {
Set<String> names = new HashSet<String>(classnames.keySet());
for(String className: names) {
ClassInfo info = getClassInfo(className, true);
if (info.nodePrinted)
continue;
ClassDoc c = root.classNamed(className);
if(c != null) {
printClass(c, false);
continue;
}
// Handle missing classes:
Options opt = optionProvider.getOptionsFor(className);
if(opt.matchesHideExpression(className))
continue;
w.println(linePrefix + "// " + className);
w.print(linePrefix + info.name + "[label=");
externalTableStart(opt, className, classToUrl(className));
innerTableStart();
String qualifiedName = qualifiedName(opt, className);
int startTemplate = qualifiedName.indexOf('<');
int idx = qualifiedName.lastIndexOf('.', startTemplate < 0 ? qualifiedName.length() - 1 : startTemplate);
if(opt.postfixPackage && idx > 0 && idx < (qualifiedName.length() - 1)) {
String packageName = qualifiedName.substring(0, idx);
String cn = qualifiedName.substring(idx + 1);
tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(cn)));
tableLine(Align.CENTER, Font.PACKAGE.wrap(opt, packageName));
} else {
tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(qualifiedName)));
}
innerTableEnd();
externalTableEnd();
if (className == null || className.length() == 0)
w.print(",URL=\"" + classToUrl(className) + "\"");
nodeProperties(opt);
}
}
|
java
|
public void printExtraClasses(RootDoc root) {
Set<String> names = new HashSet<String>(classnames.keySet());
for(String className: names) {
ClassInfo info = getClassInfo(className, true);
if (info.nodePrinted)
continue;
ClassDoc c = root.classNamed(className);
if(c != null) {
printClass(c, false);
continue;
}
// Handle missing classes:
Options opt = optionProvider.getOptionsFor(className);
if(opt.matchesHideExpression(className))
continue;
w.println(linePrefix + "// " + className);
w.print(linePrefix + info.name + "[label=");
externalTableStart(opt, className, classToUrl(className));
innerTableStart();
String qualifiedName = qualifiedName(opt, className);
int startTemplate = qualifiedName.indexOf('<');
int idx = qualifiedName.lastIndexOf('.', startTemplate < 0 ? qualifiedName.length() - 1 : startTemplate);
if(opt.postfixPackage && idx > 0 && idx < (qualifiedName.length() - 1)) {
String packageName = qualifiedName.substring(0, idx);
String cn = qualifiedName.substring(idx + 1);
tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(cn)));
tableLine(Align.CENTER, Font.PACKAGE.wrap(opt, packageName));
} else {
tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(qualifiedName)));
}
innerTableEnd();
externalTableEnd();
if (className == null || className.length() == 0)
w.print(",URL=\"" + classToUrl(className) + "\"");
nodeProperties(opt);
}
}
|
[
"public",
"void",
"printExtraClasses",
"(",
"RootDoc",
"root",
")",
"{",
"Set",
"<",
"String",
">",
"names",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"classnames",
".",
"keySet",
"(",
")",
")",
";",
"for",
"(",
"String",
"className",
":",
"names",
")",
"{",
"ClassInfo",
"info",
"=",
"getClassInfo",
"(",
"className",
",",
"true",
")",
";",
"if",
"(",
"info",
".",
"nodePrinted",
")",
"continue",
";",
"ClassDoc",
"c",
"=",
"root",
".",
"classNamed",
"(",
"className",
")",
";",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"printClass",
"(",
"c",
",",
"false",
")",
";",
"continue",
";",
"}",
"// Handle missing classes:",
"Options",
"opt",
"=",
"optionProvider",
".",
"getOptionsFor",
"(",
"className",
")",
";",
"if",
"(",
"opt",
".",
"matchesHideExpression",
"(",
"className",
")",
")",
"continue",
";",
"w",
".",
"println",
"(",
"linePrefix",
"+",
"\"// \"",
"+",
"className",
")",
";",
"w",
".",
"print",
"(",
"linePrefix",
"+",
"info",
".",
"name",
"+",
"\"[label=\"",
")",
";",
"externalTableStart",
"(",
"opt",
",",
"className",
",",
"classToUrl",
"(",
"className",
")",
")",
";",
"innerTableStart",
"(",
")",
";",
"String",
"qualifiedName",
"=",
"qualifiedName",
"(",
"opt",
",",
"className",
")",
";",
"int",
"startTemplate",
"=",
"qualifiedName",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"int",
"idx",
"=",
"qualifiedName",
".",
"lastIndexOf",
"(",
"'",
"'",
",",
"startTemplate",
"<",
"0",
"?",
"qualifiedName",
".",
"length",
"(",
")",
"-",
"1",
":",
"startTemplate",
")",
";",
"if",
"(",
"opt",
".",
"postfixPackage",
"&&",
"idx",
">",
"0",
"&&",
"idx",
"<",
"(",
"qualifiedName",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
"{",
"String",
"packageName",
"=",
"qualifiedName",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"String",
"cn",
"=",
"qualifiedName",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
";",
"tableLine",
"(",
"Align",
".",
"CENTER",
",",
"Font",
".",
"CLASS",
".",
"wrap",
"(",
"opt",
",",
"escape",
"(",
"cn",
")",
")",
")",
";",
"tableLine",
"(",
"Align",
".",
"CENTER",
",",
"Font",
".",
"PACKAGE",
".",
"wrap",
"(",
"opt",
",",
"packageName",
")",
")",
";",
"}",
"else",
"{",
"tableLine",
"(",
"Align",
".",
"CENTER",
",",
"Font",
".",
"CLASS",
".",
"wrap",
"(",
"opt",
",",
"escape",
"(",
"qualifiedName",
")",
")",
")",
";",
"}",
"innerTableEnd",
"(",
")",
";",
"externalTableEnd",
"(",
")",
";",
"if",
"(",
"className",
"==",
"null",
"||",
"className",
".",
"length",
"(",
")",
"==",
"0",
")",
"w",
".",
"print",
"(",
"\",URL=\\\"\"",
"+",
"classToUrl",
"(",
"className",
")",
"+",
"\"\\\"\"",
")",
";",
"nodeProperties",
"(",
"opt",
")",
";",
"}",
"}"
] |
Print classes that were parts of relationships, but not parsed by javadoc
|
[
"Print",
"classes",
"that",
"were",
"parts",
"of",
"relationships",
"but",
"not",
"parsed",
"by",
"javadoc"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L603-L639
|
157,836
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.printInferredRelations
|
public void printInferredRelations(ClassDoc c) {
// check if the source is excluded from inference
if (hidden(c))
return;
Options opt = optionProvider.getOptionsFor(c);
for (FieldDoc field : c.fields(false)) {
if(hidden(field))
continue;
// skip statics
if(field.isStatic())
continue;
// skip primitives
FieldRelationInfo fri = getFieldRelationInfo(field);
if (fri == null)
continue;
// check if the destination is excluded from inference
if (hidden(fri.cd))
continue;
// if source and dest are not already linked, add a dependency
RelationPattern rp = getClassInfo(c, true).getRelation(fri.cd.toString());
if (rp == null) {
String destAdornment = fri.multiple ? "*" : "";
relation(opt, opt.inferRelationshipType, c, fri.cd, "", "", destAdornment);
}
}
}
|
java
|
public void printInferredRelations(ClassDoc c) {
// check if the source is excluded from inference
if (hidden(c))
return;
Options opt = optionProvider.getOptionsFor(c);
for (FieldDoc field : c.fields(false)) {
if(hidden(field))
continue;
// skip statics
if(field.isStatic())
continue;
// skip primitives
FieldRelationInfo fri = getFieldRelationInfo(field);
if (fri == null)
continue;
// check if the destination is excluded from inference
if (hidden(fri.cd))
continue;
// if source and dest are not already linked, add a dependency
RelationPattern rp = getClassInfo(c, true).getRelation(fri.cd.toString());
if (rp == null) {
String destAdornment = fri.multiple ? "*" : "";
relation(opt, opt.inferRelationshipType, c, fri.cd, "", "", destAdornment);
}
}
}
|
[
"public",
"void",
"printInferredRelations",
"(",
"ClassDoc",
"c",
")",
"{",
"// check if the source is excluded from inference",
"if",
"(",
"hidden",
"(",
"c",
")",
")",
"return",
";",
"Options",
"opt",
"=",
"optionProvider",
".",
"getOptionsFor",
"(",
"c",
")",
";",
"for",
"(",
"FieldDoc",
"field",
":",
"c",
".",
"fields",
"(",
"false",
")",
")",
"{",
"if",
"(",
"hidden",
"(",
"field",
")",
")",
"continue",
";",
"// skip statics",
"if",
"(",
"field",
".",
"isStatic",
"(",
")",
")",
"continue",
";",
"// skip primitives",
"FieldRelationInfo",
"fri",
"=",
"getFieldRelationInfo",
"(",
"field",
")",
";",
"if",
"(",
"fri",
"==",
"null",
")",
"continue",
";",
"// check if the destination is excluded from inference",
"if",
"(",
"hidden",
"(",
"fri",
".",
"cd",
")",
")",
"continue",
";",
"// if source and dest are not already linked, add a dependency",
"RelationPattern",
"rp",
"=",
"getClassInfo",
"(",
"c",
",",
"true",
")",
".",
"getRelation",
"(",
"fri",
".",
"cd",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"rp",
"==",
"null",
")",
"{",
"String",
"destAdornment",
"=",
"fri",
".",
"multiple",
"?",
"\"*\"",
":",
"\"\"",
";",
"relation",
"(",
"opt",
",",
"opt",
".",
"inferRelationshipType",
",",
"c",
",",
"fri",
".",
"cd",
",",
"\"\"",
",",
"\"\"",
",",
"destAdornment",
")",
";",
"}",
"}",
"}"
] |
Prints associations recovered from the fields of a class. An association is inferred only
if another relation between the two classes is not already in the graph.
@param classes
|
[
"Prints",
"associations",
"recovered",
"from",
"the",
"fields",
"of",
"a",
"class",
".",
"An",
"association",
"is",
"inferred",
"only",
"if",
"another",
"relation",
"between",
"the",
"two",
"classes",
"is",
"not",
"already",
"in",
"the",
"graph",
"."
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L646-L674
|
157,837
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.printInferredDependencies
|
public void printInferredDependencies(ClassDoc c) {
if (hidden(c))
return;
Options opt = optionProvider.getOptionsFor(c);
Set<Type> types = new HashSet<Type>();
// harvest method return and parameter types
for (MethodDoc method : filterByVisibility(c.methods(false), opt.inferDependencyVisibility)) {
types.add(method.returnType());
for (Parameter parameter : method.parameters()) {
types.add(parameter.type());
}
}
// and the field types
if (!opt.inferRelationships) {
for (FieldDoc field : filterByVisibility(c.fields(false), opt.inferDependencyVisibility)) {
types.add(field.type());
}
}
// see if there are some type parameters
if (c.asParameterizedType() != null) {
ParameterizedType pt = c.asParameterizedType();
types.addAll(Arrays.asList(pt.typeArguments()));
}
// see if type parameters extend something
for(TypeVariable tv: c.typeParameters()) {
if(tv.bounds().length > 0 )
types.addAll(Arrays.asList(tv.bounds()));
}
// and finally check for explicitly imported classes (this
// assumes there are no unused imports...)
if (opt.useImports)
types.addAll(Arrays.asList(importedClasses(c)));
// compute dependencies
for (Type type : types) {
// skip primitives and type variables, as well as dependencies
// on the source class
if (type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable
|| c.toString().equals(type.asClassDoc().toString()))
continue;
// check if the destination is excluded from inference
ClassDoc fc = type.asClassDoc();
if (hidden(fc))
continue;
// check if source and destination are in the same package and if we are allowed
// to infer dependencies between classes in the same package
if(!opt.inferDepInPackage && c.containingPackage().equals(fc.containingPackage()))
continue;
// if source and dest are not already linked, add a dependency
RelationPattern rp = getClassInfo(c, true).getRelation(fc.toString());
if (rp == null || rp.matchesOne(new RelationPattern(RelationDirection.OUT))) {
relation(opt, RelationType.DEPEND, c, fc, "", "", "");
}
}
}
|
java
|
public void printInferredDependencies(ClassDoc c) {
if (hidden(c))
return;
Options opt = optionProvider.getOptionsFor(c);
Set<Type> types = new HashSet<Type>();
// harvest method return and parameter types
for (MethodDoc method : filterByVisibility(c.methods(false), opt.inferDependencyVisibility)) {
types.add(method.returnType());
for (Parameter parameter : method.parameters()) {
types.add(parameter.type());
}
}
// and the field types
if (!opt.inferRelationships) {
for (FieldDoc field : filterByVisibility(c.fields(false), opt.inferDependencyVisibility)) {
types.add(field.type());
}
}
// see if there are some type parameters
if (c.asParameterizedType() != null) {
ParameterizedType pt = c.asParameterizedType();
types.addAll(Arrays.asList(pt.typeArguments()));
}
// see if type parameters extend something
for(TypeVariable tv: c.typeParameters()) {
if(tv.bounds().length > 0 )
types.addAll(Arrays.asList(tv.bounds()));
}
// and finally check for explicitly imported classes (this
// assumes there are no unused imports...)
if (opt.useImports)
types.addAll(Arrays.asList(importedClasses(c)));
// compute dependencies
for (Type type : types) {
// skip primitives and type variables, as well as dependencies
// on the source class
if (type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable
|| c.toString().equals(type.asClassDoc().toString()))
continue;
// check if the destination is excluded from inference
ClassDoc fc = type.asClassDoc();
if (hidden(fc))
continue;
// check if source and destination are in the same package and if we are allowed
// to infer dependencies between classes in the same package
if(!opt.inferDepInPackage && c.containingPackage().equals(fc.containingPackage()))
continue;
// if source and dest are not already linked, add a dependency
RelationPattern rp = getClassInfo(c, true).getRelation(fc.toString());
if (rp == null || rp.matchesOne(new RelationPattern(RelationDirection.OUT))) {
relation(opt, RelationType.DEPEND, c, fc, "", "", "");
}
}
}
|
[
"public",
"void",
"printInferredDependencies",
"(",
"ClassDoc",
"c",
")",
"{",
"if",
"(",
"hidden",
"(",
"c",
")",
")",
"return",
";",
"Options",
"opt",
"=",
"optionProvider",
".",
"getOptionsFor",
"(",
"c",
")",
";",
"Set",
"<",
"Type",
">",
"types",
"=",
"new",
"HashSet",
"<",
"Type",
">",
"(",
")",
";",
"// harvest method return and parameter types",
"for",
"(",
"MethodDoc",
"method",
":",
"filterByVisibility",
"(",
"c",
".",
"methods",
"(",
"false",
")",
",",
"opt",
".",
"inferDependencyVisibility",
")",
")",
"{",
"types",
".",
"add",
"(",
"method",
".",
"returnType",
"(",
")",
")",
";",
"for",
"(",
"Parameter",
"parameter",
":",
"method",
".",
"parameters",
"(",
")",
")",
"{",
"types",
".",
"add",
"(",
"parameter",
".",
"type",
"(",
")",
")",
";",
"}",
"}",
"// and the field types",
"if",
"(",
"!",
"opt",
".",
"inferRelationships",
")",
"{",
"for",
"(",
"FieldDoc",
"field",
":",
"filterByVisibility",
"(",
"c",
".",
"fields",
"(",
"false",
")",
",",
"opt",
".",
"inferDependencyVisibility",
")",
")",
"{",
"types",
".",
"add",
"(",
"field",
".",
"type",
"(",
")",
")",
";",
"}",
"}",
"// see if there are some type parameters",
"if",
"(",
"c",
".",
"asParameterizedType",
"(",
")",
"!=",
"null",
")",
"{",
"ParameterizedType",
"pt",
"=",
"c",
".",
"asParameterizedType",
"(",
")",
";",
"types",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"pt",
".",
"typeArguments",
"(",
")",
")",
")",
";",
"}",
"// see if type parameters extend something",
"for",
"(",
"TypeVariable",
"tv",
":",
"c",
".",
"typeParameters",
"(",
")",
")",
"{",
"if",
"(",
"tv",
".",
"bounds",
"(",
")",
".",
"length",
">",
"0",
")",
"types",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"tv",
".",
"bounds",
"(",
")",
")",
")",
";",
"}",
"// and finally check for explicitly imported classes (this",
"// assumes there are no unused imports...)",
"if",
"(",
"opt",
".",
"useImports",
")",
"types",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"importedClasses",
"(",
"c",
")",
")",
")",
";",
"// compute dependencies",
"for",
"(",
"Type",
"type",
":",
"types",
")",
"{",
"// skip primitives and type variables, as well as dependencies",
"// on the source class",
"if",
"(",
"type",
".",
"isPrimitive",
"(",
")",
"||",
"type",
"instanceof",
"WildcardType",
"||",
"type",
"instanceof",
"TypeVariable",
"||",
"c",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"type",
".",
"asClassDoc",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
"continue",
";",
"// check if the destination is excluded from inference",
"ClassDoc",
"fc",
"=",
"type",
".",
"asClassDoc",
"(",
")",
";",
"if",
"(",
"hidden",
"(",
"fc",
")",
")",
"continue",
";",
"// check if source and destination are in the same package and if we are allowed",
"// to infer dependencies between classes in the same package",
"if",
"(",
"!",
"opt",
".",
"inferDepInPackage",
"&&",
"c",
".",
"containingPackage",
"(",
")",
".",
"equals",
"(",
"fc",
".",
"containingPackage",
"(",
")",
")",
")",
"continue",
";",
"// if source and dest are not already linked, add a dependency",
"RelationPattern",
"rp",
"=",
"getClassInfo",
"(",
"c",
",",
"true",
")",
".",
"getRelation",
"(",
"fc",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"rp",
"==",
"null",
"||",
"rp",
".",
"matchesOne",
"(",
"new",
"RelationPattern",
"(",
"RelationDirection",
".",
"OUT",
")",
")",
")",
"{",
"relation",
"(",
"opt",
",",
"RelationType",
".",
"DEPEND",
",",
"c",
",",
"fc",
",",
"\"\"",
",",
"\"\"",
",",
"\"\"",
")",
";",
"}",
"}",
"}"
] |
Prints dependencies recovered from the methods of a class. A
dependency is inferred only if another relation between the two
classes is not already in the graph.
@param classes
|
[
"Prints",
"dependencies",
"recovered",
"from",
"the",
"methods",
"of",
"a",
"class",
".",
"A",
"dependency",
"is",
"inferred",
"only",
"if",
"another",
"relation",
"between",
"the",
"two",
"classes",
"is",
"not",
"already",
"in",
"the",
"graph",
"."
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L691-L751
|
157,838
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.filterByVisibility
|
private <T extends ProgramElementDoc> List<T> filterByVisibility(T[] docs, Visibility visibility) {
if (visibility == Visibility.PRIVATE)
return Arrays.asList(docs);
List<T> filtered = new ArrayList<T>();
for (T doc : docs) {
if (Visibility.get(doc).compareTo(visibility) > 0)
filtered.add(doc);
}
return filtered;
}
|
java
|
private <T extends ProgramElementDoc> List<T> filterByVisibility(T[] docs, Visibility visibility) {
if (visibility == Visibility.PRIVATE)
return Arrays.asList(docs);
List<T> filtered = new ArrayList<T>();
for (T doc : docs) {
if (Visibility.get(doc).compareTo(visibility) > 0)
filtered.add(doc);
}
return filtered;
}
|
[
"private",
"<",
"T",
"extends",
"ProgramElementDoc",
">",
"List",
"<",
"T",
">",
"filterByVisibility",
"(",
"T",
"[",
"]",
"docs",
",",
"Visibility",
"visibility",
")",
"{",
"if",
"(",
"visibility",
"==",
"Visibility",
".",
"PRIVATE",
")",
"return",
"Arrays",
".",
"asList",
"(",
"docs",
")",
";",
"List",
"<",
"T",
">",
"filtered",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"T",
"doc",
":",
"docs",
")",
"{",
"if",
"(",
"Visibility",
".",
"get",
"(",
"doc",
")",
".",
"compareTo",
"(",
"visibility",
")",
">",
"0",
")",
"filtered",
".",
"add",
"(",
"doc",
")",
";",
"}",
"return",
"filtered",
";",
"}"
] |
Returns all program element docs that have a visibility greater or
equal than the specified level
|
[
"Returns",
"all",
"program",
"element",
"docs",
"that",
"have",
"a",
"visibility",
"greater",
"or",
"equal",
"than",
"the",
"specified",
"level"
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L757-L767
|
157,839
|
dspinellis/UMLGraph
|
src/main/java/org/umlgraph/doclet/ClassGraph.java
|
ClassGraph.firstInnerTableStart
|
private void firstInnerTableStart(Options opt) {
w.print(linePrefix + linePrefix + "<tr>" + opt.shape.extraColumn() +
"<td><table border=\"0\" cellspacing=\"0\" " +
"cellpadding=\"1\">" + linePostfix);
}
|
java
|
private void firstInnerTableStart(Options opt) {
w.print(linePrefix + linePrefix + "<tr>" + opt.shape.extraColumn() +
"<td><table border=\"0\" cellspacing=\"0\" " +
"cellpadding=\"1\">" + linePostfix);
}
|
[
"private",
"void",
"firstInnerTableStart",
"(",
"Options",
"opt",
")",
"{",
"w",
".",
"print",
"(",
"linePrefix",
"+",
"linePrefix",
"+",
"\"<tr>\"",
"+",
"opt",
".",
"shape",
".",
"extraColumn",
"(",
")",
"+",
"\"<td><table border=\\\"0\\\" cellspacing=\\\"0\\\" \"",
"+",
"\"cellpadding=\\\"1\\\">\"",
"+",
"linePostfix",
")",
";",
"}"
] |
Start the first inner table of a class.
|
[
"Start",
"the",
"first",
"inner",
"table",
"of",
"a",
"class",
"."
] |
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
|
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L927-L931
|
157,840
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.extractThriftFile
|
private File extractThriftFile(String artifactId, String fileName, Set<File> thriftFiles) {
for (File thriftFile : thriftFiles) {
boolean fileFound = false;
if (fileName.equals(thriftFile.getName())) {
for (String pathComponent : thriftFile.getPath().split(File.separator)) {
if (pathComponent.equals(artifactId)) {
fileFound = true;
}
}
}
if (fileFound) {
return thriftFile;
}
}
return null;
}
|
java
|
private File extractThriftFile(String artifactId, String fileName, Set<File> thriftFiles) {
for (File thriftFile : thriftFiles) {
boolean fileFound = false;
if (fileName.equals(thriftFile.getName())) {
for (String pathComponent : thriftFile.getPath().split(File.separator)) {
if (pathComponent.equals(artifactId)) {
fileFound = true;
}
}
}
if (fileFound) {
return thriftFile;
}
}
return null;
}
|
[
"private",
"File",
"extractThriftFile",
"(",
"String",
"artifactId",
",",
"String",
"fileName",
",",
"Set",
"<",
"File",
">",
"thriftFiles",
")",
"{",
"for",
"(",
"File",
"thriftFile",
":",
"thriftFiles",
")",
"{",
"boolean",
"fileFound",
"=",
"false",
";",
"if",
"(",
"fileName",
".",
"equals",
"(",
"thriftFile",
".",
"getName",
"(",
")",
")",
")",
"{",
"for",
"(",
"String",
"pathComponent",
":",
"thriftFile",
".",
"getPath",
"(",
")",
".",
"split",
"(",
"File",
".",
"separator",
")",
")",
"{",
"if",
"(",
"pathComponent",
".",
"equals",
"(",
"artifactId",
")",
")",
"{",
"fileFound",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"fileFound",
")",
"{",
"return",
"thriftFile",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Picks out a File from `thriftFiles` corresponding to a given artifact ID
and file name. Returns null if `artifactId` and `fileName` do not map to a
thrift file path.
@parameter artifactId The artifact ID of which to look up the path
@parameter fileName the name of the thrift file for which to extract a path
@parameter thriftFiles The set of Thrift files in which to lookup the
artifact ID.
@return The path of the directory containing Thrift files for the given
artifact ID. null if artifact ID not found.
|
[
"Picks",
"out",
"a",
"File",
"from",
"thriftFiles",
"corresponding",
"to",
"a",
"given",
"artifact",
"ID",
"and",
"file",
"name",
".",
"Returns",
"null",
"if",
"artifactId",
"and",
"fileName",
"do",
"not",
"map",
"to",
"a",
"thrift",
"file",
"path",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L228-L244
|
157,841
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.execute
|
public void execute() throws MojoExecutionException, MojoFailureException {
try {
Set<File> thriftFiles = findThriftFiles();
final File outputDirectory = getOutputDirectory();
ImmutableSet<File> outputFiles = findGeneratedFilesInDirectory(getOutputDirectory());
Set<String> compileRoots = new HashSet<String>();
compileRoots.add("scrooge");
if (thriftFiles.isEmpty()) {
getLog().info("No thrift files to compile.");
} else if (checkStaleness && ((lastModified(thriftFiles) + staleMillis) < lastModified(outputFiles))) {
getLog().info("Generated thrift files up to date, skipping compile.");
attachFiles(compileRoots);
} else {
outputDirectory.mkdirs();
// Quick fix to fix issues with two mvn installs in a row (ie no clean)
cleanDirectory(outputDirectory);
getLog().info(format("compiling thrift files %s with Scrooge", thriftFiles));
synchronized(lock) {
ScroogeRunner runner = new ScroogeRunner();
Map<String, String> thriftNamespaceMap = new HashMap<String, String>();
for (ThriftNamespaceMapping mapping : thriftNamespaceMappings) {
thriftNamespaceMap.put(mapping.getFrom(), mapping.getTo());
}
// Include thrifts from resource as well.
Set<File> includes = thriftIncludes;
includes.add(getResourcesOutputDirectory());
// Include thrift root
final File thriftSourceRoot = getThriftSourceRoot();
if (thriftSourceRoot != null && thriftSourceRoot.exists()) {
includes.add(thriftSourceRoot);
}
runner.compile(
getLog(),
includeOutputDirectoryNamespace ? new File(outputDirectory, "scrooge") : outputDirectory,
thriftFiles,
includes,
thriftNamespaceMap,
language,
thriftOpts);
}
attachFiles(compileRoots);
}
} catch (IOException e) {
throw new MojoExecutionException("An IO error occurred", e);
}
}
|
java
|
public void execute() throws MojoExecutionException, MojoFailureException {
try {
Set<File> thriftFiles = findThriftFiles();
final File outputDirectory = getOutputDirectory();
ImmutableSet<File> outputFiles = findGeneratedFilesInDirectory(getOutputDirectory());
Set<String> compileRoots = new HashSet<String>();
compileRoots.add("scrooge");
if (thriftFiles.isEmpty()) {
getLog().info("No thrift files to compile.");
} else if (checkStaleness && ((lastModified(thriftFiles) + staleMillis) < lastModified(outputFiles))) {
getLog().info("Generated thrift files up to date, skipping compile.");
attachFiles(compileRoots);
} else {
outputDirectory.mkdirs();
// Quick fix to fix issues with two mvn installs in a row (ie no clean)
cleanDirectory(outputDirectory);
getLog().info(format("compiling thrift files %s with Scrooge", thriftFiles));
synchronized(lock) {
ScroogeRunner runner = new ScroogeRunner();
Map<String, String> thriftNamespaceMap = new HashMap<String, String>();
for (ThriftNamespaceMapping mapping : thriftNamespaceMappings) {
thriftNamespaceMap.put(mapping.getFrom(), mapping.getTo());
}
// Include thrifts from resource as well.
Set<File> includes = thriftIncludes;
includes.add(getResourcesOutputDirectory());
// Include thrift root
final File thriftSourceRoot = getThriftSourceRoot();
if (thriftSourceRoot != null && thriftSourceRoot.exists()) {
includes.add(thriftSourceRoot);
}
runner.compile(
getLog(),
includeOutputDirectoryNamespace ? new File(outputDirectory, "scrooge") : outputDirectory,
thriftFiles,
includes,
thriftNamespaceMap,
language,
thriftOpts);
}
attachFiles(compileRoots);
}
} catch (IOException e) {
throw new MojoExecutionException("An IO error occurred", e);
}
}
|
[
"public",
"void",
"execute",
"(",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"try",
"{",
"Set",
"<",
"File",
">",
"thriftFiles",
"=",
"findThriftFiles",
"(",
")",
";",
"final",
"File",
"outputDirectory",
"=",
"getOutputDirectory",
"(",
")",
";",
"ImmutableSet",
"<",
"File",
">",
"outputFiles",
"=",
"findGeneratedFilesInDirectory",
"(",
"getOutputDirectory",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"compileRoots",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"compileRoots",
".",
"add",
"(",
"\"scrooge\"",
")",
";",
"if",
"(",
"thriftFiles",
".",
"isEmpty",
"(",
")",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"No thrift files to compile.\"",
")",
";",
"}",
"else",
"if",
"(",
"checkStaleness",
"&&",
"(",
"(",
"lastModified",
"(",
"thriftFiles",
")",
"+",
"staleMillis",
")",
"<",
"lastModified",
"(",
"outputFiles",
")",
")",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Generated thrift files up to date, skipping compile.\"",
")",
";",
"attachFiles",
"(",
"compileRoots",
")",
";",
"}",
"else",
"{",
"outputDirectory",
".",
"mkdirs",
"(",
")",
";",
"// Quick fix to fix issues with two mvn installs in a row (ie no clean)",
"cleanDirectory",
"(",
"outputDirectory",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"format",
"(",
"\"compiling thrift files %s with Scrooge\"",
",",
"thriftFiles",
")",
")",
";",
"synchronized",
"(",
"lock",
")",
"{",
"ScroogeRunner",
"runner",
"=",
"new",
"ScroogeRunner",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"thriftNamespaceMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"ThriftNamespaceMapping",
"mapping",
":",
"thriftNamespaceMappings",
")",
"{",
"thriftNamespaceMap",
".",
"put",
"(",
"mapping",
".",
"getFrom",
"(",
")",
",",
"mapping",
".",
"getTo",
"(",
")",
")",
";",
"}",
"// Include thrifts from resource as well.",
"Set",
"<",
"File",
">",
"includes",
"=",
"thriftIncludes",
";",
"includes",
".",
"add",
"(",
"getResourcesOutputDirectory",
"(",
")",
")",
";",
"// Include thrift root",
"final",
"File",
"thriftSourceRoot",
"=",
"getThriftSourceRoot",
"(",
")",
";",
"if",
"(",
"thriftSourceRoot",
"!=",
"null",
"&&",
"thriftSourceRoot",
".",
"exists",
"(",
")",
")",
"{",
"includes",
".",
"add",
"(",
"thriftSourceRoot",
")",
";",
"}",
"runner",
".",
"compile",
"(",
"getLog",
"(",
")",
",",
"includeOutputDirectoryNamespace",
"?",
"new",
"File",
"(",
"outputDirectory",
",",
"\"scrooge\"",
")",
":",
"outputDirectory",
",",
"thriftFiles",
",",
"includes",
",",
"thriftNamespaceMap",
",",
"language",
",",
"thriftOpts",
")",
";",
"}",
"attachFiles",
"(",
"compileRoots",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"An IO error occurred\"",
",",
"e",
")",
";",
"}",
"}"
] |
Executes the mojo.
|
[
"Executes",
"the",
"mojo",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L249-L302
|
157,842
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.lastModified
|
private long lastModified(Set<File> files) {
long result = 0;
for (File file : files) {
if (file.lastModified() > result)
result = file.lastModified();
}
return result;
}
|
java
|
private long lastModified(Set<File> files) {
long result = 0;
for (File file : files) {
if (file.lastModified() > result)
result = file.lastModified();
}
return result;
}
|
[
"private",
"long",
"lastModified",
"(",
"Set",
"<",
"File",
">",
"files",
")",
"{",
"long",
"result",
"=",
"0",
";",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"if",
"(",
"file",
".",
"lastModified",
"(",
")",
">",
"result",
")",
"result",
"=",
"file",
".",
"lastModified",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Get the last modified time for a set of files.
|
[
"Get",
"the",
"last",
"modified",
"time",
"for",
"a",
"set",
"of",
"files",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L339-L346
|
157,843
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.findThriftFiles
|
private Set<File> findThriftFiles() throws IOException, MojoExecutionException {
final File thriftSourceRoot = getThriftSourceRoot();
Set<File> thriftFiles = new HashSet<File>();
if (thriftSourceRoot != null && thriftSourceRoot.exists()) {
thriftFiles.addAll(findThriftFilesInDirectory(thriftSourceRoot));
}
getLog().info("finding thrift files in dependencies");
extractFilesFromDependencies(findThriftDependencies(), getResourcesOutputDirectory());
if (buildExtractedThrift && getResourcesOutputDirectory().exists()) {
thriftFiles.addAll(findThriftFilesInDirectory(getResourcesOutputDirectory()));
}
getLog().info("finding thrift files in referenced (reactor) projects");
thriftFiles.addAll(getReferencedThriftFiles());
return thriftFiles;
}
|
java
|
private Set<File> findThriftFiles() throws IOException, MojoExecutionException {
final File thriftSourceRoot = getThriftSourceRoot();
Set<File> thriftFiles = new HashSet<File>();
if (thriftSourceRoot != null && thriftSourceRoot.exists()) {
thriftFiles.addAll(findThriftFilesInDirectory(thriftSourceRoot));
}
getLog().info("finding thrift files in dependencies");
extractFilesFromDependencies(findThriftDependencies(), getResourcesOutputDirectory());
if (buildExtractedThrift && getResourcesOutputDirectory().exists()) {
thriftFiles.addAll(findThriftFilesInDirectory(getResourcesOutputDirectory()));
}
getLog().info("finding thrift files in referenced (reactor) projects");
thriftFiles.addAll(getReferencedThriftFiles());
return thriftFiles;
}
|
[
"private",
"Set",
"<",
"File",
">",
"findThriftFiles",
"(",
")",
"throws",
"IOException",
",",
"MojoExecutionException",
"{",
"final",
"File",
"thriftSourceRoot",
"=",
"getThriftSourceRoot",
"(",
")",
";",
"Set",
"<",
"File",
">",
"thriftFiles",
"=",
"new",
"HashSet",
"<",
"File",
">",
"(",
")",
";",
"if",
"(",
"thriftSourceRoot",
"!=",
"null",
"&&",
"thriftSourceRoot",
".",
"exists",
"(",
")",
")",
"{",
"thriftFiles",
".",
"addAll",
"(",
"findThriftFilesInDirectory",
"(",
"thriftSourceRoot",
")",
")",
";",
"}",
"getLog",
"(",
")",
".",
"info",
"(",
"\"finding thrift files in dependencies\"",
")",
";",
"extractFilesFromDependencies",
"(",
"findThriftDependencies",
"(",
")",
",",
"getResourcesOutputDirectory",
"(",
")",
")",
";",
"if",
"(",
"buildExtractedThrift",
"&&",
"getResourcesOutputDirectory",
"(",
")",
".",
"exists",
"(",
")",
")",
"{",
"thriftFiles",
".",
"addAll",
"(",
"findThriftFilesInDirectory",
"(",
"getResourcesOutputDirectory",
"(",
")",
")",
")",
";",
"}",
"getLog",
"(",
")",
".",
"info",
"(",
"\"finding thrift files in referenced (reactor) projects\"",
")",
";",
"thriftFiles",
".",
"addAll",
"(",
"getReferencedThriftFiles",
"(",
")",
")",
";",
"return",
"thriftFiles",
";",
"}"
] |
build a complete set of local files, files from referenced projects, and dependencies.
|
[
"build",
"a",
"complete",
"set",
"of",
"local",
"files",
"files",
"from",
"referenced",
"projects",
"and",
"dependencies",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L351-L365
|
157,844
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.findThriftDependencies
|
private Set<Artifact> findThriftDependencies() throws IOException, MojoExecutionException {
Set<Artifact> thriftDependencies = new HashSet<Artifact>();
Set<Artifact> deps = new HashSet<Artifact>();
deps.addAll(project.getArtifacts());
deps.addAll(project.getDependencyArtifacts());
Map<String, Artifact> depsMap = new HashMap<String, Artifact>();
for (Artifact dep : deps) {
depsMap.put(dep.getId(), dep);
}
for (Artifact artifact : deps) {
// This artifact has an idl classifier.
if (isIdlCalssifier(artifact, classifier)) {
thriftDependencies.add(artifact);
} else {
if (isDepOfIdlArtifact(artifact, depsMap)) {
// Fetch idl artifact for dependency of an idl artifact.
try {
Artifact idlArtifact = MavenScroogeCompilerUtil.getIdlArtifact(
artifact,
artifactFactory,
artifactResolver,
localRepository,
remoteArtifactRepositories,
classifier);
thriftDependencies.add(idlArtifact);
} catch (MojoExecutionException e) {
/* Do nothing as this artifact is not an idl artifact
binary jars may have dependency on thrift lib etc.
*/
getLog().debug("Could not fetch idl jar for " + artifact);
}
}
}
}
return thriftDependencies;
}
|
java
|
private Set<Artifact> findThriftDependencies() throws IOException, MojoExecutionException {
Set<Artifact> thriftDependencies = new HashSet<Artifact>();
Set<Artifact> deps = new HashSet<Artifact>();
deps.addAll(project.getArtifacts());
deps.addAll(project.getDependencyArtifacts());
Map<String, Artifact> depsMap = new HashMap<String, Artifact>();
for (Artifact dep : deps) {
depsMap.put(dep.getId(), dep);
}
for (Artifact artifact : deps) {
// This artifact has an idl classifier.
if (isIdlCalssifier(artifact, classifier)) {
thriftDependencies.add(artifact);
} else {
if (isDepOfIdlArtifact(artifact, depsMap)) {
// Fetch idl artifact for dependency of an idl artifact.
try {
Artifact idlArtifact = MavenScroogeCompilerUtil.getIdlArtifact(
artifact,
artifactFactory,
artifactResolver,
localRepository,
remoteArtifactRepositories,
classifier);
thriftDependencies.add(idlArtifact);
} catch (MojoExecutionException e) {
/* Do nothing as this artifact is not an idl artifact
binary jars may have dependency on thrift lib etc.
*/
getLog().debug("Could not fetch idl jar for " + artifact);
}
}
}
}
return thriftDependencies;
}
|
[
"private",
"Set",
"<",
"Artifact",
">",
"findThriftDependencies",
"(",
")",
"throws",
"IOException",
",",
"MojoExecutionException",
"{",
"Set",
"<",
"Artifact",
">",
"thriftDependencies",
"=",
"new",
"HashSet",
"<",
"Artifact",
">",
"(",
")",
";",
"Set",
"<",
"Artifact",
">",
"deps",
"=",
"new",
"HashSet",
"<",
"Artifact",
">",
"(",
")",
";",
"deps",
".",
"addAll",
"(",
"project",
".",
"getArtifacts",
"(",
")",
")",
";",
"deps",
".",
"addAll",
"(",
"project",
".",
"getDependencyArtifacts",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Artifact",
">",
"depsMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Artifact",
">",
"(",
")",
";",
"for",
"(",
"Artifact",
"dep",
":",
"deps",
")",
"{",
"depsMap",
".",
"put",
"(",
"dep",
".",
"getId",
"(",
")",
",",
"dep",
")",
";",
"}",
"for",
"(",
"Artifact",
"artifact",
":",
"deps",
")",
"{",
"// This artifact has an idl classifier.",
"if",
"(",
"isIdlCalssifier",
"(",
"artifact",
",",
"classifier",
")",
")",
"{",
"thriftDependencies",
".",
"add",
"(",
"artifact",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isDepOfIdlArtifact",
"(",
"artifact",
",",
"depsMap",
")",
")",
"{",
"// Fetch idl artifact for dependency of an idl artifact.",
"try",
"{",
"Artifact",
"idlArtifact",
"=",
"MavenScroogeCompilerUtil",
".",
"getIdlArtifact",
"(",
"artifact",
",",
"artifactFactory",
",",
"artifactResolver",
",",
"localRepository",
",",
"remoteArtifactRepositories",
",",
"classifier",
")",
";",
"thriftDependencies",
".",
"add",
"(",
"idlArtifact",
")",
";",
"}",
"catch",
"(",
"MojoExecutionException",
"e",
")",
"{",
"/* Do nothing as this artifact is not an idl artifact\n binary jars may have dependency on thrift lib etc.\n */",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Could not fetch idl jar for \"",
"+",
"artifact",
")",
";",
"}",
"}",
"}",
"}",
"return",
"thriftDependencies",
";",
"}"
] |
Iterate through dependencies
|
[
"Iterate",
"through",
"dependencies"
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L370-L408
|
157,845
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.getRecursiveThriftFiles
|
protected List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory) throws IOException {
return getRecursiveThriftFiles(project, outputDirectory, new ArrayList<File>());
}
|
java
|
protected List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory) throws IOException {
return getRecursiveThriftFiles(project, outputDirectory, new ArrayList<File>());
}
|
[
"protected",
"List",
"<",
"File",
">",
"getRecursiveThriftFiles",
"(",
"MavenProject",
"project",
",",
"String",
"outputDirectory",
")",
"throws",
"IOException",
"{",
"return",
"getRecursiveThriftFiles",
"(",
"project",
",",
"outputDirectory",
",",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
")",
";",
"}"
] |
Walk project references recursively, building up a list of thrift files they provide, starting
with an empty file list.
|
[
"Walk",
"project",
"references",
"recursively",
"building",
"up",
"a",
"list",
"of",
"thrift",
"files",
"they",
"provide",
"starting",
"with",
"an",
"empty",
"file",
"list",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L488-L490
|
157,846
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.getRecursiveThriftFiles
|
List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory, List<File> files) throws IOException {
HashFunction hashFun = Hashing.md5();
File dir = new File(new File(project.getFile().getParent(), "target"), outputDirectory);
if (dir.exists()) {
URI baseDir = getFileURI(dir);
for (File f : findThriftFilesInDirectory(dir)) {
URI fileURI = getFileURI(f);
String relPath = baseDir.relativize(fileURI).getPath();
File destFolder = getResourcesOutputDirectory();
destFolder.mkdirs();
File destFile = new File(destFolder, relPath);
if (!destFile.exists() || (destFile.isFile() && !Files.hash(f, hashFun).equals(Files.hash(destFile, hashFun)))) {
getLog().info(format("copying %s to %s", f.getCanonicalPath(), destFile.getCanonicalPath()));
copyFile(f, destFile);
}
files.add(destFile);
}
}
Map<String, MavenProject> refs = project.getProjectReferences();
for (String name : refs.keySet()) {
getRecursiveThriftFiles(refs.get(name), outputDirectory, files);
}
return files;
}
|
java
|
List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory, List<File> files) throws IOException {
HashFunction hashFun = Hashing.md5();
File dir = new File(new File(project.getFile().getParent(), "target"), outputDirectory);
if (dir.exists()) {
URI baseDir = getFileURI(dir);
for (File f : findThriftFilesInDirectory(dir)) {
URI fileURI = getFileURI(f);
String relPath = baseDir.relativize(fileURI).getPath();
File destFolder = getResourcesOutputDirectory();
destFolder.mkdirs();
File destFile = new File(destFolder, relPath);
if (!destFile.exists() || (destFile.isFile() && !Files.hash(f, hashFun).equals(Files.hash(destFile, hashFun)))) {
getLog().info(format("copying %s to %s", f.getCanonicalPath(), destFile.getCanonicalPath()));
copyFile(f, destFile);
}
files.add(destFile);
}
}
Map<String, MavenProject> refs = project.getProjectReferences();
for (String name : refs.keySet()) {
getRecursiveThriftFiles(refs.get(name), outputDirectory, files);
}
return files;
}
|
[
"List",
"<",
"File",
">",
"getRecursiveThriftFiles",
"(",
"MavenProject",
"project",
",",
"String",
"outputDirectory",
",",
"List",
"<",
"File",
">",
"files",
")",
"throws",
"IOException",
"{",
"HashFunction",
"hashFun",
"=",
"Hashing",
".",
"md5",
"(",
")",
";",
"File",
"dir",
"=",
"new",
"File",
"(",
"new",
"File",
"(",
"project",
".",
"getFile",
"(",
")",
".",
"getParent",
"(",
")",
",",
"\"target\"",
")",
",",
"outputDirectory",
")",
";",
"if",
"(",
"dir",
".",
"exists",
"(",
")",
")",
"{",
"URI",
"baseDir",
"=",
"getFileURI",
"(",
"dir",
")",
";",
"for",
"(",
"File",
"f",
":",
"findThriftFilesInDirectory",
"(",
"dir",
")",
")",
"{",
"URI",
"fileURI",
"=",
"getFileURI",
"(",
"f",
")",
";",
"String",
"relPath",
"=",
"baseDir",
".",
"relativize",
"(",
"fileURI",
")",
".",
"getPath",
"(",
")",
";",
"File",
"destFolder",
"=",
"getResourcesOutputDirectory",
"(",
")",
";",
"destFolder",
".",
"mkdirs",
"(",
")",
";",
"File",
"destFile",
"=",
"new",
"File",
"(",
"destFolder",
",",
"relPath",
")",
";",
"if",
"(",
"!",
"destFile",
".",
"exists",
"(",
")",
"||",
"(",
"destFile",
".",
"isFile",
"(",
")",
"&&",
"!",
"Files",
".",
"hash",
"(",
"f",
",",
"hashFun",
")",
".",
"equals",
"(",
"Files",
".",
"hash",
"(",
"destFile",
",",
"hashFun",
")",
")",
")",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"format",
"(",
"\"copying %s to %s\"",
",",
"f",
".",
"getCanonicalPath",
"(",
")",
",",
"destFile",
".",
"getCanonicalPath",
"(",
")",
")",
")",
";",
"copyFile",
"(",
"f",
",",
"destFile",
")",
";",
"}",
"files",
".",
"add",
"(",
"destFile",
")",
";",
"}",
"}",
"Map",
"<",
"String",
",",
"MavenProject",
">",
"refs",
"=",
"project",
".",
"getProjectReferences",
"(",
")",
";",
"for",
"(",
"String",
"name",
":",
"refs",
".",
"keySet",
"(",
")",
")",
"{",
"getRecursiveThriftFiles",
"(",
"refs",
".",
"get",
"(",
"name",
")",
",",
"outputDirectory",
",",
"files",
")",
";",
"}",
"return",
"files",
";",
"}"
] |
Walk project references recursively, adding thrift files to the provided list.
|
[
"Walk",
"project",
"references",
"recursively",
"adding",
"thrift",
"files",
"to",
"the",
"provided",
"list",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L495-L518
|
157,847
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
|
AbstractMavenScroogeMojo.isDepOfIdlArtifact
|
private boolean isDepOfIdlArtifact(Artifact artifact, Map<String, Artifact> depsMap) {
List<String> depTrail = artifact.getDependencyTrail();
// depTrail can be null sometimes, which seems like a maven bug
if (depTrail != null) {
for (String name : depTrail) {
Artifact dep = depsMap.get(name);
if (dep != null && isIdlCalssifier(dep, classifier)) {
return true;
}
}
}
return false;
}
|
java
|
private boolean isDepOfIdlArtifact(Artifact artifact, Map<String, Artifact> depsMap) {
List<String> depTrail = artifact.getDependencyTrail();
// depTrail can be null sometimes, which seems like a maven bug
if (depTrail != null) {
for (String name : depTrail) {
Artifact dep = depsMap.get(name);
if (dep != null && isIdlCalssifier(dep, classifier)) {
return true;
}
}
}
return false;
}
|
[
"private",
"boolean",
"isDepOfIdlArtifact",
"(",
"Artifact",
"artifact",
",",
"Map",
"<",
"String",
",",
"Artifact",
">",
"depsMap",
")",
"{",
"List",
"<",
"String",
">",
"depTrail",
"=",
"artifact",
".",
"getDependencyTrail",
"(",
")",
";",
"// depTrail can be null sometimes, which seems like a maven bug",
"if",
"(",
"depTrail",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"name",
":",
"depTrail",
")",
"{",
"Artifact",
"dep",
"=",
"depsMap",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"dep",
"!=",
"null",
"&&",
"isIdlCalssifier",
"(",
"dep",
",",
"classifier",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if the artifact is dependency of an dependent idl artifact
@returns true if the artifact was a dependency of idl artifact
|
[
"Checks",
"if",
"the",
"artifact",
"is",
"dependency",
"of",
"an",
"dependent",
"idl",
"artifact"
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L539-L551
|
157,848
|
twitter/scrooge
|
scrooge-maven-plugin/src/main/java/com/twitter/MavenScroogeCompilerUtil.java
|
MavenScroogeCompilerUtil.getIdlArtifact
|
public static Artifact getIdlArtifact(Artifact artifact, ArtifactFactory artifactFactory,
ArtifactResolver artifactResolver,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepos,
String classifier)
throws MojoExecutionException {
Artifact idlArtifact = artifactFactory.createArtifactWithClassifier(
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
"jar",
classifier);
try {
artifactResolver.resolve(idlArtifact, remoteRepos, localRepository);
return idlArtifact;
} catch (final ArtifactResolutionException e) {
throw new MojoExecutionException(
"Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e);
} catch (final ArtifactNotFoundException e) {
throw new MojoExecutionException(
"Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e);
}
}
|
java
|
public static Artifact getIdlArtifact(Artifact artifact, ArtifactFactory artifactFactory,
ArtifactResolver artifactResolver,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepos,
String classifier)
throws MojoExecutionException {
Artifact idlArtifact = artifactFactory.createArtifactWithClassifier(
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
"jar",
classifier);
try {
artifactResolver.resolve(idlArtifact, remoteRepos, localRepository);
return idlArtifact;
} catch (final ArtifactResolutionException e) {
throw new MojoExecutionException(
"Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e);
} catch (final ArtifactNotFoundException e) {
throw new MojoExecutionException(
"Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e);
}
}
|
[
"public",
"static",
"Artifact",
"getIdlArtifact",
"(",
"Artifact",
"artifact",
",",
"ArtifactFactory",
"artifactFactory",
",",
"ArtifactResolver",
"artifactResolver",
",",
"ArtifactRepository",
"localRepository",
",",
"List",
"<",
"ArtifactRepository",
">",
"remoteRepos",
",",
"String",
"classifier",
")",
"throws",
"MojoExecutionException",
"{",
"Artifact",
"idlArtifact",
"=",
"artifactFactory",
".",
"createArtifactWithClassifier",
"(",
"artifact",
".",
"getGroupId",
"(",
")",
",",
"artifact",
".",
"getArtifactId",
"(",
")",
",",
"artifact",
".",
"getVersion",
"(",
")",
",",
"\"jar\"",
",",
"classifier",
")",
";",
"try",
"{",
"artifactResolver",
".",
"resolve",
"(",
"idlArtifact",
",",
"remoteRepos",
",",
"localRepository",
")",
";",
"return",
"idlArtifact",
";",
"}",
"catch",
"(",
"final",
"ArtifactResolutionException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Failed to resolve one or more idl artifacts:\\n\\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"final",
"ArtifactNotFoundException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Failed to resolve one or more idl artifacts:\\n\\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Resolves an idl jar for the artifact.
@return Returns idl artifact
@throws MojoExecutionException is idl jar is not present for the artifact.
|
[
"Resolves",
"an",
"idl",
"jar",
"for",
"the",
"artifact",
"."
] |
2aec9b19a610e12be9609cd97925d0b1284d48bc
|
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/MavenScroogeCompilerUtil.java#L20-L42
|
157,849
|
lift/framework
|
core/common/src/main/java/net/liftweb/common/Func.java
|
Func.lift
|
public static<Z> Function0<Z> lift(Func0<Z> f) {
return bridge.lift(f);
}
|
java
|
public static<Z> Function0<Z> lift(Func0<Z> f) {
return bridge.lift(f);
}
|
[
"public",
"static",
"<",
"Z",
">",
"Function0",
"<",
"Z",
">",
"lift",
"(",
"Func0",
"<",
"Z",
">",
"f",
")",
"{",
"return",
"bridge",
".",
"lift",
"(",
"f",
")",
";",
"}"
] |
Lift a Java Func0 to a Scala Function0
@param f the function to lift
@returns the Scala function
|
[
"Lift",
"a",
"Java",
"Func0",
"to",
"a",
"Scala",
"Function0"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L37-L39
|
157,850
|
lift/framework
|
core/common/src/main/java/net/liftweb/common/Func.java
|
Func.lift
|
public static<A, Z> Function1<A, Z> lift(Func1<A, Z> f) {
return bridge.lift(f);
}
|
java
|
public static<A, Z> Function1<A, Z> lift(Func1<A, Z> f) {
return bridge.lift(f);
}
|
[
"public",
"static",
"<",
"A",
",",
"Z",
">",
"Function1",
"<",
"A",
",",
"Z",
">",
"lift",
"(",
"Func1",
"<",
"A",
",",
"Z",
">",
"f",
")",
"{",
"return",
"bridge",
".",
"lift",
"(",
"f",
")",
";",
"}"
] |
Lift a Java Func1 to a Scala Function1
@param f the function to lift
@returns the Scala function
|
[
"Lift",
"a",
"Java",
"Func1",
"to",
"a",
"Scala",
"Function1"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L48-L50
|
157,851
|
lift/framework
|
core/common/src/main/java/net/liftweb/common/Func.java
|
Func.lift
|
public static<A, B, Z> Function2<A, B, Z> lift(Func2<A, B, Z> f) {
return bridge.lift(f);
}
|
java
|
public static<A, B, Z> Function2<A, B, Z> lift(Func2<A, B, Z> f) {
return bridge.lift(f);
}
|
[
"public",
"static",
"<",
"A",
",",
"B",
",",
"Z",
">",
"Function2",
"<",
"A",
",",
"B",
",",
"Z",
">",
"lift",
"(",
"Func2",
"<",
"A",
",",
"B",
",",
"Z",
">",
"f",
")",
"{",
"return",
"bridge",
".",
"lift",
"(",
"f",
")",
";",
"}"
] |
Lift a Java Func2 to a Scala Function2
@param f the function to lift
@returns the Scala function
|
[
"Lift",
"a",
"Java",
"Func2",
"to",
"a",
"Scala",
"Function2"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L59-L61
|
157,852
|
lift/framework
|
core/common/src/main/java/net/liftweb/common/Func.java
|
Func.lift
|
public static<A, B, C, Z> Function3<A, B, C, Z> lift(Func3<A, B, C, Z> f) {
return bridge.lift(f);
}
|
java
|
public static<A, B, C, Z> Function3<A, B, C, Z> lift(Func3<A, B, C, Z> f) {
return bridge.lift(f);
}
|
[
"public",
"static",
"<",
"A",
",",
"B",
",",
"C",
",",
"Z",
">",
"Function3",
"<",
"A",
",",
"B",
",",
"C",
",",
"Z",
">",
"lift",
"(",
"Func3",
"<",
"A",
",",
"B",
",",
"C",
",",
"Z",
">",
"f",
")",
"{",
"return",
"bridge",
".",
"lift",
"(",
"f",
")",
";",
"}"
] |
Lift a Java Func3 to a Scala Function3
@param f the function to lift
@returns the Scala function
|
[
"Lift",
"a",
"Java",
"Func3",
"to",
"a",
"Scala",
"Function3"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L70-L72
|
157,853
|
lift/framework
|
core/common/src/main/java/net/liftweb/common/Func.java
|
Func.lift
|
public static<A, B, C, D, Z> Function4<A, B, C, D, Z> lift(Func4<A, B, C, D, Z> f) {
return bridge.lift(f);
}
|
java
|
public static<A, B, C, D, Z> Function4<A, B, C, D, Z> lift(Func4<A, B, C, D, Z> f) {
return bridge.lift(f);
}
|
[
"public",
"static",
"<",
"A",
",",
"B",
",",
"C",
",",
"D",
",",
"Z",
">",
"Function4",
"<",
"A",
",",
"B",
",",
"C",
",",
"D",
",",
"Z",
">",
"lift",
"(",
"Func4",
"<",
"A",
",",
"B",
",",
"C",
",",
"D",
",",
"Z",
">",
"f",
")",
"{",
"return",
"bridge",
".",
"lift",
"(",
"f",
")",
";",
"}"
] |
Lift a Java Func4 to a Scala Function4
@param f the function to lift
@returns the Scala function
|
[
"Lift",
"a",
"Java",
"Func4",
"to",
"a",
"Scala",
"Function4"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L81-L83
|
157,854
|
lift/framework
|
core/common/src/main/java/net/liftweb/common/Func.java
|
Func.lift
|
public static<Z> Function0<Z> lift(Callable<Z> f) {
return bridge.lift(f);
}
|
java
|
public static<Z> Function0<Z> lift(Callable<Z> f) {
return bridge.lift(f);
}
|
[
"public",
"static",
"<",
"Z",
">",
"Function0",
"<",
"Z",
">",
"lift",
"(",
"Callable",
"<",
"Z",
">",
"f",
")",
"{",
"return",
"bridge",
".",
"lift",
"(",
"f",
")",
";",
"}"
] |
Lift a Java Callable to a Scala Function0
@param f the function to lift
@returns the Scala function
|
[
"Lift",
"a",
"Java",
"Callable",
"to",
"a",
"Scala",
"Function0"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L92-L94
|
157,855
|
lift/framework
|
core/util/src/main/java/net/liftweb/util/Css.java
|
Css.sel
|
public static CssSel sel(String selector, String value) {
return j.sel(selector, value);
}
|
java
|
public static CssSel sel(String selector, String value) {
return j.sel(selector, value);
}
|
[
"public",
"static",
"CssSel",
"sel",
"(",
"String",
"selector",
",",
"String",
"value",
")",
"{",
"return",
"j",
".",
"sel",
"(",
"selector",
",",
"value",
")",
";",
"}"
] |
Create a Css Selector Transform
|
[
"Create",
"a",
"Css",
"Selector",
"Transform"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/util/src/main/java/net/liftweb/util/Css.java#L31-L33
|
157,856
|
lift/framework
|
core/util/src/main/java/net/liftweb/util/VendorJ.java
|
VendorJ.vendor
|
public static<T> Vendor<T> vendor(Func0<T> f) {
return j.vendor(f);
}
|
java
|
public static<T> Vendor<T> vendor(Func0<T> f) {
return j.vendor(f);
}
|
[
"public",
"static",
"<",
"T",
">",
"Vendor",
"<",
"T",
">",
"vendor",
"(",
"Func0",
"<",
"T",
">",
"f",
")",
"{",
"return",
"j",
".",
"vendor",
"(",
"f",
")",
";",
"}"
] |
Create a Vendor from a Func0
|
[
"Create",
"a",
"Vendor",
"from",
"a",
"Func0"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/util/src/main/java/net/liftweb/util/VendorJ.java#L31-L33
|
157,857
|
lift/framework
|
core/util/src/main/java/net/liftweb/util/VendorJ.java
|
VendorJ.vendor
|
public static<T> Vendor<T> vendor(Callable<T> f) {
return j.vendor(f);
}
|
java
|
public static<T> Vendor<T> vendor(Callable<T> f) {
return j.vendor(f);
}
|
[
"public",
"static",
"<",
"T",
">",
"Vendor",
"<",
"T",
">",
"vendor",
"(",
"Callable",
"<",
"T",
">",
"f",
")",
"{",
"return",
"j",
".",
"vendor",
"(",
"f",
")",
";",
"}"
] |
Create a Vendor from a Callable
|
[
"Create",
"a",
"Vendor",
"from",
"a",
"Callable"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/util/src/main/java/net/liftweb/util/VendorJ.java#L38-L40
|
157,858
|
lift/framework
|
web/webkit/src/main/java/net/liftweb/http/VarsJ.java
|
VarsJ.vendSessionVar
|
public static<T> SessionVar<T> vendSessionVar(T defValue) {
return (new VarsJBridge()).vendSessionVar(defValue, new Exception());
}
|
java
|
public static<T> SessionVar<T> vendSessionVar(T defValue) {
return (new VarsJBridge()).vendSessionVar(defValue, new Exception());
}
|
[
"public",
"static",
"<",
"T",
">",
"SessionVar",
"<",
"T",
">",
"vendSessionVar",
"(",
"T",
"defValue",
")",
"{",
"return",
"(",
"new",
"VarsJBridge",
"(",
")",
")",
".",
"vendSessionVar",
"(",
"defValue",
",",
"new",
"Exception",
"(",
")",
")",
";",
"}"
] |
Vend a SessionVar with the default value
|
[
"Vend",
"a",
"SessionVar",
"with",
"the",
"default",
"value"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/web/webkit/src/main/java/net/liftweb/http/VarsJ.java#L33-L35
|
157,859
|
lift/framework
|
web/webkit/src/main/java/net/liftweb/http/VarsJ.java
|
VarsJ.vendSessionVar
|
public static<T> SessionVar<T> vendSessionVar(Callable<T> defFunc) {
return (new VarsJBridge()).vendSessionVar(defFunc, new Exception());
}
|
java
|
public static<T> SessionVar<T> vendSessionVar(Callable<T> defFunc) {
return (new VarsJBridge()).vendSessionVar(defFunc, new Exception());
}
|
[
"public",
"static",
"<",
"T",
">",
"SessionVar",
"<",
"T",
">",
"vendSessionVar",
"(",
"Callable",
"<",
"T",
">",
"defFunc",
")",
"{",
"return",
"(",
"new",
"VarsJBridge",
"(",
")",
")",
".",
"vendSessionVar",
"(",
"defFunc",
",",
"new",
"Exception",
"(",
")",
")",
";",
"}"
] |
Vend a SessionVar with the function to create the default value
|
[
"Vend",
"a",
"SessionVar",
"with",
"the",
"function",
"to",
"create",
"the",
"default",
"value"
] |
975aa115e0a8e2450dd4905a17ebd19830ae97b2
|
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/web/webkit/src/main/java/net/liftweb/http/VarsJ.java#L40-L42
|
157,860
|
vlingo/vlingo-actors
|
src/main/java/io/vlingo/actors/Router.java
|
Router.dispatchCommand
|
protected <T1> void dispatchCommand(final BiConsumer<P, T1> action, final T1 routable1) {
routingFor(routable1)
.routees()
.forEach(routee -> routee.receiveCommand(action, routable1));
}
|
java
|
protected <T1> void dispatchCommand(final BiConsumer<P, T1> action, final T1 routable1) {
routingFor(routable1)
.routees()
.forEach(routee -> routee.receiveCommand(action, routable1));
}
|
[
"protected",
"<",
"T1",
">",
"void",
"dispatchCommand",
"(",
"final",
"BiConsumer",
"<",
"P",
",",
"T1",
">",
"action",
",",
"final",
"T1",
"routable1",
")",
"{",
"routingFor",
"(",
"routable1",
")",
".",
"routees",
"(",
")",
".",
"forEach",
"(",
"routee",
"->",
"routee",
".",
"receiveCommand",
"(",
"action",
",",
"routable1",
")",
")",
";",
"}"
] |
DISPATCHING - COMMANDS
|
[
"DISPATCHING",
"-",
"COMMANDS"
] |
c7d046fd139c0490cf0fd2588d7dc2f792f13493
|
https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/Router.java#L97-L101
|
157,861
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreSyncMongoIterableImpl.java
|
CoreSyncMongoIterableImpl.first
|
@Nullable
public ResultT first() {
final CoreRemoteMongoCursor<ResultT> cursor = iterator();
if (!cursor.hasNext()) {
return null;
}
return cursor.next();
}
|
java
|
@Nullable
public ResultT first() {
final CoreRemoteMongoCursor<ResultT> cursor = iterator();
if (!cursor.hasNext()) {
return null;
}
return cursor.next();
}
|
[
"@",
"Nullable",
"public",
"ResultT",
"first",
"(",
")",
"{",
"final",
"CoreRemoteMongoCursor",
"<",
"ResultT",
">",
"cursor",
"=",
"iterator",
"(",
")",
";",
"if",
"(",
"!",
"cursor",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"cursor",
".",
"next",
"(",
")",
";",
"}"
] |
Helper to return the first item in the iterator or null.
@return T the first item or null.
|
[
"Helper",
"to",
"return",
"the",
"first",
"item",
"in",
"the",
"iterator",
"or",
"null",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreSyncMongoIterableImpl.java#L76-L83
|
157,862
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreSyncMongoIterableImpl.java
|
CoreSyncMongoIterableImpl.map
|
public <U> CoreRemoteMongoIterable<U> map(final Function<ResultT, U> mapper) {
return new CoreRemoteMappingIterable<>(this, mapper);
}
|
java
|
public <U> CoreRemoteMongoIterable<U> map(final Function<ResultT, U> mapper) {
return new CoreRemoteMappingIterable<>(this, mapper);
}
|
[
"public",
"<",
"U",
">",
"CoreRemoteMongoIterable",
"<",
"U",
">",
"map",
"(",
"final",
"Function",
"<",
"ResultT",
",",
"U",
">",
"mapper",
")",
"{",
"return",
"new",
"CoreRemoteMappingIterable",
"<>",
"(",
"this",
",",
"mapper",
")",
";",
"}"
] |
Maps this iterable from the source document type to the target document type.
@param mapper a function that maps from the source to the target document type
@param <U> the target document type
@return an iterable which maps T to U
|
[
"Maps",
"this",
"iterable",
"from",
"the",
"source",
"document",
"type",
"to",
"the",
"target",
"document",
"type",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreSyncMongoIterableImpl.java#L92-L94
|
157,863
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreSyncMongoIterableImpl.java
|
CoreSyncMongoIterableImpl.into
|
public <A extends Collection<? super ResultT>> A into(final A target) {
forEach(new Block<ResultT>() {
@Override
public void apply(@Nonnull final ResultT t) {
target.add(t);
}
});
return target;
}
|
java
|
public <A extends Collection<? super ResultT>> A into(final A target) {
forEach(new Block<ResultT>() {
@Override
public void apply(@Nonnull final ResultT t) {
target.add(t);
}
});
return target;
}
|
[
"public",
"<",
"A",
"extends",
"Collection",
"<",
"?",
"super",
"ResultT",
">",
">",
"A",
"into",
"(",
"final",
"A",
"target",
")",
"{",
"forEach",
"(",
"new",
"Block",
"<",
"ResultT",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"apply",
"(",
"@",
"Nonnull",
"final",
"ResultT",
"t",
")",
"{",
"target",
".",
"add",
"(",
"t",
")",
";",
"}",
"}",
")",
";",
"return",
"target",
";",
"}"
] |
Iterates over all the documents, adding each to the given target.
@param target the collection to insert into
@param <A> the collection type
@return the target
|
[
"Iterates",
"over",
"all",
"the",
"documents",
"adding",
"each",
"to",
"the",
"given",
"target",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreSyncMongoIterableImpl.java#L116-L124
|
157,864
|
mongodb/stitch-android-sdk
|
android/services/aws/src/main/java/com/mongodb/stitch/android/services/aws/internal/AwsServiceClientImpl.java
|
AwsServiceClientImpl.withCodecRegistry
|
public AwsServiceClient withCodecRegistry(@Nonnull final CodecRegistry codecRegistry) {
return new AwsServiceClientImpl(proxy.withCodecRegistry(codecRegistry), dispatcher);
}
|
java
|
public AwsServiceClient withCodecRegistry(@Nonnull final CodecRegistry codecRegistry) {
return new AwsServiceClientImpl(proxy.withCodecRegistry(codecRegistry), dispatcher);
}
|
[
"public",
"AwsServiceClient",
"withCodecRegistry",
"(",
"@",
"Nonnull",
"final",
"CodecRegistry",
"codecRegistry",
")",
"{",
"return",
"new",
"AwsServiceClientImpl",
"(",
"proxy",
".",
"withCodecRegistry",
"(",
"codecRegistry",
")",
",",
"dispatcher",
")",
";",
"}"
] |
Create a new AwsServiceClient instance with a different codec registry.
@param codecRegistry the new {@link CodecRegistry} for the client.
@return a new AwsServiceClient instance with the different codec registry
|
[
"Create",
"a",
"new",
"AwsServiceClient",
"instance",
"with",
"a",
"different",
"codec",
"registry",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/services/aws/src/main/java/com/mongodb/stitch/android/services/aws/internal/AwsServiceClientImpl.java#L243-L245
|
157,865
|
mongodb/stitch-android-sdk
|
core/sdk/src/main/java/com/mongodb/stitch/core/internal/CoreStitchAppClient.java
|
CoreStitchAppClient.callFunction
|
public void callFunction(
final String name,
final List<?> args,
final @Nullable Long requestTimeout) {
this.functionService.callFunction(name, args, requestTimeout);
}
|
java
|
public void callFunction(
final String name,
final List<?> args,
final @Nullable Long requestTimeout) {
this.functionService.callFunction(name, args, requestTimeout);
}
|
[
"public",
"void",
"callFunction",
"(",
"final",
"String",
"name",
",",
"final",
"List",
"<",
"?",
">",
"args",
",",
"final",
"@",
"Nullable",
"Long",
"requestTimeout",
")",
"{",
"this",
".",
"functionService",
".",
"callFunction",
"(",
"name",
",",
"args",
",",
"requestTimeout",
")",
";",
"}"
] |
Calls the specified Stitch function.
@param name the name of the Stitch function to call.
@param args the arguments to pass to the Stitch function.
@param requestTimeout the number of milliseconds the client should wait for a response from the
server before failing with an error.
|
[
"Calls",
"the",
"specified",
"Stitch",
"function",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/CoreStitchAppClient.java#L57-L62
|
157,866
|
mongodb/stitch-android-sdk
|
core/sdk/src/main/java/com/mongodb/stitch/core/internal/CoreStitchAppClient.java
|
CoreStitchAppClient.callFunction
|
public <T> T callFunction(
final String name,
final List<?> args,
final @Nullable Long requestTimeout,
final Class<T> resultClass,
final CodecRegistry codecRegistry
) {
return this.functionService
.withCodecRegistry(codecRegistry)
.callFunction(name, args, requestTimeout, resultClass);
}
|
java
|
public <T> T callFunction(
final String name,
final List<?> args,
final @Nullable Long requestTimeout,
final Class<T> resultClass,
final CodecRegistry codecRegistry
) {
return this.functionService
.withCodecRegistry(codecRegistry)
.callFunction(name, args, requestTimeout, resultClass);
}
|
[
"public",
"<",
"T",
">",
"T",
"callFunction",
"(",
"final",
"String",
"name",
",",
"final",
"List",
"<",
"?",
">",
"args",
",",
"final",
"@",
"Nullable",
"Long",
"requestTimeout",
",",
"final",
"Class",
"<",
"T",
">",
"resultClass",
",",
"final",
"CodecRegistry",
"codecRegistry",
")",
"{",
"return",
"this",
".",
"functionService",
".",
"withCodecRegistry",
"(",
"codecRegistry",
")",
".",
"callFunction",
"(",
"name",
",",
"args",
",",
"requestTimeout",
",",
"resultClass",
")",
";",
"}"
] |
Calls the specified Stitch function, and decodes the response into an instance of the specified
type. The response will be decoded using the codec registry given.
@param name the name of the Stitch function to call.
@param args the arguments to pass to the Stitch function.
@param requestTimeout the number of milliseconds the client should wait for a response from the
server before failing with an error.
@param resultClass the class that the Stitch response should be decoded as.
@param <T> the type into which the Stitch response will be decoded.
@param codecRegistry the codec registry that will be used to encode/decode the function call.
@return the decoded value.
|
[
"Calls",
"the",
"specified",
"Stitch",
"function",
"and",
"decodes",
"the",
"response",
"into",
"an",
"instance",
"of",
"the",
"specified",
"type",
".",
"The",
"response",
"will",
"be",
"decoded",
"using",
"the",
"codec",
"registry",
"given",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/CoreStitchAppClient.java#L120-L130
|
157,867
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java
|
InstanceChangeStreamListenerImpl.start
|
public void start() {
instanceLock.writeLock().lock();
try {
for (final Map.Entry<MongoNamespace, NamespaceChangeStreamListener> streamerEntry :
nsStreamers.entrySet()) {
streamerEntry.getValue().start();
}
} finally {
instanceLock.writeLock().unlock();
}
}
|
java
|
public void start() {
instanceLock.writeLock().lock();
try {
for (final Map.Entry<MongoNamespace, NamespaceChangeStreamListener> streamerEntry :
nsStreamers.entrySet()) {
streamerEntry.getValue().start();
}
} finally {
instanceLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"start",
"(",
")",
"{",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"MongoNamespace",
",",
"NamespaceChangeStreamListener",
">",
"streamerEntry",
":",
"nsStreamers",
".",
"entrySet",
"(",
")",
")",
"{",
"streamerEntry",
".",
"getValue",
"(",
")",
".",
"start",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Starts all streams.
|
[
"Starts",
"all",
"streams",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java#L79-L89
|
157,868
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java
|
InstanceChangeStreamListenerImpl.stop
|
public void stop() {
instanceLock.writeLock().lock();
try {
for (final NamespaceChangeStreamListener streamer : nsStreamers.values()) {
streamer.stop();
}
} finally {
instanceLock.writeLock().unlock();
}
}
|
java
|
public void stop() {
instanceLock.writeLock().lock();
try {
for (final NamespaceChangeStreamListener streamer : nsStreamers.values()) {
streamer.stop();
}
} finally {
instanceLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"stop",
"(",
")",
"{",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"for",
"(",
"final",
"NamespaceChangeStreamListener",
"streamer",
":",
"nsStreamers",
".",
"values",
"(",
")",
")",
"{",
"streamer",
".",
"stop",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Stops all streams.
|
[
"Stops",
"all",
"streams",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java#L105-L114
|
157,869
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java
|
InstanceChangeStreamListenerImpl.addNamespace
|
public void addNamespace(final MongoNamespace namespace) {
this.instanceLock.writeLock().lock();
try {
if (this.nsStreamers.containsKey(namespace)) {
return;
}
final NamespaceChangeStreamListener streamer =
new NamespaceChangeStreamListener(
namespace,
instanceConfig.getNamespaceConfig(namespace),
service,
networkMonitor,
authMonitor,
getLockForNamespace(namespace));
this.nsStreamers.put(namespace, streamer);
} finally {
this.instanceLock.writeLock().unlock();
}
}
|
java
|
public void addNamespace(final MongoNamespace namespace) {
this.instanceLock.writeLock().lock();
try {
if (this.nsStreamers.containsKey(namespace)) {
return;
}
final NamespaceChangeStreamListener streamer =
new NamespaceChangeStreamListener(
namespace,
instanceConfig.getNamespaceConfig(namespace),
service,
networkMonitor,
authMonitor,
getLockForNamespace(namespace));
this.nsStreamers.put(namespace, streamer);
} finally {
this.instanceLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"addNamespace",
"(",
"final",
"MongoNamespace",
"namespace",
")",
"{",
"this",
".",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"this",
".",
"nsStreamers",
".",
"containsKey",
"(",
"namespace",
")",
")",
"{",
"return",
";",
"}",
"final",
"NamespaceChangeStreamListener",
"streamer",
"=",
"new",
"NamespaceChangeStreamListener",
"(",
"namespace",
",",
"instanceConfig",
".",
"getNamespaceConfig",
"(",
"namespace",
")",
",",
"service",
",",
"networkMonitor",
",",
"authMonitor",
",",
"getLockForNamespace",
"(",
"namespace",
")",
")",
";",
"this",
".",
"nsStreamers",
".",
"put",
"(",
"namespace",
",",
"streamer",
")",
";",
"}",
"finally",
"{",
"this",
".",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Requests that the given namespace be started listening to for change events.
@param namespace the namespace to listen for change events on.
|
[
"Requests",
"that",
"the",
"given",
"namespace",
"be",
"started",
"listening",
"to",
"for",
"change",
"events",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java#L172-L190
|
157,870
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java
|
InstanceChangeStreamListenerImpl.removeNamespace
|
@Override
public void removeNamespace(final MongoNamespace namespace) {
this.instanceLock.writeLock().lock();
try {
if (!this.nsStreamers.containsKey(namespace)) {
return;
}
final NamespaceChangeStreamListener streamer = this.nsStreamers.get(namespace);
streamer.stop();
this.nsStreamers.remove(namespace);
} finally {
this.instanceLock.writeLock().unlock();
}
}
|
java
|
@Override
public void removeNamespace(final MongoNamespace namespace) {
this.instanceLock.writeLock().lock();
try {
if (!this.nsStreamers.containsKey(namespace)) {
return;
}
final NamespaceChangeStreamListener streamer = this.nsStreamers.get(namespace);
streamer.stop();
this.nsStreamers.remove(namespace);
} finally {
this.instanceLock.writeLock().unlock();
}
}
|
[
"@",
"Override",
"public",
"void",
"removeNamespace",
"(",
"final",
"MongoNamespace",
"namespace",
")",
"{",
"this",
".",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"this",
".",
"nsStreamers",
".",
"containsKey",
"(",
"namespace",
")",
")",
"{",
"return",
";",
"}",
"final",
"NamespaceChangeStreamListener",
"streamer",
"=",
"this",
".",
"nsStreamers",
".",
"get",
"(",
"namespace",
")",
";",
"streamer",
".",
"stop",
"(",
")",
";",
"this",
".",
"nsStreamers",
".",
"remove",
"(",
"namespace",
")",
";",
"}",
"finally",
"{",
"this",
".",
"instanceLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Requests that the given namespace stopped being listened to for change events.
@param namespace the namespace to stop listening for change events on.
|
[
"Requests",
"that",
"the",
"given",
"namespace",
"stopped",
"being",
"listened",
"to",
"for",
"change",
"events",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java#L197-L210
|
157,871
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java
|
InstanceChangeStreamListenerImpl.getEventsForNamespace
|
public Map<BsonValue, ChangeEvent<BsonDocument>> getEventsForNamespace(
final MongoNamespace namespace
) {
this.instanceLock.readLock().lock();
final NamespaceChangeStreamListener streamer;
try {
streamer = nsStreamers.get(namespace);
} finally {
this.instanceLock.readLock().unlock();
}
if (streamer == null) {
return new HashMap<>();
}
return streamer.getEvents();
}
|
java
|
public Map<BsonValue, ChangeEvent<BsonDocument>> getEventsForNamespace(
final MongoNamespace namespace
) {
this.instanceLock.readLock().lock();
final NamespaceChangeStreamListener streamer;
try {
streamer = nsStreamers.get(namespace);
} finally {
this.instanceLock.readLock().unlock();
}
if (streamer == null) {
return new HashMap<>();
}
return streamer.getEvents();
}
|
[
"public",
"Map",
"<",
"BsonValue",
",",
"ChangeEvent",
"<",
"BsonDocument",
">",
">",
"getEventsForNamespace",
"(",
"final",
"MongoNamespace",
"namespace",
")",
"{",
"this",
".",
"instanceLock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"final",
"NamespaceChangeStreamListener",
"streamer",
";",
"try",
"{",
"streamer",
"=",
"nsStreamers",
".",
"get",
"(",
"namespace",
")",
";",
"}",
"finally",
"{",
"this",
".",
"instanceLock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"if",
"(",
"streamer",
"==",
"null",
")",
"{",
"return",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"return",
"streamer",
".",
"getEvents",
"(",
")",
";",
"}"
] |
Returns the latest change events for a given namespace.
@param namespace the namespace to get events for.
@return the latest change events for a given namespace.
|
[
"Returns",
"the",
"latest",
"change",
"events",
"for",
"a",
"given",
"namespace",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java#L218-L232
|
157,872
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java
|
InstanceChangeStreamListenerImpl.getUnprocessedEventForDocumentId
|
public @Nullable ChangeEvent<BsonDocument> getUnprocessedEventForDocumentId(
final MongoNamespace namespace,
final BsonValue documentId
) {
this.instanceLock.readLock().lock();
final NamespaceChangeStreamListener streamer;
try {
streamer = nsStreamers.get(namespace);
} finally {
this.instanceLock.readLock().unlock();
}
if (streamer == null) {
return null;
}
return streamer.getUnprocessedEventForDocumentId(documentId);
}
|
java
|
public @Nullable ChangeEvent<BsonDocument> getUnprocessedEventForDocumentId(
final MongoNamespace namespace,
final BsonValue documentId
) {
this.instanceLock.readLock().lock();
final NamespaceChangeStreamListener streamer;
try {
streamer = nsStreamers.get(namespace);
} finally {
this.instanceLock.readLock().unlock();
}
if (streamer == null) {
return null;
}
return streamer.getUnprocessedEventForDocumentId(documentId);
}
|
[
"public",
"@",
"Nullable",
"ChangeEvent",
"<",
"BsonDocument",
">",
"getUnprocessedEventForDocumentId",
"(",
"final",
"MongoNamespace",
"namespace",
",",
"final",
"BsonValue",
"documentId",
")",
"{",
"this",
".",
"instanceLock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"final",
"NamespaceChangeStreamListener",
"streamer",
";",
"try",
"{",
"streamer",
"=",
"nsStreamers",
".",
"get",
"(",
"namespace",
")",
";",
"}",
"finally",
"{",
"this",
".",
"instanceLock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"if",
"(",
"streamer",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"streamer",
".",
"getUnprocessedEventForDocumentId",
"(",
"documentId",
")",
";",
"}"
] |
If there is an unprocessed change event for a particular document ID, fetch it from the
appropriate namespace change stream listener, and remove it. By reading the event here, we are
assuming it will be processed by the consumer.
@return the latest unprocessed change event for the given document ID and namespace, or null
if none exists.
|
[
"If",
"there",
"is",
"an",
"unprocessed",
"change",
"event",
"for",
"a",
"particular",
"document",
"ID",
"fetch",
"it",
"from",
"the",
"appropriate",
"namespace",
"change",
"stream",
"listener",
"and",
"remove",
"it",
".",
"By",
"reading",
"the",
"event",
"here",
"we",
"are",
"assuming",
"it",
"will",
"be",
"processed",
"by",
"the",
"consumer",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/InstanceChangeStreamListenerImpl.java#L258-L275
|
157,873
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreDocumentSynchronizationConfig.java
|
CoreDocumentSynchronizationConfig.setPaused
|
void setPaused(final boolean isPaused) {
docLock.writeLock().lock();
try {
docsColl.updateOne(
getDocFilter(namespace, documentId),
new BsonDocument("$set",
new BsonDocument(
ConfigCodec.Fields.IS_PAUSED,
new BsonBoolean(isPaused))));
this.isPaused = isPaused;
} catch (IllegalStateException e) {
// eat this
} finally {
docLock.writeLock().unlock();
}
}
|
java
|
void setPaused(final boolean isPaused) {
docLock.writeLock().lock();
try {
docsColl.updateOne(
getDocFilter(namespace, documentId),
new BsonDocument("$set",
new BsonDocument(
ConfigCodec.Fields.IS_PAUSED,
new BsonBoolean(isPaused))));
this.isPaused = isPaused;
} catch (IllegalStateException e) {
// eat this
} finally {
docLock.writeLock().unlock();
}
}
|
[
"void",
"setPaused",
"(",
"final",
"boolean",
"isPaused",
")",
"{",
"docLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"docsColl",
".",
"updateOne",
"(",
"getDocFilter",
"(",
"namespace",
",",
"documentId",
")",
",",
"new",
"BsonDocument",
"(",
"\"$set\"",
",",
"new",
"BsonDocument",
"(",
"ConfigCodec",
".",
"Fields",
".",
"IS_PAUSED",
",",
"new",
"BsonBoolean",
"(",
"isPaused",
")",
")",
")",
")",
";",
"this",
".",
"isPaused",
"=",
"isPaused",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"// eat this",
"}",
"finally",
"{",
"docLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
A document that is paused no longer has remote updates applied to it.
Any local updates to this document cause it to be thawed. An example of pausing a document
is when a conflict is being resolved for that document and the handler throws an exception.
@param isPaused whether or not this config is frozen
|
[
"A",
"document",
"that",
"is",
"paused",
"no",
"longer",
"has",
"remote",
"updates",
"applied",
"to",
"it",
".",
"Any",
"local",
"updates",
"to",
"this",
"document",
"cause",
"it",
"to",
"be",
"thawed",
".",
"An",
"example",
"of",
"pausing",
"a",
"document",
"is",
"when",
"a",
"conflict",
"is",
"being",
"resolved",
"for",
"that",
"document",
"and",
"the",
"handler",
"throws",
"an",
"exception",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreDocumentSynchronizationConfig.java#L160-L175
|
157,874
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreDocumentSynchronizationConfig.java
|
CoreDocumentSynchronizationConfig.setSomePendingWritesAndSave
|
public void setSomePendingWritesAndSave(
final long atTime,
final ChangeEvent<BsonDocument> changeEvent
) {
docLock.writeLock().lock();
try {
// if we were frozen
if (isPaused) {
// unfreeze the document due to the local write
setPaused(false);
// and now the unfrozen document is now stale
setStale(true);
}
this.lastUncommittedChangeEvent =
coalesceChangeEvents(this.lastUncommittedChangeEvent, changeEvent);
this.lastResolution = atTime;
docsColl.replaceOne(
getDocFilter(namespace, documentId),
this);
} finally {
docLock.writeLock().unlock();
}
}
|
java
|
public void setSomePendingWritesAndSave(
final long atTime,
final ChangeEvent<BsonDocument> changeEvent
) {
docLock.writeLock().lock();
try {
// if we were frozen
if (isPaused) {
// unfreeze the document due to the local write
setPaused(false);
// and now the unfrozen document is now stale
setStale(true);
}
this.lastUncommittedChangeEvent =
coalesceChangeEvents(this.lastUncommittedChangeEvent, changeEvent);
this.lastResolution = atTime;
docsColl.replaceOne(
getDocFilter(namespace, documentId),
this);
} finally {
docLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"setSomePendingWritesAndSave",
"(",
"final",
"long",
"atTime",
",",
"final",
"ChangeEvent",
"<",
"BsonDocument",
">",
"changeEvent",
")",
"{",
"docLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"// if we were frozen",
"if",
"(",
"isPaused",
")",
"{",
"// unfreeze the document due to the local write",
"setPaused",
"(",
"false",
")",
";",
"// and now the unfrozen document is now stale",
"setStale",
"(",
"true",
")",
";",
"}",
"this",
".",
"lastUncommittedChangeEvent",
"=",
"coalesceChangeEvents",
"(",
"this",
".",
"lastUncommittedChangeEvent",
",",
"changeEvent",
")",
";",
"this",
".",
"lastResolution",
"=",
"atTime",
";",
"docsColl",
".",
"replaceOne",
"(",
"getDocFilter",
"(",
"namespace",
",",
"documentId",
")",
",",
"this",
")",
";",
"}",
"finally",
"{",
"docLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Sets that there are some pending writes that occurred at a time for an associated
locally emitted change event. This variant maintains the last version set.
@param atTime the time at which the write occurred.
@param changeEvent the description of the write/change.
|
[
"Sets",
"that",
"there",
"are",
"some",
"pending",
"writes",
"that",
"occurred",
"at",
"a",
"time",
"for",
"an",
"associated",
"locally",
"emitted",
"change",
"event",
".",
"This",
"variant",
"maintains",
"the",
"last",
"version",
"set",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreDocumentSynchronizationConfig.java#L188-L211
|
157,875
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreDocumentSynchronizationConfig.java
|
CoreDocumentSynchronizationConfig.coalesceChangeEvents
|
private static ChangeEvent<BsonDocument> coalesceChangeEvents(
final ChangeEvent<BsonDocument> lastUncommittedChangeEvent,
final ChangeEvent<BsonDocument> newestChangeEvent
) {
if (lastUncommittedChangeEvent == null) {
return newestChangeEvent;
}
switch (lastUncommittedChangeEvent.getOperationType()) {
case INSERT:
switch (newestChangeEvent.getOperationType()) {
// Coalesce replaces/updates to inserts since we believe at some point a document did not
// exist remotely and that this replace or update should really be an insert if we are
// still in an uncommitted state.
case REPLACE:
case UPDATE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.INSERT,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
case DELETE:
switch (newestChangeEvent.getOperationType()) {
// Coalesce inserts to replaces since we believe at some point a document existed
// remotely and that this insert should really be an replace if we are still in an
// uncommitted state.
case INSERT:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.REPLACE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
case UPDATE:
switch (newestChangeEvent.getOperationType()) {
case UPDATE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.UPDATE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
lastUncommittedChangeEvent.getUpdateDescription() != null
? lastUncommittedChangeEvent
.getUpdateDescription()
.merge(newestChangeEvent.getUpdateDescription())
: newestChangeEvent.getUpdateDescription(),
newestChangeEvent.hasUncommittedWrites()
);
case REPLACE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.REPLACE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
case REPLACE:
switch (newestChangeEvent.getOperationType()) {
case UPDATE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.REPLACE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
default:
break;
}
return newestChangeEvent;
}
|
java
|
private static ChangeEvent<BsonDocument> coalesceChangeEvents(
final ChangeEvent<BsonDocument> lastUncommittedChangeEvent,
final ChangeEvent<BsonDocument> newestChangeEvent
) {
if (lastUncommittedChangeEvent == null) {
return newestChangeEvent;
}
switch (lastUncommittedChangeEvent.getOperationType()) {
case INSERT:
switch (newestChangeEvent.getOperationType()) {
// Coalesce replaces/updates to inserts since we believe at some point a document did not
// exist remotely and that this replace or update should really be an insert if we are
// still in an uncommitted state.
case REPLACE:
case UPDATE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.INSERT,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
case DELETE:
switch (newestChangeEvent.getOperationType()) {
// Coalesce inserts to replaces since we believe at some point a document existed
// remotely and that this insert should really be an replace if we are still in an
// uncommitted state.
case INSERT:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.REPLACE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
case UPDATE:
switch (newestChangeEvent.getOperationType()) {
case UPDATE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.UPDATE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
lastUncommittedChangeEvent.getUpdateDescription() != null
? lastUncommittedChangeEvent
.getUpdateDescription()
.merge(newestChangeEvent.getUpdateDescription())
: newestChangeEvent.getUpdateDescription(),
newestChangeEvent.hasUncommittedWrites()
);
case REPLACE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.REPLACE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
case REPLACE:
switch (newestChangeEvent.getOperationType()) {
case UPDATE:
return new ChangeEvent<>(
newestChangeEvent.getId(),
OperationType.REPLACE,
newestChangeEvent.getFullDocument(),
newestChangeEvent.getNamespace(),
newestChangeEvent.getDocumentKey(),
null,
newestChangeEvent.hasUncommittedWrites()
);
default:
break;
}
break;
default:
break;
}
return newestChangeEvent;
}
|
[
"private",
"static",
"ChangeEvent",
"<",
"BsonDocument",
">",
"coalesceChangeEvents",
"(",
"final",
"ChangeEvent",
"<",
"BsonDocument",
">",
"lastUncommittedChangeEvent",
",",
"final",
"ChangeEvent",
"<",
"BsonDocument",
">",
"newestChangeEvent",
")",
"{",
"if",
"(",
"lastUncommittedChangeEvent",
"==",
"null",
")",
"{",
"return",
"newestChangeEvent",
";",
"}",
"switch",
"(",
"lastUncommittedChangeEvent",
".",
"getOperationType",
"(",
")",
")",
"{",
"case",
"INSERT",
":",
"switch",
"(",
"newestChangeEvent",
".",
"getOperationType",
"(",
")",
")",
"{",
"// Coalesce replaces/updates to inserts since we believe at some point a document did not",
"// exist remotely and that this replace or update should really be an insert if we are",
"// still in an uncommitted state.",
"case",
"REPLACE",
":",
"case",
"UPDATE",
":",
"return",
"new",
"ChangeEvent",
"<>",
"(",
"newestChangeEvent",
".",
"getId",
"(",
")",
",",
"OperationType",
".",
"INSERT",
",",
"newestChangeEvent",
".",
"getFullDocument",
"(",
")",
",",
"newestChangeEvent",
".",
"getNamespace",
"(",
")",
",",
"newestChangeEvent",
".",
"getDocumentKey",
"(",
")",
",",
"null",
",",
"newestChangeEvent",
".",
"hasUncommittedWrites",
"(",
")",
")",
";",
"default",
":",
"break",
";",
"}",
"break",
";",
"case",
"DELETE",
":",
"switch",
"(",
"newestChangeEvent",
".",
"getOperationType",
"(",
")",
")",
"{",
"// Coalesce inserts to replaces since we believe at some point a document existed",
"// remotely and that this insert should really be an replace if we are still in an",
"// uncommitted state.",
"case",
"INSERT",
":",
"return",
"new",
"ChangeEvent",
"<>",
"(",
"newestChangeEvent",
".",
"getId",
"(",
")",
",",
"OperationType",
".",
"REPLACE",
",",
"newestChangeEvent",
".",
"getFullDocument",
"(",
")",
",",
"newestChangeEvent",
".",
"getNamespace",
"(",
")",
",",
"newestChangeEvent",
".",
"getDocumentKey",
"(",
")",
",",
"null",
",",
"newestChangeEvent",
".",
"hasUncommittedWrites",
"(",
")",
")",
";",
"default",
":",
"break",
";",
"}",
"break",
";",
"case",
"UPDATE",
":",
"switch",
"(",
"newestChangeEvent",
".",
"getOperationType",
"(",
")",
")",
"{",
"case",
"UPDATE",
":",
"return",
"new",
"ChangeEvent",
"<>",
"(",
"newestChangeEvent",
".",
"getId",
"(",
")",
",",
"OperationType",
".",
"UPDATE",
",",
"newestChangeEvent",
".",
"getFullDocument",
"(",
")",
",",
"newestChangeEvent",
".",
"getNamespace",
"(",
")",
",",
"newestChangeEvent",
".",
"getDocumentKey",
"(",
")",
",",
"lastUncommittedChangeEvent",
".",
"getUpdateDescription",
"(",
")",
"!=",
"null",
"?",
"lastUncommittedChangeEvent",
".",
"getUpdateDescription",
"(",
")",
".",
"merge",
"(",
"newestChangeEvent",
".",
"getUpdateDescription",
"(",
")",
")",
":",
"newestChangeEvent",
".",
"getUpdateDescription",
"(",
")",
",",
"newestChangeEvent",
".",
"hasUncommittedWrites",
"(",
")",
")",
";",
"case",
"REPLACE",
":",
"return",
"new",
"ChangeEvent",
"<>",
"(",
"newestChangeEvent",
".",
"getId",
"(",
")",
",",
"OperationType",
".",
"REPLACE",
",",
"newestChangeEvent",
".",
"getFullDocument",
"(",
")",
",",
"newestChangeEvent",
".",
"getNamespace",
"(",
")",
",",
"newestChangeEvent",
".",
"getDocumentKey",
"(",
")",
",",
"null",
",",
"newestChangeEvent",
".",
"hasUncommittedWrites",
"(",
")",
")",
";",
"default",
":",
"break",
";",
"}",
"break",
";",
"case",
"REPLACE",
":",
"switch",
"(",
"newestChangeEvent",
".",
"getOperationType",
"(",
")",
")",
"{",
"case",
"UPDATE",
":",
"return",
"new",
"ChangeEvent",
"<>",
"(",
"newestChangeEvent",
".",
"getId",
"(",
")",
",",
"OperationType",
".",
"REPLACE",
",",
"newestChangeEvent",
".",
"getFullDocument",
"(",
")",
",",
"newestChangeEvent",
".",
"getNamespace",
"(",
")",
",",
"newestChangeEvent",
".",
"getDocumentKey",
"(",
")",
",",
"null",
",",
"newestChangeEvent",
".",
"hasUncommittedWrites",
"(",
")",
")",
";",
"default",
":",
"break",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"newestChangeEvent",
";",
"}"
] |
Possibly coalesces the newest change event to match the user's original intent. For example,
an unsynchronized insert and update is still an insert.
@param lastUncommittedChangeEvent the last change event known about for a document.
@param newestChangeEvent the newest change event known about for a document.
@return the possibly coalesced change event.
|
[
"Possibly",
"coalesces",
"the",
"newest",
"change",
"event",
"to",
"match",
"the",
"user",
"s",
"original",
"intent",
".",
"For",
"example",
"an",
"unsynchronized",
"insert",
"and",
"update",
"is",
"still",
"an",
"insert",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/CoreDocumentSynchronizationConfig.java#L373-L470
|
157,876
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java
|
DocumentVersionInfo.getRemoteVersionInfo
|
static DocumentVersionInfo getRemoteVersionInfo(final BsonDocument remoteDocument) {
final BsonDocument version = getDocumentVersionDoc(remoteDocument);
return new DocumentVersionInfo(
version,
remoteDocument != null
? BsonUtils.getDocumentId(remoteDocument) : null
);
}
|
java
|
static DocumentVersionInfo getRemoteVersionInfo(final BsonDocument remoteDocument) {
final BsonDocument version = getDocumentVersionDoc(remoteDocument);
return new DocumentVersionInfo(
version,
remoteDocument != null
? BsonUtils.getDocumentId(remoteDocument) : null
);
}
|
[
"static",
"DocumentVersionInfo",
"getRemoteVersionInfo",
"(",
"final",
"BsonDocument",
"remoteDocument",
")",
"{",
"final",
"BsonDocument",
"version",
"=",
"getDocumentVersionDoc",
"(",
"remoteDocument",
")",
";",
"return",
"new",
"DocumentVersionInfo",
"(",
"version",
",",
"remoteDocument",
"!=",
"null",
"?",
"BsonUtils",
".",
"getDocumentId",
"(",
"remoteDocument",
")",
":",
"null",
")",
";",
"}"
] |
Returns the current version info for a provided remote document.
@param remoteDocument the remote BSON document from which to extract version info
@return a DocumentVersionInfo
|
[
"Returns",
"the",
"current",
"version",
"info",
"for",
"a",
"provided",
"remote",
"document",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java#L185-L192
|
157,877
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java
|
DocumentVersionInfo.getFreshVersionDocument
|
static BsonDocument getFreshVersionDocument() {
final BsonDocument versionDoc = new BsonDocument();
versionDoc.append(Fields.SYNC_PROTOCOL_VERSION_FIELD, new BsonInt32(1));
versionDoc.append(Fields.INSTANCE_ID_FIELD, new BsonString(UUID.randomUUID().toString()));
versionDoc.append(Fields.VERSION_COUNTER_FIELD, new BsonInt64(0L));
return versionDoc;
}
|
java
|
static BsonDocument getFreshVersionDocument() {
final BsonDocument versionDoc = new BsonDocument();
versionDoc.append(Fields.SYNC_PROTOCOL_VERSION_FIELD, new BsonInt32(1));
versionDoc.append(Fields.INSTANCE_ID_FIELD, new BsonString(UUID.randomUUID().toString()));
versionDoc.append(Fields.VERSION_COUNTER_FIELD, new BsonInt64(0L));
return versionDoc;
}
|
[
"static",
"BsonDocument",
"getFreshVersionDocument",
"(",
")",
"{",
"final",
"BsonDocument",
"versionDoc",
"=",
"new",
"BsonDocument",
"(",
")",
";",
"versionDoc",
".",
"append",
"(",
"Fields",
".",
"SYNC_PROTOCOL_VERSION_FIELD",
",",
"new",
"BsonInt32",
"(",
"1",
")",
")",
";",
"versionDoc",
".",
"append",
"(",
"Fields",
".",
"INSTANCE_ID_FIELD",
",",
"new",
"BsonString",
"(",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"versionDoc",
".",
"append",
"(",
"Fields",
".",
"VERSION_COUNTER_FIELD",
",",
"new",
"BsonInt64",
"(",
"0L",
")",
")",
";",
"return",
"versionDoc",
";",
"}"
] |
Returns a BSON version document representing a new version with a new instance ID, and
version counter of zero.
@return a BsonDocument representing a synchronization version
|
[
"Returns",
"a",
"BSON",
"version",
"document",
"representing",
"a",
"new",
"version",
"with",
"a",
"new",
"instance",
"ID",
"and",
"version",
"counter",
"of",
"zero",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java#L210-L218
|
157,878
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java
|
DocumentVersionInfo.getDocumentVersionDoc
|
static BsonDocument getDocumentVersionDoc(final BsonDocument document) {
if (document == null || !document.containsKey(DOCUMENT_VERSION_FIELD)) {
return null;
}
return document.getDocument(DOCUMENT_VERSION_FIELD, null);
}
|
java
|
static BsonDocument getDocumentVersionDoc(final BsonDocument document) {
if (document == null || !document.containsKey(DOCUMENT_VERSION_FIELD)) {
return null;
}
return document.getDocument(DOCUMENT_VERSION_FIELD, null);
}
|
[
"static",
"BsonDocument",
"getDocumentVersionDoc",
"(",
"final",
"BsonDocument",
"document",
")",
"{",
"if",
"(",
"document",
"==",
"null",
"||",
"!",
"document",
".",
"containsKey",
"(",
"DOCUMENT_VERSION_FIELD",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"document",
".",
"getDocument",
"(",
"DOCUMENT_VERSION_FIELD",
",",
"null",
")",
";",
"}"
] |
Returns the version document of the given document, if any; returns null otherwise.
@param document the document to get the version from.
@return the version of the given document, if any; returns null otherwise.
|
[
"Returns",
"the",
"version",
"document",
"of",
"the",
"given",
"document",
"if",
"any",
";",
"returns",
"null",
"otherwise",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java#L225-L230
|
157,879
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java
|
DocumentVersionInfo.getVersionedFilter
|
static BsonDocument getVersionedFilter(
@Nonnull final BsonValue documentId,
@Nullable final BsonValue version
) {
final BsonDocument filter = new BsonDocument("_id", documentId);
if (version == null) {
filter.put(DOCUMENT_VERSION_FIELD, new BsonDocument("$exists", BsonBoolean.FALSE));
} else {
filter.put(DOCUMENT_VERSION_FIELD, version);
}
return filter;
}
|
java
|
static BsonDocument getVersionedFilter(
@Nonnull final BsonValue documentId,
@Nullable final BsonValue version
) {
final BsonDocument filter = new BsonDocument("_id", documentId);
if (version == null) {
filter.put(DOCUMENT_VERSION_FIELD, new BsonDocument("$exists", BsonBoolean.FALSE));
} else {
filter.put(DOCUMENT_VERSION_FIELD, version);
}
return filter;
}
|
[
"static",
"BsonDocument",
"getVersionedFilter",
"(",
"@",
"Nonnull",
"final",
"BsonValue",
"documentId",
",",
"@",
"Nullable",
"final",
"BsonValue",
"version",
")",
"{",
"final",
"BsonDocument",
"filter",
"=",
"new",
"BsonDocument",
"(",
"\"_id\"",
",",
"documentId",
")",
";",
"if",
"(",
"version",
"==",
"null",
")",
"{",
"filter",
".",
"put",
"(",
"DOCUMENT_VERSION_FIELD",
",",
"new",
"BsonDocument",
"(",
"\"$exists\"",
",",
"BsonBoolean",
".",
"FALSE",
")",
")",
";",
"}",
"else",
"{",
"filter",
".",
"put",
"(",
"DOCUMENT_VERSION_FIELD",
",",
"version",
")",
";",
"}",
"return",
"filter",
";",
"}"
] |
Returns a query filter for the given document _id and version. The version is allowed to be
null. The query will match only if there is either no version on the document in the database
in question if we have no reference of the version or if the version matches the database's
version.
@param documentId the _id of the document.
@param version the expected version of the document, if any.
@return a query filter for the given document _id and version for a remote operation.
|
[
"Returns",
"a",
"query",
"filter",
"for",
"the",
"given",
"document",
"_id",
"and",
"version",
".",
"The",
"version",
"is",
"allowed",
"to",
"be",
"null",
".",
"The",
"query",
"will",
"match",
"only",
"if",
"there",
"is",
"either",
"no",
"version",
"on",
"the",
"document",
"in",
"the",
"database",
"in",
"question",
"if",
"we",
"have",
"no",
"reference",
"of",
"the",
"version",
"or",
"if",
"the",
"version",
"matches",
"the",
"database",
"s",
"version",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java#L242-L253
|
157,880
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java
|
DocumentVersionInfo.getNextVersion
|
BsonDocument getNextVersion() {
if (!this.hasVersion() || this.getVersionDoc() == null) {
return getFreshVersionDocument();
}
final BsonDocument nextVersion = BsonUtils.copyOfDocument(this.getVersionDoc());
nextVersion.put(
Fields.VERSION_COUNTER_FIELD,
new BsonInt64(this.getVersion().getVersionCounter() + 1));
return nextVersion;
}
|
java
|
BsonDocument getNextVersion() {
if (!this.hasVersion() || this.getVersionDoc() == null) {
return getFreshVersionDocument();
}
final BsonDocument nextVersion = BsonUtils.copyOfDocument(this.getVersionDoc());
nextVersion.put(
Fields.VERSION_COUNTER_FIELD,
new BsonInt64(this.getVersion().getVersionCounter() + 1));
return nextVersion;
}
|
[
"BsonDocument",
"getNextVersion",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasVersion",
"(",
")",
"||",
"this",
".",
"getVersionDoc",
"(",
")",
"==",
"null",
")",
"{",
"return",
"getFreshVersionDocument",
"(",
")",
";",
"}",
"final",
"BsonDocument",
"nextVersion",
"=",
"BsonUtils",
".",
"copyOfDocument",
"(",
"this",
".",
"getVersionDoc",
"(",
")",
")",
";",
"nextVersion",
".",
"put",
"(",
"Fields",
".",
"VERSION_COUNTER_FIELD",
",",
"new",
"BsonInt64",
"(",
"this",
".",
"getVersion",
"(",
")",
".",
"getVersionCounter",
"(",
")",
"+",
"1",
")",
")",
";",
"return",
"nextVersion",
";",
"}"
] |
Given a DocumentVersionInfo, returns a BSON document representing the next version. This means
and incremented version count for a non-empty version, or a fresh version document for an
empty version.
@return a BsonDocument representing a synchronization version
|
[
"Given",
"a",
"DocumentVersionInfo",
"returns",
"a",
"BSON",
"document",
"representing",
"the",
"next",
"version",
".",
"This",
"means",
"and",
"incremented",
"version",
"count",
"for",
"a",
"non",
"-",
"empty",
"version",
"or",
"a",
"fresh",
"version",
"document",
"for",
"an",
"empty",
"version",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java#L261-L270
|
157,881
|
mongodb/stitch-android-sdk
|
android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/RemoteMongoDatabaseImpl.java
|
RemoteMongoDatabaseImpl.getCollection
|
public RemoteMongoCollection<Document> getCollection(final String collectionName) {
return new RemoteMongoCollectionImpl<>(proxy.getCollection(collectionName), dispatcher);
}
|
java
|
public RemoteMongoCollection<Document> getCollection(final String collectionName) {
return new RemoteMongoCollectionImpl<>(proxy.getCollection(collectionName), dispatcher);
}
|
[
"public",
"RemoteMongoCollection",
"<",
"Document",
">",
"getCollection",
"(",
"final",
"String",
"collectionName",
")",
"{",
"return",
"new",
"RemoteMongoCollectionImpl",
"<>",
"(",
"proxy",
".",
"getCollection",
"(",
"collectionName",
")",
",",
"dispatcher",
")",
";",
"}"
] |
Gets a collection.
@param collectionName the name of the collection to return
@return the collection
|
[
"Gets",
"a",
"collection",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/RemoteMongoDatabaseImpl.java#L54-L56
|
157,882
|
mongodb/stitch-android-sdk
|
core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/StitchEvent.java
|
StitchEvent.fromEvent
|
static <T> StitchEvent<T> fromEvent(final Event event,
final Decoder<T> decoder) {
return new StitchEvent<>(event.getEventName(), event.getData(), decoder);
}
|
java
|
static <T> StitchEvent<T> fromEvent(final Event event,
final Decoder<T> decoder) {
return new StitchEvent<>(event.getEventName(), event.getData(), decoder);
}
|
[
"static",
"<",
"T",
">",
"StitchEvent",
"<",
"T",
">",
"fromEvent",
"(",
"final",
"Event",
"event",
",",
"final",
"Decoder",
"<",
"T",
">",
"decoder",
")",
"{",
"return",
"new",
"StitchEvent",
"<>",
"(",
"event",
".",
"getEventName",
"(",
")",
",",
"event",
".",
"getData",
"(",
")",
",",
"decoder",
")",
";",
"}"
] |
Convert a SSE to a Stitch SSE
@param event SSE to convert
@param decoder decoder for decoding data
@param <T> type to decode data to
@return a Stitch server-sent event
|
[
"Convert",
"a",
"SSE",
"to",
"a",
"Stitch",
"SSE"
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/StitchEvent.java#L142-L145
|
157,883
|
mongodb/stitch-android-sdk
|
core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/EventStreamReader.java
|
EventStreamReader.processEvent
|
protected final Event processEvent() throws IOException {
while (true) {
String line;
try {
line = readLine();
} catch (final EOFException ex) {
if (doneOnce) {
throw ex;
}
doneOnce = true;
line = "";
}
// If the line is empty (a blank line), Dispatch the event, as defined below.
if (line.isEmpty()) {
// If the data buffer is an empty string, set the data buffer and the event name buffer to
// the empty string and abort these steps.
if (dataBuffer.length() == 0) {
eventName = "";
continue;
}
// If the event name buffer is not the empty string but is also not a valid NCName,
// set the data buffer and the event name buffer to the empty string and abort these steps.
// NOT IMPLEMENTED
final Event.Builder eventBuilder = new Event.Builder();
eventBuilder.withEventName(eventName.isEmpty() ? Event.MESSAGE_EVENT : eventName);
eventBuilder.withData(dataBuffer.toString());
// Set the data buffer and the event name buffer to the empty string.
dataBuffer = new StringBuilder();
eventName = "";
return eventBuilder.build();
// If the line starts with a U+003A COLON character (':')
} else if (line.startsWith(":")) {
// ignore the line
// If the line contains a U+003A COLON character (':') character
} else if (line.contains(":")) {
// Collect the characters on the line before the first U+003A COLON character (':'),
// and let field be that string.
final int colonIdx = line.indexOf(":");
final String field = line.substring(0, colonIdx);
// Collect the characters on the line after the first U+003A COLON character (':'),
// and let value be that string.
// If value starts with a single U+0020 SPACE character, remove it from value.
String value = line.substring(colonIdx + 1);
value = value.startsWith(" ") ? value.substring(1) : value;
processField(field, value);
// Otherwise, the string is not empty but does not contain a U+003A COLON character (':')
// character
} else {
processField(line, "");
}
}
}
|
java
|
protected final Event processEvent() throws IOException {
while (true) {
String line;
try {
line = readLine();
} catch (final EOFException ex) {
if (doneOnce) {
throw ex;
}
doneOnce = true;
line = "";
}
// If the line is empty (a blank line), Dispatch the event, as defined below.
if (line.isEmpty()) {
// If the data buffer is an empty string, set the data buffer and the event name buffer to
// the empty string and abort these steps.
if (dataBuffer.length() == 0) {
eventName = "";
continue;
}
// If the event name buffer is not the empty string but is also not a valid NCName,
// set the data buffer and the event name buffer to the empty string and abort these steps.
// NOT IMPLEMENTED
final Event.Builder eventBuilder = new Event.Builder();
eventBuilder.withEventName(eventName.isEmpty() ? Event.MESSAGE_EVENT : eventName);
eventBuilder.withData(dataBuffer.toString());
// Set the data buffer and the event name buffer to the empty string.
dataBuffer = new StringBuilder();
eventName = "";
return eventBuilder.build();
// If the line starts with a U+003A COLON character (':')
} else if (line.startsWith(":")) {
// ignore the line
// If the line contains a U+003A COLON character (':') character
} else if (line.contains(":")) {
// Collect the characters on the line before the first U+003A COLON character (':'),
// and let field be that string.
final int colonIdx = line.indexOf(":");
final String field = line.substring(0, colonIdx);
// Collect the characters on the line after the first U+003A COLON character (':'),
// and let value be that string.
// If value starts with a single U+0020 SPACE character, remove it from value.
String value = line.substring(colonIdx + 1);
value = value.startsWith(" ") ? value.substring(1) : value;
processField(field, value);
// Otherwise, the string is not empty but does not contain a U+003A COLON character (':')
// character
} else {
processField(line, "");
}
}
}
|
[
"protected",
"final",
"Event",
"processEvent",
"(",
")",
"throws",
"IOException",
"{",
"while",
"(",
"true",
")",
"{",
"String",
"line",
";",
"try",
"{",
"line",
"=",
"readLine",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"EOFException",
"ex",
")",
"{",
"if",
"(",
"doneOnce",
")",
"{",
"throw",
"ex",
";",
"}",
"doneOnce",
"=",
"true",
";",
"line",
"=",
"\"\"",
";",
"}",
"// If the line is empty (a blank line), Dispatch the event, as defined below.",
"if",
"(",
"line",
".",
"isEmpty",
"(",
")",
")",
"{",
"// If the data buffer is an empty string, set the data buffer and the event name buffer to",
"// the empty string and abort these steps.",
"if",
"(",
"dataBuffer",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"eventName",
"=",
"\"\"",
";",
"continue",
";",
"}",
"// If the event name buffer is not the empty string but is also not a valid NCName,",
"// set the data buffer and the event name buffer to the empty string and abort these steps.",
"// NOT IMPLEMENTED",
"final",
"Event",
".",
"Builder",
"eventBuilder",
"=",
"new",
"Event",
".",
"Builder",
"(",
")",
";",
"eventBuilder",
".",
"withEventName",
"(",
"eventName",
".",
"isEmpty",
"(",
")",
"?",
"Event",
".",
"MESSAGE_EVENT",
":",
"eventName",
")",
";",
"eventBuilder",
".",
"withData",
"(",
"dataBuffer",
".",
"toString",
"(",
")",
")",
";",
"// Set the data buffer and the event name buffer to the empty string.",
"dataBuffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"eventName",
"=",
"\"\"",
";",
"return",
"eventBuilder",
".",
"build",
"(",
")",
";",
"// If the line starts with a U+003A COLON character (':')",
"}",
"else",
"if",
"(",
"line",
".",
"startsWith",
"(",
"\":\"",
")",
")",
"{",
"// ignore the line",
"// If the line contains a U+003A COLON character (':') character",
"}",
"else",
"if",
"(",
"line",
".",
"contains",
"(",
"\":\"",
")",
")",
"{",
"// Collect the characters on the line before the first U+003A COLON character (':'),",
"// and let field be that string.",
"final",
"int",
"colonIdx",
"=",
"line",
".",
"indexOf",
"(",
"\":\"",
")",
";",
"final",
"String",
"field",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"colonIdx",
")",
";",
"// Collect the characters on the line after the first U+003A COLON character (':'),",
"// and let value be that string.",
"// If value starts with a single U+0020 SPACE character, remove it from value.",
"String",
"value",
"=",
"line",
".",
"substring",
"(",
"colonIdx",
"+",
"1",
")",
";",
"value",
"=",
"value",
".",
"startsWith",
"(",
"\" \"",
")",
"?",
"value",
".",
"substring",
"(",
"1",
")",
":",
"value",
";",
"processField",
"(",
"field",
",",
"value",
")",
";",
"// Otherwise, the string is not empty but does not contain a U+003A COLON character (':')",
"// character",
"}",
"else",
"{",
"processField",
"(",
"line",
",",
"\"\"",
")",
";",
"}",
"}",
"}"
] |
Process the next event in a given stream.
@return the fully processed event
@throws IOException if a stream is in the wrong state, IO errors can be thrown
|
[
"Process",
"the",
"next",
"event",
"in",
"a",
"given",
"stream",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/net/EventStreamReader.java#L86-L144
|
157,884
|
mongodb/stitch-android-sdk
|
core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/StitchError.java
|
StitchError.handleRichError
|
private static String handleRichError(final Response response, final String body) {
if (!response.getHeaders().containsKey(Headers.CONTENT_TYPE)
|| !response.getHeaders().get(Headers.CONTENT_TYPE).equals(ContentTypes.APPLICATION_JSON)) {
return body;
}
final Document doc;
try {
doc = BsonUtils.parseValue(body, Document.class);
} catch (Exception e) {
return body;
}
if (!doc.containsKey(Fields.ERROR)) {
return body;
}
final String errorMsg = doc.getString(Fields.ERROR);
if (!doc.containsKey(Fields.ERROR_CODE)) {
return errorMsg;
}
final String errorCode = doc.getString(Fields.ERROR_CODE);
throw new StitchServiceException(errorMsg, StitchServiceErrorCode.fromCodeName(errorCode));
}
|
java
|
private static String handleRichError(final Response response, final String body) {
if (!response.getHeaders().containsKey(Headers.CONTENT_TYPE)
|| !response.getHeaders().get(Headers.CONTENT_TYPE).equals(ContentTypes.APPLICATION_JSON)) {
return body;
}
final Document doc;
try {
doc = BsonUtils.parseValue(body, Document.class);
} catch (Exception e) {
return body;
}
if (!doc.containsKey(Fields.ERROR)) {
return body;
}
final String errorMsg = doc.getString(Fields.ERROR);
if (!doc.containsKey(Fields.ERROR_CODE)) {
return errorMsg;
}
final String errorCode = doc.getString(Fields.ERROR_CODE);
throw new StitchServiceException(errorMsg, StitchServiceErrorCode.fromCodeName(errorCode));
}
|
[
"private",
"static",
"String",
"handleRichError",
"(",
"final",
"Response",
"response",
",",
"final",
"String",
"body",
")",
"{",
"if",
"(",
"!",
"response",
".",
"getHeaders",
"(",
")",
".",
"containsKey",
"(",
"Headers",
".",
"CONTENT_TYPE",
")",
"||",
"!",
"response",
".",
"getHeaders",
"(",
")",
".",
"get",
"(",
"Headers",
".",
"CONTENT_TYPE",
")",
".",
"equals",
"(",
"ContentTypes",
".",
"APPLICATION_JSON",
")",
")",
"{",
"return",
"body",
";",
"}",
"final",
"Document",
"doc",
";",
"try",
"{",
"doc",
"=",
"BsonUtils",
".",
"parseValue",
"(",
"body",
",",
"Document",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"body",
";",
"}",
"if",
"(",
"!",
"doc",
".",
"containsKey",
"(",
"Fields",
".",
"ERROR",
")",
")",
"{",
"return",
"body",
";",
"}",
"final",
"String",
"errorMsg",
"=",
"doc",
".",
"getString",
"(",
"Fields",
".",
"ERROR",
")",
";",
"if",
"(",
"!",
"doc",
".",
"containsKey",
"(",
"Fields",
".",
"ERROR_CODE",
")",
")",
"{",
"return",
"errorMsg",
";",
"}",
"final",
"String",
"errorCode",
"=",
"doc",
".",
"getString",
"(",
"Fields",
".",
"ERROR_CODE",
")",
";",
"throw",
"new",
"StitchServiceException",
"(",
"errorMsg",
",",
"StitchServiceErrorCode",
".",
"fromCodeName",
"(",
"errorCode",
")",
")",
";",
"}"
] |
Private helper method which decodes the Stitch error from the body of an HTTP `Response`
object. If the error is successfully decoded, this function will throw the error for the end
user to eventually consume. If the error cannot be decoded, this is likely not an error from
the Stitch server, and this function will return an error message that the calling function
should use as the message of a StitchServiceException with an unknown code.
|
[
"Private",
"helper",
"method",
"which",
"decodes",
"the",
"Stitch",
"error",
"from",
"the",
"body",
"of",
"an",
"HTTP",
"Response",
"object",
".",
"If",
"the",
"error",
"is",
"successfully",
"decoded",
"this",
"function",
"will",
"throw",
"the",
"error",
"for",
"the",
"end",
"user",
"to",
"eventually",
"consume",
".",
"If",
"the",
"error",
"cannot",
"be",
"decoded",
"this",
"is",
"likely",
"not",
"an",
"error",
"from",
"the",
"Stitch",
"server",
"and",
"this",
"function",
"will",
"return",
"an",
"error",
"message",
"that",
"the",
"calling",
"function",
"should",
"use",
"as",
"the",
"message",
"of",
"a",
"StitchServiceException",
"with",
"an",
"unknown",
"code",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/StitchError.java#L72-L95
|
157,885
|
mongodb/stitch-android-sdk
|
android/core/src/main/java/com/mongodb/stitch/android/core/Stitch.java
|
Stitch.initialize
|
public static void initialize(final Context context) {
if (!initialized.compareAndSet(false, true)) {
return;
}
applicationContext = context.getApplicationContext();
final String packageName = applicationContext.getPackageName();
localAppName = packageName;
final PackageManager manager = applicationContext.getPackageManager();
try {
final PackageInfo pkgInfo = manager.getPackageInfo(packageName, 0);
localAppVersion = pkgInfo.versionName;
} catch (final NameNotFoundException e) {
Log.d(TAG, "Failed to get version of application, will not send in device info.");
}
Log.d(TAG, "Initialized android SDK");
}
|
java
|
public static void initialize(final Context context) {
if (!initialized.compareAndSet(false, true)) {
return;
}
applicationContext = context.getApplicationContext();
final String packageName = applicationContext.getPackageName();
localAppName = packageName;
final PackageManager manager = applicationContext.getPackageManager();
try {
final PackageInfo pkgInfo = manager.getPackageInfo(packageName, 0);
localAppVersion = pkgInfo.versionName;
} catch (final NameNotFoundException e) {
Log.d(TAG, "Failed to get version of application, will not send in device info.");
}
Log.d(TAG, "Initialized android SDK");
}
|
[
"public",
"static",
"void",
"initialize",
"(",
"final",
"Context",
"context",
")",
"{",
"if",
"(",
"!",
"initialized",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"return",
";",
"}",
"applicationContext",
"=",
"context",
".",
"getApplicationContext",
"(",
")",
";",
"final",
"String",
"packageName",
"=",
"applicationContext",
".",
"getPackageName",
"(",
")",
";",
"localAppName",
"=",
"packageName",
";",
"final",
"PackageManager",
"manager",
"=",
"applicationContext",
".",
"getPackageManager",
"(",
")",
";",
"try",
"{",
"final",
"PackageInfo",
"pkgInfo",
"=",
"manager",
".",
"getPackageInfo",
"(",
"packageName",
",",
"0",
")",
";",
"localAppVersion",
"=",
"pkgInfo",
".",
"versionName",
";",
"}",
"catch",
"(",
"final",
"NameNotFoundException",
"e",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"Failed to get version of application, will not send in device info.\"",
")",
";",
"}",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"Initialized android SDK\"",
")",
";",
"}"
] |
Initializes the Stitch SDK so that app clients can be created.
@param context An Android context value.
|
[
"Initializes",
"the",
"Stitch",
"SDK",
"so",
"that",
"app",
"clients",
"can",
"be",
"created",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/core/src/main/java/com/mongodb/stitch/android/core/Stitch.java#L62-L81
|
157,886
|
mongodb/stitch-android-sdk
|
android/core/src/main/java/com/mongodb/stitch/android/core/Stitch.java
|
Stitch.getAppClient
|
public static StitchAppClient getAppClient(
@Nonnull final String clientAppId
) {
ensureInitialized();
synchronized (Stitch.class) {
if (!appClients.containsKey(clientAppId)) {
throw new IllegalStateException(
String.format("client for app '%s' has not yet been initialized", clientAppId));
}
return appClients.get(clientAppId);
}
}
|
java
|
public static StitchAppClient getAppClient(
@Nonnull final String clientAppId
) {
ensureInitialized();
synchronized (Stitch.class) {
if (!appClients.containsKey(clientAppId)) {
throw new IllegalStateException(
String.format("client for app '%s' has not yet been initialized", clientAppId));
}
return appClients.get(clientAppId);
}
}
|
[
"public",
"static",
"StitchAppClient",
"getAppClient",
"(",
"@",
"Nonnull",
"final",
"String",
"clientAppId",
")",
"{",
"ensureInitialized",
"(",
")",
";",
"synchronized",
"(",
"Stitch",
".",
"class",
")",
"{",
"if",
"(",
"!",
"appClients",
".",
"containsKey",
"(",
"clientAppId",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"client for app '%s' has not yet been initialized\"",
",",
"clientAppId",
")",
")",
";",
"}",
"return",
"appClients",
".",
"get",
"(",
"clientAppId",
")",
";",
"}",
"}"
] |
Gets an app client by its client app id if it has been initialized; throws if none can be
found.
@param clientAppId the client app id of the app client to get.
@return the app client associated with the client app id.
|
[
"Gets",
"an",
"app",
"client",
"by",
"its",
"client",
"app",
"id",
"if",
"it",
"has",
"been",
"initialized",
";",
"throws",
"if",
"none",
"can",
"be",
"found",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/core/src/main/java/com/mongodb/stitch/android/core/Stitch.java#L114-L126
|
157,887
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java
|
NamespaceChangeStreamListener.start
|
public void start() {
nsLock.writeLock().lock();
try {
if (runnerThread != null) {
return;
}
runnerThread =
new Thread(new NamespaceChangeStreamRunner(
new WeakReference<>(this), networkMonitor, logger));
runnerThread.start();
} finally {
nsLock.writeLock().unlock();
}
}
|
java
|
public void start() {
nsLock.writeLock().lock();
try {
if (runnerThread != null) {
return;
}
runnerThread =
new Thread(new NamespaceChangeStreamRunner(
new WeakReference<>(this), networkMonitor, logger));
runnerThread.start();
} finally {
nsLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"start",
"(",
")",
"{",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"runnerThread",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"runnerThread",
"=",
"new",
"Thread",
"(",
"new",
"NamespaceChangeStreamRunner",
"(",
"new",
"WeakReference",
"<>",
"(",
"this",
")",
",",
"networkMonitor",
",",
"logger",
")",
")",
";",
"runnerThread",
".",
"start",
"(",
")",
";",
"}",
"finally",
"{",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Opens the stream in a background thread.
|
[
"Opens",
"the",
"stream",
"in",
"a",
"background",
"thread",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java#L91-L104
|
157,888
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java
|
NamespaceChangeStreamListener.stop
|
public void stop() {
if (runnerThread == null) {
return;
}
runnerThread.interrupt();
nsLock.writeLock().lock();
try {
if (runnerThread == null) {
return;
}
this.cancel();
this.close();
while (runnerThread.isAlive()) {
runnerThread.interrupt();
try {
runnerThread.join(1000);
} catch (final Exception e) {
e.printStackTrace();
return;
}
}
runnerThread = null;
} catch (Exception e) {
e.printStackTrace();
} finally {
nsLock.writeLock().unlock();
}
}
|
java
|
public void stop() {
if (runnerThread == null) {
return;
}
runnerThread.interrupt();
nsLock.writeLock().lock();
try {
if (runnerThread == null) {
return;
}
this.cancel();
this.close();
while (runnerThread.isAlive()) {
runnerThread.interrupt();
try {
runnerThread.join(1000);
} catch (final Exception e) {
e.printStackTrace();
return;
}
}
runnerThread = null;
} catch (Exception e) {
e.printStackTrace();
} finally {
nsLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"stop",
"(",
")",
"{",
"if",
"(",
"runnerThread",
"==",
"null",
")",
"{",
"return",
";",
"}",
"runnerThread",
".",
"interrupt",
"(",
")",
";",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"runnerThread",
"==",
"null",
")",
"{",
"return",
";",
"}",
"this",
".",
"cancel",
"(",
")",
";",
"this",
".",
"close",
"(",
")",
";",
"while",
"(",
"runnerThread",
".",
"isAlive",
"(",
")",
")",
"{",
"runnerThread",
".",
"interrupt",
"(",
")",
";",
"try",
"{",
"runnerThread",
".",
"join",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
";",
"}",
"}",
"runnerThread",
"=",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Stops the background stream thread.
|
[
"Stops",
"the",
"background",
"stream",
"thread",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java#L109-L140
|
157,889
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java
|
NamespaceChangeStreamListener.openStream
|
boolean openStream() throws InterruptedException, IOException {
logger.info("stream START");
final boolean isOpen;
final Set<BsonValue> idsToWatch = nsConfig.getSynchronizedDocumentIds();
if (!networkMonitor.isConnected()) {
logger.info("stream END - Network disconnected");
return false;
}
if (idsToWatch.isEmpty()) {
logger.info("stream END - No synchronized documents");
return false;
}
nsLock.writeLock().lockInterruptibly();
try {
if (!authMonitor.isLoggedIn()) {
logger.info("stream END - Logged out");
return false;
}
final Document args = new Document();
args.put("database", namespace.getDatabaseName());
args.put("collection", namespace.getCollectionName());
args.put("ids", idsToWatch);
currentStream =
service.streamFunction(
"watch",
Collections.singletonList(args),
ResultDecoders.changeEventDecoder(BSON_DOCUMENT_CODEC));
if (currentStream != null && currentStream.isOpen()) {
this.nsConfig.setStale(true);
isOpen = true;
} else {
isOpen = false;
}
} finally {
nsLock.writeLock().unlock();
}
return isOpen;
}
|
java
|
boolean openStream() throws InterruptedException, IOException {
logger.info("stream START");
final boolean isOpen;
final Set<BsonValue> idsToWatch = nsConfig.getSynchronizedDocumentIds();
if (!networkMonitor.isConnected()) {
logger.info("stream END - Network disconnected");
return false;
}
if (idsToWatch.isEmpty()) {
logger.info("stream END - No synchronized documents");
return false;
}
nsLock.writeLock().lockInterruptibly();
try {
if (!authMonitor.isLoggedIn()) {
logger.info("stream END - Logged out");
return false;
}
final Document args = new Document();
args.put("database", namespace.getDatabaseName());
args.put("collection", namespace.getCollectionName());
args.put("ids", idsToWatch);
currentStream =
service.streamFunction(
"watch",
Collections.singletonList(args),
ResultDecoders.changeEventDecoder(BSON_DOCUMENT_CODEC));
if (currentStream != null && currentStream.isOpen()) {
this.nsConfig.setStale(true);
isOpen = true;
} else {
isOpen = false;
}
} finally {
nsLock.writeLock().unlock();
}
return isOpen;
}
|
[
"boolean",
"openStream",
"(",
")",
"throws",
"InterruptedException",
",",
"IOException",
"{",
"logger",
".",
"info",
"(",
"\"stream START\"",
")",
";",
"final",
"boolean",
"isOpen",
";",
"final",
"Set",
"<",
"BsonValue",
">",
"idsToWatch",
"=",
"nsConfig",
".",
"getSynchronizedDocumentIds",
"(",
")",
";",
"if",
"(",
"!",
"networkMonitor",
".",
"isConnected",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"stream END - Network disconnected\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"idsToWatch",
".",
"isEmpty",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"stream END - No synchronized documents\"",
")",
";",
"return",
"false",
";",
"}",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"lockInterruptibly",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"authMonitor",
".",
"isLoggedIn",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"stream END - Logged out\"",
")",
";",
"return",
"false",
";",
"}",
"final",
"Document",
"args",
"=",
"new",
"Document",
"(",
")",
";",
"args",
".",
"put",
"(",
"\"database\"",
",",
"namespace",
".",
"getDatabaseName",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"collection\"",
",",
"namespace",
".",
"getCollectionName",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"ids\"",
",",
"idsToWatch",
")",
";",
"currentStream",
"=",
"service",
".",
"streamFunction",
"(",
"\"watch\"",
",",
"Collections",
".",
"singletonList",
"(",
"args",
")",
",",
"ResultDecoders",
".",
"changeEventDecoder",
"(",
"BSON_DOCUMENT_CODEC",
")",
")",
";",
"if",
"(",
"currentStream",
"!=",
"null",
"&&",
"currentStream",
".",
"isOpen",
"(",
")",
")",
"{",
"this",
".",
"nsConfig",
".",
"setStale",
"(",
"true",
")",
";",
"isOpen",
"=",
"true",
";",
"}",
"else",
"{",
"isOpen",
"=",
"false",
";",
"}",
"}",
"finally",
"{",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"return",
"isOpen",
";",
"}"
] |
Open the event stream
@return true if successfully opened, false if not
|
[
"Open",
"the",
"event",
"stream"
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java#L193-L236
|
157,890
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java
|
NamespaceChangeStreamListener.getEvents
|
@SuppressWarnings("unchecked")
public Map<BsonValue, ChangeEvent<BsonDocument>> getEvents() {
nsLock.readLock().lock();
final Map<BsonValue, ChangeEvent<BsonDocument>> events;
try {
events = new HashMap<>(this.events);
} finally {
nsLock.readLock().unlock();
}
nsLock.writeLock().lock();
try {
this.events.clear();
return events;
} finally {
nsLock.writeLock().unlock();
}
}
|
java
|
@SuppressWarnings("unchecked")
public Map<BsonValue, ChangeEvent<BsonDocument>> getEvents() {
nsLock.readLock().lock();
final Map<BsonValue, ChangeEvent<BsonDocument>> events;
try {
events = new HashMap<>(this.events);
} finally {
nsLock.readLock().unlock();
}
nsLock.writeLock().lock();
try {
this.events.clear();
return events;
} finally {
nsLock.writeLock().unlock();
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"<",
"BsonValue",
",",
"ChangeEvent",
"<",
"BsonDocument",
">",
">",
"getEvents",
"(",
")",
"{",
"nsLock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"final",
"Map",
"<",
"BsonValue",
",",
"ChangeEvent",
"<",
"BsonDocument",
">",
">",
"events",
";",
"try",
"{",
"events",
"=",
"new",
"HashMap",
"<>",
"(",
"this",
".",
"events",
")",
";",
"}",
"finally",
"{",
"nsLock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"events",
".",
"clear",
"(",
")",
";",
"return",
"events",
";",
"}",
"finally",
"{",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Returns the latest change events, and clears them from the change stream listener.
@return the latest change events.
|
[
"Returns",
"the",
"latest",
"change",
"events",
"and",
"clears",
"them",
"from",
"the",
"change",
"stream",
"listener",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java#L301-L318
|
157,891
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java
|
NamespaceChangeStreamListener.getUnprocessedEventForDocumentId
|
public @Nullable ChangeEvent<BsonDocument> getUnprocessedEventForDocumentId(
final BsonValue documentId
) {
final ChangeEvent<BsonDocument> event;
nsLock.readLock().lock();
try {
event = this.events.get(documentId);
} finally {
nsLock.readLock().unlock();
}
nsLock.writeLock().lock();
try {
this.events.remove(documentId);
return event;
} finally {
nsLock.writeLock().unlock();
}
}
|
java
|
public @Nullable ChangeEvent<BsonDocument> getUnprocessedEventForDocumentId(
final BsonValue documentId
) {
final ChangeEvent<BsonDocument> event;
nsLock.readLock().lock();
try {
event = this.events.get(documentId);
} finally {
nsLock.readLock().unlock();
}
nsLock.writeLock().lock();
try {
this.events.remove(documentId);
return event;
} finally {
nsLock.writeLock().unlock();
}
}
|
[
"public",
"@",
"Nullable",
"ChangeEvent",
"<",
"BsonDocument",
">",
"getUnprocessedEventForDocumentId",
"(",
"final",
"BsonValue",
"documentId",
")",
"{",
"final",
"ChangeEvent",
"<",
"BsonDocument",
">",
"event",
";",
"nsLock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"event",
"=",
"this",
".",
"events",
".",
"get",
"(",
"documentId",
")",
";",
"}",
"finally",
"{",
"nsLock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"events",
".",
"remove",
"(",
"documentId",
")",
";",
"return",
"event",
";",
"}",
"finally",
"{",
"nsLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
If there is an unprocessed change event for a particular document ID, fetch it from the
change stream listener, and remove it. By reading the event here, we are assuming it will be
processed by the consumer.
@return the latest unprocessed change event for the given document ID, or null if none exists.
|
[
"If",
"there",
"is",
"an",
"unprocessed",
"change",
"event",
"for",
"a",
"particular",
"document",
"ID",
"fetch",
"it",
"from",
"the",
"change",
"stream",
"listener",
"and",
"remove",
"it",
".",
"By",
"reading",
"the",
"event",
"here",
"we",
"are",
"assuming",
"it",
"will",
"be",
"processed",
"by",
"the",
"consumer",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/NamespaceChangeStreamListener.java#L327-L345
|
157,892
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/HashUtils.java
|
HashUtils.hash
|
public static long hash(final BsonDocument doc) {
if (doc == null) {
return 0L;
}
final byte[] docBytes = toBytes(doc);
long hashValue = FNV_64BIT_OFFSET_BASIS;
for (int offset = 0; offset < docBytes.length; offset++) {
hashValue ^= (0xFF & docBytes[offset]);
hashValue *= FNV_64BIT_PRIME;
}
return hashValue;
}
|
java
|
public static long hash(final BsonDocument doc) {
if (doc == null) {
return 0L;
}
final byte[] docBytes = toBytes(doc);
long hashValue = FNV_64BIT_OFFSET_BASIS;
for (int offset = 0; offset < docBytes.length; offset++) {
hashValue ^= (0xFF & docBytes[offset]);
hashValue *= FNV_64BIT_PRIME;
}
return hashValue;
}
|
[
"public",
"static",
"long",
"hash",
"(",
"final",
"BsonDocument",
"doc",
")",
"{",
"if",
"(",
"doc",
"==",
"null",
")",
"{",
"return",
"0L",
";",
"}",
"final",
"byte",
"[",
"]",
"docBytes",
"=",
"toBytes",
"(",
"doc",
")",
";",
"long",
"hashValue",
"=",
"FNV_64BIT_OFFSET_BASIS",
";",
"for",
"(",
"int",
"offset",
"=",
"0",
";",
"offset",
"<",
"docBytes",
".",
"length",
";",
"offset",
"++",
")",
"{",
"hashValue",
"^=",
"(",
"0xFF",
"&",
"docBytes",
"[",
"offset",
"]",
")",
";",
"hashValue",
"*=",
"FNV_64BIT_PRIME",
";",
"}",
"return",
"hashValue",
";",
"}"
] |
Implementation of FNV-1a hash algorithm.
@see <a href="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function">
ttps://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function</a>
@param doc the document to hash
@return
|
[
"Implementation",
"of",
"FNV",
"-",
"1a",
"hash",
"algorithm",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/HashUtils.java#L45-L59
|
157,893
|
mongodb/stitch-android-sdk
|
core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/SyncMongoClientFactory.java
|
SyncMongoClientFactory.deleteDatabase
|
public static boolean deleteDatabase(final StitchAppClientInfo appInfo,
final String serviceName,
final EmbeddedMongoClientFactory clientFactory,
final String userId) {
final String dataDir = appInfo.getDataDirectory();
if (dataDir == null) {
throw new IllegalArgumentException("StitchAppClient not configured with a data directory");
}
final String instanceKey = String.format(
"%s-%s_sync_%s_%s", appInfo.getClientAppId(), dataDir, serviceName, userId);
final String dbPath = String.format(
"%s/%s/sync_mongodb_%s/%s/0/", dataDir, appInfo.getClientAppId(), serviceName, userId);
final MongoClient client =
clientFactory.getClient(instanceKey, dbPath, appInfo.getCodecRegistry());
for (final String listDatabaseName : client.listDatabaseNames()) {
try {
client.getDatabase(listDatabaseName).drop();
} catch (Exception e) {
// do nothing
}
}
client.close();
clientFactory.removeClient(instanceKey);
return new File(dbPath).delete();
}
|
java
|
public static boolean deleteDatabase(final StitchAppClientInfo appInfo,
final String serviceName,
final EmbeddedMongoClientFactory clientFactory,
final String userId) {
final String dataDir = appInfo.getDataDirectory();
if (dataDir == null) {
throw new IllegalArgumentException("StitchAppClient not configured with a data directory");
}
final String instanceKey = String.format(
"%s-%s_sync_%s_%s", appInfo.getClientAppId(), dataDir, serviceName, userId);
final String dbPath = String.format(
"%s/%s/sync_mongodb_%s/%s/0/", dataDir, appInfo.getClientAppId(), serviceName, userId);
final MongoClient client =
clientFactory.getClient(instanceKey, dbPath, appInfo.getCodecRegistry());
for (final String listDatabaseName : client.listDatabaseNames()) {
try {
client.getDatabase(listDatabaseName).drop();
} catch (Exception e) {
// do nothing
}
}
client.close();
clientFactory.removeClient(instanceKey);
return new File(dbPath).delete();
}
|
[
"public",
"static",
"boolean",
"deleteDatabase",
"(",
"final",
"StitchAppClientInfo",
"appInfo",
",",
"final",
"String",
"serviceName",
",",
"final",
"EmbeddedMongoClientFactory",
"clientFactory",
",",
"final",
"String",
"userId",
")",
"{",
"final",
"String",
"dataDir",
"=",
"appInfo",
".",
"getDataDirectory",
"(",
")",
";",
"if",
"(",
"dataDir",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"StitchAppClient not configured with a data directory\"",
")",
";",
"}",
"final",
"String",
"instanceKey",
"=",
"String",
".",
"format",
"(",
"\"%s-%s_sync_%s_%s\"",
",",
"appInfo",
".",
"getClientAppId",
"(",
")",
",",
"dataDir",
",",
"serviceName",
",",
"userId",
")",
";",
"final",
"String",
"dbPath",
"=",
"String",
".",
"format",
"(",
"\"%s/%s/sync_mongodb_%s/%s/0/\"",
",",
"dataDir",
",",
"appInfo",
".",
"getClientAppId",
"(",
")",
",",
"serviceName",
",",
"userId",
")",
";",
"final",
"MongoClient",
"client",
"=",
"clientFactory",
".",
"getClient",
"(",
"instanceKey",
",",
"dbPath",
",",
"appInfo",
".",
"getCodecRegistry",
"(",
")",
")",
";",
"for",
"(",
"final",
"String",
"listDatabaseName",
":",
"client",
".",
"listDatabaseNames",
"(",
")",
")",
"{",
"try",
"{",
"client",
".",
"getDatabase",
"(",
"listDatabaseName",
")",
".",
"drop",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// do nothing",
"}",
"}",
"client",
".",
"close",
"(",
")",
";",
"clientFactory",
".",
"removeClient",
"(",
"instanceKey",
")",
";",
"return",
"new",
"File",
"(",
"dbPath",
")",
".",
"delete",
"(",
")",
";",
"}"
] |
Delete a database for a given path and userId.
@param appInfo the info for this application
@param serviceName the name of the associated service
@param clientFactory the associated factory that creates clients
@param userId the id of the user's to delete
@return true if successfully deleted, false if not
|
[
"Delete",
"a",
"database",
"for",
"a",
"given",
"path",
"and",
"userId",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/SyncMongoClientFactory.java#L53-L81
|
157,894
|
mongodb/stitch-android-sdk
|
android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/RemoteMongoCollectionImpl.java
|
RemoteMongoCollectionImpl.count
|
public Task<Long> count() {
return dispatcher.dispatchTask(new Callable<Long>() {
@Override
public Long call() {
return proxy.count();
}
});
}
|
java
|
public Task<Long> count() {
return dispatcher.dispatchTask(new Callable<Long>() {
@Override
public Long call() {
return proxy.count();
}
});
}
|
[
"public",
"Task",
"<",
"Long",
">",
"count",
"(",
")",
"{",
"return",
"dispatcher",
".",
"dispatchTask",
"(",
"new",
"Callable",
"<",
"Long",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Long",
"call",
"(",
")",
"{",
"return",
"proxy",
".",
"count",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Counts the number of documents in the collection.
@return a task containing the number of documents in the collection
|
[
"Counts",
"the",
"number",
"of",
"documents",
"in",
"the",
"collection",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/RemoteMongoCollectionImpl.java#L106-L113
|
157,895
|
mongodb/stitch-android-sdk
|
android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/RemoteMongoCollectionImpl.java
|
RemoteMongoCollectionImpl.insertOne
|
public Task<RemoteInsertOneResult> insertOne(final DocumentT document) {
return dispatcher.dispatchTask(new Callable<RemoteInsertOneResult>() {
@Override
public RemoteInsertOneResult call() {
return proxy.insertOne(document);
}
});
}
|
java
|
public Task<RemoteInsertOneResult> insertOne(final DocumentT document) {
return dispatcher.dispatchTask(new Callable<RemoteInsertOneResult>() {
@Override
public RemoteInsertOneResult call() {
return proxy.insertOne(document);
}
});
}
|
[
"public",
"Task",
"<",
"RemoteInsertOneResult",
">",
"insertOne",
"(",
"final",
"DocumentT",
"document",
")",
"{",
"return",
"dispatcher",
".",
"dispatchTask",
"(",
"new",
"Callable",
"<",
"RemoteInsertOneResult",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RemoteInsertOneResult",
"call",
"(",
")",
"{",
"return",
"proxy",
".",
"insertOne",
"(",
"document",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Inserts the provided document. If the document is missing an identifier, the client should
generate one.
@param document the document to insert
@return a task containing the result of the insert one operation
|
[
"Inserts",
"the",
"provided",
"document",
".",
"If",
"the",
"document",
"is",
"missing",
"an",
"identifier",
"the",
"client",
"should",
"generate",
"one",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/services/mongodb-remote/src/main/java/com/mongodb/stitch/android/services/mongodb/remote/internal/RemoteMongoCollectionImpl.java#L324-L331
|
157,896
|
mongodb/stitch-android-sdk
|
android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java
|
UserPasswordAuthProviderClientImpl.registerWithEmail
|
public Task<Void> registerWithEmail(@NonNull final String email, @NonNull final String password) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
registerWithEmailInternal(email, password);
return null;
}
});
}
|
java
|
public Task<Void> registerWithEmail(@NonNull final String email, @NonNull final String password) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
registerWithEmailInternal(email, password);
return null;
}
});
}
|
[
"public",
"Task",
"<",
"Void",
">",
"registerWithEmail",
"(",
"@",
"NonNull",
"final",
"String",
"email",
",",
"@",
"NonNull",
"final",
"String",
"password",
")",
"{",
"return",
"dispatcher",
".",
"dispatchTask",
"(",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"{",
"registerWithEmailInternal",
"(",
"email",
",",
"password",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] |
Registers a new user with the given email and password.
@param email the email to register with. This will be the username used during log in.
@param password the password to associated with the email. The password must be between
6 and 128 characters long.
@return A {@link Task} that completes when registration completes/fails.
|
[
"Registers",
"a",
"new",
"user",
"with",
"the",
"given",
"email",
"and",
"password",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java#L62-L71
|
157,897
|
mongodb/stitch-android-sdk
|
android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java
|
UserPasswordAuthProviderClientImpl.confirmUser
|
public Task<Void> confirmUser(@NonNull final String token, @NonNull final String tokenId) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
confirmUserInternal(token, tokenId);
return null;
}
});
}
|
java
|
public Task<Void> confirmUser(@NonNull final String token, @NonNull final String tokenId) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
confirmUserInternal(token, tokenId);
return null;
}
});
}
|
[
"public",
"Task",
"<",
"Void",
">",
"confirmUser",
"(",
"@",
"NonNull",
"final",
"String",
"token",
",",
"@",
"NonNull",
"final",
"String",
"tokenId",
")",
"{",
"return",
"dispatcher",
".",
"dispatchTask",
"(",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"{",
"confirmUserInternal",
"(",
"token",
",",
"tokenId",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] |
Confirms a user with the given token and token id.
@param token the confirmation token.
@param tokenId the id of the confirmation token.
@return A {@link Task} that completes when confirmation completes/fails.
|
[
"Confirms",
"a",
"user",
"with",
"the",
"given",
"token",
"and",
"token",
"id",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java#L80-L89
|
157,898
|
mongodb/stitch-android-sdk
|
android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java
|
UserPasswordAuthProviderClientImpl.resendConfirmationEmail
|
public Task<Void> resendConfirmationEmail(@NonNull final String email) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
resendConfirmationEmailInternal(email);
return null;
}
});
}
|
java
|
public Task<Void> resendConfirmationEmail(@NonNull final String email) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
resendConfirmationEmailInternal(email);
return null;
}
});
}
|
[
"public",
"Task",
"<",
"Void",
">",
"resendConfirmationEmail",
"(",
"@",
"NonNull",
"final",
"String",
"email",
")",
"{",
"return",
"dispatcher",
".",
"dispatchTask",
"(",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"{",
"resendConfirmationEmailInternal",
"(",
"email",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] |
Resend the confirmation for a user to the given email.
@param email the email of the user.
@return A {@link Task} that completes when the resend request completes/fails.
|
[
"Resend",
"the",
"confirmation",
"for",
"a",
"user",
"to",
"the",
"given",
"email",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java#L97-L106
|
157,899
|
mongodb/stitch-android-sdk
|
android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java
|
UserPasswordAuthProviderClientImpl.sendResetPasswordEmail
|
public Task<Void> sendResetPasswordEmail(@NonNull final String email) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
sendResetPasswordEmailInternal(email);
return null;
}
});
}
|
java
|
public Task<Void> sendResetPasswordEmail(@NonNull final String email) {
return dispatcher.dispatchTask(
new Callable<Void>() {
@Override
public Void call() {
sendResetPasswordEmailInternal(email);
return null;
}
});
}
|
[
"public",
"Task",
"<",
"Void",
">",
"sendResetPasswordEmail",
"(",
"@",
"NonNull",
"final",
"String",
"email",
")",
"{",
"return",
"dispatcher",
".",
"dispatchTask",
"(",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"{",
"sendResetPasswordEmailInternal",
"(",
"email",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] |
Sends a user a password reset email for the given email.
@param email the email of the user.
@return A {@link Task} that completes when the reqest request completes/fails.
|
[
"Sends",
"a",
"user",
"a",
"password",
"reset",
"email",
"for",
"the",
"given",
"email",
"."
] |
159b9334b1f1a827285544be5ee20cdf7b04e4cc
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/android/core/src/main/java/com/mongodb/stitch/android/core/auth/providers/userpassword/internal/UserPasswordAuthProviderClientImpl.java#L135-L144
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.