repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/PoolsImpl.java | PoolsImpl.resizeAsync | public Observable<Void> resizeAsync(String poolId, PoolResizeParameter poolResizeParameter) {
"""
Changes the number of compute nodes that are assigned to a pool.
You can only resize a pool when its allocation state is steady. If the pool is already resizing, the request fails with status code 409. When you resize a pool, the pool's allocation state changes from steady to resizing. You cannot resize pools which are configured for automatic scaling. If you try to do this, the Batch service returns an error 409. If you resize a pool downwards, the Batch service chooses which nodes to remove. To remove specific nodes, use the pool remove nodes API instead.
@param poolId The ID of the pool to resize.
@param poolResizeParameter The parameters for the request.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponseWithHeaders} object if successful.
"""
return resizeWithServiceResponseAsync(poolId, poolResizeParameter).map(new Func1<ServiceResponseWithHeaders<Void, PoolResizeHeaders>, Void>() {
@Override
public Void call(ServiceResponseWithHeaders<Void, PoolResizeHeaders> response) {
return response.body();
}
});
} | java | public Observable<Void> resizeAsync(String poolId, PoolResizeParameter poolResizeParameter) {
return resizeWithServiceResponseAsync(poolId, poolResizeParameter).map(new Func1<ServiceResponseWithHeaders<Void, PoolResizeHeaders>, Void>() {
@Override
public Void call(ServiceResponseWithHeaders<Void, PoolResizeHeaders> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"resizeAsync",
"(",
"String",
"poolId",
",",
"PoolResizeParameter",
"poolResizeParameter",
")",
"{",
"return",
"resizeWithServiceResponseAsync",
"(",
"poolId",
",",
"poolResizeParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"Void",
",",
"PoolResizeHeaders",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"Void",
",",
"PoolResizeHeaders",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Changes the number of compute nodes that are assigned to a pool.
You can only resize a pool when its allocation state is steady. If the pool is already resizing, the request fails with status code 409. When you resize a pool, the pool's allocation state changes from steady to resizing. You cannot resize pools which are configured for automatic scaling. If you try to do this, the Batch service returns an error 409. If you resize a pool downwards, the Batch service chooses which nodes to remove. To remove specific nodes, use the pool remove nodes API instead.
@param poolId The ID of the pool to resize.
@param poolResizeParameter The parameters for the request.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponseWithHeaders} object if successful. | [
"Changes",
"the",
"number",
"of",
"compute",
"nodes",
"that",
"are",
"assigned",
"to",
"a",
"pool",
".",
"You",
"can",
"only",
"resize",
"a",
"pool",
"when",
"its",
"allocation",
"state",
"is",
"steady",
".",
"If",
"the",
"pool",
"is",
"already",
"resizing",
"the",
"request",
"fails",
"with",
"status",
"code",
"409",
".",
"When",
"you",
"resize",
"a",
"pool",
"the",
"pool",
"s",
"allocation",
"state",
"changes",
"from",
"steady",
"to",
"resizing",
".",
"You",
"cannot",
"resize",
"pools",
"which",
"are",
"configured",
"for",
"automatic",
"scaling",
".",
"If",
"you",
"try",
"to",
"do",
"this",
"the",
"Batch",
"service",
"returns",
"an",
"error",
"409",
".",
"If",
"you",
"resize",
"a",
"pool",
"downwards",
"the",
"Batch",
"service",
"chooses",
"which",
"nodes",
"to",
"remove",
".",
"To",
"remove",
"specific",
"nodes",
"use",
"the",
"pool",
"remove",
"nodes",
"API",
"instead",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/PoolsImpl.java#L2748-L2755 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/elements/ElementPlugin.java | ElementPlugin.registerProperty | public void registerProperty(Object instance, String propertyName, boolean override) {
"""
Registers a named property to the container. Using this, a plugin can expose a property for
serialization and deserialization.
@param instance The object instance holding the property accessors. If null, any existing
registration will be removed.
@param propertyName Name of property to register.
@param override If the property is already registered to a non-proxy, the previous
registration will be replaced if this is true; otherwise the request is ignored.
"""
if (registeredProperties == null) {
registeredProperties = new HashMap<>();
}
if (instance == null) {
registeredProperties.remove(propertyName);
} else {
Object oldInstance = registeredProperties.get(propertyName);
PropertyProxy proxy = oldInstance instanceof PropertyProxy ? (PropertyProxy) oldInstance : null;
if (!override && oldInstance != null && proxy == null) {
return;
}
registeredProperties.put(propertyName, instance);
// If previous registrant was a property proxy, transfer its value to new registrant.
if (proxy != null) {
try {
proxy.getPropertyInfo().setPropertyValue(instance, proxy.getValue());
} catch (Exception e) {
throw createChainedException("Register Property", e, null);
}
}
}
} | java | public void registerProperty(Object instance, String propertyName, boolean override) {
if (registeredProperties == null) {
registeredProperties = new HashMap<>();
}
if (instance == null) {
registeredProperties.remove(propertyName);
} else {
Object oldInstance = registeredProperties.get(propertyName);
PropertyProxy proxy = oldInstance instanceof PropertyProxy ? (PropertyProxy) oldInstance : null;
if (!override && oldInstance != null && proxy == null) {
return;
}
registeredProperties.put(propertyName, instance);
// If previous registrant was a property proxy, transfer its value to new registrant.
if (proxy != null) {
try {
proxy.getPropertyInfo().setPropertyValue(instance, proxy.getValue());
} catch (Exception e) {
throw createChainedException("Register Property", e, null);
}
}
}
} | [
"public",
"void",
"registerProperty",
"(",
"Object",
"instance",
",",
"String",
"propertyName",
",",
"boolean",
"override",
")",
"{",
"if",
"(",
"registeredProperties",
"==",
"null",
")",
"{",
"registeredProperties",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"registeredProperties",
".",
"remove",
"(",
"propertyName",
")",
";",
"}",
"else",
"{",
"Object",
"oldInstance",
"=",
"registeredProperties",
".",
"get",
"(",
"propertyName",
")",
";",
"PropertyProxy",
"proxy",
"=",
"oldInstance",
"instanceof",
"PropertyProxy",
"?",
"(",
"PropertyProxy",
")",
"oldInstance",
":",
"null",
";",
"if",
"(",
"!",
"override",
"&&",
"oldInstance",
"!=",
"null",
"&&",
"proxy",
"==",
"null",
")",
"{",
"return",
";",
"}",
"registeredProperties",
".",
"put",
"(",
"propertyName",
",",
"instance",
")",
";",
"// If previous registrant was a property proxy, transfer its value to new registrant.",
"if",
"(",
"proxy",
"!=",
"null",
")",
"{",
"try",
"{",
"proxy",
".",
"getPropertyInfo",
"(",
")",
".",
"setPropertyValue",
"(",
"instance",
",",
"proxy",
".",
"getValue",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"createChainedException",
"(",
"\"Register Property\"",
",",
"e",
",",
"null",
")",
";",
"}",
"}",
"}",
"}"
] | Registers a named property to the container. Using this, a plugin can expose a property for
serialization and deserialization.
@param instance The object instance holding the property accessors. If null, any existing
registration will be removed.
@param propertyName Name of property to register.
@param override If the property is already registered to a non-proxy, the previous
registration will be replaced if this is true; otherwise the request is ignored. | [
"Registers",
"a",
"named",
"property",
"to",
"the",
"container",
".",
"Using",
"this",
"a",
"plugin",
"can",
"expose",
"a",
"property",
"for",
"serialization",
"and",
"deserialization",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/elements/ElementPlugin.java#L768-L794 |
interedition/collatex | collatex-core/src/main/java/eu/interedition/collatex/suffixarray/SuffixArrays.java | SuffixArrays.createWithLCP | public static SuffixData createWithLCP(int[] input, int start, int length) {
"""
Create a suffix array and an LCP array for a given input sequence of symbols.
"""
final ISuffixArrayBuilder builder = new DensePositiveDecorator(
new ExtraTrailingCellsDecorator(defaultAlgorithm(), 3));
return createWithLCP(input, start, length, builder);
} | java | public static SuffixData createWithLCP(int[] input, int start, int length) {
final ISuffixArrayBuilder builder = new DensePositiveDecorator(
new ExtraTrailingCellsDecorator(defaultAlgorithm(), 3));
return createWithLCP(input, start, length, builder);
} | [
"public",
"static",
"SuffixData",
"createWithLCP",
"(",
"int",
"[",
"]",
"input",
",",
"int",
"start",
",",
"int",
"length",
")",
"{",
"final",
"ISuffixArrayBuilder",
"builder",
"=",
"new",
"DensePositiveDecorator",
"(",
"new",
"ExtraTrailingCellsDecorator",
"(",
"defaultAlgorithm",
"(",
")",
",",
"3",
")",
")",
";",
"return",
"createWithLCP",
"(",
"input",
",",
"start",
",",
"length",
",",
"builder",
")",
";",
"}"
] | Create a suffix array and an LCP array for a given input sequence of symbols. | [
"Create",
"a",
"suffix",
"array",
"and",
"an",
"LCP",
"array",
"for",
"a",
"given",
"input",
"sequence",
"of",
"symbols",
"."
] | train | https://github.com/interedition/collatex/blob/76dd1fcc36047bc66a87d31142e72e98b5347821/collatex-core/src/main/java/eu/interedition/collatex/suffixarray/SuffixArrays.java#L84-L88 |
pawelprazak/java-extended | guava/src/main/java/com/bluecatcode/common/security/KeyProvider.java | KeyProvider.getPrivateKey | public PrivateKey getPrivateKey(String alias, String password) {
"""
Gets a asymmetric encryption private key from the key store
@param alias key alias
@param password key password
@return the private key
"""
Key key = getKey(alias, password);
if (key instanceof PrivateKey) {
return (PrivateKey) key;
} else {
throw new IllegalStateException(format("Key with alias '%s' was not a private key, but was: %s",
alias, key.getClass().getSimpleName()));
}
} | java | public PrivateKey getPrivateKey(String alias, String password) {
Key key = getKey(alias, password);
if (key instanceof PrivateKey) {
return (PrivateKey) key;
} else {
throw new IllegalStateException(format("Key with alias '%s' was not a private key, but was: %s",
alias, key.getClass().getSimpleName()));
}
} | [
"public",
"PrivateKey",
"getPrivateKey",
"(",
"String",
"alias",
",",
"String",
"password",
")",
"{",
"Key",
"key",
"=",
"getKey",
"(",
"alias",
",",
"password",
")",
";",
"if",
"(",
"key",
"instanceof",
"PrivateKey",
")",
"{",
"return",
"(",
"PrivateKey",
")",
"key",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"format",
"(",
"\"Key with alias '%s' was not a private key, but was: %s\"",
",",
"alias",
",",
"key",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"}",
"}"
] | Gets a asymmetric encryption private key from the key store
@param alias key alias
@param password key password
@return the private key | [
"Gets",
"a",
"asymmetric",
"encryption",
"private",
"key",
"from",
"the",
"key",
"store"
] | train | https://github.com/pawelprazak/java-extended/blob/ce1a556a95cbbf7c950a03662938bc02622de69b/guava/src/main/java/com/bluecatcode/common/security/KeyProvider.java#L55-L63 |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTree.java | MkCoPTree.adjustApproximatedKNNDistances | private void adjustApproximatedKNNDistances(MkCoPEntry entry, Map<DBID, KNNList> knnLists) {
"""
Adjusts the knn distance in the subtree of the specified root entry.
@param entry the root entry of the current subtree
@param knnLists a map of knn lists for each leaf entry
"""
MkCoPTreeNode<O> node = getNode(entry);
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPLeafEntry leafEntry = (MkCoPLeafEntry) node.getEntry(i);
approximateKnnDistances(leafEntry, knnLists.get(leafEntry.getRoutingObjectID()));
}
}
else {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPEntry dirEntry = node.getEntry(i);
adjustApproximatedKNNDistances(dirEntry, knnLists);
}
}
ApproximationLine approx = node.conservativeKnnDistanceApproximation(settings.kmax);
entry.setConservativeKnnDistanceApproximation(approx);
} | java | private void adjustApproximatedKNNDistances(MkCoPEntry entry, Map<DBID, KNNList> knnLists) {
MkCoPTreeNode<O> node = getNode(entry);
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPLeafEntry leafEntry = (MkCoPLeafEntry) node.getEntry(i);
approximateKnnDistances(leafEntry, knnLists.get(leafEntry.getRoutingObjectID()));
}
}
else {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPEntry dirEntry = node.getEntry(i);
adjustApproximatedKNNDistances(dirEntry, knnLists);
}
}
ApproximationLine approx = node.conservativeKnnDistanceApproximation(settings.kmax);
entry.setConservativeKnnDistanceApproximation(approx);
} | [
"private",
"void",
"adjustApproximatedKNNDistances",
"(",
"MkCoPEntry",
"entry",
",",
"Map",
"<",
"DBID",
",",
"KNNList",
">",
"knnLists",
")",
"{",
"MkCoPTreeNode",
"<",
"O",
">",
"node",
"=",
"getNode",
"(",
"entry",
")",
";",
"if",
"(",
"node",
".",
"isLeaf",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
"getNumEntries",
"(",
")",
";",
"i",
"++",
")",
"{",
"MkCoPLeafEntry",
"leafEntry",
"=",
"(",
"MkCoPLeafEntry",
")",
"node",
".",
"getEntry",
"(",
"i",
")",
";",
"approximateKnnDistances",
"(",
"leafEntry",
",",
"knnLists",
".",
"get",
"(",
"leafEntry",
".",
"getRoutingObjectID",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
"getNumEntries",
"(",
")",
";",
"i",
"++",
")",
"{",
"MkCoPEntry",
"dirEntry",
"=",
"node",
".",
"getEntry",
"(",
"i",
")",
";",
"adjustApproximatedKNNDistances",
"(",
"dirEntry",
",",
"knnLists",
")",
";",
"}",
"}",
"ApproximationLine",
"approx",
"=",
"node",
".",
"conservativeKnnDistanceApproximation",
"(",
"settings",
".",
"kmax",
")",
";",
"entry",
".",
"setConservativeKnnDistanceApproximation",
"(",
"approx",
")",
";",
"}"
] | Adjusts the knn distance in the subtree of the specified root entry.
@param entry the root entry of the current subtree
@param knnLists a map of knn lists for each leaf entry | [
"Adjusts",
"the",
"knn",
"distance",
"in",
"the",
"subtree",
"of",
"the",
"specified",
"root",
"entry",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTree.java#L300-L318 |
haraldk/TwelveMonkeys | common/common-lang/src/main/java/com/twelvemonkeys/util/convert/TimeConverter.java | TimeConverter.toObject | public Object toObject(String pString, Class pType, String pFormat)
throws ConversionException {
"""
Converts the string to a time, using the given format for parsing.
@param pString the string to convert.
@param pType the type to convert to. PropertyConverter
implementations may choose to ignore this parameter.
@param pFormat the format used for parsing. PropertyConverter
implementations may choose to ignore this parameter. Also,
implementations that require a parser format, should provide a default
format, and allow {@code null} as the format argument.
@return the object created from the given string. May safely be typecast
to {@code com.twelvemonkeys.util.Time}
@see com.twelvemonkeys.util.Time
@see com.twelvemonkeys.util.TimeFormat
@throws ConversionException
"""
if (StringUtil.isEmpty(pString))
return null;
TimeFormat format;
try {
if (pFormat == null) {
// Use system default format
format = TimeFormat.getInstance();
}
else {
// Get format from cache
format = getTimeFormat(pFormat);
}
return format.parse(pString);
}
catch (RuntimeException rte) {
throw new ConversionException(rte);
}
} | java | public Object toObject(String pString, Class pType, String pFormat)
throws ConversionException {
if (StringUtil.isEmpty(pString))
return null;
TimeFormat format;
try {
if (pFormat == null) {
// Use system default format
format = TimeFormat.getInstance();
}
else {
// Get format from cache
format = getTimeFormat(pFormat);
}
return format.parse(pString);
}
catch (RuntimeException rte) {
throw new ConversionException(rte);
}
} | [
"public",
"Object",
"toObject",
"(",
"String",
"pString",
",",
"Class",
"pType",
",",
"String",
"pFormat",
")",
"throws",
"ConversionException",
"{",
"if",
"(",
"StringUtil",
".",
"isEmpty",
"(",
"pString",
")",
")",
"return",
"null",
";",
"TimeFormat",
"format",
";",
"try",
"{",
"if",
"(",
"pFormat",
"==",
"null",
")",
"{",
"// Use system default format\r",
"format",
"=",
"TimeFormat",
".",
"getInstance",
"(",
")",
";",
"}",
"else",
"{",
"// Get format from cache\r",
"format",
"=",
"getTimeFormat",
"(",
"pFormat",
")",
";",
"}",
"return",
"format",
".",
"parse",
"(",
"pString",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"rte",
")",
"{",
"throw",
"new",
"ConversionException",
"(",
"rte",
")",
";",
"}",
"}"
] | Converts the string to a time, using the given format for parsing.
@param pString the string to convert.
@param pType the type to convert to. PropertyConverter
implementations may choose to ignore this parameter.
@param pFormat the format used for parsing. PropertyConverter
implementations may choose to ignore this parameter. Also,
implementations that require a parser format, should provide a default
format, and allow {@code null} as the format argument.
@return the object created from the given string. May safely be typecast
to {@code com.twelvemonkeys.util.Time}
@see com.twelvemonkeys.util.Time
@see com.twelvemonkeys.util.TimeFormat
@throws ConversionException | [
"Converts",
"the",
"string",
"to",
"a",
"time",
"using",
"the",
"given",
"format",
"for",
"parsing",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/convert/TimeConverter.java#L71-L94 |
lamydev/Android-Notification | core/src/zemin/notification/NotificationBoard.java | NotificationBoard.setHeaderMargin | public void setHeaderMargin(int l, int t, int r, int b) {
"""
Set the margin of the header.
@param l
@param t
@param r
@param b
"""
mHeader.setMargin(l, t, r, b);
} | java | public void setHeaderMargin(int l, int t, int r, int b) {
mHeader.setMargin(l, t, r, b);
} | [
"public",
"void",
"setHeaderMargin",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mHeader",
".",
"setMargin",
"(",
"l",
",",
"t",
",",
"r",
",",
"b",
")",
";",
"}"
] | Set the margin of the header.
@param l
@param t
@param r
@param b | [
"Set",
"the",
"margin",
"of",
"the",
"header",
"."
] | train | https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L556-L558 |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/repository/MultipleAddressParticipantRepository.java | MultipleAddressParticipantRepository.unregisterParticipant | public ADDRESST unregisterParticipant(ADDRESST address, EventListener entity) {
"""
Remove a participant from this repository.
@param address address of a participant to remove from this repository.
@param entity participant to unmap to the given address.
@return a.
"""
synchronized (mutex()) {
removeListener(address);
this.participants.remove(entity.getID(), address);
}
return address;
} | java | public ADDRESST unregisterParticipant(ADDRESST address, EventListener entity) {
synchronized (mutex()) {
removeListener(address);
this.participants.remove(entity.getID(), address);
}
return address;
} | [
"public",
"ADDRESST",
"unregisterParticipant",
"(",
"ADDRESST",
"address",
",",
"EventListener",
"entity",
")",
"{",
"synchronized",
"(",
"mutex",
"(",
")",
")",
"{",
"removeListener",
"(",
"address",
")",
";",
"this",
".",
"participants",
".",
"remove",
"(",
"entity",
".",
"getID",
"(",
")",
",",
"address",
")",
";",
"}",
"return",
"address",
";",
"}"
] | Remove a participant from this repository.
@param address address of a participant to remove from this repository.
@param entity participant to unmap to the given address.
@return a. | [
"Remove",
"a",
"participant",
"from",
"this",
"repository",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/repository/MultipleAddressParticipantRepository.java#L101-L107 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/join/CompositeRecordReader.java | CompositeRecordReader.accept | @SuppressWarnings("unchecked") // No values from static EMPTY class
public void accept(CompositeRecordReader.JoinCollector jc, K key)
throws IOException {
"""
If key provided matches that of this Composite, give JoinCollector
iterator over values it may emit.
"""
if (hasNext() && 0 == cmp.compare(key, key())) {
fillJoinCollector(createKey());
jc.add(id, getDelegate());
return;
}
jc.add(id, EMPTY);
} | java | @SuppressWarnings("unchecked") // No values from static EMPTY class
public void accept(CompositeRecordReader.JoinCollector jc, K key)
throws IOException {
if (hasNext() && 0 == cmp.compare(key, key())) {
fillJoinCollector(createKey());
jc.add(id, getDelegate());
return;
}
jc.add(id, EMPTY);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// No values from static EMPTY class",
"public",
"void",
"accept",
"(",
"CompositeRecordReader",
".",
"JoinCollector",
"jc",
",",
"K",
"key",
")",
"throws",
"IOException",
"{",
"if",
"(",
"hasNext",
"(",
")",
"&&",
"0",
"==",
"cmp",
".",
"compare",
"(",
"key",
",",
"key",
"(",
")",
")",
")",
"{",
"fillJoinCollector",
"(",
"createKey",
"(",
")",
")",
";",
"jc",
".",
"add",
"(",
"id",
",",
"getDelegate",
"(",
")",
")",
";",
"return",
";",
"}",
"jc",
".",
"add",
"(",
"id",
",",
"EMPTY",
")",
";",
"}"
] | If key provided matches that of this Composite, give JoinCollector
iterator over values it may emit. | [
"If",
"key",
"provided",
"matches",
"that",
"of",
"this",
"Composite",
"give",
"JoinCollector",
"iterator",
"over",
"values",
"it",
"may",
"emit",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/join/CompositeRecordReader.java#L361-L370 |
DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/PermissionOverrideAction.java | PermissionOverrideAction.setPermissions | @CheckReturnValue
public PermissionOverrideAction setPermissions(Collection<Permission> grantPermissions, Collection<Permission> denyPermissions) {
"""
Combination of {@link #setAllow(java.util.Collection)} and {@link #setDeny(java.util.Collection)}
<br>If a passed collection is {@code null} it resets the represented value to {@code 0} - no permission specifics.
<p>Example: {@code setPermissions(EnumSet.of(Permission.MESSAGE_READ), EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))}
@param grantPermissions
A Collection of {@link net.dv8tion.jda.core.Permission Permissions}
representing all explicitly granted Permissions for the PermissionOverride
@param denyPermissions
A Collection of {@link net.dv8tion.jda.core.Permission Permissions}
representing all explicitly denied Permissions for the PermissionOverride
@throws java.lang.IllegalArgumentException
If the any of the specified Permissions is {@code null}
@return The current PermissionOverrideAction - for chaining convenience
@see java.util.EnumSet EnumSet
@see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection)
"""
setAllow(grantPermissions);
setDeny(denyPermissions);
return this;
} | java | @CheckReturnValue
public PermissionOverrideAction setPermissions(Collection<Permission> grantPermissions, Collection<Permission> denyPermissions)
{
setAllow(grantPermissions);
setDeny(denyPermissions);
return this;
} | [
"@",
"CheckReturnValue",
"public",
"PermissionOverrideAction",
"setPermissions",
"(",
"Collection",
"<",
"Permission",
">",
"grantPermissions",
",",
"Collection",
"<",
"Permission",
">",
"denyPermissions",
")",
"{",
"setAllow",
"(",
"grantPermissions",
")",
";",
"setDeny",
"(",
"denyPermissions",
")",
";",
"return",
"this",
";",
"}"
] | Combination of {@link #setAllow(java.util.Collection)} and {@link #setDeny(java.util.Collection)}
<br>If a passed collection is {@code null} it resets the represented value to {@code 0} - no permission specifics.
<p>Example: {@code setPermissions(EnumSet.of(Permission.MESSAGE_READ), EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))}
@param grantPermissions
A Collection of {@link net.dv8tion.jda.core.Permission Permissions}
representing all explicitly granted Permissions for the PermissionOverride
@param denyPermissions
A Collection of {@link net.dv8tion.jda.core.Permission Permissions}
representing all explicitly denied Permissions for the PermissionOverride
@throws java.lang.IllegalArgumentException
If the any of the specified Permissions is {@code null}
@return The current PermissionOverrideAction - for chaining convenience
@see java.util.EnumSet EnumSet
@see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) | [
"Combination",
"of",
"{",
"@link",
"#setAllow",
"(",
"java",
".",
"util",
".",
"Collection",
")",
"}",
"and",
"{",
"@link",
"#setDeny",
"(",
"java",
".",
"util",
".",
"Collection",
")",
"}",
"<br",
">",
"If",
"a",
"passed",
"collection",
"is",
"{",
"@code",
"null",
"}",
"it",
"resets",
"the",
"represented",
"value",
"to",
"{",
"@code",
"0",
"}",
"-",
"no",
"permission",
"specifics",
"."
] | train | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/PermissionOverrideAction.java#L430-L436 |
fabric8io/docker-maven-plugin | src/main/java/io/fabric8/maven/docker/service/ArchiveService.java | ArchiveService.createDockerBuildArchive | public File createDockerBuildArchive(ImageConfiguration imageConfig, MojoParameters params, ArchiverCustomizer customizer)
throws MojoExecutionException {
"""
Create the tar file container the source for building an image. This tar can be used directly for
uploading to a Docker daemon for creating the image
@param imageConfig the image configuration
@param params mojo params for the project
@param customizer final customizer to be applied to the tar before being generated
@return file for holding the sources
@throws MojoExecutionException if during creation of the tar an error occurs.
"""
File ret = createArchive(imageConfig.getName(), imageConfig.getBuildConfiguration(), params, log, customizer);
log.info("%s: Created docker source tar %s",imageConfig.getDescription(), ret);
return ret;
} | java | public File createDockerBuildArchive(ImageConfiguration imageConfig, MojoParameters params, ArchiverCustomizer customizer)
throws MojoExecutionException {
File ret = createArchive(imageConfig.getName(), imageConfig.getBuildConfiguration(), params, log, customizer);
log.info("%s: Created docker source tar %s",imageConfig.getDescription(), ret);
return ret;
} | [
"public",
"File",
"createDockerBuildArchive",
"(",
"ImageConfiguration",
"imageConfig",
",",
"MojoParameters",
"params",
",",
"ArchiverCustomizer",
"customizer",
")",
"throws",
"MojoExecutionException",
"{",
"File",
"ret",
"=",
"createArchive",
"(",
"imageConfig",
".",
"getName",
"(",
")",
",",
"imageConfig",
".",
"getBuildConfiguration",
"(",
")",
",",
"params",
",",
"log",
",",
"customizer",
")",
";",
"log",
".",
"info",
"(",
"\"%s: Created docker source tar %s\"",
",",
"imageConfig",
".",
"getDescription",
"(",
")",
",",
"ret",
")",
";",
"return",
"ret",
";",
"}"
] | Create the tar file container the source for building an image. This tar can be used directly for
uploading to a Docker daemon for creating the image
@param imageConfig the image configuration
@param params mojo params for the project
@param customizer final customizer to be applied to the tar before being generated
@return file for holding the sources
@throws MojoExecutionException if during creation of the tar an error occurs. | [
"Create",
"the",
"tar",
"file",
"container",
"the",
"source",
"for",
"building",
"an",
"image",
".",
"This",
"tar",
"can",
"be",
"used",
"directly",
"for",
"uploading",
"to",
"a",
"Docker",
"daemon",
"for",
"creating",
"the",
"image"
] | train | https://github.com/fabric8io/docker-maven-plugin/blob/70ce4f56125d8efb8ddcf2ad4dbb5d6e2c7642b3/src/main/java/io/fabric8/maven/docker/service/ArchiveService.java#L73-L78 |
crawljax/crawljax | core/src/main/java/com/crawljax/util/XPathHelper.java | XPathHelper.evaluateXpathExpression | public static NodeList evaluateXpathExpression(String domStr, String xpathExpr)
throws XPathExpressionException, IOException {
"""
Returns the list of nodes which match the expression xpathExpr in the String domStr.
@return the list of nodes which match the query
@throws XPathExpressionException
@throws IOException
"""
Document dom = DomUtils.asDocument(domStr);
return evaluateXpathExpression(dom, xpathExpr);
} | java | public static NodeList evaluateXpathExpression(String domStr, String xpathExpr)
throws XPathExpressionException, IOException {
Document dom = DomUtils.asDocument(domStr);
return evaluateXpathExpression(dom, xpathExpr);
} | [
"public",
"static",
"NodeList",
"evaluateXpathExpression",
"(",
"String",
"domStr",
",",
"String",
"xpathExpr",
")",
"throws",
"XPathExpressionException",
",",
"IOException",
"{",
"Document",
"dom",
"=",
"DomUtils",
".",
"asDocument",
"(",
"domStr",
")",
";",
"return",
"evaluateXpathExpression",
"(",
"dom",
",",
"xpathExpr",
")",
";",
"}"
] | Returns the list of nodes which match the expression xpathExpr in the String domStr.
@return the list of nodes which match the query
@throws XPathExpressionException
@throws IOException | [
"Returns",
"the",
"list",
"of",
"nodes",
"which",
"match",
"the",
"expression",
"xpathExpr",
"in",
"the",
"String",
"domStr",
"."
] | train | https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/util/XPathHelper.java#L112-L116 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionPersistenceImpl.java | CPOptionPersistenceImpl.fetchByUUID_G | @Override
public CPOption fetchByUUID_G(String uuid, long groupId) {
"""
Returns the cp option where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param uuid the uuid
@param groupId the group ID
@return the matching cp option, or <code>null</code> if a matching cp option could not be found
"""
return fetchByUUID_G(uuid, groupId, true);
} | java | @Override
public CPOption fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
} | [
"@",
"Override",
"public",
"CPOption",
"fetchByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"{",
"return",
"fetchByUUID_G",
"(",
"uuid",
",",
"groupId",
",",
"true",
")",
";",
"}"
] | Returns the cp option where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param uuid the uuid
@param groupId the group ID
@return the matching cp option, or <code>null</code> if a matching cp option could not be found | [
"Returns",
"the",
"cp",
"option",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"or",
"returns",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"it",
"could",
"not",
"be",
"found",
".",
"Uses",
"the",
"finder",
"cache",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionPersistenceImpl.java#L694-L697 |
erlang/otp | lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java | AbstractConnection.sendLink | protected void sendLink(final OtpErlangPid from, final OtpErlangPid dest)
throws IOException {
"""
Create a link between the local node and the specified process on the
remote node. If the link is still active when the remote process
terminates, an exit signal will be sent to this connection. Use
{@link #sendUnlink unlink()} to remove the link.
@param dest
the Erlang PID of the remote process.
@exception java.io.IOException
if the connection is not active or a communication error
occurs.
"""
if (!connected) {
throw new IOException("Not connected");
}
@SuppressWarnings("resource")
final OtpOutputStream header = new OtpOutputStream(headerLen);
// preamble: 4 byte length + "passthrough" tag
header.write4BE(0); // reserve space for length
header.write1(passThrough);
header.write1(version);
// header
header.write_tuple_head(3);
header.write_long(linkTag);
header.write_any(from);
header.write_any(dest);
// fix up length in preamble
header.poke4BE(0, header.size() - 4);
do_send(header);
} | java | protected void sendLink(final OtpErlangPid from, final OtpErlangPid dest)
throws IOException {
if (!connected) {
throw new IOException("Not connected");
}
@SuppressWarnings("resource")
final OtpOutputStream header = new OtpOutputStream(headerLen);
// preamble: 4 byte length + "passthrough" tag
header.write4BE(0); // reserve space for length
header.write1(passThrough);
header.write1(version);
// header
header.write_tuple_head(3);
header.write_long(linkTag);
header.write_any(from);
header.write_any(dest);
// fix up length in preamble
header.poke4BE(0, header.size() - 4);
do_send(header);
} | [
"protected",
"void",
"sendLink",
"(",
"final",
"OtpErlangPid",
"from",
",",
"final",
"OtpErlangPid",
"dest",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"connected",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Not connected\"",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"final",
"OtpOutputStream",
"header",
"=",
"new",
"OtpOutputStream",
"(",
"headerLen",
")",
";",
"// preamble: 4 byte length + \"passthrough\" tag",
"header",
".",
"write4BE",
"(",
"0",
")",
";",
"// reserve space for length",
"header",
".",
"write1",
"(",
"passThrough",
")",
";",
"header",
".",
"write1",
"(",
"version",
")",
";",
"// header",
"header",
".",
"write_tuple_head",
"(",
"3",
")",
";",
"header",
".",
"write_long",
"(",
"linkTag",
")",
";",
"header",
".",
"write_any",
"(",
"from",
")",
";",
"header",
".",
"write_any",
"(",
"dest",
")",
";",
"// fix up length in preamble",
"header",
".",
"poke4BE",
"(",
"0",
",",
"header",
".",
"size",
"(",
")",
"-",
"4",
")",
";",
"do_send",
"(",
"header",
")",
";",
"}"
] | Create a link between the local node and the specified process on the
remote node. If the link is still active when the remote process
terminates, an exit signal will be sent to this connection. Use
{@link #sendUnlink unlink()} to remove the link.
@param dest
the Erlang PID of the remote process.
@exception java.io.IOException
if the connection is not active or a communication error
occurs. | [
"Create",
"a",
"link",
"between",
"the",
"local",
"node",
"and",
"the",
"specified",
"process",
"on",
"the",
"remote",
"node",
".",
"If",
"the",
"link",
"is",
"still",
"active",
"when",
"the",
"remote",
"process",
"terminates",
"an",
"exit",
"signal",
"will",
"be",
"sent",
"to",
"this",
"connection",
".",
"Use",
"{",
"@link",
"#sendUnlink",
"unlink",
"()",
"}",
"to",
"remove",
"the",
"link",
"."
] | train | https://github.com/erlang/otp/blob/ac6084fd83240355f72e94adbf303e57832d1fab/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java#L385-L408 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/ProcessDefinitionManager.java | ProcessDefinitionManager.deleteProcessDefinition | public void deleteProcessDefinition(ProcessDefinition processDefinition, String processDefinitionId, boolean cascadeToHistory, boolean cascadeToInstances, boolean skipCustomListeners, boolean skipIoMappings) {
"""
Deletes the given process definition from the database and cache.
If cascadeToHistory and cascadeToInstances is set to true it deletes
the history and the process instances.
*Note*: If more than one process definition, from one deployment, is deleted in
a single transaction and the cascadeToHistory and cascadeToInstances flag was set to true it
can cause a dirty deployment cache. The process instances of ALL process definitions must be deleted,
before every process definition can be deleted! In such cases the cascadeToInstances flag
have to set to false!
On deletion of all process instances, the task listeners will be deleted as well.
Deletion of tasks and listeners needs the redeployment of deployments.
It can cause to problems if is done sequential with the deletion of process definition
in a single transaction.
*For example*:
Deployment contains two process definition. First process definition
and instances will be removed, also cleared from the cache.
Second process definition will be removed and his instances.
Deletion of instances will cause redeployment this deploys again
first into the cache. Only the second will be removed from cache and
first remains in the cache after the deletion process.
@param processDefinition the process definition which should be deleted
@param processDefinitionId the id of the process definition
@param cascadeToHistory if true the history will deleted as well
@param cascadeToInstances if true the process instances are deleted as well
@param skipCustomListeners if true skips the custom listeners on deletion of instances
@param skipIoMappings specifies whether input/output mappings for tasks should be invoked
"""
if (cascadeToHistory) {
cascadeDeleteHistoryForProcessDefinition(processDefinitionId);
if (cascadeToInstances) {
cascadeDeleteProcessInstancesForProcessDefinition(processDefinitionId, skipCustomListeners, skipIoMappings);
}
} else {
ProcessInstanceQueryImpl procInstQuery = new ProcessInstanceQueryImpl().processDefinitionId(processDefinitionId);
long processInstanceCount = getProcessInstanceManager().findProcessInstanceCountByQueryCriteria(procInstQuery);
if (processInstanceCount != 0) {
throw LOG.deleteProcessDefinitionWithProcessInstancesException(processDefinitionId, processInstanceCount);
}
}
// remove related authorization parameters in IdentityLink table
getIdentityLinkManager().deleteIdentityLinksByProcDef(processDefinitionId);
// remove timer start events:
deleteTimerStartEventsForProcessDefinition(processDefinition);
//delete process definition from database
getDbEntityManager().delete(ProcessDefinitionEntity.class, "deleteProcessDefinitionsById", processDefinitionId);
// remove process definition from cache:
Context
.getProcessEngineConfiguration()
.getDeploymentCache()
.removeProcessDefinition(processDefinitionId);
deleteSubscriptionsForProcessDefinition(processDefinitionId);
// delete job definitions
getJobDefinitionManager().deleteJobDefinitionsByProcessDefinitionId(processDefinition.getId());
} | java | public void deleteProcessDefinition(ProcessDefinition processDefinition, String processDefinitionId, boolean cascadeToHistory, boolean cascadeToInstances, boolean skipCustomListeners, boolean skipIoMappings) {
if (cascadeToHistory) {
cascadeDeleteHistoryForProcessDefinition(processDefinitionId);
if (cascadeToInstances) {
cascadeDeleteProcessInstancesForProcessDefinition(processDefinitionId, skipCustomListeners, skipIoMappings);
}
} else {
ProcessInstanceQueryImpl procInstQuery = new ProcessInstanceQueryImpl().processDefinitionId(processDefinitionId);
long processInstanceCount = getProcessInstanceManager().findProcessInstanceCountByQueryCriteria(procInstQuery);
if (processInstanceCount != 0) {
throw LOG.deleteProcessDefinitionWithProcessInstancesException(processDefinitionId, processInstanceCount);
}
}
// remove related authorization parameters in IdentityLink table
getIdentityLinkManager().deleteIdentityLinksByProcDef(processDefinitionId);
// remove timer start events:
deleteTimerStartEventsForProcessDefinition(processDefinition);
//delete process definition from database
getDbEntityManager().delete(ProcessDefinitionEntity.class, "deleteProcessDefinitionsById", processDefinitionId);
// remove process definition from cache:
Context
.getProcessEngineConfiguration()
.getDeploymentCache()
.removeProcessDefinition(processDefinitionId);
deleteSubscriptionsForProcessDefinition(processDefinitionId);
// delete job definitions
getJobDefinitionManager().deleteJobDefinitionsByProcessDefinitionId(processDefinition.getId());
} | [
"public",
"void",
"deleteProcessDefinition",
"(",
"ProcessDefinition",
"processDefinition",
",",
"String",
"processDefinitionId",
",",
"boolean",
"cascadeToHistory",
",",
"boolean",
"cascadeToInstances",
",",
"boolean",
"skipCustomListeners",
",",
"boolean",
"skipIoMappings",
")",
"{",
"if",
"(",
"cascadeToHistory",
")",
"{",
"cascadeDeleteHistoryForProcessDefinition",
"(",
"processDefinitionId",
")",
";",
"if",
"(",
"cascadeToInstances",
")",
"{",
"cascadeDeleteProcessInstancesForProcessDefinition",
"(",
"processDefinitionId",
",",
"skipCustomListeners",
",",
"skipIoMappings",
")",
";",
"}",
"}",
"else",
"{",
"ProcessInstanceQueryImpl",
"procInstQuery",
"=",
"new",
"ProcessInstanceQueryImpl",
"(",
")",
".",
"processDefinitionId",
"(",
"processDefinitionId",
")",
";",
"long",
"processInstanceCount",
"=",
"getProcessInstanceManager",
"(",
")",
".",
"findProcessInstanceCountByQueryCriteria",
"(",
"procInstQuery",
")",
";",
"if",
"(",
"processInstanceCount",
"!=",
"0",
")",
"{",
"throw",
"LOG",
".",
"deleteProcessDefinitionWithProcessInstancesException",
"(",
"processDefinitionId",
",",
"processInstanceCount",
")",
";",
"}",
"}",
"// remove related authorization parameters in IdentityLink table",
"getIdentityLinkManager",
"(",
")",
".",
"deleteIdentityLinksByProcDef",
"(",
"processDefinitionId",
")",
";",
"// remove timer start events:",
"deleteTimerStartEventsForProcessDefinition",
"(",
"processDefinition",
")",
";",
"//delete process definition from database",
"getDbEntityManager",
"(",
")",
".",
"delete",
"(",
"ProcessDefinitionEntity",
".",
"class",
",",
"\"deleteProcessDefinitionsById\"",
",",
"processDefinitionId",
")",
";",
"// remove process definition from cache:",
"Context",
".",
"getProcessEngineConfiguration",
"(",
")",
".",
"getDeploymentCache",
"(",
")",
".",
"removeProcessDefinition",
"(",
"processDefinitionId",
")",
";",
"deleteSubscriptionsForProcessDefinition",
"(",
"processDefinitionId",
")",
";",
"// delete job definitions",
"getJobDefinitionManager",
"(",
")",
".",
"deleteJobDefinitionsByProcessDefinitionId",
"(",
"processDefinition",
".",
"getId",
"(",
")",
")",
";",
"}"
] | Deletes the given process definition from the database and cache.
If cascadeToHistory and cascadeToInstances is set to true it deletes
the history and the process instances.
*Note*: If more than one process definition, from one deployment, is deleted in
a single transaction and the cascadeToHistory and cascadeToInstances flag was set to true it
can cause a dirty deployment cache. The process instances of ALL process definitions must be deleted,
before every process definition can be deleted! In such cases the cascadeToInstances flag
have to set to false!
On deletion of all process instances, the task listeners will be deleted as well.
Deletion of tasks and listeners needs the redeployment of deployments.
It can cause to problems if is done sequential with the deletion of process definition
in a single transaction.
*For example*:
Deployment contains two process definition. First process definition
and instances will be removed, also cleared from the cache.
Second process definition will be removed and his instances.
Deletion of instances will cause redeployment this deploys again
first into the cache. Only the second will be removed from cache and
first remains in the cache after the deletion process.
@param processDefinition the process definition which should be deleted
@param processDefinitionId the id of the process definition
@param cascadeToHistory if true the history will deleted as well
@param cascadeToInstances if true the process instances are deleted as well
@param skipCustomListeners if true skips the custom listeners on deletion of instances
@param skipIoMappings specifies whether input/output mappings for tasks should be invoked | [
"Deletes",
"the",
"given",
"process",
"definition",
"from",
"the",
"database",
"and",
"cache",
".",
"If",
"cascadeToHistory",
"and",
"cascadeToInstances",
"is",
"set",
"to",
"true",
"it",
"deletes",
"the",
"history",
"and",
"the",
"process",
"instances",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/ProcessDefinitionManager.java#L335-L370 |
jenkinsci/jenkins | core/src/main/java/hudson/Launcher.java | Launcher.decorateByPrefix | @Nonnull
public final Launcher decorateByPrefix(final String... prefix) {
"""
Returns a decorated {@link Launcher} that puts the given set of arguments as a prefix to any commands
that it invokes.
@param prefix Prefixes to be appended
@since 1.299
"""
final Launcher outer = this;
return new Launcher(outer) {
@Override
public boolean isUnix() {
return outer.isUnix();
}
@Override
public Proc launch(ProcStarter starter) throws IOException {
starter.commands.addAll(0,Arrays.asList(prefix));
boolean[] masks = starter.masks;
if (masks != null) {
starter.masks = prefix(masks);
}
return outer.launch(starter);
}
@Override
public Channel launchChannel(String[] cmd, OutputStream out, FilePath workDir, Map<String, String> envVars) throws IOException, InterruptedException {
return outer.launchChannel(prefix(cmd),out,workDir,envVars);
}
@Override
public void kill(Map<String, String> modelEnvVars) throws IOException, InterruptedException {
outer.kill(modelEnvVars);
}
private String[] prefix(@Nonnull String[] args) {
String[] newArgs = new String[args.length+prefix.length];
System.arraycopy(prefix,0,newArgs,0,prefix.length);
System.arraycopy(args,0,newArgs,prefix.length,args.length);
return newArgs;
}
private boolean[] prefix(@Nonnull boolean[] args) {
boolean[] newArgs = new boolean[args.length+prefix.length];
System.arraycopy(args,0,newArgs,prefix.length,args.length);
return newArgs;
}
};
} | java | @Nonnull
public final Launcher decorateByPrefix(final String... prefix) {
final Launcher outer = this;
return new Launcher(outer) {
@Override
public boolean isUnix() {
return outer.isUnix();
}
@Override
public Proc launch(ProcStarter starter) throws IOException {
starter.commands.addAll(0,Arrays.asList(prefix));
boolean[] masks = starter.masks;
if (masks != null) {
starter.masks = prefix(masks);
}
return outer.launch(starter);
}
@Override
public Channel launchChannel(String[] cmd, OutputStream out, FilePath workDir, Map<String, String> envVars) throws IOException, InterruptedException {
return outer.launchChannel(prefix(cmd),out,workDir,envVars);
}
@Override
public void kill(Map<String, String> modelEnvVars) throws IOException, InterruptedException {
outer.kill(modelEnvVars);
}
private String[] prefix(@Nonnull String[] args) {
String[] newArgs = new String[args.length+prefix.length];
System.arraycopy(prefix,0,newArgs,0,prefix.length);
System.arraycopy(args,0,newArgs,prefix.length,args.length);
return newArgs;
}
private boolean[] prefix(@Nonnull boolean[] args) {
boolean[] newArgs = new boolean[args.length+prefix.length];
System.arraycopy(args,0,newArgs,prefix.length,args.length);
return newArgs;
}
};
} | [
"@",
"Nonnull",
"public",
"final",
"Launcher",
"decorateByPrefix",
"(",
"final",
"String",
"...",
"prefix",
")",
"{",
"final",
"Launcher",
"outer",
"=",
"this",
";",
"return",
"new",
"Launcher",
"(",
"outer",
")",
"{",
"@",
"Override",
"public",
"boolean",
"isUnix",
"(",
")",
"{",
"return",
"outer",
".",
"isUnix",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Proc",
"launch",
"(",
"ProcStarter",
"starter",
")",
"throws",
"IOException",
"{",
"starter",
".",
"commands",
".",
"addAll",
"(",
"0",
",",
"Arrays",
".",
"asList",
"(",
"prefix",
")",
")",
";",
"boolean",
"[",
"]",
"masks",
"=",
"starter",
".",
"masks",
";",
"if",
"(",
"masks",
"!=",
"null",
")",
"{",
"starter",
".",
"masks",
"=",
"prefix",
"(",
"masks",
")",
";",
"}",
"return",
"outer",
".",
"launch",
"(",
"starter",
")",
";",
"}",
"@",
"Override",
"public",
"Channel",
"launchChannel",
"(",
"String",
"[",
"]",
"cmd",
",",
"OutputStream",
"out",
",",
"FilePath",
"workDir",
",",
"Map",
"<",
"String",
",",
"String",
">",
"envVars",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"return",
"outer",
".",
"launchChannel",
"(",
"prefix",
"(",
"cmd",
")",
",",
"out",
",",
"workDir",
",",
"envVars",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"kill",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"modelEnvVars",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"outer",
".",
"kill",
"(",
"modelEnvVars",
")",
";",
"}",
"private",
"String",
"[",
"]",
"prefix",
"(",
"@",
"Nonnull",
"String",
"[",
"]",
"args",
")",
"{",
"String",
"[",
"]",
"newArgs",
"=",
"new",
"String",
"[",
"args",
".",
"length",
"+",
"prefix",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"prefix",
",",
"0",
",",
"newArgs",
",",
"0",
",",
"prefix",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"args",
",",
"0",
",",
"newArgs",
",",
"prefix",
".",
"length",
",",
"args",
".",
"length",
")",
";",
"return",
"newArgs",
";",
"}",
"private",
"boolean",
"[",
"]",
"prefix",
"(",
"@",
"Nonnull",
"boolean",
"[",
"]",
"args",
")",
"{",
"boolean",
"[",
"]",
"newArgs",
"=",
"new",
"boolean",
"[",
"args",
".",
"length",
"+",
"prefix",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"args",
",",
"0",
",",
"newArgs",
",",
"prefix",
".",
"length",
",",
"args",
".",
"length",
")",
";",
"return",
"newArgs",
";",
"}",
"}",
";",
"}"
] | Returns a decorated {@link Launcher} that puts the given set of arguments as a prefix to any commands
that it invokes.
@param prefix Prefixes to be appended
@since 1.299 | [
"Returns",
"a",
"decorated",
"{",
"@link",
"Launcher",
"}",
"that",
"puts",
"the",
"given",
"set",
"of",
"arguments",
"as",
"a",
"prefix",
"to",
"any",
"commands",
"that",
"it",
"invokes",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/Launcher.java#L819-L861 |
voldemort/voldemort | src/java/voldemort/utils/RebalanceUtils.java | RebalanceUtils.validateClusterNodeCounts | public static void validateClusterNodeCounts(final Cluster lhs, final Cluster rhs) {
"""
Confirms that both clusters have the same number of nodes by comparing
set of node Ids between clusters.
@param lhs
@param rhs
"""
if(!lhs.getNodeIds().equals(rhs.getNodeIds())) {
throw new VoldemortException("Node ids are not the same [ lhs cluster node ids ("
+ lhs.getNodeIds()
+ ") not equal to rhs cluster node ids ("
+ rhs.getNodeIds() + ") ]");
}
} | java | public static void validateClusterNodeCounts(final Cluster lhs, final Cluster rhs) {
if(!lhs.getNodeIds().equals(rhs.getNodeIds())) {
throw new VoldemortException("Node ids are not the same [ lhs cluster node ids ("
+ lhs.getNodeIds()
+ ") not equal to rhs cluster node ids ("
+ rhs.getNodeIds() + ") ]");
}
} | [
"public",
"static",
"void",
"validateClusterNodeCounts",
"(",
"final",
"Cluster",
"lhs",
",",
"final",
"Cluster",
"rhs",
")",
"{",
"if",
"(",
"!",
"lhs",
".",
"getNodeIds",
"(",
")",
".",
"equals",
"(",
"rhs",
".",
"getNodeIds",
"(",
")",
")",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"Node ids are not the same [ lhs cluster node ids (\"",
"+",
"lhs",
".",
"getNodeIds",
"(",
")",
"+",
"\") not equal to rhs cluster node ids (\"",
"+",
"rhs",
".",
"getNodeIds",
"(",
")",
"+",
"\") ]\"",
")",
";",
"}",
"}"
] | Confirms that both clusters have the same number of nodes by comparing
set of node Ids between clusters.
@param lhs
@param rhs | [
"Confirms",
"that",
"both",
"clusters",
"have",
"the",
"same",
"number",
"of",
"nodes",
"by",
"comparing",
"set",
"of",
"node",
"Ids",
"between",
"clusters",
"."
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/RebalanceUtils.java#L221-L228 |
Azure/azure-sdk-for-java | edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java | DevicesInner.beginDownloadUpdatesAsync | public Observable<Void> beginDownloadUpdatesAsync(String deviceName, String resourceGroupName) {
"""
Downloads the updates on a data box edge/gateway device.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginDownloadUpdatesWithServiceResponseAsync(deviceName, resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginDownloadUpdatesAsync(String deviceName, String resourceGroupName) {
return beginDownloadUpdatesWithServiceResponseAsync(deviceName, resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginDownloadUpdatesAsync",
"(",
"String",
"deviceName",
",",
"String",
"resourceGroupName",
")",
"{",
"return",
"beginDownloadUpdatesWithServiceResponseAsync",
"(",
"deviceName",
",",
"resourceGroupName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Downloads the updates on a data box edge/gateway device.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Downloads",
"the",
"updates",
"on",
"a",
"data",
"box",
"edge",
"/",
"gateway",
"device",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java#L1295-L1302 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark-nlp-java8/src/main/java/org/deeplearning4j/spark/models/paragraphvectors/SparkParagraphVectors.java | SparkParagraphVectors.fitMultipleFiles | public void fitMultipleFiles(JavaPairRDD<String, String> documentsRdd) {
"""
This method builds ParagraphVectors model, expecting JavaPairRDD with key as label, and value as document-in-a-string.
@param documentsRdd
"""
/*
All we want here, is to transform JavaPairRDD into JavaRDD<Sequence<VocabWord>>
*/
validateConfiguration();
broadcastEnvironment(new JavaSparkContext(documentsRdd.context()));
JavaRDD<Sequence<VocabWord>> sequenceRdd =
documentsRdd.map(new KeySequenceConvertFunction(configurationBroadcast));
super.fitSequences(sequenceRdd);
} | java | public void fitMultipleFiles(JavaPairRDD<String, String> documentsRdd) {
/*
All we want here, is to transform JavaPairRDD into JavaRDD<Sequence<VocabWord>>
*/
validateConfiguration();
broadcastEnvironment(new JavaSparkContext(documentsRdd.context()));
JavaRDD<Sequence<VocabWord>> sequenceRdd =
documentsRdd.map(new KeySequenceConvertFunction(configurationBroadcast));
super.fitSequences(sequenceRdd);
} | [
"public",
"void",
"fitMultipleFiles",
"(",
"JavaPairRDD",
"<",
"String",
",",
"String",
">",
"documentsRdd",
")",
"{",
"/*\n All we want here, is to transform JavaPairRDD into JavaRDD<Sequence<VocabWord>>\n */",
"validateConfiguration",
"(",
")",
";",
"broadcastEnvironment",
"(",
"new",
"JavaSparkContext",
"(",
"documentsRdd",
".",
"context",
"(",
")",
")",
")",
";",
"JavaRDD",
"<",
"Sequence",
"<",
"VocabWord",
">",
">",
"sequenceRdd",
"=",
"documentsRdd",
".",
"map",
"(",
"new",
"KeySequenceConvertFunction",
"(",
"configurationBroadcast",
")",
")",
";",
"super",
".",
"fitSequences",
"(",
"sequenceRdd",
")",
";",
"}"
] | This method builds ParagraphVectors model, expecting JavaPairRDD with key as label, and value as document-in-a-string.
@param documentsRdd | [
"This",
"method",
"builds",
"ParagraphVectors",
"model",
"expecting",
"JavaPairRDD",
"with",
"key",
"as",
"label",
"and",
"value",
"as",
"document",
"-",
"in",
"-",
"a",
"-",
"string",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark-nlp-java8/src/main/java/org/deeplearning4j/spark/models/paragraphvectors/SparkParagraphVectors.java#L60-L72 |
line/centraldogma | server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java | CentralDogma.forConfig | public static CentralDogma forConfig(File configFile) throws IOException {
"""
Creates a new instance from the given configuration file.
@throws IOException if failed to load the configuration from the specified file
"""
requireNonNull(configFile, "configFile");
return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class));
} | java | public static CentralDogma forConfig(File configFile) throws IOException {
requireNonNull(configFile, "configFile");
return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class));
} | [
"public",
"static",
"CentralDogma",
"forConfig",
"(",
"File",
"configFile",
")",
"throws",
"IOException",
"{",
"requireNonNull",
"(",
"configFile",
",",
"\"configFile\"",
")",
";",
"return",
"new",
"CentralDogma",
"(",
"Jackson",
".",
"readValue",
"(",
"configFile",
",",
"CentralDogmaConfig",
".",
"class",
")",
")",
";",
"}"
] | Creates a new instance from the given configuration file.
@throws IOException if failed to load the configuration from the specified file | [
"Creates",
"a",
"new",
"instance",
"from",
"the",
"given",
"configuration",
"file",
"."
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java#L179-L182 |
js-lib-com/commons | src/main/java/js/lang/Config.java | Config.getProperty | public <T> T getProperty(String name, Class<T> type, T defaultValue) {
"""
Get configuration object property converter to requested type or default value if there is no property with given
name.
@param name property name.
@param type type to convert property value to,
@param defaultValue default value, possible null or empty.
@param <T> value type.
@return newly created value object or default value.
@throws IllegalArgumentException if <code>name</code> argument is null or empty.
@throws IllegalArgumentException if <code>type</code> argument is null.
@throws ConverterException if there is no converter registered for value type or value parse fails.
"""
Params.notNullOrEmpty(name, "Property name");
Params.notNull(type, "Property type");
String value = getProperty(name);
if(value != null) {
return converter.asObject(value, type);
}
return defaultValue;
} | java | public <T> T getProperty(String name, Class<T> type, T defaultValue)
{
Params.notNullOrEmpty(name, "Property name");
Params.notNull(type, "Property type");
String value = getProperty(name);
if(value != null) {
return converter.asObject(value, type);
}
return defaultValue;
} | [
"public",
"<",
"T",
">",
"T",
"getProperty",
"(",
"String",
"name",
",",
"Class",
"<",
"T",
">",
"type",
",",
"T",
"defaultValue",
")",
"{",
"Params",
".",
"notNullOrEmpty",
"(",
"name",
",",
"\"Property name\"",
")",
";",
"Params",
".",
"notNull",
"(",
"type",
",",
"\"Property type\"",
")",
";",
"String",
"value",
"=",
"getProperty",
"(",
"name",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"converter",
".",
"asObject",
"(",
"value",
",",
"type",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
] | Get configuration object property converter to requested type or default value if there is no property with given
name.
@param name property name.
@param type type to convert property value to,
@param defaultValue default value, possible null or empty.
@param <T> value type.
@return newly created value object or default value.
@throws IllegalArgumentException if <code>name</code> argument is null or empty.
@throws IllegalArgumentException if <code>type</code> argument is null.
@throws ConverterException if there is no converter registered for value type or value parse fails. | [
"Get",
"configuration",
"object",
"property",
"converter",
"to",
"requested",
"type",
"or",
"default",
"value",
"if",
"there",
"is",
"no",
"property",
"with",
"given",
"name",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/lang/Config.java#L427-L436 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/URLConnection.java | URLConnection.skipForward | static private long skipForward(InputStream is, long toSkip)
throws IOException {
"""
Skips through the specified number of bytes from the stream
until either EOF is reached, or the specified
number of bytes have been skipped
"""
long eachSkip = 0;
long skipped = 0;
while (skipped != toSkip) {
eachSkip = is.skip(toSkip - skipped);
// check if EOF is reached
if (eachSkip <= 0) {
if (is.read() == -1) {
return skipped ;
} else {
skipped++;
}
}
skipped += eachSkip;
}
return skipped;
} | java | static private long skipForward(InputStream is, long toSkip)
throws IOException {
long eachSkip = 0;
long skipped = 0;
while (skipped != toSkip) {
eachSkip = is.skip(toSkip - skipped);
// check if EOF is reached
if (eachSkip <= 0) {
if (is.read() == -1) {
return skipped ;
} else {
skipped++;
}
}
skipped += eachSkip;
}
return skipped;
} | [
"static",
"private",
"long",
"skipForward",
"(",
"InputStream",
"is",
",",
"long",
"toSkip",
")",
"throws",
"IOException",
"{",
"long",
"eachSkip",
"=",
"0",
";",
"long",
"skipped",
"=",
"0",
";",
"while",
"(",
"skipped",
"!=",
"toSkip",
")",
"{",
"eachSkip",
"=",
"is",
".",
"skip",
"(",
"toSkip",
"-",
"skipped",
")",
";",
"// check if EOF is reached",
"if",
"(",
"eachSkip",
"<=",
"0",
")",
"{",
"if",
"(",
"is",
".",
"read",
"(",
")",
"==",
"-",
"1",
")",
"{",
"return",
"skipped",
";",
"}",
"else",
"{",
"skipped",
"++",
";",
"}",
"}",
"skipped",
"+=",
"eachSkip",
";",
"}",
"return",
"skipped",
";",
"}"
] | Skips through the specified number of bytes from the stream
until either EOF is reached, or the specified
number of bytes have been skipped | [
"Skips",
"through",
"the",
"specified",
"number",
"of",
"bytes",
"from",
"the",
"stream",
"until",
"either",
"EOF",
"is",
"reached",
"or",
"the",
"specified",
"number",
"of",
"bytes",
"have",
"been",
"skipped"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/URLConnection.java#L1759-L1779 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/pipeline/LabeledChunkIdentifier.java | LabeledChunkIdentifier.isEndOfChunk | public static boolean isEndOfChunk(LabelTagType prev, LabelTagType cur) {
"""
Returns whether a chunk ended between the previous and current token
@param prev - the label/tag/type of the previous token
@param cur - the label/tag/type of the current token
@return true if the previous token was the last token of a chunk
"""
if (prev == null) return false;
return isEndOfChunk(prev.tag, prev.type, cur.tag, cur.type);
} | java | public static boolean isEndOfChunk(LabelTagType prev, LabelTagType cur)
{
if (prev == null) return false;
return isEndOfChunk(prev.tag, prev.type, cur.tag, cur.type);
} | [
"public",
"static",
"boolean",
"isEndOfChunk",
"(",
"LabelTagType",
"prev",
",",
"LabelTagType",
"cur",
")",
"{",
"if",
"(",
"prev",
"==",
"null",
")",
"return",
"false",
";",
"return",
"isEndOfChunk",
"(",
"prev",
".",
"tag",
",",
"prev",
".",
"type",
",",
"cur",
".",
"tag",
",",
"cur",
".",
"type",
")",
";",
"}"
] | Returns whether a chunk ended between the previous and current token
@param prev - the label/tag/type of the previous token
@param cur - the label/tag/type of the current token
@return true if the previous token was the last token of a chunk | [
"Returns",
"whether",
"a",
"chunk",
"ended",
"between",
"the",
"previous",
"and",
"current",
"token"
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/pipeline/LabeledChunkIdentifier.java#L155-L159 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/DdosProtectionPlansInner.java | DdosProtectionPlansInner.beginDelete | public void beginDelete(String resourceGroupName, String ddosProtectionPlanName) {
"""
Deletes the specified DDoS protection plan.
@param resourceGroupName The name of the resource group.
@param ddosProtectionPlanName The name of the DDoS protection plan.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginDeleteWithServiceResponseAsync(resourceGroupName, ddosProtectionPlanName).toBlocking().single().body();
} | java | public void beginDelete(String resourceGroupName, String ddosProtectionPlanName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, ddosProtectionPlanName).toBlocking().single().body();
} | [
"public",
"void",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"ddosProtectionPlanName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"ddosProtectionPlanName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes the specified DDoS protection plan.
@param resourceGroupName The name of the resource group.
@param ddosProtectionPlanName The name of the DDoS protection plan.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Deletes",
"the",
"specified",
"DDoS",
"protection",
"plan",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/DdosProtectionPlansInner.java#L180-L182 |
js-lib-com/commons | src/main/java/js/util/FilteredStrings.java | FilteredStrings.addAll | public void addAll(String prefix, String[] strings) {
"""
Add strings accepted by this filter pattern but prefixed with given string. Strings argument can come from
{@link File#list()} and can be null in which case this method does nothing. This method accept a prefix argument; it is
inserted at every string start before actually adding to strings list.
<pre>
File directory = new File(".");
FilteredStrings files = new FilteredStrings("index.*");
files.addAll("/var/www/", directory.list());
</pre>
If <code>directory</code> contains files like <em>index.htm</em>, <em>index.css</em>, etc. will be added to
<code>files</code> but prefixed like <em>/var/www/index.htm</em>, respective <em>/var/www/index.css</em>.
@param prefix prefix to insert on every string,
@param strings strings to scan for pattern, possible null.
"""
if (strings == null) {
return;
}
for (String string : strings) {
if (filter.accept(string)) {
list.add(prefix + string);
}
}
} | java | public void addAll(String prefix, String[] strings) {
if (strings == null) {
return;
}
for (String string : strings) {
if (filter.accept(string)) {
list.add(prefix + string);
}
}
} | [
"public",
"void",
"addAll",
"(",
"String",
"prefix",
",",
"String",
"[",
"]",
"strings",
")",
"{",
"if",
"(",
"strings",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"String",
"string",
":",
"strings",
")",
"{",
"if",
"(",
"filter",
".",
"accept",
"(",
"string",
")",
")",
"{",
"list",
".",
"add",
"(",
"prefix",
"+",
"string",
")",
";",
"}",
"}",
"}"
] | Add strings accepted by this filter pattern but prefixed with given string. Strings argument can come from
{@link File#list()} and can be null in which case this method does nothing. This method accept a prefix argument; it is
inserted at every string start before actually adding to strings list.
<pre>
File directory = new File(".");
FilteredStrings files = new FilteredStrings("index.*");
files.addAll("/var/www/", directory.list());
</pre>
If <code>directory</code> contains files like <em>index.htm</em>, <em>index.css</em>, etc. will be added to
<code>files</code> but prefixed like <em>/var/www/index.htm</em>, respective <em>/var/www/index.css</em>.
@param prefix prefix to insert on every string,
@param strings strings to scan for pattern, possible null. | [
"Add",
"strings",
"accepted",
"by",
"this",
"filter",
"pattern",
"but",
"prefixed",
"with",
"given",
"string",
".",
"Strings",
"argument",
"can",
"come",
"from",
"{",
"@link",
"File#list",
"()",
"}",
"and",
"can",
"be",
"null",
"in",
"which",
"case",
"this",
"method",
"does",
"nothing",
".",
"This",
"method",
"accept",
"a",
"prefix",
"argument",
";",
"it",
"is",
"inserted",
"at",
"every",
"string",
"start",
"before",
"actually",
"adding",
"to",
"strings",
"list",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/FilteredStrings.java#L79-L88 |
js-lib-com/commons | src/main/java/js/util/Strings.java | Strings.removeTrailing | public static String removeTrailing(String string, char c) {
"""
Remove trailing character, if exists.
@param string source string,
@param c trailing character to eliminate.
@return source string guaranteed to not end in requested character.
"""
if(string == null) {
return null;
}
final int lastCharIndex = string.length() - 1;
return string.charAt(lastCharIndex) == c ? string.substring(0, lastCharIndex) : string;
} | java | public static String removeTrailing(String string, char c)
{
if(string == null) {
return null;
}
final int lastCharIndex = string.length() - 1;
return string.charAt(lastCharIndex) == c ? string.substring(0, lastCharIndex) : string;
} | [
"public",
"static",
"String",
"removeTrailing",
"(",
"String",
"string",
",",
"char",
"c",
")",
"{",
"if",
"(",
"string",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"int",
"lastCharIndex",
"=",
"string",
".",
"length",
"(",
")",
"-",
"1",
";",
"return",
"string",
".",
"charAt",
"(",
"lastCharIndex",
")",
"==",
"c",
"?",
"string",
".",
"substring",
"(",
"0",
",",
"lastCharIndex",
")",
":",
"string",
";",
"}"
] | Remove trailing character, if exists.
@param string source string,
@param c trailing character to eliminate.
@return source string guaranteed to not end in requested character. | [
"Remove",
"trailing",
"character",
"if",
"exists",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1328-L1335 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetIntegrationResult.java | GetIntegrationResult.withRequestTemplates | public GetIntegrationResult withRequestTemplates(java.util.Map<String, String> requestTemplates) {
"""
<p>
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template (as a
String) is the value.
</p>
@param requestTemplates
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template
(as a String) is the value.
@return Returns a reference to this object so that method calls can be chained together.
"""
setRequestTemplates(requestTemplates);
return this;
} | java | public GetIntegrationResult withRequestTemplates(java.util.Map<String, String> requestTemplates) {
setRequestTemplates(requestTemplates);
return this;
} | [
"public",
"GetIntegrationResult",
"withRequestTemplates",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"requestTemplates",
")",
"{",
"setRequestTemplates",
"(",
"requestTemplates",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template (as a
String) is the value.
</p>
@param requestTemplates
Represents a map of Velocity templates that are applied on the request payload based on the value of the
Content-Type header sent by the client. The content type value is the key in this map, and the template
(as a String) is the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Represents",
"a",
"map",
"of",
"Velocity",
"templates",
"that",
"are",
"applied",
"on",
"the",
"request",
"payload",
"based",
"on",
"the",
"value",
"of",
"the",
"Content",
"-",
"Type",
"header",
"sent",
"by",
"the",
"client",
".",
"The",
"content",
"type",
"value",
"is",
"the",
"key",
"in",
"this",
"map",
"and",
"the",
"template",
"(",
"as",
"a",
"String",
")",
"is",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetIntegrationResult.java#L1219-L1222 |
marvinlabs/android-intents | library/src/main/java/com/marvinlabs/intents/PhoneIntents.java | PhoneIntents.newPickContactIntent | @SuppressWarnings("deprecation")
public static Intent newPickContactIntent(String scope) {
"""
Pick contact from phone book
<p/>
Examples:
<p/>
<code><pre>
// Select only from users with emails
IntentUtils.pickContact(ContactsContract.CommonDataKinds.Email.CONTENT_TYPE);
<p/>
// Select only from users with phone numbers on pre Eclair devices
IntentUtils.pickContact(Contacts.Phones.CONTENT_TYPE);
<p/>
// Select only from users with phone numbers on devices with Eclair and higher
IntentUtils.pickContact(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
</pre></code>
@param scope You can restrict selection by passing required content type.
"""
Intent intent;
if (isContacts2ApiSupported()) {
intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://com.android.contacts/contacts"));
} else {
intent = new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI);
}
if (!TextUtils.isEmpty(scope)) {
intent.setType(scope);
}
return intent;
} | java | @SuppressWarnings("deprecation")
public static Intent newPickContactIntent(String scope) {
Intent intent;
if (isContacts2ApiSupported()) {
intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://com.android.contacts/contacts"));
} else {
intent = new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI);
}
if (!TextUtils.isEmpty(scope)) {
intent.setType(scope);
}
return intent;
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"Intent",
"newPickContactIntent",
"(",
"String",
"scope",
")",
"{",
"Intent",
"intent",
";",
"if",
"(",
"isContacts2ApiSupported",
"(",
")",
")",
"{",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_PICK",
",",
"Uri",
".",
"parse",
"(",
"\"content://com.android.contacts/contacts\"",
")",
")",
";",
"}",
"else",
"{",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_PICK",
",",
"Contacts",
".",
"People",
".",
"CONTENT_URI",
")",
";",
"}",
"if",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"scope",
")",
")",
"{",
"intent",
".",
"setType",
"(",
"scope",
")",
";",
"}",
"return",
"intent",
";",
"}"
] | Pick contact from phone book
<p/>
Examples:
<p/>
<code><pre>
// Select only from users with emails
IntentUtils.pickContact(ContactsContract.CommonDataKinds.Email.CONTENT_TYPE);
<p/>
// Select only from users with phone numbers on pre Eclair devices
IntentUtils.pickContact(Contacts.Phones.CONTENT_TYPE);
<p/>
// Select only from users with phone numbers on devices with Eclair and higher
IntentUtils.pickContact(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
</pre></code>
@param scope You can restrict selection by passing required content type. | [
"Pick",
"contact",
"from",
"phone",
"book",
"<p",
"/",
">",
"Examples",
":",
"<p",
"/",
">",
"<code",
">",
"<pre",
">",
"//",
"Select",
"only",
"from",
"users",
"with",
"emails",
"IntentUtils",
".",
"pickContact",
"(",
"ContactsContract",
".",
"CommonDataKinds",
".",
"Email",
".",
"CONTENT_TYPE",
")",
";",
"<p",
"/",
">",
"//",
"Select",
"only",
"from",
"users",
"with",
"phone",
"numbers",
"on",
"pre",
"Eclair",
"devices",
"IntentUtils",
".",
"pickContact",
"(",
"Contacts",
".",
"Phones",
".",
"CONTENT_TYPE",
")",
";",
"<p",
"/",
">",
"//",
"Select",
"only",
"from",
"users",
"with",
"phone",
"numbers",
"on",
"devices",
"with",
"Eclair",
"and",
"higher",
"IntentUtils",
".",
"pickContact",
"(",
"ContactsContract",
".",
"CommonDataKinds",
".",
"Phone",
".",
"CONTENT_TYPE",
")",
";",
"<",
"/",
"pre",
">",
"<",
"/",
"code",
">"
] | train | https://github.com/marvinlabs/android-intents/blob/33e79c825188b6a97601869522533cc825801f6e/library/src/main/java/com/marvinlabs/intents/PhoneIntents.java#L178-L192 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/reflect/ClassUtils.java | ClassUtils.isPresent | public static boolean isPresent(String name, @Nullable ClassLoader classLoader) {
"""
Check whether the given class is present in the given classloader.
@param name The name of the class
@param classLoader The classloader. If null will fallback to attempt the thread context loader, otherwise the system loader
@return True if it is
"""
return forName(name, classLoader).isPresent();
} | java | public static boolean isPresent(String name, @Nullable ClassLoader classLoader) {
return forName(name, classLoader).isPresent();
} | [
"public",
"static",
"boolean",
"isPresent",
"(",
"String",
"name",
",",
"@",
"Nullable",
"ClassLoader",
"classLoader",
")",
"{",
"return",
"forName",
"(",
"name",
",",
"classLoader",
")",
".",
"isPresent",
"(",
")",
";",
"}"
] | Check whether the given class is present in the given classloader.
@param name The name of the class
@param classLoader The classloader. If null will fallback to attempt the thread context loader, otherwise the system loader
@return True if it is | [
"Check",
"whether",
"the",
"given",
"class",
"is",
"present",
"in",
"the",
"given",
"classloader",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/reflect/ClassUtils.java#L212-L214 |
wisdom-framework/wisdom | core/wisdom-api/src/main/java/org/wisdom/api/router/AbstractRouter.java | AbstractRouter.getReverseRouteFor | @Override
public String getReverseRouteFor(Class<? extends Controller> clazz, String method) {
"""
Gets the url of the route handled by the specified action method. The action does not takes parameters. This
implementation delegates to {@link #getReverseRouteFor(java.lang.Class, String, java.util.Map)}.
@param clazz the controller class
@param method the controller method
@return the url, {@literal null} if the action method is not found
"""
return getReverseRouteFor(clazz, method, null);
} | java | @Override
public String getReverseRouteFor(Class<? extends Controller> clazz, String method) {
return getReverseRouteFor(clazz, method, null);
} | [
"@",
"Override",
"public",
"String",
"getReverseRouteFor",
"(",
"Class",
"<",
"?",
"extends",
"Controller",
">",
"clazz",
",",
"String",
"method",
")",
"{",
"return",
"getReverseRouteFor",
"(",
"clazz",
",",
"method",
",",
"null",
")",
";",
"}"
] | Gets the url of the route handled by the specified action method. The action does not takes parameters. This
implementation delegates to {@link #getReverseRouteFor(java.lang.Class, String, java.util.Map)}.
@param clazz the controller class
@param method the controller method
@return the url, {@literal null} if the action method is not found | [
"Gets",
"the",
"url",
"of",
"the",
"route",
"handled",
"by",
"the",
"specified",
"action",
"method",
".",
"The",
"action",
"does",
"not",
"takes",
"parameters",
".",
"This",
"implementation",
"delegates",
"to",
"{",
"@link",
"#getReverseRouteFor",
"(",
"java",
".",
"lang",
".",
"Class",
"String",
"java",
".",
"util",
".",
"Map",
")",
"}",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-api/src/main/java/org/wisdom/api/router/AbstractRouter.java#L128-L131 |
soi-toolkit/soi-toolkit-mule | commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/rest/RestClient.java | RestClient.doHttpSendRequest | public MuleMessage doHttpSendRequest(String url, String method, String payload, String contentType) {
"""
Perform a HTTP call sending information to the server using POST or PUT
@param url
@param method, e.g. "POST" or "PUT"
@param payload
@param contentType
@return
@throws MuleException
"""
Map<String, String> properties = new HashMap<String, String>();
properties.put("http.method", method);
properties.put("Content-Type", contentType);
MuleMessage response = send(url, payload, properties);
return response;
} | java | public MuleMessage doHttpSendRequest(String url, String method, String payload, String contentType) {
Map<String, String> properties = new HashMap<String, String>();
properties.put("http.method", method);
properties.put("Content-Type", contentType);
MuleMessage response = send(url, payload, properties);
return response;
} | [
"public",
"MuleMessage",
"doHttpSendRequest",
"(",
"String",
"url",
",",
"String",
"method",
",",
"String",
"payload",
",",
"String",
"contentType",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"\"http.method\"",
",",
"method",
")",
";",
"properties",
".",
"put",
"(",
"\"Content-Type\"",
",",
"contentType",
")",
";",
"MuleMessage",
"response",
"=",
"send",
"(",
"url",
",",
"payload",
",",
"properties",
")",
";",
"return",
"response",
";",
"}"
] | Perform a HTTP call sending information to the server using POST or PUT
@param url
@param method, e.g. "POST" or "PUT"
@param payload
@param contentType
@return
@throws MuleException | [
"Perform",
"a",
"HTTP",
"call",
"sending",
"information",
"to",
"the",
"server",
"using",
"POST",
"or",
"PUT"
] | train | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/rest/RestClient.java#L159-L168 |
joniles/mpxj | src/main/java/net/sf/mpxj/turboproject/PEPUtility.java | PEPUtility.getFinishDate | public static final Date getFinishDate(byte[] data, int offset) {
"""
Retrieve a finish date.
@param data byte array
@param offset offset into byte array
@return finish date
"""
Date result;
long days = getShort(data, offset);
if (days == 0x8000)
{
result = null;
}
else
{
result = DateHelper.getDateFromLong(EPOCH + ((days - 1) * DateHelper.MS_PER_DAY));
}
return (result);
} | java | public static final Date getFinishDate(byte[] data, int offset)
{
Date result;
long days = getShort(data, offset);
if (days == 0x8000)
{
result = null;
}
else
{
result = DateHelper.getDateFromLong(EPOCH + ((days - 1) * DateHelper.MS_PER_DAY));
}
return (result);
} | [
"public",
"static",
"final",
"Date",
"getFinishDate",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"Date",
"result",
";",
"long",
"days",
"=",
"getShort",
"(",
"data",
",",
"offset",
")",
";",
"if",
"(",
"days",
"==",
"0x8000",
")",
"{",
"result",
"=",
"null",
";",
"}",
"else",
"{",
"result",
"=",
"DateHelper",
".",
"getDateFromLong",
"(",
"EPOCH",
"+",
"(",
"(",
"days",
"-",
"1",
")",
"*",
"DateHelper",
".",
"MS_PER_DAY",
")",
")",
";",
"}",
"return",
"(",
"result",
")",
";",
"}"
] | Retrieve a finish date.
@param data byte array
@param offset offset into byte array
@return finish date | [
"Retrieve",
"a",
"finish",
"date",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/turboproject/PEPUtility.java#L144-L159 |
Azure/azure-sdk-for-java | hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java | ConfigurationsInner.listAsync | public Observable<ClusterConfigurationsInner> listAsync(String resourceGroupName, String clusterName) {
"""
Gets all configuration information for an HDI cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ClusterConfigurationsInner object
"""
return listWithServiceResponseAsync(resourceGroupName, clusterName).map(new Func1<ServiceResponse<ClusterConfigurationsInner>, ClusterConfigurationsInner>() {
@Override
public ClusterConfigurationsInner call(ServiceResponse<ClusterConfigurationsInner> response) {
return response.body();
}
});
} | java | public Observable<ClusterConfigurationsInner> listAsync(String resourceGroupName, String clusterName) {
return listWithServiceResponseAsync(resourceGroupName, clusterName).map(new Func1<ServiceResponse<ClusterConfigurationsInner>, ClusterConfigurationsInner>() {
@Override
public ClusterConfigurationsInner call(ServiceResponse<ClusterConfigurationsInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ClusterConfigurationsInner",
">",
"listAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ClusterConfigurationsInner",
">",
",",
"ClusterConfigurationsInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ClusterConfigurationsInner",
"call",
"(",
"ServiceResponse",
"<",
"ClusterConfigurationsInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets all configuration information for an HDI cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ClusterConfigurationsInner object | [
"Gets",
"all",
"configuration",
"information",
"for",
"an",
"HDI",
"cluster",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java#L111-L118 |
JOML-CI/JOML | src/org/joml/Vector4f.java | Vector4f.fma | public Vector4f fma(Vector4fc a, Vector4fc b) {
"""
Add the component-wise multiplication of <code>a * b</code> to this vector.
@param a
the first multiplicand
@param b
the second multiplicand
@return a vector holding the result
"""
return fma(a, b, thisOrNew());
} | java | public Vector4f fma(Vector4fc a, Vector4fc b) {
return fma(a, b, thisOrNew());
} | [
"public",
"Vector4f",
"fma",
"(",
"Vector4fc",
"a",
",",
"Vector4fc",
"b",
")",
"{",
"return",
"fma",
"(",
"a",
",",
"b",
",",
"thisOrNew",
"(",
")",
")",
";",
"}"
] | Add the component-wise multiplication of <code>a * b</code> to this vector.
@param a
the first multiplicand
@param b
the second multiplicand
@return a vector holding the result | [
"Add",
"the",
"component",
"-",
"wise",
"multiplication",
"of",
"<code",
">",
"a",
"*",
"b<",
"/",
"code",
">",
"to",
"this",
"vector",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Vector4f.java#L700-L702 |
petergeneric/stdlib | service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java | NginxService.reconfigure | public void reconfigure(final String config) {
"""
Rewrite the nginx site configuration and reload
@param config
the nginx site configuration
"""
try
{
final File tempFile = File.createTempFile("nginx", ".conf");
try
{
FileHelper.write(tempFile, config);
final Execed process = Exec.rootUtility(new File(binPath, "nginx-reconfigure").getAbsolutePath(),
tempFile.getAbsolutePath());
process.waitForExit(new Timeout(30, TimeUnit.SECONDS).start(), 0);
}
finally
{
FileUtils.deleteQuietly(tempFile);
}
}
catch (IOException e)
{
throw new RuntimeException("Error executing nginx-reload command", e);
}
reload();
} | java | public void reconfigure(final String config)
{
try
{
final File tempFile = File.createTempFile("nginx", ".conf");
try
{
FileHelper.write(tempFile, config);
final Execed process = Exec.rootUtility(new File(binPath, "nginx-reconfigure").getAbsolutePath(),
tempFile.getAbsolutePath());
process.waitForExit(new Timeout(30, TimeUnit.SECONDS).start(), 0);
}
finally
{
FileUtils.deleteQuietly(tempFile);
}
}
catch (IOException e)
{
throw new RuntimeException("Error executing nginx-reload command", e);
}
reload();
} | [
"public",
"void",
"reconfigure",
"(",
"final",
"String",
"config",
")",
"{",
"try",
"{",
"final",
"File",
"tempFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"nginx\"",
",",
"\".conf\"",
")",
";",
"try",
"{",
"FileHelper",
".",
"write",
"(",
"tempFile",
",",
"config",
")",
";",
"final",
"Execed",
"process",
"=",
"Exec",
".",
"rootUtility",
"(",
"new",
"File",
"(",
"binPath",
",",
"\"nginx-reconfigure\"",
")",
".",
"getAbsolutePath",
"(",
")",
",",
"tempFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"process",
".",
"waitForExit",
"(",
"new",
"Timeout",
"(",
"30",
",",
"TimeUnit",
".",
"SECONDS",
")",
".",
"start",
"(",
")",
",",
"0",
")",
";",
"}",
"finally",
"{",
"FileUtils",
".",
"deleteQuietly",
"(",
"tempFile",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error executing nginx-reload command\"",
",",
"e",
")",
";",
"}",
"reload",
"(",
")",
";",
"}"
] | Rewrite the nginx site configuration and reload
@param config
the nginx site configuration | [
"Rewrite",
"the",
"nginx",
"site",
"configuration",
"and",
"reload"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java#L45-L70 |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ScreenUtils.java | ScreenUtils.setScreenOffTimeout | public static void setScreenOffTimeout(Context context, int millis) {
"""
@param context
@param millis Time for screen to turn off. Setting this value to -1 will prohibit screen from turning off
"""
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, millis);
} | java | public static void setScreenOffTimeout(Context context, int millis) {
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, millis);
} | [
"public",
"static",
"void",
"setScreenOffTimeout",
"(",
"Context",
"context",
",",
"int",
"millis",
")",
"{",
"Settings",
".",
"System",
".",
"putInt",
"(",
"context",
".",
"getContentResolver",
"(",
")",
",",
"Settings",
".",
"System",
".",
"SCREEN_OFF_TIMEOUT",
",",
"millis",
")",
";",
"}"
] | @param context
@param millis Time for screen to turn off. Setting this value to -1 will prohibit screen from turning off | [
"@param",
"context",
"@param",
"millis",
"Time",
"for",
"screen",
"to",
"turn",
"off",
".",
"Setting",
"this",
"value",
"to",
"-",
"1",
"will",
"prohibit",
"screen",
"from",
"turning",
"off"
] | train | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ScreenUtils.java#L30-L32 |
netty/netty | handler/src/main/java/io/netty/handler/ssl/SslContext.java | SslContext.buildKeyStore | static KeyStore buildKeyStore(X509Certificate[] certChain, PrivateKey key, char[] keyPasswordChars)
throws KeyStoreException, NoSuchAlgorithmException,
CertificateException, IOException {
"""
Generates a new {@link KeyStore}.
@param certChain a X.509 certificate chain
@param key a PKCS#8 private key
@param keyPasswordChars the password of the {@code keyFile}.
{@code null} if it's not password-protected.
@return generated {@link KeyStore}.
"""
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, null);
ks.setKeyEntry(ALIAS, key, keyPasswordChars, certChain);
return ks;
} | java | static KeyStore buildKeyStore(X509Certificate[] certChain, PrivateKey key, char[] keyPasswordChars)
throws KeyStoreException, NoSuchAlgorithmException,
CertificateException, IOException {
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, null);
ks.setKeyEntry(ALIAS, key, keyPasswordChars, certChain);
return ks;
} | [
"static",
"KeyStore",
"buildKeyStore",
"(",
"X509Certificate",
"[",
"]",
"certChain",
",",
"PrivateKey",
"key",
",",
"char",
"[",
"]",
"keyPasswordChars",
")",
"throws",
"KeyStoreException",
",",
"NoSuchAlgorithmException",
",",
"CertificateException",
",",
"IOException",
"{",
"KeyStore",
"ks",
"=",
"KeyStore",
".",
"getInstance",
"(",
"KeyStore",
".",
"getDefaultType",
"(",
")",
")",
";",
"ks",
".",
"load",
"(",
"null",
",",
"null",
")",
";",
"ks",
".",
"setKeyEntry",
"(",
"ALIAS",
",",
"key",
",",
"keyPasswordChars",
",",
"certChain",
")",
";",
"return",
"ks",
";",
"}"
] | Generates a new {@link KeyStore}.
@param certChain a X.509 certificate chain
@param key a PKCS#8 private key
@param keyPasswordChars the password of the {@code keyFile}.
{@code null} if it's not password-protected.
@return generated {@link KeyStore}. | [
"Generates",
"a",
"new",
"{",
"@link",
"KeyStore",
"}",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/SslContext.java#L1035-L1042 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/SyncGroupsInner.java | SyncGroupsInner.listLogsAsync | public Observable<Page<SyncGroupLogPropertiesInner>> listLogsAsync(final String resourceGroupName, final String serverName, final String databaseName, final String syncGroupName, final String startTime, final String endTime, final String type, final String continuationToken) {
"""
Gets a collection of sync group logs.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database on which the sync group is hosted.
@param syncGroupName The name of the sync group.
@param startTime Get logs generated after this time.
@param endTime Get logs generated before this time.
@param type The types of logs to retrieve. Possible values include: 'All', 'Error', 'Warning', 'Success'
@param continuationToken The continuation token for this operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SyncGroupLogPropertiesInner> object
"""
return listLogsWithServiceResponseAsync(resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, type, continuationToken)
.map(new Func1<ServiceResponse<Page<SyncGroupLogPropertiesInner>>, Page<SyncGroupLogPropertiesInner>>() {
@Override
public Page<SyncGroupLogPropertiesInner> call(ServiceResponse<Page<SyncGroupLogPropertiesInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<SyncGroupLogPropertiesInner>> listLogsAsync(final String resourceGroupName, final String serverName, final String databaseName, final String syncGroupName, final String startTime, final String endTime, final String type, final String continuationToken) {
return listLogsWithServiceResponseAsync(resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, type, continuationToken)
.map(new Func1<ServiceResponse<Page<SyncGroupLogPropertiesInner>>, Page<SyncGroupLogPropertiesInner>>() {
@Override
public Page<SyncGroupLogPropertiesInner> call(ServiceResponse<Page<SyncGroupLogPropertiesInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"SyncGroupLogPropertiesInner",
">",
">",
"listLogsAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"serverName",
",",
"final",
"String",
"databaseName",
",",
"final",
"String",
"syncGroupName",
",",
"final",
"String",
"startTime",
",",
"final",
"String",
"endTime",
",",
"final",
"String",
"type",
",",
"final",
"String",
"continuationToken",
")",
"{",
"return",
"listLogsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"syncGroupName",
",",
"startTime",
",",
"endTime",
",",
"type",
",",
"continuationToken",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SyncGroupLogPropertiesInner",
">",
">",
",",
"Page",
"<",
"SyncGroupLogPropertiesInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"SyncGroupLogPropertiesInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"SyncGroupLogPropertiesInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets a collection of sync group logs.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database on which the sync group is hosted.
@param syncGroupName The name of the sync group.
@param startTime Get logs generated after this time.
@param endTime Get logs generated before this time.
@param type The types of logs to retrieve. Possible values include: 'All', 'Error', 'Warning', 'Success'
@param continuationToken The continuation token for this operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SyncGroupLogPropertiesInner> object | [
"Gets",
"a",
"collection",
"of",
"sync",
"group",
"logs",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/SyncGroupsInner.java#L804-L812 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/Jdt2Ecore.java | Jdt2Ecore.isSubClassOf | public boolean isSubClassOf(TypeFinder typeFinder, String subClass, String superClass) throws JavaModelException {
"""
Replies if the given type is a subclass of the second type.
<p>The type finder could be obtained with {@link #toTypeFinder(IJavaProject)}.
@param typeFinder the type finder to be used for finding the type definitions.
@param subClass the name of the sub class.
@param superClass the name of the expected super class.
@return <code>true</code> if it is a subclass.
@throws JavaModelException if the Java model is invalid.
@see #toTypeFinder(IJavaProject)
"""
final SuperTypeIterator typeIterator = new SuperTypeIterator(typeFinder, false, subClass);
while (typeIterator.hasNext()) {
final IType type = typeIterator.next();
if (Objects.equals(type.getFullyQualifiedName(), superClass)) {
return true;
}
}
return false;
} | java | public boolean isSubClassOf(TypeFinder typeFinder, String subClass, String superClass) throws JavaModelException {
final SuperTypeIterator typeIterator = new SuperTypeIterator(typeFinder, false, subClass);
while (typeIterator.hasNext()) {
final IType type = typeIterator.next();
if (Objects.equals(type.getFullyQualifiedName(), superClass)) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"isSubClassOf",
"(",
"TypeFinder",
"typeFinder",
",",
"String",
"subClass",
",",
"String",
"superClass",
")",
"throws",
"JavaModelException",
"{",
"final",
"SuperTypeIterator",
"typeIterator",
"=",
"new",
"SuperTypeIterator",
"(",
"typeFinder",
",",
"false",
",",
"subClass",
")",
";",
"while",
"(",
"typeIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"IType",
"type",
"=",
"typeIterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"Objects",
".",
"equals",
"(",
"type",
".",
"getFullyQualifiedName",
"(",
")",
",",
"superClass",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Replies if the given type is a subclass of the second type.
<p>The type finder could be obtained with {@link #toTypeFinder(IJavaProject)}.
@param typeFinder the type finder to be used for finding the type definitions.
@param subClass the name of the sub class.
@param superClass the name of the expected super class.
@return <code>true</code> if it is a subclass.
@throws JavaModelException if the Java model is invalid.
@see #toTypeFinder(IJavaProject) | [
"Replies",
"if",
"the",
"given",
"type",
"is",
"a",
"subclass",
"of",
"the",
"second",
"type",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/Jdt2Ecore.java#L594-L603 |
joniles/mpxj | src/main/java/net/sf/mpxj/primavera/PrimaveraPMFileReader.java | PrimaveraPMFileReader.processActivityCodes | private void processActivityCodes(APIBusinessObjects apibo, ProjectType project) {
"""
Process activity code data.
@param apibo global activity code data
@param project project-specific activity code data
"""
ActivityCodeContainer container = m_projectFile.getActivityCodes();
Map<Integer, ActivityCode> map = new HashMap<Integer, ActivityCode>();
List<ActivityCodeTypeType> types = new ArrayList<ActivityCodeTypeType>();
types.addAll(apibo.getActivityCodeType());
types.addAll(project.getActivityCodeType());
for (ActivityCodeTypeType type : types)
{
ActivityCode code = new ActivityCode(type.getObjectId(), type.getName());
container.add(code);
map.put(code.getUniqueID(), code);
}
List<ActivityCodeType> typeValues = new ArrayList<ActivityCodeType>();
typeValues.addAll(apibo.getActivityCode());
typeValues.addAll(project.getActivityCode());
for (ActivityCodeType typeValue : typeValues)
{
ActivityCode code = map.get(typeValue.getCodeTypeObjectId());
if (code != null)
{
ActivityCodeValue value = code.addValue(typeValue.getObjectId(), typeValue.getCodeValue(), typeValue.getDescription());
m_activityCodeMap.put(value.getUniqueID(), value);
}
}
} | java | private void processActivityCodes(APIBusinessObjects apibo, ProjectType project)
{
ActivityCodeContainer container = m_projectFile.getActivityCodes();
Map<Integer, ActivityCode> map = new HashMap<Integer, ActivityCode>();
List<ActivityCodeTypeType> types = new ArrayList<ActivityCodeTypeType>();
types.addAll(apibo.getActivityCodeType());
types.addAll(project.getActivityCodeType());
for (ActivityCodeTypeType type : types)
{
ActivityCode code = new ActivityCode(type.getObjectId(), type.getName());
container.add(code);
map.put(code.getUniqueID(), code);
}
List<ActivityCodeType> typeValues = new ArrayList<ActivityCodeType>();
typeValues.addAll(apibo.getActivityCode());
typeValues.addAll(project.getActivityCode());
for (ActivityCodeType typeValue : typeValues)
{
ActivityCode code = map.get(typeValue.getCodeTypeObjectId());
if (code != null)
{
ActivityCodeValue value = code.addValue(typeValue.getObjectId(), typeValue.getCodeValue(), typeValue.getDescription());
m_activityCodeMap.put(value.getUniqueID(), value);
}
}
} | [
"private",
"void",
"processActivityCodes",
"(",
"APIBusinessObjects",
"apibo",
",",
"ProjectType",
"project",
")",
"{",
"ActivityCodeContainer",
"container",
"=",
"m_projectFile",
".",
"getActivityCodes",
"(",
")",
";",
"Map",
"<",
"Integer",
",",
"ActivityCode",
">",
"map",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"ActivityCode",
">",
"(",
")",
";",
"List",
"<",
"ActivityCodeTypeType",
">",
"types",
"=",
"new",
"ArrayList",
"<",
"ActivityCodeTypeType",
">",
"(",
")",
";",
"types",
".",
"addAll",
"(",
"apibo",
".",
"getActivityCodeType",
"(",
")",
")",
";",
"types",
".",
"addAll",
"(",
"project",
".",
"getActivityCodeType",
"(",
")",
")",
";",
"for",
"(",
"ActivityCodeTypeType",
"type",
":",
"types",
")",
"{",
"ActivityCode",
"code",
"=",
"new",
"ActivityCode",
"(",
"type",
".",
"getObjectId",
"(",
")",
",",
"type",
".",
"getName",
"(",
")",
")",
";",
"container",
".",
"add",
"(",
"code",
")",
";",
"map",
".",
"put",
"(",
"code",
".",
"getUniqueID",
"(",
")",
",",
"code",
")",
";",
"}",
"List",
"<",
"ActivityCodeType",
">",
"typeValues",
"=",
"new",
"ArrayList",
"<",
"ActivityCodeType",
">",
"(",
")",
";",
"typeValues",
".",
"addAll",
"(",
"apibo",
".",
"getActivityCode",
"(",
")",
")",
";",
"typeValues",
".",
"addAll",
"(",
"project",
".",
"getActivityCode",
"(",
")",
")",
";",
"for",
"(",
"ActivityCodeType",
"typeValue",
":",
"typeValues",
")",
"{",
"ActivityCode",
"code",
"=",
"map",
".",
"get",
"(",
"typeValue",
".",
"getCodeTypeObjectId",
"(",
")",
")",
";",
"if",
"(",
"code",
"!=",
"null",
")",
"{",
"ActivityCodeValue",
"value",
"=",
"code",
".",
"addValue",
"(",
"typeValue",
".",
"getObjectId",
"(",
")",
",",
"typeValue",
".",
"getCodeValue",
"(",
")",
",",
"typeValue",
".",
"getDescription",
"(",
")",
")",
";",
"m_activityCodeMap",
".",
"put",
"(",
"value",
".",
"getUniqueID",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"}"
] | Process activity code data.
@param apibo global activity code data
@param project project-specific activity code data | [
"Process",
"activity",
"code",
"data",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/PrimaveraPMFileReader.java#L378-L407 |
jayantk/jklol | src/com/jayantkrish/jklol/ccg/SyntacticCategory.java | SyntacticCategory.assignAllFeatures | public SyntacticCategory assignAllFeatures(String value) {
"""
Assigns value to all unfilled feature variables.
@param value
@return
"""
Set<Integer> featureVars = Sets.newHashSet();
getAllFeatureVariables(featureVars);
Map<Integer, String> valueMap = Maps.newHashMap();
for (Integer var : featureVars) {
valueMap.put(var, value);
}
return assignFeatures(valueMap, Collections.<Integer, Integer>emptyMap());
} | java | public SyntacticCategory assignAllFeatures(String value) {
Set<Integer> featureVars = Sets.newHashSet();
getAllFeatureVariables(featureVars);
Map<Integer, String> valueMap = Maps.newHashMap();
for (Integer var : featureVars) {
valueMap.put(var, value);
}
return assignFeatures(valueMap, Collections.<Integer, Integer>emptyMap());
} | [
"public",
"SyntacticCategory",
"assignAllFeatures",
"(",
"String",
"value",
")",
"{",
"Set",
"<",
"Integer",
">",
"featureVars",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"getAllFeatureVariables",
"(",
"featureVars",
")",
";",
"Map",
"<",
"Integer",
",",
"String",
">",
"valueMap",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"Integer",
"var",
":",
"featureVars",
")",
"{",
"valueMap",
".",
"put",
"(",
"var",
",",
"value",
")",
";",
"}",
"return",
"assignFeatures",
"(",
"valueMap",
",",
"Collections",
".",
"<",
"Integer",
",",
"Integer",
">",
"emptyMap",
"(",
")",
")",
";",
"}"
] | Assigns value to all unfilled feature variables.
@param value
@return | [
"Assigns",
"value",
"to",
"all",
"unfilled",
"feature",
"variables",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/SyntacticCategory.java#L299-L308 |
EsotericSoftware/reflectasm | src/com/esotericsoftware/reflectasm/MethodAccess.java | MethodAccess.getIndex | public int getIndex (String methodName, Class... paramTypes) {
"""
Returns the index of the first method with the specified name and param types.
"""
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName) && Arrays.equals(paramTypes, parameterTypes[i])) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName + " " + Arrays.toString(paramTypes));
} | java | public int getIndex (String methodName, Class... paramTypes) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName) && Arrays.equals(paramTypes, parameterTypes[i])) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName + " " + Arrays.toString(paramTypes));
} | [
"public",
"int",
"getIndex",
"(",
"String",
"methodName",
",",
"Class",
"...",
"paramTypes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"methodNames",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"if",
"(",
"methodNames",
"[",
"i",
"]",
".",
"equals",
"(",
"methodName",
")",
"&&",
"Arrays",
".",
"equals",
"(",
"paramTypes",
",",
"parameterTypes",
"[",
"i",
"]",
")",
")",
"return",
"i",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unable to find non-private method: \"",
"+",
"methodName",
"+",
"\" \"",
"+",
"Arrays",
".",
"toString",
"(",
"paramTypes",
")",
")",
";",
"}"
] | Returns the index of the first method with the specified name and param types. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"method",
"with",
"the",
"specified",
"name",
"and",
"param",
"types",
"."
] | train | https://github.com/EsotericSoftware/reflectasm/blob/c86a421c5bec16fd82a22a39b85910568d3c7bf4/src/com/esotericsoftware/reflectasm/MethodAccess.java#L55-L59 |
udoprog/ffwd-client-java | src/main/java/com/google/protobuf250/FieldSet.java | FieldSet.computeFieldSize | public static int computeFieldSize(final FieldDescriptorLite<?> descriptor,
final Object value) {
"""
Compute the number of bytes needed to encode a particular field.
"""
WireFormat.FieldType type = descriptor.getLiteType();
int number = descriptor.getNumber();
if (descriptor.isRepeated()) {
if (descriptor.isPacked()) {
int dataSize = 0;
for (final Object element : (List<?>)value) {
dataSize += computeElementSizeNoTag(type, element);
}
return dataSize +
CodedOutputStream.computeTagSize(number) +
CodedOutputStream.computeRawVarint32Size(dataSize);
} else {
int size = 0;
for (final Object element : (List<?>)value) {
size += computeElementSize(type, number, element);
}
return size;
}
} else {
return computeElementSize(type, number, value);
}
} | java | public static int computeFieldSize(final FieldDescriptorLite<?> descriptor,
final Object value) {
WireFormat.FieldType type = descriptor.getLiteType();
int number = descriptor.getNumber();
if (descriptor.isRepeated()) {
if (descriptor.isPacked()) {
int dataSize = 0;
for (final Object element : (List<?>)value) {
dataSize += computeElementSizeNoTag(type, element);
}
return dataSize +
CodedOutputStream.computeTagSize(number) +
CodedOutputStream.computeRawVarint32Size(dataSize);
} else {
int size = 0;
for (final Object element : (List<?>)value) {
size += computeElementSize(type, number, element);
}
return size;
}
} else {
return computeElementSize(type, number, value);
}
} | [
"public",
"static",
"int",
"computeFieldSize",
"(",
"final",
"FieldDescriptorLite",
"<",
"?",
">",
"descriptor",
",",
"final",
"Object",
"value",
")",
"{",
"WireFormat",
".",
"FieldType",
"type",
"=",
"descriptor",
".",
"getLiteType",
"(",
")",
";",
"int",
"number",
"=",
"descriptor",
".",
"getNumber",
"(",
")",
";",
"if",
"(",
"descriptor",
".",
"isRepeated",
"(",
")",
")",
"{",
"if",
"(",
"descriptor",
".",
"isPacked",
"(",
")",
")",
"{",
"int",
"dataSize",
"=",
"0",
";",
"for",
"(",
"final",
"Object",
"element",
":",
"(",
"List",
"<",
"?",
">",
")",
"value",
")",
"{",
"dataSize",
"+=",
"computeElementSizeNoTag",
"(",
"type",
",",
"element",
")",
";",
"}",
"return",
"dataSize",
"+",
"CodedOutputStream",
".",
"computeTagSize",
"(",
"number",
")",
"+",
"CodedOutputStream",
".",
"computeRawVarint32Size",
"(",
"dataSize",
")",
";",
"}",
"else",
"{",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"final",
"Object",
"element",
":",
"(",
"List",
"<",
"?",
">",
")",
"value",
")",
"{",
"size",
"+=",
"computeElementSize",
"(",
"type",
",",
"number",
",",
"element",
")",
";",
"}",
"return",
"size",
";",
"}",
"}",
"else",
"{",
"return",
"computeElementSize",
"(",
"type",
",",
"number",
",",
"value",
")",
";",
"}",
"}"
] | Compute the number of bytes needed to encode a particular field. | [
"Compute",
"the",
"number",
"of",
"bytes",
"needed",
"to",
"encode",
"a",
"particular",
"field",
"."
] | train | https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/FieldSet.java#L837-L860 |
mapsforge/mapsforge | mapsforge-map-awt/src/main/java/org/mapsforge/map/awt/util/AwtUtil.java | AwtUtil.getMinimumCacheSize | public static int getMinimumCacheSize(int tileSize, double overdrawFactor) {
"""
Compute the minimum cache size for a view, using the size of the screen.
<p>
Combine with <code>FrameBufferController.setUseSquareFrameBuffer(false);</code>
@param tileSize the tile size
@param overdrawFactor the overdraw factor applied to the map view
@return the minimum cache size for the view
"""
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
return (int) Math.max(4, Math.round((2 + screenSize.getWidth() * overdrawFactor / tileSize)
* (2 + screenSize.getHeight() * overdrawFactor / tileSize)));
} | java | public static int getMinimumCacheSize(int tileSize, double overdrawFactor) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
return (int) Math.max(4, Math.round((2 + screenSize.getWidth() * overdrawFactor / tileSize)
* (2 + screenSize.getHeight() * overdrawFactor / tileSize)));
} | [
"public",
"static",
"int",
"getMinimumCacheSize",
"(",
"int",
"tileSize",
",",
"double",
"overdrawFactor",
")",
"{",
"Dimension",
"screenSize",
"=",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getScreenSize",
"(",
")",
";",
"return",
"(",
"int",
")",
"Math",
".",
"max",
"(",
"4",
",",
"Math",
".",
"round",
"(",
"(",
"2",
"+",
"screenSize",
".",
"getWidth",
"(",
")",
"*",
"overdrawFactor",
"/",
"tileSize",
")",
"*",
"(",
"2",
"+",
"screenSize",
".",
"getHeight",
"(",
")",
"*",
"overdrawFactor",
"/",
"tileSize",
")",
")",
")",
";",
"}"
] | Compute the minimum cache size for a view, using the size of the screen.
<p>
Combine with <code>FrameBufferController.setUseSquareFrameBuffer(false);</code>
@param tileSize the tile size
@param overdrawFactor the overdraw factor applied to the map view
@return the minimum cache size for the view | [
"Compute",
"the",
"minimum",
"cache",
"size",
"for",
"a",
"view",
"using",
"the",
"size",
"of",
"the",
"screen",
".",
"<p",
">",
"Combine",
"with",
"<code",
">",
"FrameBufferController",
".",
"setUseSquareFrameBuffer",
"(",
"false",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-awt/src/main/java/org/mapsforge/map/awt/util/AwtUtil.java#L56-L60 |
alkacon/opencms-core | src/org/opencms/flex/CmsFlexController.java | CmsFlexController.push | public void push(CmsFlexRequest req, CmsFlexResponse res) {
"""
Adds another flex request/response pair to the stack.<p>
@param req the request to add
@param res the response to add
"""
m_flexRequestList.add(req);
m_flexResponseList.add(res);
m_flexContextInfoList.add(new CmsFlexRequestContextInfo());
updateRequestContextInfo();
} | java | public void push(CmsFlexRequest req, CmsFlexResponse res) {
m_flexRequestList.add(req);
m_flexResponseList.add(res);
m_flexContextInfoList.add(new CmsFlexRequestContextInfo());
updateRequestContextInfo();
} | [
"public",
"void",
"push",
"(",
"CmsFlexRequest",
"req",
",",
"CmsFlexResponse",
"res",
")",
"{",
"m_flexRequestList",
".",
"add",
"(",
"req",
")",
";",
"m_flexResponseList",
".",
"add",
"(",
"res",
")",
";",
"m_flexContextInfoList",
".",
"add",
"(",
"new",
"CmsFlexRequestContextInfo",
"(",
")",
")",
";",
"updateRequestContextInfo",
"(",
")",
";",
"}"
] | Adds another flex request/response pair to the stack.<p>
@param req the request to add
@param res the response to add | [
"Adds",
"another",
"flex",
"request",
"/",
"response",
"pair",
"to",
"the",
"stack",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/flex/CmsFlexController.java#L617-L623 |
intellimate/Izou | src/main/java/org/intellimate/izou/security/FilePermissionModule.java | FilePermissionModule.checkPermission | @Override
public void checkPermission(Permission permission, AddOnModel addon) throws IzouPermissionException {
"""
Checks if the given addOn is allowed to access the requested service and registers them if not yet registered.
@param permission the Permission to check
@param addon the identifiable to check
@throws IzouPermissionException thrown if the addOn is not allowed to access its requested service
"""
String canonicalName = permission.getName().intern().toLowerCase();
String canonicalAction = permission.getActions().intern().toLowerCase();
if (canonicalName.contains("all files") || canonicalAction.equals("execute")) {
throw getException(permission.getName());
}
if (canonicalAction.equals("read")) {
fileReadCheck(canonicalName);
}
fileWriteCheck(canonicalName, addon);
} | java | @Override
public void checkPermission(Permission permission, AddOnModel addon) throws IzouPermissionException {
String canonicalName = permission.getName().intern().toLowerCase();
String canonicalAction = permission.getActions().intern().toLowerCase();
if (canonicalName.contains("all files") || canonicalAction.equals("execute")) {
throw getException(permission.getName());
}
if (canonicalAction.equals("read")) {
fileReadCheck(canonicalName);
}
fileWriteCheck(canonicalName, addon);
} | [
"@",
"Override",
"public",
"void",
"checkPermission",
"(",
"Permission",
"permission",
",",
"AddOnModel",
"addon",
")",
"throws",
"IzouPermissionException",
"{",
"String",
"canonicalName",
"=",
"permission",
".",
"getName",
"(",
")",
".",
"intern",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"String",
"canonicalAction",
"=",
"permission",
".",
"getActions",
"(",
")",
".",
"intern",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"canonicalName",
".",
"contains",
"(",
"\"all files\"",
")",
"||",
"canonicalAction",
".",
"equals",
"(",
"\"execute\"",
")",
")",
"{",
"throw",
"getException",
"(",
"permission",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"canonicalAction",
".",
"equals",
"(",
"\"read\"",
")",
")",
"{",
"fileReadCheck",
"(",
"canonicalName",
")",
";",
"}",
"fileWriteCheck",
"(",
"canonicalName",
",",
"addon",
")",
";",
"}"
] | Checks if the given addOn is allowed to access the requested service and registers them if not yet registered.
@param permission the Permission to check
@param addon the identifiable to check
@throws IzouPermissionException thrown if the addOn is not allowed to access its requested service | [
"Checks",
"if",
"the",
"given",
"addOn",
"is",
"allowed",
"to",
"access",
"the",
"requested",
"service",
"and",
"registers",
"them",
"if",
"not",
"yet",
"registered",
"."
] | train | https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/security/FilePermissionModule.java#L76-L88 |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.printQuery | public QueryResult printQuery( Session session,
String jcrSql2 ) throws RepositoryException {
"""
Execute the supplied JCR-SQL2 query and, if printing is enabled, print out the results.
@param session the session
@param jcrSql2 the JCR-SQL2 query
@return the results
@throws RepositoryException
"""
return printQuery(session, jcrSql2, Query.JCR_SQL2, -1, null);
} | java | public QueryResult printQuery( Session session,
String jcrSql2 ) throws RepositoryException {
return printQuery(session, jcrSql2, Query.JCR_SQL2, -1, null);
} | [
"public",
"QueryResult",
"printQuery",
"(",
"Session",
"session",
",",
"String",
"jcrSql2",
")",
"throws",
"RepositoryException",
"{",
"return",
"printQuery",
"(",
"session",
",",
"jcrSql2",
",",
"Query",
".",
"JCR_SQL2",
",",
"-",
"1",
",",
"null",
")",
";",
"}"
] | Execute the supplied JCR-SQL2 query and, if printing is enabled, print out the results.
@param session the session
@param jcrSql2 the JCR-SQL2 query
@return the results
@throws RepositoryException | [
"Execute",
"the",
"supplied",
"JCR",
"-",
"SQL2",
"query",
"and",
"if",
"printing",
"is",
"enabled",
"print",
"out",
"the",
"results",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L627-L630 |
ironjacamar/ironjacamar | core/src/main/java/org/ironjacamar/core/connectionmanager/ccm/Context.java | Context.removeConnectionListener | void removeConnectionListener(ConnectionManager cm, ConnectionListener cl) {
"""
Remove a connection listener
@param cm The connection manager
@param cl The connection listener
"""
if (cmToCl != null && cmToCl.get(cm) != null)
{
cmToCl.get(cm).remove(cl);
clToC.remove(cl);
}
} | java | void removeConnectionListener(ConnectionManager cm, ConnectionListener cl)
{
if (cmToCl != null && cmToCl.get(cm) != null)
{
cmToCl.get(cm).remove(cl);
clToC.remove(cl);
}
} | [
"void",
"removeConnectionListener",
"(",
"ConnectionManager",
"cm",
",",
"ConnectionListener",
"cl",
")",
"{",
"if",
"(",
"cmToCl",
"!=",
"null",
"&&",
"cmToCl",
".",
"get",
"(",
"cm",
")",
"!=",
"null",
")",
"{",
"cmToCl",
".",
"get",
"(",
"cm",
")",
".",
"remove",
"(",
"cl",
")",
";",
"clToC",
".",
"remove",
"(",
"cl",
")",
";",
"}",
"}"
] | Remove a connection listener
@param cm The connection manager
@param cl The connection listener | [
"Remove",
"a",
"connection",
"listener"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/core/src/main/java/org/ironjacamar/core/connectionmanager/ccm/Context.java#L178-L185 |
carewebframework/carewebframework-core | org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.core/src/main/java/org/carewebframework/maven/plugin/core/BaseMojo.java | BaseMojo.throwMojoException | public void throwMojoException(String msg, Throwable e) throws MojoExecutionException {
"""
If "failOnError" is enabled, throws a MojoExecutionException. Otherwise, logs the exception
and resumes execution.
@param msg The exception message.
@param e The original exceptions.
@throws MojoExecutionException Thrown exception.
"""
if (failOnError) {
throw new MojoExecutionException(msg, e);
} else {
getLog().error(msg, e);
}
} | java | public void throwMojoException(String msg, Throwable e) throws MojoExecutionException {
if (failOnError) {
throw new MojoExecutionException(msg, e);
} else {
getLog().error(msg, e);
}
} | [
"public",
"void",
"throwMojoException",
"(",
"String",
"msg",
",",
"Throwable",
"e",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"failOnError",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"error",
"(",
"msg",
",",
"e",
")",
";",
"}",
"}"
] | If "failOnError" is enabled, throws a MojoExecutionException. Otherwise, logs the exception
and resumes execution.
@param msg The exception message.
@param e The original exceptions.
@throws MojoExecutionException Thrown exception. | [
"If",
"failOnError",
"is",
"enabled",
"throws",
"a",
"MojoExecutionException",
".",
"Otherwise",
"logs",
"the",
"exception",
"and",
"resumes",
"execution",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.core/src/main/java/org/carewebframework/maven/plugin/core/BaseMojo.java#L256-L262 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java | EnumConstantBuilder.buildDeprecationInfo | public void buildDeprecationInfo(XMLNode node, Content enumConstantsTree) {
"""
Build the deprecation information.
@param node the XML element that specifies which components to document
@param enumConstantsTree the content tree to which the documentation will be added
"""
writer.addDeprecated(
(FieldDoc) enumConstants.get(currentEnumConstantsIndex),
enumConstantsTree);
} | java | public void buildDeprecationInfo(XMLNode node, Content enumConstantsTree) {
writer.addDeprecated(
(FieldDoc) enumConstants.get(currentEnumConstantsIndex),
enumConstantsTree);
} | [
"public",
"void",
"buildDeprecationInfo",
"(",
"XMLNode",
"node",
",",
"Content",
"enumConstantsTree",
")",
"{",
"writer",
".",
"addDeprecated",
"(",
"(",
"FieldDoc",
")",
"enumConstants",
".",
"get",
"(",
"currentEnumConstantsIndex",
")",
",",
"enumConstantsTree",
")",
";",
"}"
] | Build the deprecation information.
@param node the XML element that specifies which components to document
@param enumConstantsTree the content tree to which the documentation will be added | [
"Build",
"the",
"deprecation",
"information",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java#L190-L194 |
windup/windup | reporting/api/src/main/java/org/jboss/windup/reporting/service/TechnologyTagService.java | TechnologyTagService.addTagToFileModel | public TechnologyTagModel addTagToFileModel(FileModel fileModel, String tagName, TechnologyTagLevel level) {
"""
Adds the provided tag to the provided {@link FileModel}. If a {@link TechnologyTagModel} cannot be found with the provided name, then one will
be created.
"""
Traversable<Vertex, Vertex> q = getGraphContext().getQuery(TechnologyTagModel.class)
.traverse(g -> g.has(TechnologyTagModel.NAME, tagName));
TechnologyTagModel technologyTag = super.getUnique(q.getRawTraversal());
if (technologyTag == null)
{
technologyTag = create();
technologyTag.setName(tagName);
technologyTag.setLevel(level);
}
if (level == TechnologyTagLevel.IMPORTANT && fileModel instanceof SourceFileModel)
((SourceFileModel) fileModel).setGenerateSourceReport(true);
technologyTag.addFileModel(fileModel);
return technologyTag;
} | java | public TechnologyTagModel addTagToFileModel(FileModel fileModel, String tagName, TechnologyTagLevel level)
{
Traversable<Vertex, Vertex> q = getGraphContext().getQuery(TechnologyTagModel.class)
.traverse(g -> g.has(TechnologyTagModel.NAME, tagName));
TechnologyTagModel technologyTag = super.getUnique(q.getRawTraversal());
if (technologyTag == null)
{
technologyTag = create();
technologyTag.setName(tagName);
technologyTag.setLevel(level);
}
if (level == TechnologyTagLevel.IMPORTANT && fileModel instanceof SourceFileModel)
((SourceFileModel) fileModel).setGenerateSourceReport(true);
technologyTag.addFileModel(fileModel);
return technologyTag;
} | [
"public",
"TechnologyTagModel",
"addTagToFileModel",
"(",
"FileModel",
"fileModel",
",",
"String",
"tagName",
",",
"TechnologyTagLevel",
"level",
")",
"{",
"Traversable",
"<",
"Vertex",
",",
"Vertex",
">",
"q",
"=",
"getGraphContext",
"(",
")",
".",
"getQuery",
"(",
"TechnologyTagModel",
".",
"class",
")",
".",
"traverse",
"(",
"g",
"->",
"g",
".",
"has",
"(",
"TechnologyTagModel",
".",
"NAME",
",",
"tagName",
")",
")",
";",
"TechnologyTagModel",
"technologyTag",
"=",
"super",
".",
"getUnique",
"(",
"q",
".",
"getRawTraversal",
"(",
")",
")",
";",
"if",
"(",
"technologyTag",
"==",
"null",
")",
"{",
"technologyTag",
"=",
"create",
"(",
")",
";",
"technologyTag",
".",
"setName",
"(",
"tagName",
")",
";",
"technologyTag",
".",
"setLevel",
"(",
"level",
")",
";",
"}",
"if",
"(",
"level",
"==",
"TechnologyTagLevel",
".",
"IMPORTANT",
"&&",
"fileModel",
"instanceof",
"SourceFileModel",
")",
"(",
"(",
"SourceFileModel",
")",
"fileModel",
")",
".",
"setGenerateSourceReport",
"(",
"true",
")",
";",
"technologyTag",
".",
"addFileModel",
"(",
"fileModel",
")",
";",
"return",
"technologyTag",
";",
"}"
] | Adds the provided tag to the provided {@link FileModel}. If a {@link TechnologyTagModel} cannot be found with the provided name, then one will
be created. | [
"Adds",
"the",
"provided",
"tag",
"to",
"the",
"provided",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/TechnologyTagService.java#L44-L60 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.invokeMethod | public static Object invokeMethod(Object object, String method, Object arguments) {
"""
Provide a dynamic method invocation method which can be overloaded in
classes to implement dynamic proxies easily.
@param object any Object
@param method the name of the method to call
@param arguments the arguments to use
@return the result of the method call
@since 1.0
"""
return InvokerHelper.invokeMethod(object, method, arguments);
} | java | public static Object invokeMethod(Object object, String method, Object arguments) {
return InvokerHelper.invokeMethod(object, method, arguments);
} | [
"public",
"static",
"Object",
"invokeMethod",
"(",
"Object",
"object",
",",
"String",
"method",
",",
"Object",
"arguments",
")",
"{",
"return",
"InvokerHelper",
".",
"invokeMethod",
"(",
"object",
",",
"method",
",",
"arguments",
")",
";",
"}"
] | Provide a dynamic method invocation method which can be overloaded in
classes to implement dynamic proxies easily.
@param object any Object
@param method the name of the method to call
@param arguments the arguments to use
@return the result of the method call
@since 1.0 | [
"Provide",
"a",
"dynamic",
"method",
"invocation",
"method",
"which",
"can",
"be",
"overloaded",
"in",
"classes",
"to",
"implement",
"dynamic",
"proxies",
"easily",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1088-L1090 |
Impetus/Kundera | src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBSchemaManager.java | CouchDBSchemaManager.createViewForSelectAll | private void createViewForSelectAll(TableInfo tableInfo, Map<String, MapReduce> views) {
"""
Creates the view for select all.
@param tableInfo
the table info
@param views
the views
"""
MapReduce mapr = new MapReduce();
mapr.setMap("function(doc){if(doc." + tableInfo.getIdColumnName() + "){emit(null, doc);}}");
views.put("all", mapr);
} | java | private void createViewForSelectAll(TableInfo tableInfo, Map<String, MapReduce> views)
{
MapReduce mapr = new MapReduce();
mapr.setMap("function(doc){if(doc." + tableInfo.getIdColumnName() + "){emit(null, doc);}}");
views.put("all", mapr);
} | [
"private",
"void",
"createViewForSelectAll",
"(",
"TableInfo",
"tableInfo",
",",
"Map",
"<",
"String",
",",
"MapReduce",
">",
"views",
")",
"{",
"MapReduce",
"mapr",
"=",
"new",
"MapReduce",
"(",
")",
";",
"mapr",
".",
"setMap",
"(",
"\"function(doc){if(doc.\"",
"+",
"tableInfo",
".",
"getIdColumnName",
"(",
")",
"+",
"\"){emit(null, doc);}}\"",
")",
";",
"views",
".",
"put",
"(",
"\"all\"",
",",
"mapr",
")",
";",
"}"
] | Creates the view for select all.
@param tableInfo
the table info
@param views
the views | [
"Creates",
"the",
"view",
"for",
"select",
"all",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBSchemaManager.java#L658-L663 |
junit-team/junit4 | src/main/java/org/junit/runners/model/FrameworkMethod.java | FrameworkMethod.validatePublicVoidNoArg | public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors) {
"""
Adds to {@code errors} if this method:
<ul>
<li>is not public, or
<li>takes parameters, or
<li>returns something other than void, or
<li>is static (given {@code isStatic is false}), or
<li>is not static (given {@code isStatic is true}).
</ul>
"""
validatePublicVoid(isStatic, errors);
if (method.getParameterTypes().length != 0) {
errors.add(new Exception("Method " + method.getName() + " should have no parameters"));
}
} | java | public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors) {
validatePublicVoid(isStatic, errors);
if (method.getParameterTypes().length != 0) {
errors.add(new Exception("Method " + method.getName() + " should have no parameters"));
}
} | [
"public",
"void",
"validatePublicVoidNoArg",
"(",
"boolean",
"isStatic",
",",
"List",
"<",
"Throwable",
">",
"errors",
")",
"{",
"validatePublicVoid",
"(",
"isStatic",
",",
"errors",
")",
";",
"if",
"(",
"method",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"!=",
"0",
")",
"{",
"errors",
".",
"add",
"(",
"new",
"Exception",
"(",
"\"Method \"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\" should have no parameters\"",
")",
")",
";",
"}",
"}"
] | Adds to {@code errors} if this method:
<ul>
<li>is not public, or
<li>takes parameters, or
<li>returns something other than void, or
<li>is static (given {@code isStatic is false}), or
<li>is not static (given {@code isStatic is true}).
</ul> | [
"Adds",
"to",
"{"
] | train | https://github.com/junit-team/junit4/blob/d9861ecdb6e487f6c352437ee823879aca3b81d4/src/main/java/org/junit/runners/model/FrameworkMethod.java#L82-L87 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/installed/DefaultInstalledExtensionRepository.java | DefaultInstalledExtensionRepository.applyInstallExtension | private void applyInstallExtension(DefaultInstalledExtension installedExtension, String namespace,
boolean dependency, Map<String, Object> properties, Map<String, ExtensionDependency> managedDependencies)
throws InstallException {
"""
Install provided extension.
@param localExtension the extension to install
@param namespace the namespace
@param dependency indicate if the extension is stored as a dependency of another one
@param properties the custom properties to set on the installed extension for the specified namespace
@param managedDependencies the managed dependencies
@throws InstallException error when trying to uninstall extension
@see #installExtension(LocalExtension, String)
"""
// INSTALLED
installedExtension.setInstalled(true, namespace);
installedExtension.setInstallDate(new Date(), namespace);
// DEPENDENCY
installedExtension.setDependency(dependency, namespace);
// Add custom install properties for the specified namespace. The map holding the namespace properties should
// not be null because it is initialized by the InstalledExtension#setInstalled(true, namespace) call above.
installedExtension.getNamespaceProperties(namespace).putAll(properties);
// Save properties
try {
this.localRepository.setProperties(installedExtension.getLocalExtension(),
installedExtension.getProperties());
} catch (Exception e) {
throw new InstallException("Failed to modify extension descriptor", e);
}
// VALID
installedExtension.setValid(namespace, isValid(installedExtension, namespace, managedDependencies));
// Update caches
addInstalledExtension(installedExtension, namespace);
} | java | private void applyInstallExtension(DefaultInstalledExtension installedExtension, String namespace,
boolean dependency, Map<String, Object> properties, Map<String, ExtensionDependency> managedDependencies)
throws InstallException
{
// INSTALLED
installedExtension.setInstalled(true, namespace);
installedExtension.setInstallDate(new Date(), namespace);
// DEPENDENCY
installedExtension.setDependency(dependency, namespace);
// Add custom install properties for the specified namespace. The map holding the namespace properties should
// not be null because it is initialized by the InstalledExtension#setInstalled(true, namespace) call above.
installedExtension.getNamespaceProperties(namespace).putAll(properties);
// Save properties
try {
this.localRepository.setProperties(installedExtension.getLocalExtension(),
installedExtension.getProperties());
} catch (Exception e) {
throw new InstallException("Failed to modify extension descriptor", e);
}
// VALID
installedExtension.setValid(namespace, isValid(installedExtension, namespace, managedDependencies));
// Update caches
addInstalledExtension(installedExtension, namespace);
} | [
"private",
"void",
"applyInstallExtension",
"(",
"DefaultInstalledExtension",
"installedExtension",
",",
"String",
"namespace",
",",
"boolean",
"dependency",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
",",
"Map",
"<",
"String",
",",
"ExtensionDependency",
">",
"managedDependencies",
")",
"throws",
"InstallException",
"{",
"// INSTALLED",
"installedExtension",
".",
"setInstalled",
"(",
"true",
",",
"namespace",
")",
";",
"installedExtension",
".",
"setInstallDate",
"(",
"new",
"Date",
"(",
")",
",",
"namespace",
")",
";",
"// DEPENDENCY",
"installedExtension",
".",
"setDependency",
"(",
"dependency",
",",
"namespace",
")",
";",
"// Add custom install properties for the specified namespace. The map holding the namespace properties should",
"// not be null because it is initialized by the InstalledExtension#setInstalled(true, namespace) call above.",
"installedExtension",
".",
"getNamespaceProperties",
"(",
"namespace",
")",
".",
"putAll",
"(",
"properties",
")",
";",
"// Save properties",
"try",
"{",
"this",
".",
"localRepository",
".",
"setProperties",
"(",
"installedExtension",
".",
"getLocalExtension",
"(",
")",
",",
"installedExtension",
".",
"getProperties",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"InstallException",
"(",
"\"Failed to modify extension descriptor\"",
",",
"e",
")",
";",
"}",
"// VALID",
"installedExtension",
".",
"setValid",
"(",
"namespace",
",",
"isValid",
"(",
"installedExtension",
",",
"namespace",
",",
"managedDependencies",
")",
")",
";",
"// Update caches",
"addInstalledExtension",
"(",
"installedExtension",
",",
"namespace",
")",
";",
"}"
] | Install provided extension.
@param localExtension the extension to install
@param namespace the namespace
@param dependency indicate if the extension is stored as a dependency of another one
@param properties the custom properties to set on the installed extension for the specified namespace
@param managedDependencies the managed dependencies
@throws InstallException error when trying to uninstall extension
@see #installExtension(LocalExtension, String) | [
"Install",
"provided",
"extension",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/installed/DefaultInstalledExtensionRepository.java#L476-L505 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/websphere/servlet/filter/ChainedResponse.java | ChainedResponse.setAutoTransferringHeader | @SuppressWarnings("unchecked")
public void setAutoTransferringHeader(String name, String value) {
"""
Set a header that should be automatically transferred to all requests
in a chain. These headers will be backed up in a request attribute that
will automatically read and transferred by all ChainedResponses. This method
is useful for transparently transferring the original headers sent by the client
without forcing servlets to be specially written to transfer these headers.
"""
Hashtable headers = getAutoTransferringHeaders();
headers.put(name, value);
// setHeader(name, value);
} | java | @SuppressWarnings("unchecked")
public void setAutoTransferringHeader(String name, String value)
{
Hashtable headers = getAutoTransferringHeaders();
headers.put(name, value);
// setHeader(name, value);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"setAutoTransferringHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Hashtable",
"headers",
"=",
"getAutoTransferringHeaders",
"(",
")",
";",
"headers",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"// setHeader(name, value);",
"}"
] | Set a header that should be automatically transferred to all requests
in a chain. These headers will be backed up in a request attribute that
will automatically read and transferred by all ChainedResponses. This method
is useful for transparently transferring the original headers sent by the client
without forcing servlets to be specially written to transfer these headers. | [
"Set",
"a",
"header",
"that",
"should",
"be",
"automatically",
"transferred",
"to",
"all",
"requests",
"in",
"a",
"chain",
".",
"These",
"headers",
"will",
"be",
"backed",
"up",
"in",
"a",
"request",
"attribute",
"that",
"will",
"automatically",
"read",
"and",
"transferred",
"by",
"all",
"ChainedResponses",
".",
"This",
"method",
"is",
"useful",
"for",
"transparently",
"transferring",
"the",
"original",
"headers",
"sent",
"by",
"the",
"client",
"without",
"forcing",
"servlets",
"to",
"be",
"specially",
"written",
"to",
"transfer",
"these",
"headers",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/websphere/servlet/filter/ChainedResponse.java#L123-L129 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/commerce/orders/ExtendedPropertyUrl.java | ExtendedPropertyUrl.deleteExtendedPropertyUrl | public static MozuUrl deleteExtendedPropertyUrl(String key, String orderId, String updateMode, String version) {
"""
Get Resource Url for DeleteExtendedProperty
@param key The extended property key.
@param orderId Unique identifier of the order.
@param updateMode Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
@param version Determines whether or not to check versioning of items for concurrency purposes.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}");
formatter.formatUrl("key", key);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("updateMode", updateMode);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl deleteExtendedPropertyUrl(String key, String orderId, String updateMode, String version)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}");
formatter.formatUrl("key", key);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("updateMode", updateMode);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"deleteExtendedPropertyUrl",
"(",
"String",
"key",
",",
"String",
"orderId",
",",
"String",
"updateMode",
",",
"String",
"version",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"key\"",
",",
"key",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"orderId\"",
",",
"orderId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"updateMode\"",
",",
"updateMode",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"version\"",
",",
"version",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for DeleteExtendedProperty
@param key The extended property key.
@param orderId Unique identifier of the order.
@param updateMode Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
@param version Determines whether or not to check versioning of items for concurrency purposes.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"DeleteExtendedProperty"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/orders/ExtendedPropertyUrl.java#L96-L104 |
orbisgis/h2gis | h2gis-utilities/src/main/java/org/h2gis/utilities/TableUtilities.java | TableUtilities.copyFields | public static void copyFields(Connection connection, SimpleResultSet rs, TableLocation tableLocation) throws SQLException {
"""
Copy fields from table into a {@link org.h2.tools.SimpleResultSet}
@param connection Active connection
@param rs Result set that will receive columns
@param tableLocation Import columns from this table
@throws SQLException Error
"""
DatabaseMetaData meta = connection.getMetaData();
ResultSet columnsRs = meta.getColumns(tableLocation.getCatalog(null), tableLocation.getSchema(null),
tableLocation.getTable(), null);
Map<Integer, Object[]> columns = new HashMap<Integer, Object[]>();
int COLUMN_NAME = 0, COLUMN_TYPE = 1, COLUMN_TYPENAME = 2, COLUMN_PRECISION = 3, COLUMN_SCALE = 4;
try {
while (columnsRs.next()) {
Object[] columnInfoObjects = new Object[COLUMN_SCALE + 1];
columnInfoObjects[COLUMN_NAME] = columnsRs.getString("COLUMN_NAME");
columnInfoObjects[COLUMN_TYPE] = columnsRs.getInt("DATA_TYPE");
columnInfoObjects[COLUMN_TYPENAME] = columnsRs.getString("TYPE_NAME");
columnInfoObjects[COLUMN_PRECISION] = columnsRs.getInt("COLUMN_SIZE");
columnInfoObjects[COLUMN_SCALE] = columnsRs.getInt("DECIMAL_DIGITS");
columns.put(columnsRs.getInt("ORDINAL_POSITION"), columnInfoObjects);
}
} finally {
columnsRs.close();
}
for(int i=1;i<=columns.size();i++) {
Object[] columnInfoObjects = columns.get(i);
rs.addColumn((String)columnInfoObjects[COLUMN_NAME], (Integer)columnInfoObjects[COLUMN_TYPE],
(String)columnInfoObjects[COLUMN_TYPENAME], (Integer)columnInfoObjects[COLUMN_PRECISION]
, (Integer)columnInfoObjects[COLUMN_SCALE]);
}
} | java | public static void copyFields(Connection connection, SimpleResultSet rs, TableLocation tableLocation) throws SQLException {
DatabaseMetaData meta = connection.getMetaData();
ResultSet columnsRs = meta.getColumns(tableLocation.getCatalog(null), tableLocation.getSchema(null),
tableLocation.getTable(), null);
Map<Integer, Object[]> columns = new HashMap<Integer, Object[]>();
int COLUMN_NAME = 0, COLUMN_TYPE = 1, COLUMN_TYPENAME = 2, COLUMN_PRECISION = 3, COLUMN_SCALE = 4;
try {
while (columnsRs.next()) {
Object[] columnInfoObjects = new Object[COLUMN_SCALE + 1];
columnInfoObjects[COLUMN_NAME] = columnsRs.getString("COLUMN_NAME");
columnInfoObjects[COLUMN_TYPE] = columnsRs.getInt("DATA_TYPE");
columnInfoObjects[COLUMN_TYPENAME] = columnsRs.getString("TYPE_NAME");
columnInfoObjects[COLUMN_PRECISION] = columnsRs.getInt("COLUMN_SIZE");
columnInfoObjects[COLUMN_SCALE] = columnsRs.getInt("DECIMAL_DIGITS");
columns.put(columnsRs.getInt("ORDINAL_POSITION"), columnInfoObjects);
}
} finally {
columnsRs.close();
}
for(int i=1;i<=columns.size();i++) {
Object[] columnInfoObjects = columns.get(i);
rs.addColumn((String)columnInfoObjects[COLUMN_NAME], (Integer)columnInfoObjects[COLUMN_TYPE],
(String)columnInfoObjects[COLUMN_TYPENAME], (Integer)columnInfoObjects[COLUMN_PRECISION]
, (Integer)columnInfoObjects[COLUMN_SCALE]);
}
} | [
"public",
"static",
"void",
"copyFields",
"(",
"Connection",
"connection",
",",
"SimpleResultSet",
"rs",
",",
"TableLocation",
"tableLocation",
")",
"throws",
"SQLException",
"{",
"DatabaseMetaData",
"meta",
"=",
"connection",
".",
"getMetaData",
"(",
")",
";",
"ResultSet",
"columnsRs",
"=",
"meta",
".",
"getColumns",
"(",
"tableLocation",
".",
"getCatalog",
"(",
"null",
")",
",",
"tableLocation",
".",
"getSchema",
"(",
"null",
")",
",",
"tableLocation",
".",
"getTable",
"(",
")",
",",
"null",
")",
";",
"Map",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"columns",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"(",
")",
";",
"int",
"COLUMN_NAME",
"=",
"0",
",",
"COLUMN_TYPE",
"=",
"1",
",",
"COLUMN_TYPENAME",
"=",
"2",
",",
"COLUMN_PRECISION",
"=",
"3",
",",
"COLUMN_SCALE",
"=",
"4",
";",
"try",
"{",
"while",
"(",
"columnsRs",
".",
"next",
"(",
")",
")",
"{",
"Object",
"[",
"]",
"columnInfoObjects",
"=",
"new",
"Object",
"[",
"COLUMN_SCALE",
"+",
"1",
"]",
";",
"columnInfoObjects",
"[",
"COLUMN_NAME",
"]",
"=",
"columnsRs",
".",
"getString",
"(",
"\"COLUMN_NAME\"",
")",
";",
"columnInfoObjects",
"[",
"COLUMN_TYPE",
"]",
"=",
"columnsRs",
".",
"getInt",
"(",
"\"DATA_TYPE\"",
")",
";",
"columnInfoObjects",
"[",
"COLUMN_TYPENAME",
"]",
"=",
"columnsRs",
".",
"getString",
"(",
"\"TYPE_NAME\"",
")",
";",
"columnInfoObjects",
"[",
"COLUMN_PRECISION",
"]",
"=",
"columnsRs",
".",
"getInt",
"(",
"\"COLUMN_SIZE\"",
")",
";",
"columnInfoObjects",
"[",
"COLUMN_SCALE",
"]",
"=",
"columnsRs",
".",
"getInt",
"(",
"\"DECIMAL_DIGITS\"",
")",
";",
"columns",
".",
"put",
"(",
"columnsRs",
".",
"getInt",
"(",
"\"ORDINAL_POSITION\"",
")",
",",
"columnInfoObjects",
")",
";",
"}",
"}",
"finally",
"{",
"columnsRs",
".",
"close",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"columns",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Object",
"[",
"]",
"columnInfoObjects",
"=",
"columns",
".",
"get",
"(",
"i",
")",
";",
"rs",
".",
"addColumn",
"(",
"(",
"String",
")",
"columnInfoObjects",
"[",
"COLUMN_NAME",
"]",
",",
"(",
"Integer",
")",
"columnInfoObjects",
"[",
"COLUMN_TYPE",
"]",
",",
"(",
"String",
")",
"columnInfoObjects",
"[",
"COLUMN_TYPENAME",
"]",
",",
"(",
"Integer",
")",
"columnInfoObjects",
"[",
"COLUMN_PRECISION",
"]",
",",
"(",
"Integer",
")",
"columnInfoObjects",
"[",
"COLUMN_SCALE",
"]",
")",
";",
"}",
"}"
] | Copy fields from table into a {@link org.h2.tools.SimpleResultSet}
@param connection Active connection
@param rs Result set that will receive columns
@param tableLocation Import columns from this table
@throws SQLException Error | [
"Copy",
"fields",
"from",
"table",
"into",
"a",
"{",
"@link",
"org",
".",
"h2",
".",
"tools",
".",
"SimpleResultSet",
"}"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/TableUtilities.java#L53-L78 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java | HashtableOnDisk.getHtindex | long getHtindex(int index, int tableid) {
"""
************************************************************************
Retrieve the object pointer from the table. If we are in the process of
doubling, this method finds the correct table to update (since there are
two tables active during the doubling process).
***********************************************************************
"""
if (tableid == header.currentTableId()) {
return htindex[index];
} else {
return new_htindex[index];
}
} | java | long getHtindex(int index, int tableid) {
if (tableid == header.currentTableId()) {
return htindex[index];
} else {
return new_htindex[index];
}
} | [
"long",
"getHtindex",
"(",
"int",
"index",
",",
"int",
"tableid",
")",
"{",
"if",
"(",
"tableid",
"==",
"header",
".",
"currentTableId",
"(",
")",
")",
"{",
"return",
"htindex",
"[",
"index",
"]",
";",
"}",
"else",
"{",
"return",
"new_htindex",
"[",
"index",
"]",
";",
"}",
"}"
] | ************************************************************************
Retrieve the object pointer from the table. If we are in the process of
doubling, this method finds the correct table to update (since there are
two tables active during the doubling process).
*********************************************************************** | [
"************************************************************************",
"Retrieve",
"the",
"object",
"pointer",
"from",
"the",
"table",
".",
"If",
"we",
"are",
"in",
"the",
"process",
"of",
"doubling",
"this",
"method",
"finds",
"the",
"correct",
"table",
"to",
"update",
"(",
"since",
"there",
"are",
"two",
"tables",
"active",
"during",
"the",
"doubling",
"process",
")",
".",
"***********************************************************************"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java#L1447-L1453 |
apache/spark | common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java | ExternalShuffleBlockResolver.registerExecutor | public void registerExecutor(
String appId,
String execId,
ExecutorShuffleInfo executorInfo) {
"""
Registers a new Executor with all the configuration we need to find its shuffle files.
"""
AppExecId fullId = new AppExecId(appId, execId);
logger.info("Registered executor {} with {}", fullId, executorInfo);
if (!knownManagers.contains(executorInfo.shuffleManager)) {
throw new UnsupportedOperationException(
"Unsupported shuffle manager of executor: " + executorInfo);
}
try {
if (db != null) {
byte[] key = dbAppExecKey(fullId);
byte[] value = mapper.writeValueAsString(executorInfo).getBytes(StandardCharsets.UTF_8);
db.put(key, value);
}
} catch (Exception e) {
logger.error("Error saving registered executors", e);
}
executors.put(fullId, executorInfo);
} | java | public void registerExecutor(
String appId,
String execId,
ExecutorShuffleInfo executorInfo) {
AppExecId fullId = new AppExecId(appId, execId);
logger.info("Registered executor {} with {}", fullId, executorInfo);
if (!knownManagers.contains(executorInfo.shuffleManager)) {
throw new UnsupportedOperationException(
"Unsupported shuffle manager of executor: " + executorInfo);
}
try {
if (db != null) {
byte[] key = dbAppExecKey(fullId);
byte[] value = mapper.writeValueAsString(executorInfo).getBytes(StandardCharsets.UTF_8);
db.put(key, value);
}
} catch (Exception e) {
logger.error("Error saving registered executors", e);
}
executors.put(fullId, executorInfo);
} | [
"public",
"void",
"registerExecutor",
"(",
"String",
"appId",
",",
"String",
"execId",
",",
"ExecutorShuffleInfo",
"executorInfo",
")",
"{",
"AppExecId",
"fullId",
"=",
"new",
"AppExecId",
"(",
"appId",
",",
"execId",
")",
";",
"logger",
".",
"info",
"(",
"\"Registered executor {} with {}\"",
",",
"fullId",
",",
"executorInfo",
")",
";",
"if",
"(",
"!",
"knownManagers",
".",
"contains",
"(",
"executorInfo",
".",
"shuffleManager",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Unsupported shuffle manager of executor: \"",
"+",
"executorInfo",
")",
";",
"}",
"try",
"{",
"if",
"(",
"db",
"!=",
"null",
")",
"{",
"byte",
"[",
"]",
"key",
"=",
"dbAppExecKey",
"(",
"fullId",
")",
";",
"byte",
"[",
"]",
"value",
"=",
"mapper",
".",
"writeValueAsString",
"(",
"executorInfo",
")",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"db",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error saving registered executors\"",
",",
"e",
")",
";",
"}",
"executors",
".",
"put",
"(",
"fullId",
",",
"executorInfo",
")",
";",
"}"
] | Registers a new Executor with all the configuration we need to find its shuffle files. | [
"Registers",
"a",
"new",
"Executor",
"with",
"all",
"the",
"configuration",
"we",
"need",
"to",
"find",
"its",
"shuffle",
"files",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java#L142-L162 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/utils/H2DBLock.java | H2DBLock.readLockFile | private String readLockFile() {
"""
Reads the first line from the lock file and returns the results as a
string.
@return the first line from the lock file; or null if the contents could
not be read
"""
String msg = null;
try (RandomAccessFile f = new RandomAccessFile(lockFile, "rw")) {
msg = f.readLine();
} catch (IOException ex) {
LOGGER.debug(String.format("Error reading lock file: %s", lockFile), ex);
}
return msg;
} | java | private String readLockFile() {
String msg = null;
try (RandomAccessFile f = new RandomAccessFile(lockFile, "rw")) {
msg = f.readLine();
} catch (IOException ex) {
LOGGER.debug(String.format("Error reading lock file: %s", lockFile), ex);
}
return msg;
} | [
"private",
"String",
"readLockFile",
"(",
")",
"{",
"String",
"msg",
"=",
"null",
";",
"try",
"(",
"RandomAccessFile",
"f",
"=",
"new",
"RandomAccessFile",
"(",
"lockFile",
",",
"\"rw\"",
")",
")",
"{",
"msg",
"=",
"f",
".",
"readLine",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"String",
".",
"format",
"(",
"\"Error reading lock file: %s\"",
",",
"lockFile",
")",
",",
"ex",
")",
";",
"}",
"return",
"msg",
";",
"}"
] | Reads the first line from the lock file and returns the results as a
string.
@return the first line from the lock file; or null if the contents could
not be read | [
"Reads",
"the",
"first",
"line",
"from",
"the",
"lock",
"file",
"and",
"returns",
"the",
"results",
"as",
"a",
"string",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/utils/H2DBLock.java#L231-L239 |
m-m-m/util | pojopath/src/main/java/net/sf/mmm/util/pojo/path/base/AbstractPojoPathNavigator.java | AbstractPojoPathNavigator.convertList | @SuppressWarnings( {
"""
This method converts the given {@code arrayOrCollection} to a {@link List} as necessary.
@param currentPath is the current {@link CachingPojoPath} that lead to {@code arrayOrCollection}.
@param context is the {@link PojoPathContext context} for this operation.
@param state is the {@link #createState(Object, String, PojoPathMode, PojoPathContext) state} to use.
@param arrayOrCollection is the object to be accessed at a given index.
@return a {@link List} that adapts {@code arrayOrCollection} if it is a {@link Collection} but NOT a {@link List}.
Otherwise the given {@code arrayOrCollection} itself.
""" "unchecked", "rawtypes" })
protected Object convertList(CachingPojoPath currentPath, PojoPathContext context, PojoPathState state, Object arrayOrCollection) {
Object arrayOrList = arrayOrCollection;
if (arrayOrCollection instanceof Collection) {
if (!(arrayOrCollection instanceof List)) {
// non-list collection (e.g. Set) - create Proxy-List
if (state.cachingDisabled) {
PojoPathCachingDisabledException cachingException = new PojoPathCachingDisabledException(currentPath.getPojoPath());
throw new PojoPathAccessException(cachingException, currentPath.getPojoPath(), arrayOrCollection.getClass());
}
String collection2ListPath = currentPath.getPojoPath() + PATH_SUFFIX_COLLECTION_LIST;
CachingPojoPath listPath = state.getCachedPath(collection2ListPath);
if (listPath == null) {
listPath = new CachingPojoPath(collection2ListPath);
listPath.parent = currentPath;
listPath.pojo = new CollectionList((Collection) arrayOrCollection);
state.setCachedPath(collection2ListPath, listPath);
}
arrayOrList = listPath.pojo;
}
}
return arrayOrList;
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
protected Object convertList(CachingPojoPath currentPath, PojoPathContext context, PojoPathState state, Object arrayOrCollection) {
Object arrayOrList = arrayOrCollection;
if (arrayOrCollection instanceof Collection) {
if (!(arrayOrCollection instanceof List)) {
// non-list collection (e.g. Set) - create Proxy-List
if (state.cachingDisabled) {
PojoPathCachingDisabledException cachingException = new PojoPathCachingDisabledException(currentPath.getPojoPath());
throw new PojoPathAccessException(cachingException, currentPath.getPojoPath(), arrayOrCollection.getClass());
}
String collection2ListPath = currentPath.getPojoPath() + PATH_SUFFIX_COLLECTION_LIST;
CachingPojoPath listPath = state.getCachedPath(collection2ListPath);
if (listPath == null) {
listPath = new CachingPojoPath(collection2ListPath);
listPath.parent = currentPath;
listPath.pojo = new CollectionList((Collection) arrayOrCollection);
state.setCachedPath(collection2ListPath, listPath);
}
arrayOrList = listPath.pojo;
}
}
return arrayOrList;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"protected",
"Object",
"convertList",
"(",
"CachingPojoPath",
"currentPath",
",",
"PojoPathContext",
"context",
",",
"PojoPathState",
"state",
",",
"Object",
"arrayOrCollection",
")",
"{",
"Object",
"arrayOrList",
"=",
"arrayOrCollection",
";",
"if",
"(",
"arrayOrCollection",
"instanceof",
"Collection",
")",
"{",
"if",
"(",
"!",
"(",
"arrayOrCollection",
"instanceof",
"List",
")",
")",
"{",
"// non-list collection (e.g. Set) - create Proxy-List",
"if",
"(",
"state",
".",
"cachingDisabled",
")",
"{",
"PojoPathCachingDisabledException",
"cachingException",
"=",
"new",
"PojoPathCachingDisabledException",
"(",
"currentPath",
".",
"getPojoPath",
"(",
")",
")",
";",
"throw",
"new",
"PojoPathAccessException",
"(",
"cachingException",
",",
"currentPath",
".",
"getPojoPath",
"(",
")",
",",
"arrayOrCollection",
".",
"getClass",
"(",
")",
")",
";",
"}",
"String",
"collection2ListPath",
"=",
"currentPath",
".",
"getPojoPath",
"(",
")",
"+",
"PATH_SUFFIX_COLLECTION_LIST",
";",
"CachingPojoPath",
"listPath",
"=",
"state",
".",
"getCachedPath",
"(",
"collection2ListPath",
")",
";",
"if",
"(",
"listPath",
"==",
"null",
")",
"{",
"listPath",
"=",
"new",
"CachingPojoPath",
"(",
"collection2ListPath",
")",
";",
"listPath",
".",
"parent",
"=",
"currentPath",
";",
"listPath",
".",
"pojo",
"=",
"new",
"CollectionList",
"(",
"(",
"Collection",
")",
"arrayOrCollection",
")",
";",
"state",
".",
"setCachedPath",
"(",
"collection2ListPath",
",",
"listPath",
")",
";",
"}",
"arrayOrList",
"=",
"listPath",
".",
"pojo",
";",
"}",
"}",
"return",
"arrayOrList",
";",
"}"
] | This method converts the given {@code arrayOrCollection} to a {@link List} as necessary.
@param currentPath is the current {@link CachingPojoPath} that lead to {@code arrayOrCollection}.
@param context is the {@link PojoPathContext context} for this operation.
@param state is the {@link #createState(Object, String, PojoPathMode, PojoPathContext) state} to use.
@param arrayOrCollection is the object to be accessed at a given index.
@return a {@link List} that adapts {@code arrayOrCollection} if it is a {@link Collection} but NOT a {@link List}.
Otherwise the given {@code arrayOrCollection} itself. | [
"This",
"method",
"converts",
"the",
"given",
"{",
"@code",
"arrayOrCollection",
"}",
"to",
"a",
"{",
"@link",
"List",
"}",
"as",
"necessary",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/pojopath/src/main/java/net/sf/mmm/util/pojo/path/base/AbstractPojoPathNavigator.java#L846-L869 |
apache/flink | flink-core/src/main/java/org/apache/flink/util/AbstractID.java | AbstractID.longToByteArray | private static void longToByteArray(long l, byte[] ba, int offset) {
"""
Converts a long to a byte array.
@param l the long variable to be converted
@param ba the byte array to store the result the of the conversion
@param offset offset indicating at what position inside the byte array the result of the conversion shall be stored
"""
for (int i = 0; i < SIZE_OF_LONG; ++i) {
final int shift = i << 3; // i * 8
ba[offset + SIZE_OF_LONG - 1 - i] = (byte) ((l & (0xffL << shift)) >>> shift);
}
} | java | private static void longToByteArray(long l, byte[] ba, int offset) {
for (int i = 0; i < SIZE_OF_LONG; ++i) {
final int shift = i << 3; // i * 8
ba[offset + SIZE_OF_LONG - 1 - i] = (byte) ((l & (0xffL << shift)) >>> shift);
}
} | [
"private",
"static",
"void",
"longToByteArray",
"(",
"long",
"l",
",",
"byte",
"[",
"]",
"ba",
",",
"int",
"offset",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"SIZE_OF_LONG",
";",
"++",
"i",
")",
"{",
"final",
"int",
"shift",
"=",
"i",
"<<",
"3",
";",
"// i * 8",
"ba",
"[",
"offset",
"+",
"SIZE_OF_LONG",
"-",
"1",
"-",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"l",
"&",
"(",
"0xff",
"L",
"<<",
"shift",
")",
")",
">>>",
"shift",
")",
";",
"}",
"}"
] | Converts a long to a byte array.
@param l the long variable to be converted
@param ba the byte array to store the result the of the conversion
@param offset offset indicating at what position inside the byte array the result of the conversion shall be stored | [
"Converts",
"a",
"long",
"to",
"a",
"byte",
"array",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/AbstractID.java#L210-L215 |
tvesalainen/bcc | src/main/java/org/vesalainen/bcc/ClassFile.java | ClassFile.getFieldIndex | int getFieldIndex(TypeElement declaringClass, String name, TypeMirror type) {
"""
Returns the constant map index to field
@param declaringClass
@param name
@param type
@return
"""
return getFieldIndex(declaringClass, name, Descriptor.getFieldDesriptor(type));
} | java | int getFieldIndex(TypeElement declaringClass, String name, TypeMirror type)
{
return getFieldIndex(declaringClass, name, Descriptor.getFieldDesriptor(type));
} | [
"int",
"getFieldIndex",
"(",
"TypeElement",
"declaringClass",
",",
"String",
"name",
",",
"TypeMirror",
"type",
")",
"{",
"return",
"getFieldIndex",
"(",
"declaringClass",
",",
"name",
",",
"Descriptor",
".",
"getFieldDesriptor",
"(",
"type",
")",
")",
";",
"}"
] | Returns the constant map index to field
@param declaringClass
@param name
@param type
@return | [
"Returns",
"the",
"constant",
"map",
"index",
"to",
"field"
] | train | https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L213-L216 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/TenantServiceClient.java | TenantServiceClient.createTenant | public final Tenant createTenant(ProjectName parent, Tenant tenant) {
"""
Creates a new tenant entity.
<p>Sample code:
<pre><code>
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
Tenant response = tenantServiceClient.createTenant(parent, tenant);
}
</code></pre>
@param parent Required.
<p>Resource name of the project under which the tenant is created.
<p>The format is "projects/{project_id}", for example, "projects/api-test-project".
@param tenant Required.
<p>The tenant to be created.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
CreateTenantRequest request =
CreateTenantRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setTenant(tenant)
.build();
return createTenant(request);
} | java | public final Tenant createTenant(ProjectName parent, Tenant tenant) {
CreateTenantRequest request =
CreateTenantRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setTenant(tenant)
.build();
return createTenant(request);
} | [
"public",
"final",
"Tenant",
"createTenant",
"(",
"ProjectName",
"parent",
",",
"Tenant",
"tenant",
")",
"{",
"CreateTenantRequest",
"request",
"=",
"CreateTenantRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"parent",
"==",
"null",
"?",
"null",
":",
"parent",
".",
"toString",
"(",
")",
")",
".",
"setTenant",
"(",
"tenant",
")",
".",
"build",
"(",
")",
";",
"return",
"createTenant",
"(",
"request",
")",
";",
"}"
] | Creates a new tenant entity.
<p>Sample code:
<pre><code>
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
Tenant response = tenantServiceClient.createTenant(parent, tenant);
}
</code></pre>
@param parent Required.
<p>Resource name of the project under which the tenant is created.
<p>The format is "projects/{project_id}", for example, "projects/api-test-project".
@param tenant Required.
<p>The tenant to be created.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Creates",
"a",
"new",
"tenant",
"entity",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/TenantServiceClient.java#L179-L187 |
raphw/byte-buddy | byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java | ElementMatchers.takesGenericArgument | public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArgument(int index, Type type) {
"""
Matches {@link MethodDescription}s that define a given generic type as a parameter at the given index.
@param index The index of the parameter.
@param type The generic type the matched method is expected to define as a parameter type.
@param <T> The type of the matched object.
@return An element matcher that matches a given generic return type for a method description.
"""
return takesGenericArgument(index, TypeDefinition.Sort.describe(type));
} | java | public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArgument(int index, Type type) {
return takesGenericArgument(index, TypeDefinition.Sort.describe(type));
} | [
"public",
"static",
"<",
"T",
"extends",
"MethodDescription",
">",
"ElementMatcher",
".",
"Junction",
"<",
"T",
">",
"takesGenericArgument",
"(",
"int",
"index",
",",
"Type",
"type",
")",
"{",
"return",
"takesGenericArgument",
"(",
"index",
",",
"TypeDefinition",
".",
"Sort",
".",
"describe",
"(",
"type",
")",
")",
";",
"}"
] | Matches {@link MethodDescription}s that define a given generic type as a parameter at the given index.
@param index The index of the parameter.
@param type The generic type the matched method is expected to define as a parameter type.
@param <T> The type of the matched object.
@return An element matcher that matches a given generic return type for a method description. | [
"Matches",
"{",
"@link",
"MethodDescription",
"}",
"s",
"that",
"define",
"a",
"given",
"generic",
"type",
"as",
"a",
"parameter",
"at",
"the",
"given",
"index",
"."
] | train | https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L1158-L1160 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/xml/xpath/XPathUtils.java | XPathUtils.buildExpression | private static XPathExpression buildExpression(String xPathExpression, NamespaceContext nsContext)
throws XPathExpressionException {
"""
Construct a xPath expression instance with given expression string and namespace context.
If namespace context is not specified a default context is built from the XML node
that is evaluated against.
@param xPathExpression
@param nsContext
@return
@throws XPathExpressionException
"""
XPath xpath = createXPathFactory().newXPath();
if (nsContext != null) {
xpath.setNamespaceContext(nsContext);
}
return xpath.compile(xPathExpression);
} | java | private static XPathExpression buildExpression(String xPathExpression, NamespaceContext nsContext)
throws XPathExpressionException {
XPath xpath = createXPathFactory().newXPath();
if (nsContext != null) {
xpath.setNamespaceContext(nsContext);
}
return xpath.compile(xPathExpression);
} | [
"private",
"static",
"XPathExpression",
"buildExpression",
"(",
"String",
"xPathExpression",
",",
"NamespaceContext",
"nsContext",
")",
"throws",
"XPathExpressionException",
"{",
"XPath",
"xpath",
"=",
"createXPathFactory",
"(",
")",
".",
"newXPath",
"(",
")",
";",
"if",
"(",
"nsContext",
"!=",
"null",
")",
"{",
"xpath",
".",
"setNamespaceContext",
"(",
"nsContext",
")",
";",
"}",
"return",
"xpath",
".",
"compile",
"(",
"xPathExpression",
")",
";",
"}"
] | Construct a xPath expression instance with given expression string and namespace context.
If namespace context is not specified a default context is built from the XML node
that is evaluated against.
@param xPathExpression
@param nsContext
@return
@throws XPathExpressionException | [
"Construct",
"a",
"xPath",
"expression",
"instance",
"with",
"given",
"expression",
"string",
"and",
"namespace",
"context",
".",
"If",
"namespace",
"context",
"is",
"not",
"specified",
"a",
"default",
"context",
"is",
"built",
"from",
"the",
"XML",
"node",
"that",
"is",
"evaluated",
"against",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/xml/xpath/XPathUtils.java#L269-L278 |
aws/aws-sdk-java | aws-java-sdk-iam/src/main/java/com/amazonaws/services/identitymanagement/model/GetAccountSummaryResult.java | GetAccountSummaryResult.withSummaryMap | public GetAccountSummaryResult withSummaryMap(java.util.Map<String, Integer> summaryMap) {
"""
<p>
A set of key–value pairs containing information about IAM entity usage and IAM quotas.
</p>
@param summaryMap
A set of key–value pairs containing information about IAM entity usage and IAM quotas.
@return Returns a reference to this object so that method calls can be chained together.
"""
setSummaryMap(summaryMap);
return this;
} | java | public GetAccountSummaryResult withSummaryMap(java.util.Map<String, Integer> summaryMap) {
setSummaryMap(summaryMap);
return this;
} | [
"public",
"GetAccountSummaryResult",
"withSummaryMap",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"Integer",
">",
"summaryMap",
")",
"{",
"setSummaryMap",
"(",
"summaryMap",
")",
";",
"return",
"this",
";",
"}"
] | <p>
A set of key–value pairs containing information about IAM entity usage and IAM quotas.
</p>
@param summaryMap
A set of key–value pairs containing information about IAM entity usage and IAM quotas.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"set",
"of",
"key–value",
"pairs",
"containing",
"information",
"about",
"IAM",
"entity",
"usage",
"and",
"IAM",
"quotas",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iam/src/main/java/com/amazonaws/services/identitymanagement/model/GetAccountSummaryResult.java#L74-L77 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfContentByte.java | PdfContentByte.addImage | public void addImage(Image image, boolean inlineImage) throws DocumentException {
"""
Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have
absolute positioning. The image can be placed inline.
@param image the <CODE>Image</CODE> object
@param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise
@throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning
"""
if (!image.hasAbsoluteY())
throw new DocumentException("The image must have absolute positioning.");
float matrix[] = image.matrix();
matrix[Image.CX] = image.getAbsoluteX() - matrix[Image.CX];
matrix[Image.CY] = image.getAbsoluteY() - matrix[Image.CY];
addImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], inlineImage);
} | java | public void addImage(Image image, boolean inlineImage) throws DocumentException {
if (!image.hasAbsoluteY())
throw new DocumentException("The image must have absolute positioning.");
float matrix[] = image.matrix();
matrix[Image.CX] = image.getAbsoluteX() - matrix[Image.CX];
matrix[Image.CY] = image.getAbsoluteY() - matrix[Image.CY];
addImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], inlineImage);
} | [
"public",
"void",
"addImage",
"(",
"Image",
"image",
",",
"boolean",
"inlineImage",
")",
"throws",
"DocumentException",
"{",
"if",
"(",
"!",
"image",
".",
"hasAbsoluteY",
"(",
")",
")",
"throw",
"new",
"DocumentException",
"(",
"\"The image must have absolute positioning.\"",
")",
";",
"float",
"matrix",
"[",
"]",
"=",
"image",
".",
"matrix",
"(",
")",
";",
"matrix",
"[",
"Image",
".",
"CX",
"]",
"=",
"image",
".",
"getAbsoluteX",
"(",
")",
"-",
"matrix",
"[",
"Image",
".",
"CX",
"]",
";",
"matrix",
"[",
"Image",
".",
"CY",
"]",
"=",
"image",
".",
"getAbsoluteY",
"(",
")",
"-",
"matrix",
"[",
"Image",
".",
"CY",
"]",
";",
"addImage",
"(",
"image",
",",
"matrix",
"[",
"0",
"]",
",",
"matrix",
"[",
"1",
"]",
",",
"matrix",
"[",
"2",
"]",
",",
"matrix",
"[",
"3",
"]",
",",
"matrix",
"[",
"4",
"]",
",",
"matrix",
"[",
"5",
"]",
",",
"inlineImage",
")",
";",
"}"
] | Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have
absolute positioning. The image can be placed inline.
@param image the <CODE>Image</CODE> object
@param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise
@throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning | [
"Adds",
"an",
"<CODE",
">",
"Image<",
"/",
"CODE",
">",
"to",
"the",
"page",
".",
"The",
"<CODE",
">",
"Image<",
"/",
"CODE",
">",
"must",
"have",
"absolute",
"positioning",
".",
"The",
"image",
"can",
"be",
"placed",
"inline",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfContentByte.java#L1111-L1118 |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/control/CmsSitemapController.java | CmsSitemapController.commitChange | protected void commitChange(final CmsSitemapChange change, final Command callback) {
"""
Adds a change to the queue.<p>
@param change the change to commit
@param callback the callback to execute after the change has been applied
"""
if (change != null) {
// save the sitemap
CmsRpcAction<CmsSitemapChange> saveAction = new CmsRpcAction<CmsSitemapChange>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, true);
getService().save(getEntryPoint(), change, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
public void onResponse(CmsSitemapChange result) {
stop(false);
applyChange(result);
if (callback != null) {
callback.execute();
}
}
};
saveAction.execute();
}
} | java | protected void commitChange(final CmsSitemapChange change, final Command callback) {
if (change != null) {
// save the sitemap
CmsRpcAction<CmsSitemapChange> saveAction = new CmsRpcAction<CmsSitemapChange>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, true);
getService().save(getEntryPoint(), change, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
public void onResponse(CmsSitemapChange result) {
stop(false);
applyChange(result);
if (callback != null) {
callback.execute();
}
}
};
saveAction.execute();
}
} | [
"protected",
"void",
"commitChange",
"(",
"final",
"CmsSitemapChange",
"change",
",",
"final",
"Command",
"callback",
")",
"{",
"if",
"(",
"change",
"!=",
"null",
")",
"{",
"// save the sitemap",
"CmsRpcAction",
"<",
"CmsSitemapChange",
">",
"saveAction",
"=",
"new",
"CmsRpcAction",
"<",
"CmsSitemapChange",
">",
"(",
")",
"{",
"/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()\n */",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"start",
"(",
"0",
",",
"true",
")",
";",
"getService",
"(",
")",
".",
"save",
"(",
"getEntryPoint",
"(",
")",
",",
"change",
",",
"this",
")",
";",
"}",
"/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)\n */",
"@",
"Override",
"public",
"void",
"onResponse",
"(",
"CmsSitemapChange",
"result",
")",
"{",
"stop",
"(",
"false",
")",
";",
"applyChange",
"(",
"result",
")",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"execute",
"(",
")",
";",
"}",
"}",
"}",
";",
"saveAction",
".",
"execute",
"(",
")",
";",
"}",
"}"
] | Adds a change to the queue.<p>
@param change the change to commit
@param callback the callback to execute after the change has been applied | [
"Adds",
"a",
"change",
"to",
"the",
"queue",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/control/CmsSitemapController.java#L2147-L2180 |
ehcache/ehcache3 | impl/src/main/java/org/ehcache/impl/config/executor/PooledExecutionServiceConfiguration.java | PooledExecutionServiceConfiguration.addPool | public void addPool(String alias, int minSize, int maxSize) {
"""
Adds a new pool with the provided minimum and maximum.
@param alias the pool alias
@param minSize the minimum size
@param maxSize the maximum size
@throws NullPointerException if alias is null
@throws IllegalArgumentException if another pool with the same alias was configured already
"""
if (alias == null) {
throw new NullPointerException("Pool alias cannot be null");
}
if (poolConfigurations.containsKey(alias)) {
throw new IllegalArgumentException("A pool with the alias '" + alias + "' is already configured");
} else {
poolConfigurations.put(alias, new PoolConfiguration(minSize, maxSize));
}
} | java | public void addPool(String alias, int minSize, int maxSize) {
if (alias == null) {
throw new NullPointerException("Pool alias cannot be null");
}
if (poolConfigurations.containsKey(alias)) {
throw new IllegalArgumentException("A pool with the alias '" + alias + "' is already configured");
} else {
poolConfigurations.put(alias, new PoolConfiguration(minSize, maxSize));
}
} | [
"public",
"void",
"addPool",
"(",
"String",
"alias",
",",
"int",
"minSize",
",",
"int",
"maxSize",
")",
"{",
"if",
"(",
"alias",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Pool alias cannot be null\"",
")",
";",
"}",
"if",
"(",
"poolConfigurations",
".",
"containsKey",
"(",
"alias",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A pool with the alias '\"",
"+",
"alias",
"+",
"\"' is already configured\"",
")",
";",
"}",
"else",
"{",
"poolConfigurations",
".",
"put",
"(",
"alias",
",",
"new",
"PoolConfiguration",
"(",
"minSize",
",",
"maxSize",
")",
")",
";",
"}",
"}"
] | Adds a new pool with the provided minimum and maximum.
@param alias the pool alias
@param minSize the minimum size
@param maxSize the maximum size
@throws NullPointerException if alias is null
@throws IllegalArgumentException if another pool with the same alias was configured already | [
"Adds",
"a",
"new",
"pool",
"with",
"the",
"provided",
"minimum",
"and",
"maximum",
"."
] | train | https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/config/executor/PooledExecutionServiceConfiguration.java#L82-L91 |
ehcache/ehcache3 | transactions/src/main/java/org/ehcache/transactions/xa/txmgr/btm/BitronixXAResourceRegistry.java | BitronixXAResourceRegistry.registerXAResource | @Override
public void registerXAResource(String uniqueName, XAResource xaResource) {
"""
Register an XAResource of a cache with BTM. The first time a XAResource is registered a new
EhCacheXAResourceProducer is created to hold it.
@param uniqueName the uniqueName of this XAResourceProducer, usually the cache's name
@param xaResource the XAResource to be registered
"""
Ehcache3XAResourceProducer xaResourceProducer = producers.get(uniqueName);
if (xaResourceProducer == null) {
xaResourceProducer = new Ehcache3XAResourceProducer();
xaResourceProducer.setUniqueName(uniqueName);
// the initial xaResource must be added before init() can be called
xaResourceProducer.addXAResource(xaResource);
Ehcache3XAResourceProducer previous = producers.putIfAbsent(uniqueName, xaResourceProducer);
if (previous == null) {
xaResourceProducer.init();
} else {
previous.addXAResource(xaResource);
}
} else {
xaResourceProducer.addXAResource(xaResource);
}
} | java | @Override
public void registerXAResource(String uniqueName, XAResource xaResource) {
Ehcache3XAResourceProducer xaResourceProducer = producers.get(uniqueName);
if (xaResourceProducer == null) {
xaResourceProducer = new Ehcache3XAResourceProducer();
xaResourceProducer.setUniqueName(uniqueName);
// the initial xaResource must be added before init() can be called
xaResourceProducer.addXAResource(xaResource);
Ehcache3XAResourceProducer previous = producers.putIfAbsent(uniqueName, xaResourceProducer);
if (previous == null) {
xaResourceProducer.init();
} else {
previous.addXAResource(xaResource);
}
} else {
xaResourceProducer.addXAResource(xaResource);
}
} | [
"@",
"Override",
"public",
"void",
"registerXAResource",
"(",
"String",
"uniqueName",
",",
"XAResource",
"xaResource",
")",
"{",
"Ehcache3XAResourceProducer",
"xaResourceProducer",
"=",
"producers",
".",
"get",
"(",
"uniqueName",
")",
";",
"if",
"(",
"xaResourceProducer",
"==",
"null",
")",
"{",
"xaResourceProducer",
"=",
"new",
"Ehcache3XAResourceProducer",
"(",
")",
";",
"xaResourceProducer",
".",
"setUniqueName",
"(",
"uniqueName",
")",
";",
"// the initial xaResource must be added before init() can be called",
"xaResourceProducer",
".",
"addXAResource",
"(",
"xaResource",
")",
";",
"Ehcache3XAResourceProducer",
"previous",
"=",
"producers",
".",
"putIfAbsent",
"(",
"uniqueName",
",",
"xaResourceProducer",
")",
";",
"if",
"(",
"previous",
"==",
"null",
")",
"{",
"xaResourceProducer",
".",
"init",
"(",
")",
";",
"}",
"else",
"{",
"previous",
".",
"addXAResource",
"(",
"xaResource",
")",
";",
"}",
"}",
"else",
"{",
"xaResourceProducer",
".",
"addXAResource",
"(",
"xaResource",
")",
";",
"}",
"}"
] | Register an XAResource of a cache with BTM. The first time a XAResource is registered a new
EhCacheXAResourceProducer is created to hold it.
@param uniqueName the uniqueName of this XAResourceProducer, usually the cache's name
@param xaResource the XAResource to be registered | [
"Register",
"an",
"XAResource",
"of",
"a",
"cache",
"with",
"BTM",
".",
"The",
"first",
"time",
"a",
"XAResource",
"is",
"registered",
"a",
"new",
"EhCacheXAResourceProducer",
"is",
"created",
"to",
"hold",
"it",
"."
] | train | https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/transactions/src/main/java/org/ehcache/transactions/xa/txmgr/btm/BitronixXAResourceRegistry.java#L40-L59 |
ujmp/universal-java-matrix-package | ujmp-core/src/main/java/org/ujmp/core/util/MathUtil.java | MathUtil.nextInteger | public static final int nextInteger(int min, int max) {
"""
Returns a random value in the desired interval
@param min
minimum value (inclusive)
@param max
maximum value (exclusive)
@return a random value
"""
return min == max ? min : min + getRandom().nextInt(max - min);
} | java | public static final int nextInteger(int min, int max) {
return min == max ? min : min + getRandom().nextInt(max - min);
} | [
"public",
"static",
"final",
"int",
"nextInteger",
"(",
"int",
"min",
",",
"int",
"max",
")",
"{",
"return",
"min",
"==",
"max",
"?",
"min",
":",
"min",
"+",
"getRandom",
"(",
")",
".",
"nextInt",
"(",
"max",
"-",
"min",
")",
";",
"}"
] | Returns a random value in the desired interval
@param min
minimum value (inclusive)
@param max
maximum value (exclusive)
@return a random value | [
"Returns",
"a",
"random",
"value",
"in",
"the",
"desired",
"interval"
] | train | https://github.com/ujmp/universal-java-matrix-package/blob/b7e1d293adeadaf35d208ffe8884028d6c06b63b/ujmp-core/src/main/java/org/ujmp/core/util/MathUtil.java#L303-L305 |
payneteasy/superfly | superfly-web/src/main/java/com/payneteasy/superfly/web/wicket/component/label/DateLabels.java | DateLabels.forDate | public static DateLabel forDate(String id, Date date) {
"""
Creates a label which displays date only (year, month, day).
@param id component id
@param date date to display
@return date label
"""
return DateLabel.forDatePattern(id, new Model<Date>(date), DATE_PATTERN);
} | java | public static DateLabel forDate(String id, Date date) {
return DateLabel.forDatePattern(id, new Model<Date>(date), DATE_PATTERN);
} | [
"public",
"static",
"DateLabel",
"forDate",
"(",
"String",
"id",
",",
"Date",
"date",
")",
"{",
"return",
"DateLabel",
".",
"forDatePattern",
"(",
"id",
",",
"new",
"Model",
"<",
"Date",
">",
"(",
"date",
")",
",",
"DATE_PATTERN",
")",
";",
"}"
] | Creates a label which displays date only (year, month, day).
@param id component id
@param date date to display
@return date label | [
"Creates",
"a",
"label",
"which",
"displays",
"date",
"only",
"(",
"year",
"month",
"day",
")",
"."
] | train | https://github.com/payneteasy/superfly/blob/4cad6d0f8e951a61f3c302c49b13a51d179076f8/superfly-web/src/main/java/com/payneteasy/superfly/web/wicket/component/label/DateLabels.java#L26-L28 |
google/truth | core/src/main/java/com/google/common/truth/Platform.java | Platform.containsMatch | static boolean containsMatch(String actual, String regex) {
"""
Determines if the given subject contains a match for the given regex.
"""
return Pattern.compile(regex).matcher(actual).find();
} | java | static boolean containsMatch(String actual, String regex) {
return Pattern.compile(regex).matcher(actual).find();
} | [
"static",
"boolean",
"containsMatch",
"(",
"String",
"actual",
",",
"String",
"regex",
")",
"{",
"return",
"Pattern",
".",
"compile",
"(",
"regex",
")",
".",
"matcher",
"(",
"actual",
")",
".",
"find",
"(",
")",
";",
"}"
] | Determines if the given subject contains a match for the given regex. | [
"Determines",
"if",
"the",
"given",
"subject",
"contains",
"a",
"match",
"for",
"the",
"given",
"regex",
"."
] | train | https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/core/src/main/java/com/google/common/truth/Platform.java#L50-L52 |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ProactiveDetectionConfigurationsInner.java | ProactiveDetectionConfigurationsInner.updateAsync | public Observable<ApplicationInsightsComponentProactiveDetectionConfigurationInner> updateAsync(String resourceGroupName, String resourceName, String configurationId, ApplicationInsightsComponentProactiveDetectionConfigurationInner proactiveDetectionProperties) {
"""
Update the ProactiveDetection configuration for this configuration id.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param configurationId The ProactiveDetection configuration ID. This is unique within a Application Insights component.
@param proactiveDetectionProperties Properties that need to be specified to update the ProactiveDetection configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentProactiveDetectionConfigurationInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, resourceName, configurationId, proactiveDetectionProperties).map(new Func1<ServiceResponse<ApplicationInsightsComponentProactiveDetectionConfigurationInner>, ApplicationInsightsComponentProactiveDetectionConfigurationInner>() {
@Override
public ApplicationInsightsComponentProactiveDetectionConfigurationInner call(ServiceResponse<ApplicationInsightsComponentProactiveDetectionConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<ApplicationInsightsComponentProactiveDetectionConfigurationInner> updateAsync(String resourceGroupName, String resourceName, String configurationId, ApplicationInsightsComponentProactiveDetectionConfigurationInner proactiveDetectionProperties) {
return updateWithServiceResponseAsync(resourceGroupName, resourceName, configurationId, proactiveDetectionProperties).map(new Func1<ServiceResponse<ApplicationInsightsComponentProactiveDetectionConfigurationInner>, ApplicationInsightsComponentProactiveDetectionConfigurationInner>() {
@Override
public ApplicationInsightsComponentProactiveDetectionConfigurationInner call(ServiceResponse<ApplicationInsightsComponentProactiveDetectionConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"String",
"configurationId",
",",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
"proactiveDetectionProperties",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"configurationId",
",",
"proactiveDetectionProperties",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
",",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update the ProactiveDetection configuration for this configuration id.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param configurationId The ProactiveDetection configuration ID. This is unique within a Application Insights component.
@param proactiveDetectionProperties Properties that need to be specified to update the ProactiveDetection configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentProactiveDetectionConfigurationInner object | [
"Update",
"the",
"ProactiveDetection",
"configuration",
"for",
"this",
"configuration",
"id",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ProactiveDetectionConfigurationsInner.java#L292-L299 |
samskivert/samskivert | src/main/java/com/samskivert/util/PropertiesUtil.java | PropertiesUtil.loadAndGet | public static String loadAndGet (String loaderPath, String key) {
"""
Like {@link #loadAndGet(File,String)} but obtains the properties data via the classloader.
@return the value of the key in question or null if no such key exists or an error occurred
loading the properties file.
"""
try {
Properties props = ConfigUtil.loadProperties(loaderPath);
return props.getProperty(key);
} catch (IOException ioe) {
return null;
}
} | java | public static String loadAndGet (String loaderPath, String key)
{
try {
Properties props = ConfigUtil.loadProperties(loaderPath);
return props.getProperty(key);
} catch (IOException ioe) {
return null;
}
} | [
"public",
"static",
"String",
"loadAndGet",
"(",
"String",
"loaderPath",
",",
"String",
"key",
")",
"{",
"try",
"{",
"Properties",
"props",
"=",
"ConfigUtil",
".",
"loadProperties",
"(",
"loaderPath",
")",
";",
"return",
"props",
".",
"getProperty",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Like {@link #loadAndGet(File,String)} but obtains the properties data via the classloader.
@return the value of the key in question or null if no such key exists or an error occurred
loading the properties file. | [
"Like",
"{",
"@link",
"#loadAndGet",
"(",
"File",
"String",
")",
"}",
"but",
"obtains",
"the",
"properties",
"data",
"via",
"the",
"classloader",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/PropertiesUtil.java#L197-L205 |
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkInterfaceIPConfigurationsInner.java | NetworkInterfaceIPConfigurationsInner.getAsync | public Observable<NetworkInterfaceIPConfigurationInner> getAsync(String resourceGroupName, String networkInterfaceName, String ipConfigurationName) {
"""
Gets the specified network interface ip configuration.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param ipConfigurationName The name of the ip configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceIPConfigurationInner object
"""
return getWithServiceResponseAsync(resourceGroupName, networkInterfaceName, ipConfigurationName).map(new Func1<ServiceResponse<NetworkInterfaceIPConfigurationInner>, NetworkInterfaceIPConfigurationInner>() {
@Override
public NetworkInterfaceIPConfigurationInner call(ServiceResponse<NetworkInterfaceIPConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<NetworkInterfaceIPConfigurationInner> getAsync(String resourceGroupName, String networkInterfaceName, String ipConfigurationName) {
return getWithServiceResponseAsync(resourceGroupName, networkInterfaceName, ipConfigurationName).map(new Func1<ServiceResponse<NetworkInterfaceIPConfigurationInner>, NetworkInterfaceIPConfigurationInner>() {
@Override
public NetworkInterfaceIPConfigurationInner call(ServiceResponse<NetworkInterfaceIPConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NetworkInterfaceIPConfigurationInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkInterfaceName",
",",
"String",
"ipConfigurationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkInterfaceName",
",",
"ipConfigurationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NetworkInterfaceIPConfigurationInner",
">",
",",
"NetworkInterfaceIPConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NetworkInterfaceIPConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"NetworkInterfaceIPConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the specified network interface ip configuration.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param ipConfigurationName The name of the ip configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceIPConfigurationInner object | [
"Gets",
"the",
"specified",
"network",
"interface",
"ip",
"configuration",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkInterfaceIPConfigurationsInner.java#L233-L240 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java | NetworkCalibration.calculateDelays | private void calculateDelays( int k, double[] cDelays, double[][] net ) {
"""
Calcola il ritardo della tubazione k.
@param k indice della tubazione.
@param cDelays matrice dei ritardi.
@param net matrice che contiene la sottorete.
"""
double t;
int ind, r = 1;
for( int j = 0; j < net.length; ++j ) {
t = 0;
r = 1;
ind = (int) net[j][0];
/*
* Area k is not included in delays
*/
while( networkPipes[ind].getIndexPipeWhereDrain() != k ) {
ind = networkPipes[ind].getIndexPipeWhereDrain();
t += cDelays[ind];
r++;
}
if (r > networkPipes.length) {
pm.errorMessage(msg.message("trentoP.error.incorrectmatrix"));
throw new ArithmeticException(msg.message("trentoP.error.incorrectmatrix"));
}
net[j][2] = t;
}
} | java | private void calculateDelays( int k, double[] cDelays, double[][] net )
{
double t;
int ind, r = 1;
for( int j = 0; j < net.length; ++j ) {
t = 0;
r = 1;
ind = (int) net[j][0];
/*
* Area k is not included in delays
*/
while( networkPipes[ind].getIndexPipeWhereDrain() != k ) {
ind = networkPipes[ind].getIndexPipeWhereDrain();
t += cDelays[ind];
r++;
}
if (r > networkPipes.length) {
pm.errorMessage(msg.message("trentoP.error.incorrectmatrix"));
throw new ArithmeticException(msg.message("trentoP.error.incorrectmatrix"));
}
net[j][2] = t;
}
} | [
"private",
"void",
"calculateDelays",
"(",
"int",
"k",
",",
"double",
"[",
"]",
"cDelays",
",",
"double",
"[",
"]",
"[",
"]",
"net",
")",
"{",
"double",
"t",
";",
"int",
"ind",
",",
"r",
"=",
"1",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"net",
".",
"length",
";",
"++",
"j",
")",
"{",
"t",
"=",
"0",
";",
"r",
"=",
"1",
";",
"ind",
"=",
"(",
"int",
")",
"net",
"[",
"j",
"]",
"[",
"0",
"]",
";",
"/*\n * Area k is not included in delays\n */",
"while",
"(",
"networkPipes",
"[",
"ind",
"]",
".",
"getIndexPipeWhereDrain",
"(",
")",
"!=",
"k",
")",
"{",
"ind",
"=",
"networkPipes",
"[",
"ind",
"]",
".",
"getIndexPipeWhereDrain",
"(",
")",
";",
"t",
"+=",
"cDelays",
"[",
"ind",
"]",
";",
"r",
"++",
";",
"}",
"if",
"(",
"r",
">",
"networkPipes",
".",
"length",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.incorrectmatrix\"",
")",
")",
";",
"throw",
"new",
"ArithmeticException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.incorrectmatrix\"",
")",
")",
";",
"}",
"net",
"[",
"j",
"]",
"[",
"2",
"]",
"=",
"t",
";",
"}",
"}"
] | Calcola il ritardo della tubazione k.
@param k indice della tubazione.
@param cDelays matrice dei ritardi.
@param net matrice che contiene la sottorete. | [
"Calcola",
"il",
"ritardo",
"della",
"tubazione",
"k",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java#L465-L491 |
tvesalainen/util | util/src/main/java/org/vesalainen/util/OrderedList.java | OrderedList.headIterator | public Iterator<T> headIterator(T key, boolean inclusive) {
"""
Returns iterator from start to key
@param key
@param inclusive
@return
"""
int point = point(key, !inclusive);
return subList(0, point).iterator();
} | java | public Iterator<T> headIterator(T key, boolean inclusive)
{
int point = point(key, !inclusive);
return subList(0, point).iterator();
} | [
"public",
"Iterator",
"<",
"T",
">",
"headIterator",
"(",
"T",
"key",
",",
"boolean",
"inclusive",
")",
"{",
"int",
"point",
"=",
"point",
"(",
"key",
",",
"!",
"inclusive",
")",
";",
"return",
"subList",
"(",
"0",
",",
"point",
")",
".",
"iterator",
"(",
")",
";",
"}"
] | Returns iterator from start to key
@param key
@param inclusive
@return | [
"Returns",
"iterator",
"from",
"start",
"to",
"key"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/OrderedList.java#L125-L129 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/blas/SparseCpuLevel1.java | SparseCpuLevel1.saxpyi | @Override
protected void saxpyi(long N, double alpha, INDArray X, DataBuffer pointers, INDArray Y) {
"""
Adds a scalar multiple of float compressed sparse vector to a full-storage vector.
@param N The number of elements in vector X
@param alpha
@param X a sparse vector
@param pointers A DataBuffer that specifies the indices for the elements of x.
@param Y a dense vector
"""
cblas_saxpyi((int) N, (float) alpha, (FloatPointer) X.data().addressPointer(), (IntPointer) pointers.addressPointer(),
(FloatPointer) Y.data().addressPointer());
} | java | @Override
protected void saxpyi(long N, double alpha, INDArray X, DataBuffer pointers, INDArray Y) {
cblas_saxpyi((int) N, (float) alpha, (FloatPointer) X.data().addressPointer(), (IntPointer) pointers.addressPointer(),
(FloatPointer) Y.data().addressPointer());
} | [
"@",
"Override",
"protected",
"void",
"saxpyi",
"(",
"long",
"N",
",",
"double",
"alpha",
",",
"INDArray",
"X",
",",
"DataBuffer",
"pointers",
",",
"INDArray",
"Y",
")",
"{",
"cblas_saxpyi",
"(",
"(",
"int",
")",
"N",
",",
"(",
"float",
")",
"alpha",
",",
"(",
"FloatPointer",
")",
"X",
".",
"data",
"(",
")",
".",
"addressPointer",
"(",
")",
",",
"(",
"IntPointer",
")",
"pointers",
".",
"addressPointer",
"(",
")",
",",
"(",
"FloatPointer",
")",
"Y",
".",
"data",
"(",
")",
".",
"addressPointer",
"(",
")",
")",
";",
"}"
] | Adds a scalar multiple of float compressed sparse vector to a full-storage vector.
@param N The number of elements in vector X
@param alpha
@param X a sparse vector
@param pointers A DataBuffer that specifies the indices for the elements of x.
@param Y a dense vector | [
"Adds",
"a",
"scalar",
"multiple",
"of",
"float",
"compressed",
"sparse",
"vector",
"to",
"a",
"full",
"-",
"storage",
"vector",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/blas/SparseCpuLevel1.java#L211-L215 |
aws/aws-sdk-java | aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/PutIntegrationResponseResult.java | PutIntegrationResponseResult.withResponseTemplates | public PutIntegrationResponseResult withResponseTemplates(java.util.Map<String, String> responseTemplates) {
"""
<p>
Specifies the templates used to transform the integration response body. Response templates are represented as a
key/value map, with a content-type as the key and a template as the value.
</p>
@param responseTemplates
Specifies the templates used to transform the integration response body. Response templates are
represented as a key/value map, with a content-type as the key and a template as the value.
@return Returns a reference to this object so that method calls can be chained together.
"""
setResponseTemplates(responseTemplates);
return this;
} | java | public PutIntegrationResponseResult withResponseTemplates(java.util.Map<String, String> responseTemplates) {
setResponseTemplates(responseTemplates);
return this;
} | [
"public",
"PutIntegrationResponseResult",
"withResponseTemplates",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseTemplates",
")",
"{",
"setResponseTemplates",
"(",
"responseTemplates",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Specifies the templates used to transform the integration response body. Response templates are represented as a
key/value map, with a content-type as the key and a template as the value.
</p>
@param responseTemplates
Specifies the templates used to transform the integration response body. Response templates are
represented as a key/value map, with a content-type as the key and a template as the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Specifies",
"the",
"templates",
"used",
"to",
"transform",
"the",
"integration",
"response",
"body",
".",
"Response",
"templates",
"are",
"represented",
"as",
"a",
"key",
"/",
"value",
"map",
"with",
"a",
"content",
"-",
"type",
"as",
"the",
"key",
"and",
"a",
"template",
"as",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/PutIntegrationResponseResult.java#L351-L354 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/PathBuilder.java | PathBuilder.get | @SuppressWarnings("unchecked")
public <A extends Enum<A>> EnumPath<A> get(EnumPath<A> path) {
"""
Create a new Enum path
@param <A>
@param path existing path
@return property path
"""
EnumPath<A> newPath = getEnum(toString(path), (Class<A>) path.getType());
return addMetadataOf(newPath, path);
} | java | @SuppressWarnings("unchecked")
public <A extends Enum<A>> EnumPath<A> get(EnumPath<A> path) {
EnumPath<A> newPath = getEnum(toString(path), (Class<A>) path.getType());
return addMetadataOf(newPath, path);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"A",
"extends",
"Enum",
"<",
"A",
">",
">",
"EnumPath",
"<",
"A",
">",
"get",
"(",
"EnumPath",
"<",
"A",
">",
"path",
")",
"{",
"EnumPath",
"<",
"A",
">",
"newPath",
"=",
"getEnum",
"(",
"toString",
"(",
"path",
")",
",",
"(",
"Class",
"<",
"A",
">",
")",
"path",
".",
"getType",
"(",
")",
")",
";",
"return",
"addMetadataOf",
"(",
"newPath",
",",
"path",
")",
";",
"}"
] | Create a new Enum path
@param <A>
@param path existing path
@return property path | [
"Create",
"a",
"new",
"Enum",
"path"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/PathBuilder.java#L327-L331 |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java | CameraPlaneProjection.pixelToPlane | public boolean pixelToPlane( double pixelX , double pixelY , Point2D_F64 plane ) {
"""
Given a pixel, find the point on the plane. Be sure computeInverse was set to true in
{@link #setPlaneToCamera(georegression.struct.se.Se3_F64, boolean)}
@param pixelX (input) Pixel in the image, x-axis
@param pixelY (input) Pixel in the image, y-axis
@param plane (output) Point on the plane.
@return true if a point on the plane was found in front of the camera
"""
// computer normalized image coordinates
pixelToNorm.compute(pixelX,pixelY,norm);
// Ray pointing from camera center through pixel to ground in ground reference frame
pointing.set(norm.x,norm.y,1);
GeometryMath_F64.mult(cameraToPlane.getR(), pointing, pointing);
double height = cameraToPlane.getY();
// If the point vector and the vector from the plane have the same sign then the ray will not intersect
// the plane or the intersection is undefined
if( pointing.y*height >= 0 )
return false;
// compute the location of the point on the plane in 2D
double t = -height / pointing.y;
plane.x = pointing.z*t;
plane.y = -pointing.x*t;
return true;
} | java | public boolean pixelToPlane( double pixelX , double pixelY , Point2D_F64 plane ) {
// computer normalized image coordinates
pixelToNorm.compute(pixelX,pixelY,norm);
// Ray pointing from camera center through pixel to ground in ground reference frame
pointing.set(norm.x,norm.y,1);
GeometryMath_F64.mult(cameraToPlane.getR(), pointing, pointing);
double height = cameraToPlane.getY();
// If the point vector and the vector from the plane have the same sign then the ray will not intersect
// the plane or the intersection is undefined
if( pointing.y*height >= 0 )
return false;
// compute the location of the point on the plane in 2D
double t = -height / pointing.y;
plane.x = pointing.z*t;
plane.y = -pointing.x*t;
return true;
} | [
"public",
"boolean",
"pixelToPlane",
"(",
"double",
"pixelX",
",",
"double",
"pixelY",
",",
"Point2D_F64",
"plane",
")",
"{",
"// computer normalized image coordinates",
"pixelToNorm",
".",
"compute",
"(",
"pixelX",
",",
"pixelY",
",",
"norm",
")",
";",
"// Ray pointing from camera center through pixel to ground in ground reference frame",
"pointing",
".",
"set",
"(",
"norm",
".",
"x",
",",
"norm",
".",
"y",
",",
"1",
")",
";",
"GeometryMath_F64",
".",
"mult",
"(",
"cameraToPlane",
".",
"getR",
"(",
")",
",",
"pointing",
",",
"pointing",
")",
";",
"double",
"height",
"=",
"cameraToPlane",
".",
"getY",
"(",
")",
";",
"// If the point vector and the vector from the plane have the same sign then the ray will not intersect",
"// the plane or the intersection is undefined",
"if",
"(",
"pointing",
".",
"y",
"*",
"height",
">=",
"0",
")",
"return",
"false",
";",
"// compute the location of the point on the plane in 2D",
"double",
"t",
"=",
"-",
"height",
"/",
"pointing",
".",
"y",
";",
"plane",
".",
"x",
"=",
"pointing",
".",
"z",
"*",
"t",
";",
"plane",
".",
"y",
"=",
"-",
"pointing",
".",
"x",
"*",
"t",
";",
"return",
"true",
";",
"}"
] | Given a pixel, find the point on the plane. Be sure computeInverse was set to true in
{@link #setPlaneToCamera(georegression.struct.se.Se3_F64, boolean)}
@param pixelX (input) Pixel in the image, x-axis
@param pixelY (input) Pixel in the image, y-axis
@param plane (output) Point on the plane.
@return true if a point on the plane was found in front of the camera | [
"Given",
"a",
"pixel",
"find",
"the",
"point",
"on",
"the",
"plane",
".",
"Be",
"sure",
"computeInverse",
"was",
"set",
"to",
"true",
"in",
"{",
"@link",
"#setPlaneToCamera",
"(",
"georegression",
".",
"struct",
".",
"se",
".",
"Se3_F64",
"boolean",
")",
"}"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java#L155-L177 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.mergeCertificate | public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List<byte[]> x509Certificates, CertificateAttributes certificateAttributes, Map<String, String> tags) {
"""
Merges a certificate or a certificate chain with a key pair existing on the server.
The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate.
@param x509Certificates The certificate or the certificate chain to merge.
@param certificateAttributes The attributes of the certificate (optional).
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the CertificateBundle object if successful.
"""
return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single().body();
} | java | public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List<byte[]> x509Certificates, CertificateAttributes certificateAttributes, Map<String, String> tags) {
return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single().body();
} | [
"public",
"CertificateBundle",
"mergeCertificate",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"certificateName",
",",
"List",
"<",
"byte",
"[",
"]",
">",
"x509Certificates",
",",
"CertificateAttributes",
"certificateAttributes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"mergeCertificateWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"x509Certificates",
",",
"certificateAttributes",
",",
"tags",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Merges a certificate or a certificate chain with a key pair existing on the server.
The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate.
@param x509Certificates The certificate or the certificate chain to merge.
@param certificateAttributes The attributes of the certificate (optional).
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the CertificateBundle object if successful. | [
"Merges",
"a",
"certificate",
"or",
"a",
"certificate",
"chain",
"with",
"a",
"key",
"pair",
"existing",
"on",
"the",
"server",
".",
"The",
"MergeCertificate",
"operation",
"performs",
"the",
"merging",
"of",
"a",
"certificate",
"or",
"certificate",
"chain",
"with",
"a",
"key",
"pair",
"currently",
"available",
"in",
"the",
"service",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"create",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L8008-L8010 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java | JawrBinaryResourceRequestHandler.getRealFilePath | private String getRealFilePath(String fileName, BundleHashcodeType bundleHashcodeType) {
"""
Removes the cache buster
@param fileName
the file name
@return the file name without the cache buster.
"""
String realFilePath = fileName;
if (bundleHashcodeType.equals(BundleHashcodeType.INVALID_HASHCODE)) {
int idx = realFilePath.indexOf(JawrConstant.URL_SEPARATOR, 1);
if (idx != -1) {
realFilePath = realFilePath.substring(idx);
}
} else {
String[] resourceInfo = PathNormalizer.extractBinaryResourceInfo(realFilePath);
realFilePath = resourceInfo[0];
}
return realFilePath;
} | java | private String getRealFilePath(String fileName, BundleHashcodeType bundleHashcodeType) {
String realFilePath = fileName;
if (bundleHashcodeType.equals(BundleHashcodeType.INVALID_HASHCODE)) {
int idx = realFilePath.indexOf(JawrConstant.URL_SEPARATOR, 1);
if (idx != -1) {
realFilePath = realFilePath.substring(idx);
}
} else {
String[] resourceInfo = PathNormalizer.extractBinaryResourceInfo(realFilePath);
realFilePath = resourceInfo[0];
}
return realFilePath;
} | [
"private",
"String",
"getRealFilePath",
"(",
"String",
"fileName",
",",
"BundleHashcodeType",
"bundleHashcodeType",
")",
"{",
"String",
"realFilePath",
"=",
"fileName",
";",
"if",
"(",
"bundleHashcodeType",
".",
"equals",
"(",
"BundleHashcodeType",
".",
"INVALID_HASHCODE",
")",
")",
"{",
"int",
"idx",
"=",
"realFilePath",
".",
"indexOf",
"(",
"JawrConstant",
".",
"URL_SEPARATOR",
",",
"1",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"realFilePath",
"=",
"realFilePath",
".",
"substring",
"(",
"idx",
")",
";",
"}",
"}",
"else",
"{",
"String",
"[",
"]",
"resourceInfo",
"=",
"PathNormalizer",
".",
"extractBinaryResourceInfo",
"(",
"realFilePath",
")",
";",
"realFilePath",
"=",
"resourceInfo",
"[",
"0",
"]",
";",
"}",
"return",
"realFilePath",
";",
"}"
] | Removes the cache buster
@param fileName
the file name
@return the file name without the cache buster. | [
"Removes",
"the",
"cache",
"buster"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrBinaryResourceRequestHandler.java#L612-L626 |
derari/cthul | xml/src/main/java/org/cthul/resolve/ResolvingException.java | ResolvingException.throwIf | public <T1 extends Throwable, T2 extends Throwable>
RuntimeException throwIf(Class<T1> t1, Class<T2> t2)
throws T1, T2 {
"""
Throws the {@linkplain #getResolvingCause() cause} if it is one of the
specified types, otherwise returns a
{@linkplain #asRuntimeException() runtime exception}.
@param <T1>
@param <T2>
@param t1
@param t2
@return runtime exception
@throws T1
@throws T2
"""
return throwIf(t1, t2, NULL_EX, NULL_EX);
} | java | public <T1 extends Throwable, T2 extends Throwable>
RuntimeException throwIf(Class<T1> t1, Class<T2> t2)
throws T1, T2 {
return throwIf(t1, t2, NULL_EX, NULL_EX);
} | [
"public",
"<",
"T1",
"extends",
"Throwable",
",",
"T2",
"extends",
"Throwable",
">",
"RuntimeException",
"throwIf",
"(",
"Class",
"<",
"T1",
">",
"t1",
",",
"Class",
"<",
"T2",
">",
"t2",
")",
"throws",
"T1",
",",
"T2",
"{",
"return",
"throwIf",
"(",
"t1",
",",
"t2",
",",
"NULL_EX",
",",
"NULL_EX",
")",
";",
"}"
] | Throws the {@linkplain #getResolvingCause() cause} if it is one of the
specified types, otherwise returns a
{@linkplain #asRuntimeException() runtime exception}.
@param <T1>
@param <T2>
@param t1
@param t2
@return runtime exception
@throws T1
@throws T2 | [
"Throws",
"the",
"{"
] | train | https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/ResolvingException.java#L245-L249 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/XPath.java | XPath.fixupVariables | public void fixupVariables(java.util.Vector vars, int globalsSize) {
"""
This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).
"""
m_mainExp.fixupVariables(vars, globalsSize);
} | java | public void fixupVariables(java.util.Vector vars, int globalsSize)
{
m_mainExp.fixupVariables(vars, globalsSize);
} | [
"public",
"void",
"fixupVariables",
"(",
"java",
".",
"util",
".",
"Vector",
"vars",
",",
"int",
"globalsSize",
")",
"{",
"m_mainExp",
".",
"fixupVariables",
"(",
"vars",
",",
"globalsSize",
")",
";",
"}"
] | This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame). | [
"This",
"function",
"is",
"used",
"to",
"fixup",
"variables",
"from",
"QNames",
"to",
"stack",
"frame",
"indexes",
"at",
"stylesheet",
"build",
"time",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/XPath.java#L86-L89 |
apereo/cas | core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/scripting/ScriptingUtils.java | ScriptingUtils.executeGroovyScript | @SneakyThrows
public static <T> T executeGroovyScript(final GroovyObject groovyObject,
final String methodName,
final Object[] args,
final Class<T> clazz,
final boolean failOnError) {
"""
Execute groovy script t.
@param <T> the type parameter
@param groovyObject the groovy object
@param methodName the method name
@param args the args
@param clazz the clazz
@param failOnError the fail on error
@return the t
"""
try {
LOGGER.trace("Executing groovy script's [{}] method, with parameters [{}]", methodName, args);
val result = groovyObject.invokeMethod(methodName, args);
LOGGER.trace("Results returned by the groovy script are [{}]", result);
if (!clazz.equals(Void.class)) {
return getGroovyScriptExecutionResultOrThrow(clazz, result);
}
} catch (final Exception e) {
var cause = (Throwable) null;
if (e instanceof InvokerInvocationException) {
cause = e.getCause();
} else {
cause = e;
}
if (failOnError) {
throw cause;
}
LOGGER.error(cause.getMessage(), cause);
}
return null;
} | java | @SneakyThrows
public static <T> T executeGroovyScript(final GroovyObject groovyObject,
final String methodName,
final Object[] args,
final Class<T> clazz,
final boolean failOnError) {
try {
LOGGER.trace("Executing groovy script's [{}] method, with parameters [{}]", methodName, args);
val result = groovyObject.invokeMethod(methodName, args);
LOGGER.trace("Results returned by the groovy script are [{}]", result);
if (!clazz.equals(Void.class)) {
return getGroovyScriptExecutionResultOrThrow(clazz, result);
}
} catch (final Exception e) {
var cause = (Throwable) null;
if (e instanceof InvokerInvocationException) {
cause = e.getCause();
} else {
cause = e;
}
if (failOnError) {
throw cause;
}
LOGGER.error(cause.getMessage(), cause);
}
return null;
} | [
"@",
"SneakyThrows",
"public",
"static",
"<",
"T",
">",
"T",
"executeGroovyScript",
"(",
"final",
"GroovyObject",
"groovyObject",
",",
"final",
"String",
"methodName",
",",
"final",
"Object",
"[",
"]",
"args",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"boolean",
"failOnError",
")",
"{",
"try",
"{",
"LOGGER",
".",
"trace",
"(",
"\"Executing groovy script's [{}] method, with parameters [{}]\"",
",",
"methodName",
",",
"args",
")",
";",
"val",
"result",
"=",
"groovyObject",
".",
"invokeMethod",
"(",
"methodName",
",",
"args",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\"Results returned by the groovy script are [{}]\"",
",",
"result",
")",
";",
"if",
"(",
"!",
"clazz",
".",
"equals",
"(",
"Void",
".",
"class",
")",
")",
"{",
"return",
"getGroovyScriptExecutionResultOrThrow",
"(",
"clazz",
",",
"result",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"var",
"cause",
"=",
"(",
"Throwable",
")",
"null",
";",
"if",
"(",
"e",
"instanceof",
"InvokerInvocationException",
")",
"{",
"cause",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"else",
"{",
"cause",
"=",
"e",
";",
"}",
"if",
"(",
"failOnError",
")",
"{",
"throw",
"cause",
";",
"}",
"LOGGER",
".",
"error",
"(",
"cause",
".",
"getMessage",
"(",
")",
",",
"cause",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Execute groovy script t.
@param <T> the type parameter
@param groovyObject the groovy object
@param methodName the method name
@param args the args
@param clazz the clazz
@param failOnError the fail on error
@return the t | [
"Execute",
"groovy",
"script",
"t",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/scripting/ScriptingUtils.java#L240-L267 |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java | ChatDirector.addAuxiliarySource | public void addAuxiliarySource (DObject source, String localtype) {
"""
Adds an additional object via which chat messages may arrive. The chat director assumes the
caller will be managing the subscription to this object and will remain subscribed to it for
as long as it remains in effect as an auxiliary chat source.
@param localtype a type to be associated with all chat messages that arrive on the specified
DObject.
"""
source.addListener(this);
_auxes.put(source.getOid(), localtype);
} | java | public void addAuxiliarySource (DObject source, String localtype)
{
source.addListener(this);
_auxes.put(source.getOid(), localtype);
} | [
"public",
"void",
"addAuxiliarySource",
"(",
"DObject",
"source",
",",
"String",
"localtype",
")",
"{",
"source",
".",
"addListener",
"(",
"this",
")",
";",
"_auxes",
".",
"put",
"(",
"source",
".",
"getOid",
"(",
")",
",",
"localtype",
")",
";",
"}"
] | Adds an additional object via which chat messages may arrive. The chat director assumes the
caller will be managing the subscription to this object and will remain subscribed to it for
as long as it remains in effect as an auxiliary chat source.
@param localtype a type to be associated with all chat messages that arrive on the specified
DObject. | [
"Adds",
"an",
"additional",
"object",
"via",
"which",
"chat",
"messages",
"may",
"arrive",
".",
"The",
"chat",
"director",
"assumes",
"the",
"caller",
"will",
"be",
"managing",
"the",
"subscription",
"to",
"this",
"object",
"and",
"will",
"remain",
"subscribed",
"to",
"it",
"for",
"as",
"long",
"as",
"it",
"remains",
"in",
"effect",
"as",
"an",
"auxiliary",
"chat",
"source",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/client/ChatDirector.java#L585-L589 |
Alluxio/alluxio | core/common/src/main/java/alluxio/grpc/GrpcManagedChannelPool.java | GrpcManagedChannelPool.releaseManagedChannel | public void releaseManagedChannel(ChannelKey channelKey, long shutdownTimeoutMs) {
"""
Decreases the ref-count of the {@link ManagedChannel} for the given address.
It shuts down and releases the {@link ManagedChannel} if reference count reaches zero.
@param channelKey host address
@param shutdownTimeoutMs shutdown timeout in milliseconds
"""
boolean shutdownManagedChannel;
try (LockResource lockShared = new LockResource(mLock.readLock())) {
Verify.verify(mChannels.containsKey(channelKey));
ManagedChannelReference channelRef = mChannels.get(channelKey);
channelRef.dereference();
shutdownManagedChannel = channelRef.getRefCount() <= 0;
LOG.debug("Released managed channel for: {}. Ref-count: {}", channelKey,
channelRef.getRefCount());
}
if (shutdownManagedChannel) {
try (LockResource lockExclusive = new LockResource(mLock.writeLock())) {
if (mChannels.containsKey(channelKey)) {
ManagedChannelReference channelRef = mChannels.get(channelKey);
if (channelRef.getRefCount() <= 0) {
shutdownManagedChannel(channelKey, shutdownTimeoutMs);
}
}
}
}
} | java | public void releaseManagedChannel(ChannelKey channelKey, long shutdownTimeoutMs) {
boolean shutdownManagedChannel;
try (LockResource lockShared = new LockResource(mLock.readLock())) {
Verify.verify(mChannels.containsKey(channelKey));
ManagedChannelReference channelRef = mChannels.get(channelKey);
channelRef.dereference();
shutdownManagedChannel = channelRef.getRefCount() <= 0;
LOG.debug("Released managed channel for: {}. Ref-count: {}", channelKey,
channelRef.getRefCount());
}
if (shutdownManagedChannel) {
try (LockResource lockExclusive = new LockResource(mLock.writeLock())) {
if (mChannels.containsKey(channelKey)) {
ManagedChannelReference channelRef = mChannels.get(channelKey);
if (channelRef.getRefCount() <= 0) {
shutdownManagedChannel(channelKey, shutdownTimeoutMs);
}
}
}
}
} | [
"public",
"void",
"releaseManagedChannel",
"(",
"ChannelKey",
"channelKey",
",",
"long",
"shutdownTimeoutMs",
")",
"{",
"boolean",
"shutdownManagedChannel",
";",
"try",
"(",
"LockResource",
"lockShared",
"=",
"new",
"LockResource",
"(",
"mLock",
".",
"readLock",
"(",
")",
")",
")",
"{",
"Verify",
".",
"verify",
"(",
"mChannels",
".",
"containsKey",
"(",
"channelKey",
")",
")",
";",
"ManagedChannelReference",
"channelRef",
"=",
"mChannels",
".",
"get",
"(",
"channelKey",
")",
";",
"channelRef",
".",
"dereference",
"(",
")",
";",
"shutdownManagedChannel",
"=",
"channelRef",
".",
"getRefCount",
"(",
")",
"<=",
"0",
";",
"LOG",
".",
"debug",
"(",
"\"Released managed channel for: {}. Ref-count: {}\"",
",",
"channelKey",
",",
"channelRef",
".",
"getRefCount",
"(",
")",
")",
";",
"}",
"if",
"(",
"shutdownManagedChannel",
")",
"{",
"try",
"(",
"LockResource",
"lockExclusive",
"=",
"new",
"LockResource",
"(",
"mLock",
".",
"writeLock",
"(",
")",
")",
")",
"{",
"if",
"(",
"mChannels",
".",
"containsKey",
"(",
"channelKey",
")",
")",
"{",
"ManagedChannelReference",
"channelRef",
"=",
"mChannels",
".",
"get",
"(",
"channelKey",
")",
";",
"if",
"(",
"channelRef",
".",
"getRefCount",
"(",
")",
"<=",
"0",
")",
"{",
"shutdownManagedChannel",
"(",
"channelKey",
",",
"shutdownTimeoutMs",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Decreases the ref-count of the {@link ManagedChannel} for the given address.
It shuts down and releases the {@link ManagedChannel} if reference count reaches zero.
@param channelKey host address
@param shutdownTimeoutMs shutdown timeout in milliseconds | [
"Decreases",
"the",
"ref",
"-",
"count",
"of",
"the",
"{",
"@link",
"ManagedChannel",
"}",
"for",
"the",
"given",
"address",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcManagedChannelPool.java#L192-L212 |
hawkular/hawkular-inventory | hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/filters/Related.java | Related.asTargetWith | public static Related asTargetWith(CanonicalPath entityPath, String relationship) {
"""
Specifies a filter for entities that are targets of a relationship with the specified entity.
@param entityPath the entity that is the source of the relationship
@param relationship the name of the relationship
@return a new "related" filter instance
"""
return new Related(entityPath, relationship, EntityRole.TARGET);
} | java | public static Related asTargetWith(CanonicalPath entityPath, String relationship) {
return new Related(entityPath, relationship, EntityRole.TARGET);
} | [
"public",
"static",
"Related",
"asTargetWith",
"(",
"CanonicalPath",
"entityPath",
",",
"String",
"relationship",
")",
"{",
"return",
"new",
"Related",
"(",
"entityPath",
",",
"relationship",
",",
"EntityRole",
".",
"TARGET",
")",
";",
"}"
] | Specifies a filter for entities that are targets of a relationship with the specified entity.
@param entityPath the entity that is the source of the relationship
@param relationship the name of the relationship
@return a new "related" filter instance | [
"Specifies",
"a",
"filter",
"for",
"entities",
"that",
"are",
"targets",
"of",
"a",
"relationship",
"with",
"the",
"specified",
"entity",
"."
] | train | https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/filters/Related.java#L100-L102 |
antopen/alipay-sdk-java | src/main/java/com/alipay/api/internal/util/XmlUtils.java | XmlUtils.appendElement | public static void appendElement(Element parent, Element child) {
"""
Appends another element as a child element.
@param parent the parent element
@param child the child element to append
"""
Node tmp = parent.getOwnerDocument().importNode(child, true);
parent.appendChild(tmp);
} | java | public static void appendElement(Element parent, Element child) {
Node tmp = parent.getOwnerDocument().importNode(child, true);
parent.appendChild(tmp);
} | [
"public",
"static",
"void",
"appendElement",
"(",
"Element",
"parent",
",",
"Element",
"child",
")",
"{",
"Node",
"tmp",
"=",
"parent",
".",
"getOwnerDocument",
"(",
")",
".",
"importNode",
"(",
"child",
",",
"true",
")",
";",
"parent",
".",
"appendChild",
"(",
"tmp",
")",
";",
"}"
] | Appends another element as a child element.
@param parent the parent element
@param child the child element to append | [
"Appends",
"another",
"element",
"as",
"a",
"child",
"element",
"."
] | train | https://github.com/antopen/alipay-sdk-java/blob/e82aeac7d0239330ee173c7e393596e51e41c1cd/src/main/java/com/alipay/api/internal/util/XmlUtils.java#L376-L379 |
amlinv/amq-monitor | amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java | ActiveMQQueueJmxStats.addCounts | public ActiveMQQueueJmxStats addCounts(ActiveMQQueueJmxStats other, String resultBrokerName) {
"""
Return a new queue stats structure with the total of the stats from this structure and the one given. Returning
a new structure keeps all three structures unchanged, in the manner of immutability, to make it easier to have
safe usage under concurrency. Note that non-count values are copied out from this instance; those values from
the given other stats are ignored.
@param other
@param resultBrokerName
@return
"""
ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats(resultBrokerName, this.queueName);
result.setCursorPercentUsage(this.getCursorPercentUsage());
result.setDequeueCount(this.getDequeueCount() + other.getDequeueCount());
result.setEnqueueCount(this.getEnqueueCount() + other.getEnqueueCount());
result.setMemoryPercentUsage(this.getMemoryPercentUsage());
result.setNumConsumers(this.getNumConsumers() + other.getNumConsumers());
result.setNumProducers(this.getNumProducers() + other.getNumProducers());
result.setQueueSize(this.getQueueSize() + other.getQueueSize());
result.setInflightCount(this.getInflightCount() + other.getInflightCount());
return result;
} | java | public ActiveMQQueueJmxStats addCounts(ActiveMQQueueJmxStats other, String resultBrokerName) {
ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats(resultBrokerName, this.queueName);
result.setCursorPercentUsage(this.getCursorPercentUsage());
result.setDequeueCount(this.getDequeueCount() + other.getDequeueCount());
result.setEnqueueCount(this.getEnqueueCount() + other.getEnqueueCount());
result.setMemoryPercentUsage(this.getMemoryPercentUsage());
result.setNumConsumers(this.getNumConsumers() + other.getNumConsumers());
result.setNumProducers(this.getNumProducers() + other.getNumProducers());
result.setQueueSize(this.getQueueSize() + other.getQueueSize());
result.setInflightCount(this.getInflightCount() + other.getInflightCount());
return result;
} | [
"public",
"ActiveMQQueueJmxStats",
"addCounts",
"(",
"ActiveMQQueueJmxStats",
"other",
",",
"String",
"resultBrokerName",
")",
"{",
"ActiveMQQueueJmxStats",
"result",
"=",
"new",
"ActiveMQQueueJmxStats",
"(",
"resultBrokerName",
",",
"this",
".",
"queueName",
")",
";",
"result",
".",
"setCursorPercentUsage",
"(",
"this",
".",
"getCursorPercentUsage",
"(",
")",
")",
";",
"result",
".",
"setDequeueCount",
"(",
"this",
".",
"getDequeueCount",
"(",
")",
"+",
"other",
".",
"getDequeueCount",
"(",
")",
")",
";",
"result",
".",
"setEnqueueCount",
"(",
"this",
".",
"getEnqueueCount",
"(",
")",
"+",
"other",
".",
"getEnqueueCount",
"(",
")",
")",
";",
"result",
".",
"setMemoryPercentUsage",
"(",
"this",
".",
"getMemoryPercentUsage",
"(",
")",
")",
";",
"result",
".",
"setNumConsumers",
"(",
"this",
".",
"getNumConsumers",
"(",
")",
"+",
"other",
".",
"getNumConsumers",
"(",
")",
")",
";",
"result",
".",
"setNumProducers",
"(",
"this",
".",
"getNumProducers",
"(",
")",
"+",
"other",
".",
"getNumProducers",
"(",
")",
")",
";",
"result",
".",
"setQueueSize",
"(",
"this",
".",
"getQueueSize",
"(",
")",
"+",
"other",
".",
"getQueueSize",
"(",
")",
")",
";",
"result",
".",
"setInflightCount",
"(",
"this",
".",
"getInflightCount",
"(",
")",
"+",
"other",
".",
"getInflightCount",
"(",
")",
")",
";",
"return",
"result",
";",
"}"
] | Return a new queue stats structure with the total of the stats from this structure and the one given. Returning
a new structure keeps all three structures unchanged, in the manner of immutability, to make it easier to have
safe usage under concurrency. Note that non-count values are copied out from this instance; those values from
the given other stats are ignored.
@param other
@param resultBrokerName
@return | [
"Return",
"a",
"new",
"queue",
"stats",
"structure",
"with",
"the",
"total",
"of",
"the",
"stats",
"from",
"this",
"structure",
"and",
"the",
"one",
"given",
".",
"Returning",
"a",
"new",
"structure",
"keeps",
"all",
"three",
"structures",
"unchanged",
"in",
"the",
"manner",
"of",
"immutability",
"to",
"make",
"it",
"easier",
"to",
"have",
"safe",
"usage",
"under",
"concurrency",
".",
"Note",
"that",
"non",
"-",
"count",
"values",
"are",
"copied",
"out",
"from",
"this",
"instance",
";",
"those",
"values",
"from",
"the",
"given",
"other",
"stats",
"are",
"ignored",
"."
] | train | https://github.com/amlinv/amq-monitor/blob/0ae0156f56d7d3edf98bca9c30b153b770fe5bfa/amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java#L146-L158 |
litsec/swedish-eid-shibboleth-base | shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/ProxyIdpAuthnContextServiceImpl.java | ProxyIdpAuthnContextServiceImpl.isSupported | protected boolean isSupported(ProfileRequestContext<?, ?> context, String uri, List<String> assuranceURIs) {
"""
A Proxy-IdP may communicate with an IdP that uses different URI declarations for the same type of authentication
methods, e.g., the Swedish eID framework and eIDAS has different URI:s for the same type of authentication. This
method will enable tranformation of URI:s and provide the possibility to match URI:s from different schemes.
<p>
The default implementation just checks if the supplied {@code uri} is part of the {@code assuranceURIs} list. To
implement different behaviour override this method.
</p>
@param context
the request context
@param uri
the URI to test
@param assuranceURIs
IdP assurance certification URI:s
@return {@code true} if there is a match, and {@code false} otherwise
"""
return assuranceURIs.contains(uri);
} | java | protected boolean isSupported(ProfileRequestContext<?, ?> context, String uri, List<String> assuranceURIs) {
return assuranceURIs.contains(uri);
} | [
"protected",
"boolean",
"isSupported",
"(",
"ProfileRequestContext",
"<",
"?",
",",
"?",
">",
"context",
",",
"String",
"uri",
",",
"List",
"<",
"String",
">",
"assuranceURIs",
")",
"{",
"return",
"assuranceURIs",
".",
"contains",
"(",
"uri",
")",
";",
"}"
] | A Proxy-IdP may communicate with an IdP that uses different URI declarations for the same type of authentication
methods, e.g., the Swedish eID framework and eIDAS has different URI:s for the same type of authentication. This
method will enable tranformation of URI:s and provide the possibility to match URI:s from different schemes.
<p>
The default implementation just checks if the supplied {@code uri} is part of the {@code assuranceURIs} list. To
implement different behaviour override this method.
</p>
@param context
the request context
@param uri
the URI to test
@param assuranceURIs
IdP assurance certification URI:s
@return {@code true} if there is a match, and {@code false} otherwise | [
"A",
"Proxy",
"-",
"IdP",
"may",
"communicate",
"with",
"an",
"IdP",
"that",
"uses",
"different",
"URI",
"declarations",
"for",
"the",
"same",
"type",
"of",
"authentication",
"methods",
"e",
".",
"g",
".",
"the",
"Swedish",
"eID",
"framework",
"and",
"eIDAS",
"has",
"different",
"URI",
":",
"s",
"for",
"the",
"same",
"type",
"of",
"authentication",
".",
"This",
"method",
"will",
"enable",
"tranformation",
"of",
"URI",
":",
"s",
"and",
"provide",
"the",
"possibility",
"to",
"match",
"URI",
":",
"s",
"from",
"different",
"schemes",
".",
"<p",
">",
"The",
"default",
"implementation",
"just",
"checks",
"if",
"the",
"supplied",
"{",
"@code",
"uri",
"}",
"is",
"part",
"of",
"the",
"{",
"@code",
"assuranceURIs",
"}",
"list",
".",
"To",
"implement",
"different",
"behaviour",
"override",
"this",
"method",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/litsec/swedish-eid-shibboleth-base/blob/aaaa467ff61f07d7dfa31627fb36851a37da6804/shibboleth-base/shibboleth-extensions/src/main/java/se/litsec/shibboleth/idp/authn/service/impl/ProxyIdpAuthnContextServiceImpl.java#L130-L132 |
Alluxio/alluxio | core/base/src/main/java/alluxio/AlluxioURI.java | AlluxioURI.hasWindowsDrive | public static boolean hasWindowsDrive(String path, boolean slashed) {
"""
Checks if the path is a windows path. This should be platform independent.
@param path the path to check
@param slashed if the path starts with a slash
@return true if it is a windows path, false otherwise
"""
int start = slashed ? 1 : 0;
return path.length() >= start + 2
&& (!slashed || path.charAt(0) == '/')
&& path.charAt(start + 1) == ':'
&& ((path.charAt(start) >= 'A' && path.charAt(start) <= 'Z') || (path.charAt(start) >= 'a'
&& path.charAt(start) <= 'z'));
} | java | public static boolean hasWindowsDrive(String path, boolean slashed) {
int start = slashed ? 1 : 0;
return path.length() >= start + 2
&& (!slashed || path.charAt(0) == '/')
&& path.charAt(start + 1) == ':'
&& ((path.charAt(start) >= 'A' && path.charAt(start) <= 'Z') || (path.charAt(start) >= 'a'
&& path.charAt(start) <= 'z'));
} | [
"public",
"static",
"boolean",
"hasWindowsDrive",
"(",
"String",
"path",
",",
"boolean",
"slashed",
")",
"{",
"int",
"start",
"=",
"slashed",
"?",
"1",
":",
"0",
";",
"return",
"path",
".",
"length",
"(",
")",
">=",
"start",
"+",
"2",
"&&",
"(",
"!",
"slashed",
"||",
"path",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"&&",
"path",
".",
"charAt",
"(",
"start",
"+",
"1",
")",
"==",
"'",
"'",
"&&",
"(",
"(",
"path",
".",
"charAt",
"(",
"start",
")",
">=",
"'",
"'",
"&&",
"path",
".",
"charAt",
"(",
"start",
")",
"<=",
"'",
"'",
")",
"||",
"(",
"path",
".",
"charAt",
"(",
"start",
")",
">=",
"'",
"'",
"&&",
"path",
".",
"charAt",
"(",
"start",
")",
"<=",
"'",
"'",
")",
")",
";",
"}"
] | Checks if the path is a windows path. This should be platform independent.
@param path the path to check
@param slashed if the path starts with a slash
@return true if it is a windows path, false otherwise | [
"Checks",
"if",
"the",
"path",
"is",
"a",
"windows",
"path",
".",
"This",
"should",
"be",
"platform",
"independent",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/AlluxioURI.java#L335-L342 |
rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/GitSettings.java | GitSettings.setIdentity | public void setIdentity(String name, String email) {
"""
Sets the name and email for the Git commands user
@param name The Git user's name
@param email The Git user's email
"""
if (GitTaskUtils.isNullOrBlankString(name) || GitTaskUtils.isNullOrBlankString(email)) {
throw new IllegalArgumentException("Both the username and password must be provided.");
}
identity = new PersonIdent(name, email);
} | java | public void setIdentity(String name, String email) {
if (GitTaskUtils.isNullOrBlankString(name) || GitTaskUtils.isNullOrBlankString(email)) {
throw new IllegalArgumentException("Both the username and password must be provided.");
}
identity = new PersonIdent(name, email);
} | [
"public",
"void",
"setIdentity",
"(",
"String",
"name",
",",
"String",
"email",
")",
"{",
"if",
"(",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"name",
")",
"||",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"email",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Both the username and password must be provided.\"",
")",
";",
"}",
"identity",
"=",
"new",
"PersonIdent",
"(",
"name",
",",
"email",
")",
";",
"}"
] | Sets the name and email for the Git commands user
@param name The Git user's name
@param email The Git user's email | [
"Sets",
"the",
"name",
"and",
"email",
"for",
"the",
"Git",
"commands",
"user"
] | train | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/GitSettings.java#L52-L58 |
trellis-ldp/trellis | components/constraint-rules/src/main/java/org/trellisldp/constraint/LdpConstraints.java | LdpConstraints.violatesCardinality | private static boolean violatesCardinality(final Graph graph, final IRI model) {
"""
Verify that the cardinality of the `propertiesWithUriRange` properties. Keep any whose cardinality is > 1
"""
final boolean isIndirect = LDP.IndirectContainer.equals(model);
return isIndirect && (!graph.contains(null, LDP.insertedContentRelation, null) || !hasMembershipProps(graph))
|| !isIndirect && LDP.DirectContainer.equals(model) && !hasMembershipProps(graph)
|| propertiesWithUriRange.stream().anyMatch(p -> graph.stream(null, p, null).count() > 1);
} | java | private static boolean violatesCardinality(final Graph graph, final IRI model) {
final boolean isIndirect = LDP.IndirectContainer.equals(model);
return isIndirect && (!graph.contains(null, LDP.insertedContentRelation, null) || !hasMembershipProps(graph))
|| !isIndirect && LDP.DirectContainer.equals(model) && !hasMembershipProps(graph)
|| propertiesWithUriRange.stream().anyMatch(p -> graph.stream(null, p, null).count() > 1);
} | [
"private",
"static",
"boolean",
"violatesCardinality",
"(",
"final",
"Graph",
"graph",
",",
"final",
"IRI",
"model",
")",
"{",
"final",
"boolean",
"isIndirect",
"=",
"LDP",
".",
"IndirectContainer",
".",
"equals",
"(",
"model",
")",
";",
"return",
"isIndirect",
"&&",
"(",
"!",
"graph",
".",
"contains",
"(",
"null",
",",
"LDP",
".",
"insertedContentRelation",
",",
"null",
")",
"||",
"!",
"hasMembershipProps",
"(",
"graph",
")",
")",
"||",
"!",
"isIndirect",
"&&",
"LDP",
".",
"DirectContainer",
".",
"equals",
"(",
"model",
")",
"&&",
"!",
"hasMembershipProps",
"(",
"graph",
")",
"||",
"propertiesWithUriRange",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"p",
"->",
"graph",
".",
"stream",
"(",
"null",
",",
"p",
",",
"null",
")",
".",
"count",
"(",
")",
">",
"1",
")",
";",
"}"
] | Verify that the cardinality of the `propertiesWithUriRange` properties. Keep any whose cardinality is > 1 | [
"Verify",
"that",
"the",
"cardinality",
"of",
"the",
"propertiesWithUriRange",
"properties",
".",
"Keep",
"any",
"whose",
"cardinality",
"is",
">",
"1"
] | train | https://github.com/trellis-ldp/trellis/blob/789fd7a3df86cab7ebba63e72bf4e58397e5f42d/components/constraint-rules/src/main/java/org/trellisldp/constraint/LdpConstraints.java#L139-L144 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java | ApiOvhDedicatedserver.serviceName_ipCanBeMovedTo_GET | public void serviceName_ipCanBeMovedTo_GET(String serviceName, String ip) throws IOException {
"""
Check if given IP can be moved to this server
REST: GET /dedicated/server/{serviceName}/ipCanBeMovedTo
@param ip [required] The ip to move to this server
@param serviceName [required] The internal name of your dedicated server
"""
String qPath = "/dedicated/server/{serviceName}/ipCanBeMovedTo";
StringBuilder sb = path(qPath, serviceName);
query(sb, "ip", ip);
exec(qPath, "GET", sb.toString(), null);
} | java | public void serviceName_ipCanBeMovedTo_GET(String serviceName, String ip) throws IOException {
String qPath = "/dedicated/server/{serviceName}/ipCanBeMovedTo";
StringBuilder sb = path(qPath, serviceName);
query(sb, "ip", ip);
exec(qPath, "GET", sb.toString(), null);
} | [
"public",
"void",
"serviceName_ipCanBeMovedTo_GET",
"(",
"String",
"serviceName",
",",
"String",
"ip",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/ipCanBeMovedTo\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"ip\"",
",",
"ip",
")",
";",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Check if given IP can be moved to this server
REST: GET /dedicated/server/{serviceName}/ipCanBeMovedTo
@param ip [required] The ip to move to this server
@param serviceName [required] The internal name of your dedicated server | [
"Check",
"if",
"given",
"IP",
"can",
"be",
"moved",
"to",
"this",
"server"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L1920-L1925 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/internal/provisioning/api/OptionsApi.java | OptionsApi.optionsPostAsync | public com.squareup.okhttp.Call optionsPostAsync(OptionsPost body, final ApiCallback<OptionsPostResponseStatusSuccess> callback) throws ApiException {
"""
Replace old options with new. (asynchronously)
The POST operation will replace CloudCluster/Options with new values
@param body Body Data (required)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
"""
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = optionsPostValidateBeforeCall(body, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<OptionsPostResponseStatusSuccess>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | java | public com.squareup.okhttp.Call optionsPostAsync(OptionsPost body, final ApiCallback<OptionsPostResponseStatusSuccess> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = optionsPostValidateBeforeCall(body, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<OptionsPostResponseStatusSuccess>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"optionsPostAsync",
"(",
"OptionsPost",
"body",
",",
"final",
"ApiCallback",
"<",
"OptionsPostResponseStatusSuccess",
">",
"callback",
")",
"throws",
"ApiException",
"{",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
"=",
"null",
";",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
"=",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"progressListener",
"=",
"new",
"ProgressResponseBody",
".",
"ProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"long",
"bytesRead",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onDownloadProgress",
"(",
"bytesRead",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"progressRequestListener",
"=",
"new",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onRequestProgress",
"(",
"long",
"bytesWritten",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onUploadProgress",
"(",
"bytesWritten",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"optionsPostValidateBeforeCall",
"(",
"body",
",",
"progressListener",
",",
"progressRequestListener",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"OptionsPostResponseStatusSuccess",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"apiClient",
".",
"executeAsync",
"(",
"call",
",",
"localVarReturnType",
",",
"callback",
")",
";",
"return",
"call",
";",
"}"
] | Replace old options with new. (asynchronously)
The POST operation will replace CloudCluster/Options with new values
@param body Body Data (required)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object | [
"Replace",
"old",
"options",
"with",
"new",
".",
"(",
"asynchronously",
")",
"The",
"POST",
"operation",
"will",
"replace",
"CloudCluster",
"/",
"Options",
"with",
"new",
"values"
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/OptionsApi.java#L285-L310 |
Subsets and Splits