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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
lordcodes/SnackbarBuilder | snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java | SnackbarBuilder.timeoutDismissCallback | public SnackbarBuilder timeoutDismissCallback(final SnackbarTimeoutDismissCallback callback) {
callbacks.add(new SnackbarCallback() {
public void onSnackbarTimedOut(Snackbar snackbar) {
callback.onSnackbarTimedOut(snackbar);
}
});
return this;
} | java | public SnackbarBuilder timeoutDismissCallback(final SnackbarTimeoutDismissCallback callback) {
callbacks.add(new SnackbarCallback() {
public void onSnackbarTimedOut(Snackbar snackbar) {
callback.onSnackbarTimedOut(snackbar);
}
});
return this;
} | [
"public",
"SnackbarBuilder",
"timeoutDismissCallback",
"(",
"final",
"SnackbarTimeoutDismissCallback",
"callback",
")",
"{",
"callbacks",
".",
"add",
"(",
"new",
"SnackbarCallback",
"(",
")",
"{",
"public",
"void",
"onSnackbarTimedOut",
"(",
"Snackbar",
"snackbar",
")... | Set the callback to be informed of the Snackbar being dismissed due to a timeout.
@param callback The callback.
@return This instance. | [
"Set",
"the",
"callback",
"to",
"be",
"informed",
"of",
"the",
"Snackbar",
"being",
"dismissed",
"due",
"to",
"a",
"timeout",
"."
] | a104a753c78ed66940c19d295e141a521cf81d73 | https://github.com/lordcodes/SnackbarBuilder/blob/a104a753c78ed66940c19d295e141a521cf81d73/snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java#L405-L412 | train |
lordcodes/SnackbarBuilder | snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java | SnackbarBuilder.consecutiveDismissCallback | @SuppressWarnings("WeakerAccess")
public SnackbarBuilder consecutiveDismissCallback(final SnackbarConsecutiveDismissCallback callback) {
callbacks.add(new SnackbarCallback() {
public void onSnackbarDismissedAfterAnotherShown(Snackbar snackbar) {
callback.onSnackbarDismissedAfterAnotherShown(snackbar);
}
});
return this;
} | java | @SuppressWarnings("WeakerAccess")
public SnackbarBuilder consecutiveDismissCallback(final SnackbarConsecutiveDismissCallback callback) {
callbacks.add(new SnackbarCallback() {
public void onSnackbarDismissedAfterAnotherShown(Snackbar snackbar) {
callback.onSnackbarDismissedAfterAnotherShown(snackbar);
}
});
return this;
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"SnackbarBuilder",
"consecutiveDismissCallback",
"(",
"final",
"SnackbarConsecutiveDismissCallback",
"callback",
")",
"{",
"callbacks",
".",
"add",
"(",
"new",
"SnackbarCallback",
"(",
")",
"{",
"public",
... | Set the callback to be informed of the Snackbar being dismissed due to another Snackbar being shown.
@param callback The callback.
@return This instance. | [
"Set",
"the",
"callback",
"to",
"be",
"informed",
"of",
"the",
"Snackbar",
"being",
"dismissed",
"due",
"to",
"another",
"Snackbar",
"being",
"shown",
"."
] | a104a753c78ed66940c19d295e141a521cf81d73 | https://github.com/lordcodes/SnackbarBuilder/blob/a104a753c78ed66940c19d295e141a521cf81d73/snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java#L436-L444 | train |
lordcodes/SnackbarBuilder | snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java | SnackbarBuilder.buildWrapper | public SnackbarWrapper buildWrapper() {
Snackbar snackbar = Snackbar.make(parentView, message, duration);
SnackbarWrapper wrapper = new SnackbarWrapper(snackbar)
.setAction(actionText, sanitisedActionClickListener())
.setActionTextAllCaps(actionAllCaps)
.addCallbacks(callbacks)
.setIconMargin(iconMargin);
if (actionTextColor != 0) {
wrapper.setActionTextColor(actionTextColor);
}
if (messageTextColor != 0) {
wrapper.setTextColor(messageTextColor);
}
if (appendMessages != null) {
wrapper.appendMessage(appendMessages);
}
if (backgroundColor != 0) {
wrapper.setBackgroundColor(backgroundColor);
}
if (icon != null) {
wrapper.setIcon(icon);
}
return wrapper;
} | java | public SnackbarWrapper buildWrapper() {
Snackbar snackbar = Snackbar.make(parentView, message, duration);
SnackbarWrapper wrapper = new SnackbarWrapper(snackbar)
.setAction(actionText, sanitisedActionClickListener())
.setActionTextAllCaps(actionAllCaps)
.addCallbacks(callbacks)
.setIconMargin(iconMargin);
if (actionTextColor != 0) {
wrapper.setActionTextColor(actionTextColor);
}
if (messageTextColor != 0) {
wrapper.setTextColor(messageTextColor);
}
if (appendMessages != null) {
wrapper.appendMessage(appendMessages);
}
if (backgroundColor != 0) {
wrapper.setBackgroundColor(backgroundColor);
}
if (icon != null) {
wrapper.setIcon(icon);
}
return wrapper;
} | [
"public",
"SnackbarWrapper",
"buildWrapper",
"(",
")",
"{",
"Snackbar",
"snackbar",
"=",
"Snackbar",
".",
"make",
"(",
"parentView",
",",
"message",
",",
"duration",
")",
";",
"SnackbarWrapper",
"wrapper",
"=",
"new",
"SnackbarWrapper",
"(",
"snackbar",
")",
"... | Build a Snackbar using the options specified in the builder. Wrap this Snackbar into a SnackbarWrapper, which
allows further customisation.
@return A SnackbarWrapper, a class which wraps a Snackbar for further customisation. | [
"Build",
"a",
"Snackbar",
"using",
"the",
"options",
"specified",
"in",
"the",
"builder",
".",
"Wrap",
"this",
"Snackbar",
"into",
"a",
"SnackbarWrapper",
"which",
"allows",
"further",
"customisation",
"."
] | a104a753c78ed66940c19d295e141a521cf81d73 | https://github.com/lordcodes/SnackbarBuilder/blob/a104a753c78ed66940c19d295e141a521cf81d73/snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java#L511-L534 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/tooling/InterfaceReport.java | InterfaceReport.getInterfaceInfoMap | private Map<Class<?>, InterfaceInfo> getInterfaceInfoMap() {
if (interfaceInfoMap == null) {
interfaceInfoMap = new HashMap<Class<?>, InterfaceInfo>();
for (final Class<?> c : packageClasses) {
if (INTERESTING_CLASSES.accept( c )) {
if (!interfaceInfoMap.containsKey( c )) {
interfaceInfoMap.put( c, new InterfaceInfo( c ) );
}
} else {
final Contract contract = c.getAnnotation( Contract.class );
if (contract != null) {
InterfaceInfo ii = interfaceInfoMap.get( contract.value() );
if (ii == null) {
ii = new InterfaceInfo( contract.value() );
interfaceInfoMap.put( contract.value(), ii );
}
ii.add( c );
}
}
}
}
return interfaceInfoMap;
} | java | private Map<Class<?>, InterfaceInfo> getInterfaceInfoMap() {
if (interfaceInfoMap == null) {
interfaceInfoMap = new HashMap<Class<?>, InterfaceInfo>();
for (final Class<?> c : packageClasses) {
if (INTERESTING_CLASSES.accept( c )) {
if (!interfaceInfoMap.containsKey( c )) {
interfaceInfoMap.put( c, new InterfaceInfo( c ) );
}
} else {
final Contract contract = c.getAnnotation( Contract.class );
if (contract != null) {
InterfaceInfo ii = interfaceInfoMap.get( contract.value() );
if (ii == null) {
ii = new InterfaceInfo( contract.value() );
interfaceInfoMap.put( contract.value(), ii );
}
ii.add( c );
}
}
}
}
return interfaceInfoMap;
} | [
"private",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"InterfaceInfo",
">",
"getInterfaceInfoMap",
"(",
")",
"{",
"if",
"(",
"interfaceInfoMap",
"==",
"null",
")",
"{",
"interfaceInfoMap",
"=",
"new",
"HashMap",
"<",
"Class",
"<",
"?",
">",
",",
"Interface... | Get the interface info map.
All interfaces implemented in the packages that have contract tests.
@return | [
"Get",
"the",
"interface",
"info",
"map",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/tooling/InterfaceReport.java#L107-L130 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/tooling/InterfaceReport.java | InterfaceReport.getErrors | public List<Throwable> getErrors() {
final List<Throwable> retval = new ArrayList<Throwable>();
for (final TestInfo testInfo : contractTestMap.listTestInfo()) {
retval.addAll( testInfo.getErrors() );
}
return retval;
} | java | public List<Throwable> getErrors() {
final List<Throwable> retval = new ArrayList<Throwable>();
for (final TestInfo testInfo : contractTestMap.listTestInfo()) {
retval.addAll( testInfo.getErrors() );
}
return retval;
} | [
"public",
"List",
"<",
"Throwable",
">",
"getErrors",
"(",
")",
"{",
"final",
"List",
"<",
"Throwable",
">",
"retval",
"=",
"new",
"ArrayList",
"<",
"Throwable",
">",
"(",
")",
";",
"for",
"(",
"final",
"TestInfo",
"testInfo",
":",
"contractTestMap",
"."... | Get the set of errors encountered when discovering contract tests. This
is a list of all errors for all tests.
@return The list of Throwable objects that represent errors. | [
"Get",
"the",
"set",
"of",
"errors",
"encountered",
"when",
"discovering",
"contract",
"tests",
".",
"This",
"is",
"a",
"list",
"of",
"all",
"errors",
"for",
"all",
"tests",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/tooling/InterfaceReport.java#L189-L195 | train |
zzsrv/torrent-utils | src/main/java/cc/vcode/util/SHA1.java | SHA1.update | public void update(ByteBuffer buffer) {
length += buffer.remaining();
//Save current position to leave given buffer unchanged
int position = buffer.position();
//Complete the final buffer if needed
completeFinalBuffer(buffer);
while(buffer.remaining() >= 64) {
transform(buffer);
}
if(buffer.remaining() != 0) {
finalBuffer.put(buffer);
}
buffer.position(position);
} | java | public void update(ByteBuffer buffer) {
length += buffer.remaining();
//Save current position to leave given buffer unchanged
int position = buffer.position();
//Complete the final buffer if needed
completeFinalBuffer(buffer);
while(buffer.remaining() >= 64) {
transform(buffer);
}
if(buffer.remaining() != 0) {
finalBuffer.put(buffer);
}
buffer.position(position);
} | [
"public",
"void",
"update",
"(",
"ByteBuffer",
"buffer",
")",
"{",
"length",
"+=",
"buffer",
".",
"remaining",
"(",
")",
";",
"//Save current position to leave given buffer unchanged",
"int",
"position",
"=",
"buffer",
".",
"position",
"(",
")",
";",
"//Complete t... | Starts or continues a SHA-1 message digest calculation.
Only the remaining bytes of the given ByteBuffer are used.
@param buffer input data | [
"Starts",
"or",
"continues",
"a",
"SHA",
"-",
"1",
"message",
"digest",
"calculation",
".",
"Only",
"the",
"remaining",
"bytes",
"of",
"the",
"given",
"ByteBuffer",
"are",
"used",
"."
] | 70ba8bccd5af1ed7a18c42c61ad409256e9865f3 | https://github.com/zzsrv/torrent-utils/blob/70ba8bccd5af1ed7a18c42c61ad409256e9865f3/src/main/java/cc/vcode/util/SHA1.java#L341-L358 | train |
zzsrv/torrent-utils | src/main/java/cc/vcode/util/SHA1.java | SHA1.digest | public byte[] digest() {
byte[] result = new byte[20];
finalBuffer.put((byte)0x80);
if(finalBuffer.remaining() < 8) {
while(finalBuffer.remaining() > 0) {
finalBuffer.put((byte)0);
}
finalBuffer.position(0);
transform(finalBuffer);
finalBuffer.position(0);
}
while(finalBuffer.remaining() > 8) {
finalBuffer.put((byte)0);
}
finalBuffer.putLong(length << 3);
finalBuffer.position(0);
transform(finalBuffer);
finalBuffer.position(0);
finalBuffer.putInt(h0);
finalBuffer.putInt(h1);
finalBuffer.putInt(h2);
finalBuffer.putInt(h3);
finalBuffer.putInt(h4);
finalBuffer.position(0);
for(int i = 0 ; i < 20 ; i++) {
result[i] = finalBuffer.get();
}
return result;
} | java | public byte[] digest() {
byte[] result = new byte[20];
finalBuffer.put((byte)0x80);
if(finalBuffer.remaining() < 8) {
while(finalBuffer.remaining() > 0) {
finalBuffer.put((byte)0);
}
finalBuffer.position(0);
transform(finalBuffer);
finalBuffer.position(0);
}
while(finalBuffer.remaining() > 8) {
finalBuffer.put((byte)0);
}
finalBuffer.putLong(length << 3);
finalBuffer.position(0);
transform(finalBuffer);
finalBuffer.position(0);
finalBuffer.putInt(h0);
finalBuffer.putInt(h1);
finalBuffer.putInt(h2);
finalBuffer.putInt(h3);
finalBuffer.putInt(h4);
finalBuffer.position(0);
for(int i = 0 ; i < 20 ; i++) {
result[i] = finalBuffer.get();
}
return result;
} | [
"public",
"byte",
"[",
"]",
"digest",
"(",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"20",
"]",
";",
"finalBuffer",
".",
"put",
"(",
"(",
"byte",
")",
"0x80",
")",
";",
"if",
"(",
"finalBuffer",
".",
"remaining",
"(",
")",
... | Finishes the SHA-1 message digest calculation.
@return 20-byte hash result | [
"Finishes",
"the",
"SHA",
"-",
"1",
"message",
"digest",
"calculation",
"."
] | 70ba8bccd5af1ed7a18c42c61ad409256e9865f3 | https://github.com/zzsrv/torrent-utils/blob/70ba8bccd5af1ed7a18c42c61ad409256e9865f3/src/main/java/cc/vcode/util/SHA1.java#L365-L399 | train |
zzsrv/torrent-utils | src/main/java/cc/vcode/util/SHA1.java | SHA1.restoreState | public void restoreState() {
h0=s0;
h1=s1;
h2=s2;
h3=s3;
h4=s4;
length = saveLength;
finalBuffer.clear();
finalBuffer.put(saveBuffer);
} | java | public void restoreState() {
h0=s0;
h1=s1;
h2=s2;
h3=s3;
h4=s4;
length = saveLength;
finalBuffer.clear();
finalBuffer.put(saveBuffer);
} | [
"public",
"void",
"restoreState",
"(",
")",
"{",
"h0",
"=",
"s0",
";",
"h1",
"=",
"s1",
";",
"h2",
"=",
"s2",
";",
"h3",
"=",
"s3",
";",
"h4",
"=",
"s4",
";",
"length",
"=",
"saveLength",
";",
"finalBuffer",
".",
"clear",
"(",
")",
";",
"finalB... | Restore the digest to its previously-saved state. | [
"Restore",
"the",
"digest",
"to",
"its",
"previously",
"-",
"saved",
"state",
"."
] | 70ba8bccd5af1ed7a18c42c61ad409256e9865f3 | https://github.com/zzsrv/torrent-utils/blob/70ba8bccd5af1ed7a18c42c61ad409256e9865f3/src/main/java/cc/vcode/util/SHA1.java#L446-L457 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLHandler.java | GDLHandler.append | public void append(String asciiString) {
if (asciiString == null) {
throw new IllegalArgumentException("AsciiString must not be null");
}
ANTLRInputStream antlrInputStream = new ANTLRInputStream(asciiString);
GDLLexer lexer = new GDLLexer(antlrInputStream);
GDLParser parser = new GDLParser(new CommonTokenStream(lexer));
// update the loader state while walking the parse tree
new ParseTreeWalker().walk(loader, parser.database());
} | java | public void append(String asciiString) {
if (asciiString == null) {
throw new IllegalArgumentException("AsciiString must not be null");
}
ANTLRInputStream antlrInputStream = new ANTLRInputStream(asciiString);
GDLLexer lexer = new GDLLexer(antlrInputStream);
GDLParser parser = new GDLParser(new CommonTokenStream(lexer));
// update the loader state while walking the parse tree
new ParseTreeWalker().walk(loader, parser.database());
} | [
"public",
"void",
"append",
"(",
"String",
"asciiString",
")",
"{",
"if",
"(",
"asciiString",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"AsciiString must not be null\"",
")",
";",
"}",
"ANTLRInputStream",
"antlrInputStream",
"=",
"... | Append the given GDL string to the current database.
@param asciiString GDL string (must not be {@code null}). | [
"Append",
"the",
"given",
"GDL",
"string",
"to",
"the",
"current",
"database",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLHandler.java#L59-L68 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLHandler.java | GDLHandler.getGraphCache | public Map<String, Graph> getGraphCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return loader.getGraphCache(includeUserDefined, includeAutoGenerated);
} | java | public Map<String, Graph> getGraphCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return loader.getGraphCache(includeUserDefined, includeAutoGenerated);
} | [
"public",
"Map",
"<",
"String",
",",
"Graph",
">",
"getGraphCache",
"(",
"boolean",
"includeUserDefined",
",",
"boolean",
"includeAutoGenerated",
")",
"{",
"return",
"loader",
".",
"getGraphCache",
"(",
"includeUserDefined",
",",
"includeAutoGenerated",
")",
";",
... | Returns a cache that contains a mapping from variables to graph instances.
@param includeUserDefined true, iff user-defined variables shall be included in the cache
@param includeAutoGenerated true, iff auto-generated variables shall be included in the cache
@return immutable graph cache | [
"Returns",
"a",
"cache",
"that",
"contains",
"a",
"mapping",
"from",
"variables",
"to",
"graph",
"instances",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLHandler.java#L121-L123 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLHandler.java | GDLHandler.getVertexCache | public Map<String, Vertex> getVertexCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return loader.getVertexCache(includeUserDefined, includeAutoGenerated);
} | java | public Map<String, Vertex> getVertexCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return loader.getVertexCache(includeUserDefined, includeAutoGenerated);
} | [
"public",
"Map",
"<",
"String",
",",
"Vertex",
">",
"getVertexCache",
"(",
"boolean",
"includeUserDefined",
",",
"boolean",
"includeAutoGenerated",
")",
"{",
"return",
"loader",
".",
"getVertexCache",
"(",
"includeUserDefined",
",",
"includeAutoGenerated",
")",
";",... | Returns a cache that contains a mapping from variables to vertex instances.
@param includeUserDefined true, iff user-defined variables shall be included in the cache
@param includeAutoGenerated true, iff auto-generated variables shall be included in the cache
@return immutable vertex cache | [
"Returns",
"a",
"cache",
"that",
"contains",
"a",
"mapping",
"from",
"variables",
"to",
"vertex",
"instances",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLHandler.java#L142-L144 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLHandler.java | GDLHandler.getEdgeCache | public Map<String, Edge> getEdgeCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return loader.getEdgeCache(includeUserDefined, includeAutoGenerated);
} | java | public Map<String, Edge> getEdgeCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return loader.getEdgeCache(includeUserDefined, includeAutoGenerated);
} | [
"public",
"Map",
"<",
"String",
",",
"Edge",
">",
"getEdgeCache",
"(",
"boolean",
"includeUserDefined",
",",
"boolean",
"includeAutoGenerated",
")",
"{",
"return",
"loader",
".",
"getEdgeCache",
"(",
"includeUserDefined",
",",
"includeAutoGenerated",
")",
";",
"}"... | Returns a cache that contains a mapping from variables to edge instances.
@param includeUserDefined true, iff user-defined variables shall be included in the cache
@param includeAutoGenerated true, iff auto-generated variables shall be included in the cache
@return immutable edge cache | [
"Returns",
"a",
"cache",
"that",
"contains",
"a",
"mapping",
"from",
"variables",
"to",
"edge",
"instances",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLHandler.java#L163-L165 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getPredicates | Optional<Predicate> getPredicates() {
return predicates != null ? Optional.of(predicates) : Optional.empty();
} | java | Optional<Predicate> getPredicates() {
return predicates != null ? Optional.of(predicates) : Optional.empty();
} | [
"Optional",
"<",
"Predicate",
">",
"getPredicates",
"(",
")",
"{",
"return",
"predicates",
"!=",
"null",
"?",
"Optional",
".",
"of",
"(",
"predicates",
")",
":",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
] | Returns the predicates defined by the query.
@return predicates | [
"Returns",
"the",
"predicates",
"defined",
"by",
"the",
"query",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L195-L197 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getGraphCache | Map<String, Graph> getGraphCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return getCache(userGraphCache, autoGraphCache, includeUserDefined, includeAutoGenerated);
} | java | Map<String, Graph> getGraphCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return getCache(userGraphCache, autoGraphCache, includeUserDefined, includeAutoGenerated);
} | [
"Map",
"<",
"String",
",",
"Graph",
">",
"getGraphCache",
"(",
"boolean",
"includeUserDefined",
",",
"boolean",
"includeAutoGenerated",
")",
"{",
"return",
"getCache",
"(",
"userGraphCache",
",",
"autoGraphCache",
",",
"includeUserDefined",
",",
"includeAutoGenerated"... | Returns a cache containing a mapping from variables to graphs.
@param includeUserDefined include user-defined variables
@param includeAutoGenerated include auto-generated variables
@return immutable graph cache | [
"Returns",
"a",
"cache",
"containing",
"a",
"mapping",
"from",
"variables",
"to",
"graphs",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L216-L218 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getVertexCache | Map<String, Vertex> getVertexCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return getCache(userVertexCache, autoVertexCache, includeUserDefined, includeAutoGenerated);
} | java | Map<String, Vertex> getVertexCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return getCache(userVertexCache, autoVertexCache, includeUserDefined, includeAutoGenerated);
} | [
"Map",
"<",
"String",
",",
"Vertex",
">",
"getVertexCache",
"(",
"boolean",
"includeUserDefined",
",",
"boolean",
"includeAutoGenerated",
")",
"{",
"return",
"getCache",
"(",
"userVertexCache",
",",
"autoVertexCache",
",",
"includeUserDefined",
",",
"includeAutoGenera... | Returns a cache containing a mapping from variables to vertices.
@param includeUserDefined include user-defined variables
@param includeAutoGenerated include auto-generated variables
@return immutable vertex cache | [
"Returns",
"a",
"cache",
"containing",
"a",
"mapping",
"from",
"variables",
"to",
"vertices",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L238-L240 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getEdgeCache | Map<String, Edge> getEdgeCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return getCache(userEdgeCache, autoEdgeCache, includeUserDefined, includeAutoGenerated);
} | java | Map<String, Edge> getEdgeCache(boolean includeUserDefined, boolean includeAutoGenerated) {
return getCache(userEdgeCache, autoEdgeCache, includeUserDefined, includeAutoGenerated);
} | [
"Map",
"<",
"String",
",",
"Edge",
">",
"getEdgeCache",
"(",
"boolean",
"includeUserDefined",
",",
"boolean",
"includeAutoGenerated",
")",
"{",
"return",
"getCache",
"(",
"userEdgeCache",
",",
"autoEdgeCache",
",",
"includeUserDefined",
",",
"includeAutoGenerated",
... | Returns a cache containing a mapping from variables to edges.
@param includeUserDefined include user-defined variables
@param includeAutoGenerated include auto-generated variables
@return immutable edge cache | [
"Returns",
"a",
"cache",
"containing",
"a",
"mapping",
"from",
"variables",
"to",
"edges",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L260-L262 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.enterGraph | @Override
public void enterGraph(GDLParser.GraphContext graphContext) {
inGraph = true;
String variable = getVariable(graphContext.header());
Graph g;
if (variable != null && userGraphCache.containsKey(variable)) {
g = userGraphCache.get(variable);
} else {
g = initNewGraph(graphContext);
if (variable != null) {
userGraphCache.put(variable, g);
} else {
variable = String.format(ANONYMOUS_GRAPH_VARIABLE, g.getId());
autoGraphCache.put(variable, g);
}
g.setVariable(variable);
graphs.add(g);
}
currentGraphId = g.getId();
} | java | @Override
public void enterGraph(GDLParser.GraphContext graphContext) {
inGraph = true;
String variable = getVariable(graphContext.header());
Graph g;
if (variable != null && userGraphCache.containsKey(variable)) {
g = userGraphCache.get(variable);
} else {
g = initNewGraph(graphContext);
if (variable != null) {
userGraphCache.put(variable, g);
} else {
variable = String.format(ANONYMOUS_GRAPH_VARIABLE, g.getId());
autoGraphCache.put(variable, g);
}
g.setVariable(variable);
graphs.add(g);
}
currentGraphId = g.getId();
} | [
"@",
"Override",
"public",
"void",
"enterGraph",
"(",
"GDLParser",
".",
"GraphContext",
"graphContext",
")",
"{",
"inGraph",
"=",
"true",
";",
"String",
"variable",
"=",
"getVariable",
"(",
"graphContext",
".",
"header",
"(",
")",
")",
";",
"Graph",
"g",
"... | Called when parser enters a graph context.
Checks if the graph has already been created (using its variable). If not, a new graph is
created and added to the graph cache.
@param graphContext graph context | [
"Called",
"when",
"parser",
"enters",
"a",
"graph",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L272-L292 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.exitQuery | @Override
public void exitQuery(GDLParser.QueryContext ctx) {
for(Vertex v : vertices) {
addPredicates(Predicate.fromGraphElement(v, getDefaultVertexLabel()));
}
for(Edge e : edges) {
addPredicates(Predicate.fromGraphElement(e, getDefaultEdgeLabel()));
}
} | java | @Override
public void exitQuery(GDLParser.QueryContext ctx) {
for(Vertex v : vertices) {
addPredicates(Predicate.fromGraphElement(v, getDefaultVertexLabel()));
}
for(Edge e : edges) {
addPredicates(Predicate.fromGraphElement(e, getDefaultEdgeLabel()));
}
} | [
"@",
"Override",
"public",
"void",
"exitQuery",
"(",
"GDLParser",
".",
"QueryContext",
"ctx",
")",
"{",
"for",
"(",
"Vertex",
"v",
":",
"vertices",
")",
"{",
"addPredicates",
"(",
"Predicate",
".",
"fromGraphElement",
"(",
"v",
",",
"getDefaultVertexLabel",
... | When leaving a query context its save to add the pattern predicates to the filters
@param ctx query context | [
"When",
"leaving",
"a",
"query",
"context",
"its",
"save",
"to",
"add",
"the",
"pattern",
"predicates",
"to",
"the",
"filters"
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L304-L312 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.enterVertex | @Override
public void enterVertex(GDLParser.VertexContext vertexContext) {
String variable = getVariable(vertexContext.header());
Vertex v;
if (variable != null && userVertexCache.containsKey(variable)) {
v = userVertexCache.get(variable);
} else {
v = initNewVertex(vertexContext);
if (variable != null) {
userVertexCache.put(variable, v);
} else {
variable = String.format(ANONYMOUS_VERTEX_VARIABLE, v.getId());
autoVertexCache.put(variable, v);
}
v.setVariable(variable);
vertices.add(v);
}
updateGraphElement(v);
setLastSeenVertex(v);
updateLastSeenEdge(v);
} | java | @Override
public void enterVertex(GDLParser.VertexContext vertexContext) {
String variable = getVariable(vertexContext.header());
Vertex v;
if (variable != null && userVertexCache.containsKey(variable)) {
v = userVertexCache.get(variable);
} else {
v = initNewVertex(vertexContext);
if (variable != null) {
userVertexCache.put(variable, v);
} else {
variable = String.format(ANONYMOUS_VERTEX_VARIABLE, v.getId());
autoVertexCache.put(variable, v);
}
v.setVariable(variable);
vertices.add(v);
}
updateGraphElement(v);
setLastSeenVertex(v);
updateLastSeenEdge(v);
} | [
"@",
"Override",
"public",
"void",
"enterVertex",
"(",
"GDLParser",
".",
"VertexContext",
"vertexContext",
")",
"{",
"String",
"variable",
"=",
"getVariable",
"(",
"vertexContext",
".",
"header",
"(",
")",
")",
";",
"Vertex",
"v",
";",
"if",
"(",
"variable",... | Called when parser enters a vertex context.
Checks if the vertex has already been created (using its variable). If not, a new vertex is
created and added to the vertex cache.
@param vertexContext vertex context | [
"Called",
"when",
"parser",
"enters",
"a",
"vertex",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L322-L343 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.exitWhere | @Override
public void exitWhere(GDLParser.WhereContext ctx) {
addPredicates(Collections.singletonList(currentPredicates.pop()));
} | java | @Override
public void exitWhere(GDLParser.WhereContext ctx) {
addPredicates(Collections.singletonList(currentPredicates.pop()));
} | [
"@",
"Override",
"public",
"void",
"exitWhere",
"(",
"GDLParser",
".",
"WhereContext",
"ctx",
")",
"{",
"addPredicates",
"(",
"Collections",
".",
"singletonList",
"(",
"currentPredicates",
".",
"pop",
"(",
")",
")",
")",
";",
"}"
] | Called when the parser leaves a WHERE expression
Takes care that the filter build from the current expression is stored
in the graph
@param ctx where context | [
"Called",
"when",
"the",
"parser",
"leaves",
"a",
"WHERE",
"expression"
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L373-L376 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.exitNotExpression | @Override
public void exitNotExpression(GDLParser.NotExpressionContext ctx) {
if (!ctx.NOT().isEmpty()) {
Predicate not = new Not(currentPredicates.pop());
currentPredicates.add(not);
}
} | java | @Override
public void exitNotExpression(GDLParser.NotExpressionContext ctx) {
if (!ctx.NOT().isEmpty()) {
Predicate not = new Not(currentPredicates.pop());
currentPredicates.add(not);
}
} | [
"@",
"Override",
"public",
"void",
"exitNotExpression",
"(",
"GDLParser",
".",
"NotExpressionContext",
"ctx",
")",
"{",
"if",
"(",
"!",
"ctx",
".",
"NOT",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"Predicate",
"not",
"=",
"new",
"Not",
"(",
"curren... | Called when we leave an NotExpression.
Checks if the expression is preceded by a Not and adds the filter in that case.
@param ctx expression context | [
"Called",
"when",
"we",
"leave",
"an",
"NotExpression",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L394-L400 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.processEdge | private void processEdge(GDLParser.EdgeBodyContext edgeBodyContext, boolean isIncoming) {
String variable = null;
Edge e;
if (edgeBodyContext != null) {
variable = getVariable(edgeBodyContext.header());
}
if (variable != null && userEdgeCache.containsKey(variable)) {
e = userEdgeCache.get(variable);
} else {
e = initNewEdge(edgeBodyContext, isIncoming);
if (variable != null) {
userEdgeCache.put(variable, e);
} else {
variable = String.format(ANONYMOUS_EDGE_VARIABLE, e.getId());
autoEdgeCache.put(variable, e);
}
e.setVariable(variable);
edges.add(e);
}
updateGraphElement(e);
setLastSeenEdge(e);
} | java | private void processEdge(GDLParser.EdgeBodyContext edgeBodyContext, boolean isIncoming) {
String variable = null;
Edge e;
if (edgeBodyContext != null) {
variable = getVariable(edgeBodyContext.header());
}
if (variable != null && userEdgeCache.containsKey(variable)) {
e = userEdgeCache.get(variable);
} else {
e = initNewEdge(edgeBodyContext, isIncoming);
if (variable != null) {
userEdgeCache.put(variable, e);
} else {
variable = String.format(ANONYMOUS_EDGE_VARIABLE, e.getId());
autoEdgeCache.put(variable, e);
}
e.setVariable(variable);
edges.add(e);
}
updateGraphElement(e);
setLastSeenEdge(e);
} | [
"private",
"void",
"processEdge",
"(",
"GDLParser",
".",
"EdgeBodyContext",
"edgeBodyContext",
",",
"boolean",
"isIncoming",
")",
"{",
"String",
"variable",
"=",
"null",
";",
"Edge",
"e",
";",
"if",
"(",
"edgeBodyContext",
"!=",
"null",
")",
"{",
"variable",
... | Processes incoming and outgoing edges.
Checks if the edge has already been created (using its variable). If not, a new edge is created
and added to the edge cache.
@param edgeBodyContext edge body context
@param isIncoming true, if edge is incoming, false for outgoing edge | [
"Processes",
"incoming",
"and",
"outgoing",
"edges",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L444-L467 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.initNewGraph | private Graph initNewGraph(GDLParser.GraphContext graphContext) {
Graph g = new Graph();
g.setId(getNewGraphId());
List<String> labels = getLabels(graphContext.header());
g.setLabels(labels.isEmpty() ?
useDefaultGraphLabel ? Collections.singletonList(defaultGraphLabel) : Collections.emptyList()
: labels);
g.setProperties(getProperties(graphContext.properties()));
return g;
} | java | private Graph initNewGraph(GDLParser.GraphContext graphContext) {
Graph g = new Graph();
g.setId(getNewGraphId());
List<String> labels = getLabels(graphContext.header());
g.setLabels(labels.isEmpty() ?
useDefaultGraphLabel ? Collections.singletonList(defaultGraphLabel) : Collections.emptyList()
: labels);
g.setProperties(getProperties(graphContext.properties()));
return g;
} | [
"private",
"Graph",
"initNewGraph",
"(",
"GDLParser",
".",
"GraphContext",
"graphContext",
")",
"{",
"Graph",
"g",
"=",
"new",
"Graph",
"(",
")",
";",
"g",
".",
"setId",
"(",
"getNewGraphId",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"labels",
"=... | Initializes a new graph from a given graph context.
@param graphContext graph context
@return new graph | [
"Initializes",
"a",
"new",
"graph",
"from",
"a",
"given",
"graph",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L506-L516 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.initNewVertex | private Vertex initNewVertex(GDLParser.VertexContext vertexContext) {
Vertex v = new Vertex();
v.setId(getNewVertexId());
List<String> labels = getLabels(vertexContext.header());
v.setLabels(labels.isEmpty() ?
useDefaultVertexLabel ? Collections.singletonList(defaultVertexLabel) : Collections.emptyList()
: labels);
v.setProperties(getProperties(vertexContext.properties()));
return v;
} | java | private Vertex initNewVertex(GDLParser.VertexContext vertexContext) {
Vertex v = new Vertex();
v.setId(getNewVertexId());
List<String> labels = getLabels(vertexContext.header());
v.setLabels(labels.isEmpty() ?
useDefaultVertexLabel ? Collections.singletonList(defaultVertexLabel) : Collections.emptyList()
: labels);
v.setProperties(getProperties(vertexContext.properties()));
return v;
} | [
"private",
"Vertex",
"initNewVertex",
"(",
"GDLParser",
".",
"VertexContext",
"vertexContext",
")",
"{",
"Vertex",
"v",
"=",
"new",
"Vertex",
"(",
")",
";",
"v",
".",
"setId",
"(",
"getNewVertexId",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"labels... | Initializes a new vertex from a given vertex context.
@param vertexContext vertex context
@return new vertex | [
"Initializes",
"a",
"new",
"vertex",
"from",
"a",
"given",
"vertex",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L524-L534 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.initNewEdge | private Edge initNewEdge(GDLParser.EdgeBodyContext edgeBodyContext, boolean isIncoming) {
boolean hasBody = edgeBodyContext != null;
Edge e = new Edge();
e.setId(getNewEdgeId());
e.setSourceVertexId(getSourceVertexId(isIncoming));
e.setTargetVertexId(getTargetVertexId(isIncoming));
if (hasBody) {
List<String> labels = getLabels(edgeBodyContext.header());
e.setLabels(labels.isEmpty() ?
useDefaultEdgeLabel ? Collections.singletonList(defaultEdgeLabel) : Collections.emptyList()
: labels);
e.setProperties(getProperties(edgeBodyContext.properties()));
int[] range = parseEdgeLengthContext(edgeBodyContext.edgeLength());
e.setLowerBound(range[0]);
e.setUpperBound(range[1]);
} else {
if (useDefaultEdgeLabel) {
e.setLabel(defaultEdgeLabel);
} else {
e.setLabel(null);
}
}
return e;
} | java | private Edge initNewEdge(GDLParser.EdgeBodyContext edgeBodyContext, boolean isIncoming) {
boolean hasBody = edgeBodyContext != null;
Edge e = new Edge();
e.setId(getNewEdgeId());
e.setSourceVertexId(getSourceVertexId(isIncoming));
e.setTargetVertexId(getTargetVertexId(isIncoming));
if (hasBody) {
List<String> labels = getLabels(edgeBodyContext.header());
e.setLabels(labels.isEmpty() ?
useDefaultEdgeLabel ? Collections.singletonList(defaultEdgeLabel) : Collections.emptyList()
: labels);
e.setProperties(getProperties(edgeBodyContext.properties()));
int[] range = parseEdgeLengthContext(edgeBodyContext.edgeLength());
e.setLowerBound(range[0]);
e.setUpperBound(range[1]);
} else {
if (useDefaultEdgeLabel) {
e.setLabel(defaultEdgeLabel);
} else {
e.setLabel(null);
}
}
return e;
} | [
"private",
"Edge",
"initNewEdge",
"(",
"GDLParser",
".",
"EdgeBodyContext",
"edgeBodyContext",
",",
"boolean",
"isIncoming",
")",
"{",
"boolean",
"hasBody",
"=",
"edgeBodyContext",
"!=",
"null",
";",
"Edge",
"e",
"=",
"new",
"Edge",
"(",
")",
";",
"e",
".",
... | Initializes a new edge from the given edge body context.
@param edgeBodyContext edge body context
@param isIncoming true, if it's an incoming edge, false for outgoing edge
@return new edge | [
"Initializes",
"a",
"new",
"edge",
"from",
"the",
"given",
"edge",
"body",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L543-L568 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getVariable | private String getVariable(GDLParser.HeaderContext header) {
if (header != null && header.Identifier() != null) {
return header.Identifier().getText();
}
return null;
} | java | private String getVariable(GDLParser.HeaderContext header) {
if (header != null && header.Identifier() != null) {
return header.Identifier().getText();
}
return null;
} | [
"private",
"String",
"getVariable",
"(",
"GDLParser",
".",
"HeaderContext",
"header",
")",
"{",
"if",
"(",
"header",
"!=",
"null",
"&&",
"header",
".",
"Identifier",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"header",
".",
"Identifier",
"(",
")",
".",
... | Returns the element variable from a given header context.
@param header header context
@return element variable or {@code null} if context was null | [
"Returns",
"the",
"element",
"variable",
"from",
"a",
"given",
"header",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L595-L600 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getLabels | private List<String> getLabels(GDLParser.HeaderContext header) {
if (header != null && header.label() != null) {
return header
.label()
.stream()
.map(RuleContext::getText)
.map(x -> x.substring(1))
.collect(Collectors.toList());
}
return null;
} | java | private List<String> getLabels(GDLParser.HeaderContext header) {
if (header != null && header.label() != null) {
return header
.label()
.stream()
.map(RuleContext::getText)
.map(x -> x.substring(1))
.collect(Collectors.toList());
}
return null;
} | [
"private",
"List",
"<",
"String",
">",
"getLabels",
"(",
"GDLParser",
".",
"HeaderContext",
"header",
")",
"{",
"if",
"(",
"header",
"!=",
"null",
"&&",
"header",
".",
"label",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"header",
".",
"label",
"(",
... | Returns the element labels from a given header context.
@param header header context
@return element labels or {@code null} if context was null | [
"Returns",
"the",
"element",
"labels",
"from",
"a",
"given",
"header",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L608-L618 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getProperties | private Map<String, Object> getProperties(GDLParser.PropertiesContext propertiesContext) {
if (propertiesContext != null) {
Map<String, Object> properties = new HashMap<>();
for (GDLParser.PropertyContext property : propertiesContext.property()) {
properties.put(property.Identifier().getText(), getPropertyValue(property.literal()));
}
return properties;
}
return Collections.emptyMap();
} | java | private Map<String, Object> getProperties(GDLParser.PropertiesContext propertiesContext) {
if (propertiesContext != null) {
Map<String, Object> properties = new HashMap<>();
for (GDLParser.PropertyContext property : propertiesContext.property()) {
properties.put(property.Identifier().getText(), getPropertyValue(property.literal()));
}
return properties;
}
return Collections.emptyMap();
} | [
"private",
"Map",
"<",
"String",
",",
"Object",
">",
"getProperties",
"(",
"GDLParser",
".",
"PropertiesContext",
"propertiesContext",
")",
"{",
"if",
"(",
"propertiesContext",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"... | Returns the properties map from a given properties context.
@param propertiesContext properties context
@return properties map or {@code null} if context was null | [
"Returns",
"the",
"properties",
"map",
"from",
"a",
"given",
"properties",
"context",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L626-L635 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.getPropertyValue | private Object getPropertyValue(GDLParser.LiteralContext literalContext) {
String text;
if (literalContext.StringLiteral() != null) {
return parseString(literalContext.StringLiteral().getText());
} else if (literalContext.BooleanLiteral() != null) {
return Boolean.parseBoolean(literalContext.BooleanLiteral().getText());
} else if (literalContext.IntegerLiteral() != null) {
text = literalContext.IntegerLiteral().getText().toLowerCase();
if (text.endsWith("l")) {
return Long.parseLong(text.substring(0, text.length() - 1));
}
return Integer.parseInt(text);
} else if (literalContext.FloatingPointLiteral() != null) {
text = literalContext.FloatingPointLiteral().getText().toLowerCase();
if (text.endsWith("f")) {
return Float.parseFloat(text.substring(0, text.length() - 1));
} else if (text.endsWith("d")) {
return Double.parseDouble(text.substring(0, text.length() - 1));
}
return Float.parseFloat(text);
}
return null;
} | java | private Object getPropertyValue(GDLParser.LiteralContext literalContext) {
String text;
if (literalContext.StringLiteral() != null) {
return parseString(literalContext.StringLiteral().getText());
} else if (literalContext.BooleanLiteral() != null) {
return Boolean.parseBoolean(literalContext.BooleanLiteral().getText());
} else if (literalContext.IntegerLiteral() != null) {
text = literalContext.IntegerLiteral().getText().toLowerCase();
if (text.endsWith("l")) {
return Long.parseLong(text.substring(0, text.length() - 1));
}
return Integer.parseInt(text);
} else if (literalContext.FloatingPointLiteral() != null) {
text = literalContext.FloatingPointLiteral().getText().toLowerCase();
if (text.endsWith("f")) {
return Float.parseFloat(text.substring(0, text.length() - 1));
} else if (text.endsWith("d")) {
return Double.parseDouble(text.substring(0, text.length() - 1));
}
return Float.parseFloat(text);
}
return null;
} | [
"private",
"Object",
"getPropertyValue",
"(",
"GDLParser",
".",
"LiteralContext",
"literalContext",
")",
"{",
"String",
"text",
";",
"if",
"(",
"literalContext",
".",
"StringLiteral",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"parseString",
"(",
"literalContex... | Returns the corresponding value for a given literal.
@param literalContext literal context
@return parsed value | [
"Returns",
"the",
"corresponding",
"value",
"for",
"a",
"given",
"literal",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L643-L665 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.buildComparison | private Comparison buildComparison(GDLParser.ComparisonExpressionContext ctx) {
ComparableExpression lhs = extractComparableExpression(ctx.comparisonElement(0));
ComparableExpression rhs = extractComparableExpression(ctx.comparisonElement(1));
Comparator comp = Comparator.fromString(ctx .ComparisonOP().getText());
return new Comparison(lhs, comp, rhs);
} | java | private Comparison buildComparison(GDLParser.ComparisonExpressionContext ctx) {
ComparableExpression lhs = extractComparableExpression(ctx.comparisonElement(0));
ComparableExpression rhs = extractComparableExpression(ctx.comparisonElement(1));
Comparator comp = Comparator.fromString(ctx .ComparisonOP().getText());
return new Comparison(lhs, comp, rhs);
} | [
"private",
"Comparison",
"buildComparison",
"(",
"GDLParser",
".",
"ComparisonExpressionContext",
"ctx",
")",
"{",
"ComparableExpression",
"lhs",
"=",
"extractComparableExpression",
"(",
"ctx",
".",
"comparisonElement",
"(",
"0",
")",
")",
";",
"ComparableExpression",
... | Builds a Comparison filter operator from comparison context
@param ctx the comparison context that will be parsed
@return parsed operator | [
"Builds",
"a",
"Comparison",
"filter",
"operator",
"from",
"comparison",
"context"
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L706-L712 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.extractComparableExpression | private ComparableExpression extractComparableExpression(GDLParser.ComparisonElementContext element) {
if(element.literal() != null) {
return new Literal(getPropertyValue(element.literal()));
} else if(element.propertyLookup() != null) {
return buildPropertySelector(element.propertyLookup());
} else {
return new ElementSelector(element.Identifier().getText());
}
} | java | private ComparableExpression extractComparableExpression(GDLParser.ComparisonElementContext element) {
if(element.literal() != null) {
return new Literal(getPropertyValue(element.literal()));
} else if(element.propertyLookup() != null) {
return buildPropertySelector(element.propertyLookup());
} else {
return new ElementSelector(element.Identifier().getText());
}
} | [
"private",
"ComparableExpression",
"extractComparableExpression",
"(",
"GDLParser",
".",
"ComparisonElementContext",
"element",
")",
"{",
"if",
"(",
"element",
".",
"literal",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"new",
"Literal",
"(",
"getPropertyValue",
"... | Extracts a ComparableExpression from comparissonElement
@param element comparissonElement
@return extracted comparable expression | [
"Extracts",
"a",
"ComparableExpression",
"from",
"comparissonElement"
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L720-L728 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.buildPropertySelector | private PropertySelector buildPropertySelector(GDLParser.PropertyLookupContext ctx) {
GraphElement element;
String identifier = ctx.Identifier(0).getText();
String property = ctx.Identifier(1).getText();
if(userVertexCache.containsKey(identifier)) {
element = userVertexCache.get(identifier);
}
else if(userEdgeCache.containsKey(identifier)) {
element = userEdgeCache.get(identifier);
}
else { throw new InvalidReferenceException(identifier);}
return new PropertySelector(element.getVariable(),property);
} | java | private PropertySelector buildPropertySelector(GDLParser.PropertyLookupContext ctx) {
GraphElement element;
String identifier = ctx.Identifier(0).getText();
String property = ctx.Identifier(1).getText();
if(userVertexCache.containsKey(identifier)) {
element = userVertexCache.get(identifier);
}
else if(userEdgeCache.containsKey(identifier)) {
element = userEdgeCache.get(identifier);
}
else { throw new InvalidReferenceException(identifier);}
return new PropertySelector(element.getVariable(),property);
} | [
"private",
"PropertySelector",
"buildPropertySelector",
"(",
"GDLParser",
".",
"PropertyLookupContext",
"ctx",
")",
"{",
"GraphElement",
"element",
";",
"String",
"identifier",
"=",
"ctx",
".",
"Identifier",
"(",
"0",
")",
".",
"getText",
"(",
")",
";",
"String"... | Builds an property selector expression like alice.age
@param ctx the property lookup context that will be parsed
@return parsed property selector expression | [
"Builds",
"an",
"property",
"selector",
"expression",
"like",
"alice",
".",
"age"
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L736-L751 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.addPredicates | private void addPredicates(List<Predicate> newPredicates) {
for(Predicate newPredicate : newPredicates) {
if(this.predicates == null) {
this.predicates = newPredicate;
} else {
this.predicates = new And(this.predicates, newPredicate);
}
}
} | java | private void addPredicates(List<Predicate> newPredicates) {
for(Predicate newPredicate : newPredicates) {
if(this.predicates == null) {
this.predicates = newPredicate;
} else {
this.predicates = new And(this.predicates, newPredicate);
}
}
} | [
"private",
"void",
"addPredicates",
"(",
"List",
"<",
"Predicate",
">",
"newPredicates",
")",
"{",
"for",
"(",
"Predicate",
"newPredicate",
":",
"newPredicates",
")",
"{",
"if",
"(",
"this",
".",
"predicates",
"==",
"null",
")",
"{",
"this",
".",
"predicat... | Adds a list of predicates to the current predicates using AND conjunctions
@param newPredicates predicates to be added | [
"Adds",
"a",
"list",
"of",
"predicates",
"to",
"the",
"current",
"predicates",
"using",
"AND",
"conjunctions"
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L825-L833 | train |
s1ck/gdl | src/main/java/org/s1ck/gdl/GDLLoader.java | GDLLoader.updateLastSeenEdge | private void updateLastSeenEdge(Vertex v) {
Edge lastSeenEdge = getLastSeenEdge();
if (lastSeenEdge != null) {
if (lastSeenEdge.getSourceVertexId() == null) {
lastSeenEdge.setSourceVertexId(v.getId());
} else if (lastSeenEdge.getTargetVertexId() == null) {
lastSeenEdge.setTargetVertexId(v.getId());
}
}
} | java | private void updateLastSeenEdge(Vertex v) {
Edge lastSeenEdge = getLastSeenEdge();
if (lastSeenEdge != null) {
if (lastSeenEdge.getSourceVertexId() == null) {
lastSeenEdge.setSourceVertexId(v.getId());
} else if (lastSeenEdge.getTargetVertexId() == null) {
lastSeenEdge.setTargetVertexId(v.getId());
}
}
} | [
"private",
"void",
"updateLastSeenEdge",
"(",
"Vertex",
"v",
")",
"{",
"Edge",
"lastSeenEdge",
"=",
"getLastSeenEdge",
"(",
")",
";",
"if",
"(",
"lastSeenEdge",
"!=",
"null",
")",
"{",
"if",
"(",
"lastSeenEdge",
".",
"getSourceVertexId",
"(",
")",
"==",
"n... | Updates the source or target vertex identifier of the last seen edge.
@param v current vertex | [
"Updates",
"the",
"source",
"or",
"target",
"vertex",
"identifier",
"of",
"the",
"last",
"seen",
"edge",
"."
] | c89b0f83526661823ad3392f338dbf7dc3e3f834 | https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L840-L849 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/MethodUtils.java | MethodUtils.findAnnotatedGetter | public static Method findAnnotatedGetter(Class<?> cls, Class<? extends Annotation> class1) {
for (final Method m : cls.getDeclaredMethods()) {
if (m.getAnnotation( class1 ) != null) {
if (!m.getReturnType().equals( Void.TYPE ) && !Modifier.isAbstract( m.getModifiers() )
&& (m.getParameterTypes().length == 0)
// must be public
&& (Modifier.isPublic( m.getModifiers() ))) {
return m;
}
}
}
return null;
} | java | public static Method findAnnotatedGetter(Class<?> cls, Class<? extends Annotation> class1) {
for (final Method m : cls.getDeclaredMethods()) {
if (m.getAnnotation( class1 ) != null) {
if (!m.getReturnType().equals( Void.TYPE ) && !Modifier.isAbstract( m.getModifiers() )
&& (m.getParameterTypes().length == 0)
// must be public
&& (Modifier.isPublic( m.getModifiers() ))) {
return m;
}
}
}
return null;
} | [
"public",
"static",
"Method",
"findAnnotatedGetter",
"(",
"Class",
"<",
"?",
">",
"cls",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"class1",
")",
"{",
"for",
"(",
"final",
"Method",
"m",
":",
"cls",
".",
"getDeclaredMethods",
"(",
")",
")",
... | Find a getter with the specified annotation. getter must be annotated,
return a value, not be abstract and not take any parameters and is
public.
@param cls
Class that declares the method to find.
@param class1
the annotation to find.
@return getter method or null | [
"Find",
"a",
"getter",
"with",
"the",
"specified",
"annotation",
".",
"getter",
"must",
"be",
"annotated",
"return",
"a",
"value",
"not",
"be",
"abstract",
"and",
"not",
"take",
"any",
"parameters",
"and",
"is",
"public",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/MethodUtils.java#L41-L53 | train |
zzsrv/torrent-utils | src/main/java/cc/vcode/util/SHA1Hasher.java | SHA1Hasher.update | public void update( byte[] data, int pos, int len ) {
update( ByteBuffer.wrap( data, pos, len ));
} | java | public void update( byte[] data, int pos, int len ) {
update( ByteBuffer.wrap( data, pos, len ));
} | [
"public",
"void",
"update",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"pos",
",",
"int",
"len",
")",
"{",
"update",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"data",
",",
"pos",
",",
"len",
")",
")",
";",
"}"
] | Start or continue a hash calculation with the given data,
starting at the given position, for the given length.
@param data input
@param pos start position
@param len length | [
"Start",
"or",
"continue",
"a",
"hash",
"calculation",
"with",
"the",
"given",
"data",
"starting",
"at",
"the",
"given",
"position",
"for",
"the",
"given",
"length",
"."
] | 70ba8bccd5af1ed7a18c42c61ad409256e9865f3 | https://github.com/zzsrv/torrent-utils/blob/70ba8bccd5af1ed7a18c42c61ad409256e9865f3/src/main/java/cc/vcode/util/SHA1Hasher.java#L66-L68 | train |
Claudenw/junit-contracts | maven/src/main/java/org/xenei/contracts/maven/ReportConfig.java | ReportConfig.setFilter | public void setFilter(String filter) throws IllegalArgumentException {
if (StringUtils.isBlank(filter)) {
this.filter = ClassPathFilter.TRUE;
} else {
this.filter = new Parser().parse(filter);
}
} | java | public void setFilter(String filter) throws IllegalArgumentException {
if (StringUtils.isBlank(filter)) {
this.filter = ClassPathFilter.TRUE;
} else {
this.filter = new Parser().parse(filter);
}
} | [
"public",
"void",
"setFilter",
"(",
"String",
"filter",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"filter",
")",
")",
"{",
"this",
".",
"filter",
"=",
"ClassPathFilter",
".",
"TRUE",
";",
"}",
"else",
"{... | Set the class filter. Only classes that pass the filter will be included.
By default the filter accepts all classes. Passing a null or null length
string will result in all classes passing the test.
@param filter
The string representation of the filter. May be null.
@throws IllegalArgumentException if the filter can not be parsed. | [
"Set",
"the",
"class",
"filter",
".",
"Only",
"classes",
"that",
"pass",
"the",
"filter",
"will",
"be",
"included",
".",
"By",
"default",
"the",
"filter",
"accepts",
"all",
"classes",
".",
"Passing",
"a",
"null",
"or",
"null",
"length",
"string",
"will",
... | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/maven/src/main/java/org/xenei/contracts/maven/ReportConfig.java#L79-L85 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/ContractSuite.java | ContractSuite.getContractImpl | private ContractImpl getContractImpl(final Class<?> cls) throws InitializationError {
final ContractImpl impl = cls.getAnnotation( ContractImpl.class );
if (impl == null) {
throw new InitializationError( "Classes annotated as @RunWith( ContractSuite ) [" + cls
+ "] must also be annotated with @ContractImpl" );
}
return impl;
} | java | private ContractImpl getContractImpl(final Class<?> cls) throws InitializationError {
final ContractImpl impl = cls.getAnnotation( ContractImpl.class );
if (impl == null) {
throw new InitializationError( "Classes annotated as @RunWith( ContractSuite ) [" + cls
+ "] must also be annotated with @ContractImpl" );
}
return impl;
} | [
"private",
"ContractImpl",
"getContractImpl",
"(",
"final",
"Class",
"<",
"?",
">",
"cls",
")",
"throws",
"InitializationError",
"{",
"final",
"ContractImpl",
"impl",
"=",
"cls",
".",
"getAnnotation",
"(",
"ContractImpl",
".",
"class",
")",
";",
"if",
"(",
"... | Get the ContractImpl annotation. Logs an error if the annotation is not
found.
@param cls
The class to look on
@return ContractImpl or null if not found.
@throws InitializationError | [
"Get",
"the",
"ContractImpl",
"annotation",
".",
"Logs",
"an",
"error",
"if",
"the",
"annotation",
"is",
"not",
"found",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/ContractSuite.java#L153-L161 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/ContractSuite.java | ContractSuite.getExcludedMethods | private List<Method> getExcludedMethods(final Class<?> cls) {
final List<Method> lst = new ArrayList<Method>();
for (final ContractExclude exclude : cls.getAnnotationsByType( ContractExclude.class )) {
final Class<?> clazz = exclude.value();
for (final String mthdName : exclude.methods()) {
try {
lst.add( clazz.getDeclaredMethod( mthdName ) );
} catch (NoSuchMethodException | SecurityException e) {
LOG.warn( String.format( "ContractExclude annotation on %s incorrect", cls ), e );
}
}
}
return lst;
} | java | private List<Method> getExcludedMethods(final Class<?> cls) {
final List<Method> lst = new ArrayList<Method>();
for (final ContractExclude exclude : cls.getAnnotationsByType( ContractExclude.class )) {
final Class<?> clazz = exclude.value();
for (final String mthdName : exclude.methods()) {
try {
lst.add( clazz.getDeclaredMethod( mthdName ) );
} catch (NoSuchMethodException | SecurityException e) {
LOG.warn( String.format( "ContractExclude annotation on %s incorrect", cls ), e );
}
}
}
return lst;
} | [
"private",
"List",
"<",
"Method",
">",
"getExcludedMethods",
"(",
"final",
"Class",
"<",
"?",
">",
"cls",
")",
"{",
"final",
"List",
"<",
"Method",
">",
"lst",
"=",
"new",
"ArrayList",
"<",
"Method",
">",
"(",
")",
";",
"for",
"(",
"final",
"Contract... | Get the ContractExclude annotation and extract the list of methods from
it.
logs error if method is not found on the class specified in the
annotation.
@param cls
The class on which to for the annotation.
@param errors
The list of errors to add to if there is an error
@return A list of methods. May be empty.
@throws InitializationError | [
"Get",
"the",
"ContractExclude",
"annotation",
"and",
"extract",
"the",
"list",
"of",
"methods",
"from",
"it",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/ContractSuite.java#L177-L191 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/ContractSuite.java | ContractSuite.addDynamicClasses | private List<Runner> addDynamicClasses(final RunnerBuilder builder, final ContractTestMap contractTestMap,
final Dynamic dynamic) throws InitializationError {
final Class<? extends Dynamic> dynamicClass = dynamic.getClass();
// this is the list of all the JUnit runners in the suite.
final List<Runner> runners = new ArrayList<Runner>();
ContractImpl impl = getContractImpl( dynamicClass );
if (impl == null) {
return runners;
}
final DynamicSuiteInfo dynamicSuiteInfo = new DynamicSuiteInfo( dynamicClass, impl );
final Collection<Class<?>> tests = dynamic.getSuiteClasses();
if ((tests == null) || (tests.size() == 0)) {
dynamicSuiteInfo
.addError( new InitializationError( "Dynamic suite did not return a list of classes to execute" ) );
runners.add( new TestInfoErrorRunner( dynamicClass, dynamicSuiteInfo ) );
} else {
for (final Class<?> test : tests) {
final RunWith runwith = test.getAnnotation( RunWith.class );
if ((runwith != null) && runwith.value().equals( ContractSuite.class )) {
impl = getContractImpl( test );
if (impl != null) {
final DynamicTestInfo parentTestInfo = new DynamicTestInfo( test, impl, dynamicSuiteInfo );
if (!parentTestInfo.hasErrors()) {
addSpecifiedClasses( runners, test, builder, contractTestMap, dynamic, parentTestInfo );
}
// this is not an else as addSpecifiedClasses may add
// errors to parentTestInfo
if (parentTestInfo.hasErrors()) {
runners.add( new TestInfoErrorRunner( dynamicClass, parentTestInfo ) );
}
}
} else {
try {
runners.add( builder.runnerForClass( test ) );
} catch (final Throwable t) {
throw new InitializationError( t );
}
}
}
}
return runners;
} | java | private List<Runner> addDynamicClasses(final RunnerBuilder builder, final ContractTestMap contractTestMap,
final Dynamic dynamic) throws InitializationError {
final Class<? extends Dynamic> dynamicClass = dynamic.getClass();
// this is the list of all the JUnit runners in the suite.
final List<Runner> runners = new ArrayList<Runner>();
ContractImpl impl = getContractImpl( dynamicClass );
if (impl == null) {
return runners;
}
final DynamicSuiteInfo dynamicSuiteInfo = new DynamicSuiteInfo( dynamicClass, impl );
final Collection<Class<?>> tests = dynamic.getSuiteClasses();
if ((tests == null) || (tests.size() == 0)) {
dynamicSuiteInfo
.addError( new InitializationError( "Dynamic suite did not return a list of classes to execute" ) );
runners.add( new TestInfoErrorRunner( dynamicClass, dynamicSuiteInfo ) );
} else {
for (final Class<?> test : tests) {
final RunWith runwith = test.getAnnotation( RunWith.class );
if ((runwith != null) && runwith.value().equals( ContractSuite.class )) {
impl = getContractImpl( test );
if (impl != null) {
final DynamicTestInfo parentTestInfo = new DynamicTestInfo( test, impl, dynamicSuiteInfo );
if (!parentTestInfo.hasErrors()) {
addSpecifiedClasses( runners, test, builder, contractTestMap, dynamic, parentTestInfo );
}
// this is not an else as addSpecifiedClasses may add
// errors to parentTestInfo
if (parentTestInfo.hasErrors()) {
runners.add( new TestInfoErrorRunner( dynamicClass, parentTestInfo ) );
}
}
} else {
try {
runners.add( builder.runnerForClass( test ) );
} catch (final Throwable t) {
throw new InitializationError( t );
}
}
}
}
return runners;
} | [
"private",
"List",
"<",
"Runner",
">",
"addDynamicClasses",
"(",
"final",
"RunnerBuilder",
"builder",
",",
"final",
"ContractTestMap",
"contractTestMap",
",",
"final",
"Dynamic",
"dynamic",
")",
"throws",
"InitializationError",
"{",
"final",
"Class",
"<",
"?",
"ex... | Add dynamic classes to the suite.
@param builder
The builder to use
@param errors
The list of errors
@param contractTestMap
The ContractTest map.
@param dynamic
The instance of the dynamic test.
@return The list of runners.
@throws InitializationError | [
"Add",
"dynamic",
"classes",
"to",
"the",
"suite",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/ContractSuite.java#L207-L251 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/ContractSuite.java | ContractSuite.addAnnotatedClasses | private List<Runner> addAnnotatedClasses(final Class<?> baseClass, final RunnerBuilder builder,
final ContractTestMap contractTestMap, final Object baseObj) throws InitializationError {
final List<Runner> runners = new ArrayList<Runner>();
final ContractImpl impl = getContractImpl( baseClass );
if (impl != null) {
TestInfo testInfo = contractTestMap.getInfoByTestClass( impl.value() );
if (testInfo == null) {
testInfo = new SuiteInfo( baseClass, impl );
contractTestMap.add( testInfo );
}
if (!testInfo.hasErrors()) {
addSpecifiedClasses( runners, baseClass, builder, contractTestMap, baseObj, testInfo );
}
// this is not an else since addSpecifiedClasses may add errors to
// testInfo.
if (testInfo.hasErrors()) {
runners.add( new TestInfoErrorRunner( baseClass, testInfo ) );
}
}
return runners;
} | java | private List<Runner> addAnnotatedClasses(final Class<?> baseClass, final RunnerBuilder builder,
final ContractTestMap contractTestMap, final Object baseObj) throws InitializationError {
final List<Runner> runners = new ArrayList<Runner>();
final ContractImpl impl = getContractImpl( baseClass );
if (impl != null) {
TestInfo testInfo = contractTestMap.getInfoByTestClass( impl.value() );
if (testInfo == null) {
testInfo = new SuiteInfo( baseClass, impl );
contractTestMap.add( testInfo );
}
if (!testInfo.hasErrors()) {
addSpecifiedClasses( runners, baseClass, builder, contractTestMap, baseObj, testInfo );
}
// this is not an else since addSpecifiedClasses may add errors to
// testInfo.
if (testInfo.hasErrors()) {
runners.add( new TestInfoErrorRunner( baseClass, testInfo ) );
}
}
return runners;
} | [
"private",
"List",
"<",
"Runner",
">",
"addAnnotatedClasses",
"(",
"final",
"Class",
"<",
"?",
">",
"baseClass",
",",
"final",
"RunnerBuilder",
"builder",
",",
"final",
"ContractTestMap",
"contractTestMap",
",",
"final",
"Object",
"baseObj",
")",
"throws",
"Init... | Add annotated classes to the test
@param baseClass
the base test class
@param builder
The builder to use
@param contractTestMap
The ContractTest map.
@param baseObj
this is the instance object that we will use to get the
producer instance.
@return the list of runners
@throws InitializationError | [
"Add",
"annotated",
"classes",
"to",
"the",
"test"
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/ContractSuite.java#L268-L289 | train |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/ContractSuite.java | ContractSuite.addSpecifiedClasses | private void addSpecifiedClasses(final List<Runner> runners, final Class<?> testClass, final RunnerBuilder builder,
final ContractTestMap contractTestMap, final Object baseObj, final TestInfo parentTestInfo)
throws InitializationError {
// this is the list of all the JUnit runners in the suite.
final Set<TestInfo> testClasses = new LinkedHashSet<TestInfo>();
// we have a RunWith annotated class: Klass
// see if it is in the annotatedClasses
final BaseClassRunner bcr = new BaseClassRunner( testClass );
if (bcr.computeTestMethods().size() > 0) {
runners.add( bcr );
}
final List<Method> excludeMethods = getExcludedMethods( getTestClass().getJavaClass() );
/*
* get all the annotated classes that test the interfaces that
* parentTestInfo implements and iterate over them
*/
for (final TestInfo testInfo : contractTestMap.getAnnotatedClasses( testClasses, parentTestInfo )) {
if (!Arrays.asList( parentTestInfo.getSkipTests() ).contains( testInfo.getClassUnderTest() )) {
if (testInfo.getErrors().size() > 0) {
final TestInfoErrorRunner runner = new TestInfoErrorRunner( testClass, testInfo );
runner.logErrors( LOG );
runners.add( runner );
} else {
runners.add( new ContractTestRunner( baseObj, parentTestInfo, testInfo, excludeMethods ) );
}
}
}
if (runners.size() == 0) {
LOG.info( "No tests for " + testClass );
}
} | java | private void addSpecifiedClasses(final List<Runner> runners, final Class<?> testClass, final RunnerBuilder builder,
final ContractTestMap contractTestMap, final Object baseObj, final TestInfo parentTestInfo)
throws InitializationError {
// this is the list of all the JUnit runners in the suite.
final Set<TestInfo> testClasses = new LinkedHashSet<TestInfo>();
// we have a RunWith annotated class: Klass
// see if it is in the annotatedClasses
final BaseClassRunner bcr = new BaseClassRunner( testClass );
if (bcr.computeTestMethods().size() > 0) {
runners.add( bcr );
}
final List<Method> excludeMethods = getExcludedMethods( getTestClass().getJavaClass() );
/*
* get all the annotated classes that test the interfaces that
* parentTestInfo implements and iterate over them
*/
for (final TestInfo testInfo : contractTestMap.getAnnotatedClasses( testClasses, parentTestInfo )) {
if (!Arrays.asList( parentTestInfo.getSkipTests() ).contains( testInfo.getClassUnderTest() )) {
if (testInfo.getErrors().size() > 0) {
final TestInfoErrorRunner runner = new TestInfoErrorRunner( testClass, testInfo );
runner.logErrors( LOG );
runners.add( runner );
} else {
runners.add( new ContractTestRunner( baseObj, parentTestInfo, testInfo, excludeMethods ) );
}
}
}
if (runners.size() == 0) {
LOG.info( "No tests for " + testClass );
}
} | [
"private",
"void",
"addSpecifiedClasses",
"(",
"final",
"List",
"<",
"Runner",
">",
"runners",
",",
"final",
"Class",
"<",
"?",
">",
"testClass",
",",
"final",
"RunnerBuilder",
"builder",
",",
"final",
"ContractTestMap",
"contractTestMap",
",",
"final",
"Object"... | Adds the specified classes to to the test suite.
May add error notations to the parentTestInfo.
@param runners
The list of runners to add the test to
@param testClass
The class under test
@param builder
The builder to user
@param errors
The list of errors.
@param contractTestMap
The ContractTestMap
@param baseObj
The object under test
@param parentTestInfo
The parent test Info.
@throws InitializationError | [
"Adds",
"the",
"specified",
"classes",
"to",
"to",
"the",
"test",
"suite",
"."
] | 47e7294dbff374cdd875b3aafe28db48a37fe4d4 | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/ContractSuite.java#L312-L350 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/api/Ortc.java | Ortc.saveAuthentication | public static void saveAuthentication(String url, boolean isCluster,
final String authenticationToken, final boolean authenticationTokenIsPrivate,
final String applicationKey, final int timeToLive, final String privateKey,
final Map<String, ChannelPermissions> permissions,
final OnRestWebserviceResponse onCompleted) throws IOException,
InvalidBalancerServerException,
OrtcAuthenticationNotAuthorizedException {
HashMap<String, LinkedList<ChannelPermissions>> permissionsMap = new HashMap<String, LinkedList<ChannelPermissions>>();
Set<String> channels = permissions.keySet();
for (String channelName : channels) {
LinkedList<ChannelPermissions> channelPermissionList = new LinkedList<ChannelPermissions>();
channelPermissionList.add(permissions.get(channelName));
permissionsMap.put(channelName, channelPermissionList);
}
saveAuthentication(url, isCluster, authenticationToken, authenticationTokenIsPrivate, applicationKey, timeToLive, privateKey, permissionsMap, onCompleted);
} | java | public static void saveAuthentication(String url, boolean isCluster,
final String authenticationToken, final boolean authenticationTokenIsPrivate,
final String applicationKey, final int timeToLive, final String privateKey,
final Map<String, ChannelPermissions> permissions,
final OnRestWebserviceResponse onCompleted) throws IOException,
InvalidBalancerServerException,
OrtcAuthenticationNotAuthorizedException {
HashMap<String, LinkedList<ChannelPermissions>> permissionsMap = new HashMap<String, LinkedList<ChannelPermissions>>();
Set<String> channels = permissions.keySet();
for (String channelName : channels) {
LinkedList<ChannelPermissions> channelPermissionList = new LinkedList<ChannelPermissions>();
channelPermissionList.add(permissions.get(channelName));
permissionsMap.put(channelName, channelPermissionList);
}
saveAuthentication(url, isCluster, authenticationToken, authenticationTokenIsPrivate, applicationKey, timeToLive, privateKey, permissionsMap, onCompleted);
} | [
"public",
"static",
"void",
"saveAuthentication",
"(",
"String",
"url",
",",
"boolean",
"isCluster",
",",
"final",
"String",
"authenticationToken",
",",
"final",
"boolean",
"authenticationTokenIsPrivate",
",",
"final",
"String",
"applicationKey",
",",
"final",
"int",
... | Asynchronously saves the authentication token channels permissions in the ORTC server.
<pre>
HashMap<String, ChannelPermissions> permissions = new HashMap<String, ChannelPermissions>();
permissions.put("channel1:*", ChannelPermissions.Write);
permissions.put("channel1", ChannelPermissions.Write);
if (!Ortc.saveAuthentication("http://ortc-developers.realtime.co/server/2.1/",
true, "SessionId", false, "APPKEY", 1800, "PVTKEY", permissions)) {
throw new Exception("Was not possible to authenticate");
}
</pre>
@param url
Ortc Server Url
@param isCluster
Indicates whether the ORTC server is in a cluster.
@param authenticationToken
Authentication Token which is generated by the application
server, for instance a unique session ID.
@param authenticationTokenIsPrivate
Indicates whether the authentication token is private (true)
or not (false)
@param applicationKey
Application Key that was provided to you together with the
ORTC service purchasing.
@param timeToLive
The authentication token time to live, in other words, the
allowed activity time (in seconds).
@param privateKey
The private key provided to you together with the ORTC service
purchasing.
@param permissions
The channels and their permissions (w: write/read or r: read
or p: presence, case sensitive).
@param onCompleted
The callback that is executed after the save authentication is completed
@throws ibt.ortc.api.OrtcAuthenticationNotAuthorizedException | [
"Asynchronously",
"saves",
"the",
"authentication",
"token",
"channels",
"permissions",
"in",
"the",
"ORTC",
"server",
"."
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/api/Ortc.java#L430-L448 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/ChannelSubscription.java | ChannelSubscription.runHandler | public void runHandler(OrtcClient sender, String channel, String message){
this.runHandler(sender, channel, message, false, null);
} | java | public void runHandler(OrtcClient sender, String channel, String message){
this.runHandler(sender, channel, message, false, null);
} | [
"public",
"void",
"runHandler",
"(",
"OrtcClient",
"sender",
",",
"String",
"channel",
",",
"String",
"message",
")",
"{",
"this",
".",
"runHandler",
"(",
"sender",
",",
"channel",
",",
"message",
",",
"false",
",",
"null",
")",
";",
"}"
] | Fires the event handler that is associated the subscribed channel
@param channel
@param sender
@param message | [
"Fires",
"the",
"event",
"handler",
"that",
"is",
"associated",
"the",
"subscribed",
"channel"
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/ChannelSubscription.java#L111-L113 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/OrtcClient.java | OrtcClient.publish | public void publish(final String channel, String message, final int ttl, OnPublishResult callback) {
// CAUSE: Assignment to method parameter
final Pair<Boolean, String> sendValidation = isSendValid(channel, message);
//String lMessage = message.replace("\n", "\\n");
if (sendValidation != null && sendValidation.first) {
try {
final String messageId = Strings.randomString(8);
final ArrayList<Pair<String, String>> messagesToSend = multiPartMessage(message, messageId);
CountDownTimer ackTimeout = new CountDownTimer(this.publishTimeout, 100) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
if (pendingPublishMessages.containsKey(messageId)) {
String err = String.format("Message publish timeout after %l seconds", publishTimeout);
if (pendingPublishMessages != null && ((HashMap) pendingPublishMessages.get(messageId)).containsKey("callback")) {
OnPublishResult callbackP = (OnPublishResult) ((HashMap) pendingPublishMessages.get(messageId)).get("callback");
callbackP.run(err, null);
pendingPublishMessages.remove(messageId);
}
pendingPublishMessages.remove(messageId);
}
}
}.start();
Map pendingMsg = new HashMap();
pendingMsg.put("totalNumOfParts", messagesToSend.size());
pendingMsg.put("callback", callback);
pendingMsg.put("timeout", ackTimeout);
this.pendingPublishMessages.put(messageId, pendingMsg);
if (messagesToSend.size() < 20) {
for (Pair<String, String> messageToSend : messagesToSend) {
publish(channel, messageToSend.second, ttl, messageToSend.first,
sendValidation.second);
}
} else {
partSendInterval = new CountDownTimer(messagesToSend.size() * 100, 100) {
int partsSent = 0;
public void onTick(long millisUntilFinished) {
int currentPart = partsSent + 1;
if (isConnected) {
Pair<String, String> messageToSend = messagesToSend.get(currentPart);
publish(channel, messageToSend.second, ttl, messageToSend.first,
sendValidation.second);
partsSent++;
}
}
public void onFinish() {
}
}.start();
}
}catch(IOException e){
raiseOrtcEvent(EventEnum.OnException, this, e);
}
}
} | java | public void publish(final String channel, String message, final int ttl, OnPublishResult callback) {
// CAUSE: Assignment to method parameter
final Pair<Boolean, String> sendValidation = isSendValid(channel, message);
//String lMessage = message.replace("\n", "\\n");
if (sendValidation != null && sendValidation.first) {
try {
final String messageId = Strings.randomString(8);
final ArrayList<Pair<String, String>> messagesToSend = multiPartMessage(message, messageId);
CountDownTimer ackTimeout = new CountDownTimer(this.publishTimeout, 100) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
if (pendingPublishMessages.containsKey(messageId)) {
String err = String.format("Message publish timeout after %l seconds", publishTimeout);
if (pendingPublishMessages != null && ((HashMap) pendingPublishMessages.get(messageId)).containsKey("callback")) {
OnPublishResult callbackP = (OnPublishResult) ((HashMap) pendingPublishMessages.get(messageId)).get("callback");
callbackP.run(err, null);
pendingPublishMessages.remove(messageId);
}
pendingPublishMessages.remove(messageId);
}
}
}.start();
Map pendingMsg = new HashMap();
pendingMsg.put("totalNumOfParts", messagesToSend.size());
pendingMsg.put("callback", callback);
pendingMsg.put("timeout", ackTimeout);
this.pendingPublishMessages.put(messageId, pendingMsg);
if (messagesToSend.size() < 20) {
for (Pair<String, String> messageToSend : messagesToSend) {
publish(channel, messageToSend.second, ttl, messageToSend.first,
sendValidation.second);
}
} else {
partSendInterval = new CountDownTimer(messagesToSend.size() * 100, 100) {
int partsSent = 0;
public void onTick(long millisUntilFinished) {
int currentPart = partsSent + 1;
if (isConnected) {
Pair<String, String> messageToSend = messagesToSend.get(currentPart);
publish(channel, messageToSend.second, ttl, messageToSend.first,
sendValidation.second);
partsSent++;
}
}
public void onFinish() {
}
}.start();
}
}catch(IOException e){
raiseOrtcEvent(EventEnum.OnException, this, e);
}
}
} | [
"public",
"void",
"publish",
"(",
"final",
"String",
"channel",
",",
"String",
"message",
",",
"final",
"int",
"ttl",
",",
"OnPublishResult",
"callback",
")",
"{",
"// CAUSE: Assignment to method parameter",
"final",
"Pair",
"<",
"Boolean",
",",
"String",
">",
"... | Publish a message to a channel.
@param channel
Channel to wich the message should be sent
@param message
The content of the message to be sent
@param ttl
The message expiration time in seconds (0 for maximum allowed ttl).
@param callback
Returns error if message publish was not successful or published message unique id (seqId) if sucessfully published | [
"Publish",
"a",
"message",
"to",
"a",
"channel",
"."
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L525-L596 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/OrtcClient.java | OrtcClient.subscribeWithBuffer | public void subscribeWithBuffer(String channel, String subscriberId, final OnMessageWithBuffer onMessage){
if (subscriberId != null) {
HashMap options = new HashMap();
options.put("channel", channel);
options.put("subscribeOnReconnected", true);
options.put("subscriberId", subscriberId);
this.subscribeWithOptions(options, new OnMessageWithOptions() {
@Override
public void run(OrtcClient sender, Map msgOptions) {
if (msgOptions.containsKey("channel") && msgOptions.containsKey("message")) {
final String channel = (String) msgOptions.get("channel");
final String message = (String) msgOptions.get("message");
final String seqId = (String) msgOptions.get("seqId");
onMessage.run(sender, channel, seqId, message);
}
}
});
}else{
raiseOrtcEvent(
EventEnum.OnException,
this,
new OrtcGcmException(
"subscribeWithBuffer called with no subscriberId"));
}
} | java | public void subscribeWithBuffer(String channel, String subscriberId, final OnMessageWithBuffer onMessage){
if (subscriberId != null) {
HashMap options = new HashMap();
options.put("channel", channel);
options.put("subscribeOnReconnected", true);
options.put("subscriberId", subscriberId);
this.subscribeWithOptions(options, new OnMessageWithOptions() {
@Override
public void run(OrtcClient sender, Map msgOptions) {
if (msgOptions.containsKey("channel") && msgOptions.containsKey("message")) {
final String channel = (String) msgOptions.get("channel");
final String message = (String) msgOptions.get("message");
final String seqId = (String) msgOptions.get("seqId");
onMessage.run(sender, channel, seqId, message);
}
}
});
}else{
raiseOrtcEvent(
EventEnum.OnException,
this,
new OrtcGcmException(
"subscribeWithBuffer called with no subscriberId"));
}
} | [
"public",
"void",
"subscribeWithBuffer",
"(",
"String",
"channel",
",",
"String",
"subscriberId",
",",
"final",
"OnMessageWithBuffer",
"onMessage",
")",
"{",
"if",
"(",
"subscriberId",
"!=",
"null",
")",
"{",
"HashMap",
"options",
"=",
"new",
"HashMap",
"(",
"... | Subscribes to a channel to receive messages published to it.
@param channel
The channel name.
@param subscriberId
The subscriberId associated to the channel.
@param OnMessageWithBuffer
The callback called when a message arrives at the channel and message seqId number. | [
"Subscribes",
"to",
"a",
"channel",
"to",
"receive",
"messages",
"published",
"to",
"it",
"."
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L707-L733 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/OrtcClient.java | OrtcClient.subscribeWithNotifications | public void subscribeWithNotifications(String channel, boolean subscribeOnReconnect, OnMessage onMessage){
_subscribeWithNotifications(channel, subscribeOnReconnect, onMessage, false);
} | java | public void subscribeWithNotifications(String channel, boolean subscribeOnReconnect, OnMessage onMessage){
_subscribeWithNotifications(channel, subscribeOnReconnect, onMessage, false);
} | [
"public",
"void",
"subscribeWithNotifications",
"(",
"String",
"channel",
",",
"boolean",
"subscribeOnReconnect",
",",
"OnMessage",
"onMessage",
")",
"{",
"_subscribeWithNotifications",
"(",
"channel",
",",
"subscribeOnReconnect",
",",
"onMessage",
",",
"false",
")",
... | Subscribe the specified channel in order to receive messages in that
channel with a support of Google Cloud Messaging.
@param channel
Channel to be subscribed
@param subscribeOnReconnect
Indicates if the channel should be subscribe if the event on
reconnected is fired
@param onMessage
Event handler that will be called when a message will be
received on the subscribed channel | [
"Subscribe",
"the",
"specified",
"channel",
"in",
"order",
"to",
"receive",
"messages",
"in",
"that",
"channel",
"with",
"a",
"support",
"of",
"Google",
"Cloud",
"Messaging",
"."
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L893-L895 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/OrtcClient.java | OrtcClient.unsubscribe | public void unsubscribe(String channel) {
ChannelSubscription subscribedChannel = subscribedChannels.get(channel);
if (isUnsubscribeValid(channel, subscribedChannel)) {
subscribedChannel.setSubscribeOnReconnected(false);
unsubscribe(channel, true, subscribedChannel.isWithNotification());
}
//subscribedChannels.remove(channel);
} | java | public void unsubscribe(String channel) {
ChannelSubscription subscribedChannel = subscribedChannels.get(channel);
if (isUnsubscribeValid(channel, subscribedChannel)) {
subscribedChannel.setSubscribeOnReconnected(false);
unsubscribe(channel, true, subscribedChannel.isWithNotification());
}
//subscribedChannels.remove(channel);
} | [
"public",
"void",
"unsubscribe",
"(",
"String",
"channel",
")",
"{",
"ChannelSubscription",
"subscribedChannel",
"=",
"subscribedChannels",
".",
"get",
"(",
"channel",
")",
";",
"if",
"(",
"isUnsubscribeValid",
"(",
"channel",
",",
"subscribedChannel",
")",
")",
... | Stop receiving messages in the specified channel
@param channel
Channel to be unsubscribed | [
"Stop",
"receiving",
"messages",
"in",
"the",
"specified",
"channel"
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L992-L1001 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/OrtcClient.java | OrtcClient.presence | public void presence(String channel, OnPresence callback)
throws OrtcNotConnectedException {
if (!this.isConnected) {
throw new OrtcNotConnectedException();
} else {
String presenceUrl = this.isCluster ? this.clusterUrl : this.url;
Ortc.presence(presenceUrl, this.isCluster, this.applicationKey,
this.authenticationToken, channel, callback);
}
} | java | public void presence(String channel, OnPresence callback)
throws OrtcNotConnectedException {
if (!this.isConnected) {
throw new OrtcNotConnectedException();
} else {
String presenceUrl = this.isCluster ? this.clusterUrl : this.url;
Ortc.presence(presenceUrl, this.isCluster, this.applicationKey,
this.authenticationToken, channel, callback);
}
} | [
"public",
"void",
"presence",
"(",
"String",
"channel",
",",
"OnPresence",
"callback",
")",
"throws",
"OrtcNotConnectedException",
"{",
"if",
"(",
"!",
"this",
".",
"isConnected",
")",
"{",
"throw",
"new",
"OrtcNotConnectedException",
"(",
")",
";",
"}",
"else... | Gets the subscriptions in the specified channel and if active the first
100 unique metadata.
<pre>
Ortc.presence("CHANNEL", new onPresence() {
public void run(Exception error, Presence presence) {
if (error != null) {
System.out.println(error.getMessage());
} else {
System.out.println("Subscriptions - " + presence.getSubscriptions());
Iterator<?> metadataIterator = presence.getMetadata().entrySet()
.iterator();
while (metadataIterator.hasNext()) {
Map.Entry<String, Long> entry = (Map.Entry<String, Long>) metadataIterator
.next();
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
}
});
</pre>
@param channel
Channel with presence data active.
@param callback
Callback with error and result.
@throws OrtcNotConnectedException | [
"Gets",
"the",
"subscriptions",
"in",
"the",
"specified",
"channel",
"and",
"if",
"active",
"the",
"first",
"100",
"unique",
"metadata",
"."
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L1049-L1059 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/OrtcClient.java | OrtcClient.enablePresence | public void enablePresence(String privateKey, String channel,
Boolean metadata, OnEnablePresence callback)
throws OrtcNotConnectedException {
if (!this.isConnected) {
throw new OrtcNotConnectedException();
} else {
String presenceUrl = this.isCluster ? this.clusterUrl : this.url;
Ortc.enablePresence(presenceUrl, this.isCluster,
this.applicationKey, privateKey, channel, metadata,
callback);
}
} | java | public void enablePresence(String privateKey, String channel,
Boolean metadata, OnEnablePresence callback)
throws OrtcNotConnectedException {
if (!this.isConnected) {
throw new OrtcNotConnectedException();
} else {
String presenceUrl = this.isCluster ? this.clusterUrl : this.url;
Ortc.enablePresence(presenceUrl, this.isCluster,
this.applicationKey, privateKey, channel, metadata,
callback);
}
} | [
"public",
"void",
"enablePresence",
"(",
"String",
"privateKey",
",",
"String",
"channel",
",",
"Boolean",
"metadata",
",",
"OnEnablePresence",
"callback",
")",
"throws",
"OrtcNotConnectedException",
"{",
"if",
"(",
"!",
"this",
".",
"isConnected",
")",
"{",
"th... | Enables presence for the specified channel with first 100 unique metadata
if metadata is set to true.
<pre>
Ortc.enablePresence("PRIVATE_KEY", "CHANNEL", true, new onEnablePresence() {
public void run(Exception error, String result) {
if (error != null) {
System.out.println(error.getMessage());
} else {
System.out.println(result);
}
}
});
</pre>
@param privateKey
The private key provided when the ORTC service is purchased.
@param channel
Channel with presence data active.
@param metadata
Defines if to collect first 100 unique metadata.
@param callback
Callback with error and result.
@throws OrtcNotConnectedException | [
"Enables",
"presence",
"for",
"the",
"specified",
"channel",
"with",
"first",
"100",
"unique",
"metadata",
"if",
"metadata",
"is",
"set",
"to",
"true",
"."
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/OrtcClient.java#L1089-L1101 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/AuditBaseDao.java | AuditBaseDao.determineDatabaseType | protected String determineDatabaseType() throws HandlerException {
String dbName = null;
try (Connection conn = getConnection()) {
dbName = conn.getMetaData().getDatabaseProductName();
} catch (SQLException e) {
throw new HandlerException("Exception occured while getting DB Name",
DatabaseAuditHandler.class, e);
}
return dbName;
} | java | protected String determineDatabaseType() throws HandlerException {
String dbName = null;
try (Connection conn = getConnection()) {
dbName = conn.getMetaData().getDatabaseProductName();
} catch (SQLException e) {
throw new HandlerException("Exception occured while getting DB Name",
DatabaseAuditHandler.class, e);
}
return dbName;
} | [
"protected",
"String",
"determineDatabaseType",
"(",
")",
"throws",
"HandlerException",
"{",
"String",
"dbName",
"=",
"null",
";",
"try",
"(",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",
")",
"{",
"dbName",
"=",
"conn",
".",
"getMetaData",
"(",
")"... | Determine database type using database metadata product name.
@return the string
@throws HandlerException
the handler exception | [
"Determine",
"database",
"type",
"using",
"database",
"metadata",
"product",
"name",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/AuditBaseDao.java#L51-L60 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/AuditBaseDao.java | AuditBaseDao.isOracleDatabase | protected boolean isOracleDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "Oracle".equalsIgnoreCase(dbName);
} | java | protected boolean isOracleDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "Oracle".equalsIgnoreCase(dbName);
} | [
"protected",
"boolean",
"isOracleDatabase",
"(",
")",
"throws",
"HandlerException",
"{",
"String",
"dbName",
"=",
"determineDatabaseType",
"(",
")",
";",
"if",
"(",
"dbName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"\"Oracle\"",
".",
"... | Checks if is oracle database.
@return true, if is oracle database
@throws HandlerException
the handler exception | [
"Checks",
"if",
"is",
"oracle",
"database",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/AuditBaseDao.java#L69-L75 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/AuditBaseDao.java | AuditBaseDao.isHSQLDatabase | protected boolean isHSQLDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "HSQL Database Engine".equalsIgnoreCase(dbName);
} | java | protected boolean isHSQLDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "HSQL Database Engine".equalsIgnoreCase(dbName);
} | [
"protected",
"boolean",
"isHSQLDatabase",
"(",
")",
"throws",
"HandlerException",
"{",
"String",
"dbName",
"=",
"determineDatabaseType",
"(",
")",
";",
"if",
"(",
"dbName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"\"HSQL Database Engine\""... | Checks if is HSQL database.
@return true, if is HSQL database
@throws HandlerException
the handler exception | [
"Checks",
"if",
"is",
"HSQL",
"database",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/AuditBaseDao.java#L84-L90 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/AuditBaseDao.java | AuditBaseDao.isMySQLDatabase | protected boolean isMySQLDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "MySQL".equalsIgnoreCase(dbName);
} | java | protected boolean isMySQLDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "MySQL".equalsIgnoreCase(dbName);
} | [
"protected",
"boolean",
"isMySQLDatabase",
"(",
")",
"throws",
"HandlerException",
"{",
"String",
"dbName",
"=",
"determineDatabaseType",
"(",
")",
";",
"if",
"(",
"dbName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"\"MySQL\"",
".",
"eq... | Checks if the database is MySQL.
@return true, if is my sql database
@throws HandlerException the handler exception | [
"Checks",
"if",
"the",
"database",
"is",
"MySQL",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/AuditBaseDao.java#L98-L104 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/AuditBaseDao.java | AuditBaseDao.isSQLServerDatabase | protected boolean isSQLServerDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "Microsoft SQL Server".equalsIgnoreCase(dbName);
} | java | protected boolean isSQLServerDatabase() throws HandlerException {
String dbName = determineDatabaseType();
if (dbName == null) {
return false;
}
return "Microsoft SQL Server".equalsIgnoreCase(dbName);
} | [
"protected",
"boolean",
"isSQLServerDatabase",
"(",
")",
"throws",
"HandlerException",
"{",
"String",
"dbName",
"=",
"determineDatabaseType",
"(",
")",
";",
"if",
"(",
"dbName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"\"Microsoft SQL Serv... | Checks if is SQLServer database.
@return true, if is sqlserver database
@throws HandlerException
the handler exception | [
"Checks",
"if",
"is",
"SQLServer",
"database",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/AuditBaseDao.java#L113-L119 | train |
realtime-framework/RealtimeMessaging-Android | library/src/main/java/ibt/ortc/extensibility/GcmRegistration.java | GcmRegistration.getRegistrationId | protected static void getRegistrationId(OrtcClient ortcClient){
if (checkPlayServices(ortcClient)) {
gcm = GoogleCloudMessaging.getInstance(ortcClient.appContext);
if (ortcClient.registrationId.isEmpty()){
String regid = getRegistrationId(ortcClient.appContext);
ortcClient.registrationId = regid;
if (regid.isEmpty()) {
registerInBackground(ortcClient);
}
}
} else {
ortcClient.raiseOrtcEvent(EventEnum.OnException, ortcClient, new OrtcGcmException("No valid Google Play Services APK found."));
}
} | java | protected static void getRegistrationId(OrtcClient ortcClient){
if (checkPlayServices(ortcClient)) {
gcm = GoogleCloudMessaging.getInstance(ortcClient.appContext);
if (ortcClient.registrationId.isEmpty()){
String regid = getRegistrationId(ortcClient.appContext);
ortcClient.registrationId = regid;
if (regid.isEmpty()) {
registerInBackground(ortcClient);
}
}
} else {
ortcClient.raiseOrtcEvent(EventEnum.OnException, ortcClient, new OrtcGcmException("No valid Google Play Services APK found."));
}
} | [
"protected",
"static",
"void",
"getRegistrationId",
"(",
"OrtcClient",
"ortcClient",
")",
"{",
"if",
"(",
"checkPlayServices",
"(",
"ortcClient",
")",
")",
"{",
"gcm",
"=",
"GoogleCloudMessaging",
".",
"getInstance",
"(",
"ortcClient",
".",
"appContext",
")",
";... | private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; | [
"private",
"final",
"static",
"int",
"PLAY_SERVICES_RESOLUTION_REQUEST",
"=",
"9000",
";"
] | f0d87b92ed7c591bcfe2b9cf45b947865570e061 | https://github.com/realtime-framework/RealtimeMessaging-Android/blob/f0d87b92ed7c591bcfe2b9cf45b947865570e061/library/src/main/java/ibt/ortc/extensibility/GcmRegistration.java#L26-L41 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/ConnectionFactory.java | ConnectionFactory.getDataSourceConnection | Connection getDataSourceConnection() {
Connection connection = null;
try {
connection = dataSource.getConnection();
} catch (SQLException ex) {
throw new InitializationException("Could not obtain the db connection: Cannot get connection", ex);
}
return connection;
} | java | Connection getDataSourceConnection() {
Connection connection = null;
try {
connection = dataSource.getConnection();
} catch (SQLException ex) {
throw new InitializationException("Could not obtain the db connection: Cannot get connection", ex);
}
return connection;
} | [
"Connection",
"getDataSourceConnection",
"(",
")",
"{",
"Connection",
"connection",
"=",
"null",
";",
"try",
"{",
"connection",
"=",
"dataSource",
".",
"getConnection",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"throw",
"new",
"Initia... | Gets the data source connection.
@return the data source connection
@since 2.4.0 | [
"Gets",
"the",
"data",
"source",
"connection",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/ConnectionFactory.java#L143-L151 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/ConnectionFactory.java | ConnectionFactory.init | void init() {
if (dataSource == null) {
if (connectionType.equals(ConnectionType.POOLED)) {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(maximumPoolSize);
config.setDataSourceClassName(dataSourceClass);
config.addDataSourceProperty("url", url);
config.addDataSourceProperty("user", user);
config.addDataSourceProperty("password", password);
config.setPoolName(CONNECTION_POOL_NAME);
config.setAutoCommit(autoCommit);
config.setMaximumPoolSize(maximumPoolSize);
// config.setConnectionTestQuery("SELECT 1");
if (connectionTimeout != null) {
config.setConnectionTimeout(connectionTimeout);
}
if (idleTimeout != null) {
config.setIdleTimeout(idleTimeout);
}
if (maxLifetime != null) {
config.setMaxLifetime(maxLifetime);
}
if (minimumIdle != null) {
config.setMinimumIdle(minimumIdle);
}
ds = new HikariDataSource(config);
dataSource = ds;
} else if (connectionType.equals(ConnectionType.JNDI)) {
if (null == jndiDataSource) {
throw new InitializationException("Could not obtain the db connection: jndi data source is null");
}
String DATASOURCE_CONTEXT = jndiDataSource;
try {
Context initialContext = new InitialContext();
dataSource = (DataSource) initialContext.lookup(DATASOURCE_CONTEXT);
if (dataSource == null) {
Log.error("Failed to lookup datasource.");
throw new InitializationException(
"Could not obtain the db connection: Failed to lookup datasource: " + jndiDataSource);
}
} catch (NamingException ex) {
throw new InitializationException("Could not obtain the db connection: jndi lookup failed", ex);
}
}
}
} | java | void init() {
if (dataSource == null) {
if (connectionType.equals(ConnectionType.POOLED)) {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(maximumPoolSize);
config.setDataSourceClassName(dataSourceClass);
config.addDataSourceProperty("url", url);
config.addDataSourceProperty("user", user);
config.addDataSourceProperty("password", password);
config.setPoolName(CONNECTION_POOL_NAME);
config.setAutoCommit(autoCommit);
config.setMaximumPoolSize(maximumPoolSize);
// config.setConnectionTestQuery("SELECT 1");
if (connectionTimeout != null) {
config.setConnectionTimeout(connectionTimeout);
}
if (idleTimeout != null) {
config.setIdleTimeout(idleTimeout);
}
if (maxLifetime != null) {
config.setMaxLifetime(maxLifetime);
}
if (minimumIdle != null) {
config.setMinimumIdle(minimumIdle);
}
ds = new HikariDataSource(config);
dataSource = ds;
} else if (connectionType.equals(ConnectionType.JNDI)) {
if (null == jndiDataSource) {
throw new InitializationException("Could not obtain the db connection: jndi data source is null");
}
String DATASOURCE_CONTEXT = jndiDataSource;
try {
Context initialContext = new InitialContext();
dataSource = (DataSource) initialContext.lookup(DATASOURCE_CONTEXT);
if (dataSource == null) {
Log.error("Failed to lookup datasource.");
throw new InitializationException(
"Could not obtain the db connection: Failed to lookup datasource: " + jndiDataSource);
}
} catch (NamingException ex) {
throw new InitializationException("Could not obtain the db connection: jndi lookup failed", ex);
}
}
}
} | [
"void",
"init",
"(",
")",
"{",
"if",
"(",
"dataSource",
"==",
"null",
")",
"{",
"if",
"(",
"connectionType",
".",
"equals",
"(",
"ConnectionType",
".",
"POOLED",
")",
")",
"{",
"HikariConfig",
"config",
"=",
"new",
"HikariConfig",
"(",
")",
";",
"confi... | initialize connection factory. This will created the necessary connection
pools and jndi lookups in advance. | [
"initialize",
"connection",
"factory",
".",
"This",
"will",
"created",
"the",
"necessary",
"connection",
"pools",
"and",
"jndi",
"lookups",
"in",
"advance",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/ConnectionFactory.java#L157-L205 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/Utils.java | Utils.getDBName | public static String getDBName(String userName) {
StringBuilder buffer = new StringBuilder();
buffer.append(EMBEDED_DB_NAME);
buffer.append("@");
buffer.append(userName);
return buffer.toString();
} | java | public static String getDBName(String userName) {
StringBuilder buffer = new StringBuilder();
buffer.append(EMBEDED_DB_NAME);
buffer.append("@");
buffer.append(userName);
return buffer.toString();
} | [
"public",
"static",
"String",
"getDBName",
"(",
"String",
"userName",
")",
"{",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buffer",
".",
"append",
"(",
"EMBEDED_DB_NAME",
")",
";",
"buffer",
".",
"append",
"(",
"\"@\"",
")",
";... | Gets the dB name.
@param userName the user name
@return the dB name | [
"Gets",
"the",
"dB",
"name",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/Utils.java#L53-L59 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/Utils.java | Utils.checkNotEmpty | public static String checkNotEmpty(String str, String message) {
if (checkNotNull(str).isEmpty()) {
throw new IllegalArgumentException(message);
}
return str;
} | java | public static String checkNotEmpty(String str, String message) {
if (checkNotNull(str).isEmpty()) {
throw new IllegalArgumentException(message);
}
return str;
} | [
"public",
"static",
"String",
"checkNotEmpty",
"(",
"String",
"str",
",",
"String",
"message",
")",
"{",
"if",
"(",
"checkNotNull",
"(",
"str",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
... | Throws a IllegalArgumentException if given String is empty
@param str the parameter to check
@param message the parameter to check
@return the provided parameter | [
"Throws",
"a",
"IllegalArgumentException",
"if",
"given",
"String",
"is",
"empty"
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/Utils.java#L81-L86 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/DatabaseAuditHandler.java | DatabaseAuditHandler.init | @Override
public void init() throws InitializationException {
if (null == embedded || "true".equalsIgnoreCase(embedded)) {
Log.warn("Audit4j Database Handler runs on embedded mode. See " + ErrorGuide.ERROR_URL
+ "embeddeddb for further details.");
server = HSQLEmbededDBServer.getInstance();
db_driver = server.getDriver();
db_url = server.getNetworkProtocol() + ":file:audit4jdb";
if (db_user == null) {
db_user = Utils.EMBEDED_DB_USER;
}
if (db_password == null) {
db_password = Utils.EMBEDED_DB_PASSWORD;
}
server.setUname(db_user);
server.setPassword(db_password);
server.start();
}
factory = ConnectionFactory.getInstance();
factory.setDataSource(dataSource);
factory.setDriver(getDb_driver());
factory.setUrl(getDb_url());
factory.setUser(getDb_user());
factory.setPassword(getDb_password());
factory.setDataSourceClass(db_datasourceClass);
factory.setAutoCommit(db_pool_autoCommit);
if (db_pool_connectionTimeout != null) {
factory.setConnectionTimeout(db_pool_connectionTimeout);
}
if (db_pool_idleTimeout != null) {
factory.setIdleTimeout(db_pool_idleTimeout);
}
if (db_pool_maximumPoolSize != null) {
factory.setMaximumPoolSize(db_pool_maximumPoolSize);
}
if (db_pool_maxLifetime != null) {
factory.setMaxLifetime(db_pool_maxLifetime);
}
if (db_pool_minimumIdle != null) {
factory.setMinimumIdle(db_pool_minimumIdle);
}
if (getDb_connection_type() != null && getDb_connection_type().equals(POOLED_CONNECTION)) {
factory.setConnectionType(ConnectionType.POOLED);
} else if (getDb_connection_type() != null && getDb_connection_type().equals(JNDI_CONNECTION)) {
factory.setConnectionType(ConnectionType.JNDI);
factory.setJndiDataSource(getDb_jndi_datasource());
} else {
factory.setConnectionType(ConnectionType.SINGLE);
}
factory.init();
try {
getDaoForTable(default_table_name);
} catch (HandlerException e) {
throw new InitializationException("Unable to create tables", e);
}
} | java | @Override
public void init() throws InitializationException {
if (null == embedded || "true".equalsIgnoreCase(embedded)) {
Log.warn("Audit4j Database Handler runs on embedded mode. See " + ErrorGuide.ERROR_URL
+ "embeddeddb for further details.");
server = HSQLEmbededDBServer.getInstance();
db_driver = server.getDriver();
db_url = server.getNetworkProtocol() + ":file:audit4jdb";
if (db_user == null) {
db_user = Utils.EMBEDED_DB_USER;
}
if (db_password == null) {
db_password = Utils.EMBEDED_DB_PASSWORD;
}
server.setUname(db_user);
server.setPassword(db_password);
server.start();
}
factory = ConnectionFactory.getInstance();
factory.setDataSource(dataSource);
factory.setDriver(getDb_driver());
factory.setUrl(getDb_url());
factory.setUser(getDb_user());
factory.setPassword(getDb_password());
factory.setDataSourceClass(db_datasourceClass);
factory.setAutoCommit(db_pool_autoCommit);
if (db_pool_connectionTimeout != null) {
factory.setConnectionTimeout(db_pool_connectionTimeout);
}
if (db_pool_idleTimeout != null) {
factory.setIdleTimeout(db_pool_idleTimeout);
}
if (db_pool_maximumPoolSize != null) {
factory.setMaximumPoolSize(db_pool_maximumPoolSize);
}
if (db_pool_maxLifetime != null) {
factory.setMaxLifetime(db_pool_maxLifetime);
}
if (db_pool_minimumIdle != null) {
factory.setMinimumIdle(db_pool_minimumIdle);
}
if (getDb_connection_type() != null && getDb_connection_type().equals(POOLED_CONNECTION)) {
factory.setConnectionType(ConnectionType.POOLED);
} else if (getDb_connection_type() != null && getDb_connection_type().equals(JNDI_CONNECTION)) {
factory.setConnectionType(ConnectionType.JNDI);
factory.setJndiDataSource(getDb_jndi_datasource());
} else {
factory.setConnectionType(ConnectionType.SINGLE);
}
factory.init();
try {
getDaoForTable(default_table_name);
} catch (HandlerException e) {
throw new InitializationException("Unable to create tables", e);
}
} | [
"@",
"Override",
"public",
"void",
"init",
"(",
")",
"throws",
"InitializationException",
"{",
"if",
"(",
"null",
"==",
"embedded",
"||",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"embedded",
")",
")",
"{",
"Log",
".",
"warn",
"(",
"\"Audit4j Database Handler ... | Initialize database handler.
@throws InitializationException the initialization exception | [
"Initialize",
"database",
"handler",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/DatabaseAuditHandler.java#L197-L258 | train |
audit4j/audit4j-db | src/main/java/org/audit4j/handler/db/DatabaseAuditHandler.java | DatabaseAuditHandler.generateTableName | private String generateTableName(String repository) {
if (table_prefix == null) {
return repository + "_" + table_suffix;
}
return table_prefix + "_" + repository + "_" + table_suffix;
} | java | private String generateTableName(String repository) {
if (table_prefix == null) {
return repository + "_" + table_suffix;
}
return table_prefix + "_" + repository + "_" + table_suffix;
} | [
"private",
"String",
"generateTableName",
"(",
"String",
"repository",
")",
"{",
"if",
"(",
"table_prefix",
"==",
"null",
")",
"{",
"return",
"repository",
"+",
"\"_\"",
"+",
"table_suffix",
";",
"}",
"return",
"table_prefix",
"+",
"\"_\"",
"+",
"repository",
... | Generate table name.
@param repository
@return the string | [
"Generate",
"table",
"name",
"."
] | bba822a5722533e6f465a9784f2353ae2e5bc01d | https://github.com/audit4j/audit4j-db/blob/bba822a5722533e6f465a9784f2353ae2e5bc01d/src/main/java/org/audit4j/handler/db/DatabaseAuditHandler.java#L293-L298 | train |
jboss/jboss-ejb-api_spec | src/main/java/javax/ejb/embeddable/EJBContainer.java | EJBContainer.createEJBContainer | public static EJBContainer createEJBContainer(Map<?, ?> properties)
throws EJBException
{
for(EJBContainerProvider factory : factories)
{
EJBContainer container = factory.createEJBContainer(properties);
if(container != null)
return container;
}
throw new EJBException("Unable to instantiate container with factories " + factories);
} | java | public static EJBContainer createEJBContainer(Map<?, ?> properties)
throws EJBException
{
for(EJBContainerProvider factory : factories)
{
EJBContainer container = factory.createEJBContainer(properties);
if(container != null)
return container;
}
throw new EJBException("Unable to instantiate container with factories " + factories);
} | [
"public",
"static",
"EJBContainer",
"createEJBContainer",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"properties",
")",
"throws",
"EJBException",
"{",
"for",
"(",
"EJBContainerProvider",
"factory",
":",
"factories",
")",
"{",
"EJBContainer",
"container",
"=",
"factory... | Create and initialize an embeddable EJB container with an
set of configuration properties and names of modules to be initialized.
@param properties One or more spec-defined or vendor-specific properties.
The spec reserves the prefix "javax.ejb." for spec-defined properties.
@return EJBContainer instance
@throws EJBException Thrown if the container or application could not
be successfully initialized. | [
"Create",
"and",
"initialize",
"an",
"embeddable",
"EJB",
"container",
"with",
"an",
"set",
"of",
"configuration",
"properties",
"and",
"names",
"of",
"modules",
"to",
"be",
"initialized",
"."
] | 2efa693ed40cdfcf43bbd6cecbaf49039170bc3b | https://github.com/jboss/jboss-ejb-api_spec/blob/2efa693ed40cdfcf43bbd6cecbaf49039170bc3b/src/main/java/javax/ejb/embeddable/EJBContainer.java#L72-L82 | train |
icon-Systemhaus-GmbH/javassist-maven-plugin | src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java | ClassnameExtractor.extractClassNameFromFile | public static String extractClassNameFromFile(final File parentDirectory,
final File classFile) throws IOException {
if (null == classFile) {
return null;
}
final String qualifiedFileName = parentDirectory != null
? classFile.getCanonicalPath()
.substring(parentDirectory.getCanonicalPath().length() + 1)
: classFile.getCanonicalPath();
return removeExtension(qualifiedFileName.replace(File.separator, "."));
} | java | public static String extractClassNameFromFile(final File parentDirectory,
final File classFile) throws IOException {
if (null == classFile) {
return null;
}
final String qualifiedFileName = parentDirectory != null
? classFile.getCanonicalPath()
.substring(parentDirectory.getCanonicalPath().length() + 1)
: classFile.getCanonicalPath();
return removeExtension(qualifiedFileName.replace(File.separator, "."));
} | [
"public",
"static",
"String",
"extractClassNameFromFile",
"(",
"final",
"File",
"parentDirectory",
",",
"final",
"File",
"classFile",
")",
"throws",
"IOException",
"{",
"if",
"(",
"null",
"==",
"classFile",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Strin... | Remove parent directory from file name and replace directory separator with dots.
<ul>
<li>parentDirectory: {@code /tmp/my/parent/src/}</li>
<li>classFile: {@code /tmp/my/parent/src/foo/bar/MyApp.class}</li>
</ul>
returns: {@code foo.bar.MyApp}
@param parentDirectory to remove from {@code classFile} and maybe {@code null}.
@param classFile to extract the name from. Maybe {@code null}
@return class name extracted from file name or {@code null}
@throws IOException by file operations | [
"Remove",
"parent",
"directory",
"from",
"file",
"name",
"and",
"replace",
"directory",
"separator",
"with",
"dots",
"."
] | 798368f79a0bd641648bebd8546388daf013a50e | https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/798368f79a0bd641648bebd8546388daf013a50e/src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java#L54-L64 | train |
icon-Systemhaus-GmbH/javassist-maven-plugin | src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java | ClassnameExtractor.iterateClassnames | public static Iterator<String> iterateClassnames(final File parentDirectory,
final File ... classFiles) {
return iterateClassnames(parentDirectory, Arrays.asList(classFiles).iterator());
} | java | public static Iterator<String> iterateClassnames(final File parentDirectory,
final File ... classFiles) {
return iterateClassnames(parentDirectory, Arrays.asList(classFiles).iterator());
} | [
"public",
"static",
"Iterator",
"<",
"String",
">",
"iterateClassnames",
"(",
"final",
"File",
"parentDirectory",
",",
"final",
"File",
"...",
"classFiles",
")",
"{",
"return",
"iterateClassnames",
"(",
"parentDirectory",
",",
"Arrays",
".",
"asList",
"(",
"clas... | Iterate over the class files and remove the parent directory from file name and replace
directory separator with dots.
@param parentDirectory to remove from {@code classFile} and maybe {@code null}.
@param classFiles array to extract the names from. Must not be {@code null}.
@return iterator of full qualified class names based on passed classFiles
@see #iterateClassnames(File, Iterator) | [
"Iterate",
"over",
"the",
"class",
"files",
"and",
"remove",
"the",
"parent",
"directory",
"from",
"file",
"name",
"and",
"replace",
"directory",
"separator",
"with",
"dots",
"."
] | 798368f79a0bd641648bebd8546388daf013a50e | https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/798368f79a0bd641648bebd8546388daf013a50e/src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java#L75-L78 | train |
icon-Systemhaus-GmbH/javassist-maven-plugin | src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassTransformerConfiguration.java | ClassTransformerConfiguration.setProperties | public void setProperties(final Properties properties) {
this.properties = (null == properties) ? new Properties() : (Properties)properties.clone();
} | java | public void setProperties(final Properties properties) {
this.properties = (null == properties) ? new Properties() : (Properties)properties.clone();
} | [
"public",
"void",
"setProperties",
"(",
"final",
"Properties",
"properties",
")",
"{",
"this",
".",
"properties",
"=",
"(",
"null",
"==",
"properties",
")",
"?",
"new",
"Properties",
"(",
")",
":",
"(",
"Properties",
")",
"properties",
".",
"clone",
"(",
... | Sets the optional settings for the transformer class.
@param properties should not be {@code null} | [
"Sets",
"the",
"optional",
"settings",
"for",
"the",
"transformer",
"class",
"."
] | 798368f79a0bd641648bebd8546388daf013a50e | https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/798368f79a0bd641648bebd8546388daf013a50e/src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassTransformerConfiguration.java#L116-L118 | train |
rimerosolutions/ant-wrapper | src/main/java/com/rimerosolutions/ant/wrapper/PathAssembler.java | PathAssembler.getDistribution | public LocalDistribution getDistribution(WrapperConfiguration configuration) {
String baseName = getDistName(configuration.getDistribution());
String distName = removeExtension(baseName);
String rootDirName = rootDirName(distName, configuration);
String distDirPathName = configuration.getDistributionPath() + "/" + rootDirName;
File distDir = new File(getBaseDir(configuration.getDistributionBase()), distDirPathName);
String distZipFilename = configuration.getZipPath() + "/" + rootDirName + "/" + baseName;
File distZip = new File(getBaseDir(configuration.getZipBase()), distZipFilename);
return new LocalDistribution(distDir, distZip);
} | java | public LocalDistribution getDistribution(WrapperConfiguration configuration) {
String baseName = getDistName(configuration.getDistribution());
String distName = removeExtension(baseName);
String rootDirName = rootDirName(distName, configuration);
String distDirPathName = configuration.getDistributionPath() + "/" + rootDirName;
File distDir = new File(getBaseDir(configuration.getDistributionBase()), distDirPathName);
String distZipFilename = configuration.getZipPath() + "/" + rootDirName + "/" + baseName;
File distZip = new File(getBaseDir(configuration.getZipBase()), distZipFilename);
return new LocalDistribution(distDir, distZip);
} | [
"public",
"LocalDistribution",
"getDistribution",
"(",
"WrapperConfiguration",
"configuration",
")",
"{",
"String",
"baseName",
"=",
"getDistName",
"(",
"configuration",
".",
"getDistribution",
"(",
")",
")",
";",
"String",
"distName",
"=",
"removeExtension",
"(",
"... | Determines the local locations for the distribution to use given the supplied configuration. | [
"Determines",
"the",
"local",
"locations",
"for",
"the",
"distribution",
"to",
"use",
"given",
"the",
"supplied",
"configuration",
"."
] | b996b14ee572242b7a3e0359a25761cfda70f831 | https://github.com/rimerosolutions/ant-wrapper/blob/b996b14ee572242b7a3e0359a25761cfda70f831/src/main/java/com/rimerosolutions/ant/wrapper/PathAssembler.java#L45-L57 | train |
icon-Systemhaus-GmbH/javassist-maven-plugin | src/main/java/de/icongmbh/oss/maven/plugin/javassist/JavassistTransformerExecutor.java | JavassistTransformerExecutor.evaluateOutputDirectory | protected String evaluateOutputDirectory(final String outputDir, final String inputDir) {
return outputDir != null && !outputDir.trim().isEmpty() ? outputDir : inputDir.trim();
} | java | protected String evaluateOutputDirectory(final String outputDir, final String inputDir) {
return outputDir != null && !outputDir.trim().isEmpty() ? outputDir : inputDir.trim();
} | [
"protected",
"String",
"evaluateOutputDirectory",
"(",
"final",
"String",
"outputDir",
",",
"final",
"String",
"inputDir",
")",
"{",
"return",
"outputDir",
"!=",
"null",
"&&",
"!",
"outputDir",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
"?",
"outputDir... | Evaluates and returns the output directory.
<p>
If the passed {@code outputDir} is {@code null} or empty, the passed {@code inputDir} otherwise
the {@code outputDir} will returned.
@param outputDir could be {@code null} or empty
@param inputDir must not be {@code null}
@return never {@code null}
@throws NullPointerException if passed {@code inputDir} is {@code null}
@since 1.2.0 | [
"Evaluates",
"and",
"returns",
"the",
"output",
"directory",
"."
] | 798368f79a0bd641648bebd8546388daf013a50e | https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/798368f79a0bd641648bebd8546388daf013a50e/src/main/java/de/icongmbh/oss/maven/plugin/javassist/JavassistTransformerExecutor.java#L316-L318 | train |
hamnis/json-collection | src/main/java/net/hamnaberg/json/DataContainer.java | DataContainer.replace | @SuppressWarnings("unchecked")
public A replace(Property property) {
Data data = getData();
Data replaced = data.replace(property);
if (!replaced.isEmpty()) {
return copy(delegate.put("data", Property.toArrayNode(replaced)));
}
return (A)this;
} | java | @SuppressWarnings("unchecked")
public A replace(Property property) {
Data data = getData();
Data replaced = data.replace(property);
if (!replaced.isEmpty()) {
return copy(delegate.put("data", Property.toArrayNode(replaced)));
}
return (A)this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"A",
"replace",
"(",
"Property",
"property",
")",
"{",
"Data",
"data",
"=",
"getData",
"(",
")",
";",
"Data",
"replaced",
"=",
"data",
".",
"replace",
"(",
"property",
")",
";",
"if",
"(",
"... | Replaces all properties with the same name as the supplied property
@param property property to replace with
@return a new copy of the template, or this if nothing was modified. | [
"Replaces",
"all",
"properties",
"with",
"the",
"same",
"name",
"as",
"the",
"supplied",
"property"
] | fbd4a1c6ab75b70b3b4cb981b608b395e9c8c180 | https://github.com/hamnis/json-collection/blob/fbd4a1c6ab75b70b3b4cb981b608b395e9c8c180/src/main/java/net/hamnaberg/json/DataContainer.java#L36-L44 | train |
hamnis/json-collection | src/main/java/net/hamnaberg/json/Data.java | Data.replace | public Data replace(Iterable<Property> replacement) {
if (Iterables.isEmpty(replacement)) {
return this;
}
Map<String, Property> map = getDataAsMap(replacement);
List<Property> props = this.stream().
map(f -> map.getOrDefault(f.getName(), f)).
collect(Collectors.toList());
return new Data(props);
} | java | public Data replace(Iterable<Property> replacement) {
if (Iterables.isEmpty(replacement)) {
return this;
}
Map<String, Property> map = getDataAsMap(replacement);
List<Property> props = this.stream().
map(f -> map.getOrDefault(f.getName(), f)).
collect(Collectors.toList());
return new Data(props);
} | [
"public",
"Data",
"replace",
"(",
"Iterable",
"<",
"Property",
">",
"replacement",
")",
"{",
"if",
"(",
"Iterables",
".",
"isEmpty",
"(",
"replacement",
")",
")",
"{",
"return",
"this",
";",
"}",
"Map",
"<",
"String",
",",
"Property",
">",
"map",
"=",
... | Replaces all properties with the same name as the supplied properties.
@param replacement property to replace with
@return a new copy of the template | [
"Replaces",
"all",
"properties",
"with",
"the",
"same",
"name",
"as",
"the",
"supplied",
"properties",
"."
] | fbd4a1c6ab75b70b3b4cb981b608b395e9c8c180 | https://github.com/hamnis/json-collection/blob/fbd4a1c6ab75b70b3b4cb981b608b395e9c8c180/src/main/java/net/hamnaberg/json/Data.java#L67-L78 | train |
facebookarchive/hive-dwrf | hive-dwrf/src/main/java/com/facebook/hive/orc/lazy/OrcLazyObject.java | OrcLazyObject.materializeHelper | public void materializeHelper(Materializer maker) throws IOException {
if (!materialized) {
ReaderWriterProfiler.start(ReaderWriterProfiler.Counter.DECODING_TIME);
try {
maker.materialize(treeReader, currentRow);
materialized = true;
writableCreated = false;
nextIsNull = false;
nextIsNullSet = true;
}
catch (ValueNotPresentException e) {
// Is the value null?
//
materialized = true;
writableCreated = true; // We have effectively created a writable
nextIsNull = true;
nextIsNullSet = true;
throw new IOException("Cannot materialize primitive: value not present");
}
ReaderWriterProfiler.end(ReaderWriterProfiler.Counter.DECODING_TIME);
}
else if (nextIsNull) {
throw new IOException("Cannot materialize primitive: value not present.");
}
} | java | public void materializeHelper(Materializer maker) throws IOException {
if (!materialized) {
ReaderWriterProfiler.start(ReaderWriterProfiler.Counter.DECODING_TIME);
try {
maker.materialize(treeReader, currentRow);
materialized = true;
writableCreated = false;
nextIsNull = false;
nextIsNullSet = true;
}
catch (ValueNotPresentException e) {
// Is the value null?
//
materialized = true;
writableCreated = true; // We have effectively created a writable
nextIsNull = true;
nextIsNullSet = true;
throw new IOException("Cannot materialize primitive: value not present");
}
ReaderWriterProfiler.end(ReaderWriterProfiler.Counter.DECODING_TIME);
}
else if (nextIsNull) {
throw new IOException("Cannot materialize primitive: value not present.");
}
} | [
"public",
"void",
"materializeHelper",
"(",
"Materializer",
"maker",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"materialized",
")",
"{",
"ReaderWriterProfiler",
".",
"start",
"(",
"ReaderWriterProfiler",
".",
"Counter",
".",
"DECODING_TIME",
")",
";",
"... | A Helper to materialize primitive data types | [
"A",
"Helper",
"to",
"materialize",
"primitive",
"data",
"types"
] | a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45 | https://github.com/facebookarchive/hive-dwrf/blob/a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45/hive-dwrf/src/main/java/com/facebook/hive/orc/lazy/OrcLazyObject.java#L184-L208 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/FastLeaderElection.java | FastLeaderElection.broadcast | void broadcast(ClusterConfiguration config) {
Message vote = voteInfo.toMessage();
for (String server : config.getPeers()) {
this.transport.send(server, vote);
}
} | java | void broadcast(ClusterConfiguration config) {
Message vote = voteInfo.toMessage();
for (String server : config.getPeers()) {
this.transport.send(server, vote);
}
} | [
"void",
"broadcast",
"(",
"ClusterConfiguration",
"config",
")",
"{",
"Message",
"vote",
"=",
"voteInfo",
".",
"toMessage",
"(",
")",
";",
"for",
"(",
"String",
"server",
":",
"config",
".",
"getPeers",
"(",
")",
")",
"{",
"this",
".",
"transport",
".",
... | Broadcasts its vote to all the peers in current configuration. | [
"Broadcasts",
"its",
"vote",
"to",
"all",
"the",
"peers",
"in",
"current",
"configuration",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/FastLeaderElection.java#L167-L172 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.toProtoZxid | public static ZabMessage.Zxid toProtoZxid(Zxid zxid) {
ZabMessage.Zxid z = ZabMessage.Zxid.newBuilder()
.setEpoch(zxid.getEpoch())
.setXid(zxid.getXid())
.build();
return z;
} | java | public static ZabMessage.Zxid toProtoZxid(Zxid zxid) {
ZabMessage.Zxid z = ZabMessage.Zxid.newBuilder()
.setEpoch(zxid.getEpoch())
.setXid(zxid.getXid())
.build();
return z;
} | [
"public",
"static",
"ZabMessage",
".",
"Zxid",
"toProtoZxid",
"(",
"Zxid",
"zxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"z",
"=",
"ZabMessage",
".",
"Zxid",
".",
"newBuilder",
"(",
")",
".",
"setEpoch",
"(",
"zxid",
".",
"getEpoch",
"(",
")",
")",
".",... | Converts Zxid object to protobuf Zxid object.
@param zxid the Zxid object.
@return the ZabMessage.Zxid | [
"Converts",
"Zxid",
"object",
"to",
"protobuf",
"Zxid",
"object",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L59-L65 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.fromProtoZxid | public static Zxid fromProtoZxid(ZabMessage.Zxid zxid) {
return new Zxid(zxid.getEpoch(), zxid.getXid());
} | java | public static Zxid fromProtoZxid(ZabMessage.Zxid zxid) {
return new Zxid(zxid.getEpoch(), zxid.getXid());
} | [
"public",
"static",
"Zxid",
"fromProtoZxid",
"(",
"ZabMessage",
".",
"Zxid",
"zxid",
")",
"{",
"return",
"new",
"Zxid",
"(",
"zxid",
".",
"getEpoch",
"(",
")",
",",
"zxid",
".",
"getXid",
"(",
")",
")",
";",
"}"
] | Converts protobuf Zxid object to Zxid object.
@param zxid the protobuf Zxid object.
@return the Zxid object. | [
"Converts",
"protobuf",
"Zxid",
"object",
"to",
"Zxid",
"object",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L73-L75 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.fromProposal | public static Transaction fromProposal(Proposal prop) {
Zxid zxid = fromProtoZxid(prop.getZxid());
ByteBuffer buffer = prop.getBody().asReadOnlyByteBuffer();
return new Transaction(zxid, prop.getType().getNumber(), buffer);
} | java | public static Transaction fromProposal(Proposal prop) {
Zxid zxid = fromProtoZxid(prop.getZxid());
ByteBuffer buffer = prop.getBody().asReadOnlyByteBuffer();
return new Transaction(zxid, prop.getType().getNumber(), buffer);
} | [
"public",
"static",
"Transaction",
"fromProposal",
"(",
"Proposal",
"prop",
")",
"{",
"Zxid",
"zxid",
"=",
"fromProtoZxid",
"(",
"prop",
".",
"getZxid",
"(",
")",
")",
";",
"ByteBuffer",
"buffer",
"=",
"prop",
".",
"getBody",
"(",
")",
".",
"asReadOnlyByte... | Converts protobuf Proposal object to Transaction object.
@param prop the protobuf Proposal object.
@return the Transaction object. | [
"Converts",
"protobuf",
"Proposal",
"object",
"to",
"Transaction",
"object",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L83-L87 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.fromTransaction | public static Proposal fromTransaction(Transaction txn) {
ZabMessage.Zxid zxid = toProtoZxid(txn.getZxid());
ByteString bs = ByteString.copyFrom(txn.getBody());
return Proposal.newBuilder().setZxid(zxid).setBody(bs)
.setType(ProposalType.values()[txn.getType()]).build();
} | java | public static Proposal fromTransaction(Transaction txn) {
ZabMessage.Zxid zxid = toProtoZxid(txn.getZxid());
ByteString bs = ByteString.copyFrom(txn.getBody());
return Proposal.newBuilder().setZxid(zxid).setBody(bs)
.setType(ProposalType.values()[txn.getType()]).build();
} | [
"public",
"static",
"Proposal",
"fromTransaction",
"(",
"Transaction",
"txn",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"txn",
".",
"getZxid",
"(",
")",
")",
";",
"ByteString",
"bs",
"=",
"ByteString",
".",
"copyFrom",
"(",
"txn... | Converts Transaction object to protobuf Proposal object.
@param txn the Transaction object.
@return the protobuf Proposal object. | [
"Converts",
"Transaction",
"object",
"to",
"protobuf",
"Proposal",
"object",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L95-L100 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildProposedEpoch | public static Message buildProposedEpoch(long proposedEpoch,
long acknowledgedEpoch,
ClusterConfiguration config,
int syncTimeoutMs) {
ZabMessage.Zxid version = toProtoZxid(config.getVersion());
ZabMessage.ClusterConfiguration zCnf
= ZabMessage.ClusterConfiguration.newBuilder()
.setVersion(version)
.addAllServers(config.getPeers())
.build();
ProposedEpoch pEpoch = ProposedEpoch.newBuilder()
.setProposedEpoch(proposedEpoch)
.setCurrentEpoch(acknowledgedEpoch)
.setConfig(zCnf)
.setSyncTimeout(syncTimeoutMs)
.build();
return Message.newBuilder().setType(MessageType.PROPOSED_EPOCH)
.setProposedEpoch(pEpoch)
.build();
} | java | public static Message buildProposedEpoch(long proposedEpoch,
long acknowledgedEpoch,
ClusterConfiguration config,
int syncTimeoutMs) {
ZabMessage.Zxid version = toProtoZxid(config.getVersion());
ZabMessage.ClusterConfiguration zCnf
= ZabMessage.ClusterConfiguration.newBuilder()
.setVersion(version)
.addAllServers(config.getPeers())
.build();
ProposedEpoch pEpoch = ProposedEpoch.newBuilder()
.setProposedEpoch(proposedEpoch)
.setCurrentEpoch(acknowledgedEpoch)
.setConfig(zCnf)
.setSyncTimeout(syncTimeoutMs)
.build();
return Message.newBuilder().setType(MessageType.PROPOSED_EPOCH)
.setProposedEpoch(pEpoch)
.build();
} | [
"public",
"static",
"Message",
"buildProposedEpoch",
"(",
"long",
"proposedEpoch",
",",
"long",
"acknowledgedEpoch",
",",
"ClusterConfiguration",
"config",
",",
"int",
"syncTimeoutMs",
")",
"{",
"ZabMessage",
".",
"Zxid",
"version",
"=",
"toProtoZxid",
"(",
"config"... | Creates CEPOCH message.
@param proposedEpoch the last proposed epoch.
@param acknowledgedEpoch the acknowledged epoch.
@param config the current seen configuration.
@return the protobuf message. | [
"Creates",
"CEPOCH",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L110-L129 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildNewEpochMessage | public static Message buildNewEpochMessage(long epoch, int syncTimeoutMs) {
NewEpoch nEpoch = NewEpoch.newBuilder()
.setNewEpoch(epoch)
.setSyncTimeout(syncTimeoutMs)
.build();
return Message.newBuilder().setType(MessageType.NEW_EPOCH)
.setNewEpoch(nEpoch)
.build();
} | java | public static Message buildNewEpochMessage(long epoch, int syncTimeoutMs) {
NewEpoch nEpoch = NewEpoch.newBuilder()
.setNewEpoch(epoch)
.setSyncTimeout(syncTimeoutMs)
.build();
return Message.newBuilder().setType(MessageType.NEW_EPOCH)
.setNewEpoch(nEpoch)
.build();
} | [
"public",
"static",
"Message",
"buildNewEpochMessage",
"(",
"long",
"epoch",
",",
"int",
"syncTimeoutMs",
")",
"{",
"NewEpoch",
"nEpoch",
"=",
"NewEpoch",
".",
"newBuilder",
"(",
")",
".",
"setNewEpoch",
"(",
"epoch",
")",
".",
"setSyncTimeout",
"(",
"syncTime... | Creates a NEW_EPOCH message.
@param epoch the new proposed epoch number.
@param syncTimeoutMs the timeout for synchronization.
@return the protobuf message. | [
"Creates",
"a",
"NEW_EPOCH",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L138-L146 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildAckEpoch | public static Message buildAckEpoch(long epoch, Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
AckEpoch ackEpoch = AckEpoch.newBuilder()
.setAcknowledgedEpoch(epoch)
.setLastZxid(zxid)
.build();
return Message.newBuilder().setType(MessageType.ACK_EPOCH)
.setAckEpoch(ackEpoch)
.build();
} | java | public static Message buildAckEpoch(long epoch, Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
AckEpoch ackEpoch = AckEpoch.newBuilder()
.setAcknowledgedEpoch(epoch)
.setLastZxid(zxid)
.build();
return Message.newBuilder().setType(MessageType.ACK_EPOCH)
.setAckEpoch(ackEpoch)
.build();
} | [
"public",
"static",
"Message",
"buildAckEpoch",
"(",
"long",
"epoch",
",",
"Zxid",
"lastZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"lastZxid",
")",
";",
"AckEpoch",
"ackEpoch",
"=",
"AckEpoch",
".",
"newBuilder",
"(",
")",
... | Creates a ACK_EPOCH message.
@param epoch the last leader proposal the follower has acknowledged.
@param lastZxid the last zxid of the follower.
@return the protobuf message. | [
"Creates",
"a",
"ACK_EPOCH",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L155-L166 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildInvalidMessage | public static Message buildInvalidMessage(byte[] content) {
InvalidMessage msg = InvalidMessage.newBuilder()
.setReceivedBytes(ByteString.copyFrom(content))
.build();
return Message.newBuilder().setType(MessageType.INVALID_MESSAGE)
.setInvalid(msg)
.build();
} | java | public static Message buildInvalidMessage(byte[] content) {
InvalidMessage msg = InvalidMessage.newBuilder()
.setReceivedBytes(ByteString.copyFrom(content))
.build();
return Message.newBuilder().setType(MessageType.INVALID_MESSAGE)
.setInvalid(msg)
.build();
} | [
"public",
"static",
"Message",
"buildInvalidMessage",
"(",
"byte",
"[",
"]",
"content",
")",
"{",
"InvalidMessage",
"msg",
"=",
"InvalidMessage",
".",
"newBuilder",
"(",
")",
".",
"setReceivedBytes",
"(",
"ByteString",
".",
"copyFrom",
"(",
"content",
")",
")"... | Creates an INVALID message. This message will not be transmitted among
workers. It's created when protobuf fails to parse the byte buffer.
@param content the byte array which can't be parsed by protobuf.
@return a message represents an invalid message. | [
"Creates",
"an",
"INVALID",
"message",
".",
"This",
"message",
"will",
"not",
"be",
"transmitted",
"among",
"workers",
".",
"It",
"s",
"created",
"when",
"protobuf",
"fails",
"to",
"parse",
"the",
"byte",
"buffer",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L175-L183 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildPullTxnReq | public static Message buildPullTxnReq(Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
PullTxnReq req = PullTxnReq.newBuilder().setLastZxid(zxid)
.build();
return Message.newBuilder().setType(MessageType.PULL_TXN_REQ)
.setPullTxnReq(req)
.build();
} | java | public static Message buildPullTxnReq(Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
PullTxnReq req = PullTxnReq.newBuilder().setLastZxid(zxid)
.build();
return Message.newBuilder().setType(MessageType.PULL_TXN_REQ)
.setPullTxnReq(req)
.build();
} | [
"public",
"static",
"Message",
"buildPullTxnReq",
"(",
"Zxid",
"lastZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"lastZxid",
")",
";",
"PullTxnReq",
"req",
"=",
"PullTxnReq",
".",
"newBuilder",
"(",
")",
".",
"setLastZxid",
"(... | Creates a PULL_TXN_REQ message to ask follower sync its history to leader.
@param lastZxid the last transaction id of leader, the sync starts one
after this transaction (not including this one).
@return a protobuf message. | [
"Creates",
"a",
"PULL_TXN_REQ",
"message",
"to",
"ask",
"follower",
"sync",
"its",
"history",
"to",
"leader",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L192-L201 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildProposal | public static Message buildProposal(Transaction txn) {
ZabMessage.Zxid zxid = toProtoZxid(txn.getZxid());
Proposal prop = Proposal.newBuilder()
.setZxid(zxid)
.setBody(ByteString.copyFrom(txn.getBody()))
.setType(ProposalType.values()[txn.getType()])
.build();
return Message.newBuilder().setType(MessageType.PROPOSAL)
.setProposal(prop)
.build();
} | java | public static Message buildProposal(Transaction txn) {
ZabMessage.Zxid zxid = toProtoZxid(txn.getZxid());
Proposal prop = Proposal.newBuilder()
.setZxid(zxid)
.setBody(ByteString.copyFrom(txn.getBody()))
.setType(ProposalType.values()[txn.getType()])
.build();
return Message.newBuilder().setType(MessageType.PROPOSAL)
.setProposal(prop)
.build();
} | [
"public",
"static",
"Message",
"buildProposal",
"(",
"Transaction",
"txn",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"txn",
".",
"getZxid",
"(",
")",
")",
";",
"Proposal",
"prop",
"=",
"Proposal",
".",
"newBuilder",
"(",
")",
... | Creates a PROPOSAL message.
@param txn the transaction of this proposal.
@return a protobuf message. | [
"Creates",
"a",
"PROPOSAL",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L209-L221 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildDiff | public static Message buildDiff(Zxid lastZxid) {
ZabMessage.Zxid lz = toProtoZxid(lastZxid);
Diff diff = Diff.newBuilder().setLastZxid(lz).build();
return Message.newBuilder().setType(MessageType.DIFF)
.setDiff(diff)
.build();
} | java | public static Message buildDiff(Zxid lastZxid) {
ZabMessage.Zxid lz = toProtoZxid(lastZxid);
Diff diff = Diff.newBuilder().setLastZxid(lz).build();
return Message.newBuilder().setType(MessageType.DIFF)
.setDiff(diff)
.build();
} | [
"public",
"static",
"Message",
"buildDiff",
"(",
"Zxid",
"lastZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"lz",
"=",
"toProtoZxid",
"(",
"lastZxid",
")",
";",
"Diff",
"diff",
"=",
"Diff",
".",
"newBuilder",
"(",
")",
".",
"setLastZxid",
"(",
"lz",
")",
... | Creates a DIFF message.
@param lastZxid the last zxid of the server who initiates the sync.
@return a protobuf message. | [
"Creates",
"a",
"DIFF",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L250-L258 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildTruncate | public static Message buildTruncate(Zxid lastPrefixZxid, Zxid lastZxid) {
ZabMessage.Zxid lpz = toProtoZxid(lastPrefixZxid);
ZabMessage.Zxid lz = toProtoZxid(lastZxid);
Truncate trunc = Truncate.newBuilder().setLastPrefixZxid(lpz)
.setLastZxid(lz)
.build();
return Message.newBuilder().setType(MessageType.TRUNCATE)
.setTruncate(trunc)
.build();
} | java | public static Message buildTruncate(Zxid lastPrefixZxid, Zxid lastZxid) {
ZabMessage.Zxid lpz = toProtoZxid(lastPrefixZxid);
ZabMessage.Zxid lz = toProtoZxid(lastZxid);
Truncate trunc = Truncate.newBuilder().setLastPrefixZxid(lpz)
.setLastZxid(lz)
.build();
return Message.newBuilder().setType(MessageType.TRUNCATE)
.setTruncate(trunc)
.build();
} | [
"public",
"static",
"Message",
"buildTruncate",
"(",
"Zxid",
"lastPrefixZxid",
",",
"Zxid",
"lastZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"lpz",
"=",
"toProtoZxid",
"(",
"lastPrefixZxid",
")",
";",
"ZabMessage",
".",
"Zxid",
"lz",
"=",
"toProtoZxid",
"(",
... | Creates a TRUNCATE message.
@param lastPrefixZxid truncate receiver's log from lastPrefixZxid
exclusively.
@param lastZxid the last zxid for the synchronization.
@return a protobuf message. | [
"Creates",
"a",
"TRUNCATE",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L268-L277 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildNewLeader | public static Message buildNewLeader(long epoch) {
NewLeader nl = NewLeader.newBuilder().setEpoch(epoch).build();
return Message.newBuilder().setType(MessageType.NEW_LEADER)
.setNewLeader(nl)
.build();
} | java | public static Message buildNewLeader(long epoch) {
NewLeader nl = NewLeader.newBuilder().setEpoch(epoch).build();
return Message.newBuilder().setType(MessageType.NEW_LEADER)
.setNewLeader(nl)
.build();
} | [
"public",
"static",
"Message",
"buildNewLeader",
"(",
"long",
"epoch",
")",
"{",
"NewLeader",
"nl",
"=",
"NewLeader",
".",
"newBuilder",
"(",
")",
".",
"setEpoch",
"(",
"epoch",
")",
".",
"build",
"(",
")",
";",
"return",
"Message",
".",
"newBuilder",
"(... | Creates a NEW_LEADER message.
@param epoch the established epoch.
@return a protobuf message. | [
"Creates",
"a",
"NEW_LEADER",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L285-L290 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildAck | public static Message buildAck(Zxid zxid) {
ZabMessage.Zxid zzxid = toProtoZxid(zxid);
Ack ack = Ack.newBuilder().setZxid(zzxid).build();
return Message.newBuilder().setType(MessageType.ACK).setAck(ack).build();
} | java | public static Message buildAck(Zxid zxid) {
ZabMessage.Zxid zzxid = toProtoZxid(zxid);
Ack ack = Ack.newBuilder().setZxid(zzxid).build();
return Message.newBuilder().setType(MessageType.ACK).setAck(ack).build();
} | [
"public",
"static",
"Message",
"buildAck",
"(",
"Zxid",
"zxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zzxid",
"=",
"toProtoZxid",
"(",
"zxid",
")",
";",
"Ack",
"ack",
"=",
"Ack",
".",
"newBuilder",
"(",
")",
".",
"setZxid",
"(",
"zzxid",
")",
".",
"b... | Creates a ACK message.
@param zxid the zxid of the transaction ACK.
@return a protobuf message. | [
"Creates",
"a",
"ACK",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L298-L302 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildRequest | public static Message buildRequest(ByteBuffer request) {
Request req = Request.newBuilder()
.setRequest(ByteString.copyFrom(request))
.build();
return Message.newBuilder().setType(MessageType.REQUEST)
.setRequest(req)
.build();
} | java | public static Message buildRequest(ByteBuffer request) {
Request req = Request.newBuilder()
.setRequest(ByteString.copyFrom(request))
.build();
return Message.newBuilder().setType(MessageType.REQUEST)
.setRequest(req)
.build();
} | [
"public",
"static",
"Message",
"buildRequest",
"(",
"ByteBuffer",
"request",
")",
"{",
"Request",
"req",
"=",
"Request",
".",
"newBuilder",
"(",
")",
".",
"setRequest",
"(",
"ByteString",
".",
"copyFrom",
"(",
"request",
")",
")",
".",
"build",
"(",
")",
... | Creates a REQUEST message.
@param request the ByteBuffer represents the request.
@return a protobuf message. | [
"Creates",
"a",
"REQUEST",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L343-L351 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildCommit | public static Message buildCommit(Zxid zxid) {
ZabMessage.Zxid cZxid = toProtoZxid(zxid);
Commit commit = Commit.newBuilder().setZxid(cZxid).build();
return Message.newBuilder().setType(MessageType.COMMIT)
.setCommit(commit)
.build();
} | java | public static Message buildCommit(Zxid zxid) {
ZabMessage.Zxid cZxid = toProtoZxid(zxid);
Commit commit = Commit.newBuilder().setZxid(cZxid).build();
return Message.newBuilder().setType(MessageType.COMMIT)
.setCommit(commit)
.build();
} | [
"public",
"static",
"Message",
"buildCommit",
"(",
"Zxid",
"zxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"cZxid",
"=",
"toProtoZxid",
"(",
"zxid",
")",
";",
"Commit",
"commit",
"=",
"Commit",
".",
"newBuilder",
"(",
")",
".",
"setZxid",
"(",
"cZxid",
")",... | Creates a COMMIT message.
@param zxid the id of the committed transaction.
@return a protobuf message. | [
"Creates",
"a",
"COMMIT",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L359-L367 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildHandshake | public static Message buildHandshake(String nodeId) {
Handshake handshake = Handshake.newBuilder().setNodeId(nodeId).build();
return Message.newBuilder().setType(MessageType.HANDSHAKE)
.setHandshake(handshake)
.build();
} | java | public static Message buildHandshake(String nodeId) {
Handshake handshake = Handshake.newBuilder().setNodeId(nodeId).build();
return Message.newBuilder().setType(MessageType.HANDSHAKE)
.setHandshake(handshake)
.build();
} | [
"public",
"static",
"Message",
"buildHandshake",
"(",
"String",
"nodeId",
")",
"{",
"Handshake",
"handshake",
"=",
"Handshake",
".",
"newBuilder",
"(",
")",
".",
"setNodeId",
"(",
"nodeId",
")",
".",
"build",
"(",
")",
";",
"return",
"Message",
".",
"newBu... | Creates a HANDSHAKE message.
@param nodeId the node ID in the handshake message.
@return a protobuf message. | [
"Creates",
"a",
"HANDSHAKE",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L375-L380 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildDisconnected | public static Message buildDisconnected(String serverId) {
Disconnected dis = Disconnected.newBuilder()
.setServerId(serverId)
.build();
return Message.newBuilder().setType(MessageType.DISCONNECTED)
.setDisconnected(dis)
.build();
} | java | public static Message buildDisconnected(String serverId) {
Disconnected dis = Disconnected.newBuilder()
.setServerId(serverId)
.build();
return Message.newBuilder().setType(MessageType.DISCONNECTED)
.setDisconnected(dis)
.build();
} | [
"public",
"static",
"Message",
"buildDisconnected",
"(",
"String",
"serverId",
")",
"{",
"Disconnected",
"dis",
"=",
"Disconnected",
".",
"newBuilder",
"(",
")",
".",
"setServerId",
"(",
"serverId",
")",
".",
"build",
"(",
")",
";",
"return",
"Message",
".",... | Creates a DISCONNECTED message.
@param serverId the ID of the disconnected peer.
@return a protobuf message. | [
"Creates",
"a",
"DISCONNECTED",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L397-L404 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildQueryReply | public static Message buildQueryReply(String leader) {
QueryReply reply = QueryReply.newBuilder()
.setLeader(leader)
.build();
return Message.newBuilder().setType(MessageType.QUERY_LEADER_REPLY)
.setReply(reply)
.build();
} | java | public static Message buildQueryReply(String leader) {
QueryReply reply = QueryReply.newBuilder()
.setLeader(leader)
.build();
return Message.newBuilder().setType(MessageType.QUERY_LEADER_REPLY)
.setReply(reply)
.build();
} | [
"public",
"static",
"Message",
"buildQueryReply",
"(",
"String",
"leader",
")",
"{",
"QueryReply",
"reply",
"=",
"QueryReply",
".",
"newBuilder",
"(",
")",
".",
"setLeader",
"(",
"leader",
")",
".",
"build",
"(",
")",
";",
"return",
"Message",
".",
"newBui... | Creates a QUERY_REPLY message.
@param leader the current leader in broadcasting phase.
@return a protobuf message. | [
"Creates",
"a",
"QUERY_REPLY",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L421-L428 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildJoin | public static Message buildJoin(Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
ZabMessage.Join join =
ZabMessage.Join.newBuilder().setLastZxid(zxid).build();
return Message.newBuilder().setType(MessageType.JOIN).setJoin(join).build();
} | java | public static Message buildJoin(Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
ZabMessage.Join join =
ZabMessage.Join.newBuilder().setLastZxid(zxid).build();
return Message.newBuilder().setType(MessageType.JOIN).setJoin(join).build();
} | [
"public",
"static",
"Message",
"buildJoin",
"(",
"Zxid",
"lastZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"lastZxid",
")",
";",
"ZabMessage",
".",
"Join",
"join",
"=",
"ZabMessage",
".",
"Join",
".",
"newBuilder",
"(",
")",... | Creates a JOIN message.
@return a protobuf message. | [
"Creates",
"a",
"JOIN",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L435-L440 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildConfig | public static ZabMessage.ClusterConfiguration
buildConfig(ClusterConfiguration config) {
ZabMessage.Zxid version = toProtoZxid(config.getVersion());
return ZabMessage.ClusterConfiguration.newBuilder()
.setVersion(version)
.addAllServers(config.getPeers())
.build();
} | java | public static ZabMessage.ClusterConfiguration
buildConfig(ClusterConfiguration config) {
ZabMessage.Zxid version = toProtoZxid(config.getVersion());
return ZabMessage.ClusterConfiguration.newBuilder()
.setVersion(version)
.addAllServers(config.getPeers())
.build();
} | [
"public",
"static",
"ZabMessage",
".",
"ClusterConfiguration",
"buildConfig",
"(",
"ClusterConfiguration",
"config",
")",
"{",
"ZabMessage",
".",
"Zxid",
"version",
"=",
"toProtoZxid",
"(",
"config",
".",
"getVersion",
"(",
")",
")",
";",
"return",
"ZabMessage",
... | Creates a ZabMessage.ClusterConfiguration object.
@param config the ClusterConfiguration object.
@return protobuf ClusterConfiguration object. | [
"Creates",
"a",
"ZabMessage",
".",
"ClusterConfiguration",
"object",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L448-L455 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildSyncEnd | public static Message buildSyncEnd(ClusterConfiguration config) {
ZabMessage.Zxid version = toProtoZxid(config.getVersion());
ZabMessage.ClusterConfiguration zConfig
= ZabMessage.ClusterConfiguration.newBuilder()
.setVersion(version)
.addAllServers(config.getPeers())
.build();
return Message.newBuilder().setType(MessageType.SYNC_END)
.setConfig(zConfig)
.build();
} | java | public static Message buildSyncEnd(ClusterConfiguration config) {
ZabMessage.Zxid version = toProtoZxid(config.getVersion());
ZabMessage.ClusterConfiguration zConfig
= ZabMessage.ClusterConfiguration.newBuilder()
.setVersion(version)
.addAllServers(config.getPeers())
.build();
return Message.newBuilder().setType(MessageType.SYNC_END)
.setConfig(zConfig)
.build();
} | [
"public",
"static",
"Message",
"buildSyncEnd",
"(",
"ClusterConfiguration",
"config",
")",
"{",
"ZabMessage",
".",
"Zxid",
"version",
"=",
"toProtoZxid",
"(",
"config",
".",
"getVersion",
"(",
")",
")",
";",
"ZabMessage",
".",
"ClusterConfiguration",
"zConfig",
... | Creates a SYNC_END message.
@param config the cluster configuration.
@return a protobuf message. | [
"Creates",
"a",
"SYNC_END",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L463-L473 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildRemove | public static Message buildRemove(String serverId) {
Remove remove = Remove.newBuilder().setServerId(serverId).build();
return Message.newBuilder().setType(MessageType.REMOVE)
.setRemove(remove)
.build();
} | java | public static Message buildRemove(String serverId) {
Remove remove = Remove.newBuilder().setServerId(serverId).build();
return Message.newBuilder().setType(MessageType.REMOVE)
.setRemove(remove)
.build();
} | [
"public",
"static",
"Message",
"buildRemove",
"(",
"String",
"serverId",
")",
"{",
"Remove",
"remove",
"=",
"Remove",
".",
"newBuilder",
"(",
")",
".",
"setServerId",
"(",
"serverId",
")",
".",
"build",
"(",
")",
";",
"return",
"Message",
".",
"newBuilder"... | Creates a REMOVE message.
@param serverId the id of server who will be removed from the cluster
configuration.
@return a protobuf message. | [
"Creates",
"a",
"REMOVE",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L482-L487 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildDelivered | public static Message buildDelivered(Zxid deliveredZxid) {
ZabMessage.Zxid zxid = toProtoZxid(deliveredZxid);
ZabMessage.Delivered delivered =
ZabMessage.Delivered.newBuilder().setZxid(zxid).build();
return Message.newBuilder().setType(MessageType.DELIVERED)
.setDelivered(delivered).build();
} | java | public static Message buildDelivered(Zxid deliveredZxid) {
ZabMessage.Zxid zxid = toProtoZxid(deliveredZxid);
ZabMessage.Delivered delivered =
ZabMessage.Delivered.newBuilder().setZxid(zxid).build();
return Message.newBuilder().setType(MessageType.DELIVERED)
.setDelivered(delivered).build();
} | [
"public",
"static",
"Message",
"buildDelivered",
"(",
"Zxid",
"deliveredZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"deliveredZxid",
")",
";",
"ZabMessage",
".",
"Delivered",
"delivered",
"=",
"ZabMessage",
".",
"Delivered",
".",... | Creates a DELIVERED message.
@param deliveredZxid the last zxid of delivered transaction.
@return a protobuf message. | [
"Creates",
"a",
"DELIVERED",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L504-L510 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildFileHeader | public static Message buildFileHeader(long length) {
ZabMessage.FileHeader header = ZabMessage.FileHeader.newBuilder()
.setLength(length).build();
return Message.newBuilder().setType(MessageType.FILE_HEADER)
.setFileHeader(header).build();
} | java | public static Message buildFileHeader(long length) {
ZabMessage.FileHeader header = ZabMessage.FileHeader.newBuilder()
.setLength(length).build();
return Message.newBuilder().setType(MessageType.FILE_HEADER)
.setFileHeader(header).build();
} | [
"public",
"static",
"Message",
"buildFileHeader",
"(",
"long",
"length",
")",
"{",
"ZabMessage",
".",
"FileHeader",
"header",
"=",
"ZabMessage",
".",
"FileHeader",
".",
"newBuilder",
"(",
")",
".",
"setLength",
"(",
"length",
")",
".",
"build",
"(",
")",
"... | Creates a FILE_HEADER message.
@param length the lenght of the file.
@return a protobuf message. | [
"Creates",
"a",
"FILE_HEADER",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L518-L523 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildFileReceived | public static Message buildFileReceived(String fullPath) {
ZabMessage.FileReceived received = ZabMessage.FileReceived
.newBuilder()
.setFullPath(fullPath)
.build();
return Message.newBuilder().setType(MessageType.FILE_RECEIVED)
.setFileReceived(received).build();
} | java | public static Message buildFileReceived(String fullPath) {
ZabMessage.FileReceived received = ZabMessage.FileReceived
.newBuilder()
.setFullPath(fullPath)
.build();
return Message.newBuilder().setType(MessageType.FILE_RECEIVED)
.setFileReceived(received).build();
} | [
"public",
"static",
"Message",
"buildFileReceived",
"(",
"String",
"fullPath",
")",
"{",
"ZabMessage",
".",
"FileReceived",
"received",
"=",
"ZabMessage",
".",
"FileReceived",
".",
"newBuilder",
"(",
")",
".",
"setFullPath",
"(",
"fullPath",
")",
".",
"build",
... | Creates a FILE_RECEIVED message.
@param fullPath the path of the received file.
@return a protobuf message. | [
"Creates",
"a",
"FILE_RECEIVED",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L531-L538 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildFlushRequest | public static Message buildFlushRequest(ByteBuffer body) {
ZabMessage.FlushRequest flushReq =
ZabMessage.FlushRequest.newBuilder().setBody(ByteString.copyFrom(body))
.build();
return Message.newBuilder().setType(MessageType.FLUSH_REQ)
.setFlushRequest(flushReq)
.build();
} | java | public static Message buildFlushRequest(ByteBuffer body) {
ZabMessage.FlushRequest flushReq =
ZabMessage.FlushRequest.newBuilder().setBody(ByteString.copyFrom(body))
.build();
return Message.newBuilder().setType(MessageType.FLUSH_REQ)
.setFlushRequest(flushReq)
.build();
} | [
"public",
"static",
"Message",
"buildFlushRequest",
"(",
"ByteBuffer",
"body",
")",
"{",
"ZabMessage",
".",
"FlushRequest",
"flushReq",
"=",
"ZabMessage",
".",
"FlushRequest",
".",
"newBuilder",
"(",
")",
".",
"setBody",
"(",
"ByteString",
".",
"copyFrom",
"(",
... | Creates a FLUSH_REQ message.
@param body the data of the request.
@return a protobuf message. | [
"Creates",
"a",
"FLUSH_REQ",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L546-L553 | train |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildFlush | public static Message buildFlush(Zxid lastProposedZxid, ByteBuffer body) {
ZabMessage.Zxid zxid = toProtoZxid(lastProposedZxid);
ZabMessage.Flush flush = ZabMessage.Flush.newBuilder()
.setZxid(zxid)
.setBody(ByteString.copyFrom(body))
.build();
return Message.newBuilder().setType(MessageType.FLUSH).setFlush(flush)
.build();
} | java | public static Message buildFlush(Zxid lastProposedZxid, ByteBuffer body) {
ZabMessage.Zxid zxid = toProtoZxid(lastProposedZxid);
ZabMessage.Flush flush = ZabMessage.Flush.newBuilder()
.setZxid(zxid)
.setBody(ByteString.copyFrom(body))
.build();
return Message.newBuilder().setType(MessageType.FLUSH).setFlush(flush)
.build();
} | [
"public",
"static",
"Message",
"buildFlush",
"(",
"Zxid",
"lastProposedZxid",
",",
"ByteBuffer",
"body",
")",
"{",
"ZabMessage",
".",
"Zxid",
"zxid",
"=",
"toProtoZxid",
"(",
"lastProposedZxid",
")",
";",
"ZabMessage",
".",
"Flush",
"flush",
"=",
"ZabMessage",
... | Creates a FLUSH message.
@param lastProposedZxid the last proposed zxid before the FLUSH.
@param body the data of the request.
@return a protobuf message. | [
"Creates",
"a",
"FLUSH",
"message",
"."
] | 2a8893bcc1a125f3aebdaddee80ad49c9761bba1 | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L562-L570 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.