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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/Context.java | Context.expandIri | String expandIri(String value, boolean relative, boolean vocab, Map<String, Object> context,
Map<String, Boolean> defined) throws JsonLdError {
// 1)
if (value == null || JsonLdUtils.isKeyword(value)) {
return value;
}
// 2)
if (context != null && context.containsKey(value)
&& !Boolean.TRUE.equals(defined.get(value))) {
this.createTermDefinition(context, value, defined);
}
// 3)
if (vocab && this.termDefinitions.containsKey(value)) {
final Map<String, Object> td = (Map<String, Object>) this.termDefinitions.get(value);
if (td != null) {
return (String) td.get(JsonLdConsts.ID);
} else {
return null;
}
}
// 4)
final int colIndex = value.indexOf(":");
if (colIndex >= 0) {
// 4.1)
final String prefix = value.substring(0, colIndex);
final String suffix = value.substring(colIndex + 1);
// 4.2)
if ("_".equals(prefix) || suffix.startsWith("//")) {
return value;
}
// 4.3)
if (context != null && context.containsKey(prefix)
&& (!defined.containsKey(prefix) || defined.get(prefix) == false)) {
this.createTermDefinition(context, prefix, defined);
}
// 4.4)
if (this.termDefinitions.containsKey(prefix)) {
return (String) ((Map<String, Object>) this.termDefinitions.get(prefix))
.get(JsonLdConsts.ID) + suffix;
}
// 4.5)
return value;
}
// 5)
if (vocab && this.containsKey(JsonLdConsts.VOCAB)) {
return this.get(JsonLdConsts.VOCAB) + value;
}
// 6)
else if (relative) {
return JsonLdUrl.resolve((String) this.get(JsonLdConsts.BASE), value);
} else if (context != null && JsonLdUtils.isRelativeIri(value)) {
throw new JsonLdError(Error.INVALID_IRI_MAPPING, "not an absolute IRI: " + value);
}
// 7)
return value;
} | java | String expandIri(String value, boolean relative, boolean vocab, Map<String, Object> context,
Map<String, Boolean> defined) throws JsonLdError {
// 1)
if (value == null || JsonLdUtils.isKeyword(value)) {
return value;
}
// 2)
if (context != null && context.containsKey(value)
&& !Boolean.TRUE.equals(defined.get(value))) {
this.createTermDefinition(context, value, defined);
}
// 3)
if (vocab && this.termDefinitions.containsKey(value)) {
final Map<String, Object> td = (Map<String, Object>) this.termDefinitions.get(value);
if (td != null) {
return (String) td.get(JsonLdConsts.ID);
} else {
return null;
}
}
// 4)
final int colIndex = value.indexOf(":");
if (colIndex >= 0) {
// 4.1)
final String prefix = value.substring(0, colIndex);
final String suffix = value.substring(colIndex + 1);
// 4.2)
if ("_".equals(prefix) || suffix.startsWith("//")) {
return value;
}
// 4.3)
if (context != null && context.containsKey(prefix)
&& (!defined.containsKey(prefix) || defined.get(prefix) == false)) {
this.createTermDefinition(context, prefix, defined);
}
// 4.4)
if (this.termDefinitions.containsKey(prefix)) {
return (String) ((Map<String, Object>) this.termDefinitions.get(prefix))
.get(JsonLdConsts.ID) + suffix;
}
// 4.5)
return value;
}
// 5)
if (vocab && this.containsKey(JsonLdConsts.VOCAB)) {
return this.get(JsonLdConsts.VOCAB) + value;
}
// 6)
else if (relative) {
return JsonLdUrl.resolve((String) this.get(JsonLdConsts.BASE), value);
} else if (context != null && JsonLdUtils.isRelativeIri(value)) {
throw new JsonLdError(Error.INVALID_IRI_MAPPING, "not an absolute IRI: " + value);
}
// 7)
return value;
} | [
"String",
"expandIri",
"(",
"String",
"value",
",",
"boolean",
"relative",
",",
"boolean",
"vocab",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"context",
",",
"Map",
"<",
"String",
",",
"Boolean",
">",
"defined",
")",
"throws",
"JsonLdError",
"{",
"/... | IRI Expansion Algorithm
http://json-ld.org/spec/latest/json-ld-api/#iri-expansion
@param value
@param relative
@param vocab
@param context
@param defined
@return
@throws JsonLdError | [
"IRI",
"Expansion",
"Algorithm"
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/Context.java#L506-L561 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/Context.java | Context.getContainer | public String getContainer(String property) {
if (property == null) {
return null;
}
if (JsonLdConsts.GRAPH.equals(property)) {
return JsonLdConsts.SET;
}
if (!property.equals(JsonLdConsts.TYPE) && JsonLdUtils.isKeyword(property)) {
return property;
}
final Map<String, Object> td = (Map<String, Object>) termDefinitions.get(property);
if (td == null) {
return null;
}
return (String) td.get(JsonLdConsts.CONTAINER);
} | java | public String getContainer(String property) {
if (property == null) {
return null;
}
if (JsonLdConsts.GRAPH.equals(property)) {
return JsonLdConsts.SET;
}
if (!property.equals(JsonLdConsts.TYPE) && JsonLdUtils.isKeyword(property)) {
return property;
}
final Map<String, Object> td = (Map<String, Object>) termDefinitions.get(property);
if (td == null) {
return null;
}
return (String) td.get(JsonLdConsts.CONTAINER);
} | [
"public",
"String",
"getContainer",
"(",
"String",
"property",
")",
"{",
"if",
"(",
"property",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"JsonLdConsts",
".",
"GRAPH",
".",
"equals",
"(",
"property",
")",
")",
"{",
"return",
"JsonL... | Retrieve container mapping.
@param property
The Property to get a container mapping for.
@return The container mapping if any, else null | [
"Retrieve",
"container",
"mapping",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/Context.java#L1065-L1080 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/NormalizeUtils.java | NormalizeUtils.hashQuads | private static String hashQuads(String id, Map<String, Object> bnodes, UniqueNamer namer) {
// return cached hash
if (((Map<String, Object>) bnodes.get(id)).containsKey("hash")) {
return (String) ((Map<String, Object>) bnodes.get(id)).get("hash");
}
// serialize all of bnode's quads
final List<Map<String, Object>> quads = (List<Map<String, Object>>) ((Map<String, Object>) bnodes
.get(id)).get("quads");
final List<String> nquads = new ArrayList<String>();
for (int i = 0; i < quads.size(); ++i) {
nquads.add(toNQuad((RDFDataset.Quad) quads.get(i),
quads.get(i).get("name") != null
? (String) ((Map<String, Object>) quads.get(i).get("name")).get("value")
: null,
id));
}
// sort serialized quads
Collections.sort(nquads);
// return hashed quads
final String hash = sha1hash(nquads);
((Map<String, Object>) bnodes.get(id)).put("hash", hash);
return hash;
} | java | private static String hashQuads(String id, Map<String, Object> bnodes, UniqueNamer namer) {
// return cached hash
if (((Map<String, Object>) bnodes.get(id)).containsKey("hash")) {
return (String) ((Map<String, Object>) bnodes.get(id)).get("hash");
}
// serialize all of bnode's quads
final List<Map<String, Object>> quads = (List<Map<String, Object>>) ((Map<String, Object>) bnodes
.get(id)).get("quads");
final List<String> nquads = new ArrayList<String>();
for (int i = 0; i < quads.size(); ++i) {
nquads.add(toNQuad((RDFDataset.Quad) quads.get(i),
quads.get(i).get("name") != null
? (String) ((Map<String, Object>) quads.get(i).get("name")).get("value")
: null,
id));
}
// sort serialized quads
Collections.sort(nquads);
// return hashed quads
final String hash = sha1hash(nquads);
((Map<String, Object>) bnodes.get(id)).put("hash", hash);
return hash;
} | [
"private",
"static",
"String",
"hashQuads",
"(",
"String",
"id",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"bnodes",
",",
"UniqueNamer",
"namer",
")",
"{",
"// return cached hash",
"if",
"(",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
... | Hashes all of the quads about a blank node.
@param id
the ID of the bnode to hash quads for.
@param bnodes
the mapping of bnodes to quads.
@param namer
the canonical bnode namer.
@return the new hash. | [
"Hashes",
"all",
"of",
"the",
"quads",
"about",
"a",
"blank",
"node",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/NormalizeUtils.java#L427-L450 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/NormalizeUtils.java | NormalizeUtils.sha1hash | private static String sha1hash(Collection<String> nquads) {
try {
// create SHA-1 digest
final MessageDigest md = MessageDigest.getInstance("SHA-1");
for (final String nquad : nquads) {
md.update(nquad.getBytes("UTF-8"));
}
return encodeHex(md.digest());
} catch (final NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} | java | private static String sha1hash(Collection<String> nquads) {
try {
// create SHA-1 digest
final MessageDigest md = MessageDigest.getInstance("SHA-1");
for (final String nquad : nquads) {
md.update(nquad.getBytes("UTF-8"));
}
return encodeHex(md.digest());
} catch (final NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} | [
"private",
"static",
"String",
"sha1hash",
"(",
"Collection",
"<",
"String",
">",
"nquads",
")",
"{",
"try",
"{",
"// create SHA-1 digest",
"final",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA-1\"",
")",
";",
"for",
"(",
"final... | A helper class to sha1 hash all the strings in a collection
@param nquads
@return | [
"A",
"helper",
"class",
"to",
"sha1",
"hash",
"all",
"the",
"strings",
"in",
"a",
"collection"
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/NormalizeUtils.java#L458-L471 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/JsonLdOptions.java | JsonLdOptions.copy | public JsonLdOptions copy() {
final JsonLdOptions copy = new JsonLdOptions(base);
copy.setCompactArrays(compactArrays);
copy.setExpandContext(expandContext);
copy.setProcessingMode(processingMode);
copy.setDocumentLoader(documentLoader);
copy.setEmbed(embed);
copy.setExplicit(explicit);
copy.setOmitDefault(omitDefault);
copy.setOmitGraph(omitGraph);
copy.setFrameExpansion(frameExpansion);
copy.setPruneBlankNodeIdentifiers(pruneBlankNodeIdentifiers);
copy.setRequireAll(requireAll);
copy.setAllowContainerSetOnType(allowContainerSetOnType);
copy.setUseRdfType(useRdfType);
copy.setUseNativeTypes(useNativeTypes);
copy.setProduceGeneralizedRdf(produceGeneralizedRdf);
copy.format = format;
copy.useNamespaces = useNamespaces;
copy.outputForm = outputForm;
return copy;
} | java | public JsonLdOptions copy() {
final JsonLdOptions copy = new JsonLdOptions(base);
copy.setCompactArrays(compactArrays);
copy.setExpandContext(expandContext);
copy.setProcessingMode(processingMode);
copy.setDocumentLoader(documentLoader);
copy.setEmbed(embed);
copy.setExplicit(explicit);
copy.setOmitDefault(omitDefault);
copy.setOmitGraph(omitGraph);
copy.setFrameExpansion(frameExpansion);
copy.setPruneBlankNodeIdentifiers(pruneBlankNodeIdentifiers);
copy.setRequireAll(requireAll);
copy.setAllowContainerSetOnType(allowContainerSetOnType);
copy.setUseRdfType(useRdfType);
copy.setUseNativeTypes(useNativeTypes);
copy.setProduceGeneralizedRdf(produceGeneralizedRdf);
copy.format = format;
copy.useNamespaces = useNamespaces;
copy.outputForm = outputForm;
return copy;
} | [
"public",
"JsonLdOptions",
"copy",
"(",
")",
"{",
"final",
"JsonLdOptions",
"copy",
"=",
"new",
"JsonLdOptions",
"(",
"base",
")",
";",
"copy",
".",
"setCompactArrays",
"(",
"compactArrays",
")",
";",
"copy",
".",
"setExpandContext",
"(",
"expandContext",
")",... | Creates a shallow copy of this JsonLdOptions object.
It will share the same DocumentLoader unless that is overridden, and
other mutable objects, so it isn't immutable.
@return A copy of this JsonLdOptions object. | [
"Creates",
"a",
"shallow",
"copy",
"of",
"this",
"JsonLdOptions",
"object",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/JsonLdOptions.java#L46-L69 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java | JsonLdApi.removeEmbed | private static void removeEmbed(FramingContext state, String id) {
// get existing embed
final Map<String, EmbedNode> links = state.uniqueEmbeds;
final EmbedNode embed = links.get(id);
final Object parent = embed.parent;
final String property = embed.property;
// create reference to replace embed
final Map<String, Object> node = newMap(JsonLdConsts.ID, id);
// remove existing embed
if (JsonLdUtils.isNode(parent)) {
// replace subject with reference
final List<Object> newvals = new ArrayList<Object>();
final List<Object> oldvals = (List<Object>) ((Map<String, Object>) parent)
.get(property);
for (final Object v : oldvals) {
if (v instanceof Map
&& Obj.equals(((Map<String, Object>) v).get(JsonLdConsts.ID), id)) {
newvals.add(node);
} else {
newvals.add(v);
}
}
((Map<String, Object>) parent).put(property, newvals);
}
// recursively remove dependent dangling embeds
removeDependents(links, id);
} | java | private static void removeEmbed(FramingContext state, String id) {
// get existing embed
final Map<String, EmbedNode> links = state.uniqueEmbeds;
final EmbedNode embed = links.get(id);
final Object parent = embed.parent;
final String property = embed.property;
// create reference to replace embed
final Map<String, Object> node = newMap(JsonLdConsts.ID, id);
// remove existing embed
if (JsonLdUtils.isNode(parent)) {
// replace subject with reference
final List<Object> newvals = new ArrayList<Object>();
final List<Object> oldvals = (List<Object>) ((Map<String, Object>) parent)
.get(property);
for (final Object v : oldvals) {
if (v instanceof Map
&& Obj.equals(((Map<String, Object>) v).get(JsonLdConsts.ID), id)) {
newvals.add(node);
} else {
newvals.add(v);
}
}
((Map<String, Object>) parent).put(property, newvals);
}
// recursively remove dependent dangling embeds
removeDependents(links, id);
} | [
"private",
"static",
"void",
"removeEmbed",
"(",
"FramingContext",
"state",
",",
"String",
"id",
")",
"{",
"// get existing embed",
"final",
"Map",
"<",
"String",
",",
"EmbedNode",
">",
"links",
"=",
"state",
".",
"uniqueEmbeds",
";",
"final",
"EmbedNode",
"em... | Removes an existing embed.
@param state
the current framing state.
@param id
the @id of the embed to remove. | [
"Removes",
"an",
"existing",
"embed",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java#L1651-L1679 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java | JsonLdApi.addFrameOutput | private static void addFrameOutput(FramingContext state, Object parent, String property,
Object output) {
if (parent instanceof Map) {
List<Object> prop = (List<Object>) ((Map<String, Object>) parent).get(property);
if (prop == null) {
prop = new ArrayList<Object>();
((Map<String, Object>) parent).put(property, prop);
}
prop.add(output);
} else {
((List) parent).add(output);
}
} | java | private static void addFrameOutput(FramingContext state, Object parent, String property,
Object output) {
if (parent instanceof Map) {
List<Object> prop = (List<Object>) ((Map<String, Object>) parent).get(property);
if (prop == null) {
prop = new ArrayList<Object>();
((Map<String, Object>) parent).put(property, prop);
}
prop.add(output);
} else {
((List) parent).add(output);
}
} | [
"private",
"static",
"void",
"addFrameOutput",
"(",
"FramingContext",
"state",
",",
"Object",
"parent",
",",
"String",
"property",
",",
"Object",
"output",
")",
"{",
"if",
"(",
"parent",
"instanceof",
"Map",
")",
"{",
"List",
"<",
"Object",
">",
"prop",
"=... | Adds framing output to the given parent.
@param state
the current framing state.
@param parent
the parent to add to.
@param property
the parent property.
@param output
the output to add. | [
"Adds",
"framing",
"output",
"to",
"the",
"given",
"parent",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java#L1822-L1834 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java | JsonLdApi.toRDF | public RDFDataset toRDF() throws JsonLdError {
// TODO: make the default generateNodeMap call (i.e. without a
// graphName) create and return the nodeMap
final Map<String, Object> nodeMap = newMap();
nodeMap.put(JsonLdConsts.DEFAULT, newMap());
generateNodeMap(this.value, nodeMap);
final RDFDataset dataset = new RDFDataset(this);
for (final String graphName : nodeMap.keySet()) {
// 4.1)
if (JsonLdUtils.isRelativeIri(graphName)) {
continue;
}
final Map<String, Object> graph = (Map<String, Object>) nodeMap.get(graphName);
dataset.graphToRDF(graphName, graph);
}
return dataset;
} | java | public RDFDataset toRDF() throws JsonLdError {
// TODO: make the default generateNodeMap call (i.e. without a
// graphName) create and return the nodeMap
final Map<String, Object> nodeMap = newMap();
nodeMap.put(JsonLdConsts.DEFAULT, newMap());
generateNodeMap(this.value, nodeMap);
final RDFDataset dataset = new RDFDataset(this);
for (final String graphName : nodeMap.keySet()) {
// 4.1)
if (JsonLdUtils.isRelativeIri(graphName)) {
continue;
}
final Map<String, Object> graph = (Map<String, Object>) nodeMap.get(graphName);
dataset.graphToRDF(graphName, graph);
}
return dataset;
} | [
"public",
"RDFDataset",
"toRDF",
"(",
")",
"throws",
"JsonLdError",
"{",
"// TODO: make the default generateNodeMap call (i.e. without a",
"// graphName) create and return the nodeMap",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"nodeMap",
"=",
"newMap",
"(",
")",
... | Adds RDF triples for each graph in the current node map to an RDF
dataset.
@return the RDF dataset.
@throws JsonLdError
If there was an error converting from JSON-LD to RDF. | [
"Adds",
"RDF",
"triples",
"for",
"each",
"graph",
"in",
"the",
"current",
"node",
"map",
"to",
"an",
"RDF",
"dataset",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java#L2146-L2165 | train |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java | JsonLdApi.normalize | public Object normalize(Map<String, Object> dataset) throws JsonLdError {
// create quads and map bnodes to their associated quads
final List<Object> quads = new ArrayList<Object>();
final Map<String, Object> bnodes = newMap();
for (String graphName : dataset.keySet()) {
final List<Map<String, Object>> triples = (List<Map<String, Object>>) dataset
.get(graphName);
if (JsonLdConsts.DEFAULT.equals(graphName)) {
graphName = null;
}
for (final Map<String, Object> quad : triples) {
if (graphName != null) {
if (graphName.indexOf("_:") == 0) {
final Map<String, Object> tmp = newMap();
tmp.put("type", "blank node");
tmp.put("value", graphName);
quad.put("name", tmp);
} else {
final Map<String, Object> tmp = newMap();
tmp.put("type", "IRI");
tmp.put("value", graphName);
quad.put("name", tmp);
}
}
quads.add(quad);
final String[] attrs = new String[] { "subject", "object", "name" };
for (final String attr : attrs) {
if (quad.containsKey(attr) && "blank node"
.equals(((Map<String, Object>) quad.get(attr)).get("type"))) {
final String id = (String) ((Map<String, Object>) quad.get(attr))
.get("value");
if (!bnodes.containsKey(id)) {
bnodes.put(id, new LinkedHashMap<String, List<Object>>() {
{
put("quads", new ArrayList<Object>());
}
});
}
((List<Object>) ((Map<String, Object>) bnodes.get(id)).get("quads"))
.add(quad);
}
}
}
}
// mapping complete, start canonical naming
final NormalizeUtils normalizeUtils = new NormalizeUtils(quads, bnodes,
new UniqueNamer("_:c14n"), opts);
return normalizeUtils.hashBlankNodes(bnodes.keySet());
} | java | public Object normalize(Map<String, Object> dataset) throws JsonLdError {
// create quads and map bnodes to their associated quads
final List<Object> quads = new ArrayList<Object>();
final Map<String, Object> bnodes = newMap();
for (String graphName : dataset.keySet()) {
final List<Map<String, Object>> triples = (List<Map<String, Object>>) dataset
.get(graphName);
if (JsonLdConsts.DEFAULT.equals(graphName)) {
graphName = null;
}
for (final Map<String, Object> quad : triples) {
if (graphName != null) {
if (graphName.indexOf("_:") == 0) {
final Map<String, Object> tmp = newMap();
tmp.put("type", "blank node");
tmp.put("value", graphName);
quad.put("name", tmp);
} else {
final Map<String, Object> tmp = newMap();
tmp.put("type", "IRI");
tmp.put("value", graphName);
quad.put("name", tmp);
}
}
quads.add(quad);
final String[] attrs = new String[] { "subject", "object", "name" };
for (final String attr : attrs) {
if (quad.containsKey(attr) && "blank node"
.equals(((Map<String, Object>) quad.get(attr)).get("type"))) {
final String id = (String) ((Map<String, Object>) quad.get(attr))
.get("value");
if (!bnodes.containsKey(id)) {
bnodes.put(id, new LinkedHashMap<String, List<Object>>() {
{
put("quads", new ArrayList<Object>());
}
});
}
((List<Object>) ((Map<String, Object>) bnodes.get(id)).get("quads"))
.add(quad);
}
}
}
}
// mapping complete, start canonical naming
final NormalizeUtils normalizeUtils = new NormalizeUtils(quads, bnodes,
new UniqueNamer("_:c14n"), opts);
return normalizeUtils.hashBlankNodes(bnodes.keySet());
} | [
"public",
"Object",
"normalize",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"dataset",
")",
"throws",
"JsonLdError",
"{",
"// create quads and map bnodes to their associated quads",
"final",
"List",
"<",
"Object",
">",
"quads",
"=",
"new",
"ArrayList",
"<",
"O... | Performs RDF normalization on the given JSON-LD input.
@param dataset
the expanded JSON-LD object to normalize.
@return The normalized JSON-LD object
@throws JsonLdError
If there was an error while normalizing. | [
"Performs",
"RDF",
"normalization",
"on",
"the",
"given",
"JSON",
"-",
"LD",
"input",
"."
] | efeef6ee96029a0011649633457035fa6be42da1 | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java#L2186-L2236 | train |
stagemonitor/stagemonitor | stagemonitor-tracing/src/main/java/org/stagemonitor/tracing/profiler/CallStackElement.java | CallStackElement.create | public static CallStackElement create(CallStackElement parent, String signature, long startTimestamp) {
CallStackElement cse;
if (useObjectPooling) {
cse = objectPool.poll();
if (cse == null) {
cse = new CallStackElement();
}
} else {
cse = new CallStackElement();
}
cse.executionTime = startTimestamp;
cse.signature = signature;
if (parent != null) {
cse.parent = parent;
parent.children.add(cse);
}
return cse;
} | java | public static CallStackElement create(CallStackElement parent, String signature, long startTimestamp) {
CallStackElement cse;
if (useObjectPooling) {
cse = objectPool.poll();
if (cse == null) {
cse = new CallStackElement();
}
} else {
cse = new CallStackElement();
}
cse.executionTime = startTimestamp;
cse.signature = signature;
if (parent != null) {
cse.parent = parent;
parent.children.add(cse);
}
return cse;
} | [
"public",
"static",
"CallStackElement",
"create",
"(",
"CallStackElement",
"parent",
",",
"String",
"signature",
",",
"long",
"startTimestamp",
")",
"{",
"CallStackElement",
"cse",
";",
"if",
"(",
"useObjectPooling",
")",
"{",
"cse",
"=",
"objectPool",
".",
"pol... | This static factory method also sets the parent-child relationships.
@param parent the parent
@param startTimestamp the timestamp at the beginning of the method | [
"This",
"static",
"factory",
"method",
"also",
"sets",
"the",
"parent",
"-",
"child",
"relationships",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-tracing/src/main/java/org/stagemonitor/tracing/profiler/CallStackElement.java#L55-L73 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/StagemonitorByteBuddyTransformer.java | StagemonitorByteBuddyTransformer.beforeTransformation | public void beforeTransformation(TypeDescription typeDescription, ClassLoader classLoader) {
if (isPreventDuplicateTransformation()) {
Dispatcher.put(getClassAlreadyTransformedKey(typeDescription, classLoader), Boolean.TRUE);
}
if (DEBUG_INSTRUMENTATION && logger.isDebugEnabled()) {
logger.debug("TRANSFORM {} ({})", typeDescription.getName(), getClass().getSimpleName());
}
} | java | public void beforeTransformation(TypeDescription typeDescription, ClassLoader classLoader) {
if (isPreventDuplicateTransformation()) {
Dispatcher.put(getClassAlreadyTransformedKey(typeDescription, classLoader), Boolean.TRUE);
}
if (DEBUG_INSTRUMENTATION && logger.isDebugEnabled()) {
logger.debug("TRANSFORM {} ({})", typeDescription.getName(), getClass().getSimpleName());
}
} | [
"public",
"void",
"beforeTransformation",
"(",
"TypeDescription",
"typeDescription",
",",
"ClassLoader",
"classLoader",
")",
"{",
"if",
"(",
"isPreventDuplicateTransformation",
"(",
")",
")",
"{",
"Dispatcher",
".",
"put",
"(",
"getClassAlreadyTransformedKey",
"(",
"t... | This method is called before the transformation.
You can stop the transformation from happening by returning false from this method.
@param typeDescription The type that is being transformed.
@param classLoader The class loader which is loading this type. | [
"This",
"method",
"is",
"called",
"before",
"the",
"transformation",
".",
"You",
"can",
"stop",
"the",
"transformation",
"from",
"happening",
"by",
"returning",
"false",
"from",
"this",
"method",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/StagemonitorByteBuddyTransformer.java#L226-L234 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/CallerUtil.java | CallerUtil.getCallerSignature | public static String getCallerSignature() {
if (Stagemonitor.getPlugin(CorePlugin.class).getIncludePackages().isEmpty()) {
return null;
}
if (javaLangAccessObject != null) {
return getCallerSignatureSharedSecrets();
} else {
return getCallerSignatureGetStackTrace();
}
} | java | public static String getCallerSignature() {
if (Stagemonitor.getPlugin(CorePlugin.class).getIncludePackages().isEmpty()) {
return null;
}
if (javaLangAccessObject != null) {
return getCallerSignatureSharedSecrets();
} else {
return getCallerSignatureGetStackTrace();
}
} | [
"public",
"static",
"String",
"getCallerSignature",
"(",
")",
"{",
"if",
"(",
"Stagemonitor",
".",
"getPlugin",
"(",
"CorePlugin",
".",
"class",
")",
".",
"getIncludePackages",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if... | Returns the signature of the method inside the monitored codebase which was last executed. | [
"Returns",
"the",
"signature",
"of",
"the",
"method",
"inside",
"the",
"monitored",
"codebase",
"which",
"was",
"last",
"executed",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/CallerUtil.java#L28-L37 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/Stagemonitor.java | Stagemonitor.reset | @Deprecated
public static void reset(MeasurementSession measurementSession) {
started = false;
disabled = false;
if (configuration == null) {
reloadPluginsAndConfiguration();
}
if (measurementSession == null) {
CorePlugin corePlugin = getPlugin(CorePlugin.class);
measurementSession = new MeasurementSession(corePlugin.getApplicationName(),
corePlugin.getHostName(), corePlugin.getInstanceName());
}
onShutdownActions.add(AgentAttacher.performRuntimeAttachment());
startMonitoring(measurementSession);
healthCheckRegistry.register("Startup", new HealthCheck() {
@Override
protected Result check() throws Exception {
if (started) {
return Result.healthy();
} else {
return Result.unhealthy("stagemonitor is not started");
}
}
});
logStatus();
new ConfigurationLogger().logConfiguration(configuration);
} | java | @Deprecated
public static void reset(MeasurementSession measurementSession) {
started = false;
disabled = false;
if (configuration == null) {
reloadPluginsAndConfiguration();
}
if (measurementSession == null) {
CorePlugin corePlugin = getPlugin(CorePlugin.class);
measurementSession = new MeasurementSession(corePlugin.getApplicationName(),
corePlugin.getHostName(), corePlugin.getInstanceName());
}
onShutdownActions.add(AgentAttacher.performRuntimeAttachment());
startMonitoring(measurementSession);
healthCheckRegistry.register("Startup", new HealthCheck() {
@Override
protected Result check() throws Exception {
if (started) {
return Result.healthy();
} else {
return Result.unhealthy("stagemonitor is not started");
}
}
});
logStatus();
new ConfigurationLogger().logConfiguration(configuration);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"reset",
"(",
"MeasurementSession",
"measurementSession",
")",
"{",
"started",
"=",
"false",
";",
"disabled",
"=",
"false",
";",
"if",
"(",
"configuration",
"==",
"null",
")",
"{",
"reloadPluginsAndConfiguration",
"... | Should only be used outside of this class by the internal unit tests | [
"Should",
"only",
"be",
"used",
"outside",
"of",
"this",
"class",
"by",
"the",
"internal",
"unit",
"tests"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/Stagemonitor.java#L303-L329 | train |
stagemonitor/stagemonitor | stagemonitor-web-servlet/src/main/java/org/stagemonitor/web/servlet/configuration/ConfigurationPasswordChecker.java | ConfigurationPasswordChecker.isPasswordCorrect | public boolean isPasswordCorrect(String password) {
final String actualPassword = configurationRegistry.getString(updateConfigPasswordKey);
return "".equals(actualPassword) || actualPassword != null && actualPassword.equals(password);
} | java | public boolean isPasswordCorrect(String password) {
final String actualPassword = configurationRegistry.getString(updateConfigPasswordKey);
return "".equals(actualPassword) || actualPassword != null && actualPassword.equals(password);
} | [
"public",
"boolean",
"isPasswordCorrect",
"(",
"String",
"password",
")",
"{",
"final",
"String",
"actualPassword",
"=",
"configurationRegistry",
".",
"getString",
"(",
"updateConfigPasswordKey",
")",
";",
"return",
"\"\"",
".",
"equals",
"(",
"actualPassword",
")",... | Validates a password.
@param password the provided password to validate
@return <code>true</code>, if the password is correct, <code>false</code> otherwise | [
"Validates",
"a",
"password",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-web-servlet/src/main/java/org/stagemonitor/web/servlet/configuration/ConfigurationPasswordChecker.java#L21-L24 | train |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/converter/EnumValueConverter.java | EnumValueConverter.convert | @Override
public T convert(String name) throws IllegalArgumentException {
if (name == null) {
throw new IllegalArgumentException("Cant convert 'null' to " + enumClass.getSimpleName());
}
try {
return Enum.valueOf(enumClass, name);
} catch (IllegalArgumentException e) {
// ignore
}
try {
return Enum.valueOf(enumClass, name.toUpperCase());
} catch (IllegalArgumentException e) {
// ignore
}
try {
return Enum.valueOf(enumClass, name.toUpperCase().replace("-", "_"));
} catch (IllegalArgumentException e) {
// ignore
}
throw new IllegalArgumentException("Can't convert " + name + " to " + enumClass.getSimpleName());
} | java | @Override
public T convert(String name) throws IllegalArgumentException {
if (name == null) {
throw new IllegalArgumentException("Cant convert 'null' to " + enumClass.getSimpleName());
}
try {
return Enum.valueOf(enumClass, name);
} catch (IllegalArgumentException e) {
// ignore
}
try {
return Enum.valueOf(enumClass, name.toUpperCase());
} catch (IllegalArgumentException e) {
// ignore
}
try {
return Enum.valueOf(enumClass, name.toUpperCase().replace("-", "_"));
} catch (IllegalArgumentException e) {
// ignore
}
throw new IllegalArgumentException("Can't convert " + name + " to " + enumClass.getSimpleName());
} | [
"@",
"Override",
"public",
"T",
"convert",
"(",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cant convert 'null' to \"",
"+",
"enumClass",
".",
"g... | Converts a String into an Enum.
@param name The Enum's name. May be in the form THE_ENUM, the_enum or the-enum.
@return The Enum
@throws IllegalArgumentException if there is no such Enum constant | [
"Converts",
"a",
"String",
"into",
"an",
"Enum",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/converter/EnumValueConverter.java#L21-L43 | train |
stagemonitor/stagemonitor | stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/AlerterTypeServlet.java | AlerterTypeServlet.doGet | @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if (alertingPlugin.getAlertSender() != null) {
JsonUtils.writeJsonToOutputStream(alertingPlugin.getAlertSender().getAvailableAlerters(),
resp.getOutputStream());
} else {
JsonUtils.writeJsonToOutputStream(Collections.emptyList(), resp.getOutputStream());
}
} | java | @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if (alertingPlugin.getAlertSender() != null) {
JsonUtils.writeJsonToOutputStream(alertingPlugin.getAlertSender().getAvailableAlerters(),
resp.getOutputStream());
} else {
JsonUtils.writeJsonToOutputStream(Collections.emptyList(), resp.getOutputStream());
}
} | [
"@",
"Override",
"protected",
"void",
"doGet",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"if",
"(",
"alertingPlugin",
".",
"getAlertSender",
"(",
")",
"!=",
"null",
")",
"{",... | Returns all available alerters | [
"Returns",
"all",
"available",
"alerters"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/AlerterTypeServlet.java#L33-L41 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/StagemonitorCoreConfigurationSourceInitializer.java | StagemonitorCoreConfigurationSourceInitializer.addRemotePropertiesConfigurationSources | private void addRemotePropertiesConfigurationSources(ConfigurationRegistry configuration, CorePlugin corePlugin) {
final List<URL> configurationUrls = corePlugin.getRemotePropertiesConfigUrls();
if (corePlugin.isDeactivateStagemonitorIfRemotePropertyServerIsDown()) {
assertRemotePropertiesServerIsAvailable(configurationUrls.get(0));
}
logger.debug("Loading RemotePropertiesConfigurationSources with: configurationUrls = " + configurationUrls);
final HttpClient sharedHttpClient = new HttpClient();
for (URL configUrl : configurationUrls) {
final RemotePropertiesConfigurationSource source = new RemotePropertiesConfigurationSource(
sharedHttpClient,
configUrl);
configuration.addConfigurationSourceAfter(source, SimpleSource.class);
}
configuration.reloadAllConfigurationOptions();
} | java | private void addRemotePropertiesConfigurationSources(ConfigurationRegistry configuration, CorePlugin corePlugin) {
final List<URL> configurationUrls = corePlugin.getRemotePropertiesConfigUrls();
if (corePlugin.isDeactivateStagemonitorIfRemotePropertyServerIsDown()) {
assertRemotePropertiesServerIsAvailable(configurationUrls.get(0));
}
logger.debug("Loading RemotePropertiesConfigurationSources with: configurationUrls = " + configurationUrls);
final HttpClient sharedHttpClient = new HttpClient();
for (URL configUrl : configurationUrls) {
final RemotePropertiesConfigurationSource source = new RemotePropertiesConfigurationSource(
sharedHttpClient,
configUrl);
configuration.addConfigurationSourceAfter(source, SimpleSource.class);
}
configuration.reloadAllConfigurationOptions();
} | [
"private",
"void",
"addRemotePropertiesConfigurationSources",
"(",
"ConfigurationRegistry",
"configuration",
",",
"CorePlugin",
"corePlugin",
")",
"{",
"final",
"List",
"<",
"URL",
">",
"configurationUrls",
"=",
"corePlugin",
".",
"getRemotePropertiesConfigUrls",
"(",
")"... | Creates and registers a RemotePropertiesConfigurationSource for each configuration url | [
"Creates",
"and",
"registers",
"a",
"RemotePropertiesConfigurationSource",
"for",
"each",
"configuration",
"url"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/StagemonitorCoreConfigurationSourceInitializer.java#L79-L95 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/StagemonitorCoreConfigurationSourceInitializer.java | StagemonitorCoreConfigurationSourceInitializer.assertRemotePropertiesServerIsAvailable | private void assertRemotePropertiesServerIsAvailable(final URL configUrl) {
new HttpClient().send(
"HEAD",
configUrl.toExternalForm(),
new HashMap<String, String>(),
null,
new HttpClient.ResponseHandler<Void>() {
@Override
public Void handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException {
if (e != null || statusCode != 200) {
throw new IllegalStateException("Remote properties are not available at " +
configUrl + ", http status code: " + statusCode, e);
}
return null;
}
}
);
} | java | private void assertRemotePropertiesServerIsAvailable(final URL configUrl) {
new HttpClient().send(
"HEAD",
configUrl.toExternalForm(),
new HashMap<String, String>(),
null,
new HttpClient.ResponseHandler<Void>() {
@Override
public Void handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException {
if (e != null || statusCode != 200) {
throw new IllegalStateException("Remote properties are not available at " +
configUrl + ", http status code: " + statusCode, e);
}
return null;
}
}
);
} | [
"private",
"void",
"assertRemotePropertiesServerIsAvailable",
"(",
"final",
"URL",
"configUrl",
")",
"{",
"new",
"HttpClient",
"(",
")",
".",
"send",
"(",
"\"HEAD\"",
",",
"configUrl",
".",
"toExternalForm",
"(",
")",
",",
"new",
"HashMap",
"<",
"String",
",",... | Does a simple HEAD request to a configuration endpoint to check if it's reachable. If not an
IllegalStateException is thrown
@param configUrl Full qualified configuration url | [
"Does",
"a",
"simple",
"HEAD",
"request",
"to",
"a",
"configuration",
"endpoint",
"to",
"check",
"if",
"it",
"s",
"reachable",
".",
"If",
"not",
"an",
"IllegalStateException",
"is",
"thrown"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/StagemonitorCoreConfigurationSourceInitializer.java#L103-L120 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/prometheus/StagemonitorPrometheusCollector.java | StagemonitorPrometheusCollector.fromCounter | private CounterMetricFamily fromCounter(List<Map.Entry<MetricName, Counter>> countersWithSameName) {
final Map.Entry<MetricName, Counter> first = countersWithSameName.get(0);
final MetricName firstName = first.getKey();
final CounterMetricFamily metricFamily = new CounterMetricFamily(firstName.getName(), getHelpMessage(firstName, first.getValue()), firstName.getTagKeys());
for (Map.Entry<MetricName, Counter> entry : countersWithSameName) {
metricFamily.addMetric(entry.getKey().getTagValues(), entry.getValue().getCount());
}
return metricFamily;
} | java | private CounterMetricFamily fromCounter(List<Map.Entry<MetricName, Counter>> countersWithSameName) {
final Map.Entry<MetricName, Counter> first = countersWithSameName.get(0);
final MetricName firstName = first.getKey();
final CounterMetricFamily metricFamily = new CounterMetricFamily(firstName.getName(), getHelpMessage(firstName, first.getValue()), firstName.getTagKeys());
for (Map.Entry<MetricName, Counter> entry : countersWithSameName) {
metricFamily.addMetric(entry.getKey().getTagValues(), entry.getValue().getCount());
}
return metricFamily;
} | [
"private",
"CounterMetricFamily",
"fromCounter",
"(",
"List",
"<",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Counter",
">",
">",
"countersWithSameName",
")",
"{",
"final",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Counter",
">",
"first",
"=",
"counte... | Export counter as prometheus counter. | [
"Export",
"counter",
"as",
"prometheus",
"counter",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/prometheus/StagemonitorPrometheusCollector.java#L75-L83 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/prometheus/StagemonitorPrometheusCollector.java | StagemonitorPrometheusCollector.fromTimer | private MetricFamilySamples fromTimer(List<Map.Entry<MetricName, Timer>> histogramsWithSameName) {
final SummaryMetricFamily summaryMetricFamily = getSummaryMetricFamily(histogramsWithSameName, "_seconds");
for (Map.Entry<MetricName, Timer> entry : histogramsWithSameName) {
addSummaryMetric(summaryMetricFamily, entry.getKey(), entry.getValue().getSnapshot(), SECONDS_IN_NANOS, entry.getValue().getCount());
}
return summaryMetricFamily;
} | java | private MetricFamilySamples fromTimer(List<Map.Entry<MetricName, Timer>> histogramsWithSameName) {
final SummaryMetricFamily summaryMetricFamily = getSummaryMetricFamily(histogramsWithSameName, "_seconds");
for (Map.Entry<MetricName, Timer> entry : histogramsWithSameName) {
addSummaryMetric(summaryMetricFamily, entry.getKey(), entry.getValue().getSnapshot(), SECONDS_IN_NANOS, entry.getValue().getCount());
}
return summaryMetricFamily;
} | [
"private",
"MetricFamilySamples",
"fromTimer",
"(",
"List",
"<",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Timer",
">",
">",
"histogramsWithSameName",
")",
"{",
"final",
"SummaryMetricFamily",
"summaryMetricFamily",
"=",
"getSummaryMetricFamily",
"(",
"histogramsW... | Export dropwizard Timer as a histogram. Use TIME_UNIT as time unit. | [
"Export",
"dropwizard",
"Timer",
"as",
"a",
"histogram",
".",
"Use",
"TIME_UNIT",
"as",
"time",
"unit",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/prometheus/StagemonitorPrometheusCollector.java#L127-L133 | train |
stagemonitor/stagemonitor | stagemonitor-dispatcher/src/main/java/__redirected/org/stagemonitor/dispatcher/Dispatcher.java | Dispatcher.get | @SuppressWarnings("unchecked")
public static <T> T get(String key, Class<T> valueClass) {
return (T) values.get(key);
} | java | @SuppressWarnings("unchecked")
public static <T> T get(String key, Class<T> valueClass) {
return (T) values.get(key);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"get",
"(",
"String",
"key",
",",
"Class",
"<",
"T",
">",
"valueClass",
")",
"{",
"return",
"(",
"T",
")",
"values",
".",
"get",
"(",
"key",
")",
";",
"}"
] | Gets a shared value by it's key
<p> Automatically casts the value to the desired type </p>
@param key the key
@param valueClass the class of the value
@param <T> the type of the value
@return the shared value | [
"Gets",
"a",
"shared",
"value",
"by",
"it",
"s",
"key"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-dispatcher/src/main/java/__redirected/org/stagemonitor/dispatcher/Dispatcher.java#L55-L58 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/AgentAttacher.java | AgentAttacher.performRuntimeAttachment | public static synchronized Runnable performRuntimeAttachment() {
if (runtimeAttached || !corePlugin.isStagemonitorActive() || !corePlugin.isAttachAgentAtRuntime()) {
return NOOP_ON_SHUTDOWN_ACTION;
}
runtimeAttached = true;
final List<ClassFileTransformer> classFileTransformers = new ArrayList<ClassFileTransformer>();
final AutoEvictingCachingBinaryLocator binaryLocator = new AutoEvictingCachingBinaryLocator();
if (assertNoDifferentStagemonitorVersionIsDeployedOnSameJvm() && initInstrumentation()) {
final long start = System.currentTimeMillis();
classFileTransformers.add(initByteBuddyClassFileTransformer(binaryLocator));
if (corePlugin.isDebugInstrumentation()) {
logger.info("Attached agents in {} ms", System.currentTimeMillis() - start);
}
TimedElementMatcherDecorator.logMetrics();
}
return new Runnable() {
public void run() {
for (ClassFileTransformer classFileTransformer : classFileTransformers) {
instrumentation.removeTransformer(classFileTransformer);
}
// This ClassLoader is shutting down so don't try to retransform classes of it in the future
hashCodesOfClassLoadersToIgnore.add(ClassUtils.getIdentityString(AgentAttacher.class.getClassLoader()));
binaryLocator.close();
}
};
} | java | public static synchronized Runnable performRuntimeAttachment() {
if (runtimeAttached || !corePlugin.isStagemonitorActive() || !corePlugin.isAttachAgentAtRuntime()) {
return NOOP_ON_SHUTDOWN_ACTION;
}
runtimeAttached = true;
final List<ClassFileTransformer> classFileTransformers = new ArrayList<ClassFileTransformer>();
final AutoEvictingCachingBinaryLocator binaryLocator = new AutoEvictingCachingBinaryLocator();
if (assertNoDifferentStagemonitorVersionIsDeployedOnSameJvm() && initInstrumentation()) {
final long start = System.currentTimeMillis();
classFileTransformers.add(initByteBuddyClassFileTransformer(binaryLocator));
if (corePlugin.isDebugInstrumentation()) {
logger.info("Attached agents in {} ms", System.currentTimeMillis() - start);
}
TimedElementMatcherDecorator.logMetrics();
}
return new Runnable() {
public void run() {
for (ClassFileTransformer classFileTransformer : classFileTransformers) {
instrumentation.removeTransformer(classFileTransformer);
}
// This ClassLoader is shutting down so don't try to retransform classes of it in the future
hashCodesOfClassLoadersToIgnore.add(ClassUtils.getIdentityString(AgentAttacher.class.getClassLoader()));
binaryLocator.close();
}
};
} | [
"public",
"static",
"synchronized",
"Runnable",
"performRuntimeAttachment",
"(",
")",
"{",
"if",
"(",
"runtimeAttached",
"||",
"!",
"corePlugin",
".",
"isStagemonitorActive",
"(",
")",
"||",
"!",
"corePlugin",
".",
"isAttachAgentAtRuntime",
"(",
")",
")",
"{",
"... | Attaches the profiler and other instrumenters at runtime so that it is not necessary to add the -javaagent
command line argument.
@return A runnable that should be called on shutdown to unregister this class file transformer | [
"Attaches",
"the",
"profiler",
"and",
"other",
"instrumenters",
"at",
"runtime",
"so",
"that",
"it",
"is",
"not",
"necessary",
"to",
"add",
"the",
"-",
"javaagent",
"command",
"line",
"argument",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/AgentAttacher.java#L75-L101 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/util/MBeanUtils.java | MBeanUtils.registerMBean | public static void registerMBean(final ObjectInstance objectInstance, final String mBeanAttributeName, MetricName metricName, Metric2Registry metricRegistry) {
metricRegistry.register(metricName, new Gauge<Object>() {
@Override
public Object getValue() {
return getValueFromMBean(objectInstance, mBeanAttributeName);
}
});
} | java | public static void registerMBean(final ObjectInstance objectInstance, final String mBeanAttributeName, MetricName metricName, Metric2Registry metricRegistry) {
metricRegistry.register(metricName, new Gauge<Object>() {
@Override
public Object getValue() {
return getValueFromMBean(objectInstance, mBeanAttributeName);
}
});
} | [
"public",
"static",
"void",
"registerMBean",
"(",
"final",
"ObjectInstance",
"objectInstance",
",",
"final",
"String",
"mBeanAttributeName",
",",
"MetricName",
"metricName",
",",
"Metric2Registry",
"metricRegistry",
")",
"{",
"metricRegistry",
".",
"register",
"(",
"m... | Registers a MBean into the MetricRegistry
@param objectInstance The ObjectInstance
@param mBeanAttributeName The attribute name of the MBean that should be collected
@param metricName The name of the metric in the MetricRegistry
@param metricRegistry The metric registry the values of the mbean should be registered at | [
"Registers",
"a",
"MBean",
"into",
"the",
"MetricRegistry"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/util/MBeanUtils.java#L84-L91 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/Metric2Registry.java | Metric2Registry.registerAll | public void registerAll(Metric2Set metrics) throws IllegalArgumentException {
for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
register(entry.getKey(), entry.getValue());
}
} | java | public void registerAll(Metric2Set metrics) throws IllegalArgumentException {
for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
register(entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"registerAll",
"(",
"Metric2Set",
"metrics",
")",
"throws",
"IllegalArgumentException",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Metric",
">",
"entry",
":",
"metrics",
".",
"getMetrics",
"(",
")",
".",
"entrySet",
"(",... | Given a metric set, registers them.
@param metrics a set of metrics
@throws IllegalArgumentException if any of the names are already registered | [
"Given",
"a",
"metric",
"set",
"registers",
"them",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/Metric2Registry.java#L77-L81 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/Metric2Registry.java | Metric2Registry.registerAny | public void registerAny(Metric2Set metrics) {
for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
registerNewMetrics(entry.getKey(), entry.getValue());
}
} | java | public void registerAny(Metric2Set metrics) {
for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
registerNewMetrics(entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"registerAny",
"(",
"Metric2Set",
"metrics",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Metric",
">",
"entry",
":",
"metrics",
".",
"getMetrics",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"registerNewMetric... | Given a metric set, registers the ones not already registered.
This method prevents IllegalArgumentException
@param metrics a set of metrics | [
"Given",
"a",
"metric",
"set",
"registers",
"the",
"ones",
"not",
"already",
"registered",
".",
"This",
"method",
"prevents",
"IllegalArgumentException"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/Metric2Registry.java#L88-L92 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/Metric2Registry.java | Metric2Registry.registerNewMetrics | public void registerNewMetrics(MetricName name, Metric metric) {
final Set<MetricName> registeredNames = getNames();
if (!registeredNames.contains(name)) {
try {
register(name, metric);
} catch (IllegalArgumentException e){/* exception due to race condition*/}
}
} | java | public void registerNewMetrics(MetricName name, Metric metric) {
final Set<MetricName> registeredNames = getNames();
if (!registeredNames.contains(name)) {
try {
register(name, metric);
} catch (IllegalArgumentException e){/* exception due to race condition*/}
}
} | [
"public",
"void",
"registerNewMetrics",
"(",
"MetricName",
"name",
",",
"Metric",
"metric",
")",
"{",
"final",
"Set",
"<",
"MetricName",
">",
"registeredNames",
"=",
"getNames",
"(",
")",
";",
"if",
"(",
"!",
"registeredNames",
".",
"contains",
"(",
"name",
... | Only registers the metric if it is not already registered
@param name the name of the metric
@param metric the metric | [
"Only",
"registers",
"the",
"metric",
"if",
"it",
"is",
"not",
"already",
"registered"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/Metric2Registry.java#L99-L106 | train |
stagemonitor/stagemonitor | stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java | MailRequest.createMimeMessage | public MimeMessage createMimeMessage(Session session) throws MessagingException {
if (isEmpty(htmlPart) && isEmpty(textPart)) {
throw new IllegalArgumentException("Missing email content");
}
final MimeMessage msg = new MimeMessage(session);
msg.setSubject(subject);
msg.setFrom(new InternetAddress(from));
msg.setContent(createMultiPart());
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
return msg;
} | java | public MimeMessage createMimeMessage(Session session) throws MessagingException {
if (isEmpty(htmlPart) && isEmpty(textPart)) {
throw new IllegalArgumentException("Missing email content");
}
final MimeMessage msg = new MimeMessage(session);
msg.setSubject(subject);
msg.setFrom(new InternetAddress(from));
msg.setContent(createMultiPart());
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
return msg;
} | [
"public",
"MimeMessage",
"createMimeMessage",
"(",
"Session",
"session",
")",
"throws",
"MessagingException",
"{",
"if",
"(",
"isEmpty",
"(",
"htmlPart",
")",
"&&",
"isEmpty",
"(",
"textPart",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Mi... | Creates a MimeMessage containing given Multipart.
Subject, sender and content and session will be set.
@param session current mail session
@return MimeMessage without recipients
@throws MessagingException | [
"Creates",
"a",
"MimeMessage",
"containing",
"given",
"Multipart",
".",
"Subject",
"sender",
"and",
"content",
"and",
"session",
"will",
"be",
"set",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java#L78-L88 | train |
stagemonitor/stagemonitor | stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java | MailRequest.createMultiPart | private Multipart createMultiPart() throws MessagingException {
Multipart multipart = new MimeMultipart("alternative");
if (textPart != null) {
// add text first, to give priority to html
multipart.addBodyPart((BodyPart) createTextMimePart());
}
if (htmlPart != null) {
multipart.addBodyPart((BodyPart) createHtmlMimePart());
}
return multipart;
} | java | private Multipart createMultiPart() throws MessagingException {
Multipart multipart = new MimeMultipart("alternative");
if (textPart != null) {
// add text first, to give priority to html
multipart.addBodyPart((BodyPart) createTextMimePart());
}
if (htmlPart != null) {
multipart.addBodyPart((BodyPart) createHtmlMimePart());
}
return multipart;
} | [
"private",
"Multipart",
"createMultiPart",
"(",
")",
"throws",
"MessagingException",
"{",
"Multipart",
"multipart",
"=",
"new",
"MimeMultipart",
"(",
"\"alternative\"",
")",
";",
"if",
"(",
"textPart",
"!=",
"null",
")",
"{",
"// add text first, to give priority to ht... | Creates a Multipart from present parts.
@return multipart with all present parts
@throws MessagingException | [
"Creates",
"a",
"Multipart",
"from",
"present",
"parts",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java#L95-L105 | train |
stagemonitor/stagemonitor | stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java | MailRequest.createHtmlMimePart | private MimePart createHtmlMimePart() throws MessagingException {
MimePart bodyPart = new MimeBodyPart();
bodyPart.setContent(htmlPart, "text/html; charset=utf-8");
return bodyPart;
} | java | private MimePart createHtmlMimePart() throws MessagingException {
MimePart bodyPart = new MimeBodyPart();
bodyPart.setContent(htmlPart, "text/html; charset=utf-8");
return bodyPart;
} | [
"private",
"MimePart",
"createHtmlMimePart",
"(",
")",
"throws",
"MessagingException",
"{",
"MimePart",
"bodyPart",
"=",
"new",
"MimeBodyPart",
"(",
")",
";",
"bodyPart",
".",
"setContent",
"(",
"htmlPart",
",",
"\"text/html; charset=utf-8\"",
")",
";",
"return",
... | Creates a MimePart from HTML part.
@return mimePart from HTML part
@throws MessagingException | [
"Creates",
"a",
"MimePart",
"from",
"HTML",
"part",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java#L113-L117 | train |
stagemonitor/stagemonitor | stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java | MailRequest.createTextMimePart | private MimePart createTextMimePart() throws MessagingException {
MimePart bodyPart = new MimeBodyPart();
bodyPart.setText(textPart);
return bodyPart;
} | java | private MimePart createTextMimePart() throws MessagingException {
MimePart bodyPart = new MimeBodyPart();
bodyPart.setText(textPart);
return bodyPart;
} | [
"private",
"MimePart",
"createTextMimePart",
"(",
")",
"throws",
"MessagingException",
"{",
"MimePart",
"bodyPart",
"=",
"new",
"MimeBodyPart",
"(",
")",
";",
"bodyPart",
".",
"setText",
"(",
"textPart",
")",
";",
"return",
"bodyPart",
";",
"}"
] | Creates a MimePart from text part.
@return mimePart from HTML string
@throws MessagingException | [
"Creates",
"a",
"MimePart",
"from",
"text",
"part",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/alerter/MailRequest.java#L125-L129 | train |
stagemonitor/stagemonitor | stagemonitor-tracing/src/main/java/org/stagemonitor/tracing/sampling/PreExecutionInterceptorContext.java | PreExecutionInterceptorContext.mustCollectCallTree | public PreExecutionInterceptorContext mustCollectCallTree(String reason) {
logger.debug("Must collect call tree because {}", reason);
mustCollectCallTree = true;
collectCallTree = true;
return this;
} | java | public PreExecutionInterceptorContext mustCollectCallTree(String reason) {
logger.debug("Must collect call tree because {}", reason);
mustCollectCallTree = true;
collectCallTree = true;
return this;
} | [
"public",
"PreExecutionInterceptorContext",
"mustCollectCallTree",
"(",
"String",
"reason",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Must collect call tree because {}\"",
",",
"reason",
")",
";",
"mustCollectCallTree",
"=",
"true",
";",
"collectCallTree",
"=",
"true",
... | Makes sure, that a call tree is collected for the current request. In other words, profiles this request.
@param reason the reason why a call tree should always be collected (debug message)
@return <code>this</code> for chaining | [
"Makes",
"sure",
"that",
"a",
"call",
"tree",
"is",
"collected",
"for",
"the",
"current",
"request",
".",
"In",
"other",
"words",
"profiles",
"this",
"request",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-tracing/src/main/java/org/stagemonitor/tracing/sampling/PreExecutionInterceptorContext.java#L24-L29 | train |
stagemonitor/stagemonitor | stagemonitor-tracing/src/main/java/org/stagemonitor/tracing/sampling/PreExecutionInterceptorContext.java | PreExecutionInterceptorContext.shouldNotCollectCallTree | public PreExecutionInterceptorContext shouldNotCollectCallTree(String reason) {
if (!mustCollectCallTree) {
logger.debug("Should not collect call tree because {}", reason);
collectCallTree = false;
}
return this;
} | java | public PreExecutionInterceptorContext shouldNotCollectCallTree(String reason) {
if (!mustCollectCallTree) {
logger.debug("Should not collect call tree because {}", reason);
collectCallTree = false;
}
return this;
} | [
"public",
"PreExecutionInterceptorContext",
"shouldNotCollectCallTree",
"(",
"String",
"reason",
")",
"{",
"if",
"(",
"!",
"mustCollectCallTree",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Should not collect call tree because {}\"",
",",
"reason",
")",
";",
"collectCallT... | Requests that this request should not be profiled
@param reason the reason why no call tree should be collected (debug message)
@return <code>this</code> for chaining | [
"Requests",
"that",
"this",
"request",
"should",
"not",
"be",
"profiled"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-tracing/src/main/java/org/stagemonitor/tracing/sampling/PreExecutionInterceptorContext.java#L37-L43 | train |
stagemonitor/stagemonitor | stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/check/Check.java | Check.check | public List<CheckResult> check(MetricName actualTarget, Map<String, Number> currentValuesByMetric) {
SortedMap<CheckResult.Status, List<Threshold>> sortedThresholds = new TreeMap<CheckResult.Status, List<Threshold>>(thresholds);
for (Map.Entry<CheckResult.Status, List<Threshold>> entry : sortedThresholds.entrySet()) {
List<CheckResult> results = checkThresholds(entry.getValue(), entry.getKey(), actualTarget, currentValuesByMetric);
if (!results.isEmpty()) {
return results;
}
}
return Collections.emptyList();
} | java | public List<CheckResult> check(MetricName actualTarget, Map<String, Number> currentValuesByMetric) {
SortedMap<CheckResult.Status, List<Threshold>> sortedThresholds = new TreeMap<CheckResult.Status, List<Threshold>>(thresholds);
for (Map.Entry<CheckResult.Status, List<Threshold>> entry : sortedThresholds.entrySet()) {
List<CheckResult> results = checkThresholds(entry.getValue(), entry.getKey(), actualTarget, currentValuesByMetric);
if (!results.isEmpty()) {
return results;
}
}
return Collections.emptyList();
} | [
"public",
"List",
"<",
"CheckResult",
">",
"check",
"(",
"MetricName",
"actualTarget",
",",
"Map",
"<",
"String",
",",
"Number",
">",
"currentValuesByMetric",
")",
"{",
"SortedMap",
"<",
"CheckResult",
".",
"Status",
",",
"List",
"<",
"Threshold",
">",
">",
... | Performs threshold checks for the whole check group
@param currentValuesByMetric the values of the target
@param actualTarget the actual target that matched the {@link #target} pattern
@return a list of check results (results with OK statuses are omitted) | [
"Performs",
"threshold",
"checks",
"for",
"the",
"whole",
"check",
"group"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-alerting/src/main/java/org/stagemonitor/alerting/check/Check.java#L49-L58 | train |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java | ConfigurationRegistry.getNamesOfConfigurationSources | public Map<String, Boolean> getNamesOfConfigurationSources() {
final Map<String, Boolean> result = new LinkedHashMap<String, Boolean>();
for (ConfigurationSource configurationSource : configurationSources) {
result.put(configurationSource.getName(), configurationSource.isSavingPossible());
}
return result;
} | java | public Map<String, Boolean> getNamesOfConfigurationSources() {
final Map<String, Boolean> result = new LinkedHashMap<String, Boolean>();
for (ConfigurationSource configurationSource : configurationSources) {
result.put(configurationSource.getName(), configurationSource.isSavingPossible());
}
return result;
} | [
"public",
"Map",
"<",
"String",
",",
"Boolean",
">",
"getNamesOfConfigurationSources",
"(",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Boolean",
">",
"result",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Boolean",
">",
"(",
")",
";",
"for",
"("... | Returns a map with the names of all configuration sources as key and a boolean indicating whether the configuration
source supports saving as value
@return the names of all configuration sources | [
"Returns",
"a",
"map",
"with",
"the",
"names",
"of",
"all",
"configuration",
"sources",
"as",
"key",
"and",
"a",
"boolean",
"indicating",
"whether",
"the",
"configuration",
"source",
"supports",
"saving",
"as",
"value"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java#L237-L243 | train |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java | ConfigurationRegistry.reload | public void reload(String key) {
if (configurationOptionsByKey.containsKey(key)) {
configurationOptionsByKey.get(key).reload(false);
}
} | java | public void reload(String key) {
if (configurationOptionsByKey.containsKey(key)) {
configurationOptionsByKey.get(key).reload(false);
}
} | [
"public",
"void",
"reload",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"configurationOptionsByKey",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"configurationOptionsByKey",
".",
"get",
"(",
"key",
")",
".",
"reload",
"(",
"false",
")",
";",
"}",
"}"
] | Reloads a specific dynamic configuration option.
@param key the key of the configuration option | [
"Reloads",
"a",
"specific",
"dynamic",
"configuration",
"option",
"."
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java#L294-L298 | train |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java | ConfigurationRegistry.getString | public String getString(String key) {
if (key == null || key.isEmpty()) {
return null;
}
String property = null;
for (ConfigurationSource configurationSource : configurationSources) {
property = configurationSource.getValue(key);
if (property != null) {
break;
}
}
return property;
} | java | public String getString(String key) {
if (key == null || key.isEmpty()) {
return null;
}
String property = null;
for (ConfigurationSource configurationSource : configurationSources) {
property = configurationSource.getValue(key);
if (property != null) {
break;
}
}
return property;
} | [
"public",
"String",
"getString",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"key",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"property",
"=",
"null",
";",
"for",
"(",
"ConfigurationSource",
"... | Gets the value of a configuration key as string
@param key the configuration key
@return the value of this configuration key | [
"Gets",
"the",
"value",
"of",
"a",
"configuration",
"key",
"as",
"string"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java#L428-L440 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/CorePlugin.java | CorePlugin.getElasticsearchUrl | public URL getElasticsearchUrl() {
final List<URL> urls = elasticsearchUrls.getValue();
if (urls.isEmpty()) {
return null;
}
final int index = accessesToElasticsearchUrl.getAndIncrement() % urls.size();
URL elasticsearchURL = urls.get(index);
final String defaultUsernameValue = elasticsearchDefaultUsername.getValue();
final String defaultPasswordValue = elasticsearchDefaultPassword.getValue();
if (elasticsearchURL.getUserInfo() == null
&& ! defaultUsernameValue.isEmpty()
&& ! defaultPasswordValue.isEmpty()) {
try {
String username = URLEncoder.encode(defaultUsernameValue, "UTF-8");
String password = URLEncoder.encode(defaultPasswordValue, "UTF-8");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder
.append(elasticsearchURL.getProtocol())
.append("://")
.append(username)
.append(":")
.append(password)
.append("@")
.append(elasticsearchURL.getHost())
.append(":")
.append(elasticsearchURL.getPort())
.append(elasticsearchURL.getPath());
return new URL(stringBuilder.toString());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
return elasticsearchURL;
} | java | public URL getElasticsearchUrl() {
final List<URL> urls = elasticsearchUrls.getValue();
if (urls.isEmpty()) {
return null;
}
final int index = accessesToElasticsearchUrl.getAndIncrement() % urls.size();
URL elasticsearchURL = urls.get(index);
final String defaultUsernameValue = elasticsearchDefaultUsername.getValue();
final String defaultPasswordValue = elasticsearchDefaultPassword.getValue();
if (elasticsearchURL.getUserInfo() == null
&& ! defaultUsernameValue.isEmpty()
&& ! defaultPasswordValue.isEmpty()) {
try {
String username = URLEncoder.encode(defaultUsernameValue, "UTF-8");
String password = URLEncoder.encode(defaultPasswordValue, "UTF-8");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder
.append(elasticsearchURL.getProtocol())
.append("://")
.append(username)
.append(":")
.append(password)
.append("@")
.append(elasticsearchURL.getHost())
.append(":")
.append(elasticsearchURL.getPort())
.append(elasticsearchURL.getPath());
return new URL(stringBuilder.toString());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
return elasticsearchURL;
} | [
"public",
"URL",
"getElasticsearchUrl",
"(",
")",
"{",
"final",
"List",
"<",
"URL",
">",
"urls",
"=",
"elasticsearchUrls",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"urls",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"in... | Cycles through all provided Elasticsearch URLs and returns one
@return One of the provided Elasticsearch URLs | [
"Cycles",
"through",
"all",
"provided",
"Elasticsearch",
"URLs",
"and",
"returns",
"one"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/CorePlugin.java#L702-L739 | train |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationOption.java | ConfigurationOption.update | public void update(T newValue, String configurationSourceName) throws IOException {
final String newValueAsString = valueConverter.toString(newValue);
configuration.save(key, newValueAsString, configurationSourceName);
} | java | public void update(T newValue, String configurationSourceName) throws IOException {
final String newValueAsString = valueConverter.toString(newValue);
configuration.save(key, newValueAsString, configurationSourceName);
} | [
"public",
"void",
"update",
"(",
"T",
"newValue",
",",
"String",
"configurationSourceName",
")",
"throws",
"IOException",
"{",
"final",
"String",
"newValueAsString",
"=",
"valueConverter",
".",
"toString",
"(",
"newValue",
")",
";",
"configuration",
".",
"save",
... | Updates the existing value with a new one
@param newValue the new value
@param configurationSourceName the name of the configuration source that the value should be saved to
@throws IOException if there was an error saving the key to the source
@throws IllegalArgumentException if there was a error processing the configuration key or value or the
configurationSourceName did not match any of the available configuration
sources
@throws UnsupportedOperationException if saving values is not possible with this configuration source | [
"Updates",
"the",
"existing",
"value",
"with",
"a",
"new",
"one"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationOption.java#L560-L563 | train |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationOption.java | ConfigurationOption.isDefault | public boolean isDefault() {
return (valueAsString != null && valueAsString.equals(defaultValueAsString)) ||
(valueAsString == null && defaultValueAsString == null);
} | java | public boolean isDefault() {
return (valueAsString != null && valueAsString.equals(defaultValueAsString)) ||
(valueAsString == null && defaultValueAsString == null);
} | [
"public",
"boolean",
"isDefault",
"(",
")",
"{",
"return",
"(",
"valueAsString",
"!=",
"null",
"&&",
"valueAsString",
".",
"equals",
"(",
"defaultValueAsString",
")",
")",
"||",
"(",
"valueAsString",
"==",
"null",
"&&",
"defaultValueAsString",
"==",
"null",
")... | Returns true if the current value is equal to the default value
@return true if the current value is equal to the default value | [
"Returns",
"true",
"if",
"the",
"current",
"value",
"is",
"equal",
"to",
"the",
"default",
"value"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationOption.java#L580-L583 | train |
stagemonitor/stagemonitor | stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/MetricName.java | MetricName.toGraphiteName | public String toGraphiteName() {
StringBuilder sb = new StringBuilder(GraphiteSanitizer.sanitizeGraphiteMetricSegment(name));
for (String value : tags.values()) {
sb.append('.').append(GraphiteSanitizer.sanitizeGraphiteMetricSegment(value));
}
return sb.toString();
} | java | public String toGraphiteName() {
StringBuilder sb = new StringBuilder(GraphiteSanitizer.sanitizeGraphiteMetricSegment(name));
for (String value : tags.values()) {
sb.append('.').append(GraphiteSanitizer.sanitizeGraphiteMetricSegment(value));
}
return sb.toString();
} | [
"public",
"String",
"toGraphiteName",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"GraphiteSanitizer",
".",
"sanitizeGraphiteMetricSegment",
"(",
"name",
")",
")",
";",
"for",
"(",
"String",
"value",
":",
"tags",
".",
"values",
"(",... | Converts a metrics 2.0 name into a graphite compliant name by appending all tag values to the metric name
@return A graphite compliant name | [
"Converts",
"a",
"metrics",
"2",
".",
"0",
"name",
"into",
"a",
"graphite",
"compliant",
"name",
"by",
"appending",
"all",
"tag",
"values",
"to",
"the",
"metric",
"name"
] | 7a1bf6848906f816aa465983f602ea1f1e8f2b7b | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-core/src/main/java/org/stagemonitor/core/metrics/metrics2/MetricName.java#L107-L113 | train |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/Controller.java | Controller.getChildRouters | @NonNull
public final List<Router> getChildRouters() {
List<Router> routers = new ArrayList<>(childRouters.size());
routers.addAll(childRouters);
return routers;
} | java | @NonNull
public final List<Router> getChildRouters() {
List<Router> routers = new ArrayList<>(childRouters.size());
routers.addAll(childRouters);
return routers;
} | [
"@",
"NonNull",
"public",
"final",
"List",
"<",
"Router",
">",
"getChildRouters",
"(",
")",
"{",
"List",
"<",
"Router",
">",
"routers",
"=",
"new",
"ArrayList",
"<>",
"(",
"childRouters",
".",
"size",
"(",
")",
")",
";",
"routers",
".",
"addAll",
"(",
... | Returns all of this Controller's child Routers | [
"Returns",
"all",
"of",
"this",
"Controller",
"s",
"child",
"Routers"
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/Controller.java#L355-L360 | train |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/Controller.java | Controller.handleBack | public boolean handleBack() {
List<RouterTransaction> childTransactions = new ArrayList<>();
for (ControllerHostedRouter childRouter : childRouters) {
childTransactions.addAll(childRouter.getBackstack());
}
Collections.sort(childTransactions, new Comparator<RouterTransaction>() {
@Override
public int compare(RouterTransaction o1, RouterTransaction o2) {
return o2.transactionIndex - o1.transactionIndex;
}
});
for (RouterTransaction transaction : childTransactions) {
Controller childController = transaction.controller;
if (childController.isAttached() && childController.getRouter().handleBack()) {
return true;
}
}
return false;
} | java | public boolean handleBack() {
List<RouterTransaction> childTransactions = new ArrayList<>();
for (ControllerHostedRouter childRouter : childRouters) {
childTransactions.addAll(childRouter.getBackstack());
}
Collections.sort(childTransactions, new Comparator<RouterTransaction>() {
@Override
public int compare(RouterTransaction o1, RouterTransaction o2) {
return o2.transactionIndex - o1.transactionIndex;
}
});
for (RouterTransaction transaction : childTransactions) {
Controller childController = transaction.controller;
if (childController.isAttached() && childController.getRouter().handleBack()) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"handleBack",
"(",
")",
"{",
"List",
"<",
"RouterTransaction",
">",
"childTransactions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"ControllerHostedRouter",
"childRouter",
":",
"childRouters",
")",
"{",
"childTransactions",
"... | Should be overridden if this Controller needs to handle the back button being pressed.
@return True if this Controller has consumed the back button press, otherwise false | [
"Should",
"be",
"overridden",
"if",
"this",
"Controller",
"needs",
"to",
"handle",
"the",
"back",
"button",
"being",
"pressed",
"."
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/Controller.java#L596-L619 | train |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/Router.java | Router.getBackstack | @NonNull
public List<RouterTransaction> getBackstack() {
List<RouterTransaction> list = new ArrayList<>(backstack.size());
Iterator<RouterTransaction> backstackIterator = backstack.reverseIterator();
while (backstackIterator.hasNext()) {
list.add(backstackIterator.next());
}
return list;
} | java | @NonNull
public List<RouterTransaction> getBackstack() {
List<RouterTransaction> list = new ArrayList<>(backstack.size());
Iterator<RouterTransaction> backstackIterator = backstack.reverseIterator();
while (backstackIterator.hasNext()) {
list.add(backstackIterator.next());
}
return list;
} | [
"@",
"NonNull",
"public",
"List",
"<",
"RouterTransaction",
">",
"getBackstack",
"(",
")",
"{",
"List",
"<",
"RouterTransaction",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
"backstack",
".",
"size",
"(",
")",
")",
";",
"Iterator",
"<",
"RouterTransac... | Returns the current backstack, ordered from root to most recently pushed. | [
"Returns",
"the",
"current",
"backstack",
"ordered",
"from",
"root",
"to",
"most",
"recently",
"pushed",
"."
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/Router.java#L387-L395 | train |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/Router.java | Router.rebindIfNeeded | @UiThread
public void rebindIfNeeded() {
ThreadUtils.ensureMainThread();
Iterator<RouterTransaction> backstackIterator = backstack.reverseIterator();
while (backstackIterator.hasNext()) {
RouterTransaction transaction = backstackIterator.next();
if (transaction.controller.getNeedsAttach()) {
performControllerChange(transaction, null, true, new SimpleSwapChangeHandler(false));
} else {
setControllerRouter(transaction.controller);
}
}
} | java | @UiThread
public void rebindIfNeeded() {
ThreadUtils.ensureMainThread();
Iterator<RouterTransaction> backstackIterator = backstack.reverseIterator();
while (backstackIterator.hasNext()) {
RouterTransaction transaction = backstackIterator.next();
if (transaction.controller.getNeedsAttach()) {
performControllerChange(transaction, null, true, new SimpleSwapChangeHandler(false));
} else {
setControllerRouter(transaction.controller);
}
}
} | [
"@",
"UiThread",
"public",
"void",
"rebindIfNeeded",
"(",
")",
"{",
"ThreadUtils",
".",
"ensureMainThread",
"(",
")",
";",
"Iterator",
"<",
"RouterTransaction",
">",
"backstackIterator",
"=",
"backstack",
".",
"reverseIterator",
"(",
")",
";",
"while",
"(",
"b... | Attaches this Router's existing backstack to its container if one exists. | [
"Attaches",
"this",
"Router",
"s",
"existing",
"backstack",
"to",
"its",
"container",
"if",
"one",
"exists",
"."
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/Router.java#L544-L558 | train |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/Router.java | Router.ensureOrderedTransactionIndices | private void ensureOrderedTransactionIndices(List<RouterTransaction> backstack) {
List<Integer> indices = new ArrayList<>(backstack.size());
for (RouterTransaction transaction : backstack) {
transaction.ensureValidIndex(getTransactionIndexer());
indices.add(transaction.transactionIndex);
}
Collections.sort(indices);
for (int i = 0; i < backstack.size(); i++) {
backstack.get(i).transactionIndex = indices.get(i);
}
} | java | private void ensureOrderedTransactionIndices(List<RouterTransaction> backstack) {
List<Integer> indices = new ArrayList<>(backstack.size());
for (RouterTransaction transaction : backstack) {
transaction.ensureValidIndex(getTransactionIndexer());
indices.add(transaction.transactionIndex);
}
Collections.sort(indices);
for (int i = 0; i < backstack.size(); i++) {
backstack.get(i).transactionIndex = indices.get(i);
}
} | [
"private",
"void",
"ensureOrderedTransactionIndices",
"(",
"List",
"<",
"RouterTransaction",
">",
"backstack",
")",
"{",
"List",
"<",
"Integer",
">",
"indices",
"=",
"new",
"ArrayList",
"<>",
"(",
"backstack",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"... | developer rearranging the backstack at runtime. | [
"developer",
"rearranging",
"the",
"backstack",
"at",
"runtime",
"."
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/Router.java#L895-L907 | train |
bluelinelabs/Conductor | conductor/src/main/java/com/bluelinelabs/conductor/RouterTransaction.java | RouterTransaction.saveInstanceState | @NonNull
public Bundle saveInstanceState() {
Bundle bundle = new Bundle();
bundle.putBundle(KEY_VIEW_CONTROLLER_BUNDLE, controller.saveInstanceState());
if (pushControllerChangeHandler != null) {
bundle.putBundle(KEY_PUSH_TRANSITION, pushControllerChangeHandler.toBundle());
}
if (popControllerChangeHandler != null) {
bundle.putBundle(KEY_POP_TRANSITION, popControllerChangeHandler.toBundle());
}
bundle.putString(KEY_TAG, tag);
bundle.putInt(KEY_INDEX, transactionIndex);
bundle.putBoolean(KEY_ATTACHED_TO_ROUTER, attachedToRouter);
return bundle;
} | java | @NonNull
public Bundle saveInstanceState() {
Bundle bundle = new Bundle();
bundle.putBundle(KEY_VIEW_CONTROLLER_BUNDLE, controller.saveInstanceState());
if (pushControllerChangeHandler != null) {
bundle.putBundle(KEY_PUSH_TRANSITION, pushControllerChangeHandler.toBundle());
}
if (popControllerChangeHandler != null) {
bundle.putBundle(KEY_POP_TRANSITION, popControllerChangeHandler.toBundle());
}
bundle.putString(KEY_TAG, tag);
bundle.putInt(KEY_INDEX, transactionIndex);
bundle.putBoolean(KEY_ATTACHED_TO_ROUTER, attachedToRouter);
return bundle;
} | [
"@",
"NonNull",
"public",
"Bundle",
"saveInstanceState",
"(",
")",
"{",
"Bundle",
"bundle",
"=",
"new",
"Bundle",
"(",
")",
";",
"bundle",
".",
"putBundle",
"(",
"KEY_VIEW_CONTROLLER_BUNDLE",
",",
"controller",
".",
"saveInstanceState",
"(",
")",
")",
";",
"... | Used to serialize this transaction into a Bundle | [
"Used",
"to",
"serialize",
"this",
"transaction",
"into",
"a",
"Bundle"
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/conductor/src/main/java/com/bluelinelabs/conductor/RouterTransaction.java#L120-L138 | train |
bluelinelabs/Conductor | demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/base/BaseController.java | BaseController.getActionBar | protected ActionBar getActionBar() {
ActionBarProvider actionBarProvider = ((ActionBarProvider)getActivity());
return actionBarProvider != null ? actionBarProvider.getSupportActionBar() : null;
} | java | protected ActionBar getActionBar() {
ActionBarProvider actionBarProvider = ((ActionBarProvider)getActivity());
return actionBarProvider != null ? actionBarProvider.getSupportActionBar() : null;
} | [
"protected",
"ActionBar",
"getActionBar",
"(",
")",
"{",
"ActionBarProvider",
"actionBarProvider",
"=",
"(",
"(",
"ActionBarProvider",
")",
"getActivity",
"(",
")",
")",
";",
"return",
"actionBarProvider",
"!=",
"null",
"?",
"actionBarProvider",
".",
"getSupportActi... | be accessed. In a production app, this would use Dagger instead. | [
"be",
"accessed",
".",
"In",
"a",
"production",
"app",
"this",
"would",
"use",
"Dagger",
"instead",
"."
] | 94c9121bb16f93b481954513a8e3905846829fb2 | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/base/BaseController.java#L21-L24 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/ConnectionSettings.java | ConnectionSettings.driverVersion | private static String driverVersion()
{
// "Session" is arbitrary - the only thing that matters is that the class we use here is in the
// 'org.neo4j.driver' package, because that is where the jar manifest specifies the version.
// This is done as part of the build, adding a MANIFEST.MF file to the generated jarfile.
Package pkg = Session.class.getPackage();
if ( pkg != null && pkg.getImplementationVersion() != null )
{
return pkg.getImplementationVersion();
}
// If there is no version, we're not running from a jar file, but from raw compiled class files.
// This should only happen during development, so call the version 'dev'.
return "dev";
} | java | private static String driverVersion()
{
// "Session" is arbitrary - the only thing that matters is that the class we use here is in the
// 'org.neo4j.driver' package, because that is where the jar manifest specifies the version.
// This is done as part of the build, adding a MANIFEST.MF file to the generated jarfile.
Package pkg = Session.class.getPackage();
if ( pkg != null && pkg.getImplementationVersion() != null )
{
return pkg.getImplementationVersion();
}
// If there is no version, we're not running from a jar file, but from raw compiled class files.
// This should only happen during development, so call the version 'dev'.
return "dev";
} | [
"private",
"static",
"String",
"driverVersion",
"(",
")",
"{",
"// \"Session\" is arbitrary - the only thing that matters is that the class we use here is in the",
"// 'org.neo4j.driver' package, because that is where the jar manifest specifies the version.",
"// This is done as part of the build,... | Extracts the driver version from the driver jar MANIFEST.MF file. | [
"Extracts",
"the",
"driver",
"version",
"from",
"the",
"driver",
"jar",
"MANIFEST",
".",
"MF",
"file",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/ConnectionSettings.java#L37-L51 | train |
neo4j/neo4j-java-driver | examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java | PassBookmarkExample.addCompany | private StatementResult addCompany( final Transaction tx, final String name )
{
return tx.run( "CREATE (:Company {name: $name})", parameters( "name", name ) );
} | java | private StatementResult addCompany( final Transaction tx, final String name )
{
return tx.run( "CREATE (:Company {name: $name})", parameters( "name", name ) );
} | [
"private",
"StatementResult",
"addCompany",
"(",
"final",
"Transaction",
"tx",
",",
"final",
"String",
"name",
")",
"{",
"return",
"tx",
".",
"run",
"(",
"\"CREATE (:Company {name: $name})\"",
",",
"parameters",
"(",
"\"name\"",
",",
"name",
")",
")",
";",
"}"... | Create a company node | [
"Create",
"a",
"company",
"node"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java#L44-L47 | train |
neo4j/neo4j-java-driver | examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java | PassBookmarkExample.addPerson | private StatementResult addPerson( final Transaction tx, final String name )
{
return tx.run( "CREATE (:Person {name: $name})", parameters( "name", name ) );
} | java | private StatementResult addPerson( final Transaction tx, final String name )
{
return tx.run( "CREATE (:Person {name: $name})", parameters( "name", name ) );
} | [
"private",
"StatementResult",
"addPerson",
"(",
"final",
"Transaction",
"tx",
",",
"final",
"String",
"name",
")",
"{",
"return",
"tx",
".",
"run",
"(",
"\"CREATE (:Person {name: $name})\"",
",",
"parameters",
"(",
"\"name\"",
",",
"name",
")",
")",
";",
"}"
] | Create a person node | [
"Create",
"a",
"person",
"node"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java#L50-L53 | train |
neo4j/neo4j-java-driver | examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java | PassBookmarkExample.employ | private StatementResult employ( final Transaction tx, final String person, final String company )
{
return tx.run( "MATCH (person:Person {name: $person_name}) " +
"MATCH (company:Company {name: $company_name}) " +
"CREATE (person)-[:WORKS_FOR]->(company)",
parameters( "person_name", person, "company_name", company ) );
} | java | private StatementResult employ( final Transaction tx, final String person, final String company )
{
return tx.run( "MATCH (person:Person {name: $person_name}) " +
"MATCH (company:Company {name: $company_name}) " +
"CREATE (person)-[:WORKS_FOR]->(company)",
parameters( "person_name", person, "company_name", company ) );
} | [
"private",
"StatementResult",
"employ",
"(",
"final",
"Transaction",
"tx",
",",
"final",
"String",
"person",
",",
"final",
"String",
"company",
")",
"{",
"return",
"tx",
".",
"run",
"(",
"\"MATCH (person:Person {name: $person_name}) \"",
"+",
"\"MATCH (company:Company... | This relies on the person first having been created. | [
"This",
"relies",
"on",
"the",
"person",
"first",
"having",
"been",
"created",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java#L57-L63 | train |
neo4j/neo4j-java-driver | examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java | PassBookmarkExample.makeFriends | private StatementResult makeFriends( final Transaction tx, final String person1, final String person2 )
{
return tx.run( "MATCH (a:Person {name: $person_1}) " +
"MATCH (b:Person {name: $person_2}) " +
"MERGE (a)-[:KNOWS]->(b)",
parameters( "person_1", person1, "person_2", person2 ) );
} | java | private StatementResult makeFriends( final Transaction tx, final String person1, final String person2 )
{
return tx.run( "MATCH (a:Person {name: $person_1}) " +
"MATCH (b:Person {name: $person_2}) " +
"MERGE (a)-[:KNOWS]->(b)",
parameters( "person_1", person1, "person_2", person2 ) );
} | [
"private",
"StatementResult",
"makeFriends",
"(",
"final",
"Transaction",
"tx",
",",
"final",
"String",
"person1",
",",
"final",
"String",
"person2",
")",
"{",
"return",
"tx",
".",
"run",
"(",
"\"MATCH (a:Person {name: $person_1}) \"",
"+",
"\"MATCH (b:Person {name: $... | Create a friendship between two people. | [
"Create",
"a",
"friendship",
"between",
"two",
"people",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java#L66-L72 | train |
neo4j/neo4j-java-driver | examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java | PassBookmarkExample.printFriends | private StatementResult printFriends( final Transaction tx )
{
StatementResult result = tx.run( "MATCH (a)-[:KNOWS]->(b) RETURN a.name, b.name" );
while ( result.hasNext() )
{
Record record = result.next();
System.out.println( String.format( "%s knows %s", record.get( "a.name" ).asString(), record.get( "b.name" ).toString() ) );
}
return result;
} | java | private StatementResult printFriends( final Transaction tx )
{
StatementResult result = tx.run( "MATCH (a)-[:KNOWS]->(b) RETURN a.name, b.name" );
while ( result.hasNext() )
{
Record record = result.next();
System.out.println( String.format( "%s knows %s", record.get( "a.name" ).asString(), record.get( "b.name" ).toString() ) );
}
return result;
} | [
"private",
"StatementResult",
"printFriends",
"(",
"final",
"Transaction",
"tx",
")",
"{",
"StatementResult",
"result",
"=",
"tx",
".",
"run",
"(",
"\"MATCH (a)-[:KNOWS]->(b) RETURN a.name, b.name\"",
")",
";",
"while",
"(",
"result",
".",
"hasNext",
"(",
")",
")"... | Match and display all friendships. | [
"Match",
"and",
"display",
"all",
"friendships",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/examples/src/main/java/org/neo4j/docs/driver/PassBookmarkExample.java#L75-L84 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/Preconditions.java | Preconditions.checkArgument | public static void checkArgument( Object argument, Class<?> expectedClass )
{
if ( !expectedClass.isInstance( argument ) )
{
throw new IllegalArgumentException( "Argument expected to be of type: " + expectedClass.getName() + " but was: " + argument );
}
} | java | public static void checkArgument( Object argument, Class<?> expectedClass )
{
if ( !expectedClass.isInstance( argument ) )
{
throw new IllegalArgumentException( "Argument expected to be of type: " + expectedClass.getName() + " but was: " + argument );
}
} | [
"public",
"static",
"void",
"checkArgument",
"(",
"Object",
"argument",
",",
"Class",
"<",
"?",
">",
"expectedClass",
")",
"{",
"if",
"(",
"!",
"expectedClass",
".",
"isInstance",
"(",
"argument",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(... | Assert that given argument is of expected type.
@param argument the object to check.
@param expectedClass the expected type.
@throws IllegalArgumentException if argument is not of expected type. | [
"Assert",
"that",
"given",
"argument",
"is",
"of",
"expected",
"type",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/Preconditions.java#L49-L55 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/AuthTokens.java | AuthTokens.kerberos | public static AuthToken kerberos( String base64EncodedTicket )
{
Objects.requireNonNull( base64EncodedTicket, "Ticket can't be null" );
Map<String,Value> map = newHashMapWithSize( 3 );
map.put( SCHEME_KEY, value( "kerberos" ) );
map.put( PRINCIPAL_KEY, value( "" ) ); // This empty string is required for backwards compatibility.
map.put( CREDENTIALS_KEY, value( base64EncodedTicket ) );
return new InternalAuthToken( map );
} | java | public static AuthToken kerberos( String base64EncodedTicket )
{
Objects.requireNonNull( base64EncodedTicket, "Ticket can't be null" );
Map<String,Value> map = newHashMapWithSize( 3 );
map.put( SCHEME_KEY, value( "kerberos" ) );
map.put( PRINCIPAL_KEY, value( "" ) ); // This empty string is required for backwards compatibility.
map.put( CREDENTIALS_KEY, value( base64EncodedTicket ) );
return new InternalAuthToken( map );
} | [
"public",
"static",
"AuthToken",
"kerberos",
"(",
"String",
"base64EncodedTicket",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"base64EncodedTicket",
",",
"\"Ticket can't be null\"",
")",
";",
"Map",
"<",
"String",
",",
"Value",
">",
"map",
"=",
"newHashMapWi... | The kerberos authentication scheme, using a base64 encoded ticket
@param base64EncodedTicket a base64 encoded service ticket
@return an authentication token that can be used to connect to Neo4j
@see GraphDatabase#driver(String, AuthToken)
@since 1.3
@throws NullPointerException when ticket is {@code null} | [
"The",
"kerberos",
"authentication",
"scheme",
"using",
"a",
"base64",
"encoded",
"ticket"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/AuthTokens.java#L90-L99 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/reactive/RxUtils.java | RxUtils.createEmptyPublisher | public static <T> Publisher<T> createEmptyPublisher( Supplier<CompletionStage<Void>> supplier )
{
return Mono.create( sink -> supplier.get().whenComplete( ( ignore, completionError ) -> {
Throwable error = Futures.completionExceptionCause( completionError );
if ( error != null )
{
sink.error( error );
}
else
{
sink.success();
}
} ) );
} | java | public static <T> Publisher<T> createEmptyPublisher( Supplier<CompletionStage<Void>> supplier )
{
return Mono.create( sink -> supplier.get().whenComplete( ( ignore, completionError ) -> {
Throwable error = Futures.completionExceptionCause( completionError );
if ( error != null )
{
sink.error( error );
}
else
{
sink.success();
}
} ) );
} | [
"public",
"static",
"<",
"T",
">",
"Publisher",
"<",
"T",
">",
"createEmptyPublisher",
"(",
"Supplier",
"<",
"CompletionStage",
"<",
"Void",
">",
">",
"supplier",
")",
"{",
"return",
"Mono",
".",
"create",
"(",
"sink",
"->",
"supplier",
".",
"get",
"(",
... | The publisher created by this method will either succeed without publishing anything or fail with an error.
@param supplier supplies a {@link CompletionStage<Void>}.
@return A publisher that publishes nothing on completion or fails with an error. | [
"The",
"publisher",
"created",
"by",
"this",
"method",
"will",
"either",
"succeed",
"without",
"publishing",
"anything",
"or",
"fail",
"with",
"an",
"error",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/reactive/RxUtils.java#L36-L49 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/security/TrustOnFirstUseTrustManager.java | TrustOnFirstUseTrustManager.load | private void load() throws IOException
{
if ( !knownHosts.exists() )
{
return;
}
assertKnownHostFileReadable();
try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) )
{
String line;
while ( (line = reader.readLine()) != null )
{
if ( (!line.trim().startsWith( "#" )) )
{
String[] strings = line.split( " " );
if ( strings[0].trim().equals( serverId ) )
{
// load the certificate
fingerprint = strings[1].trim();
return;
}
}
}
}
} | java | private void load() throws IOException
{
if ( !knownHosts.exists() )
{
return;
}
assertKnownHostFileReadable();
try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) )
{
String line;
while ( (line = reader.readLine()) != null )
{
if ( (!line.trim().startsWith( "#" )) )
{
String[] strings = line.split( " " );
if ( strings[0].trim().equals( serverId ) )
{
// load the certificate
fingerprint = strings[1].trim();
return;
}
}
}
}
} | [
"private",
"void",
"load",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"knownHosts",
".",
"exists",
"(",
")",
")",
"{",
"return",
";",
"}",
"assertKnownHostFileReadable",
"(",
")",
";",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"Buf... | Try to load the certificate form the file if the server we've connected is a known server.
@throws IOException | [
"Try",
"to",
"load",
"the",
"certificate",
"form",
"the",
"file",
"if",
"the",
"server",
"we",
"ve",
"connected",
"is",
"a",
"known",
"server",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/security/TrustOnFirstUseTrustManager.java#L76-L102 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/security/TrustOnFirstUseTrustManager.java | TrustOnFirstUseTrustManager.fingerprint | public static String fingerprint( X509Certificate cert ) throws CertificateException
{
try
{
MessageDigest md = MessageDigest.getInstance( "SHA-512" );
md.update( cert.getEncoded() );
return ByteBufUtil.hexDump( md.digest() );
}
catch( NoSuchAlgorithmException e )
{
// SHA-1 not available
throw new CertificateException( "Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e.getMessage(), e );
}
} | java | public static String fingerprint( X509Certificate cert ) throws CertificateException
{
try
{
MessageDigest md = MessageDigest.getInstance( "SHA-512" );
md.update( cert.getEncoded() );
return ByteBufUtil.hexDump( md.digest() );
}
catch( NoSuchAlgorithmException e )
{
// SHA-1 not available
throw new CertificateException( "Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e.getMessage(), e );
}
} | [
"public",
"static",
"String",
"fingerprint",
"(",
"X509Certificate",
"cert",
")",
"throws",
"CertificateException",
"{",
"try",
"{",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA-512\"",
")",
";",
"md",
".",
"update",
"(",
"cert",
... | Calculate the certificate fingerprint - simply the SHA-512 hash of the DER-encoded certificate. | [
"Calculate",
"the",
"certificate",
"fingerprint",
"-",
"simply",
"the",
"SHA",
"-",
"512",
"hash",
"of",
"the",
"DER",
"-",
"encoded",
"certificate",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/security/TrustOnFirstUseTrustManager.java#L202-L215 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/cluster/Rediscovery.java | Rediscovery.lookupClusterComposition | public CompletionStage<ClusterComposition> lookupClusterComposition( RoutingTable routingTable,
ConnectionPool connectionPool )
{
CompletableFuture<ClusterComposition> result = new CompletableFuture<>();
lookupClusterComposition( routingTable, connectionPool, 0, 0, result );
return result;
} | java | public CompletionStage<ClusterComposition> lookupClusterComposition( RoutingTable routingTable,
ConnectionPool connectionPool )
{
CompletableFuture<ClusterComposition> result = new CompletableFuture<>();
lookupClusterComposition( routingTable, connectionPool, 0, 0, result );
return result;
} | [
"public",
"CompletionStage",
"<",
"ClusterComposition",
">",
"lookupClusterComposition",
"(",
"RoutingTable",
"routingTable",
",",
"ConnectionPool",
"connectionPool",
")",
"{",
"CompletableFuture",
"<",
"ClusterComposition",
">",
"result",
"=",
"new",
"CompletableFuture",
... | Given the current routing table and connection pool, use the connection composition provider to fetch a new
cluster composition, which would be used to update the routing table and connection pool.
@param routingTable current routing table.
@param connectionPool connection pool.
@return new cluster composition. | [
"Given",
"the",
"current",
"routing",
"table",
"and",
"connection",
"pool",
"use",
"the",
"connection",
"composition",
"provider",
"to",
"fetch",
"a",
"new",
"cluster",
"composition",
"which",
"would",
"be",
"used",
"to",
"update",
"the",
"routing",
"table",
"... | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/cluster/Rediscovery.java#L87-L93 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.saveX509Cert | public static void saveX509Cert( String certStr, File certFile ) throws IOException
{
try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) )
{
writer.write( BEGIN_CERT );
writer.newLine();
writer.write( certStr );
writer.newLine();
writer.write( END_CERT );
writer.newLine();
}
} | java | public static void saveX509Cert( String certStr, File certFile ) throws IOException
{
try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) )
{
writer.write( BEGIN_CERT );
writer.newLine();
writer.write( certStr );
writer.newLine();
writer.write( END_CERT );
writer.newLine();
}
} | [
"public",
"static",
"void",
"saveX509Cert",
"(",
"String",
"certStr",
",",
"File",
"certFile",
")",
"throws",
"IOException",
"{",
"try",
"(",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"certFile",
")",
")",
")",
... | Save a certificate to a file in base 64 binary format with BEGIN and END strings
@param certStr
@param certFile
@throws IOException | [
"Save",
"a",
"certificate",
"to",
"a",
"file",
"in",
"base",
"64",
"binary",
"format",
"with",
"BEGIN",
"and",
"END",
"strings"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L49-L62 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.saveX509Cert | public static void saveX509Cert( Certificate cert, File certFile ) throws GeneralSecurityException, IOException
{
saveX509Cert( new Certificate[]{cert}, certFile );
} | java | public static void saveX509Cert( Certificate cert, File certFile ) throws GeneralSecurityException, IOException
{
saveX509Cert( new Certificate[]{cert}, certFile );
} | [
"public",
"static",
"void",
"saveX509Cert",
"(",
"Certificate",
"cert",
",",
"File",
"certFile",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"saveX509Cert",
"(",
"new",
"Certificate",
"[",
"]",
"{",
"cert",
"}",
",",
"certFile",
")",
";... | Save a certificate to a file. Remove all the content in the file if there is any before.
@param cert
@param certFile
@throws GeneralSecurityException
@throws IOException | [
"Save",
"a",
"certificate",
"to",
"a",
"file",
".",
"Remove",
"all",
"the",
"content",
"in",
"the",
"file",
"if",
"there",
"is",
"any",
"before",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L72-L75 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.saveX509Cert | public static void saveX509Cert( Certificate[] certs, File certFile ) throws GeneralSecurityException, IOException
{
try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) )
{
for ( Certificate cert : certs )
{
String certStr = Base64.getEncoder().encodeToString( cert.getEncoded() ).replaceAll( "(.{64})", "$1\n" );
writer.write( BEGIN_CERT );
writer.newLine();
writer.write( certStr );
writer.newLine();
writer.write( END_CERT );
writer.newLine();
}
}
} | java | public static void saveX509Cert( Certificate[] certs, File certFile ) throws GeneralSecurityException, IOException
{
try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) )
{
for ( Certificate cert : certs )
{
String certStr = Base64.getEncoder().encodeToString( cert.getEncoded() ).replaceAll( "(.{64})", "$1\n" );
writer.write( BEGIN_CERT );
writer.newLine();
writer.write( certStr );
writer.newLine();
writer.write( END_CERT );
writer.newLine();
}
}
} | [
"public",
"static",
"void",
"saveX509Cert",
"(",
"Certificate",
"[",
"]",
"certs",
",",
"File",
"certFile",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"try",
"(",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"Fil... | Save a list of certificates into a file
@param certs
@param certFile
@throws GeneralSecurityException
@throws IOException | [
"Save",
"a",
"list",
"of",
"certificates",
"into",
"a",
"file"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L85-L103 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.loadX509Cert | public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException
{
try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) )
{
CertificateFactory certFactory = CertificateFactory.getInstance( "X.509" );
int certCount = 0; // The file might contain multiple certs
while ( inputStream.available() > 0 )
{
try
{
Certificate cert = certFactory.generateCertificate( inputStream );
certCount++;
loadX509Cert( cert, "neo4j.javadriver.trustedcert." + certCount, keyStore );
}
catch ( CertificateException e )
{
if ( e.getCause() != null && e.getCause().getMessage().equals( "Empty input" ) )
{
// This happens if there is whitespace at the end of the certificate - we load one cert, and then try and load a
// second cert, at which point we fail
return;
}
throw new IOException( "Failed to load certificate from `" + certFile.getAbsolutePath() + "`: " + certCount + " : " + e.getMessage(), e );
}
}
}
} | java | public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException
{
try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) )
{
CertificateFactory certFactory = CertificateFactory.getInstance( "X.509" );
int certCount = 0; // The file might contain multiple certs
while ( inputStream.available() > 0 )
{
try
{
Certificate cert = certFactory.generateCertificate( inputStream );
certCount++;
loadX509Cert( cert, "neo4j.javadriver.trustedcert." + certCount, keyStore );
}
catch ( CertificateException e )
{
if ( e.getCause() != null && e.getCause().getMessage().equals( "Empty input" ) )
{
// This happens if there is whitespace at the end of the certificate - we load one cert, and then try and load a
// second cert, at which point we fail
return;
}
throw new IOException( "Failed to load certificate from `" + certFile.getAbsolutePath() + "`: " + certCount + " : " + e.getMessage(), e );
}
}
}
} | [
"public",
"static",
"void",
"loadX509Cert",
"(",
"File",
"certFile",
",",
"KeyStore",
"keyStore",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"try",
"(",
"BufferedInputStream",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"Fi... | Load the certificates written in X.509 format in a file to a key store.
@param certFile
@param keyStore
@throws GeneralSecurityException
@throws IOException | [
"Load",
"the",
"certificates",
"written",
"in",
"X",
".",
"509",
"format",
"in",
"a",
"file",
"to",
"a",
"key",
"store",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L113-L140 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.loadX509Cert | public static void loadX509Cert( Certificate cert, String certAlias, KeyStore keyStore ) throws KeyStoreException
{
keyStore.setCertificateEntry( certAlias, cert );
} | java | public static void loadX509Cert( Certificate cert, String certAlias, KeyStore keyStore ) throws KeyStoreException
{
keyStore.setCertificateEntry( certAlias, cert );
} | [
"public",
"static",
"void",
"loadX509Cert",
"(",
"Certificate",
"cert",
",",
"String",
"certAlias",
",",
"KeyStore",
"keyStore",
")",
"throws",
"KeyStoreException",
"{",
"keyStore",
".",
"setCertificateEntry",
"(",
"certAlias",
",",
"cert",
")",
";",
"}"
] | Load a certificate to a key store with a name
@param certAlias a name to identify different certificates
@param cert
@param keyStore | [
"Load",
"a",
"certificate",
"to",
"a",
"key",
"store",
"with",
"a",
"name"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L149-L152 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.X509CertToString | public static String X509CertToString( String cert )
{
String cert64CharPerLine = cert.replaceAll( "(.{64})", "$1\n" );
return BEGIN_CERT + "\n" + cert64CharPerLine + "\n"+ END_CERT + "\n";
} | java | public static String X509CertToString( String cert )
{
String cert64CharPerLine = cert.replaceAll( "(.{64})", "$1\n" );
return BEGIN_CERT + "\n" + cert64CharPerLine + "\n"+ END_CERT + "\n";
} | [
"public",
"static",
"String",
"X509CertToString",
"(",
"String",
"cert",
")",
"{",
"String",
"cert64CharPerLine",
"=",
"cert",
".",
"replaceAll",
"(",
"\"(.{64})\"",
",",
"\"$1\\n\"",
")",
";",
"return",
"BEGIN_CERT",
"+",
"\"\\n\"",
"+",
"cert64CharPerLine",
"+... | Convert a certificate in base 64 binary format with BEGIN and END strings
@param cert encoded cert string
@return | [
"Convert",
"a",
"certificate",
"in",
"base",
"64",
"binary",
"format",
"with",
"BEGIN",
"and",
"END",
"strings"
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L159-L163 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/Statement.java | Statement.withUpdatedParameters | public Statement withUpdatedParameters( Value updates )
{
if ( updates == null || updates.isEmpty() )
{
return this;
}
else
{
Map<String,Value> newParameters = newHashMapWithSize( Math.max( parameters.size(), updates.size() ) );
newParameters.putAll( parameters.asMap( ofValue() ) );
for ( Map.Entry<String, Value> entry : updates.asMap( ofValue() ).entrySet() )
{
Value value = entry.getValue();
if ( value.isNull() )
{
newParameters.remove( entry.getKey() );
}
else
{
newParameters.put( entry.getKey(), value );
}
}
return withParameters( value(newParameters) );
}
} | java | public Statement withUpdatedParameters( Value updates )
{
if ( updates == null || updates.isEmpty() )
{
return this;
}
else
{
Map<String,Value> newParameters = newHashMapWithSize( Math.max( parameters.size(), updates.size() ) );
newParameters.putAll( parameters.asMap( ofValue() ) );
for ( Map.Entry<String, Value> entry : updates.asMap( ofValue() ).entrySet() )
{
Value value = entry.getValue();
if ( value.isNull() )
{
newParameters.remove( entry.getKey() );
}
else
{
newParameters.put( entry.getKey(), value );
}
}
return withParameters( value(newParameters) );
}
} | [
"public",
"Statement",
"withUpdatedParameters",
"(",
"Value",
"updates",
")",
"{",
"if",
"(",
"updates",
"==",
"null",
"||",
"updates",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"else",
"{",
"Map",
"<",
"String",
",",
"Value",
">"... | Create a new statement with new parameters derived by updating this'
statement's parameters using the given updates.
Every update key that points to a null value will be removed from
the new statement's parameters. All other entries will just replace
any existing parameter in the new statement.
@param updates describing how to update the parameters
@return a new statement with updated parameters | [
"Create",
"a",
"new",
"statement",
"with",
"new",
"parameters",
"derived",
"by",
"updating",
"this",
"statement",
"s",
"parameters",
"using",
"the",
"given",
"updates",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/Statement.java#L144-L168 | train |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/BoltServerAddress.java | BoltServerAddress.resolve | public BoltServerAddress resolve() throws UnknownHostException
{
String ipAddress = InetAddress.getByName( host ).getHostAddress();
if ( ipAddress.equals( host ) )
{
return this;
}
else
{
return new BoltServerAddress( host, ipAddress, port );
}
} | java | public BoltServerAddress resolve() throws UnknownHostException
{
String ipAddress = InetAddress.getByName( host ).getHostAddress();
if ( ipAddress.equals( host ) )
{
return this;
}
else
{
return new BoltServerAddress( host, ipAddress, port );
}
} | [
"public",
"BoltServerAddress",
"resolve",
"(",
")",
"throws",
"UnknownHostException",
"{",
"String",
"ipAddress",
"=",
"InetAddress",
".",
"getByName",
"(",
"host",
")",
".",
"getHostAddress",
"(",
")",
";",
"if",
"(",
"ipAddress",
".",
"equals",
"(",
"host",
... | Resolve the host name down to an IP address, if not already resolved.
@return this instance if already resolved, otherwise a new address instance
@throws UnknownHostException if no IP address for the host could be found
@see InetAddress#getByName(String) | [
"Resolve",
"the",
"host",
"name",
"down",
"to",
"an",
"IP",
"address",
"if",
"not",
"already",
"resolved",
"."
] | 8dad6c48251fa1ab7017e72d9998a24fa2337a22 | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/BoltServerAddress.java#L121-L132 | train |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java | GoogleConnector.getInstance | public static GoogleConnector getInstance() {
if (instance == null) {
try {
instance = new GoogleConnector();
} catch (Exception e) {
throw new RuntimeException("The GoogleConnector could not be instanced!", e);
}
}
return instance;
} | java | public static GoogleConnector getInstance() {
if (instance == null) {
try {
instance = new GoogleConnector();
} catch (Exception e) {
throw new RuntimeException("The GoogleConnector could not be instanced!", e);
}
}
return instance;
} | [
"public",
"static",
"GoogleConnector",
"getInstance",
"(",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"try",
"{",
"instance",
"=",
"new",
"GoogleConnector",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"Ru... | On demand instance creator method used to get the single instance of this
google authenticator class.
@return The single instance of this class, if the instance does not exist,
this is immediately created. | [
"On",
"demand",
"instance",
"creator",
"method",
"used",
"to",
"get",
"the",
"single",
"instance",
"of",
"this",
"google",
"authenticator",
"class",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java#L116-L125 | train |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java | GoogleConnector.removeCredential | synchronized void removeCredential(String accountId) throws IOException {
DataStore<StoredCredential> sc = StoredCredential.getDefaultDataStore(dataStoreFactory);
sc.delete(accountId);
calendarService = null;
geoService = null;
} | java | synchronized void removeCredential(String accountId) throws IOException {
DataStore<StoredCredential> sc = StoredCredential.getDefaultDataStore(dataStoreFactory);
sc.delete(accountId);
calendarService = null;
geoService = null;
} | [
"synchronized",
"void",
"removeCredential",
"(",
"String",
"accountId",
")",
"throws",
"IOException",
"{",
"DataStore",
"<",
"StoredCredential",
">",
"sc",
"=",
"StoredCredential",
".",
"getDefaultDataStore",
"(",
"dataStoreFactory",
")",
";",
"sc",
".",
"delete",
... | Deletes the stored credentials for the given account id. This means the
next time the user must authorize the app to access his calendars.
@param accountId
The identifier of the account. | [
"Deletes",
"the",
"stored",
"credentials",
"for",
"the",
"given",
"account",
"id",
".",
"This",
"means",
"the",
"next",
"time",
"the",
"user",
"must",
"authorize",
"the",
"app",
"to",
"access",
"his",
"calendars",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java#L146-L151 | train |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java | GoogleConnector.isAuthorized | boolean isAuthorized(String accountId) {
try {
DataStore<StoredCredential> sc = StoredCredential.getDefaultDataStore(dataStoreFactory);
return sc.containsKey(accountId);
} catch (IOException e) {
return false;
}
} | java | boolean isAuthorized(String accountId) {
try {
DataStore<StoredCredential> sc = StoredCredential.getDefaultDataStore(dataStoreFactory);
return sc.containsKey(accountId);
} catch (IOException e) {
return false;
}
} | [
"boolean",
"isAuthorized",
"(",
"String",
"accountId",
")",
"{",
"try",
"{",
"DataStore",
"<",
"StoredCredential",
">",
"sc",
"=",
"StoredCredential",
".",
"getDefaultDataStore",
"(",
"dataStoreFactory",
")",
";",
"return",
"sc",
".",
"containsKey",
"(",
"accoun... | Checks if the given account id has already been authorized and the
user granted access to his calendars info.
@param accountId
The identifier of the account used internally by the application.
@return {@code true} if the account has already been set up, otherwise
{@code false}. | [
"Checks",
"if",
"the",
"given",
"account",
"id",
"has",
"already",
"been",
"authorized",
"and",
"the",
"user",
"granted",
"access",
"to",
"his",
"calendars",
"info",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java#L162-L169 | train |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java | GoogleConnector.getCalendarService | public synchronized GoogleCalendarService getCalendarService(String accountId) throws IOException {
if (calendarService == null) {
Credential credential = impl_getStoredCredential(accountId);
if (credential == null) {
throw new UnsupportedOperationException("The account has not been authorized yet!");
}
calendarService = new GoogleCalendarService(impl_createService(credential));
}
return calendarService;
} | java | public synchronized GoogleCalendarService getCalendarService(String accountId) throws IOException {
if (calendarService == null) {
Credential credential = impl_getStoredCredential(accountId);
if (credential == null) {
throw new UnsupportedOperationException("The account has not been authorized yet!");
}
calendarService = new GoogleCalendarService(impl_createService(credential));
}
return calendarService;
} | [
"public",
"synchronized",
"GoogleCalendarService",
"getCalendarService",
"(",
"String",
"accountId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"calendarService",
"==",
"null",
")",
"{",
"Credential",
"credential",
"=",
"impl_getStoredCredential",
"(",
"accountId",
... | Instances a new calendar service for the given google account user name.
This requires previous authorization to get the service, so if the user
has not granted access to his data, this method will start the
authorization process automatically; this attempts to open the login google page in the
default browser.
@param accountId
The google account.
@return The calendar service, this can be null if the account cannot be
authenticated.
@throws IOException If the account has not been authenticated. | [
"Instances",
"a",
"new",
"calendar",
"service",
"for",
"the",
"given",
"google",
"account",
"user",
"name",
".",
"This",
"requires",
"previous",
"authorization",
"to",
"get",
"the",
"service",
"so",
"if",
"the",
"user",
"has",
"not",
"granted",
"access",
"to... | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java#L206-L215 | train |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java | GoogleConnector.getAccountInfo | GoogleAccount getAccountInfo(String accountId) throws IOException {
Credential credential = impl_getStoredCredential(accountId);
if (credential == null) {
throw new UnsupportedOperationException("The account has not been authorized yet!");
}
Userinfoplus info = impl_requestUserInfo(credential);
GoogleAccount account = new GoogleAccount();
account.setId(accountId);
account.setName(info.getName());
return account;
} | java | GoogleAccount getAccountInfo(String accountId) throws IOException {
Credential credential = impl_getStoredCredential(accountId);
if (credential == null) {
throw new UnsupportedOperationException("The account has not been authorized yet!");
}
Userinfoplus info = impl_requestUserInfo(credential);
GoogleAccount account = new GoogleAccount();
account.setId(accountId);
account.setName(info.getName());
return account;
} | [
"GoogleAccount",
"getAccountInfo",
"(",
"String",
"accountId",
")",
"throws",
"IOException",
"{",
"Credential",
"credential",
"=",
"impl_getStoredCredential",
"(",
"accountId",
")",
";",
"if",
"(",
"credential",
"==",
"null",
")",
"{",
"throw",
"new",
"Unsupported... | Requests the user info for the given account. This requires previous
authorization from the user, so this might start the process.
@param accountId
The id of the account to get the user info.
@return The user info bean.
@throws IOException If the account cannot be accessed. | [
"Requests",
"the",
"user",
"info",
"for",
"the",
"given",
"account",
".",
"This",
"requires",
"previous",
"authorization",
"from",
"the",
"user",
"so",
"this",
"might",
"start",
"the",
"process",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/service/GoogleConnector.java#L226-L236 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java | AllDayView.extraPaddingProperty | public final ObjectProperty<Insets> extraPaddingProperty() {
if (extraPadding == null) {
extraPadding = new StyleableObjectProperty<Insets>(new Insets(2, 0,
9, 0)) {
@Override
public CssMetaData<AllDayView, Insets> getCssMetaData() {
return StyleableProperties.EXTRA_PADDING;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "extraPadding"; //$NON-NLS-1$
}
};
}
return extraPadding;
} | java | public final ObjectProperty<Insets> extraPaddingProperty() {
if (extraPadding == null) {
extraPadding = new StyleableObjectProperty<Insets>(new Insets(2, 0,
9, 0)) {
@Override
public CssMetaData<AllDayView, Insets> getCssMetaData() {
return StyleableProperties.EXTRA_PADDING;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "extraPadding"; //$NON-NLS-1$
}
};
}
return extraPadding;
} | [
"public",
"final",
"ObjectProperty",
"<",
"Insets",
">",
"extraPaddingProperty",
"(",
")",
"{",
"if",
"(",
"extraPadding",
"==",
"null",
")",
"{",
"extraPadding",
"=",
"new",
"StyleableObjectProperty",
"<",
"Insets",
">",
"(",
"new",
"Insets",
"(",
"2",
",",... | Extra padding to be used inside of the view above and below the full day
entries. This is required as the regular padding is already used for
other styling purposes.
@return insets for extra padding | [
"Extra",
"padding",
"to",
"be",
"used",
"inside",
"of",
"the",
"view",
"above",
"and",
"below",
"the",
"full",
"day",
"entries",
".",
"This",
"is",
"required",
"as",
"the",
"regular",
"padding",
"is",
"already",
"used",
"for",
"other",
"styling",
"purposes... | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java#L124-L147 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java | AllDayView.rowHeightProperty | public final DoubleProperty rowHeightProperty() {
if (rowHeight == null) {
rowHeight = new StyleableDoubleProperty(20) {
@Override
public CssMetaData<AllDayView, Number> getCssMetaData() {
return StyleableProperties.ROW_HEIGHT;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "rowHeight"; //$NON-NLS-1$
}
};
}
return rowHeight;
} | java | public final DoubleProperty rowHeightProperty() {
if (rowHeight == null) {
rowHeight = new StyleableDoubleProperty(20) {
@Override
public CssMetaData<AllDayView, Number> getCssMetaData() {
return StyleableProperties.ROW_HEIGHT;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "rowHeight"; //$NON-NLS-1$
}
};
}
return rowHeight;
} | [
"public",
"final",
"DoubleProperty",
"rowHeightProperty",
"(",
")",
"{",
"if",
"(",
"rowHeight",
"==",
"null",
")",
"{",
"rowHeight",
"=",
"new",
"StyleableDoubleProperty",
"(",
"20",
")",
"{",
"@",
"Override",
"public",
"CssMetaData",
"<",
"AllDayView",
",",
... | The height for each row shown by the view. This value determines the
total height of the view.
@return the row height property | [
"The",
"height",
"for",
"each",
"row",
"shown",
"by",
"the",
"view",
".",
"This",
"value",
"determines",
"the",
"total",
"height",
"of",
"the",
"view",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java#L177-L199 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java | AllDayView.rowSpacingProperty | public final DoubleProperty rowSpacingProperty() {
if (rowSpacing == null) {
rowSpacing = new StyleableDoubleProperty(2) {
@Override
public CssMetaData<AllDayView, Number> getCssMetaData() {
return StyleableProperties.ROW_SPACING;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "rowSpacing"; //$NON-NLS-1$
}
};
}
return rowSpacing;
} | java | public final DoubleProperty rowSpacingProperty() {
if (rowSpacing == null) {
rowSpacing = new StyleableDoubleProperty(2) {
@Override
public CssMetaData<AllDayView, Number> getCssMetaData() {
return StyleableProperties.ROW_SPACING;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "rowSpacing"; //$NON-NLS-1$
}
};
}
return rowSpacing;
} | [
"public",
"final",
"DoubleProperty",
"rowSpacingProperty",
"(",
")",
"{",
"if",
"(",
"rowSpacing",
"==",
"null",
")",
"{",
"rowSpacing",
"=",
"new",
"StyleableDoubleProperty",
"(",
"2",
")",
"{",
"@",
"Override",
"public",
"CssMetaData",
"<",
"AllDayView",
","... | Stores the spacing between rows in the view.
@return the spacing between rows in pixels | [
"Stores",
"the",
"spacing",
"between",
"rows",
"in",
"the",
"view",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java#L227-L249 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java | AllDayView.columnSpacingProperty | public final DoubleProperty columnSpacingProperty() {
if (columnSpacing == null) {
columnSpacing = new StyleableDoubleProperty(2) {
@Override
public CssMetaData<AllDayView, Number> getCssMetaData() {
return StyleableProperties.COLUMN_SPACING;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "columnSpacing"; //$NON-NLS-1$
}
};
}
return columnSpacing;
} | java | public final DoubleProperty columnSpacingProperty() {
if (columnSpacing == null) {
columnSpacing = new StyleableDoubleProperty(2) {
@Override
public CssMetaData<AllDayView, Number> getCssMetaData() {
return StyleableProperties.COLUMN_SPACING;
}
@Override
public Object getBean() {
return AllDayView.this;
}
@Override
public String getName() {
return "columnSpacing"; //$NON-NLS-1$
}
};
}
return columnSpacing;
} | [
"public",
"final",
"DoubleProperty",
"columnSpacingProperty",
"(",
")",
"{",
"if",
"(",
"columnSpacing",
"==",
"null",
")",
"{",
"columnSpacing",
"=",
"new",
"StyleableDoubleProperty",
"(",
"2",
")",
"{",
"@",
"Override",
"public",
"CssMetaData",
"<",
"AllDayVie... | Stores the spacing between columns in the view.
@return the spacing between columns in pixels | [
"Stores",
"the",
"spacing",
"between",
"columns",
"in",
"the",
"view",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/AllDayView.java#L281-L303 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/print/PrintView.java | PrintView.show | public void show(Window owner) {
InvalidationListener viewTypeListener = obs -> loadDropDownValues(getDate());
if (dialog != null) {
dialog.show();
} else {
TimeRangeView timeRange = getSettingsView().getTimeRangeView();
Scene scene = new Scene(this);
dialog = new Stage();
dialog.initOwner(owner);
dialog.setScene(scene);
dialog.sizeToScene();
dialog.centerOnScreen();
dialog.setTitle(Messages.getString("PrintView.TITLE_LABEL"));
dialog.initModality(Modality.APPLICATION_MODAL);
if (getPrintIcon() != null)
dialog.getIcons().add(getPrintIcon());
dialog.setOnHidden(obs -> {
timeRange.cleanOldValues();
timeRange.viewTypeProperty().removeListener(viewTypeListener);
});
dialog.setOnShown(obs -> timeRange.viewTypeProperty().addListener(viewTypeListener));
dialog.show();
}
} | java | public void show(Window owner) {
InvalidationListener viewTypeListener = obs -> loadDropDownValues(getDate());
if (dialog != null) {
dialog.show();
} else {
TimeRangeView timeRange = getSettingsView().getTimeRangeView();
Scene scene = new Scene(this);
dialog = new Stage();
dialog.initOwner(owner);
dialog.setScene(scene);
dialog.sizeToScene();
dialog.centerOnScreen();
dialog.setTitle(Messages.getString("PrintView.TITLE_LABEL"));
dialog.initModality(Modality.APPLICATION_MODAL);
if (getPrintIcon() != null)
dialog.getIcons().add(getPrintIcon());
dialog.setOnHidden(obs -> {
timeRange.cleanOldValues();
timeRange.viewTypeProperty().removeListener(viewTypeListener);
});
dialog.setOnShown(obs -> timeRange.viewTypeProperty().addListener(viewTypeListener));
dialog.show();
}
} | [
"public",
"void",
"show",
"(",
"Window",
"owner",
")",
"{",
"InvalidationListener",
"viewTypeListener",
"=",
"obs",
"->",
"loadDropDownValues",
"(",
"getDate",
"(",
")",
")",
";",
"if",
"(",
"dialog",
"!=",
"null",
")",
"{",
"dialog",
".",
"show",
"(",
"... | Creates an application-modal dialog and shows it after adding the print
view to it.
@param owner
the owner window of the dialog | [
"Creates",
"an",
"application",
"-",
"modal",
"dialog",
"and",
"shows",
"it",
"after",
"adding",
"the",
"print",
"view",
"to",
"it",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/print/PrintView.java#L417-L444 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/values/RRule.java | RRule.approximateIntervalInDays | public int approximateIntervalInDays() {
int freqLengthDays;
int nPerPeriod = 0;
switch (this.freq) {
case DAILY:
freqLengthDays = 1;
break;
case WEEKLY:
freqLengthDays = 7;
if (!this.byDay.isEmpty()) {
nPerPeriod = this.byDay.size();
}
break;
case MONTHLY:
freqLengthDays = 30;
if (!this.byDay.isEmpty()) {
for (WeekdayNum day : byDay) {
// if it's every weekday in the month, assume four of that weekday,
// otherwise there is one of that week-in-month,weekday pair
nPerPeriod += 0 != day.num ? 1 : 4;
}
} else {
nPerPeriod = this.byMonthDay.length;
}
break;
case YEARLY:
freqLengthDays = 365;
int monthCount = 12;
if (0 != this.byMonth.length) {
monthCount = this.byMonth.length;
}
if (!this.byDay.isEmpty()) {
for (WeekdayNum day : byDay) {
// if it's every weekend in the months in the year,
// assume 4 of that weekday per month,
// otherwise there is one of that week-in-month,weekday pair per
// month
nPerPeriod += (0 != day.num ? 1 : 4) * monthCount;
}
} else if (0 != this.byMonthDay.length) {
nPerPeriod += monthCount * this.byMonthDay.length;
} else {
nPerPeriod += this.byYearDay.length;
}
break;
default:
freqLengthDays = 0;
}
if (0 == nPerPeriod) {
nPerPeriod = 1;
}
return ((freqLengthDays / nPerPeriod) * this.interval);
} | java | public int approximateIntervalInDays() {
int freqLengthDays;
int nPerPeriod = 0;
switch (this.freq) {
case DAILY:
freqLengthDays = 1;
break;
case WEEKLY:
freqLengthDays = 7;
if (!this.byDay.isEmpty()) {
nPerPeriod = this.byDay.size();
}
break;
case MONTHLY:
freqLengthDays = 30;
if (!this.byDay.isEmpty()) {
for (WeekdayNum day : byDay) {
// if it's every weekday in the month, assume four of that weekday,
// otherwise there is one of that week-in-month,weekday pair
nPerPeriod += 0 != day.num ? 1 : 4;
}
} else {
nPerPeriod = this.byMonthDay.length;
}
break;
case YEARLY:
freqLengthDays = 365;
int monthCount = 12;
if (0 != this.byMonth.length) {
monthCount = this.byMonth.length;
}
if (!this.byDay.isEmpty()) {
for (WeekdayNum day : byDay) {
// if it's every weekend in the months in the year,
// assume 4 of that weekday per month,
// otherwise there is one of that week-in-month,weekday pair per
// month
nPerPeriod += (0 != day.num ? 1 : 4) * monthCount;
}
} else if (0 != this.byMonthDay.length) {
nPerPeriod += monthCount * this.byMonthDay.length;
} else {
nPerPeriod += this.byYearDay.length;
}
break;
default:
freqLengthDays = 0;
}
if (0 == nPerPeriod) {
nPerPeriod = 1;
}
return ((freqLengthDays / nPerPeriod) * this.interval);
} | [
"public",
"int",
"approximateIntervalInDays",
"(",
")",
"{",
"int",
"freqLengthDays",
";",
"int",
"nPerPeriod",
"=",
"0",
";",
"switch",
"(",
"this",
".",
"freq",
")",
"{",
"case",
"DAILY",
":",
"freqLengthDays",
"=",
"1",
";",
"break",
";",
"case",
"WEE... | an approximate number of days between occurences. | [
"an",
"approximate",
"number",
"of",
"days",
"between",
"occurences",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/values/RRule.java#L150-L205 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/values/RDateList.java | RDateList.toIcal | public String toIcal() {
StringBuilder buf = new StringBuilder();
buf.append(this.getName().toUpperCase());
buf.append(";TZID=\"").append(tzid.getID()).append('"');
buf.append(";VALUE=").append(valueType.toIcal());
if (hasExtParams()) {
for (Map.Entry<String, String> param : getExtParams().entrySet()) {
String k = param.getKey(),
v = param.getValue();
if (ICAL_SPECIALS.matcher(v).find()) {
v = "\"" + v + "\"";
}
buf.append(';').append(k).append('=').append(v);
}
}
buf.append(':');
for (int i = 0; i < datesUtc.length; ++i) {
if (0 != i) {
buf.append(',');
}
DateValue v = datesUtc[i];
buf.append(v);
if (v instanceof TimeValue) {
buf.append('Z');
}
}
return buf.toString();
} | java | public String toIcal() {
StringBuilder buf = new StringBuilder();
buf.append(this.getName().toUpperCase());
buf.append(";TZID=\"").append(tzid.getID()).append('"');
buf.append(";VALUE=").append(valueType.toIcal());
if (hasExtParams()) {
for (Map.Entry<String, String> param : getExtParams().entrySet()) {
String k = param.getKey(),
v = param.getValue();
if (ICAL_SPECIALS.matcher(v).find()) {
v = "\"" + v + "\"";
}
buf.append(';').append(k).append('=').append(v);
}
}
buf.append(':');
for (int i = 0; i < datesUtc.length; ++i) {
if (0 != i) {
buf.append(',');
}
DateValue v = datesUtc[i];
buf.append(v);
if (v instanceof TimeValue) {
buf.append('Z');
}
}
return buf.toString();
} | [
"public",
"String",
"toIcal",
"(",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"this",
".",
"getName",
"(",
")",
".",
"toUpperCase",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\";TZID=... | returns a String containing ical content lines. | [
"returns",
"a",
"String",
"containing",
"ical",
"content",
"lines",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/values/RDateList.java#L86-L113 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java | Filters.byDayFilter | static Predicate<DateValue> byDayFilter(
final WeekdayNum[] days, final boolean weeksInYear, final Weekday wkst) {
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
Weekday dow = Weekday.valueOf(date);
int nDays;
// first day of the week in the given year or month
Weekday dow0;
// where does date appear in the year or month?
// in [0, lengthOfMonthOrYear - 1]
int instance;
if (weeksInYear) {
nDays = TimeUtils.yearLength(date.year());
dow0 = Weekday.firstDayOfWeekInMonth(date.year(), 1);
instance = TimeUtils.dayOfYear(
date.year(), date.month(), date.day());
} else {
nDays = TimeUtils.monthLength(date.year(), date.month());
dow0 = Weekday.firstDayOfWeekInMonth(date.year(), date.month());
instance = date.day() - 1;
}
// which week of the year or month does this date fall on?
// one-indexed
int dateWeekNo;
if (wkst.javaDayNum <= dow.javaDayNum) {
dateWeekNo = 1 + (instance / 7);
} else {
dateWeekNo = (instance / 7);
}
// TODO(msamuel): according to section 4.3.10
// Week number one of the calendar year is the first week which
// contains at least four (4) days in that calendar year. This
// rule part is only valid for YEARLY rules.
// That's mentioned under the BYWEEKNO rule, and there's no mention
// of it in the earlier discussion of the BYDAY rule.
// Does it apply to yearly week numbers calculated for BYDAY rules in
// a FREQ=YEARLY rule?
for (int i = days.length; --i >= 0; ) {
WeekdayNum day = days[i];
if (day.wday == dow) {
int weekNo = day.num;
if (0 == weekNo) {
return true;
}
if (weekNo < 0) {
weekNo = Util.invertWeekdayNum(day, dow0, nDays);
}
if (dateWeekNo == weekNo) {
return true;
}
}
}
return false;
}
};
} | java | static Predicate<DateValue> byDayFilter(
final WeekdayNum[] days, final boolean weeksInYear, final Weekday wkst) {
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
Weekday dow = Weekday.valueOf(date);
int nDays;
// first day of the week in the given year or month
Weekday dow0;
// where does date appear in the year or month?
// in [0, lengthOfMonthOrYear - 1]
int instance;
if (weeksInYear) {
nDays = TimeUtils.yearLength(date.year());
dow0 = Weekday.firstDayOfWeekInMonth(date.year(), 1);
instance = TimeUtils.dayOfYear(
date.year(), date.month(), date.day());
} else {
nDays = TimeUtils.monthLength(date.year(), date.month());
dow0 = Weekday.firstDayOfWeekInMonth(date.year(), date.month());
instance = date.day() - 1;
}
// which week of the year or month does this date fall on?
// one-indexed
int dateWeekNo;
if (wkst.javaDayNum <= dow.javaDayNum) {
dateWeekNo = 1 + (instance / 7);
} else {
dateWeekNo = (instance / 7);
}
// TODO(msamuel): according to section 4.3.10
// Week number one of the calendar year is the first week which
// contains at least four (4) days in that calendar year. This
// rule part is only valid for YEARLY rules.
// That's mentioned under the BYWEEKNO rule, and there's no mention
// of it in the earlier discussion of the BYDAY rule.
// Does it apply to yearly week numbers calculated for BYDAY rules in
// a FREQ=YEARLY rule?
for (int i = days.length; --i >= 0; ) {
WeekdayNum day = days[i];
if (day.wday == dow) {
int weekNo = day.num;
if (0 == weekNo) {
return true;
}
if (weekNo < 0) {
weekNo = Util.invertWeekdayNum(day, dow0, nDays);
}
if (dateWeekNo == weekNo) {
return true;
}
}
}
return false;
}
};
} | [
"static",
"Predicate",
"<",
"DateValue",
">",
"byDayFilter",
"(",
"final",
"WeekdayNum",
"[",
"]",
"days",
",",
"final",
"boolean",
"weeksInYear",
",",
"final",
"Weekday",
"wkst",
")",
"{",
"return",
"new",
"Predicate",
"<",
"DateValue",
">",
"(",
")",
"{"... | constructs a day filter based on a BYDAY rule.
@param days non null
@param weeksInYear are the week numbers meant to be weeks in the
current year, or weeks in the current month. | [
"constructs",
"a",
"day",
"filter",
"based",
"on",
"a",
"BYDAY",
"rule",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java#L54-L116 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java | Filters.weekIntervalFilter | static Predicate<DateValue> weekIntervalFilter(
final int interval, final Weekday wkst, final DateValue dtStart) {
return new Predicate<DateValue>() {
DateValue wkStart;
{
// the latest day with day of week wkst on or before dtStart
DTBuilder wkStartB = new DTBuilder(dtStart);
wkStartB.day -=
(7 + Weekday.valueOf(dtStart).javaDayNum - wkst.javaDayNum) % 7;
wkStart = wkStartB.toDate();
}
public boolean apply(DateValue date) {
int daysBetween = TimeUtils.daysBetween(date, wkStart);
if (daysBetween < 0) {
// date must be before dtStart. Shouldn't occur in practice.
daysBetween += (interval * 7 * (1 + daysBetween / (-7 * interval)));
}
int off = (daysBetween / 7) % interval;
return 0 == off;
}
};
} | java | static Predicate<DateValue> weekIntervalFilter(
final int interval, final Weekday wkst, final DateValue dtStart) {
return new Predicate<DateValue>() {
DateValue wkStart;
{
// the latest day with day of week wkst on or before dtStart
DTBuilder wkStartB = new DTBuilder(dtStart);
wkStartB.day -=
(7 + Weekday.valueOf(dtStart).javaDayNum - wkst.javaDayNum) % 7;
wkStart = wkStartB.toDate();
}
public boolean apply(DateValue date) {
int daysBetween = TimeUtils.daysBetween(date, wkStart);
if (daysBetween < 0) {
// date must be before dtStart. Shouldn't occur in practice.
daysBetween += (interval * 7 * (1 + daysBetween / (-7 * interval)));
}
int off = (daysBetween / 7) % interval;
return 0 == off;
}
};
} | [
"static",
"Predicate",
"<",
"DateValue",
">",
"weekIntervalFilter",
"(",
"final",
"int",
"interval",
",",
"final",
"Weekday",
"wkst",
",",
"final",
"DateValue",
"dtStart",
")",
"{",
"return",
"new",
"Predicate",
"<",
"DateValue",
">",
"(",
")",
"{",
"DateVal... | constructs a filter that accepts only every interval-th week from the week
containing dtStart.
@param interval > 0 number of weeks
@param wkst day of the week that the week starts on.
@param dtStart non null | [
"constructs",
"a",
"filter",
"that",
"accepts",
"only",
"every",
"interval",
"-",
"th",
"week",
"from",
"the",
"week",
"containing",
"dtStart",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java#L147-L170 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java | Filters.byMinuteFilter | static Predicate<DateValue> byMinuteFilter(int[] minutes) {
long minutesByBit = 0;
for (int minute : minutes) {
minutesByBit |= 1L << minute;
}
if ((minutesByBit & LOW_60_BITS) == LOW_60_BITS) {
return Predicates.alwaysTrue();
}
final long bitField = minutesByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1L << tv.minute())) != 0;
}
};
} | java | static Predicate<DateValue> byMinuteFilter(int[] minutes) {
long minutesByBit = 0;
for (int minute : minutes) {
minutesByBit |= 1L << minute;
}
if ((minutesByBit & LOW_60_BITS) == LOW_60_BITS) {
return Predicates.alwaysTrue();
}
final long bitField = minutesByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1L << tv.minute())) != 0;
}
};
} | [
"static",
"Predicate",
"<",
"DateValue",
">",
"byMinuteFilter",
"(",
"int",
"[",
"]",
"minutes",
")",
"{",
"long",
"minutesByBit",
"=",
"0",
";",
"for",
"(",
"int",
"minute",
":",
"minutes",
")",
"{",
"minutesByBit",
"|=",
"1L",
"<<",
"minute",
";",
"}... | constructs a minute filter based on a BYMINUTE rule.
@param minutes minutes of the hour in [0, 59] | [
"constructs",
"a",
"minute",
"filter",
"based",
"on",
"a",
"BYMINUTE",
"rule",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java#L203-L221 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java | Filters.bySecondFilter | static Predicate<DateValue> bySecondFilter(int[] seconds) {
long secondsByBit = 0;
for (int second : seconds) {
secondsByBit |= 1L << second;
}
if ((secondsByBit & LOW_60_BITS) == LOW_60_BITS) {
return Predicates.alwaysTrue();
}
final long bitField = secondsByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1L << tv.second())) != 0;
}
};
} | java | static Predicate<DateValue> bySecondFilter(int[] seconds) {
long secondsByBit = 0;
for (int second : seconds) {
secondsByBit |= 1L << second;
}
if ((secondsByBit & LOW_60_BITS) == LOW_60_BITS) {
return Predicates.alwaysTrue();
}
final long bitField = secondsByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1L << tv.second())) != 0;
}
};
} | [
"static",
"Predicate",
"<",
"DateValue",
">",
"bySecondFilter",
"(",
"int",
"[",
"]",
"seconds",
")",
"{",
"long",
"secondsByBit",
"=",
"0",
";",
"for",
"(",
"int",
"second",
":",
"seconds",
")",
"{",
"secondsByBit",
"|=",
"1L",
"<<",
"second",
";",
"}... | constructs a second filter based on a BYMINUTE rule.
@param seconds seconds of the minute in [0, 59] | [
"constructs",
"a",
"second",
"filter",
"based",
"on",
"a",
"BYMINUTE",
"rule",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Filters.java#L228-L246 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/MonthSheetView.java | MonthSheetView.isExtendedMonth | public final boolean isExtendedMonth(YearMonth month) {
if (month != null) {
YearMonth extendedStart = getExtendedStartMonth();
if ((month.equals(extendedStart) || month.isAfter(extendedStart)) && month.isBefore(getStartMonth())) {
return true;
}
YearMonth extendedEnd = getExtendedEndMonth();
if ((month.equals(extendedEnd) || month.isBefore(extendedEnd)) && month.isAfter(getEndMonth())) {
return true;
}
}
return false;
} | java | public final boolean isExtendedMonth(YearMonth month) {
if (month != null) {
YearMonth extendedStart = getExtendedStartMonth();
if ((month.equals(extendedStart) || month.isAfter(extendedStart)) && month.isBefore(getStartMonth())) {
return true;
}
YearMonth extendedEnd = getExtendedEndMonth();
if ((month.equals(extendedEnd) || month.isBefore(extendedEnd)) && month.isAfter(getEndMonth())) {
return true;
}
}
return false;
} | [
"public",
"final",
"boolean",
"isExtendedMonth",
"(",
"YearMonth",
"month",
")",
"{",
"if",
"(",
"month",
"!=",
"null",
")",
"{",
"YearMonth",
"extendedStart",
"=",
"getExtendedStartMonth",
"(",
")",
";",
"if",
"(",
"(",
"month",
".",
"equals",
"(",
"exten... | A simple check to see if the given month is part of the extended months.
@param month the month to check
@return true if the given month is part of the extended months
@see #setExtendedViewUnit(ViewUnit)
@see #setExtendedUnitsBackward(int)
@see #setExtendedUnitsForward(int) | [
"A",
"simple",
"check",
"to",
"see",
"if",
"the",
"given",
"month",
"is",
"part",
"of",
"the",
"extended",
"months",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/MonthSheetView.java#L495-L508 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/MonthSheetView.java | MonthSheetView.isVisibleDate | public final boolean isVisibleDate(LocalDate date) {
if (date != null) {
YearMonth extendedStart = getExtendedStartMonth();
YearMonth extendedEnd = getExtendedEndMonth();
LocalDate startDate = extendedStart.atDay(1);
LocalDate endDate = extendedEnd.atEndOfMonth();
if ((date.equals(startDate) || date.isAfter(startDate)) && (date.equals(endDate) || date.isBefore(endDate))) {
return true;
}
}
return false;
} | java | public final boolean isVisibleDate(LocalDate date) {
if (date != null) {
YearMonth extendedStart = getExtendedStartMonth();
YearMonth extendedEnd = getExtendedEndMonth();
LocalDate startDate = extendedStart.atDay(1);
LocalDate endDate = extendedEnd.atEndOfMonth();
if ((date.equals(startDate) || date.isAfter(startDate)) && (date.equals(endDate) || date.isBefore(endDate))) {
return true;
}
}
return false;
} | [
"public",
"final",
"boolean",
"isVisibleDate",
"(",
"LocalDate",
"date",
")",
"{",
"if",
"(",
"date",
"!=",
"null",
")",
"{",
"YearMonth",
"extendedStart",
"=",
"getExtendedStartMonth",
"(",
")",
";",
"YearMonth",
"extendedEnd",
"=",
"getExtendedEndMonth",
"(",
... | Determines if the given date is currently showing is part of the view. This
method uses the extended start and end months.
@param date the date to check for visibility
@return true if the date is within the time range of the view
@see #getExtendedStartMonth()
@see #getExtendedEndMonth() | [
"Determines",
"if",
"the",
"given",
"date",
"is",
"currently",
"showing",
"is",
"part",
"of",
"the",
"view",
".",
"This",
"method",
"uses",
"the",
"extended",
"start",
"and",
"end",
"months",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/MonthSheetView.java#L519-L532 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/util/TimeUtils.java | TimeUtils.secsSinceEpoch | public static long secsSinceEpoch(DateValue date) {
long result = fixedFromGregorian(date) *
SECS_PER_DAY;
if (date instanceof TimeValue) {
TimeValue time = (TimeValue) date;
result +=
time.second() +
60 * (time.minute() +
60 * time.hour());
}
return result;
} | java | public static long secsSinceEpoch(DateValue date) {
long result = fixedFromGregorian(date) *
SECS_PER_DAY;
if (date instanceof TimeValue) {
TimeValue time = (TimeValue) date;
result +=
time.second() +
60 * (time.minute() +
60 * time.hour());
}
return result;
} | [
"public",
"static",
"long",
"secsSinceEpoch",
"(",
"DateValue",
"date",
")",
"{",
"long",
"result",
"=",
"fixedFromGregorian",
"(",
"date",
")",
"*",
"SECS_PER_DAY",
";",
"if",
"(",
"date",
"instanceof",
"TimeValue",
")",
"{",
"TimeValue",
"time",
"=",
"(",
... | Compute the number of seconds from the Proleptic Gregorian epoch
to the given time. | [
"Compute",
"the",
"number",
"of",
"seconds",
"from",
"the",
"Proleptic",
"Gregorian",
"epoch",
"to",
"the",
"given",
"time",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/util/TimeUtils.java#L249-L260 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/util/TimeUtils.java | TimeUtils.toDateValue | public static DateValue toDateValue(DateValue dv) {
return (!(dv instanceof TimeValue) ? dv
: new DateValueImpl(dv.year(), dv.month(), dv.day()));
} | java | public static DateValue toDateValue(DateValue dv) {
return (!(dv instanceof TimeValue) ? dv
: new DateValueImpl(dv.year(), dv.month(), dv.day()));
} | [
"public",
"static",
"DateValue",
"toDateValue",
"(",
"DateValue",
"dv",
")",
"{",
"return",
"(",
"!",
"(",
"dv",
"instanceof",
"TimeValue",
")",
"?",
"dv",
":",
"new",
"DateValueImpl",
"(",
"dv",
".",
"year",
"(",
")",
",",
"dv",
".",
"month",
"(",
"... | a DateValue with the same year, month, and day as the given instance that
is not a TimeValue. | [
"a",
"DateValue",
"with",
"the",
"same",
"year",
"month",
"and",
"day",
"as",
"the",
"given",
"instance",
"that",
"is",
"not",
"a",
"TimeValue",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/util/TimeUtils.java#L270-L273 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/com/calendarfx/view/Messages.java | Messages.getString | public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
} | java | public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
} | [
"public",
"static",
"String",
"getString",
"(",
"String",
"key",
")",
"{",
"try",
"{",
"return",
"RESOURCE_BUNDLE",
".",
"getString",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"e",
")",
"{",
"return",
"'",
"'",
"+",
"key",
"+",... | Returns the translation for the given key.
@param key the i18n key
@return the translation | [
"Returns",
"the",
"translation",
"for",
"the",
"given",
"key",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/com/calendarfx/view/Messages.java#L41-L47 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/impl/com/calendarfx/view/DayEntryViewSkin.java | DayEntryViewSkin.updateStyles | protected void updateStyles() {
DayEntryView view = getSkinnable();
Entry<?> entry = getEntry();
Calendar calendar = entry.getCalendar();
if (entry instanceof DraggedEntry) {
calendar = ((DraggedEntry) entry).getOriginalCalendar();
}
// when the entry gets removed from its calendar then the calendar can
// be null
if (calendar == null) {
return;
}
view.getStyleClass().setAll("default-style-entry",
calendar.getStyle() + "-entry");
if (entry.isRecurrence()) {
view.getStyleClass().add("recurrence"); //$NON-NLS-1$
}
startTimeLabel.getStyleClass().setAll("start-time-label",
"default-style-entry-time-label",
calendar.getStyle() + "-entry-time-label");
titleLabel.getStyleClass().setAll("title-label",
"default-style-entry-title-label",
calendar.getStyle() + "-entry-title-label");
} | java | protected void updateStyles() {
DayEntryView view = getSkinnable();
Entry<?> entry = getEntry();
Calendar calendar = entry.getCalendar();
if (entry instanceof DraggedEntry) {
calendar = ((DraggedEntry) entry).getOriginalCalendar();
}
// when the entry gets removed from its calendar then the calendar can
// be null
if (calendar == null) {
return;
}
view.getStyleClass().setAll("default-style-entry",
calendar.getStyle() + "-entry");
if (entry.isRecurrence()) {
view.getStyleClass().add("recurrence"); //$NON-NLS-1$
}
startTimeLabel.getStyleClass().setAll("start-time-label",
"default-style-entry-time-label",
calendar.getStyle() + "-entry-time-label");
titleLabel.getStyleClass().setAll("title-label",
"default-style-entry-title-label",
calendar.getStyle() + "-entry-title-label");
} | [
"protected",
"void",
"updateStyles",
"(",
")",
"{",
"DayEntryView",
"view",
"=",
"getSkinnable",
"(",
")",
";",
"Entry",
"<",
"?",
">",
"entry",
"=",
"getEntry",
"(",
")",
";",
"Calendar",
"calendar",
"=",
"entry",
".",
"getCalendar",
"(",
")",
";",
"i... | This methods updates the styles of the node according to the entry
settings. | [
"This",
"methods",
"updates",
"the",
"styles",
"of",
"the",
"node",
"according",
"to",
"the",
"entry",
"settings",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayEntryViewSkin.java#L99-L127 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/impl/com/calendarfx/view/DayEntryViewSkin.java | DayEntryViewSkin.createTitleLabel | protected Label createTitleLabel() {
Label label = new Label();
label.setWrapText(true);
label.setMinSize(0, 0);
return label;
} | java | protected Label createTitleLabel() {
Label label = new Label();
label.setWrapText(true);
label.setMinSize(0, 0);
return label;
} | [
"protected",
"Label",
"createTitleLabel",
"(",
")",
"{",
"Label",
"label",
"=",
"new",
"Label",
"(",
")",
";",
"label",
".",
"setWrapText",
"(",
"true",
")",
";",
"label",
".",
"setMinSize",
"(",
"0",
",",
"0",
")",
";",
"return",
"label",
";",
"}"
] | The label used to show the title.
@returns The title component. | [
"The",
"label",
"used",
"to",
"show",
"the",
"title",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayEntryViewSkin.java#L165-L171 | train |
dlemmermann/CalendarFX | CalendarFXView/src/main/java/impl/com/calendarfx/view/DayEntryViewSkin.java | DayEntryViewSkin.updateLabels | protected void updateLabels() {
Entry<?> entry = getEntry();
startTimeLabel.setText(formatTime(entry.getStartTime()));
titleLabel.setText(formatTitle(entry.getTitle()));
} | java | protected void updateLabels() {
Entry<?> entry = getEntry();
startTimeLabel.setText(formatTime(entry.getStartTime()));
titleLabel.setText(formatTitle(entry.getTitle()));
} | [
"protected",
"void",
"updateLabels",
"(",
")",
"{",
"Entry",
"<",
"?",
">",
"entry",
"=",
"getEntry",
"(",
")",
";",
"startTimeLabel",
".",
"setText",
"(",
"formatTime",
"(",
"entry",
".",
"getStartTime",
"(",
")",
")",
")",
";",
"titleLabel",
".",
"se... | This method will be called if the labels need to be updated. | [
"This",
"method",
"will",
"be",
"called",
"if",
"the",
"labels",
"need",
"to",
"be",
"updated",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayEntryViewSkin.java#L176-L181 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java | Util.rollToNextWeekStart | static void rollToNextWeekStart(DTBuilder builder, Weekday wkst) {
DateValue bd = builder.toDate();
builder.day += (7 - ((7 + (Weekday.valueOf(bd).javaDayNum
- wkst.javaDayNum))
% 7)) % 7;
builder.normalize();
} | java | static void rollToNextWeekStart(DTBuilder builder, Weekday wkst) {
DateValue bd = builder.toDate();
builder.day += (7 - ((7 + (Weekday.valueOf(bd).javaDayNum
- wkst.javaDayNum))
% 7)) % 7;
builder.normalize();
} | [
"static",
"void",
"rollToNextWeekStart",
"(",
"DTBuilder",
"builder",
",",
"Weekday",
"wkst",
")",
"{",
"DateValue",
"bd",
"=",
"builder",
".",
"toDate",
"(",
")",
";",
"builder",
".",
"day",
"+=",
"(",
"7",
"-",
"(",
"(",
"7",
"+",
"(",
"Weekday",
"... | advances builder to the earliest day on or after builder that falls on
wkst.
@param builder non null.
@param wkst the day of the week that the week starts on | [
"advances",
"builder",
"to",
"the",
"earliest",
"day",
"on",
"or",
"after",
"builder",
"that",
"falls",
"on",
"wkst",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java#L41-L47 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java | Util.nextWeekStart | static DateValue nextWeekStart(DateValue d, Weekday wkst) {
DTBuilder builder = new DTBuilder(d);
builder.day += (7 - ((7 + (Weekday.valueOf(d).javaDayNum
- wkst.javaDayNum)) % 7))
% 7;
return builder.toDate();
} | java | static DateValue nextWeekStart(DateValue d, Weekday wkst) {
DTBuilder builder = new DTBuilder(d);
builder.day += (7 - ((7 + (Weekday.valueOf(d).javaDayNum
- wkst.javaDayNum)) % 7))
% 7;
return builder.toDate();
} | [
"static",
"DateValue",
"nextWeekStart",
"(",
"DateValue",
"d",
",",
"Weekday",
"wkst",
")",
"{",
"DTBuilder",
"builder",
"=",
"new",
"DTBuilder",
"(",
"d",
")",
";",
"builder",
".",
"day",
"+=",
"(",
"7",
"-",
"(",
"(",
"7",
"+",
"(",
"Weekday",
".",... | the earliest day on or after d that falls on wkst.
@param wkst the day of the week that the week starts on | [
"the",
"earliest",
"day",
"on",
"or",
"after",
"d",
"that",
"falls",
"on",
"wkst",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java#L53-L59 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java | Util.uniquify | static int[] uniquify(int[] ints, int start, int end) {
IntSet iset = new IntSet();
for (int i = end; --i >= start; ) {
iset.add(ints[i]);
}
return iset.toIntArray();
} | java | static int[] uniquify(int[] ints, int start, int end) {
IntSet iset = new IntSet();
for (int i = end; --i >= start; ) {
iset.add(ints[i]);
}
return iset.toIntArray();
} | [
"static",
"int",
"[",
"]",
"uniquify",
"(",
"int",
"[",
"]",
"ints",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"IntSet",
"iset",
"=",
"new",
"IntSet",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"end",
";",
"--",
"i",
">=",
"start",
"... | returns a sorted unique copy of ints. | [
"returns",
"a",
"sorted",
"unique",
"copy",
"of",
"ints",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java#L67-L73 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java | Util.dayNumToDate | static int dayNumToDate(Weekday dow0, int nDays, int weekNum,
Weekday dow, int d0, int nDaysInMonth) {
// if dow is wednesday, then this is the date of the first wednesday
int firstDateOfGivenDow = 1 + ((7 + dow.javaDayNum - dow0.javaDayNum) % 7);
int date;
if (weekNum > 0) {
date = ((weekNum - 1) * 7) + firstDateOfGivenDow - d0;
} else { // count weeks from end of month
// calculate last day of the given dow.
// Since nDays <= 366, this should be > nDays
int lastDateOfGivenDow = firstDateOfGivenDow + (7 * 54);
lastDateOfGivenDow -= 7 * ((lastDateOfGivenDow - nDays + 6) / 7);
date = lastDateOfGivenDow + 7 * (weekNum + 1) - d0;
}
if (date <= 0 || date > nDaysInMonth) {
return 0;
}
return date;
} | java | static int dayNumToDate(Weekday dow0, int nDays, int weekNum,
Weekday dow, int d0, int nDaysInMonth) {
// if dow is wednesday, then this is the date of the first wednesday
int firstDateOfGivenDow = 1 + ((7 + dow.javaDayNum - dow0.javaDayNum) % 7);
int date;
if (weekNum > 0) {
date = ((weekNum - 1) * 7) + firstDateOfGivenDow - d0;
} else { // count weeks from end of month
// calculate last day of the given dow.
// Since nDays <= 366, this should be > nDays
int lastDateOfGivenDow = firstDateOfGivenDow + (7 * 54);
lastDateOfGivenDow -= 7 * ((lastDateOfGivenDow - nDays + 6) / 7);
date = lastDateOfGivenDow + 7 * (weekNum + 1) - d0;
}
if (date <= 0 || date > nDaysInMonth) {
return 0;
}
return date;
} | [
"static",
"int",
"dayNumToDate",
"(",
"Weekday",
"dow0",
",",
"int",
"nDays",
",",
"int",
"weekNum",
",",
"Weekday",
"dow",
",",
"int",
"d0",
",",
"int",
"nDaysInMonth",
")",
"{",
"// if dow is wednesday, then this is the date of the first wednesday",
"int",
"firstD... | given a weekday number, such as -1SU, returns the day of the month that it
falls on.
The weekday number may be refer to a week in the current month in some
contexts or a week in the current year in other contexts.
@param dow0 the day of week of the first day in the current year/month.
@param nDays the number of days in the current year/month.
In [28,29,30,31,365,366].
@param weekNum -1SU in the example above.
@param d0 the number of days between the 1st day of the current
year/month and the current month.
@param nDaysInMonth the number of days in the current month.
@return 0 indicates no such day | [
"given",
"a",
"weekday",
"number",
"such",
"as",
"-",
"1SU",
"returns",
"the",
"day",
"of",
"the",
"month",
"that",
"it",
"falls",
"on",
".",
"The",
"weekday",
"number",
"may",
"be",
"refer",
"to",
"a",
"week",
"in",
"the",
"current",
"month",
"in",
... | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java#L89-L108 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java | Util.invertWeekdayNum | static int invertWeekdayNum(
WeekdayNum weekdayNum, Weekday dow0, int nDays) {
assert weekdayNum.num < 0;
// how many are there of that week?
return countInPeriod(weekdayNum.wday, dow0, nDays) + weekdayNum.num + 1;
} | java | static int invertWeekdayNum(
WeekdayNum weekdayNum, Weekday dow0, int nDays) {
assert weekdayNum.num < 0;
// how many are there of that week?
return countInPeriod(weekdayNum.wday, dow0, nDays) + weekdayNum.num + 1;
} | [
"static",
"int",
"invertWeekdayNum",
"(",
"WeekdayNum",
"weekdayNum",
",",
"Weekday",
"dow0",
",",
"int",
"nDays",
")",
"{",
"assert",
"weekdayNum",
".",
"num",
"<",
"0",
";",
"// how many are there of that week?",
"return",
"countInPeriod",
"(",
"weekdayNum",
"."... | Compute an absolute week number given a relative one.
The day number -1SU refers to the last Sunday, so if there are 5 Sundays
in a period that starts on dow0 with nDays, then -1SU is 5SU.
Depending on where its used it may refer to the last Sunday of the year
or of the month.
@param weekdayNum -1SU in the example above.
@param dow0 the day of the week of the first day of the week or month.
One of the RRULE_WDAY_* constants.
@param nDays the number of days in the month or year.
@return an abolute week number, e.g. 5 in the example above.
Valid if in [1,53]. | [
"Compute",
"an",
"absolute",
"week",
"number",
"given",
"a",
"relative",
"one",
".",
"The",
"day",
"number",
"-",
"1SU",
"refers",
"to",
"the",
"last",
"Sunday",
"so",
"if",
"there",
"are",
"5",
"Sundays",
"in",
"a",
"period",
"that",
"starts",
"on",
"... | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java#L124-L129 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java | Util.countInPeriod | static int countInPeriod(Weekday dow, Weekday dow0, int nDays) {
// Two cases
// (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7
// (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7
if (dow.javaDayNum >= dow0.javaDayNum) {
return 1 + ((nDays - (dow.javaDayNum - dow0.javaDayNum) - 1) / 7);
} else {
return 1 + ((nDays - (7 - (dow0.javaDayNum - dow.javaDayNum)) - 1) / 7);
}
} | java | static int countInPeriod(Weekday dow, Weekday dow0, int nDays) {
// Two cases
// (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7
// (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7
if (dow.javaDayNum >= dow0.javaDayNum) {
return 1 + ((nDays - (dow.javaDayNum - dow0.javaDayNum) - 1) / 7);
} else {
return 1 + ((nDays - (7 - (dow0.javaDayNum - dow.javaDayNum)) - 1) / 7);
}
} | [
"static",
"int",
"countInPeriod",
"(",
"Weekday",
"dow",
",",
"Weekday",
"dow0",
",",
"int",
"nDays",
")",
"{",
"// Two cases",
"// (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7",
"// (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7",
"if",
"(",
"dow",
... | the number of occurences of dow in a period nDays long where the first day
of the period has day of week dow0. | [
"the",
"number",
"of",
"occurences",
"of",
"dow",
"in",
"a",
"period",
"nDays",
"long",
"where",
"the",
"first",
"day",
"of",
"the",
"period",
"has",
"day",
"of",
"week",
"dow0",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Util.java#L135-L144 | train |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/view/data/GoogleCalendarData.java | GoogleCalendarData.getUnloadedSlices | public List<Slice> getUnloadedSlices(List<Slice> slices) {
List<Slice> unloadedSlices = new ArrayList<>(slices);
unloadedSlices.removeAll(loadedSlices);
unloadedSlices.removeAll(inProgressSlices);
return unloadedSlices;
} | java | public List<Slice> getUnloadedSlices(List<Slice> slices) {
List<Slice> unloadedSlices = new ArrayList<>(slices);
unloadedSlices.removeAll(loadedSlices);
unloadedSlices.removeAll(inProgressSlices);
return unloadedSlices;
} | [
"public",
"List",
"<",
"Slice",
">",
"getUnloadedSlices",
"(",
"List",
"<",
"Slice",
">",
"slices",
")",
"{",
"List",
"<",
"Slice",
">",
"unloadedSlices",
"=",
"new",
"ArrayList",
"<>",
"(",
"slices",
")",
";",
"unloadedSlices",
".",
"removeAll",
"(",
"l... | Takes the list of slices and removes those already loaded.
@param slices the slices to be processed.
@return A new list containing the unloaded slices. | [
"Takes",
"the",
"list",
"of",
"slices",
"and",
"removes",
"those",
"already",
"loaded",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/view/data/GoogleCalendarData.java#L62-L67 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/RecurrenceIteratorFactory.java | RecurrenceIteratorFactory.createRecurrenceIterator | public static RecurrenceIterator createRecurrenceIterator(
String rdata, DateValue dtStart, TimeZone tzid, boolean strict)
throws ParseException {
return createRecurrenceIterable(rdata, dtStart, tzid, strict).iterator();
} | java | public static RecurrenceIterator createRecurrenceIterator(
String rdata, DateValue dtStart, TimeZone tzid, boolean strict)
throws ParseException {
return createRecurrenceIterable(rdata, dtStart, tzid, strict).iterator();
} | [
"public",
"static",
"RecurrenceIterator",
"createRecurrenceIterator",
"(",
"String",
"rdata",
",",
"DateValue",
"dtStart",
",",
"TimeZone",
"tzid",
",",
"boolean",
"strict",
")",
"throws",
"ParseException",
"{",
"return",
"createRecurrenceIterable",
"(",
"rdata",
",",... | given a block of RRULE, EXRULE, RDATE, and EXDATE content lines, parse
them into a single recurrence iterator.
@param rdata ical text.
@param dtStart the date of the first occurrence in timezone tzid, which is
used to fill in optional fields in the RRULE, such as the day of the
month for a monthly repetition when no ther day specified.
Note: this may not be the first date in the series since an EXRULE or
EXDATE might force it to be skipped, but there will be no earlier date
generated by this ruleset.
@param strict true if any failure to parse should result in a
ParseException. false causes bad content lines to be logged and ignored. | [
"given",
"a",
"block",
"of",
"RRULE",
"EXRULE",
"RDATE",
"and",
"EXDATE",
"content",
"lines",
"parse",
"them",
"into",
"a",
"single",
"recurrence",
"iterator",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/RecurrenceIteratorFactory.java#L91-L95 | train |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/RecurrenceIteratorFactory.java | RecurrenceIteratorFactory.createRecurrenceIterator | public static RecurrenceIterator createRecurrenceIterator(RDateList rdates) {
DateValue[] dates = rdates.getDatesUtc();
Arrays.sort(dates);
int k = 0;
for (int i = 1; i < dates.length; ++i) {
if (!dates[i].equals(dates[k])) {
dates[++k] = dates[i];
}
}
if (++k < dates.length) {
DateValue[] uniqueDates = new DateValue[k];
System.arraycopy(dates, 0, uniqueDates, 0, k);
dates = uniqueDates;
}
return new RDateIteratorImpl(dates);
} | java | public static RecurrenceIterator createRecurrenceIterator(RDateList rdates) {
DateValue[] dates = rdates.getDatesUtc();
Arrays.sort(dates);
int k = 0;
for (int i = 1; i < dates.length; ++i) {
if (!dates[i].equals(dates[k])) {
dates[++k] = dates[i];
}
}
if (++k < dates.length) {
DateValue[] uniqueDates = new DateValue[k];
System.arraycopy(dates, 0, uniqueDates, 0, k);
dates = uniqueDates;
}
return new RDateIteratorImpl(dates);
} | [
"public",
"static",
"RecurrenceIterator",
"createRecurrenceIterator",
"(",
"RDateList",
"rdates",
")",
"{",
"DateValue",
"[",
"]",
"dates",
"=",
"rdates",
".",
"getDatesUtc",
"(",
")",
";",
"Arrays",
".",
"sort",
"(",
"dates",
")",
";",
"int",
"k",
"=",
"0... | create a recurrence iterator from an rdate or exdate list. | [
"create",
"a",
"recurrence",
"iterator",
"from",
"an",
"rdate",
"or",
"exdate",
"list",
"."
] | f2b91c2622c3f29d004485b6426b23b86c331f96 | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/RecurrenceIteratorFactory.java#L157-L172 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.