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
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/protocol/LocatedBlocks.java | LocatedBlocks.setLastBlockSize | public synchronized void setLastBlockSize(long blockId, long blockSize) {
"""
If file is under construction, set block size of the last block. It updates
file length in the same time.
"""
assert blocks.size() > 0;
LocatedBlock last = blocks.get(blocks.size() - 1);
if (underConstruction && blockSize > last.getBlockSize()) {
assert blockId == last.getBlock().getBlockId();
this.setFileLength(this.getFileLength() + blockSize - last.getBlockSize());
last.setBlockSize(blockSize);
if (LOG.isDebugEnabled()) {
LOG.debug("DFSClient setting last block " + last + " to length "
+ blockSize + " filesize is now " + getFileLength());
}
}
} | java | public synchronized void setLastBlockSize(long blockId, long blockSize) {
assert blocks.size() > 0;
LocatedBlock last = blocks.get(blocks.size() - 1);
if (underConstruction && blockSize > last.getBlockSize()) {
assert blockId == last.getBlock().getBlockId();
this.setFileLength(this.getFileLength() + blockSize - last.getBlockSize());
last.setBlockSize(blockSize);
if (LOG.isDebugEnabled()) {
LOG.debug("DFSClient setting last block " + last + " to length "
+ blockSize + " filesize is now " + getFileLength());
}
}
} | [
"public",
"synchronized",
"void",
"setLastBlockSize",
"(",
"long",
"blockId",
",",
"long",
"blockSize",
")",
"{",
"assert",
"blocks",
".",
"size",
"(",
")",
">",
"0",
";",
"LocatedBlock",
"last",
"=",
"blocks",
".",
"get",
"(",
"blocks",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"underConstruction",
"&&",
"blockSize",
">",
"last",
".",
"getBlockSize",
"(",
")",
")",
"{",
"assert",
"blockId",
"==",
"last",
".",
"getBlock",
"(",
")",
".",
"getBlockId",
"(",
")",
";",
"this",
".",
"setFileLength",
"(",
"this",
".",
"getFileLength",
"(",
")",
"+",
"blockSize",
"-",
"last",
".",
"getBlockSize",
"(",
")",
")",
";",
"last",
".",
"setBlockSize",
"(",
"blockSize",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"DFSClient setting last block \"",
"+",
"last",
"+",
"\" to length \"",
"+",
"blockSize",
"+",
"\" filesize is now \"",
"+",
"getFileLength",
"(",
")",
")",
";",
"}",
"}",
"}"
]
| If file is under construction, set block size of the last block. It updates
file length in the same time. | [
"If",
"file",
"is",
"under",
"construction",
"set",
"block",
"size",
"of",
"the",
"last",
"block",
".",
"It",
"updates",
"file",
"length",
"in",
"the",
"same",
"time",
"."
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/protocol/LocatedBlocks.java#L132-L145 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.findIndexValues | public static <T> List<Number> findIndexValues(T[] self, @ClosureParams(FirstParam.Component.class) Closure condition) {
"""
Iterates over the elements of an Array and returns
the index values of the items that match the condition specified in the closure.
@param self an Array
@param condition the matching condition
@return a list of numbers corresponding to the index values of all matched objects
@since 2.5.0
"""
return findIndexValues(self, 0, condition);
} | java | public static <T> List<Number> findIndexValues(T[] self, @ClosureParams(FirstParam.Component.class) Closure condition) {
return findIndexValues(self, 0, condition);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"Number",
">",
"findIndexValues",
"(",
"T",
"[",
"]",
"self",
",",
"@",
"ClosureParams",
"(",
"FirstParam",
".",
"Component",
".",
"class",
")",
"Closure",
"condition",
")",
"{",
"return",
"findIndexValues",
"(",
"self",
",",
"0",
",",
"condition",
")",
";",
"}"
]
| Iterates over the elements of an Array and returns
the index values of the items that match the condition specified in the closure.
@param self an Array
@param condition the matching condition
@return a list of numbers corresponding to the index values of all matched objects
@since 2.5.0 | [
"Iterates",
"over",
"the",
"elements",
"of",
"an",
"Array",
"and",
"returns",
"the",
"index",
"values",
"of",
"the",
"items",
"that",
"match",
"the",
"condition",
"specified",
"in",
"the",
"closure",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L17041-L17043 |
Alluxio/alluxio | core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournal.java | UfsJournal.losePrimacy | public synchronized void losePrimacy() throws IOException {
"""
Transitions the journal from primary to secondary mode. The journal will no longer allow
writes, and the state machine is rebuilt from the journal and kept up to date.
"""
Preconditions.checkState(mState == State.PRIMARY, "unexpected state " + mState);
Preconditions.checkState(mWriter != null, "writer thread must not be null in primary mode");
Preconditions.checkState(mTailerThread == null, "tailer thread must be null in primary mode");
mWriter.close();
mWriter = null;
mAsyncWriter = null;
mMaster.resetState();
mTailerThread = new UfsJournalCheckpointThread(mMaster, this);
mTailerThread.start();
mState = State.SECONDARY;
} | java | public synchronized void losePrimacy() throws IOException {
Preconditions.checkState(mState == State.PRIMARY, "unexpected state " + mState);
Preconditions.checkState(mWriter != null, "writer thread must not be null in primary mode");
Preconditions.checkState(mTailerThread == null, "tailer thread must be null in primary mode");
mWriter.close();
mWriter = null;
mAsyncWriter = null;
mMaster.resetState();
mTailerThread = new UfsJournalCheckpointThread(mMaster, this);
mTailerThread.start();
mState = State.SECONDARY;
} | [
"public",
"synchronized",
"void",
"losePrimacy",
"(",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mState",
"==",
"State",
".",
"PRIMARY",
",",
"\"unexpected state \"",
"+",
"mState",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mWriter",
"!=",
"null",
",",
"\"writer thread must not be null in primary mode\"",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mTailerThread",
"==",
"null",
",",
"\"tailer thread must be null in primary mode\"",
")",
";",
"mWriter",
".",
"close",
"(",
")",
";",
"mWriter",
"=",
"null",
";",
"mAsyncWriter",
"=",
"null",
";",
"mMaster",
".",
"resetState",
"(",
")",
";",
"mTailerThread",
"=",
"new",
"UfsJournalCheckpointThread",
"(",
"mMaster",
",",
"this",
")",
";",
"mTailerThread",
".",
"start",
"(",
")",
";",
"mState",
"=",
"State",
".",
"SECONDARY",
";",
"}"
]
| Transitions the journal from primary to secondary mode. The journal will no longer allow
writes, and the state machine is rebuilt from the journal and kept up to date. | [
"Transitions",
"the",
"journal",
"from",
"primary",
"to",
"secondary",
"mode",
".",
"The",
"journal",
"will",
"no",
"longer",
"allow",
"writes",
"and",
"the",
"state",
"machine",
"is",
"rebuilt",
"from",
"the",
"journal",
"and",
"kept",
"up",
"to",
"date",
"."
]
| train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournal.java#L220-L231 |
carewebframework/carewebframework-vista | org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java | ESigList.fireEvent | private void fireEvent(String action, ESigItem item) {
"""
Notifies subscribers of changes to the list by firing an ESIG.[action] event.
@param action Name of the action. This becomes a subtype of the ESIG event.
@param item The item for which the action occurred.
"""
if (eventManager != null) {
eventManager.fireLocalEvent("ESIG." + action, item);
}
} | java | private void fireEvent(String action, ESigItem item) {
if (eventManager != null) {
eventManager.fireLocalEvent("ESIG." + action, item);
}
} | [
"private",
"void",
"fireEvent",
"(",
"String",
"action",
",",
"ESigItem",
"item",
")",
"{",
"if",
"(",
"eventManager",
"!=",
"null",
")",
"{",
"eventManager",
".",
"fireLocalEvent",
"(",
"\"ESIG.\"",
"+",
"action",
",",
"item",
")",
";",
"}",
"}"
]
| Notifies subscribers of changes to the list by firing an ESIG.[action] event.
@param action Name of the action. This becomes a subtype of the ESIG event.
@param item The item for which the action occurred. | [
"Notifies",
"subscribers",
"of",
"changes",
"to",
"the",
"list",
"by",
"firing",
"an",
"ESIG",
".",
"[",
"action",
"]",
"event",
"."
]
| train | https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java#L212-L216 |
aol/cyclops | cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java | ExceptionSoftener.throwIf | public static <X extends Throwable> void throwIf(final X e, final Predicate<X> p) {
"""
Throw the exception as upwards if the predicate holds, otherwise do nothing
@param e Exception
@param p Predicate to check exception should be thrown or not
"""
if (p.test(e))
throw ExceptionSoftener.<RuntimeException> uncheck(e);
} | java | public static <X extends Throwable> void throwIf(final X e, final Predicate<X> p) {
if (p.test(e))
throw ExceptionSoftener.<RuntimeException> uncheck(e);
} | [
"public",
"static",
"<",
"X",
"extends",
"Throwable",
">",
"void",
"throwIf",
"(",
"final",
"X",
"e",
",",
"final",
"Predicate",
"<",
"X",
">",
"p",
")",
"{",
"if",
"(",
"p",
".",
"test",
"(",
"e",
")",
")",
"throw",
"ExceptionSoftener",
".",
"<",
"RuntimeException",
">",
"uncheck",
"(",
"e",
")",
";",
"}"
]
| Throw the exception as upwards if the predicate holds, otherwise do nothing
@param e Exception
@param p Predicate to check exception should be thrown or not | [
"Throw",
"the",
"exception",
"as",
"upwards",
"if",
"the",
"predicate",
"holds",
"otherwise",
"do",
"nothing"
]
| train | https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L680-L683 |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/internaleventdispatching/AgentInternalEventsDispatcher.java | AgentInternalEventsDispatcher.immediateDispatchTo | public void immediateDispatchTo(Object listener, Event event) {
"""
Posts an event to the registered {@code BehaviorGuardEvaluator} of the given listener only.
The dispatch of this event will be done synchronously.
This method will return successfully after the event has been posted to all {@code BehaviorGuardEvaluator}, and regardless
of any exceptions thrown by {@code BehaviorGuardEvaluator}.
@param listener the listener to dispatch to.
@param event an event to dispatch synchronously.
"""
assert event != null;
Iterable<BehaviorGuardEvaluator> behaviorGuardEvaluators = null;
synchronized (this.behaviorGuardEvaluatorRegistry) {
behaviorGuardEvaluators = AgentInternalEventsDispatcher.this.behaviorGuardEvaluatorRegistry
.getBehaviorGuardEvaluatorsFor(event, listener);
}
if (behaviorGuardEvaluators != null) {
final Collection<Runnable> behaviorsMethodsToExecute;
try {
behaviorsMethodsToExecute = evaluateGuards(event, behaviorGuardEvaluators);
executeBehaviorMethodsInParalellWithSynchroAtTheEnd(behaviorsMethodsToExecute);
} catch (RuntimeException exception) {
throw exception;
} catch (InterruptedException | ExecutionException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
} | java | public void immediateDispatchTo(Object listener, Event event) {
assert event != null;
Iterable<BehaviorGuardEvaluator> behaviorGuardEvaluators = null;
synchronized (this.behaviorGuardEvaluatorRegistry) {
behaviorGuardEvaluators = AgentInternalEventsDispatcher.this.behaviorGuardEvaluatorRegistry
.getBehaviorGuardEvaluatorsFor(event, listener);
}
if (behaviorGuardEvaluators != null) {
final Collection<Runnable> behaviorsMethodsToExecute;
try {
behaviorsMethodsToExecute = evaluateGuards(event, behaviorGuardEvaluators);
executeBehaviorMethodsInParalellWithSynchroAtTheEnd(behaviorsMethodsToExecute);
} catch (RuntimeException exception) {
throw exception;
} catch (InterruptedException | ExecutionException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
} | [
"public",
"void",
"immediateDispatchTo",
"(",
"Object",
"listener",
",",
"Event",
"event",
")",
"{",
"assert",
"event",
"!=",
"null",
";",
"Iterable",
"<",
"BehaviorGuardEvaluator",
">",
"behaviorGuardEvaluators",
"=",
"null",
";",
"synchronized",
"(",
"this",
".",
"behaviorGuardEvaluatorRegistry",
")",
"{",
"behaviorGuardEvaluators",
"=",
"AgentInternalEventsDispatcher",
".",
"this",
".",
"behaviorGuardEvaluatorRegistry",
".",
"getBehaviorGuardEvaluatorsFor",
"(",
"event",
",",
"listener",
")",
";",
"}",
"if",
"(",
"behaviorGuardEvaluators",
"!=",
"null",
")",
"{",
"final",
"Collection",
"<",
"Runnable",
">",
"behaviorsMethodsToExecute",
";",
"try",
"{",
"behaviorsMethodsToExecute",
"=",
"evaluateGuards",
"(",
"event",
",",
"behaviorGuardEvaluators",
")",
";",
"executeBehaviorMethodsInParalellWithSynchroAtTheEnd",
"(",
"behaviorsMethodsToExecute",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"exception",
")",
"{",
"throw",
"exception",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"ExecutionException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}"
]
| Posts an event to the registered {@code BehaviorGuardEvaluator} of the given listener only.
The dispatch of this event will be done synchronously.
This method will return successfully after the event has been posted to all {@code BehaviorGuardEvaluator}, and regardless
of any exceptions thrown by {@code BehaviorGuardEvaluator}.
@param listener the listener to dispatch to.
@param event an event to dispatch synchronously. | [
"Posts",
"an",
"event",
"to",
"the",
"registered",
"{",
"@code",
"BehaviorGuardEvaluator",
"}",
"of",
"the",
"given",
"listener",
"only",
".",
"The",
"dispatch",
"of",
"this",
"event",
"will",
"be",
"done",
"synchronously",
".",
"This",
"method",
"will",
"return",
"successfully",
"after",
"the",
"event",
"has",
"been",
"posted",
"to",
"all",
"{",
"@code",
"BehaviorGuardEvaluator",
"}",
"and",
"regardless",
"of",
"any",
"exceptions",
"thrown",
"by",
"{",
"@code",
"BehaviorGuardEvaluator",
"}",
"."
]
| train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/internaleventdispatching/AgentInternalEventsDispatcher.java#L187-L206 |
dmfs/xmlobjects | src/org/dmfs/xmlobjects/serializer/XmlObjectSerializer.java | XmlObjectSerializer.setOutput | public XmlObjectSerializer setOutput(SerializerContext serializerContext, Writer out) throws SerializerException, IOException {
"""
Set the output of the serializer.
@param serializerContext
A {@link SerializerContext}.
@param out
The {@link Writer} to write to.
@return
@throws SerializerException
@throws IOException
"""
try
{
serializerContext.serializer.setOutput(out);
}
catch (IllegalArgumentException e)
{
throw new SerializerException("can't configure serializer", e);
}
catch (IllegalStateException e)
{
throw new SerializerException("can't configure serializer", e);
}
return this;
} | java | public XmlObjectSerializer setOutput(SerializerContext serializerContext, Writer out) throws SerializerException, IOException
{
try
{
serializerContext.serializer.setOutput(out);
}
catch (IllegalArgumentException e)
{
throw new SerializerException("can't configure serializer", e);
}
catch (IllegalStateException e)
{
throw new SerializerException("can't configure serializer", e);
}
return this;
} | [
"public",
"XmlObjectSerializer",
"setOutput",
"(",
"SerializerContext",
"serializerContext",
",",
"Writer",
"out",
")",
"throws",
"SerializerException",
",",
"IOException",
"{",
"try",
"{",
"serializerContext",
".",
"serializer",
".",
"setOutput",
"(",
"out",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"SerializerException",
"(",
"\"can't configure serializer\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"throw",
"new",
"SerializerException",
"(",
"\"can't configure serializer\"",
",",
"e",
")",
";",
"}",
"return",
"this",
";",
"}"
]
| Set the output of the serializer.
@param serializerContext
A {@link SerializerContext}.
@param out
The {@link Writer} to write to.
@return
@throws SerializerException
@throws IOException | [
"Set",
"the",
"output",
"of",
"the",
"serializer",
"."
]
| train | https://github.com/dmfs/xmlobjects/blob/b68ddd0ce994d804fc2ec6da1096bf0d883b37f9/src/org/dmfs/xmlobjects/serializer/XmlObjectSerializer.java#L190-L205 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableUpdater.java | CollidableUpdater.getMirror | private static Mirror getMirror(FeatureProvider provider, Collision collision) {
"""
Get the collision mirror.
@param provider The provider owner.
@param collision The collision reference.
@return The collision mirror, {@link Mirror#NONE} if undefined.
"""
if (collision.hasMirror() && provider.hasFeature(Mirrorable.class))
{
return provider.getFeature(Mirrorable.class).getMirror();
}
return Mirror.NONE;
} | java | private static Mirror getMirror(FeatureProvider provider, Collision collision)
{
if (collision.hasMirror() && provider.hasFeature(Mirrorable.class))
{
return provider.getFeature(Mirrorable.class).getMirror();
}
return Mirror.NONE;
} | [
"private",
"static",
"Mirror",
"getMirror",
"(",
"FeatureProvider",
"provider",
",",
"Collision",
"collision",
")",
"{",
"if",
"(",
"collision",
".",
"hasMirror",
"(",
")",
"&&",
"provider",
".",
"hasFeature",
"(",
"Mirrorable",
".",
"class",
")",
")",
"{",
"return",
"provider",
".",
"getFeature",
"(",
"Mirrorable",
".",
"class",
")",
".",
"getMirror",
"(",
")",
";",
"}",
"return",
"Mirror",
".",
"NONE",
";",
"}"
]
| Get the collision mirror.
@param provider The provider owner.
@param collision The collision reference.
@return The collision mirror, {@link Mirror#NONE} if undefined. | [
"Get",
"the",
"collision",
"mirror",
"."
]
| train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableUpdater.java#L124-L131 |
cloudant/sync-android | cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/CouchURIHelper.java | CouchURIHelper.queryAsString | private String queryAsString(Map<String, Object> query) {
"""
Joins the entries in a map into a URL-encoded query string.
@param query map containing query params
@return joined, URL-encoded query params
"""
ArrayList<String> queryParts = new ArrayList<String>(query.size());
for(Map.Entry<String, Object> entry : query.entrySet()) {
String value = this.encodeQueryParameter(entry.getValue().toString());
String key = this.encodeQueryParameter(entry.getKey());
String term = String.format("%s=%s", key, value);
queryParts.add(term);
}
return Misc.join("&", queryParts);
} | java | private String queryAsString(Map<String, Object> query) {
ArrayList<String> queryParts = new ArrayList<String>(query.size());
for(Map.Entry<String, Object> entry : query.entrySet()) {
String value = this.encodeQueryParameter(entry.getValue().toString());
String key = this.encodeQueryParameter(entry.getKey());
String term = String.format("%s=%s", key, value);
queryParts.add(term);
}
return Misc.join("&", queryParts);
} | [
"private",
"String",
"queryAsString",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"query",
")",
"{",
"ArrayList",
"<",
"String",
">",
"queryParts",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"query",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"query",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"value",
"=",
"this",
".",
"encodeQueryParameter",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"String",
"key",
"=",
"this",
".",
"encodeQueryParameter",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"String",
"term",
"=",
"String",
".",
"format",
"(",
"\"%s=%s\"",
",",
"key",
",",
"value",
")",
";",
"queryParts",
".",
"add",
"(",
"term",
")",
";",
"}",
"return",
"Misc",
".",
"join",
"(",
"\"&\"",
",",
"queryParts",
")",
";",
"}"
]
| Joins the entries in a map into a URL-encoded query string.
@param query map containing query params
@return joined, URL-encoded query params | [
"Joins",
"the",
"entries",
"in",
"a",
"map",
"into",
"a",
"URL",
"-",
"encoded",
"query",
"string",
"."
]
| train | https://github.com/cloudant/sync-android/blob/5f1416ed1bd9ab05d7a4b8736480c8ae68bd7383/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/CouchURIHelper.java#L165-L174 |
haifengl/smile | core/src/main/java/smile/association/FPGrowth.java | FPGrowth.grow | private long grow(PrintStream out, List<ItemSet> list, TotalSupportTree ttree, FPTree fptree, int[] itemset) {
"""
Mines frequent item sets. Start with the bottom of the header table and
work upwards. For each available FP tree node:
<OL>
<LI> Count the support.
<LI> Build up item set sofar.
<LI> Add to supported sets.
<LI> Build a new FP tree: (i) create a new local root, (ii) create a
new local header table and (iii) populate with ancestors.
<LI> If new local FP tree is not empty repeat mining operation.
</OL>
Otherwise end.
@param itemset the current item sets as generated so far (null at start).
"""
long n = 0;
int[] prefixItemset = new int[T0.maxItemSetSize];
int[] localItemSupport = new int[T0.numItems];
// Loop through header table from end to start, item by item
for (int i = fptree.headerTable.length; i-- > 0;) {
n += grow(out, list, ttree, fptree.headerTable[i], itemset, localItemSupport, prefixItemset);
}
return n;
} | java | private long grow(PrintStream out, List<ItemSet> list, TotalSupportTree ttree, FPTree fptree, int[] itemset) {
long n = 0;
int[] prefixItemset = new int[T0.maxItemSetSize];
int[] localItemSupport = new int[T0.numItems];
// Loop through header table from end to start, item by item
for (int i = fptree.headerTable.length; i-- > 0;) {
n += grow(out, list, ttree, fptree.headerTable[i], itemset, localItemSupport, prefixItemset);
}
return n;
} | [
"private",
"long",
"grow",
"(",
"PrintStream",
"out",
",",
"List",
"<",
"ItemSet",
">",
"list",
",",
"TotalSupportTree",
"ttree",
",",
"FPTree",
"fptree",
",",
"int",
"[",
"]",
"itemset",
")",
"{",
"long",
"n",
"=",
"0",
";",
"int",
"[",
"]",
"prefixItemset",
"=",
"new",
"int",
"[",
"T0",
".",
"maxItemSetSize",
"]",
";",
"int",
"[",
"]",
"localItemSupport",
"=",
"new",
"int",
"[",
"T0",
".",
"numItems",
"]",
";",
"// Loop through header table from end to start, item by item",
"for",
"(",
"int",
"i",
"=",
"fptree",
".",
"headerTable",
".",
"length",
";",
"i",
"--",
">",
"0",
";",
")",
"{",
"n",
"+=",
"grow",
"(",
"out",
",",
"list",
",",
"ttree",
",",
"fptree",
".",
"headerTable",
"[",
"i",
"]",
",",
"itemset",
",",
"localItemSupport",
",",
"prefixItemset",
")",
";",
"}",
"return",
"n",
";",
"}"
]
| Mines frequent item sets. Start with the bottom of the header table and
work upwards. For each available FP tree node:
<OL>
<LI> Count the support.
<LI> Build up item set sofar.
<LI> Add to supported sets.
<LI> Build a new FP tree: (i) create a new local root, (ii) create a
new local header table and (iii) populate with ancestors.
<LI> If new local FP tree is not empty repeat mining operation.
</OL>
Otherwise end.
@param itemset the current item sets as generated so far (null at start). | [
"Mines",
"frequent",
"item",
"sets",
".",
"Start",
"with",
"the",
"bottom",
"of",
"the",
"header",
"table",
"and",
"work",
"upwards",
".",
"For",
"each",
"available",
"FP",
"tree",
"node",
":",
"<OL",
">",
"<LI",
">",
"Count",
"the",
"support",
".",
"<LI",
">",
"Build",
"up",
"item",
"set",
"sofar",
".",
"<LI",
">",
"Add",
"to",
"supported",
"sets",
".",
"<LI",
">",
"Build",
"a",
"new",
"FP",
"tree",
":",
"(",
"i",
")",
"create",
"a",
"new",
"local",
"root",
"(",
"ii",
")",
"create",
"a",
"new",
"local",
"header",
"table",
"and",
"(",
"iii",
")",
"populate",
"with",
"ancestors",
".",
"<LI",
">",
"If",
"new",
"local",
"FP",
"tree",
"is",
"not",
"empty",
"repeat",
"mining",
"operation",
".",
"<",
"/",
"OL",
">",
"Otherwise",
"end",
"."
]
| train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/FPGrowth.java#L250-L261 |
graylog-labs/syslog4j-graylog2 | src/main/java/org/graylog2/syslog4j/util/Base64.java | Base64.encodeToFile | public static boolean encodeToFile(byte[] dataToEncode, String filename) {
"""
Convenience method for encoding data to a file.
@param dataToEncode byte array of data to encode in base64 form
@param filename Filename for saving encoded data
@return <tt>true</tt> if successful, <tt>false</tt> otherwise
@since 2.1
"""
boolean success = false;
Base64.OutputStream bos = null;
try {
bos = new Base64.OutputStream(
new java.io.FileOutputStream(filename), Base64.ENCODE);
bos.write(dataToEncode);
success = true;
} // end try
catch (java.io.IOException e) {
success = false;
} // end catch: IOException
finally {
try {
if (bos != null) bos.close();
} catch (Exception e) {
}
} // end finally
return success;
} | java | public static boolean encodeToFile(byte[] dataToEncode, String filename) {
boolean success = false;
Base64.OutputStream bos = null;
try {
bos = new Base64.OutputStream(
new java.io.FileOutputStream(filename), Base64.ENCODE);
bos.write(dataToEncode);
success = true;
} // end try
catch (java.io.IOException e) {
success = false;
} // end catch: IOException
finally {
try {
if (bos != null) bos.close();
} catch (Exception e) {
}
} // end finally
return success;
} | [
"public",
"static",
"boolean",
"encodeToFile",
"(",
"byte",
"[",
"]",
"dataToEncode",
",",
"String",
"filename",
")",
"{",
"boolean",
"success",
"=",
"false",
";",
"Base64",
".",
"OutputStream",
"bos",
"=",
"null",
";",
"try",
"{",
"bos",
"=",
"new",
"Base64",
".",
"OutputStream",
"(",
"new",
"java",
".",
"io",
".",
"FileOutputStream",
"(",
"filename",
")",
",",
"Base64",
".",
"ENCODE",
")",
";",
"bos",
".",
"write",
"(",
"dataToEncode",
")",
";",
"success",
"=",
"true",
";",
"}",
"// end try\r",
"catch",
"(",
"java",
".",
"io",
".",
"IOException",
"e",
")",
"{",
"success",
"=",
"false",
";",
"}",
"// end catch: IOException\r",
"finally",
"{",
"try",
"{",
"if",
"(",
"bos",
"!=",
"null",
")",
"bos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"// end finally\r",
"return",
"success",
";",
"}"
]
| Convenience method for encoding data to a file.
@param dataToEncode byte array of data to encode in base64 form
@param filename Filename for saving encoded data
@return <tt>true</tt> if successful, <tt>false</tt> otherwise
@since 2.1 | [
"Convenience",
"method",
"for",
"encoding",
"data",
"to",
"a",
"file",
"."
]
| train | https://github.com/graylog-labs/syslog4j-graylog2/blob/374bc20d77c3aaa36a68bec5125dd82ce0a88aab/src/main/java/org/graylog2/syslog4j/util/Base64.java#L1091-L1112 |
geomajas/geomajas-project-server | api/src/main/java/org/geomajas/layer/feature/attribute/AssociationValue.java | AssociationValue.setDoubleAttribute | public void setDoubleAttribute(String name, Double value) {
"""
Sets the specified double attribute to the specified value.
@param name name of the attribute
@param value value of the attribute
@since 1.9.0
"""
ensureAttributes();
Attribute attribute = new DoubleAttribute(value);
attribute.setEditable(isEditable(name));
getAllAttributes().put(name, attribute);
} | java | public void setDoubleAttribute(String name, Double value) {
ensureAttributes();
Attribute attribute = new DoubleAttribute(value);
attribute.setEditable(isEditable(name));
getAllAttributes().put(name, attribute);
} | [
"public",
"void",
"setDoubleAttribute",
"(",
"String",
"name",
",",
"Double",
"value",
")",
"{",
"ensureAttributes",
"(",
")",
";",
"Attribute",
"attribute",
"=",
"new",
"DoubleAttribute",
"(",
"value",
")",
";",
"attribute",
".",
"setEditable",
"(",
"isEditable",
"(",
"name",
")",
")",
";",
"getAllAttributes",
"(",
")",
".",
"put",
"(",
"name",
",",
"attribute",
")",
";",
"}"
]
| Sets the specified double attribute to the specified value.
@param name name of the attribute
@param value value of the attribute
@since 1.9.0 | [
"Sets",
"the",
"specified",
"double",
"attribute",
"to",
"the",
"specified",
"value",
"."
]
| train | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/api/src/main/java/org/geomajas/layer/feature/attribute/AssociationValue.java#L260-L266 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFile.java | BoxFile.deleteMetadata | public void deleteMetadata(String typeName, String scope) {
"""
Deletes the file metadata of specified template type.
@param typeName the metadata template type name.
@param scope the metadata scope (global or enterprise).
"""
URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, typeName);
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
request.send();
} | java | public void deleteMetadata(String typeName, String scope) {
URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, typeName);
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
request.send();
} | [
"public",
"void",
"deleteMetadata",
"(",
"String",
"typeName",
",",
"String",
"scope",
")",
"{",
"URL",
"url",
"=",
"METADATA_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
",",
"scope",
",",
"typeName",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"DELETE\"",
")",
";",
"request",
".",
"send",
"(",
")",
";",
"}"
]
| Deletes the file metadata of specified template type.
@param typeName the metadata template type name.
@param scope the metadata scope (global or enterprise). | [
"Deletes",
"the",
"file",
"metadata",
"of",
"specified",
"template",
"type",
"."
]
| train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1329-L1333 |
m-m-m/util | collection/src/main/java/net/sf/mmm/util/collection/base/RankMap.java | RankMap.addRank | public int addRank(E element, int gain) {
"""
This method adds the given {@code gain} to the current {@link #getRank(Object) rank} of the given {@code element}.
If the {@code element} is {@link #setUnacceptable(Object) unacceptable}, this method will have no effect. This
method guarantees that there will be no overflow of the {@link #getRank(Object) rank}.
@param element is the element to rank.
@param gain is the value to add to the current rank. It may be negative to reduce the rank. A value of {@code 0}
will have no effect.
@return the new rank.
"""
Ranking ranking = this.map.get(element);
if (ranking == null) {
if (gain == 0) {
return 0;
}
ranking = new Ranking();
this.map.put(element, ranking);
}
ranking.addRank(gain);
return ranking.rank;
} | java | public int addRank(E element, int gain) {
Ranking ranking = this.map.get(element);
if (ranking == null) {
if (gain == 0) {
return 0;
}
ranking = new Ranking();
this.map.put(element, ranking);
}
ranking.addRank(gain);
return ranking.rank;
} | [
"public",
"int",
"addRank",
"(",
"E",
"element",
",",
"int",
"gain",
")",
"{",
"Ranking",
"ranking",
"=",
"this",
".",
"map",
".",
"get",
"(",
"element",
")",
";",
"if",
"(",
"ranking",
"==",
"null",
")",
"{",
"if",
"(",
"gain",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"ranking",
"=",
"new",
"Ranking",
"(",
")",
";",
"this",
".",
"map",
".",
"put",
"(",
"element",
",",
"ranking",
")",
";",
"}",
"ranking",
".",
"addRank",
"(",
"gain",
")",
";",
"return",
"ranking",
".",
"rank",
";",
"}"
]
| This method adds the given {@code gain} to the current {@link #getRank(Object) rank} of the given {@code element}.
If the {@code element} is {@link #setUnacceptable(Object) unacceptable}, this method will have no effect. This
method guarantees that there will be no overflow of the {@link #getRank(Object) rank}.
@param element is the element to rank.
@param gain is the value to add to the current rank. It may be negative to reduce the rank. A value of {@code 0}
will have no effect.
@return the new rank. | [
"This",
"method",
"adds",
"the",
"given",
"{",
"@code",
"gain",
"}",
"to",
"the",
"current",
"{",
"@link",
"#getRank",
"(",
"Object",
")",
"rank",
"}",
"of",
"the",
"given",
"{",
"@code",
"element",
"}",
".",
"If",
"the",
"{",
"@code",
"element",
"}",
"is",
"{",
"@link",
"#setUnacceptable",
"(",
"Object",
")",
"unacceptable",
"}",
"this",
"method",
"will",
"have",
"no",
"effect",
".",
"This",
"method",
"guarantees",
"that",
"there",
"will",
"be",
"no",
"overflow",
"of",
"the",
"{",
"@link",
"#getRank",
"(",
"Object",
")",
"rank",
"}",
"."
]
| train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/collection/src/main/java/net/sf/mmm/util/collection/base/RankMap.java#L124-L136 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java | Shape.getOffset | public static long getOffset(DataBuffer shapeInformation, int dim0, int dim1, int dim2) {
"""
Get the offset of the specified [dim0,dim1,dim2] for the 3d array
@param shapeInformation Shape information
@param dim0 Row index to get the offset for
@param dim1 Column index to get the offset for
@param dim2 dimension 2 index to get the offset for
@return Buffer offset
"""
int rank = rank(shapeInformation);
if (rank != 3)
throw new IllegalArgumentException(
"Cannot use this getOffset method on arrays of rank != 3 (rank is: " + rank + ")");
return getOffsetUnsafe(shapeInformation, dim0, dim1, dim2);
} | java | public static long getOffset(DataBuffer shapeInformation, int dim0, int dim1, int dim2) {
int rank = rank(shapeInformation);
if (rank != 3)
throw new IllegalArgumentException(
"Cannot use this getOffset method on arrays of rank != 3 (rank is: " + rank + ")");
return getOffsetUnsafe(shapeInformation, dim0, dim1, dim2);
} | [
"public",
"static",
"long",
"getOffset",
"(",
"DataBuffer",
"shapeInformation",
",",
"int",
"dim0",
",",
"int",
"dim1",
",",
"int",
"dim2",
")",
"{",
"int",
"rank",
"=",
"rank",
"(",
"shapeInformation",
")",
";",
"if",
"(",
"rank",
"!=",
"3",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot use this getOffset method on arrays of rank != 3 (rank is: \"",
"+",
"rank",
"+",
"\")\"",
")",
";",
"return",
"getOffsetUnsafe",
"(",
"shapeInformation",
",",
"dim0",
",",
"dim1",
",",
"dim2",
")",
";",
"}"
]
| Get the offset of the specified [dim0,dim1,dim2] for the 3d array
@param shapeInformation Shape information
@param dim0 Row index to get the offset for
@param dim1 Column index to get the offset for
@param dim2 dimension 2 index to get the offset for
@return Buffer offset | [
"Get",
"the",
"offset",
"of",
"the",
"specified",
"[",
"dim0",
"dim1",
"dim2",
"]",
"for",
"the",
"3d",
"array"
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java#L1117-L1123 |
tiesebarrell/process-assertions | process-assertions-api/src/main/java/org/toxos/processassertions/api/ProcessAssert.java | ProcessAssert.assertProcessInActivity | public static final void assertProcessInActivity(final String processInstanceId, final String activityId) {
"""
Asserts the process instance with the provided id is active and in (at lease) an activity with the provided id.
@param processInstanceId
the process instance's id to check for. May not be <code>null</code>
@param activityId
the activity's id to check for. May not be <code>null</code>
"""
Validate.notNull(processInstanceId);
Validate.notNull(activityId);
apiCallback.debug(LogMessage.PROCESS_15, processInstanceId, activityId);
try {
getProcessInstanceAssertable().processIsInActivity(processInstanceId, activityId);
} catch (final AssertionError ae) {
apiCallback.fail(ae, LogMessage.ERROR_PROCESS_6, processInstanceId, activityId);
}
} | java | public static final void assertProcessInActivity(final String processInstanceId, final String activityId) {
Validate.notNull(processInstanceId);
Validate.notNull(activityId);
apiCallback.debug(LogMessage.PROCESS_15, processInstanceId, activityId);
try {
getProcessInstanceAssertable().processIsInActivity(processInstanceId, activityId);
} catch (final AssertionError ae) {
apiCallback.fail(ae, LogMessage.ERROR_PROCESS_6, processInstanceId, activityId);
}
} | [
"public",
"static",
"final",
"void",
"assertProcessInActivity",
"(",
"final",
"String",
"processInstanceId",
",",
"final",
"String",
"activityId",
")",
"{",
"Validate",
".",
"notNull",
"(",
"processInstanceId",
")",
";",
"Validate",
".",
"notNull",
"(",
"activityId",
")",
";",
"apiCallback",
".",
"debug",
"(",
"LogMessage",
".",
"PROCESS_15",
",",
"processInstanceId",
",",
"activityId",
")",
";",
"try",
"{",
"getProcessInstanceAssertable",
"(",
")",
".",
"processIsInActivity",
"(",
"processInstanceId",
",",
"activityId",
")",
";",
"}",
"catch",
"(",
"final",
"AssertionError",
"ae",
")",
"{",
"apiCallback",
".",
"fail",
"(",
"ae",
",",
"LogMessage",
".",
"ERROR_PROCESS_6",
",",
"processInstanceId",
",",
"activityId",
")",
";",
"}",
"}"
]
| Asserts the process instance with the provided id is active and in (at lease) an activity with the provided id.
@param processInstanceId
the process instance's id to check for. May not be <code>null</code>
@param activityId
the activity's id to check for. May not be <code>null</code> | [
"Asserts",
"the",
"process",
"instance",
"with",
"the",
"provided",
"id",
"is",
"active",
"and",
"in",
"(",
"at",
"lease",
")",
"an",
"activity",
"with",
"the",
"provided",
"id",
"."
]
| train | https://github.com/tiesebarrell/process-assertions/blob/932a8443982e356cdf5a230165a35c725d9306ab/process-assertions-api/src/main/java/org/toxos/processassertions/api/ProcessAssert.java#L100-L110 |
landawn/AbacusUtil | src/com/landawn/abacus/util/DateUtil.java | DateUtil.addMinutes | public static <T extends java.util.Date> T addMinutes(final T date, final int amount) {
"""
Adds a number of minutes to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to add, may be negative
@return the new {@code Date} with the amount added
@throws IllegalArgumentException if the date is null
"""
return roll(date, amount, CalendarUnit.MINUTE);
} | java | public static <T extends java.util.Date> T addMinutes(final T date, final int amount) {
return roll(date, amount, CalendarUnit.MINUTE);
} | [
"public",
"static",
"<",
"T",
"extends",
"java",
".",
"util",
".",
"Date",
">",
"T",
"addMinutes",
"(",
"final",
"T",
"date",
",",
"final",
"int",
"amount",
")",
"{",
"return",
"roll",
"(",
"date",
",",
"amount",
",",
"CalendarUnit",
".",
"MINUTE",
")",
";",
"}"
]
| Adds a number of minutes to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to add, may be negative
@return the new {@code Date} with the amount added
@throws IllegalArgumentException if the date is null | [
"Adds",
"a",
"number",
"of",
"minutes",
"to",
"a",
"date",
"returning",
"a",
"new",
"object",
".",
"The",
"original",
"{",
"@code",
"Date",
"}",
"is",
"unchanged",
"."
]
| train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/DateUtil.java#L1021-L1023 |
MorphiaOrg/morphia | morphia/src/main/java/dev/morphia/mapping/Mapper.java | Mapper.fromDBObject | @Deprecated
public <T> T fromDBObject(final Datastore datastore, final Class<T> entityClass, final DBObject dbObject, final EntityCache cache) {
"""
Converts a DBObject back to a type-safe java object (POJO)
@param <T> the type of the entity
@param datastore the Datastore to use when fetching this reference
@param entityClass The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
@param dbObject the DBObject containing the document from mongodb
@param cache the EntityCache to use
@return the new entity
@morphia.internal
@deprecated no replacement is planned
"""
if (dbObject == null) {
LOG.error("A null reference was passed in for the dbObject", new Throwable());
return null;
}
return fromDb(datastore, dbObject, opts.getObjectFactory().createInstance(entityClass, dbObject), cache);
} | java | @Deprecated
public <T> T fromDBObject(final Datastore datastore, final Class<T> entityClass, final DBObject dbObject, final EntityCache cache) {
if (dbObject == null) {
LOG.error("A null reference was passed in for the dbObject", new Throwable());
return null;
}
return fromDb(datastore, dbObject, opts.getObjectFactory().createInstance(entityClass, dbObject), cache);
} | [
"@",
"Deprecated",
"public",
"<",
"T",
">",
"T",
"fromDBObject",
"(",
"final",
"Datastore",
"datastore",
",",
"final",
"Class",
"<",
"T",
">",
"entityClass",
",",
"final",
"DBObject",
"dbObject",
",",
"final",
"EntityCache",
"cache",
")",
"{",
"if",
"(",
"dbObject",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"\"A null reference was passed in for the dbObject\"",
",",
"new",
"Throwable",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"return",
"fromDb",
"(",
"datastore",
",",
"dbObject",
",",
"opts",
".",
"getObjectFactory",
"(",
")",
".",
"createInstance",
"(",
"entityClass",
",",
"dbObject",
")",
",",
"cache",
")",
";",
"}"
]
| Converts a DBObject back to a type-safe java object (POJO)
@param <T> the type of the entity
@param datastore the Datastore to use when fetching this reference
@param entityClass The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
@param dbObject the DBObject containing the document from mongodb
@param cache the EntityCache to use
@return the new entity
@morphia.internal
@deprecated no replacement is planned | [
"Converts",
"a",
"DBObject",
"back",
"to",
"a",
"type",
"-",
"safe",
"java",
"object",
"(",
"POJO",
")"
]
| train | https://github.com/MorphiaOrg/morphia/blob/667c30bdc7c6f1d9f2e2eb8774835d6137b52d12/morphia/src/main/java/dev/morphia/mapping/Mapper.java#L199-L207 |
knowhowlab/org.knowhowlab.osgi.shell | felix-gogo/src/main/java/org/knowhowlab/osgi/shell/felixgogo/AbstractFelixCommandsService.java | AbstractFelixCommandsService.runCommand | protected void runCommand(String commandName, CommandSession session, String[] params) {
"""
Run command method
@param commandName command name
@param params command parameters
"""
try {
Method method = service.getClass().getMethod(commandName, PrintWriter.class, String[].class);
PrintWriter printWriter = new PrintWriter(session.getConsole());
method.invoke(service, printWriter, params);
printWriter.flush();
} catch (NoSuchMethodException e) {
session.getConsole().println("No such command: " + commandName);
} catch (Exception e) {
LOG.log(Level.WARNING, "Unable to execute command: " + commandName + " with args: " + Arrays.toString(params), e);
e.printStackTrace(session.getConsole());
}
} | java | protected void runCommand(String commandName, CommandSession session, String[] params) {
try {
Method method = service.getClass().getMethod(commandName, PrintWriter.class, String[].class);
PrintWriter printWriter = new PrintWriter(session.getConsole());
method.invoke(service, printWriter, params);
printWriter.flush();
} catch (NoSuchMethodException e) {
session.getConsole().println("No such command: " + commandName);
} catch (Exception e) {
LOG.log(Level.WARNING, "Unable to execute command: " + commandName + " with args: " + Arrays.toString(params), e);
e.printStackTrace(session.getConsole());
}
} | [
"protected",
"void",
"runCommand",
"(",
"String",
"commandName",
",",
"CommandSession",
"session",
",",
"String",
"[",
"]",
"params",
")",
"{",
"try",
"{",
"Method",
"method",
"=",
"service",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"commandName",
",",
"PrintWriter",
".",
"class",
",",
"String",
"[",
"]",
".",
"class",
")",
";",
"PrintWriter",
"printWriter",
"=",
"new",
"PrintWriter",
"(",
"session",
".",
"getConsole",
"(",
")",
")",
";",
"method",
".",
"invoke",
"(",
"service",
",",
"printWriter",
",",
"params",
")",
";",
"printWriter",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"session",
".",
"getConsole",
"(",
")",
".",
"println",
"(",
"\"No such command: \"",
"+",
"commandName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Unable to execute command: \"",
"+",
"commandName",
"+",
"\" with args: \"",
"+",
"Arrays",
".",
"toString",
"(",
"params",
")",
",",
"e",
")",
";",
"e",
".",
"printStackTrace",
"(",
"session",
".",
"getConsole",
"(",
")",
")",
";",
"}",
"}"
]
| Run command method
@param commandName command name
@param params command parameters | [
"Run",
"command",
"method"
]
| train | https://github.com/knowhowlab/org.knowhowlab.osgi.shell/blob/5c3172b1e6b741c753f02af48ab42adc4915a6ae/felix-gogo/src/main/java/org/knowhowlab/osgi/shell/felixgogo/AbstractFelixCommandsService.java#L31-L43 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/SourceLineAnnotation.java | SourceLineAnnotation.createUnknown | public static SourceLineAnnotation createUnknown(@DottedClassName String className) {
"""
Factory method to create an unknown source line annotation. This variant
looks up the source filename automatically based on the class using best
effort.
@param className
the class name
@return the SourceLineAnnotation
"""
return createUnknown(className, AnalysisContext.currentAnalysisContext().lookupSourceFile(className), -1, -1);
} | java | public static SourceLineAnnotation createUnknown(@DottedClassName String className) {
return createUnknown(className, AnalysisContext.currentAnalysisContext().lookupSourceFile(className), -1, -1);
} | [
"public",
"static",
"SourceLineAnnotation",
"createUnknown",
"(",
"@",
"DottedClassName",
"String",
"className",
")",
"{",
"return",
"createUnknown",
"(",
"className",
",",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"lookupSourceFile",
"(",
"className",
")",
",",
"-",
"1",
",",
"-",
"1",
")",
";",
"}"
]
| Factory method to create an unknown source line annotation. This variant
looks up the source filename automatically based on the class using best
effort.
@param className
the class name
@return the SourceLineAnnotation | [
"Factory",
"method",
"to",
"create",
"an",
"unknown",
"source",
"line",
"annotation",
".",
"This",
"variant",
"looks",
"up",
"the",
"source",
"filename",
"automatically",
"based",
"on",
"the",
"class",
"using",
"best",
"effort",
"."
]
| train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SourceLineAnnotation.java#L180-L182 |
intuit/QuickBooks-V3-Java-SDK | ipp-v3-java-devkit/src/main/java/com/intuit/ipp/services/DataService.java | DataService.isContainResponse | private boolean isContainResponse(IntuitMessage intuitMessage, int idx) {
"""
verifies availability of an object in response
@param intuitMessage
@param idx
@return
"""
List<AttachableResponse> response = ((IntuitResponse) intuitMessage.getResponseElements().getResponse()).getAttachableResponse();
if(null == response) { return false; }
if(0 >= response.size() ) { return false; }
if(idx >= response.size() ) { return false; }
return true;
} | java | private boolean isContainResponse(IntuitMessage intuitMessage, int idx)
{
List<AttachableResponse> response = ((IntuitResponse) intuitMessage.getResponseElements().getResponse()).getAttachableResponse();
if(null == response) { return false; }
if(0 >= response.size() ) { return false; }
if(idx >= response.size() ) { return false; }
return true;
} | [
"private",
"boolean",
"isContainResponse",
"(",
"IntuitMessage",
"intuitMessage",
",",
"int",
"idx",
")",
"{",
"List",
"<",
"AttachableResponse",
">",
"response",
"=",
"(",
"(",
"IntuitResponse",
")",
"intuitMessage",
".",
"getResponseElements",
"(",
")",
".",
"getResponse",
"(",
")",
")",
".",
"getAttachableResponse",
"(",
")",
";",
"if",
"(",
"null",
"==",
"response",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"0",
">=",
"response",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"idx",
">=",
"response",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| verifies availability of an object in response
@param intuitMessage
@param idx
@return | [
"verifies",
"availability",
"of",
"an",
"object",
"in",
"response"
]
| train | https://github.com/intuit/QuickBooks-V3-Java-SDK/blob/59f988d0776d46620d0b34711c411b2b5b1da06b/ipp-v3-java-devkit/src/main/java/com/intuit/ipp/services/DataService.java#L491-L498 |
MenoData/Time4J | base/src/main/java/net/time4j/range/ClockInterval.java | ClockInterval.parseISO | public static ClockInterval parseISO(String text) throws ParseException {
"""
/*[deutsch]
<p>Interpretiert den angegebenen ISO-konformen Text als Intervall. </p>
<p>Beispiele für unterstützte Formate: </p>
<ul>
<li>09:45/PT5H</li>
<li>PT5H/14:45</li>
<li>0945/PT5H</li>
<li>PT5H/1445</li>
<li>PT01:55:30/14:15:30</li>
<li>04:01:30.123/24:00:00.000</li>
<li>04:01:30,123/24:00:00,000</li>
</ul>
@param text text to be parsed
@return parsed interval
@throws IndexOutOfBoundsException if given text is empty
@throws ParseException if the text is not parseable
@since 2.1
@see BracketPolicy#SHOW_NEVER
"""
if (text.isEmpty()) {
throw new IndexOutOfBoundsException("Empty text.");
}
ChronoParser<PlainTime> parser = (
(text.indexOf(':') == -1) ? Iso8601Format.BASIC_WALL_TIME : Iso8601Format.EXTENDED_WALL_TIME);
ParseLog plog = new ParseLog();
ClockInterval result =
new IntervalParser<>(
ClockIntervalFactory.INSTANCE,
parser,
parser,
BracketPolicy.SHOW_NEVER,
'/'
).parse(text, plog, parser.getAttributes());
if ((result == null) || plog.isError()) {
throw new ParseException(plog.getErrorMessage(), plog.getErrorIndex());
} else if (plog.getPosition() < text.length()) {
throw new ParseException("Trailing characters found: " + text, plog.getPosition());
} else {
return result;
}
} | java | public static ClockInterval parseISO(String text) throws ParseException {
if (text.isEmpty()) {
throw new IndexOutOfBoundsException("Empty text.");
}
ChronoParser<PlainTime> parser = (
(text.indexOf(':') == -1) ? Iso8601Format.BASIC_WALL_TIME : Iso8601Format.EXTENDED_WALL_TIME);
ParseLog plog = new ParseLog();
ClockInterval result =
new IntervalParser<>(
ClockIntervalFactory.INSTANCE,
parser,
parser,
BracketPolicy.SHOW_NEVER,
'/'
).parse(text, plog, parser.getAttributes());
if ((result == null) || plog.isError()) {
throw new ParseException(plog.getErrorMessage(), plog.getErrorIndex());
} else if (plog.getPosition() < text.length()) {
throw new ParseException("Trailing characters found: " + text, plog.getPosition());
} else {
return result;
}
} | [
"public",
"static",
"ClockInterval",
"parseISO",
"(",
"String",
"text",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"text",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Empty text.\"",
")",
";",
"}",
"ChronoParser",
"<",
"PlainTime",
">",
"parser",
"=",
"(",
"(",
"text",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"?",
"Iso8601Format",
".",
"BASIC_WALL_TIME",
":",
"Iso8601Format",
".",
"EXTENDED_WALL_TIME",
")",
";",
"ParseLog",
"plog",
"=",
"new",
"ParseLog",
"(",
")",
";",
"ClockInterval",
"result",
"=",
"new",
"IntervalParser",
"<>",
"(",
"ClockIntervalFactory",
".",
"INSTANCE",
",",
"parser",
",",
"parser",
",",
"BracketPolicy",
".",
"SHOW_NEVER",
",",
"'",
"'",
")",
".",
"parse",
"(",
"text",
",",
"plog",
",",
"parser",
".",
"getAttributes",
"(",
")",
")",
";",
"if",
"(",
"(",
"result",
"==",
"null",
")",
"||",
"plog",
".",
"isError",
"(",
")",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"plog",
".",
"getErrorMessage",
"(",
")",
",",
"plog",
".",
"getErrorIndex",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"plog",
".",
"getPosition",
"(",
")",
"<",
"text",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"\"Trailing characters found: \"",
"+",
"text",
",",
"plog",
".",
"getPosition",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"result",
";",
"}",
"}"
]
| /*[deutsch]
<p>Interpretiert den angegebenen ISO-konformen Text als Intervall. </p>
<p>Beispiele für unterstützte Formate: </p>
<ul>
<li>09:45/PT5H</li>
<li>PT5H/14:45</li>
<li>0945/PT5H</li>
<li>PT5H/1445</li>
<li>PT01:55:30/14:15:30</li>
<li>04:01:30.123/24:00:00.000</li>
<li>04:01:30,123/24:00:00,000</li>
</ul>
@param text text to be parsed
@return parsed interval
@throws IndexOutOfBoundsException if given text is empty
@throws ParseException if the text is not parseable
@since 2.1
@see BracketPolicy#SHOW_NEVER | [
"/",
"*",
"[",
"deutsch",
"]",
"<p",
">",
"Interpretiert",
"den",
"angegebenen",
"ISO",
"-",
"konformen",
"Text",
"als",
"Intervall",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/range/ClockInterval.java#L934-L961 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/http/HttpHeaderMap.java | HttpHeaderMap.setDateHeader | public void setDateHeader (@Nonnull @Nonempty final String sName, @Nonnull final ZonedDateTime aDT) {
"""
Set the passed header as a date header.
@param sName
Header name. May neither be <code>null</code> nor empty.
@param aDT
The DateTime to set as a date. May not be <code>null</code>.
"""
_setHeader (sName, getDateTimeAsString (aDT));
} | java | public void setDateHeader (@Nonnull @Nonempty final String sName, @Nonnull final ZonedDateTime aDT)
{
_setHeader (sName, getDateTimeAsString (aDT));
} | [
"public",
"void",
"setDateHeader",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
",",
"@",
"Nonnull",
"final",
"ZonedDateTime",
"aDT",
")",
"{",
"_setHeader",
"(",
"sName",
",",
"getDateTimeAsString",
"(",
"aDT",
")",
")",
";",
"}"
]
| Set the passed header as a date header.
@param sName
Header name. May neither be <code>null</code> nor empty.
@param aDT
The DateTime to set as a date. May not be <code>null</code>. | [
"Set",
"the",
"passed",
"header",
"as",
"a",
"date",
"header",
"."
]
| train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/http/HttpHeaderMap.java#L277-L280 |
h2oai/h2o-3 | h2o-core/src/main/java/water/api/AlgoAbstractRegister.java | AlgoAbstractRegister.registerModelBuilder | protected final void registerModelBuilder(RestApiContext context, ModelBuilder mbProto, int version) {
"""
Register algorithm common REST interface.
@param mbProto prototype instance of algorithm model builder
@param version registration version
"""
Class<? extends water.api.Handler> handlerClass = water.api.ModelBuilderHandler.class;
if (H2O.ARGS.features_level.compareTo(mbProto.builderVisibility()) > 0) {
return; // Skip endpoint registration
}
String base = mbProto.getClass().getSimpleName();
String lbase = base.toLowerCase();
// This is common model builder handler
context.registerEndpoint(
"train_" + lbase,
"POST /" + version + "/ModelBuilders/" + lbase,
handlerClass,
"train",
"Train a " + base + " model."
);
context.registerEndpoint(
"validate_" + lbase,
"POST /" + version + "/ModelBuilders/" + lbase + "/parameters",
handlerClass,
"validate_parameters",
"Validate a set of " + base + " model builder parameters."
);
// Grid search is experimental feature
context.registerEndpoint(
"grid_search_" + lbase,
"POST /99/Grid/" + lbase,
GridSearchHandler.class,
"train",
"Run grid search for " + base + " model."
);
} | java | protected final void registerModelBuilder(RestApiContext context, ModelBuilder mbProto, int version) {
Class<? extends water.api.Handler> handlerClass = water.api.ModelBuilderHandler.class;
if (H2O.ARGS.features_level.compareTo(mbProto.builderVisibility()) > 0) {
return; // Skip endpoint registration
}
String base = mbProto.getClass().getSimpleName();
String lbase = base.toLowerCase();
// This is common model builder handler
context.registerEndpoint(
"train_" + lbase,
"POST /" + version + "/ModelBuilders/" + lbase,
handlerClass,
"train",
"Train a " + base + " model."
);
context.registerEndpoint(
"validate_" + lbase,
"POST /" + version + "/ModelBuilders/" + lbase + "/parameters",
handlerClass,
"validate_parameters",
"Validate a set of " + base + " model builder parameters."
);
// Grid search is experimental feature
context.registerEndpoint(
"grid_search_" + lbase,
"POST /99/Grid/" + lbase,
GridSearchHandler.class,
"train",
"Run grid search for " + base + " model."
);
} | [
"protected",
"final",
"void",
"registerModelBuilder",
"(",
"RestApiContext",
"context",
",",
"ModelBuilder",
"mbProto",
",",
"int",
"version",
")",
"{",
"Class",
"<",
"?",
"extends",
"water",
".",
"api",
".",
"Handler",
">",
"handlerClass",
"=",
"water",
".",
"api",
".",
"ModelBuilderHandler",
".",
"class",
";",
"if",
"(",
"H2O",
".",
"ARGS",
".",
"features_level",
".",
"compareTo",
"(",
"mbProto",
".",
"builderVisibility",
"(",
")",
")",
">",
"0",
")",
"{",
"return",
";",
"// Skip endpoint registration",
"}",
"String",
"base",
"=",
"mbProto",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
";",
"String",
"lbase",
"=",
"base",
".",
"toLowerCase",
"(",
")",
";",
"// This is common model builder handler",
"context",
".",
"registerEndpoint",
"(",
"\"train_\"",
"+",
"lbase",
",",
"\"POST /\"",
"+",
"version",
"+",
"\"/ModelBuilders/\"",
"+",
"lbase",
",",
"handlerClass",
",",
"\"train\"",
",",
"\"Train a \"",
"+",
"base",
"+",
"\" model.\"",
")",
";",
"context",
".",
"registerEndpoint",
"(",
"\"validate_\"",
"+",
"lbase",
",",
"\"POST /\"",
"+",
"version",
"+",
"\"/ModelBuilders/\"",
"+",
"lbase",
"+",
"\"/parameters\"",
",",
"handlerClass",
",",
"\"validate_parameters\"",
",",
"\"Validate a set of \"",
"+",
"base",
"+",
"\" model builder parameters.\"",
")",
";",
"// Grid search is experimental feature",
"context",
".",
"registerEndpoint",
"(",
"\"grid_search_\"",
"+",
"lbase",
",",
"\"POST /99/Grid/\"",
"+",
"lbase",
",",
"GridSearchHandler",
".",
"class",
",",
"\"train\"",
",",
"\"Run grid search for \"",
"+",
"base",
"+",
"\" model.\"",
")",
";",
"}"
]
| Register algorithm common REST interface.
@param mbProto prototype instance of algorithm model builder
@param version registration version | [
"Register",
"algorithm",
"common",
"REST",
"interface",
"."
]
| train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/api/AlgoAbstractRegister.java#L17-L50 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/ui/CmsResultsTab.java | CmsResultsTab.fillContent | public void fillContent(final CmsGallerySearchBean searchObj, List<CmsSearchParamPanel> paramPanels) {
"""
Fill the content of the results tab.<p>
@param searchObj the current search object containing search results
@param paramPanels list of search parameter panels to show
"""
removeNoParamMessage();
// in case there is a single type selected and the current sort order is not by type,
// hide the type ascending and type descending sort order options
SortParams currentSorting = SortParams.valueOf(searchObj.getSortOrder());
if ((searchObj.getTypes().size() == 1)
&& !((currentSorting == SortParams.type_asc) || (currentSorting == SortParams.type_desc))) {
m_sortSelectBox.setItems(getSortList(false));
} else {
m_sortSelectBox.setItems(getSortList(true));
}
m_sortSelectBox.selectValue(searchObj.getSortOrder());
displayResultCount(getResultsDisplayed(searchObj), searchObj.getResultCount());
m_hasMoreResults = searchObj.hasMore();
if (searchObj.getPage() == 1) {
m_preset = null;
getList().scrollToTop();
clearList();
showParams(paramPanels);
m_backwardScrollHandler.updateSearchBean(searchObj);
getList().getElement().getStyle().clearDisplay();
scrollToPreset();
} else {
showParams(paramPanels);
addContent(searchObj);
}
showUpload(searchObj);
} | java | public void fillContent(final CmsGallerySearchBean searchObj, List<CmsSearchParamPanel> paramPanels) {
removeNoParamMessage();
// in case there is a single type selected and the current sort order is not by type,
// hide the type ascending and type descending sort order options
SortParams currentSorting = SortParams.valueOf(searchObj.getSortOrder());
if ((searchObj.getTypes().size() == 1)
&& !((currentSorting == SortParams.type_asc) || (currentSorting == SortParams.type_desc))) {
m_sortSelectBox.setItems(getSortList(false));
} else {
m_sortSelectBox.setItems(getSortList(true));
}
m_sortSelectBox.selectValue(searchObj.getSortOrder());
displayResultCount(getResultsDisplayed(searchObj), searchObj.getResultCount());
m_hasMoreResults = searchObj.hasMore();
if (searchObj.getPage() == 1) {
m_preset = null;
getList().scrollToTop();
clearList();
showParams(paramPanels);
m_backwardScrollHandler.updateSearchBean(searchObj);
getList().getElement().getStyle().clearDisplay();
scrollToPreset();
} else {
showParams(paramPanels);
addContent(searchObj);
}
showUpload(searchObj);
} | [
"public",
"void",
"fillContent",
"(",
"final",
"CmsGallerySearchBean",
"searchObj",
",",
"List",
"<",
"CmsSearchParamPanel",
">",
"paramPanels",
")",
"{",
"removeNoParamMessage",
"(",
")",
";",
"// in case there is a single type selected and the current sort order is not by type,",
"// hide the type ascending and type descending sort order options",
"SortParams",
"currentSorting",
"=",
"SortParams",
".",
"valueOf",
"(",
"searchObj",
".",
"getSortOrder",
"(",
")",
")",
";",
"if",
"(",
"(",
"searchObj",
".",
"getTypes",
"(",
")",
".",
"size",
"(",
")",
"==",
"1",
")",
"&&",
"!",
"(",
"(",
"currentSorting",
"==",
"SortParams",
".",
"type_asc",
")",
"||",
"(",
"currentSorting",
"==",
"SortParams",
".",
"type_desc",
")",
")",
")",
"{",
"m_sortSelectBox",
".",
"setItems",
"(",
"getSortList",
"(",
"false",
")",
")",
";",
"}",
"else",
"{",
"m_sortSelectBox",
".",
"setItems",
"(",
"getSortList",
"(",
"true",
")",
")",
";",
"}",
"m_sortSelectBox",
".",
"selectValue",
"(",
"searchObj",
".",
"getSortOrder",
"(",
")",
")",
";",
"displayResultCount",
"(",
"getResultsDisplayed",
"(",
"searchObj",
")",
",",
"searchObj",
".",
"getResultCount",
"(",
")",
")",
";",
"m_hasMoreResults",
"=",
"searchObj",
".",
"hasMore",
"(",
")",
";",
"if",
"(",
"searchObj",
".",
"getPage",
"(",
")",
"==",
"1",
")",
"{",
"m_preset",
"=",
"null",
";",
"getList",
"(",
")",
".",
"scrollToTop",
"(",
")",
";",
"clearList",
"(",
")",
";",
"showParams",
"(",
"paramPanels",
")",
";",
"m_backwardScrollHandler",
".",
"updateSearchBean",
"(",
"searchObj",
")",
";",
"getList",
"(",
")",
".",
"getElement",
"(",
")",
".",
"getStyle",
"(",
")",
".",
"clearDisplay",
"(",
")",
";",
"scrollToPreset",
"(",
")",
";",
"}",
"else",
"{",
"showParams",
"(",
"paramPanels",
")",
";",
"addContent",
"(",
"searchObj",
")",
";",
"}",
"showUpload",
"(",
"searchObj",
")",
";",
"}"
]
| Fill the content of the results tab.<p>
@param searchObj the current search object containing search results
@param paramPanels list of search parameter panels to show | [
"Fill",
"the",
"content",
"of",
"the",
"results",
"tab",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/ui/CmsResultsTab.java#L380-L410 |
soulgalore/crawler | src/main/java/com/soulgalore/crawler/util/HTTPSFaker.java | HTTPSFaker.getClientThatAllowAnyHTTPS | @SuppressWarnings("deprecation")
public static DefaultHttpClient getClientThatAllowAnyHTTPS(ThreadSafeClientConnManager cm) {
"""
Get a HttpClient that accept any HTTP certificate.
@param cm the connection manager to use when creating the new HttpClient
@return a httpClient that accept any HTTP certificate
"""
final TrustManager easyTrustManager = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] xcs, String string)
throws CertificateException {}
public void checkServerTrusted(X509Certificate[] xcs, String string)
throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
final X509HostnameVerifier easyVerifier = new X509HostnameVerifier() {
public boolean verify(String string, SSLSession ssls) {
return true;
}
public void verify(String string, SSLSocket ssls) throws IOException {}
public void verify(String string, String[] strings, String[] strings1) throws SSLException {}
public void verify(String string, X509Certificate xc) throws SSLException {}
};
SSLContext ctx = null;
try {
ctx = SSLContext.getInstance("TLS");
ctx.init(null, new TrustManager[] {easyTrustManager}, null);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
final SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(easyVerifier);
cm.getSchemeRegistry().register(new Scheme(HTTPS, ssf, HTTPS_PORT));
return new DefaultHttpClient(cm);
} | java | @SuppressWarnings("deprecation")
public static DefaultHttpClient getClientThatAllowAnyHTTPS(ThreadSafeClientConnManager cm) {
final TrustManager easyTrustManager = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] xcs, String string)
throws CertificateException {}
public void checkServerTrusted(X509Certificate[] xcs, String string)
throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
final X509HostnameVerifier easyVerifier = new X509HostnameVerifier() {
public boolean verify(String string, SSLSession ssls) {
return true;
}
public void verify(String string, SSLSocket ssls) throws IOException {}
public void verify(String string, String[] strings, String[] strings1) throws SSLException {}
public void verify(String string, X509Certificate xc) throws SSLException {}
};
SSLContext ctx = null;
try {
ctx = SSLContext.getInstance("TLS");
ctx.init(null, new TrustManager[] {easyTrustManager}, null);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
final SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(easyVerifier);
cm.getSchemeRegistry().register(new Scheme(HTTPS, ssf, HTTPS_PORT));
return new DefaultHttpClient(cm);
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"DefaultHttpClient",
"getClientThatAllowAnyHTTPS",
"(",
"ThreadSafeClientConnManager",
"cm",
")",
"{",
"final",
"TrustManager",
"easyTrustManager",
"=",
"new",
"X509TrustManager",
"(",
")",
"{",
"public",
"void",
"checkClientTrusted",
"(",
"X509Certificate",
"[",
"]",
"xcs",
",",
"String",
"string",
")",
"throws",
"CertificateException",
"{",
"}",
"public",
"void",
"checkServerTrusted",
"(",
"X509Certificate",
"[",
"]",
"xcs",
",",
"String",
"string",
")",
"throws",
"CertificateException",
"{",
"}",
"public",
"X509Certificate",
"[",
"]",
"getAcceptedIssuers",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}",
";",
"final",
"X509HostnameVerifier",
"easyVerifier",
"=",
"new",
"X509HostnameVerifier",
"(",
")",
"{",
"public",
"boolean",
"verify",
"(",
"String",
"string",
",",
"SSLSession",
"ssls",
")",
"{",
"return",
"true",
";",
"}",
"public",
"void",
"verify",
"(",
"String",
"string",
",",
"SSLSocket",
"ssls",
")",
"throws",
"IOException",
"{",
"}",
"public",
"void",
"verify",
"(",
"String",
"string",
",",
"String",
"[",
"]",
"strings",
",",
"String",
"[",
"]",
"strings1",
")",
"throws",
"SSLException",
"{",
"}",
"public",
"void",
"verify",
"(",
"String",
"string",
",",
"X509Certificate",
"xc",
")",
"throws",
"SSLException",
"{",
"}",
"}",
";",
"SSLContext",
"ctx",
"=",
"null",
";",
"try",
"{",
"ctx",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"TLS\"",
")",
";",
"ctx",
".",
"init",
"(",
"null",
",",
"new",
"TrustManager",
"[",
"]",
"{",
"easyTrustManager",
"}",
",",
"null",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"KeyManagementException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"final",
"SSLSocketFactory",
"ssf",
"=",
"new",
"SSLSocketFactory",
"(",
"ctx",
")",
";",
"ssf",
".",
"setHostnameVerifier",
"(",
"easyVerifier",
")",
";",
"cm",
".",
"getSchemeRegistry",
"(",
")",
".",
"register",
"(",
"new",
"Scheme",
"(",
"HTTPS",
",",
"ssf",
",",
"HTTPS_PORT",
")",
")",
";",
"return",
"new",
"DefaultHttpClient",
"(",
"cm",
")",
";",
"}"
]
| Get a HttpClient that accept any HTTP certificate.
@param cm the connection manager to use when creating the new HttpClient
@return a httpClient that accept any HTTP certificate | [
"Get",
"a",
"HttpClient",
"that",
"accept",
"any",
"HTTP",
"certificate",
"."
]
| train | https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/util/HTTPSFaker.java#L61-L108 |
google/error-prone | core/src/main/java/com/google/errorprone/refaster/RefasterScanner.java | RefasterScanner.visitDoWhileLoop | @Override
public Void visitDoWhileLoop(DoWhileLoopTree node, Context context) {
"""
/*
Matching on the parentheses surrounding the condition of an if, while, or do-while
is nonsensical, as those parentheses are obligatory and should never be changed.
"""
scan(node.getStatement(), context);
scan(SKIP_PARENS.visit(node.getCondition(), null), context);
return null;
} | java | @Override
public Void visitDoWhileLoop(DoWhileLoopTree node, Context context) {
scan(node.getStatement(), context);
scan(SKIP_PARENS.visit(node.getCondition(), null), context);
return null;
} | [
"@",
"Override",
"public",
"Void",
"visitDoWhileLoop",
"(",
"DoWhileLoopTree",
"node",
",",
"Context",
"context",
")",
"{",
"scan",
"(",
"node",
".",
"getStatement",
"(",
")",
",",
"context",
")",
";",
"scan",
"(",
"SKIP_PARENS",
".",
"visit",
"(",
"node",
".",
"getCondition",
"(",
")",
",",
"null",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
]
| /*
Matching on the parentheses surrounding the condition of an if, while, or do-while
is nonsensical, as those parentheses are obligatory and should never be changed. | [
"/",
"*",
"Matching",
"on",
"the",
"parentheses",
"surrounding",
"the",
"condition",
"of",
"an",
"if",
"while",
"or",
"do",
"-",
"while",
"is",
"nonsensical",
"as",
"those",
"parentheses",
"are",
"obligatory",
"and",
"should",
"never",
"be",
"changed",
"."
]
| train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/RefasterScanner.java#L142-L147 |
aleksandr-m/gitflow-maven-plugin | src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java | AbstractGitFlowMojo.gitPush | protected void gitPush(final String branchName, boolean pushTags)
throws MojoFailureException, CommandLineException {
"""
Executes git push, optionally with the <code>--follow-tags</code>
argument.
@param branchName
Branch name to push.
@param pushTags
If <code>true</code> adds <code>--follow-tags</code> argument
to the git <code>push</code> command.
@throws MojoFailureException
@throws CommandLineException
"""
getLog().info(
"Pushing '" + branchName + "' branch" + " to '"
+ gitFlowConfig.getOrigin() + "'.");
if (pushTags) {
executeGitCommand("push", "--quiet", "-u", "--follow-tags",
gitFlowConfig.getOrigin(), branchName);
} else {
executeGitCommand("push", "--quiet", "-u",
gitFlowConfig.getOrigin(), branchName);
}
} | java | protected void gitPush(final String branchName, boolean pushTags)
throws MojoFailureException, CommandLineException {
getLog().info(
"Pushing '" + branchName + "' branch" + " to '"
+ gitFlowConfig.getOrigin() + "'.");
if (pushTags) {
executeGitCommand("push", "--quiet", "-u", "--follow-tags",
gitFlowConfig.getOrigin(), branchName);
} else {
executeGitCommand("push", "--quiet", "-u",
gitFlowConfig.getOrigin(), branchName);
}
} | [
"protected",
"void",
"gitPush",
"(",
"final",
"String",
"branchName",
",",
"boolean",
"pushTags",
")",
"throws",
"MojoFailureException",
",",
"CommandLineException",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Pushing '\"",
"+",
"branchName",
"+",
"\"' branch\"",
"+",
"\" to '\"",
"+",
"gitFlowConfig",
".",
"getOrigin",
"(",
")",
"+",
"\"'.\"",
")",
";",
"if",
"(",
"pushTags",
")",
"{",
"executeGitCommand",
"(",
"\"push\"",
",",
"\"--quiet\"",
",",
"\"-u\"",
",",
"\"--follow-tags\"",
",",
"gitFlowConfig",
".",
"getOrigin",
"(",
")",
",",
"branchName",
")",
";",
"}",
"else",
"{",
"executeGitCommand",
"(",
"\"push\"",
",",
"\"--quiet\"",
",",
"\"-u\"",
",",
"gitFlowConfig",
".",
"getOrigin",
"(",
")",
",",
"branchName",
")",
";",
"}",
"}"
]
| Executes git push, optionally with the <code>--follow-tags</code>
argument.
@param branchName
Branch name to push.
@param pushTags
If <code>true</code> adds <code>--follow-tags</code> argument
to the git <code>push</code> command.
@throws MojoFailureException
@throws CommandLineException | [
"Executes",
"git",
"push",
"optionally",
"with",
"the",
"<code",
">",
"--",
"follow",
"-",
"tags<",
"/",
"code",
">",
"argument",
"."
]
| train | https://github.com/aleksandr-m/gitflow-maven-plugin/blob/d7be13c653d885c1cb1d8cd0337fa9db985c381e/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java#L883-L896 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Transaction.java | Transaction.hashForSignature | public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript,
SigHash type, boolean anyoneCanPay) {
"""
<p>Calculates a signature hash, that is, a hash of a simplified form of the transaction. How exactly the transaction
is simplified is specified by the type and anyoneCanPay parameters.</p>
<p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
scriptPubKey of the output you're signing for.</p>
@param inputIndex input the signature is being calculated for. Tx signatures are always relative to an input.
@param redeemScript the bytes that should be in the given input during signing.
@param type Should be SigHash.ALL
@param anyoneCanPay should be false.
"""
byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay);
return hashForSignature(inputIndex, redeemScript, sigHashType);
} | java | public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript,
SigHash type, boolean anyoneCanPay) {
byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay);
return hashForSignature(inputIndex, redeemScript, sigHashType);
} | [
"public",
"Sha256Hash",
"hashForSignature",
"(",
"int",
"inputIndex",
",",
"byte",
"[",
"]",
"redeemScript",
",",
"SigHash",
"type",
",",
"boolean",
"anyoneCanPay",
")",
"{",
"byte",
"sigHashType",
"=",
"(",
"byte",
")",
"TransactionSignature",
".",
"calcSigHashValue",
"(",
"type",
",",
"anyoneCanPay",
")",
";",
"return",
"hashForSignature",
"(",
"inputIndex",
",",
"redeemScript",
",",
"sigHashType",
")",
";",
"}"
]
| <p>Calculates a signature hash, that is, a hash of a simplified form of the transaction. How exactly the transaction
is simplified is specified by the type and anyoneCanPay parameters.</p>
<p>This is a low level API and when using the regular {@link Wallet} class you don't have to call this yourself.
When working with more complex transaction types and contracts, it can be necessary. When signing a P2SH output
the redeemScript should be the script encoded into the scriptSig field, for normal transactions, it's the
scriptPubKey of the output you're signing for.</p>
@param inputIndex input the signature is being calculated for. Tx signatures are always relative to an input.
@param redeemScript the bytes that should be in the given input during signing.
@param type Should be SigHash.ALL
@param anyoneCanPay should be false. | [
"<p",
">",
"Calculates",
"a",
"signature",
"hash",
"that",
"is",
"a",
"hash",
"of",
"a",
"simplified",
"form",
"of",
"the",
"transaction",
".",
"How",
"exactly",
"the",
"transaction",
"is",
"simplified",
"is",
"specified",
"by",
"the",
"type",
"and",
"anyoneCanPay",
"parameters",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Transaction.java#L1158-L1162 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/job/internal/AbstractInstallPlanJob.java | AbstractInstallPlanJob.getDependency | private ExtensionDependency getDependency(Extension extension, String dependencyId) {
"""
Extract extension with the provided id from the provided extension.
@param extension the extension
@param dependencyId the id of the dependency
@return the extension dependency or null if none has been found
"""
for (ExtensionDependency dependency : extension.getDependencies()) {
if (dependency.getId().equals(dependencyId)) {
return dependency;
}
}
return null;
} | java | private ExtensionDependency getDependency(Extension extension, String dependencyId)
{
for (ExtensionDependency dependency : extension.getDependencies()) {
if (dependency.getId().equals(dependencyId)) {
return dependency;
}
}
return null;
} | [
"private",
"ExtensionDependency",
"getDependency",
"(",
"Extension",
"extension",
",",
"String",
"dependencyId",
")",
"{",
"for",
"(",
"ExtensionDependency",
"dependency",
":",
"extension",
".",
"getDependencies",
"(",
")",
")",
"{",
"if",
"(",
"dependency",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"dependencyId",
")",
")",
"{",
"return",
"dependency",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Extract extension with the provided id from the provided extension.
@param extension the extension
@param dependencyId the id of the dependency
@return the extension dependency or null if none has been found | [
"Extract",
"extension",
"with",
"the",
"provided",
"id",
"from",
"the",
"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/job/internal/AbstractInstallPlanJob.java#L728-L737 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/ArchiveFileFactory.java | ArchiveFileFactory.registerArchiveFileProvider | public static void registerArchiveFileProvider(Class<? extends IArchiveFile> provider, String fileExtension) {
"""
Registers a custom archive file provider
@param provider
@param fileExtension without the dot
@since 5.0
"""
extensionMap.put(fileExtension, provider);
} | java | public static void registerArchiveFileProvider(Class<? extends IArchiveFile> provider, String fileExtension){
extensionMap.put(fileExtension, provider);
} | [
"public",
"static",
"void",
"registerArchiveFileProvider",
"(",
"Class",
"<",
"?",
"extends",
"IArchiveFile",
">",
"provider",
",",
"String",
"fileExtension",
")",
"{",
"extensionMap",
".",
"put",
"(",
"fileExtension",
",",
"provider",
")",
";",
"}"
]
| Registers a custom archive file provider
@param provider
@param fileExtension without the dot
@since 5.0 | [
"Registers",
"a",
"custom",
"archive",
"file",
"provider"
]
| train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/ArchiveFileFactory.java#L43-L45 |
box/box-java-sdk | src/main/java/com/box/sdk/Metadata.java | Metadata.addOp | private void addOp(String op, String path, String value) {
"""
Adds a patch operation.
@param op the operation type. Must be add, replace, remove, or test.
@param path the path that designates the key. Must be prefixed with a "/".
@param value the value to be set.
"""
if (this.operations == null) {
this.operations = new JsonArray();
}
this.operations.add(new JsonObject()
.add("op", op)
.add("path", path)
.add("value", value));
} | java | private void addOp(String op, String path, String value) {
if (this.operations == null) {
this.operations = new JsonArray();
}
this.operations.add(new JsonObject()
.add("op", op)
.add("path", path)
.add("value", value));
} | [
"private",
"void",
"addOp",
"(",
"String",
"op",
",",
"String",
"path",
",",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"operations",
"==",
"null",
")",
"{",
"this",
".",
"operations",
"=",
"new",
"JsonArray",
"(",
")",
";",
"}",
"this",
".",
"operations",
".",
"add",
"(",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"op\"",
",",
"op",
")",
".",
"add",
"(",
"\"path\"",
",",
"path",
")",
".",
"add",
"(",
"\"value\"",
",",
"value",
")",
")",
";",
"}"
]
| Adds a patch operation.
@param op the operation type. Must be add, replace, remove, or test.
@param path the path that designates the key. Must be prefixed with a "/".
@param value the value to be set. | [
"Adds",
"a",
"patch",
"operation",
"."
]
| train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L411-L420 |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java | IPAddressSection.isZeroHost | public boolean isZeroHost(int prefixLength) {
"""
Returns whether the host is zero for the given prefix length for this section or all sections in this set of address sections.
If this section already has a prefix length, then that prefix length is ignored.
If the host section is zero length (there are no host bits at all), returns false.
@return
"""
if(prefixLength < 0 || prefixLength > getBitCount()) {
throw new PrefixLenException(this, prefixLength);
}
return isZeroHost(prefixLength, getSegments(), getBytesPerSegment(), getBitsPerSegment(), getBitCount());
} | java | public boolean isZeroHost(int prefixLength) {
if(prefixLength < 0 || prefixLength > getBitCount()) {
throw new PrefixLenException(this, prefixLength);
}
return isZeroHost(prefixLength, getSegments(), getBytesPerSegment(), getBitsPerSegment(), getBitCount());
} | [
"public",
"boolean",
"isZeroHost",
"(",
"int",
"prefixLength",
")",
"{",
"if",
"(",
"prefixLength",
"<",
"0",
"||",
"prefixLength",
">",
"getBitCount",
"(",
")",
")",
"{",
"throw",
"new",
"PrefixLenException",
"(",
"this",
",",
"prefixLength",
")",
";",
"}",
"return",
"isZeroHost",
"(",
"prefixLength",
",",
"getSegments",
"(",
")",
",",
"getBytesPerSegment",
"(",
")",
",",
"getBitsPerSegment",
"(",
")",
",",
"getBitCount",
"(",
")",
")",
";",
"}"
]
| Returns whether the host is zero for the given prefix length for this section or all sections in this set of address sections.
If this section already has a prefix length, then that prefix length is ignored.
If the host section is zero length (there are no host bits at all), returns false.
@return | [
"Returns",
"whether",
"the",
"host",
"is",
"zero",
"for",
"the",
"given",
"prefix",
"length",
"for",
"this",
"section",
"or",
"all",
"sections",
"in",
"this",
"set",
"of",
"address",
"sections",
".",
"If",
"this",
"section",
"already",
"has",
"a",
"prefix",
"length",
"then",
"that",
"prefix",
"length",
"is",
"ignored",
".",
"If",
"the",
"host",
"section",
"is",
"zero",
"length",
"(",
"there",
"are",
"no",
"host",
"bits",
"at",
"all",
")",
"returns",
"false",
"."
]
| train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java#L2168-L2173 |
Wolfgang-Schuetzelhofer/jcypher | src/main/java/iot/jcypher/query/values/ReplaceWith.java | ReplaceWith.with | public JcString with(JcString with) {
"""
<div color='red' style="font-size:24px;color:red"><b><i><u>JCYPHER</u></i></b></div>
<div color='red' style="font-size:18px;color:red"><i>specify the replacement for a part of a string</i></div>
<br/>
"""
JcString ret = new JcString(with, this,
new FunctionInstance(FUNCTION.String.REPLACE, 3));
QueryRecorder.recordInvocationConditional(this, "with", ret, QueryRecorder.placeHolder(with));
return ret;
} | java | public JcString with(JcString with) {
JcString ret = new JcString(with, this,
new FunctionInstance(FUNCTION.String.REPLACE, 3));
QueryRecorder.recordInvocationConditional(this, "with", ret, QueryRecorder.placeHolder(with));
return ret;
} | [
"public",
"JcString",
"with",
"(",
"JcString",
"with",
")",
"{",
"JcString",
"ret",
"=",
"new",
"JcString",
"(",
"with",
",",
"this",
",",
"new",
"FunctionInstance",
"(",
"FUNCTION",
".",
"String",
".",
"REPLACE",
",",
"3",
")",
")",
";",
"QueryRecorder",
".",
"recordInvocationConditional",
"(",
"this",
",",
"\"with\"",
",",
"ret",
",",
"QueryRecorder",
".",
"placeHolder",
"(",
"with",
")",
")",
";",
"return",
"ret",
";",
"}"
]
| <div color='red' style="font-size:24px;color:red"><b><i><u>JCYPHER</u></i></b></div>
<div color='red' style="font-size:18px;color:red"><i>specify the replacement for a part of a string</i></div>
<br/> | [
"<div",
"color",
"=",
"red",
"style",
"=",
"font",
"-",
"size",
":",
"24px",
";",
"color",
":",
"red",
">",
"<b",
">",
"<i",
">",
"<u",
">",
"JCYPHER<",
"/",
"u",
">",
"<",
"/",
"i",
">",
"<",
"/",
"b",
">",
"<",
"/",
"div",
">",
"<div",
"color",
"=",
"red",
"style",
"=",
"font",
"-",
"size",
":",
"18px",
";",
"color",
":",
"red",
">",
"<i",
">",
"specify",
"the",
"replacement",
"for",
"a",
"part",
"of",
"a",
"string<",
"/",
"i",
">",
"<",
"/",
"div",
">",
"<br",
"/",
">"
]
| train | https://github.com/Wolfgang-Schuetzelhofer/jcypher/blob/0f36914b4d6993a004cc235bb18dd3e02a59d253/src/main/java/iot/jcypher/query/values/ReplaceWith.java#L53-L58 |
nielsbasjes/logparser | parser-core/src/main/java/nl/basjes/parse/core/Parser.java | Parser.addParseTarget | public Parser<RECORD> addParseTarget(final Method method, final List<String> fieldValues) {
"""
/*
When there is a need to add a target callback manually use this method.
"""
return addParseTarget(method, SetterPolicy.ALWAYS, fieldValues);
} | java | public Parser<RECORD> addParseTarget(final Method method, final List<String> fieldValues) {
return addParseTarget(method, SetterPolicy.ALWAYS, fieldValues);
} | [
"public",
"Parser",
"<",
"RECORD",
">",
"addParseTarget",
"(",
"final",
"Method",
"method",
",",
"final",
"List",
"<",
"String",
">",
"fieldValues",
")",
"{",
"return",
"addParseTarget",
"(",
"method",
",",
"SetterPolicy",
".",
"ALWAYS",
",",
"fieldValues",
")",
";",
"}"
]
| /*
When there is a need to add a target callback manually use this method. | [
"/",
"*",
"When",
"there",
"is",
"a",
"need",
"to",
"add",
"a",
"target",
"callback",
"manually",
"use",
"this",
"method",
"."
]
| train | https://github.com/nielsbasjes/logparser/blob/236d5bf91926addab82b20387262bb35da8512cd/parser-core/src/main/java/nl/basjes/parse/core/Parser.java#L575-L577 |
reactor/reactor-netty | src/main/java/reactor/netty/ByteBufMono.java | ByteBufMono.asByteBuffer | public final Mono<ByteBuffer> asByteBuffer() {
"""
a {@link ByteBuffer} inbound {@link Mono}
@return a {@link ByteBuffer} inbound {@link Mono}
"""
return handle((bb, sink) -> {
try {
sink.next(bb.nioBuffer());
}
catch (IllegalReferenceCountException e) {
sink.complete();
}
});
} | java | public final Mono<ByteBuffer> asByteBuffer() {
return handle((bb, sink) -> {
try {
sink.next(bb.nioBuffer());
}
catch (IllegalReferenceCountException e) {
sink.complete();
}
});
} | [
"public",
"final",
"Mono",
"<",
"ByteBuffer",
">",
"asByteBuffer",
"(",
")",
"{",
"return",
"handle",
"(",
"(",
"bb",
",",
"sink",
")",
"->",
"{",
"try",
"{",
"sink",
".",
"next",
"(",
"bb",
".",
"nioBuffer",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalReferenceCountException",
"e",
")",
"{",
"sink",
".",
"complete",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| a {@link ByteBuffer} inbound {@link Mono}
@return a {@link ByteBuffer} inbound {@link Mono} | [
"a",
"{",
"@link",
"ByteBuffer",
"}",
"inbound",
"{",
"@link",
"Mono",
"}"
]
| train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/ByteBufMono.java#L45-L54 |
albfernandez/itext2 | src/main/java/com/lowagie/text/rtf/parser/RtfParser.java | RtfParser.importRtfDocumentIntoElement | public void importRtfDocumentIntoElement(Element elem, InputStream readerIn, RtfDocument rtfDoc) throws IOException {
"""
Imports a complete RTF document into an Element, i.e. Chapter, section, Table Cell, etc.
@param elem The Element the document is to be imported into.
@param readerIn
The Reader to read the RTF document from.
@param rtfDoc
The RtfDocument to add the imported document to.
@throws IOException On I/O errors.
@since 2.1.4
"""
if(readerIn == null || rtfDoc == null || elem == null) return;
this.init(TYPE_IMPORT_INTO_ELEMENT, rtfDoc, readerIn, this.document, elem);
this.setCurrentDestination(RtfDestinationMgr.DESTINATION_NULL);
this.groupLevel = 0;
try {
this.tokenise();
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} | java | public void importRtfDocumentIntoElement(Element elem, InputStream readerIn, RtfDocument rtfDoc) throws IOException {
if(readerIn == null || rtfDoc == null || elem == null) return;
this.init(TYPE_IMPORT_INTO_ELEMENT, rtfDoc, readerIn, this.document, elem);
this.setCurrentDestination(RtfDestinationMgr.DESTINATION_NULL);
this.groupLevel = 0;
try {
this.tokenise();
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} | [
"public",
"void",
"importRtfDocumentIntoElement",
"(",
"Element",
"elem",
",",
"InputStream",
"readerIn",
",",
"RtfDocument",
"rtfDoc",
")",
"throws",
"IOException",
"{",
"if",
"(",
"readerIn",
"==",
"null",
"||",
"rtfDoc",
"==",
"null",
"||",
"elem",
"==",
"null",
")",
"return",
";",
"this",
".",
"init",
"(",
"TYPE_IMPORT_INTO_ELEMENT",
",",
"rtfDoc",
",",
"readerIn",
",",
"this",
".",
"document",
",",
"elem",
")",
";",
"this",
".",
"setCurrentDestination",
"(",
"RtfDestinationMgr",
".",
"DESTINATION_NULL",
")",
";",
"this",
".",
"groupLevel",
"=",
"0",
";",
"try",
"{",
"this",
".",
"tokenise",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"// TODO Auto-generated catch block\r",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// TODO Auto-generated catch block\r",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
]
| Imports a complete RTF document into an Element, i.e. Chapter, section, Table Cell, etc.
@param elem The Element the document is to be imported into.
@param readerIn
The Reader to read the RTF document from.
@param rtfDoc
The RtfDocument to add the imported document to.
@throws IOException On I/O errors.
@since 2.1.4 | [
"Imports",
"a",
"complete",
"RTF",
"document",
"into",
"an",
"Element",
"i",
".",
"e",
".",
"Chapter",
"section",
"Table",
"Cell",
"etc",
"."
]
| train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/rtf/parser/RtfParser.java#L509-L524 |
bmwcarit/joynr | java/core/clustercontroller/src/main/java/io/joynr/accesscontrol/AccessControlAlgorithm.java | AccessControlAlgorithm.getConsumerPermission | public Permission getConsumerPermission(@Nullable MasterAccessControlEntry master,
@Nullable MasterAccessControlEntry mediator,
@Nullable OwnerAccessControlEntry owner,
TrustLevel trustLevel) {
"""
Get the consumer permission for given combination of control entries and with the given trust level.
@param master The master access control entry
@param mediator The mediator access control entry
@param owner The owner access control entry
@param trustLevel The trust level of the user sending the message
@return consumer permission
"""
return getPermission(PermissionType.CONSUMER, master, mediator, owner, trustLevel);
} | java | public Permission getConsumerPermission(@Nullable MasterAccessControlEntry master,
@Nullable MasterAccessControlEntry mediator,
@Nullable OwnerAccessControlEntry owner,
TrustLevel trustLevel) {
return getPermission(PermissionType.CONSUMER, master, mediator, owner, trustLevel);
} | [
"public",
"Permission",
"getConsumerPermission",
"(",
"@",
"Nullable",
"MasterAccessControlEntry",
"master",
",",
"@",
"Nullable",
"MasterAccessControlEntry",
"mediator",
",",
"@",
"Nullable",
"OwnerAccessControlEntry",
"owner",
",",
"TrustLevel",
"trustLevel",
")",
"{",
"return",
"getPermission",
"(",
"PermissionType",
".",
"CONSUMER",
",",
"master",
",",
"mediator",
",",
"owner",
",",
"trustLevel",
")",
";",
"}"
]
| Get the consumer permission for given combination of control entries and with the given trust level.
@param master The master access control entry
@param mediator The mediator access control entry
@param owner The owner access control entry
@param trustLevel The trust level of the user sending the message
@return consumer permission | [
"Get",
"the",
"consumer",
"permission",
"for",
"given",
"combination",
"of",
"control",
"entries",
"and",
"with",
"the",
"given",
"trust",
"level",
"."
]
| train | https://github.com/bmwcarit/joynr/blob/b7a92bad1cf2f093de080facd2c803560f4c6c26/java/core/clustercontroller/src/main/java/io/joynr/accesscontrol/AccessControlAlgorithm.java#L42-L48 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/app/PendingIntentUtils.java | PendingIntentUtils.getActivities | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags) {
"""
Create a new {@link PendingIntent} clearing previously created {@link PendingIntent} that does not work properly due to application's re-installation.
Bugfix utility for this issue: https://code.google.com/p/android/issues/detail?id=61850
"""
PendingIntent.getActivities(context, requestCode, intents, flags).cancel();
return PendingIntent.getActivities(context, requestCode, intents, flags);
} | java | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags) {
PendingIntent.getActivities(context, requestCode, intents, flags).cancel();
return PendingIntent.getActivities(context, requestCode, intents, flags);
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"public",
"static",
"PendingIntent",
"getActivities",
"(",
"Context",
"context",
",",
"int",
"requestCode",
",",
"Intent",
"[",
"]",
"intents",
",",
"int",
"flags",
")",
"{",
"PendingIntent",
".",
"getActivities",
"(",
"context",
",",
"requestCode",
",",
"intents",
",",
"flags",
")",
".",
"cancel",
"(",
")",
";",
"return",
"PendingIntent",
".",
"getActivities",
"(",
"context",
",",
"requestCode",
",",
"intents",
",",
"flags",
")",
";",
"}"
]
| Create a new {@link PendingIntent} clearing previously created {@link PendingIntent} that does not work properly due to application's re-installation.
Bugfix utility for this issue: https://code.google.com/p/android/issues/detail?id=61850 | [
"Create",
"a",
"new",
"{"
]
| train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/PendingIntentUtils.java#L22-L26 |
OrienteerBAP/wicket-orientdb | wicket-orientdb/src/main/java/ru/ydn/wicket/wicketorientdb/security/OSecurityHelper.java | OSecurityHelper.isAllowed | public static boolean isAllowed(ORule.ResourceGeneric resource, String specific, OrientPermission... permissions) {
"""
Check that all required permissions present for specified resource and specific
@param resource specific resource to secure
@param specific specific resource to secure
@param permissions {@link OrientPermission}s to check
@return true of require resource if allowed for current user
"""
return OrientDbWebSession.get().getEffectiveUser()
.checkIfAllowed(resource, specific, OrientPermission.combinedPermission(permissions))!=null;
} | java | public static boolean isAllowed(ORule.ResourceGeneric resource, String specific, OrientPermission... permissions)
{
return OrientDbWebSession.get().getEffectiveUser()
.checkIfAllowed(resource, specific, OrientPermission.combinedPermission(permissions))!=null;
} | [
"public",
"static",
"boolean",
"isAllowed",
"(",
"ORule",
".",
"ResourceGeneric",
"resource",
",",
"String",
"specific",
",",
"OrientPermission",
"...",
"permissions",
")",
"{",
"return",
"OrientDbWebSession",
".",
"get",
"(",
")",
".",
"getEffectiveUser",
"(",
")",
".",
"checkIfAllowed",
"(",
"resource",
",",
"specific",
",",
"OrientPermission",
".",
"combinedPermission",
"(",
"permissions",
")",
")",
"!=",
"null",
";",
"}"
]
| Check that all required permissions present for specified resource and specific
@param resource specific resource to secure
@param specific specific resource to secure
@param permissions {@link OrientPermission}s to check
@return true of require resource if allowed for current user | [
"Check",
"that",
"all",
"required",
"permissions",
"present",
"for",
"specified",
"resource",
"and",
"specific"
]
| train | https://github.com/OrienteerBAP/wicket-orientdb/blob/eb1d94f00a6bff9e266c5c032baa6043afc1db92/wicket-orientdb/src/main/java/ru/ydn/wicket/wicketorientdb/security/OSecurityHelper.java#L213-L217 |
jenkinsci/jenkins | core/src/main/java/hudson/model/AbstractProject.java | AbstractProject.scheduleBuild | public boolean scheduleBuild(int quietPeriod, Cause c, Action... actions) {
"""
Schedules a build.
Important: the actions should be persistable without outside references (e.g. don't store
references to this project). To provide parameters for a parameterized project, add a ParametersAction. If
no ParametersAction is provided for such a project, one will be created with the default parameter values.
@param quietPeriod the quiet period to observer
@param c the cause for this build which should be recorded
@param actions a list of Actions that will be added to the build
@return whether the build was actually scheduled
"""
return scheduleBuild2(quietPeriod,c,actions)!=null;
} | java | public boolean scheduleBuild(int quietPeriod, Cause c, Action... actions) {
return scheduleBuild2(quietPeriod,c,actions)!=null;
} | [
"public",
"boolean",
"scheduleBuild",
"(",
"int",
"quietPeriod",
",",
"Cause",
"c",
",",
"Action",
"...",
"actions",
")",
"{",
"return",
"scheduleBuild2",
"(",
"quietPeriod",
",",
"c",
",",
"actions",
")",
"!=",
"null",
";",
"}"
]
| Schedules a build.
Important: the actions should be persistable without outside references (e.g. don't store
references to this project). To provide parameters for a parameterized project, add a ParametersAction. If
no ParametersAction is provided for such a project, one will be created with the default parameter values.
@param quietPeriod the quiet period to observer
@param c the cause for this build which should be recorded
@param actions a list of Actions that will be added to the build
@return whether the build was actually scheduled | [
"Schedules",
"a",
"build",
"."
]
| train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/AbstractProject.java#L795-L797 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java | Section508Compliance.processSetSizeOps | private void processSetSizeOps(String methodName) throws ClassNotFoundException {
"""
looks for calls to setSize on components, rather than letting the layout manager set them
@param methodName
the method that was called on a component
@throws ClassNotFoundException
if the gui class wasn't found
"""
if ("setSize".equals(methodName)) {
int argCount = SignatureUtils.getNumParameters(getSigConstantOperand());
if ((windowClass != null) && (stack.getStackDepth() > argCount)) {
OpcodeStack.Item item = stack.getStackItem(argCount);
JavaClass cls = item.getJavaClass();
if ((cls != null) && cls.instanceOf(windowClass)) {
bugReporter.reportBug(
new BugInstance(this, BugType.S508C_NO_SETSIZE.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
}
}
} | java | private void processSetSizeOps(String methodName) throws ClassNotFoundException {
if ("setSize".equals(methodName)) {
int argCount = SignatureUtils.getNumParameters(getSigConstantOperand());
if ((windowClass != null) && (stack.getStackDepth() > argCount)) {
OpcodeStack.Item item = stack.getStackItem(argCount);
JavaClass cls = item.getJavaClass();
if ((cls != null) && cls.instanceOf(windowClass)) {
bugReporter.reportBug(
new BugInstance(this, BugType.S508C_NO_SETSIZE.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
}
}
} | [
"private",
"void",
"processSetSizeOps",
"(",
"String",
"methodName",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"\"setSize\"",
".",
"equals",
"(",
"methodName",
")",
")",
"{",
"int",
"argCount",
"=",
"SignatureUtils",
".",
"getNumParameters",
"(",
"getSigConstantOperand",
"(",
")",
")",
";",
"if",
"(",
"(",
"windowClass",
"!=",
"null",
")",
"&&",
"(",
"stack",
".",
"getStackDepth",
"(",
")",
">",
"argCount",
")",
")",
"{",
"OpcodeStack",
".",
"Item",
"item",
"=",
"stack",
".",
"getStackItem",
"(",
"argCount",
")",
";",
"JavaClass",
"cls",
"=",
"item",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"(",
"cls",
"!=",
"null",
")",
"&&",
"cls",
".",
"instanceOf",
"(",
"windowClass",
")",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"S508C_NO_SETSIZE",
".",
"name",
"(",
")",
",",
"NORMAL_PRIORITY",
")",
".",
"addClass",
"(",
"this",
")",
".",
"addMethod",
"(",
"this",
")",
".",
"addSourceLine",
"(",
"this",
")",
")",
";",
"}",
"}",
"}",
"}"
]
| looks for calls to setSize on components, rather than letting the layout manager set them
@param methodName
the method that was called on a component
@throws ClassNotFoundException
if the gui class wasn't found | [
"looks",
"for",
"calls",
"to",
"setSize",
"on",
"components",
"rather",
"than",
"letting",
"the",
"layout",
"manager",
"set",
"them"
]
| train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java#L408-L420 |
csc19601128/Phynixx | phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/RestartCondition.java | RestartCondition.conditionViolated | public void conditionViolated() {
"""
Not synchronized as to be meant for the watch dog exclusively
Do not call it unsynchronized
"""
if (this.watchdogReference.isStale()) {
throw new IllegalStateException("Watchdog is stale and does not exist any longer");
}
Watchdog wd = this.watchdogReference.getWatchdog();
wd.restart();
if (log.isInfoEnabled()) {
log.info(new ConditionViolatedLog(this, "Watchdog " + wd.getId() + " is restarted by Condition " + this.toString()).toString());
}
} | java | public void conditionViolated() {
if (this.watchdogReference.isStale()) {
throw new IllegalStateException("Watchdog is stale and does not exist any longer");
}
Watchdog wd = this.watchdogReference.getWatchdog();
wd.restart();
if (log.isInfoEnabled()) {
log.info(new ConditionViolatedLog(this, "Watchdog " + wd.getId() + " is restarted by Condition " + this.toString()).toString());
}
} | [
"public",
"void",
"conditionViolated",
"(",
")",
"{",
"if",
"(",
"this",
".",
"watchdogReference",
".",
"isStale",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Watchdog is stale and does not exist any longer\"",
")",
";",
"}",
"Watchdog",
"wd",
"=",
"this",
".",
"watchdogReference",
".",
"getWatchdog",
"(",
")",
";",
"wd",
".",
"restart",
"(",
")",
";",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"new",
"ConditionViolatedLog",
"(",
"this",
",",
"\"Watchdog \"",
"+",
"wd",
".",
"getId",
"(",
")",
"+",
"\" is restarted by Condition \"",
"+",
"this",
".",
"toString",
"(",
")",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
]
| Not synchronized as to be meant for the watch dog exclusively
Do not call it unsynchronized | [
"Not",
"synchronized",
"as",
"to",
"be",
"meant",
"for",
"the",
"watch",
"dog",
"exclusively"
]
| train | https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/RestartCondition.java#L84-L96 |
vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.getReferenceCollection | public <T, K> JacksonDBCollection<T, K> getReferenceCollection(String collectionName, JavaType type, JavaType keyType) {
"""
Get a collection for loading a reference of the given type
@param collectionName The name of the collection
@param type The type of the object
@param keyType the type of the id
@return The collection
"""
return getReferenceCollection(new JacksonCollectionKey(collectionName, type, keyType));
} | java | public <T, K> JacksonDBCollection<T, K> getReferenceCollection(String collectionName, JavaType type, JavaType keyType) {
return getReferenceCollection(new JacksonCollectionKey(collectionName, type, keyType));
} | [
"public",
"<",
"T",
",",
"K",
">",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"getReferenceCollection",
"(",
"String",
"collectionName",
",",
"JavaType",
"type",
",",
"JavaType",
"keyType",
")",
"{",
"return",
"getReferenceCollection",
"(",
"new",
"JacksonCollectionKey",
"(",
"collectionName",
",",
"type",
",",
"keyType",
")",
")",
";",
"}"
]
| Get a collection for loading a reference of the given type
@param collectionName The name of the collection
@param type The type of the object
@param keyType the type of the id
@return The collection | [
"Get",
"a",
"collection",
"for",
"loading",
"a",
"reference",
"of",
"the",
"given",
"type"
]
| train | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1519-L1521 |
ontop/ontop | core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java | OntologyBuilderImpl.addDataPropertyRangeAxiom | @Override
public void addDataPropertyRangeAxiom(DataPropertyRangeExpression range, Datatype datatype) throws InconsistentOntologyException {
"""
Normalizes and adds a data property range axiom
<p>
DataPropertyRange := 'DataPropertyRange' '(' axiomAnnotations DataPropertyExpression DataRange ')'
<p>
Implements rule [D3]:
- ignore if the property is bot or the range is rdfs:Literal (top datatype)
- inconsistency if the property is top but the range is not rdfs:Literal
@throws InconsistentOntologyException
"""
checkSignature(range);
checkSignature(datatype);
if (datatype.equals(DatatypeImpl.rdfsLiteral))
return;
// otherwise the datatype is not top
if (range.getProperty().isBottom())
return;
if (range.getProperty().isTop())
throw new InconsistentOntologyException();
BinaryAxiom<DataRangeExpression> ax = new BinaryAxiomImpl<>(range, datatype);
subDataRangeAxioms.add(ax);
} | java | @Override
public void addDataPropertyRangeAxiom(DataPropertyRangeExpression range, Datatype datatype) throws InconsistentOntologyException {
checkSignature(range);
checkSignature(datatype);
if (datatype.equals(DatatypeImpl.rdfsLiteral))
return;
// otherwise the datatype is not top
if (range.getProperty().isBottom())
return;
if (range.getProperty().isTop())
throw new InconsistentOntologyException();
BinaryAxiom<DataRangeExpression> ax = new BinaryAxiomImpl<>(range, datatype);
subDataRangeAxioms.add(ax);
} | [
"@",
"Override",
"public",
"void",
"addDataPropertyRangeAxiom",
"(",
"DataPropertyRangeExpression",
"range",
",",
"Datatype",
"datatype",
")",
"throws",
"InconsistentOntologyException",
"{",
"checkSignature",
"(",
"range",
")",
";",
"checkSignature",
"(",
"datatype",
")",
";",
"if",
"(",
"datatype",
".",
"equals",
"(",
"DatatypeImpl",
".",
"rdfsLiteral",
")",
")",
"return",
";",
"// otherwise the datatype is not top",
"if",
"(",
"range",
".",
"getProperty",
"(",
")",
".",
"isBottom",
"(",
")",
")",
"return",
";",
"if",
"(",
"range",
".",
"getProperty",
"(",
")",
".",
"isTop",
"(",
")",
")",
"throw",
"new",
"InconsistentOntologyException",
"(",
")",
";",
"BinaryAxiom",
"<",
"DataRangeExpression",
">",
"ax",
"=",
"new",
"BinaryAxiomImpl",
"<>",
"(",
"range",
",",
"datatype",
")",
";",
"subDataRangeAxioms",
".",
"add",
"(",
"ax",
")",
";",
"}"
]
| Normalizes and adds a data property range axiom
<p>
DataPropertyRange := 'DataPropertyRange' '(' axiomAnnotations DataPropertyExpression DataRange ')'
<p>
Implements rule [D3]:
- ignore if the property is bot or the range is rdfs:Literal (top datatype)
- inconsistency if the property is top but the range is not rdfs:Literal
@throws InconsistentOntologyException | [
"Normalizes",
"and",
"adds",
"a",
"data",
"property",
"range",
"axiom",
"<p",
">",
"DataPropertyRange",
":",
"=",
"DataPropertyRange",
"(",
"axiomAnnotations",
"DataPropertyExpression",
"DataRange",
")",
"<p",
">",
"Implements",
"rule",
"[",
"D3",
"]",
":",
"-",
"ignore",
"if",
"the",
"property",
"is",
"bot",
"or",
"the",
"range",
"is",
"rdfs",
":",
"Literal",
"(",
"top",
"datatype",
")",
"-",
"inconsistency",
"if",
"the",
"property",
"is",
"top",
"but",
"the",
"range",
"is",
"not",
"rdfs",
":",
"Literal"
]
| train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java#L233-L248 |
jbundle/jbundle | main/calendar/src/main/java/org/jbundle/main/calendar/db/CalendarEntry.java | CalendarEntry.createSharedRecord | public Record createSharedRecord(Object objKey, RecordOwner recordOwner) {
"""
Get the shared record that goes with this key.
(Always override this).
@param objKey The value that specifies the record type.
@return The correct (new) record for this type (or null if none).
"""
if (objKey instanceof Integer)
{
int iCalendarType = ((Integer)objKey).intValue();
if (iCalendarType == CalendarEntry.APPOINTMENT_ID)
return new Appointment(recordOwner);
if (iCalendarType == CalendarEntry.ANNIVERSARY_ID)
return new Anniversary(recordOwner);
}
return null;
} | java | public Record createSharedRecord(Object objKey, RecordOwner recordOwner)
{
if (objKey instanceof Integer)
{
int iCalendarType = ((Integer)objKey).intValue();
if (iCalendarType == CalendarEntry.APPOINTMENT_ID)
return new Appointment(recordOwner);
if (iCalendarType == CalendarEntry.ANNIVERSARY_ID)
return new Anniversary(recordOwner);
}
return null;
} | [
"public",
"Record",
"createSharedRecord",
"(",
"Object",
"objKey",
",",
"RecordOwner",
"recordOwner",
")",
"{",
"if",
"(",
"objKey",
"instanceof",
"Integer",
")",
"{",
"int",
"iCalendarType",
"=",
"(",
"(",
"Integer",
")",
"objKey",
")",
".",
"intValue",
"(",
")",
";",
"if",
"(",
"iCalendarType",
"==",
"CalendarEntry",
".",
"APPOINTMENT_ID",
")",
"return",
"new",
"Appointment",
"(",
"recordOwner",
")",
";",
"if",
"(",
"iCalendarType",
"==",
"CalendarEntry",
".",
"ANNIVERSARY_ID",
")",
"return",
"new",
"Anniversary",
"(",
"recordOwner",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Get the shared record that goes with this key.
(Always override this).
@param objKey The value that specifies the record type.
@return The correct (new) record for this type (or null if none). | [
"Get",
"the",
"shared",
"record",
"that",
"goes",
"with",
"this",
"key",
".",
"(",
"Always",
"override",
"this",
")",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/calendar/src/main/java/org/jbundle/main/calendar/db/CalendarEntry.java#L256-L267 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVREventManager.java | GVREventManager.sendEvent | public boolean sendEvent(Object target, Class<? extends IEvents> eventsClass,
String eventName, Object... params) {
"""
Delivers an event to a handler object. An event is sent in the following
way: <p>
<ol>
<li> If the {@code target} defines the interface of the class object
{@code eventsClass}, the event is delivered to it first, by invoking
the corresponding method in the {@code target}. </li>
<li> If the {@code target} implements interface {@link IEventReceiver}, the
event is delivered to listeners added to the {@link GVREventReceiver} object.
See {@link GVREventReceiver} for more information.
</li>
<li> If the target is bound with scripts, the event is delivered to the scripts.
A script can be attached to the target using {@link org.gearvrf.script.GVRScriptManager#attachScriptFile(IScriptable, GVRScriptFile)}.</li>
</ol>
@param target
The object which handles the event.
@param eventsClass
The interface class object representing an event group, such
as {@link IScriptEvents}.class.
@param eventName
The name of the event, such as "onInit".
@param params
Parameters of the event. It should match the parameter list
of the corresponding method in the interface, specified by {@code
event class}
@return
{@code true} if the event is handled successfully, {@code false} if not handled
or any error occurred.
"""
return sendEventWithMask(SEND_MASK_ALL, target, eventsClass, eventName, params);
} | java | public boolean sendEvent(Object target, Class<? extends IEvents> eventsClass,
String eventName, Object... params) {
return sendEventWithMask(SEND_MASK_ALL, target, eventsClass, eventName, params);
} | [
"public",
"boolean",
"sendEvent",
"(",
"Object",
"target",
",",
"Class",
"<",
"?",
"extends",
"IEvents",
">",
"eventsClass",
",",
"String",
"eventName",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"sendEventWithMask",
"(",
"SEND_MASK_ALL",
",",
"target",
",",
"eventsClass",
",",
"eventName",
",",
"params",
")",
";",
"}"
]
| Delivers an event to a handler object. An event is sent in the following
way: <p>
<ol>
<li> If the {@code target} defines the interface of the class object
{@code eventsClass}, the event is delivered to it first, by invoking
the corresponding method in the {@code target}. </li>
<li> If the {@code target} implements interface {@link IEventReceiver}, the
event is delivered to listeners added to the {@link GVREventReceiver} object.
See {@link GVREventReceiver} for more information.
</li>
<li> If the target is bound with scripts, the event is delivered to the scripts.
A script can be attached to the target using {@link org.gearvrf.script.GVRScriptManager#attachScriptFile(IScriptable, GVRScriptFile)}.</li>
</ol>
@param target
The object which handles the event.
@param eventsClass
The interface class object representing an event group, such
as {@link IScriptEvents}.class.
@param eventName
The name of the event, such as "onInit".
@param params
Parameters of the event. It should match the parameter list
of the corresponding method in the interface, specified by {@code
event class}
@return
{@code true} if the event is handled successfully, {@code false} if not handled
or any error occurred. | [
"Delivers",
"an",
"event",
"to",
"a",
"handler",
"object",
".",
"An",
"event",
"is",
"sent",
"in",
"the",
"following",
"way",
":",
"<p",
">"
]
| train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVREventManager.java#L106-L109 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/commerce/orders/ExtendedPropertyUrl.java | ExtendedPropertyUrl.updateExtendedPropertyUrl | public static MozuUrl updateExtendedPropertyUrl(String key, String orderId, String responseFields, String updateMode, Boolean upsert, String version) {
"""
Get Resource Url for UpdateExtendedProperty
@param key The extended property key.
@param orderId Unique identifier of the order.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@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 upsert Inserts and updates an extended property.
@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}&upsert={upsert}&responseFields={responseFields}");
formatter.formatUrl("key", key);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("updateMode", updateMode);
formatter.formatUrl("upsert", upsert);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl updateExtendedPropertyUrl(String key, String orderId, String responseFields, String updateMode, Boolean upsert, String version)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}&upsert={upsert}&responseFields={responseFields}");
formatter.formatUrl("key", key);
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("updateMode", updateMode);
formatter.formatUrl("upsert", upsert);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"updateExtendedPropertyUrl",
"(",
"String",
"key",
",",
"String",
"orderId",
",",
"String",
"responseFields",
",",
"String",
"updateMode",
",",
"Boolean",
"upsert",
",",
"String",
"version",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}&upsert={upsert}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"key\"",
",",
"key",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"orderId\"",
",",
"orderId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"updateMode\"",
",",
"updateMode",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"upsert\"",
",",
"upsert",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"version\"",
",",
"version",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
]
| Get Resource Url for UpdateExtendedProperty
@param key The extended property key.
@param orderId Unique identifier of the order.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@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 upsert Inserts and updates an extended property.
@param version Determines whether or not to check versioning of items for concurrency purposes.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"UpdateExtendedProperty",
"@param",
"key",
"The",
"extended",
"property",
"key",
".",
"@param",
"orderId",
"Unique",
"identifier",
"of",
"the",
"order",
".",
"@param",
"responseFields",
"Filtering",
"syntax",
"appended",
"to",
"an",
"API",
"call",
"to",
"increase",
"or",
"decrease",
"the",
"amount",
"of",
"data",
"returned",
"inside",
"a",
"JSON",
"object",
".",
"This",
"parameter",
"should",
"only",
"be",
"used",
"to",
"retrieve",
"data",
".",
"Attempting",
"to",
"update",
"data",
"using",
"this",
"parameter",
"may",
"cause",
"data",
"loss",
".",
"@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",
"upsert",
"Inserts",
"and",
"updates",
"an",
"extended",
"property",
"."
]
| train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/orders/ExtendedPropertyUrl.java#L57-L67 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UTF16.java | UTF16.countCodePoint | public static int countCodePoint(StringBuffer source) {
"""
Number of codepoints in a UTF16 String buffer
@param source UTF16 string buffer
@return number of codepoint in string
"""
if (source == null || source.length() == 0) {
return 0;
}
return findCodePointOffset(source, source.length());
} | java | public static int countCodePoint(StringBuffer source) {
if (source == null || source.length() == 0) {
return 0;
}
return findCodePointOffset(source, source.length());
} | [
"public",
"static",
"int",
"countCodePoint",
"(",
"StringBuffer",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
"||",
"source",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"return",
"findCodePointOffset",
"(",
"source",
",",
"source",
".",
"length",
"(",
")",
")",
";",
"}"
]
| Number of codepoints in a UTF16 String buffer
@param source UTF16 string buffer
@return number of codepoint in string | [
"Number",
"of",
"codepoints",
"in",
"a",
"UTF16",
"String",
"buffer"
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UTF16.java#L1051-L1056 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/GalleriesApi.java | GalleriesApi.getList | public GalleryList getList(String userId, int perPage, int page, EnumSet<JinxConstants.PhotoExtras> extras) throws JinxException {
"""
Return the list of galleries created by a user. Sorted from newest to oldest.
<br>
This method does not require authentication.
@param userId Required. The NSID of the user to get a galleries list for. If none is specified, the calling user is assumed.
@param perPage Optional. Number of galleries to return per page. If this argument is ≤= 0, it defaults to 100. The maximum allowed value is 500.
@param page Optional. The page of results to return. If this argument is ≤= 0, it defaults to 1.
@param extras Optional. Extra information to fetch for the primary photo.
@return list of galleries for the user.
@throws JinxException if required parameters are null or empty, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.galleries.getList.html">flickr.galleries.getList</a>
"""
JinxUtils.validateParams(userId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.galleries.getList");
params.put("user_id", userId);
if (perPage > 0) {
params.put("per_page", Integer.toString(perPage));
}
if (page > 0) {
params.put("page", Integer.toString(page));
}
if (!JinxUtils.isNullOrEmpty(extras)) {
params.put("primary_photo_extras", JinxUtils.buildCommaDelimitedList(extras));
}
return jinx.flickrGet(params, GalleryList.class);
} | java | public GalleryList getList(String userId, int perPage, int page, EnumSet<JinxConstants.PhotoExtras> extras) throws JinxException {
JinxUtils.validateParams(userId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.galleries.getList");
params.put("user_id", userId);
if (perPage > 0) {
params.put("per_page", Integer.toString(perPage));
}
if (page > 0) {
params.put("page", Integer.toString(page));
}
if (!JinxUtils.isNullOrEmpty(extras)) {
params.put("primary_photo_extras", JinxUtils.buildCommaDelimitedList(extras));
}
return jinx.flickrGet(params, GalleryList.class);
} | [
"public",
"GalleryList",
"getList",
"(",
"String",
"userId",
",",
"int",
"perPage",
",",
"int",
"page",
",",
"EnumSet",
"<",
"JinxConstants",
".",
"PhotoExtras",
">",
"extras",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"userId",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.galleries.getList\"",
")",
";",
"params",
".",
"put",
"(",
"\"user_id\"",
",",
"userId",
")",
";",
"if",
"(",
"perPage",
">",
"0",
")",
"{",
"params",
".",
"put",
"(",
"\"per_page\"",
",",
"Integer",
".",
"toString",
"(",
"perPage",
")",
")",
";",
"}",
"if",
"(",
"page",
">",
"0",
")",
"{",
"params",
".",
"put",
"(",
"\"page\"",
",",
"Integer",
".",
"toString",
"(",
"page",
")",
")",
";",
"}",
"if",
"(",
"!",
"JinxUtils",
".",
"isNullOrEmpty",
"(",
"extras",
")",
")",
"{",
"params",
".",
"put",
"(",
"\"primary_photo_extras\"",
",",
"JinxUtils",
".",
"buildCommaDelimitedList",
"(",
"extras",
")",
")",
";",
"}",
"return",
"jinx",
".",
"flickrGet",
"(",
"params",
",",
"GalleryList",
".",
"class",
")",
";",
"}"
]
| Return the list of galleries created by a user. Sorted from newest to oldest.
<br>
This method does not require authentication.
@param userId Required. The NSID of the user to get a galleries list for. If none is specified, the calling user is assumed.
@param perPage Optional. Number of galleries to return per page. If this argument is ≤= 0, it defaults to 100. The maximum allowed value is 500.
@param page Optional. The page of results to return. If this argument is ≤= 0, it defaults to 1.
@param extras Optional. Extra information to fetch for the primary photo.
@return list of galleries for the user.
@throws JinxException if required parameters are null or empty, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.galleries.getList.html">flickr.galleries.getList</a> | [
"Return",
"the",
"list",
"of",
"galleries",
"created",
"by",
"a",
"user",
".",
"Sorted",
"from",
"newest",
"to",
"oldest",
".",
"<br",
">",
"This",
"method",
"does",
"not",
"require",
"authentication",
"."
]
| train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/GalleriesApi.java#L197-L212 |
Bearded-Hen/Android-Bootstrap | AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapProgressBar.java | BootstrapProgressBar.createTile | private static Bitmap createTile(float h, Paint stripePaint, Paint progressPaint) {
"""
Creates a Bitmap which is a tile of the progress bar background
@param h the view height
@return a bitmap of the progress bar background
"""
Bitmap bm = Bitmap.createBitmap((int) h * 2, (int) h, ARGB_8888);
Canvas tile = new Canvas(bm);
float x = 0;
Path path = new Path();
path.moveTo(x, 0);
path.lineTo(x, h);
path.lineTo(h, h);
tile.drawPath(path, stripePaint); // draw striped triangle
path.reset();
path.moveTo(x, 0);
path.lineTo(x + h, h);
path.lineTo(x + (h * 2), h);
path.lineTo(x + h, 0);
tile.drawPath(path, progressPaint); // draw progress parallelogram
x += h;
path.reset();
path.moveTo(x, 0);
path.lineTo(x + h, 0);
path.lineTo(x + h, h);
tile.drawPath(path, stripePaint); // draw striped triangle (completing tile)
return bm;
} | java | private static Bitmap createTile(float h, Paint stripePaint, Paint progressPaint) {
Bitmap bm = Bitmap.createBitmap((int) h * 2, (int) h, ARGB_8888);
Canvas tile = new Canvas(bm);
float x = 0;
Path path = new Path();
path.moveTo(x, 0);
path.lineTo(x, h);
path.lineTo(h, h);
tile.drawPath(path, stripePaint); // draw striped triangle
path.reset();
path.moveTo(x, 0);
path.lineTo(x + h, h);
path.lineTo(x + (h * 2), h);
path.lineTo(x + h, 0);
tile.drawPath(path, progressPaint); // draw progress parallelogram
x += h;
path.reset();
path.moveTo(x, 0);
path.lineTo(x + h, 0);
path.lineTo(x + h, h);
tile.drawPath(path, stripePaint); // draw striped triangle (completing tile)
return bm;
} | [
"private",
"static",
"Bitmap",
"createTile",
"(",
"float",
"h",
",",
"Paint",
"stripePaint",
",",
"Paint",
"progressPaint",
")",
"{",
"Bitmap",
"bm",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"(",
"int",
")",
"h",
"*",
"2",
",",
"(",
"int",
")",
"h",
",",
"ARGB_8888",
")",
";",
"Canvas",
"tile",
"=",
"new",
"Canvas",
"(",
"bm",
")",
";",
"float",
"x",
"=",
"0",
";",
"Path",
"path",
"=",
"new",
"Path",
"(",
")",
";",
"path",
".",
"moveTo",
"(",
"x",
",",
"0",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
",",
"h",
")",
";",
"path",
".",
"lineTo",
"(",
"h",
",",
"h",
")",
";",
"tile",
".",
"drawPath",
"(",
"path",
",",
"stripePaint",
")",
";",
"// draw striped triangle",
"path",
".",
"reset",
"(",
")",
";",
"path",
".",
"moveTo",
"(",
"x",
",",
"0",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"h",
",",
"h",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"(",
"h",
"*",
"2",
")",
",",
"h",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"h",
",",
"0",
")",
";",
"tile",
".",
"drawPath",
"(",
"path",
",",
"progressPaint",
")",
";",
"// draw progress parallelogram",
"x",
"+=",
"h",
";",
"path",
".",
"reset",
"(",
")",
";",
"path",
".",
"moveTo",
"(",
"x",
",",
"0",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"h",
",",
"0",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"h",
",",
"h",
")",
";",
"tile",
".",
"drawPath",
"(",
"path",
",",
"stripePaint",
")",
";",
"// draw striped triangle (completing tile)",
"return",
"bm",
";",
"}"
]
| Creates a Bitmap which is a tile of the progress bar background
@param h the view height
@return a bitmap of the progress bar background | [
"Creates",
"a",
"Bitmap",
"which",
"is",
"a",
"tile",
"of",
"the",
"progress",
"bar",
"background"
]
| train | https://github.com/Bearded-Hen/Android-Bootstrap/blob/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapProgressBar.java#L374-L401 |
PureSolTechnologies/genesis | commons.hadoop/src/main/java/com/puresoltechnologies/genesis/commons/hadoop/HadoopClientHelper.java | HadoopClientHelper.createConfiguration | public static Configuration createConfiguration(File configurationDirectory) {
"""
This method provides the default configuration for Hadoop client. The
configuration for the client is looked up in the provided directory. The
Hadoop etc directory is expected there.
@param configurationDirectory
is the directory where Hadoop's etc configuration directory can be
found.
@return A {@link Configuration} object is returned for the client to connect
with.
"""
Configuration hadoopConfiguration = new Configuration();
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/core-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/hdfs-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/mapred-site.xml").toString()));
return hadoopConfiguration;
} | java | public static Configuration createConfiguration(File configurationDirectory) {
Configuration hadoopConfiguration = new Configuration();
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/core-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/hdfs-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/mapred-site.xml").toString()));
return hadoopConfiguration;
} | [
"public",
"static",
"Configuration",
"createConfiguration",
"(",
"File",
"configurationDirectory",
")",
"{",
"Configuration",
"hadoopConfiguration",
"=",
"new",
"Configuration",
"(",
")",
";",
"hadoopConfiguration",
".",
"addResource",
"(",
"new",
"Path",
"(",
"new",
"File",
"(",
"configurationDirectory",
",",
"\"etc/hadoop/core-site.xml\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"hadoopConfiguration",
".",
"addResource",
"(",
"new",
"Path",
"(",
"new",
"File",
"(",
"configurationDirectory",
",",
"\"etc/hadoop/hdfs-site.xml\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"hadoopConfiguration",
".",
"addResource",
"(",
"new",
"Path",
"(",
"new",
"File",
"(",
"configurationDirectory",
",",
"\"etc/hadoop/mapred-site.xml\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"return",
"hadoopConfiguration",
";",
"}"
]
| This method provides the default configuration for Hadoop client. The
configuration for the client is looked up in the provided directory. The
Hadoop etc directory is expected there.
@param configurationDirectory
is the directory where Hadoop's etc configuration directory can be
found.
@return A {@link Configuration} object is returned for the client to connect
with. | [
"This",
"method",
"provides",
"the",
"default",
"configuration",
"for",
"Hadoop",
"client",
".",
"The",
"configuration",
"for",
"the",
"client",
"is",
"looked",
"up",
"in",
"the",
"provided",
"directory",
".",
"The",
"Hadoop",
"etc",
"directory",
"is",
"expected",
"there",
"."
]
| train | https://github.com/PureSolTechnologies/genesis/blob/1031027c5edcfeaad670896802058f78a2f7b159/commons.hadoop/src/main/java/com/puresoltechnologies/genesis/commons/hadoop/HadoopClientHelper.java#L48-L58 |
liferay/com-liferay-commerce | commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRelPersistenceImpl.java | CommerceDiscountRelPersistenceImpl.findAll | @Override
public List<CommerceDiscountRel> findAll(int start, int end) {
"""
Returns a range of all the commerce discount rels.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceDiscountRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce discount rels
@param end the upper bound of the range of commerce discount rels (not inclusive)
@return the range of commerce discount rels
"""
return findAll(start, end, null);
} | java | @Override
public List<CommerceDiscountRel> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceDiscountRel",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
]
| Returns a range of all the commerce discount rels.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceDiscountRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce discount rels
@param end the upper bound of the range of commerce discount rels (not inclusive)
@return the range of commerce discount rels | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"discount",
"rels",
"."
]
| train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRelPersistenceImpl.java#L2302-L2305 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/UniversalTimeScale.java | UniversalTimeScale.bigDecimalFrom | public static BigDecimal bigDecimalFrom(double otherTime, int timeScale) {
"""
Convert a <code>double</code> datetime from the given time scale to the universal time scale.
All calculations are done using <code>BigDecimal</code> to guarantee that the value
does not go out of range.
@param otherTime The <code>double</code> datetime
@param timeScale The time scale to convert from
@return The datetime converted to the universal time scale
"""
TimeScaleData data = getTimeScaleData(timeScale);
BigDecimal other = new BigDecimal(String.valueOf(otherTime));
BigDecimal units = new BigDecimal(data.units);
BigDecimal epochOffset = new BigDecimal(data.epochOffset);
return other.add(epochOffset).multiply(units);
} | java | public static BigDecimal bigDecimalFrom(double otherTime, int timeScale)
{
TimeScaleData data = getTimeScaleData(timeScale);
BigDecimal other = new BigDecimal(String.valueOf(otherTime));
BigDecimal units = new BigDecimal(data.units);
BigDecimal epochOffset = new BigDecimal(data.epochOffset);
return other.add(epochOffset).multiply(units);
} | [
"public",
"static",
"BigDecimal",
"bigDecimalFrom",
"(",
"double",
"otherTime",
",",
"int",
"timeScale",
")",
"{",
"TimeScaleData",
"data",
"=",
"getTimeScaleData",
"(",
"timeScale",
")",
";",
"BigDecimal",
"other",
"=",
"new",
"BigDecimal",
"(",
"String",
".",
"valueOf",
"(",
"otherTime",
")",
")",
";",
"BigDecimal",
"units",
"=",
"new",
"BigDecimal",
"(",
"data",
".",
"units",
")",
";",
"BigDecimal",
"epochOffset",
"=",
"new",
"BigDecimal",
"(",
"data",
".",
"epochOffset",
")",
";",
"return",
"other",
".",
"add",
"(",
"epochOffset",
")",
".",
"multiply",
"(",
"units",
")",
";",
"}"
]
| Convert a <code>double</code> datetime from the given time scale to the universal time scale.
All calculations are done using <code>BigDecimal</code> to guarantee that the value
does not go out of range.
@param otherTime The <code>double</code> datetime
@param timeScale The time scale to convert from
@return The datetime converted to the universal time scale | [
"Convert",
"a",
"<code",
">",
"double<",
"/",
"code",
">",
"datetime",
"from",
"the",
"given",
"time",
"scale",
"to",
"the",
"universal",
"time",
"scale",
".",
"All",
"calculations",
"are",
"done",
"using",
"<code",
">",
"BigDecimal<",
"/",
"code",
">",
"to",
"guarantee",
"that",
"the",
"value",
"does",
"not",
"go",
"out",
"of",
"range",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/UniversalTimeScale.java#L352-L360 |
micronaut-projects/micronaut-core | runtime/src/main/java/io/micronaut/jackson/JacksonConfiguration.java | JacksonConfiguration.setDeserialization | public void setDeserialization(Map<DeserializationFeature, Boolean> deserialization) {
"""
Sets the deserialization features to use.
@param deserialization The deserialiation features.
"""
if (CollectionUtils.isNotEmpty(deserialization)) {
this.deserialization = deserialization;
}
} | java | public void setDeserialization(Map<DeserializationFeature, Boolean> deserialization) {
if (CollectionUtils.isNotEmpty(deserialization)) {
this.deserialization = deserialization;
}
} | [
"public",
"void",
"setDeserialization",
"(",
"Map",
"<",
"DeserializationFeature",
",",
"Boolean",
">",
"deserialization",
")",
"{",
"if",
"(",
"CollectionUtils",
".",
"isNotEmpty",
"(",
"deserialization",
")",
")",
"{",
"this",
".",
"deserialization",
"=",
"deserialization",
";",
"}",
"}"
]
| Sets the deserialization features to use.
@param deserialization The deserialiation features. | [
"Sets",
"the",
"deserialization",
"features",
"to",
"use",
"."
]
| train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/runtime/src/main/java/io/micronaut/jackson/JacksonConfiguration.java#L245-L249 |
appium/java-client | src/main/java/io/appium/java_client/TouchAction.java | TouchAction.waitAction | public T waitAction(WaitOptions waitOptions) {
"""
Waits for specified amount of time to pass before continue to next touch action.
@param waitOptions see {@link WaitOptions}.
@return this TouchAction, for chaining.
"""
ActionParameter action = new ActionParameter("wait", waitOptions);
parameterBuilder.add(action);
//noinspection unchecked
return (T) this;
} | java | public T waitAction(WaitOptions waitOptions) {
ActionParameter action = new ActionParameter("wait", waitOptions);
parameterBuilder.add(action);
//noinspection unchecked
return (T) this;
} | [
"public",
"T",
"waitAction",
"(",
"WaitOptions",
"waitOptions",
")",
"{",
"ActionParameter",
"action",
"=",
"new",
"ActionParameter",
"(",
"\"wait\"",
",",
"waitOptions",
")",
";",
"parameterBuilder",
".",
"add",
"(",
"action",
")",
";",
"//noinspection unchecked",
"return",
"(",
"T",
")",
"this",
";",
"}"
]
| Waits for specified amount of time to pass before continue to next touch action.
@param waitOptions see {@link WaitOptions}.
@return this TouchAction, for chaining. | [
"Waits",
"for",
"specified",
"amount",
"of",
"time",
"to",
"pass",
"before",
"continue",
"to",
"next",
"touch",
"action",
"."
]
| train | https://github.com/appium/java-client/blob/5a17759b05d6fda8ef425b3ab6e766c73ed2e8df/src/main/java/io/appium/java_client/TouchAction.java#L139-L144 |
alkacon/opencms-core | src/org/opencms/ui/apps/git/CmsGitCheckin.java | CmsGitCheckin.runCommitScript | private int runCommitScript() {
"""
Runs the shell script for committing and optionally pushing the changes in the module.
@return exit code of the script.
"""
if (m_checkout && !m_fetchAndResetBeforeImport) {
m_logStream.println("Skipping script....");
return 0;
}
try {
m_logStream.flush();
String commandParam;
if (m_resetRemoteHead) {
commandParam = resetRemoteHeadScriptCommand();
} else if (m_resetHead) {
commandParam = resetHeadScriptCommand();
} else if (m_checkout) {
commandParam = checkoutScriptCommand();
} else {
commandParam = checkinScriptCommand();
}
String[] cmd = {"bash", "-c", commandParam};
m_logStream.println("Calling the script as follows:");
m_logStream.println();
m_logStream.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
ProcessBuilder builder = new ProcessBuilder(cmd);
m_logStream.close();
m_logStream = null;
Redirect redirect = Redirect.appendTo(new File(DEFAULT_LOGFILE_PATH));
builder.redirectOutput(redirect);
builder.redirectError(redirect);
Process scriptProcess = builder.start();
int exitCode = scriptProcess.waitFor();
scriptProcess.getOutputStream().close();
m_logStream = new PrintStream(new FileOutputStream(DEFAULT_LOGFILE_PATH, true));
return exitCode;
} catch (InterruptedException | IOException e) {
e.printStackTrace(m_logStream);
return -1;
}
} | java | private int runCommitScript() {
if (m_checkout && !m_fetchAndResetBeforeImport) {
m_logStream.println("Skipping script....");
return 0;
}
try {
m_logStream.flush();
String commandParam;
if (m_resetRemoteHead) {
commandParam = resetRemoteHeadScriptCommand();
} else if (m_resetHead) {
commandParam = resetHeadScriptCommand();
} else if (m_checkout) {
commandParam = checkoutScriptCommand();
} else {
commandParam = checkinScriptCommand();
}
String[] cmd = {"bash", "-c", commandParam};
m_logStream.println("Calling the script as follows:");
m_logStream.println();
m_logStream.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
ProcessBuilder builder = new ProcessBuilder(cmd);
m_logStream.close();
m_logStream = null;
Redirect redirect = Redirect.appendTo(new File(DEFAULT_LOGFILE_PATH));
builder.redirectOutput(redirect);
builder.redirectError(redirect);
Process scriptProcess = builder.start();
int exitCode = scriptProcess.waitFor();
scriptProcess.getOutputStream().close();
m_logStream = new PrintStream(new FileOutputStream(DEFAULT_LOGFILE_PATH, true));
return exitCode;
} catch (InterruptedException | IOException e) {
e.printStackTrace(m_logStream);
return -1;
}
} | [
"private",
"int",
"runCommitScript",
"(",
")",
"{",
"if",
"(",
"m_checkout",
"&&",
"!",
"m_fetchAndResetBeforeImport",
")",
"{",
"m_logStream",
".",
"println",
"(",
"\"Skipping script....\"",
")",
";",
"return",
"0",
";",
"}",
"try",
"{",
"m_logStream",
".",
"flush",
"(",
")",
";",
"String",
"commandParam",
";",
"if",
"(",
"m_resetRemoteHead",
")",
"{",
"commandParam",
"=",
"resetRemoteHeadScriptCommand",
"(",
")",
";",
"}",
"else",
"if",
"(",
"m_resetHead",
")",
"{",
"commandParam",
"=",
"resetHeadScriptCommand",
"(",
")",
";",
"}",
"else",
"if",
"(",
"m_checkout",
")",
"{",
"commandParam",
"=",
"checkoutScriptCommand",
"(",
")",
";",
"}",
"else",
"{",
"commandParam",
"=",
"checkinScriptCommand",
"(",
")",
";",
"}",
"String",
"[",
"]",
"cmd",
"=",
"{",
"\"bash\"",
",",
"\"-c\"",
",",
"commandParam",
"}",
";",
"m_logStream",
".",
"println",
"(",
"\"Calling the script as follows:\"",
")",
";",
"m_logStream",
".",
"println",
"(",
")",
";",
"m_logStream",
".",
"println",
"(",
"cmd",
"[",
"0",
"]",
"+",
"\" \"",
"+",
"cmd",
"[",
"1",
"]",
"+",
"\" \"",
"+",
"cmd",
"[",
"2",
"]",
")",
";",
"ProcessBuilder",
"builder",
"=",
"new",
"ProcessBuilder",
"(",
"cmd",
")",
";",
"m_logStream",
".",
"close",
"(",
")",
";",
"m_logStream",
"=",
"null",
";",
"Redirect",
"redirect",
"=",
"Redirect",
".",
"appendTo",
"(",
"new",
"File",
"(",
"DEFAULT_LOGFILE_PATH",
")",
")",
";",
"builder",
".",
"redirectOutput",
"(",
"redirect",
")",
";",
"builder",
".",
"redirectError",
"(",
"redirect",
")",
";",
"Process",
"scriptProcess",
"=",
"builder",
".",
"start",
"(",
")",
";",
"int",
"exitCode",
"=",
"scriptProcess",
".",
"waitFor",
"(",
")",
";",
"scriptProcess",
".",
"getOutputStream",
"(",
")",
".",
"close",
"(",
")",
";",
"m_logStream",
"=",
"new",
"PrintStream",
"(",
"new",
"FileOutputStream",
"(",
"DEFAULT_LOGFILE_PATH",
",",
"true",
")",
")",
";",
"return",
"exitCode",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
"m_logStream",
")",
";",
"return",
"-",
"1",
";",
"}",
"}"
]
| Runs the shell script for committing and optionally pushing the changes in the module.
@return exit code of the script. | [
"Runs",
"the",
"shell",
"script",
"for",
"committing",
"and",
"optionally",
"pushing",
"the",
"changes",
"in",
"the",
"module",
"."
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/git/CmsGitCheckin.java#L902-L940 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/RepositoryApi.java | RepositoryApi.getRepositoryArchive | public File getRepositoryArchive(Object projectIdOrPath, String sha, File directory, ArchiveFormat format) throws GitLabApiException {
"""
Get an archive of the complete repository by SHA (optional) and saves to the specified directory.
If the archive already exists in the directory it will be overwritten.
<pre><code>GitLab Endpoint: GET /projects/:id/repository/archive</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param sha the SHA of the archive to get
@param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
@param format The archive format, defaults to TAR_GZ if null
@return a File instance pointing to the downloaded instance
@throws GitLabApiException if any exception occurs
"""
if (format == null) {
format = ArchiveFormat.TAR_GZ;
}
/*
* Gitlab-ce has a bug when you try to download file archives with format by using "&format=zip(or tar... etc.)",
* there is a solution to request .../archive.:format instead of .../archive?format=:format.
*
* Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/45992
* https://gitlab.com/gitlab-com/support-forum/issues/3067
*/
Form formData = new GitLabApiForm().withParam("sha", sha);
Response response = getWithAccepts(Response.Status.OK, formData.asMap(), MediaType.MEDIA_TYPE_WILDCARD,
"projects", getProjectIdOrPath(projectIdOrPath), "repository", "archive" + "." + format.toString());
try {
if (directory == null)
directory = new File(System.getProperty("java.io.tmpdir"));
String filename = FileUtils.getFilenameFromContentDisposition(response);
File file = new File(directory, filename);
InputStream in = response.readEntity(InputStream.class);
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
return (file);
} catch (IOException ioe) {
throw new GitLabApiException(ioe);
}
} | java | public File getRepositoryArchive(Object projectIdOrPath, String sha, File directory, ArchiveFormat format) throws GitLabApiException {
if (format == null) {
format = ArchiveFormat.TAR_GZ;
}
/*
* Gitlab-ce has a bug when you try to download file archives with format by using "&format=zip(or tar... etc.)",
* there is a solution to request .../archive.:format instead of .../archive?format=:format.
*
* Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/45992
* https://gitlab.com/gitlab-com/support-forum/issues/3067
*/
Form formData = new GitLabApiForm().withParam("sha", sha);
Response response = getWithAccepts(Response.Status.OK, formData.asMap(), MediaType.MEDIA_TYPE_WILDCARD,
"projects", getProjectIdOrPath(projectIdOrPath), "repository", "archive" + "." + format.toString());
try {
if (directory == null)
directory = new File(System.getProperty("java.io.tmpdir"));
String filename = FileUtils.getFilenameFromContentDisposition(response);
File file = new File(directory, filename);
InputStream in = response.readEntity(InputStream.class);
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
return (file);
} catch (IOException ioe) {
throw new GitLabApiException(ioe);
}
} | [
"public",
"File",
"getRepositoryArchive",
"(",
"Object",
"projectIdOrPath",
",",
"String",
"sha",
",",
"File",
"directory",
",",
"ArchiveFormat",
"format",
")",
"throws",
"GitLabApiException",
"{",
"if",
"(",
"format",
"==",
"null",
")",
"{",
"format",
"=",
"ArchiveFormat",
".",
"TAR_GZ",
";",
"}",
"/*\n * Gitlab-ce has a bug when you try to download file archives with format by using \"&format=zip(or tar... etc.)\",\n * there is a solution to request .../archive.:format instead of .../archive?format=:format.\n *\n * Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/45992\n * https://gitlab.com/gitlab-com/support-forum/issues/3067\n */",
"Form",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"sha\"",
",",
"sha",
")",
";",
"Response",
"response",
"=",
"getWithAccepts",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"formData",
".",
"asMap",
"(",
")",
",",
"MediaType",
".",
"MEDIA_TYPE_WILDCARD",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"repository\"",
",",
"\"archive\"",
"+",
"\".\"",
"+",
"format",
".",
"toString",
"(",
")",
")",
";",
"try",
"{",
"if",
"(",
"directory",
"==",
"null",
")",
"directory",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
")",
";",
"String",
"filename",
"=",
"FileUtils",
".",
"getFilenameFromContentDisposition",
"(",
"response",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"directory",
",",
"filename",
")",
";",
"InputStream",
"in",
"=",
"response",
".",
"readEntity",
"(",
"InputStream",
".",
"class",
")",
";",
"Files",
".",
"copy",
"(",
"in",
",",
"file",
".",
"toPath",
"(",
")",
",",
"StandardCopyOption",
".",
"REPLACE_EXISTING",
")",
";",
"return",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"GitLabApiException",
"(",
"ioe",
")",
";",
"}",
"}"
]
| Get an archive of the complete repository by SHA (optional) and saves to the specified directory.
If the archive already exists in the directory it will be overwritten.
<pre><code>GitLab Endpoint: GET /projects/:id/repository/archive</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param sha the SHA of the archive to get
@param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
@param format The archive format, defaults to TAR_GZ if null
@return a File instance pointing to the downloaded instance
@throws GitLabApiException if any exception occurs | [
"Get",
"an",
"archive",
"of",
"the",
"complete",
"repository",
"by",
"SHA",
"(",
"optional",
")",
"and",
"saves",
"to",
"the",
"specified",
"directory",
".",
"If",
"the",
"archive",
"already",
"exists",
"in",
"the",
"directory",
"it",
"will",
"be",
"overwritten",
"."
]
| train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/RepositoryApi.java#L638-L670 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/tiled/TiledMap.java | TiledMap.setTileId | public void setTileId(int x, int y, int layerIndex, int tileid) {
"""
Set the global ID of a tile at specified location in the map
@param x
The x location of the tile
@param y
The y location of the tile
@param layerIndex
The index of the layer to set the new tileid
@param tileid
The tileid to be set
"""
Layer layer = (Layer) layers.get(layerIndex);
layer.setTileID(x, y, tileid);
} | java | public void setTileId(int x, int y, int layerIndex, int tileid) {
Layer layer = (Layer) layers.get(layerIndex);
layer.setTileID(x, y, tileid);
} | [
"public",
"void",
"setTileId",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"layerIndex",
",",
"int",
"tileid",
")",
"{",
"Layer",
"layer",
"=",
"(",
"Layer",
")",
"layers",
".",
"get",
"(",
"layerIndex",
")",
";",
"layer",
".",
"setTileID",
"(",
"x",
",",
"y",
",",
"tileid",
")",
";",
"}"
]
| Set the global ID of a tile at specified location in the map
@param x
The x location of the tile
@param y
The y location of the tile
@param layerIndex
The index of the layer to set the new tileid
@param tileid
The tileid to be set | [
"Set",
"the",
"global",
"ID",
"of",
"a",
"tile",
"at",
"specified",
"location",
"in",
"the",
"map"
]
| train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/tiled/TiledMap.java#L276-L279 |
Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.writeLanguage | public void writeLanguage(String appid, String langCode, Map<String, String> lang, boolean writeToDatabase) {
"""
Persists the language map in the data store. Overwrites any existing maps.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param lang the language map
@param writeToDatabase true if you want the language map to be stored in the DB as well
"""
if (lang == null || lang.isEmpty() || StringUtils.isBlank(langCode) || !ALL_LOCALES.containsKey(langCode)) {
return;
}
writeLanguageToFile(appid, langCode, lang);
if (writeToDatabase) {
// this will overwrite a saved language map!
Sysprop s = new Sysprop(keyPrefix.concat(langCode));
Map<String, String> dlang = getDefaultLanguage(appid);
for (Map.Entry<String, String> entry : dlang.entrySet()) {
String key = entry.getKey();
if (lang.containsKey(key)) {
s.addProperty(key, lang.get(key));
} else {
s.addProperty(key, entry.getValue());
}
}
dao.create(appid, s);
}
} | java | public void writeLanguage(String appid, String langCode, Map<String, String> lang, boolean writeToDatabase) {
if (lang == null || lang.isEmpty() || StringUtils.isBlank(langCode) || !ALL_LOCALES.containsKey(langCode)) {
return;
}
writeLanguageToFile(appid, langCode, lang);
if (writeToDatabase) {
// this will overwrite a saved language map!
Sysprop s = new Sysprop(keyPrefix.concat(langCode));
Map<String, String> dlang = getDefaultLanguage(appid);
for (Map.Entry<String, String> entry : dlang.entrySet()) {
String key = entry.getKey();
if (lang.containsKey(key)) {
s.addProperty(key, lang.get(key));
} else {
s.addProperty(key, entry.getValue());
}
}
dao.create(appid, s);
}
} | [
"public",
"void",
"writeLanguage",
"(",
"String",
"appid",
",",
"String",
"langCode",
",",
"Map",
"<",
"String",
",",
"String",
">",
"lang",
",",
"boolean",
"writeToDatabase",
")",
"{",
"if",
"(",
"lang",
"==",
"null",
"||",
"lang",
".",
"isEmpty",
"(",
")",
"||",
"StringUtils",
".",
"isBlank",
"(",
"langCode",
")",
"||",
"!",
"ALL_LOCALES",
".",
"containsKey",
"(",
"langCode",
")",
")",
"{",
"return",
";",
"}",
"writeLanguageToFile",
"(",
"appid",
",",
"langCode",
",",
"lang",
")",
";",
"if",
"(",
"writeToDatabase",
")",
"{",
"// this will overwrite a saved language map!",
"Sysprop",
"s",
"=",
"new",
"Sysprop",
"(",
"keyPrefix",
".",
"concat",
"(",
"langCode",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"dlang",
"=",
"getDefaultLanguage",
"(",
"appid",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"dlang",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"lang",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"s",
".",
"addProperty",
"(",
"key",
",",
"lang",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"else",
"{",
"s",
".",
"addProperty",
"(",
"key",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"dao",
".",
"create",
"(",
"appid",
",",
"s",
")",
";",
"}",
"}"
]
| Persists the language map in the data store. Overwrites any existing maps.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param lang the language map
@param writeToDatabase true if you want the language map to be stored in the DB as well | [
"Persists",
"the",
"language",
"map",
"in",
"the",
"data",
"store",
".",
"Overwrites",
"any",
"existing",
"maps",
"."
]
| train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L143-L163 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringParser.java | StringParser.parseByteObj | @Nullable
public static Byte parseByteObj (@Nullable final String sStr, @Nullable final Byte aDefault) {
"""
Parse the given {@link String} as {@link Byte} with radix
{@value #DEFAULT_RADIX}.
@param sStr
The String to parse. May be <code>null</code>.
@param aDefault
The default value to be returned if the passed string could not be
converted to a valid value. May be <code>null</code>.
@return <code>aDefault</code> if the string does not represent a valid
value.
"""
return parseByteObj (sStr, DEFAULT_RADIX, aDefault);
} | java | @Nullable
public static Byte parseByteObj (@Nullable final String sStr, @Nullable final Byte aDefault)
{
return parseByteObj (sStr, DEFAULT_RADIX, aDefault);
} | [
"@",
"Nullable",
"public",
"static",
"Byte",
"parseByteObj",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"@",
"Nullable",
"final",
"Byte",
"aDefault",
")",
"{",
"return",
"parseByteObj",
"(",
"sStr",
",",
"DEFAULT_RADIX",
",",
"aDefault",
")",
";",
"}"
]
| Parse the given {@link String} as {@link Byte} with radix
{@value #DEFAULT_RADIX}.
@param sStr
The String to parse. May be <code>null</code>.
@param aDefault
The default value to be returned if the passed string could not be
converted to a valid value. May be <code>null</code>.
@return <code>aDefault</code> if the string does not represent a valid
value. | [
"Parse",
"the",
"given",
"{",
"@link",
"String",
"}",
"as",
"{",
"@link",
"Byte",
"}",
"with",
"radix",
"{",
"@value",
"#DEFAULT_RADIX",
"}",
"."
]
| train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L414-L418 |
NoraUi/NoraUi | src/main/java/com/github/noraui/utils/Messages.java | Messages.getMessage | public static String getMessage(String key, String bundle) {
"""
Gets a message by key using the resources bundle given in parameters.
@param key
The key of the message to retrieve.
@param bundle
The resource bundle to use.
@return
The String content of the message.
"""
if (!messagesBundles.containsKey(bundle)) {
if (Context.getLocale() == null) {
messagesBundles.put(bundle, ResourceBundle.getBundle("i18n/" + bundle, Locale.getDefault()));
} else {
messagesBundles.put(bundle, ResourceBundle.getBundle("i18n/" + bundle, Context.getLocale()));
}
}
return messagesBundles.get(bundle).getString(key);
} | java | public static String getMessage(String key, String bundle) {
if (!messagesBundles.containsKey(bundle)) {
if (Context.getLocale() == null) {
messagesBundles.put(bundle, ResourceBundle.getBundle("i18n/" + bundle, Locale.getDefault()));
} else {
messagesBundles.put(bundle, ResourceBundle.getBundle("i18n/" + bundle, Context.getLocale()));
}
}
return messagesBundles.get(bundle).getString(key);
} | [
"public",
"static",
"String",
"getMessage",
"(",
"String",
"key",
",",
"String",
"bundle",
")",
"{",
"if",
"(",
"!",
"messagesBundles",
".",
"containsKey",
"(",
"bundle",
")",
")",
"{",
"if",
"(",
"Context",
".",
"getLocale",
"(",
")",
"==",
"null",
")",
"{",
"messagesBundles",
".",
"put",
"(",
"bundle",
",",
"ResourceBundle",
".",
"getBundle",
"(",
"\"i18n/\"",
"+",
"bundle",
",",
"Locale",
".",
"getDefault",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"messagesBundles",
".",
"put",
"(",
"bundle",
",",
"ResourceBundle",
".",
"getBundle",
"(",
"\"i18n/\"",
"+",
"bundle",
",",
"Context",
".",
"getLocale",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"messagesBundles",
".",
"get",
"(",
"bundle",
")",
".",
"getString",
"(",
"key",
")",
";",
"}"
]
| Gets a message by key using the resources bundle given in parameters.
@param key
The key of the message to retrieve.
@param bundle
The resource bundle to use.
@return
The String content of the message. | [
"Gets",
"a",
"message",
"by",
"key",
"using",
"the",
"resources",
"bundle",
"given",
"in",
"parameters",
"."
]
| train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/utils/Messages.java#L145-L155 |
alkacon/opencms-core | src/org/opencms/ui/apps/user/CmsImportExportUserDialog.java | CmsImportExportUserDialog.getGroupSelect | protected CmsPrincipalSelect getGroupSelect(String ou, boolean enabled, CmsUUID groupID) {
"""
Get a principle select for choosing groups.<p>
@param ou name
@param enabled enabled?
@param groupID default value
@return CmsPrinicpalSelect
"""
CmsPrincipalSelect select = new CmsPrincipalSelect();
select.setOU(ou);
select.setEnabled(enabled);
select.setRealPrincipalsOnly(true);
select.setPrincipalType(I_CmsPrincipal.PRINCIPAL_GROUP);
select.setWidgetType(WidgetType.groupwidget);
if (groupID != null) {
try {
select.setValue(m_cms.readGroup(groupID).getName());
} catch (CmsException e) {
LOG.error("Unable to read group", e);
}
}
//OU Change enabled because ou-user can be part of other ou-groups
return select;
} | java | protected CmsPrincipalSelect getGroupSelect(String ou, boolean enabled, CmsUUID groupID) {
CmsPrincipalSelect select = new CmsPrincipalSelect();
select.setOU(ou);
select.setEnabled(enabled);
select.setRealPrincipalsOnly(true);
select.setPrincipalType(I_CmsPrincipal.PRINCIPAL_GROUP);
select.setWidgetType(WidgetType.groupwidget);
if (groupID != null) {
try {
select.setValue(m_cms.readGroup(groupID).getName());
} catch (CmsException e) {
LOG.error("Unable to read group", e);
}
}
//OU Change enabled because ou-user can be part of other ou-groups
return select;
} | [
"protected",
"CmsPrincipalSelect",
"getGroupSelect",
"(",
"String",
"ou",
",",
"boolean",
"enabled",
",",
"CmsUUID",
"groupID",
")",
"{",
"CmsPrincipalSelect",
"select",
"=",
"new",
"CmsPrincipalSelect",
"(",
")",
";",
"select",
".",
"setOU",
"(",
"ou",
")",
";",
"select",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"select",
".",
"setRealPrincipalsOnly",
"(",
"true",
")",
";",
"select",
".",
"setPrincipalType",
"(",
"I_CmsPrincipal",
".",
"PRINCIPAL_GROUP",
")",
";",
"select",
".",
"setWidgetType",
"(",
"WidgetType",
".",
"groupwidget",
")",
";",
"if",
"(",
"groupID",
"!=",
"null",
")",
"{",
"try",
"{",
"select",
".",
"setValue",
"(",
"m_cms",
".",
"readGroup",
"(",
"groupID",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to read group\"",
",",
"e",
")",
";",
"}",
"}",
"//OU Change enabled because ou-user can be part of other ou-groups",
"return",
"select",
";",
"}"
]
| Get a principle select for choosing groups.<p>
@param ou name
@param enabled enabled?
@param groupID default value
@return CmsPrinicpalSelect | [
"Get",
"a",
"principle",
"select",
"for",
"choosing",
"groups",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsImportExportUserDialog.java#L506-L525 |
OpenSextant/SolrTextTagger | src/main/java/org/opensextant/solrtexttagger/TaggerRequestHandler.java | TaggerRequestHandler.computeDocCorpus | private Bits computeDocCorpus(SolrQueryRequest req) throws SyntaxError, IOException {
"""
The set of documents matching the provided 'fq' (filter query). Don't include deleted docs
either. If null is returned, then all docs are available.
"""
final String[] corpusFilterQueries = req.getParams().getParams("fq");
final SolrIndexSearcher searcher = req.getSearcher();
final Bits docBits;
if (corpusFilterQueries != null && corpusFilterQueries.length > 0) {
List<Query> filterQueries = new ArrayList<Query>(corpusFilterQueries.length);
for (String corpusFilterQuery : corpusFilterQueries) {
QParser qParser = QParser.getParser(corpusFilterQuery, null, req);
try {
filterQueries.add(qParser.parse());
} catch (SyntaxError e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
}
final DocSet docSet = searcher.getDocSet(filterQueries);//hopefully in the cache
//note: before Solr 4.7 we could call docSet.getBits() but no longer.
if (docSet instanceof BitDocSet) {
docBits = ((BitDocSet)docSet).getBits();
} else {
docBits = new Bits() {
@Override
public boolean get(int index) {
return docSet.exists(index);
}
@Override
public int length() {
return searcher.maxDoc();
}
};
}
} else {
docBits = searcher.getSlowAtomicReader().getLiveDocs();
}
return docBits;
} | java | private Bits computeDocCorpus(SolrQueryRequest req) throws SyntaxError, IOException {
final String[] corpusFilterQueries = req.getParams().getParams("fq");
final SolrIndexSearcher searcher = req.getSearcher();
final Bits docBits;
if (corpusFilterQueries != null && corpusFilterQueries.length > 0) {
List<Query> filterQueries = new ArrayList<Query>(corpusFilterQueries.length);
for (String corpusFilterQuery : corpusFilterQueries) {
QParser qParser = QParser.getParser(corpusFilterQuery, null, req);
try {
filterQueries.add(qParser.parse());
} catch (SyntaxError e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
}
final DocSet docSet = searcher.getDocSet(filterQueries);//hopefully in the cache
//note: before Solr 4.7 we could call docSet.getBits() but no longer.
if (docSet instanceof BitDocSet) {
docBits = ((BitDocSet)docSet).getBits();
} else {
docBits = new Bits() {
@Override
public boolean get(int index) {
return docSet.exists(index);
}
@Override
public int length() {
return searcher.maxDoc();
}
};
}
} else {
docBits = searcher.getSlowAtomicReader().getLiveDocs();
}
return docBits;
} | [
"private",
"Bits",
"computeDocCorpus",
"(",
"SolrQueryRequest",
"req",
")",
"throws",
"SyntaxError",
",",
"IOException",
"{",
"final",
"String",
"[",
"]",
"corpusFilterQueries",
"=",
"req",
".",
"getParams",
"(",
")",
".",
"getParams",
"(",
"\"fq\"",
")",
";",
"final",
"SolrIndexSearcher",
"searcher",
"=",
"req",
".",
"getSearcher",
"(",
")",
";",
"final",
"Bits",
"docBits",
";",
"if",
"(",
"corpusFilterQueries",
"!=",
"null",
"&&",
"corpusFilterQueries",
".",
"length",
">",
"0",
")",
"{",
"List",
"<",
"Query",
">",
"filterQueries",
"=",
"new",
"ArrayList",
"<",
"Query",
">",
"(",
"corpusFilterQueries",
".",
"length",
")",
";",
"for",
"(",
"String",
"corpusFilterQuery",
":",
"corpusFilterQueries",
")",
"{",
"QParser",
"qParser",
"=",
"QParser",
".",
"getParser",
"(",
"corpusFilterQuery",
",",
"null",
",",
"req",
")",
";",
"try",
"{",
"filterQueries",
".",
"add",
"(",
"qParser",
".",
"parse",
"(",
")",
")",
";",
"}",
"catch",
"(",
"SyntaxError",
"e",
")",
"{",
"throw",
"new",
"SolrException",
"(",
"SolrException",
".",
"ErrorCode",
".",
"BAD_REQUEST",
",",
"e",
")",
";",
"}",
"}",
"final",
"DocSet",
"docSet",
"=",
"searcher",
".",
"getDocSet",
"(",
"filterQueries",
")",
";",
"//hopefully in the cache",
"//note: before Solr 4.7 we could call docSet.getBits() but no longer.",
"if",
"(",
"docSet",
"instanceof",
"BitDocSet",
")",
"{",
"docBits",
"=",
"(",
"(",
"BitDocSet",
")",
"docSet",
")",
".",
"getBits",
"(",
")",
";",
"}",
"else",
"{",
"docBits",
"=",
"new",
"Bits",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"get",
"(",
"int",
"index",
")",
"{",
"return",
"docSet",
".",
"exists",
"(",
"index",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"length",
"(",
")",
"{",
"return",
"searcher",
".",
"maxDoc",
"(",
")",
";",
"}",
"}",
";",
"}",
"}",
"else",
"{",
"docBits",
"=",
"searcher",
".",
"getSlowAtomicReader",
"(",
")",
".",
"getLiveDocs",
"(",
")",
";",
"}",
"return",
"docBits",
";",
"}"
]
| The set of documents matching the provided 'fq' (filter query). Don't include deleted docs
either. If null is returned, then all docs are available. | [
"The",
"set",
"of",
"documents",
"matching",
"the",
"provided",
"fq",
"(",
"filter",
"query",
")",
".",
"Don",
"t",
"include",
"deleted",
"docs",
"either",
".",
"If",
"null",
"is",
"returned",
"then",
"all",
"docs",
"are",
"available",
"."
]
| train | https://github.com/OpenSextant/SolrTextTagger/blob/e7ae82b94f1490fa1b7882ada09b57071094b0a5/src/main/java/org/opensextant/solrtexttagger/TaggerRequestHandler.java#L314-L351 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/fieldaccessor/LabelSetterFactory.java | LabelSetterFactory.createField | private Optional<LabelSetter> createField(final Class<?> beanClass, final String fieldName) {
"""
フィールドによるラベル情報を格納する場合。
<p>{@code <フィールド名> + Label}のメソッド名</p>
<p>引数として、{@link CellPosition}、{@link Point}、 {@link org.apache.poi.ss.util.CellAddress}をサポートする。</p>
@param beanClass フィールドが定義してあるクラスのインスタンス
@param fieldName フィールド名
@return ラベル情報の設定用クラス
"""
final String labelFieldName = fieldName + "Label";
final Field labelField;
try {
labelField = beanClass.getDeclaredField(labelFieldName);
labelField.setAccessible(true);
} catch (NoSuchFieldException | SecurityException e) {
return Optional.empty();
}
if(labelField.getType().equals(String.class)) {
return Optional.of(new LabelSetter() {
@Override
public void set(final Object beanObj, final String label) {
ArgUtils.notNull(beanObj, "beanObj");
ArgUtils.notNull(label, "label");
try {
labelField.set(beanObj, label);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException("fail access label field.", e);
}
}
});
}
return Optional.empty();
} | java | private Optional<LabelSetter> createField(final Class<?> beanClass, final String fieldName) {
final String labelFieldName = fieldName + "Label";
final Field labelField;
try {
labelField = beanClass.getDeclaredField(labelFieldName);
labelField.setAccessible(true);
} catch (NoSuchFieldException | SecurityException e) {
return Optional.empty();
}
if(labelField.getType().equals(String.class)) {
return Optional.of(new LabelSetter() {
@Override
public void set(final Object beanObj, final String label) {
ArgUtils.notNull(beanObj, "beanObj");
ArgUtils.notNull(label, "label");
try {
labelField.set(beanObj, label);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException("fail access label field.", e);
}
}
});
}
return Optional.empty();
} | [
"private",
"Optional",
"<",
"LabelSetter",
">",
"createField",
"(",
"final",
"Class",
"<",
"?",
">",
"beanClass",
",",
"final",
"String",
"fieldName",
")",
"{",
"final",
"String",
"labelFieldName",
"=",
"fieldName",
"+",
"\"Label\"",
";",
"final",
"Field",
"labelField",
";",
"try",
"{",
"labelField",
"=",
"beanClass",
".",
"getDeclaredField",
"(",
"labelFieldName",
")",
";",
"labelField",
".",
"setAccessible",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"|",
"SecurityException",
"e",
")",
"{",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"if",
"(",
"labelField",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"String",
".",
"class",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"new",
"LabelSetter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"set",
"(",
"final",
"Object",
"beanObj",
",",
"final",
"String",
"label",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"beanObj",
",",
"\"beanObj\"",
")",
";",
"ArgUtils",
".",
"notNull",
"(",
"label",
",",
"\"label\"",
")",
";",
"try",
"{",
"labelField",
".",
"set",
"(",
"beanObj",
",",
"label",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"fail access label field.\"",
",",
"e",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
]
| フィールドによるラベル情報を格納する場合。
<p>{@code <フィールド名> + Label}のメソッド名</p>
<p>引数として、{@link CellPosition}、{@link Point}、 {@link org.apache.poi.ss.util.CellAddress}をサポートする。</p>
@param beanClass フィールドが定義してあるクラスのインスタンス
@param fieldName フィールド名
@return ラベル情報の設定用クラス | [
"フィールドによるラベル情報を格納する場合。",
"<p",
">",
"{",
"@code",
"<フィールド名",
">",
"+",
"Label",
"}",
"のメソッド名<",
"/",
"p",
">",
"<p",
">",
"引数として、",
"{",
"@link",
"CellPosition",
"}",
"、",
"{",
"@link",
"Point",
"}",
"、",
"{",
"@link",
"org",
".",
"apache",
".",
"poi",
".",
"ss",
".",
"util",
".",
"CellAddress",
"}",
"をサポートする。<",
"/",
"p",
">"
]
| train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/fieldaccessor/LabelSetterFactory.java#L178-L211 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/FeaturePyramid.java | FeaturePyramid.findLocalScaleSpaceMax | protected void findLocalScaleSpaceMax(PyramidFloat<T> ss, int layerID) {
"""
Searches the pyramid layers up and down to see if the found 2D features are also scale space maximums.
"""
int index0 = spaceIndex;
int index1 = (spaceIndex + 1) % 3;
int index2 = (spaceIndex + 2) % 3;
List<Point2D_I16> candidates = maximums[index1];
ImageBorder_F32 inten0 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index0], 0);
GrayF32 inten1 = intensities[index1];
ImageBorder_F32 inten2 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index2], 0);
float scale0 = (float) ss.scale[layerID - 1];
float scale1 = (float) ss.scale[layerID];
float scale2 = (float) ss.scale[layerID + 1];
float sigma0 = (float) ss.getSigma(layerID - 1);
float sigma1 = (float) ss.getSigma(layerID);
float sigma2 = (float) ss.getSigma(layerID + 1);
// not sure if this is the correct way to handle the change in scale
float ss0 = (float) (Math.pow(sigma0, scalePower)/scale0);
float ss1 = (float) (Math.pow(sigma1, scalePower)/scale1);
float ss2 = (float) (Math.pow(sigma2, scalePower)/scale2);
for (Point2D_I16 c : candidates) {
float val = ss1 * inten1.get(c.x, c.y);
// find pixel location in each image's local coordinate
int x0 = (int) (c.x * scale1 / scale0);
int y0 = (int) (c.y * scale1 / scale0);
int x2 = (int) (c.x * scale1 / scale2);
int y2 = (int) (c.y * scale1 / scale2);
if (checkMax(inten0, val / ss0, x0, y0) && checkMax(inten2, val / ss2, x2, y2)) {
// put features into the scale of the upper image
foundPoints.add(new ScalePoint(c.x * scale1, c.y * scale1, sigma1));
}
}
} | java | protected void findLocalScaleSpaceMax(PyramidFloat<T> ss, int layerID) {
int index0 = spaceIndex;
int index1 = (spaceIndex + 1) % 3;
int index2 = (spaceIndex + 2) % 3;
List<Point2D_I16> candidates = maximums[index1];
ImageBorder_F32 inten0 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index0], 0);
GrayF32 inten1 = intensities[index1];
ImageBorder_F32 inten2 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index2], 0);
float scale0 = (float) ss.scale[layerID - 1];
float scale1 = (float) ss.scale[layerID];
float scale2 = (float) ss.scale[layerID + 1];
float sigma0 = (float) ss.getSigma(layerID - 1);
float sigma1 = (float) ss.getSigma(layerID);
float sigma2 = (float) ss.getSigma(layerID + 1);
// not sure if this is the correct way to handle the change in scale
float ss0 = (float) (Math.pow(sigma0, scalePower)/scale0);
float ss1 = (float) (Math.pow(sigma1, scalePower)/scale1);
float ss2 = (float) (Math.pow(sigma2, scalePower)/scale2);
for (Point2D_I16 c : candidates) {
float val = ss1 * inten1.get(c.x, c.y);
// find pixel location in each image's local coordinate
int x0 = (int) (c.x * scale1 / scale0);
int y0 = (int) (c.y * scale1 / scale0);
int x2 = (int) (c.x * scale1 / scale2);
int y2 = (int) (c.y * scale1 / scale2);
if (checkMax(inten0, val / ss0, x0, y0) && checkMax(inten2, val / ss2, x2, y2)) {
// put features into the scale of the upper image
foundPoints.add(new ScalePoint(c.x * scale1, c.y * scale1, sigma1));
}
}
} | [
"protected",
"void",
"findLocalScaleSpaceMax",
"(",
"PyramidFloat",
"<",
"T",
">",
"ss",
",",
"int",
"layerID",
")",
"{",
"int",
"index0",
"=",
"spaceIndex",
";",
"int",
"index1",
"=",
"(",
"spaceIndex",
"+",
"1",
")",
"%",
"3",
";",
"int",
"index2",
"=",
"(",
"spaceIndex",
"+",
"2",
")",
"%",
"3",
";",
"List",
"<",
"Point2D_I16",
">",
"candidates",
"=",
"maximums",
"[",
"index1",
"]",
";",
"ImageBorder_F32",
"inten0",
"=",
"(",
"ImageBorder_F32",
")",
"FactoryImageBorderAlgs",
".",
"value",
"(",
"intensities",
"[",
"index0",
"]",
",",
"0",
")",
";",
"GrayF32",
"inten1",
"=",
"intensities",
"[",
"index1",
"]",
";",
"ImageBorder_F32",
"inten2",
"=",
"(",
"ImageBorder_F32",
")",
"FactoryImageBorderAlgs",
".",
"value",
"(",
"intensities",
"[",
"index2",
"]",
",",
"0",
")",
";",
"float",
"scale0",
"=",
"(",
"float",
")",
"ss",
".",
"scale",
"[",
"layerID",
"-",
"1",
"]",
";",
"float",
"scale1",
"=",
"(",
"float",
")",
"ss",
".",
"scale",
"[",
"layerID",
"]",
";",
"float",
"scale2",
"=",
"(",
"float",
")",
"ss",
".",
"scale",
"[",
"layerID",
"+",
"1",
"]",
";",
"float",
"sigma0",
"=",
"(",
"float",
")",
"ss",
".",
"getSigma",
"(",
"layerID",
"-",
"1",
")",
";",
"float",
"sigma1",
"=",
"(",
"float",
")",
"ss",
".",
"getSigma",
"(",
"layerID",
")",
";",
"float",
"sigma2",
"=",
"(",
"float",
")",
"ss",
".",
"getSigma",
"(",
"layerID",
"+",
"1",
")",
";",
"// not sure if this is the correct way to handle the change in scale",
"float",
"ss0",
"=",
"(",
"float",
")",
"(",
"Math",
".",
"pow",
"(",
"sigma0",
",",
"scalePower",
")",
"/",
"scale0",
")",
";",
"float",
"ss1",
"=",
"(",
"float",
")",
"(",
"Math",
".",
"pow",
"(",
"sigma1",
",",
"scalePower",
")",
"/",
"scale1",
")",
";",
"float",
"ss2",
"=",
"(",
"float",
")",
"(",
"Math",
".",
"pow",
"(",
"sigma2",
",",
"scalePower",
")",
"/",
"scale2",
")",
";",
"for",
"(",
"Point2D_I16",
"c",
":",
"candidates",
")",
"{",
"float",
"val",
"=",
"ss1",
"*",
"inten1",
".",
"get",
"(",
"c",
".",
"x",
",",
"c",
".",
"y",
")",
";",
"// find pixel location in each image's local coordinate",
"int",
"x0",
"=",
"(",
"int",
")",
"(",
"c",
".",
"x",
"*",
"scale1",
"/",
"scale0",
")",
";",
"int",
"y0",
"=",
"(",
"int",
")",
"(",
"c",
".",
"y",
"*",
"scale1",
"/",
"scale0",
")",
";",
"int",
"x2",
"=",
"(",
"int",
")",
"(",
"c",
".",
"x",
"*",
"scale1",
"/",
"scale2",
")",
";",
"int",
"y2",
"=",
"(",
"int",
")",
"(",
"c",
".",
"y",
"*",
"scale1",
"/",
"scale2",
")",
";",
"if",
"(",
"checkMax",
"(",
"inten0",
",",
"val",
"/",
"ss0",
",",
"x0",
",",
"y0",
")",
"&&",
"checkMax",
"(",
"inten2",
",",
"val",
"/",
"ss2",
",",
"x2",
",",
"y2",
")",
")",
"{",
"// put features into the scale of the upper image",
"foundPoints",
".",
"add",
"(",
"new",
"ScalePoint",
"(",
"c",
".",
"x",
"*",
"scale1",
",",
"c",
".",
"y",
"*",
"scale1",
",",
"sigma1",
")",
")",
";",
"}",
"}",
"}"
]
| Searches the pyramid layers up and down to see if the found 2D features are also scale space maximums. | [
"Searches",
"the",
"pyramid",
"layers",
"up",
"and",
"down",
"to",
"see",
"if",
"the",
"found",
"2D",
"features",
"are",
"also",
"scale",
"space",
"maximums",
"."
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/FeaturePyramid.java#L168-L206 |
erlang/otp | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java | OtpOutputStream.writeLE | public void writeLE(final long n, final int b) {
"""
Write any number of bytes in little endian format.
@param n
the value to use.
@param b
the number of bytes to write from the little end.
"""
long v = n;
for (int i = 0; i < b; i++) {
write((byte) (v & 0xff));
v >>= 8;
}
} | java | public void writeLE(final long n, final int b) {
long v = n;
for (int i = 0; i < b; i++) {
write((byte) (v & 0xff));
v >>= 8;
}
} | [
"public",
"void",
"writeLE",
"(",
"final",
"long",
"n",
",",
"final",
"int",
"b",
")",
"{",
"long",
"v",
"=",
"n",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"b",
";",
"i",
"++",
")",
"{",
"write",
"(",
"(",
"byte",
")",
"(",
"v",
"&",
"0xff",
")",
")",
";",
"v",
">>=",
"8",
";",
"}",
"}"
]
| Write any number of bytes in little endian format.
@param n
the value to use.
@param b
the number of bytes to write from the little end. | [
"Write",
"any",
"number",
"of",
"bytes",
"in",
"little",
"endian",
"format",
"."
]
| train | https://github.com/erlang/otp/blob/ac6084fd83240355f72e94adbf303e57832d1fab/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java#L314-L320 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.containsAll | private boolean containsAll(String s, int i) {
"""
Recursive routine called if we fail to find a match in containsAll, and there are strings
@param s source string
@param i point to match to the end on
@return true if ok
"""
if (i >= s.length()) {
return true;
}
int cp= UTF16.charAt(s, i);
if (contains(cp) && containsAll(s, i+UTF16.getCharCount(cp))) {
return true;
}
for (String setStr : strings) {
if (s.startsWith(setStr, i) && containsAll(s, i+setStr.length())) {
return true;
}
}
return false;
} | java | private boolean containsAll(String s, int i) {
if (i >= s.length()) {
return true;
}
int cp= UTF16.charAt(s, i);
if (contains(cp) && containsAll(s, i+UTF16.getCharCount(cp))) {
return true;
}
for (String setStr : strings) {
if (s.startsWith(setStr, i) && containsAll(s, i+setStr.length())) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"containsAll",
"(",
"String",
"s",
",",
"int",
"i",
")",
"{",
"if",
"(",
"i",
">=",
"s",
".",
"length",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"int",
"cp",
"=",
"UTF16",
".",
"charAt",
"(",
"s",
",",
"i",
")",
";",
"if",
"(",
"contains",
"(",
"cp",
")",
"&&",
"containsAll",
"(",
"s",
",",
"i",
"+",
"UTF16",
".",
"getCharCount",
"(",
"cp",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"String",
"setStr",
":",
"strings",
")",
"{",
"if",
"(",
"s",
".",
"startsWith",
"(",
"setStr",
",",
"i",
")",
"&&",
"containsAll",
"(",
"s",
",",
"i",
"+",
"setStr",
".",
"length",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Recursive routine called if we fail to find a match in containsAll, and there are strings
@param s source string
@param i point to match to the end on
@return true if ok | [
"Recursive",
"routine",
"called",
"if",
"we",
"fail",
"to",
"find",
"a",
"match",
"in",
"containsAll",
"and",
"there",
"are",
"strings"
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1948-L1963 |
netty/netty | handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java | ReferenceCountedOpenSslContext.toBIO | static long toBIO(ByteBufAllocator allocator, PrivateKey key) throws Exception {
"""
Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a>
or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}.
"""
if (key == null) {
return 0;
}
PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key);
try {
return toBIO(allocator, pem.retain());
} finally {
pem.release();
}
} | java | static long toBIO(ByteBufAllocator allocator, PrivateKey key) throws Exception {
if (key == null) {
return 0;
}
PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key);
try {
return toBIO(allocator, pem.retain());
} finally {
pem.release();
}
} | [
"static",
"long",
"toBIO",
"(",
"ByteBufAllocator",
"allocator",
",",
"PrivateKey",
"key",
")",
"throws",
"Exception",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"PemEncoded",
"pem",
"=",
"PemPrivateKey",
".",
"toPEM",
"(",
"allocator",
",",
"true",
",",
"key",
")",
";",
"try",
"{",
"return",
"toBIO",
"(",
"allocator",
",",
"pem",
".",
"retain",
"(",
")",
")",
";",
"}",
"finally",
"{",
"pem",
".",
"release",
"(",
")",
";",
"}",
"}"
]
| Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a>
or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}. | [
"Return",
"the",
"pointer",
"to",
"a",
"<a",
"href",
"=",
"https",
":",
"//",
"www",
".",
"openssl",
".",
"org",
"/",
"docs",
"/",
"crypto",
"/",
"BIO_get_mem_ptr",
".",
"html",
">",
"in",
"-",
"memory",
"BIO<",
"/",
"a",
">",
"or",
"{"
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java#L816-L827 |
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/lineage/LineageInfo.java | LineageInfo.setSource | public void setSource(Descriptor source, State state) {
"""
Set source {@link DatasetDescriptor} of a lineage event
<p>
Only the {@link org.apache.gobblin.source.Source} or its {@link org.apache.gobblin.source.extractor.Extractor}
is supposed to set the source for a work unit of a dataset
</p>
@param state state about a {@link org.apache.gobblin.source.workunit.WorkUnit}
"""
Descriptor descriptor = resolver.resolve(source, state);
if (descriptor == null) {
return;
}
state.setProp(getKey(NAME_KEY), descriptor.getName());
state.setProp(getKey(LineageEventBuilder.SOURCE), Descriptor.toJson(descriptor));
} | java | public void setSource(Descriptor source, State state) {
Descriptor descriptor = resolver.resolve(source, state);
if (descriptor == null) {
return;
}
state.setProp(getKey(NAME_KEY), descriptor.getName());
state.setProp(getKey(LineageEventBuilder.SOURCE), Descriptor.toJson(descriptor));
} | [
"public",
"void",
"setSource",
"(",
"Descriptor",
"source",
",",
"State",
"state",
")",
"{",
"Descriptor",
"descriptor",
"=",
"resolver",
".",
"resolve",
"(",
"source",
",",
"state",
")",
";",
"if",
"(",
"descriptor",
"==",
"null",
")",
"{",
"return",
";",
"}",
"state",
".",
"setProp",
"(",
"getKey",
"(",
"NAME_KEY",
")",
",",
"descriptor",
".",
"getName",
"(",
")",
")",
";",
"state",
".",
"setProp",
"(",
"getKey",
"(",
"LineageEventBuilder",
".",
"SOURCE",
")",
",",
"Descriptor",
".",
"toJson",
"(",
"descriptor",
")",
")",
";",
"}"
]
| Set source {@link DatasetDescriptor} of a lineage event
<p>
Only the {@link org.apache.gobblin.source.Source} or its {@link org.apache.gobblin.source.extractor.Extractor}
is supposed to set the source for a work unit of a dataset
</p>
@param state state about a {@link org.apache.gobblin.source.workunit.WorkUnit} | [
"Set",
"source",
"{",
"@link",
"DatasetDescriptor",
"}",
"of",
"a",
"lineage",
"event"
]
| train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/lineage/LineageInfo.java#L112-L120 |
marklogic/marklogic-sesame | marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java | MarkLogicClientImpl.performGraphQuery | public InputStream performGraphQuery(String queryString, SPARQLQueryBindingSet bindings, InputStreamHandle handle, Transaction tx, boolean includeInferred, String baseURI) throws JsonProcessingException {
"""
executes GraphQuery
@param queryString
@param bindings
@param handle
@param tx
@param includeInferred
@param baseURI
@return
@throws JsonProcessingException
"""
SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(queryString);
if(notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);}
if (notNull(ruleset)) {qdef.setRulesets(ruleset);}
if (notNull(getConstrainingQueryDefinition())){
qdef.setConstrainingQueryDefinition(getConstrainingQueryDefinition());
qdef.setDirectory(getConstrainingQueryDefinition().getDirectory());
qdef.setCollections(getConstrainingQueryDefinition().getCollections());
qdef.setResponseTransform(getConstrainingQueryDefinition().getResponseTransform());
qdef.setOptionsName(getConstrainingQueryDefinition().getOptionsName());
}
if(notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);}
qdef.setIncludeDefaultRulesets(includeInferred);
sparqlManager.executeDescribe(qdef, handle, tx);
return new BufferedInputStream(handle.get());
} | java | public InputStream performGraphQuery(String queryString, SPARQLQueryBindingSet bindings, InputStreamHandle handle, Transaction tx, boolean includeInferred, String baseURI) throws JsonProcessingException {
SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(queryString);
if(notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);}
if (notNull(ruleset)) {qdef.setRulesets(ruleset);}
if (notNull(getConstrainingQueryDefinition())){
qdef.setConstrainingQueryDefinition(getConstrainingQueryDefinition());
qdef.setDirectory(getConstrainingQueryDefinition().getDirectory());
qdef.setCollections(getConstrainingQueryDefinition().getCollections());
qdef.setResponseTransform(getConstrainingQueryDefinition().getResponseTransform());
qdef.setOptionsName(getConstrainingQueryDefinition().getOptionsName());
}
if(notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);}
qdef.setIncludeDefaultRulesets(includeInferred);
sparqlManager.executeDescribe(qdef, handle, tx);
return new BufferedInputStream(handle.get());
} | [
"public",
"InputStream",
"performGraphQuery",
"(",
"String",
"queryString",
",",
"SPARQLQueryBindingSet",
"bindings",
",",
"InputStreamHandle",
"handle",
",",
"Transaction",
"tx",
",",
"boolean",
"includeInferred",
",",
"String",
"baseURI",
")",
"throws",
"JsonProcessingException",
"{",
"SPARQLQueryDefinition",
"qdef",
"=",
"sparqlManager",
".",
"newQueryDefinition",
"(",
"queryString",
")",
";",
"if",
"(",
"notNull",
"(",
"baseURI",
")",
"&&",
"!",
"baseURI",
".",
"isEmpty",
"(",
")",
")",
"{",
"qdef",
".",
"setBaseUri",
"(",
"baseURI",
")",
";",
"}",
"if",
"(",
"notNull",
"(",
"ruleset",
")",
")",
"{",
"qdef",
".",
"setRulesets",
"(",
"ruleset",
")",
";",
"}",
"if",
"(",
"notNull",
"(",
"getConstrainingQueryDefinition",
"(",
")",
")",
")",
"{",
"qdef",
".",
"setConstrainingQueryDefinition",
"(",
"getConstrainingQueryDefinition",
"(",
")",
")",
";",
"qdef",
".",
"setDirectory",
"(",
"getConstrainingQueryDefinition",
"(",
")",
".",
"getDirectory",
"(",
")",
")",
";",
"qdef",
".",
"setCollections",
"(",
"getConstrainingQueryDefinition",
"(",
")",
".",
"getCollections",
"(",
")",
")",
";",
"qdef",
".",
"setResponseTransform",
"(",
"getConstrainingQueryDefinition",
"(",
")",
".",
"getResponseTransform",
"(",
")",
")",
";",
"qdef",
".",
"setOptionsName",
"(",
"getConstrainingQueryDefinition",
"(",
")",
".",
"getOptionsName",
"(",
")",
")",
";",
"}",
"if",
"(",
"notNull",
"(",
"graphPerms",
")",
")",
"{",
"qdef",
".",
"setUpdatePermissions",
"(",
"graphPerms",
")",
";",
"}",
"qdef",
".",
"setIncludeDefaultRulesets",
"(",
"includeInferred",
")",
";",
"sparqlManager",
".",
"executeDescribe",
"(",
"qdef",
",",
"handle",
",",
"tx",
")",
";",
"return",
"new",
"BufferedInputStream",
"(",
"handle",
".",
"get",
"(",
")",
")",
";",
"}"
]
| executes GraphQuery
@param queryString
@param bindings
@param handle
@param tx
@param includeInferred
@param baseURI
@return
@throws JsonProcessingException | [
"executes",
"GraphQuery"
]
| train | https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L201-L216 |
ehcache/ehcache3 | impl/src/main/java/org/ehcache/impl/config/resilience/DefaultResilienceStrategyProviderConfiguration.java | DefaultResilienceStrategyProviderConfiguration.addResilienceStrategyFor | public DefaultResilienceStrategyProviderConfiguration addResilienceStrategyFor(String alias, ResilienceStrategy<?, ?> resilienceStrategy) {
"""
Adds a {@link ResilienceStrategy} instance to be used with a cache matching the provided alias.
@param alias the cache alias
@param resilienceStrategy the resilience strategy instance
@return this configuration instance
"""
getDefaults().put(alias, new DefaultResilienceStrategyConfiguration(resilienceStrategy));
return this;
} | java | public DefaultResilienceStrategyProviderConfiguration addResilienceStrategyFor(String alias, ResilienceStrategy<?, ?> resilienceStrategy) {
getDefaults().put(alias, new DefaultResilienceStrategyConfiguration(resilienceStrategy));
return this;
} | [
"public",
"DefaultResilienceStrategyProviderConfiguration",
"addResilienceStrategyFor",
"(",
"String",
"alias",
",",
"ResilienceStrategy",
"<",
"?",
",",
"?",
">",
"resilienceStrategy",
")",
"{",
"getDefaults",
"(",
")",
".",
"put",
"(",
"alias",
",",
"new",
"DefaultResilienceStrategyConfiguration",
"(",
"resilienceStrategy",
")",
")",
";",
"return",
"this",
";",
"}"
]
| Adds a {@link ResilienceStrategy} instance to be used with a cache matching the provided alias.
@param alias the cache alias
@param resilienceStrategy the resilience strategy instance
@return this configuration instance | [
"Adds",
"a",
"{",
"@link",
"ResilienceStrategy",
"}",
"instance",
"to",
"be",
"used",
"with",
"a",
"cache",
"matching",
"the",
"provided",
"alias",
"."
]
| train | https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/config/resilience/DefaultResilienceStrategyProviderConfiguration.java#L153-L156 |
kiegroup/drools | kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalyser.java | DMNDTAnalyser.canBeNewCurrInterval | private static boolean canBeNewCurrInterval(Bound<?> lastBound, Bound<?> currentBound) {
"""
Avoid a situation to "open" a new currentInterval for pair of same-side equals bounds like: x], x]
"""
int vCompare = BoundValueComparator.compareValueDispatchingToInf(lastBound, currentBound);
if (vCompare != 0) {
return true;
} else {
if (lastBound.isLowerBound() && currentBound.isUpperBound()) {
return true;
} else if (lastBound.isUpperBound() && lastBound.getBoundaryType() == RangeBoundary.OPEN
&& currentBound.isLowerBound() && currentBound.getBoundaryType() == RangeBoundary.OPEN) {
return true; // the case x) (x
} else {
return false;
}
}
} | java | private static boolean canBeNewCurrInterval(Bound<?> lastBound, Bound<?> currentBound) {
int vCompare = BoundValueComparator.compareValueDispatchingToInf(lastBound, currentBound);
if (vCompare != 0) {
return true;
} else {
if (lastBound.isLowerBound() && currentBound.isUpperBound()) {
return true;
} else if (lastBound.isUpperBound() && lastBound.getBoundaryType() == RangeBoundary.OPEN
&& currentBound.isLowerBound() && currentBound.getBoundaryType() == RangeBoundary.OPEN) {
return true; // the case x) (x
} else {
return false;
}
}
} | [
"private",
"static",
"boolean",
"canBeNewCurrInterval",
"(",
"Bound",
"<",
"?",
">",
"lastBound",
",",
"Bound",
"<",
"?",
">",
"currentBound",
")",
"{",
"int",
"vCompare",
"=",
"BoundValueComparator",
".",
"compareValueDispatchingToInf",
"(",
"lastBound",
",",
"currentBound",
")",
";",
"if",
"(",
"vCompare",
"!=",
"0",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"lastBound",
".",
"isLowerBound",
"(",
")",
"&&",
"currentBound",
".",
"isUpperBound",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"lastBound",
".",
"isUpperBound",
"(",
")",
"&&",
"lastBound",
".",
"getBoundaryType",
"(",
")",
"==",
"RangeBoundary",
".",
"OPEN",
"&&",
"currentBound",
".",
"isLowerBound",
"(",
")",
"&&",
"currentBound",
".",
"getBoundaryType",
"(",
")",
"==",
"RangeBoundary",
".",
"OPEN",
")",
"{",
"return",
"true",
";",
"// the case x) (x",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}"
]
| Avoid a situation to "open" a new currentInterval for pair of same-side equals bounds like: x], x] | [
"Avoid",
"a",
"situation",
"to",
"open",
"a",
"new",
"currentInterval",
"for",
"pair",
"of",
"same",
"-",
"side",
"equals",
"bounds",
"like",
":",
"x",
"]",
"x",
"]"
]
| train | https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/dtanalysis/DMNDTAnalyser.java#L421-L435 |
alkacon/opencms-core | src/org/opencms/site/CmsSite.java | CmsSite.getServerPrefix | public String getServerPrefix(CmsObject cms, String resourceName) {
"""
Returns the server prefix for the given resource in this site, used to distinguish between
secure (https) and non-secure (http) sites.<p>
This is required since a resource may have an individual "secure" setting using the property
{@link org.opencms.file.CmsPropertyDefinition#PROPERTY_SECURE}, which means this resource
must be delivered only using a secure protocol.<p>
The result will look like <code>http://site.enterprise.com:8080/</code> or <code>https://site.enterprise.com/</code>.<p>
@param cms the current users OpenCms context
@param resourceName the resource name
@return the server prefix for the given resource in this site
@see #getSecureUrl()
@see #getUrl()
"""
if (resourceName.startsWith(cms.getRequestContext().getSiteRoot())) {
// make sure this can also be used with a resource root path
resourceName = resourceName.substring(cms.getRequestContext().getSiteRoot().length());
}
boolean secure = OpenCms.getStaticExportManager().isSecureLink(
cms,
resourceName,
cms.getRequestContext().isSecureRequest());
return (secure ? getSecureUrl() : getUrl());
} | java | public String getServerPrefix(CmsObject cms, String resourceName) {
if (resourceName.startsWith(cms.getRequestContext().getSiteRoot())) {
// make sure this can also be used with a resource root path
resourceName = resourceName.substring(cms.getRequestContext().getSiteRoot().length());
}
boolean secure = OpenCms.getStaticExportManager().isSecureLink(
cms,
resourceName,
cms.getRequestContext().isSecureRequest());
return (secure ? getSecureUrl() : getUrl());
} | [
"public",
"String",
"getServerPrefix",
"(",
"CmsObject",
"cms",
",",
"String",
"resourceName",
")",
"{",
"if",
"(",
"resourceName",
".",
"startsWith",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
")",
")",
"{",
"// make sure this can also be used with a resource root path",
"resourceName",
"=",
"resourceName",
".",
"substring",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
".",
"length",
"(",
")",
")",
";",
"}",
"boolean",
"secure",
"=",
"OpenCms",
".",
"getStaticExportManager",
"(",
")",
".",
"isSecureLink",
"(",
"cms",
",",
"resourceName",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"isSecureRequest",
"(",
")",
")",
";",
"return",
"(",
"secure",
"?",
"getSecureUrl",
"(",
")",
":",
"getUrl",
"(",
")",
")",
";",
"}"
]
| Returns the server prefix for the given resource in this site, used to distinguish between
secure (https) and non-secure (http) sites.<p>
This is required since a resource may have an individual "secure" setting using the property
{@link org.opencms.file.CmsPropertyDefinition#PROPERTY_SECURE}, which means this resource
must be delivered only using a secure protocol.<p>
The result will look like <code>http://site.enterprise.com:8080/</code> or <code>https://site.enterprise.com/</code>.<p>
@param cms the current users OpenCms context
@param resourceName the resource name
@return the server prefix for the given resource in this site
@see #getSecureUrl()
@see #getUrl() | [
"Returns",
"the",
"server",
"prefix",
"for",
"the",
"given",
"resource",
"in",
"this",
"site",
"used",
"to",
"distinguish",
"between",
"secure",
"(",
"https",
")",
"and",
"non",
"-",
"secure",
"(",
"http",
")",
"sites",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/site/CmsSite.java#L514-L526 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPMeasurementUnitPersistenceImpl.java | CPMeasurementUnitPersistenceImpl.removeByG_K_T | @Override
public CPMeasurementUnit removeByG_K_T(long groupId, String key, int type)
throws NoSuchCPMeasurementUnitException {
"""
Removes the cp measurement unit where groupId = ? and key = ? and type = ? from the database.
@param groupId the group ID
@param key the key
@param type the type
@return the cp measurement unit that was removed
"""
CPMeasurementUnit cpMeasurementUnit = findByG_K_T(groupId, key, type);
return remove(cpMeasurementUnit);
} | java | @Override
public CPMeasurementUnit removeByG_K_T(long groupId, String key, int type)
throws NoSuchCPMeasurementUnitException {
CPMeasurementUnit cpMeasurementUnit = findByG_K_T(groupId, key, type);
return remove(cpMeasurementUnit);
} | [
"@",
"Override",
"public",
"CPMeasurementUnit",
"removeByG_K_T",
"(",
"long",
"groupId",
",",
"String",
"key",
",",
"int",
"type",
")",
"throws",
"NoSuchCPMeasurementUnitException",
"{",
"CPMeasurementUnit",
"cpMeasurementUnit",
"=",
"findByG_K_T",
"(",
"groupId",
",",
"key",
",",
"type",
")",
";",
"return",
"remove",
"(",
"cpMeasurementUnit",
")",
";",
"}"
]
| Removes the cp measurement unit where groupId = ? and key = ? and type = ? from the database.
@param groupId the group ID
@param key the key
@param type the type
@return the cp measurement unit that was removed | [
"Removes",
"the",
"cp",
"measurement",
"unit",
"where",
"groupId",
"=",
"?",
";",
"and",
"key",
"=",
"?",
";",
"and",
"type",
"=",
"?",
";",
"from",
"the",
"database",
"."
]
| train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPMeasurementUnitPersistenceImpl.java#L2724-L2730 |
PistoiaHELM/HELM2NotationToolkit | src/main/java/org/helm/notation2/tools/ChangeObjects.java | ChangeObjects.addAnnotationToMonomerNotation | public final static void addAnnotationToMonomerNotation(PolymerNotation polymer, int position, String annotation) {
"""
method to add an annotation to a MonomerNotation
@param polymer
PolymerNotation
@param position
position of the monomerNotation
@param annotation
new annotation
"""
polymer.getPolymerElements().getListOfElements().get(position).setAnnotation(annotation);
} | java | public final static void addAnnotationToMonomerNotation(PolymerNotation polymer, int position, String annotation) {
polymer.getPolymerElements().getListOfElements().get(position).setAnnotation(annotation);
} | [
"public",
"final",
"static",
"void",
"addAnnotationToMonomerNotation",
"(",
"PolymerNotation",
"polymer",
",",
"int",
"position",
",",
"String",
"annotation",
")",
"{",
"polymer",
".",
"getPolymerElements",
"(",
")",
".",
"getListOfElements",
"(",
")",
".",
"get",
"(",
"position",
")",
".",
"setAnnotation",
"(",
"annotation",
")",
";",
"}"
]
| method to add an annotation to a MonomerNotation
@param polymer
PolymerNotation
@param position
position of the monomerNotation
@param annotation
new annotation | [
"method",
"to",
"add",
"an",
"annotation",
"to",
"a",
"MonomerNotation"
]
| train | https://github.com/PistoiaHELM/HELM2NotationToolkit/blob/ac5bb01fd5b4082134a8ef226bbe2ff0f60fcd38/src/main/java/org/helm/notation2/tools/ChangeObjects.java#L326-L328 |
alkacon/opencms-core | src/org/opencms/workplace/CmsWorkplace.java | CmsWorkplace.sendForward | public void sendForward(String location, Map<String, String[]> params) throws IOException, ServletException {
"""
Forwards to the specified location in the OpenCms VFS.<p>
@param location the location the response is redirected to
@param params the map of parameters to use for the forwarded request
@throws IOException in case the forward fails
@throws ServletException in case the forward fails
"""
setForwarded(true);
// params must be arrays of String, ensure this is the case
Map<String, String[]> parameters = CmsRequestUtil.createParameterMap(params);
CmsRequestUtil.forwardRequest(
getJsp().link(location),
parameters,
getJsp().getRequest(),
getJsp().getResponse());
} | java | public void sendForward(String location, Map<String, String[]> params) throws IOException, ServletException {
setForwarded(true);
// params must be arrays of String, ensure this is the case
Map<String, String[]> parameters = CmsRequestUtil.createParameterMap(params);
CmsRequestUtil.forwardRequest(
getJsp().link(location),
parameters,
getJsp().getRequest(),
getJsp().getResponse());
} | [
"public",
"void",
"sendForward",
"(",
"String",
"location",
",",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"params",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"setForwarded",
"(",
"true",
")",
";",
"// params must be arrays of String, ensure this is the case",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
"=",
"CmsRequestUtil",
".",
"createParameterMap",
"(",
"params",
")",
";",
"CmsRequestUtil",
".",
"forwardRequest",
"(",
"getJsp",
"(",
")",
".",
"link",
"(",
"location",
")",
",",
"parameters",
",",
"getJsp",
"(",
")",
".",
"getRequest",
"(",
")",
",",
"getJsp",
"(",
")",
".",
"getResponse",
"(",
")",
")",
";",
"}"
]
| Forwards to the specified location in the OpenCms VFS.<p>
@param location the location the response is redirected to
@param params the map of parameters to use for the forwarded request
@throws IOException in case the forward fails
@throws ServletException in case the forward fails | [
"Forwards",
"to",
"the",
"specified",
"location",
"in",
"the",
"OpenCms",
"VFS",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsWorkplace.java#L2135-L2145 |
Esri/spatial-framework-for-hadoop | hive/src/main/java/com/esri/hadoop/hive/GeometryUtils.java | GeometryUtils.setType | public static void setType(BytesWritable geomref, OGCType type) {
"""
Sets the geometry type (in place) for the given hive geometry bytes
@param geomref reference to hive geometry bytes
@param type OGC geometry type
"""
geomref.getBytes()[SIZE_WKID] = (byte) type.getIndex();
} | java | public static void setType(BytesWritable geomref, OGCType type){
geomref.getBytes()[SIZE_WKID] = (byte) type.getIndex();
} | [
"public",
"static",
"void",
"setType",
"(",
"BytesWritable",
"geomref",
",",
"OGCType",
"type",
")",
"{",
"geomref",
".",
"getBytes",
"(",
")",
"[",
"SIZE_WKID",
"]",
"=",
"(",
"byte",
")",
"type",
".",
"getIndex",
"(",
")",
";",
"}"
]
| Sets the geometry type (in place) for the given hive geometry bytes
@param geomref reference to hive geometry bytes
@param type OGC geometry type | [
"Sets",
"the",
"geometry",
"type",
"(",
"in",
"place",
")",
"for",
"the",
"given",
"hive",
"geometry",
"bytes"
]
| train | https://github.com/Esri/spatial-framework-for-hadoop/blob/00959d6b4465313c934aaa8aaf17b52d6c9c60d4/hive/src/main/java/com/esri/hadoop/hive/GeometryUtils.java#L156-L158 |
JodaOrg/joda-time | src/main/java/org/joda/time/field/FieldUtils.java | FieldUtils.safeDivide | public static long safeDivide(long dividend, long divisor, RoundingMode roundingMode) {
"""
Divides the dividend by divisor. Rounding of result occurs
as per the roundingMode.
@param dividend the dividend
@param divisor the divisor
@param roundingMode the desired rounding mode
@return the division result as per the specified rounding mode
@throws ArithmeticException if the operation overflows or the divisor is zero
"""
if (dividend == Long.MIN_VALUE && divisor == -1L) {
throw new ArithmeticException("Multiplication overflows a long: " + dividend + " / " + divisor);
}
BigDecimal dividendBigDecimal = new BigDecimal(dividend);
BigDecimal divisorBigDecimal = new BigDecimal(divisor);
return dividendBigDecimal.divide(divisorBigDecimal, roundingMode).longValue();
} | java | public static long safeDivide(long dividend, long divisor, RoundingMode roundingMode) {
if (dividend == Long.MIN_VALUE && divisor == -1L) {
throw new ArithmeticException("Multiplication overflows a long: " + dividend + " / " + divisor);
}
BigDecimal dividendBigDecimal = new BigDecimal(dividend);
BigDecimal divisorBigDecimal = new BigDecimal(divisor);
return dividendBigDecimal.divide(divisorBigDecimal, roundingMode).longValue();
} | [
"public",
"static",
"long",
"safeDivide",
"(",
"long",
"dividend",
",",
"long",
"divisor",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"if",
"(",
"dividend",
"==",
"Long",
".",
"MIN_VALUE",
"&&",
"divisor",
"==",
"-",
"1L",
")",
"{",
"throw",
"new",
"ArithmeticException",
"(",
"\"Multiplication overflows a long: \"",
"+",
"dividend",
"+",
"\" / \"",
"+",
"divisor",
")",
";",
"}",
"BigDecimal",
"dividendBigDecimal",
"=",
"new",
"BigDecimal",
"(",
"dividend",
")",
";",
"BigDecimal",
"divisorBigDecimal",
"=",
"new",
"BigDecimal",
"(",
"divisor",
")",
";",
"return",
"dividendBigDecimal",
".",
"divide",
"(",
"divisorBigDecimal",
",",
"roundingMode",
")",
".",
"longValue",
"(",
")",
";",
"}"
]
| Divides the dividend by divisor. Rounding of result occurs
as per the roundingMode.
@param dividend the dividend
@param divisor the divisor
@param roundingMode the desired rounding mode
@return the division result as per the specified rounding mode
@throws ArithmeticException if the operation overflows or the divisor is zero | [
"Divides",
"the",
"dividend",
"by",
"divisor",
".",
"Rounding",
"of",
"result",
"occurs",
"as",
"per",
"the",
"roundingMode",
"."
]
| train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L208-L216 |
exoplatform/jcr | exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/MembershipTypeHandlerImpl.java | MembershipTypeHandlerImpl.writeMembershipType | private void writeMembershipType(MembershipType membershipType, Node mtNode) throws Exception {
"""
Writes membership type properties to the node.
@param membershipType
the membership type to store
@param mtNode
the node where membership type properties will be stored
"""
if (!mtNode.isNodeType("exo:datetime")) {
mtNode.addMixin("exo:datetime");
}
mtNode.setProperty(MembershipTypeProperties.JOS_DESCRIPTION, membershipType.getDescription());
} | java | private void writeMembershipType(MembershipType membershipType, Node mtNode) throws Exception
{
if (!mtNode.isNodeType("exo:datetime")) {
mtNode.addMixin("exo:datetime");
}
mtNode.setProperty(MembershipTypeProperties.JOS_DESCRIPTION, membershipType.getDescription());
} | [
"private",
"void",
"writeMembershipType",
"(",
"MembershipType",
"membershipType",
",",
"Node",
"mtNode",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"mtNode",
".",
"isNodeType",
"(",
"\"exo:datetime\"",
")",
")",
"{",
"mtNode",
".",
"addMixin",
"(",
"\"exo:datetime\"",
")",
";",
"}",
"mtNode",
".",
"setProperty",
"(",
"MembershipTypeProperties",
".",
"JOS_DESCRIPTION",
",",
"membershipType",
".",
"getDescription",
"(",
")",
")",
";",
"}"
]
| Writes membership type properties to the node.
@param membershipType
the membership type to store
@param mtNode
the node where membership type properties will be stored | [
"Writes",
"membership",
"type",
"properties",
"to",
"the",
"node",
"."
]
| train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/MembershipTypeHandlerImpl.java#L405-L411 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java | JNStorage.getSyncLogDestFile | File getSyncLogDestFile(long segmentTxId, long endTxId) {
"""
Get name for destination file used for log syncing, after a journal node
crashed.
"""
String name = NNStorage.getFinalizedEditsFileName(segmentTxId, endTxId);
return new File(sd.getCurrentDir(), name);
} | java | File getSyncLogDestFile(long segmentTxId, long endTxId) {
String name = NNStorage.getFinalizedEditsFileName(segmentTxId, endTxId);
return new File(sd.getCurrentDir(), name);
} | [
"File",
"getSyncLogDestFile",
"(",
"long",
"segmentTxId",
",",
"long",
"endTxId",
")",
"{",
"String",
"name",
"=",
"NNStorage",
".",
"getFinalizedEditsFileName",
"(",
"segmentTxId",
",",
"endTxId",
")",
";",
"return",
"new",
"File",
"(",
"sd",
".",
"getCurrentDir",
"(",
")",
",",
"name",
")",
";",
"}"
]
| Get name for destination file used for log syncing, after a journal node
crashed. | [
"Get",
"name",
"for",
"destination",
"file",
"used",
"for",
"log",
"syncing",
"after",
"a",
"journal",
"node",
"crashed",
"."
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java#L155-L158 |
google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/java/nio/charset/ModifiedUtf8.java | ModifiedUtf8.countBytes | public static long countBytes(String s, boolean shortLength) throws UTFDataFormatException {
"""
Returns the number of bytes the modified UTF-8 representation of 's' would take. Note
that this is just the space for the bytes representing the characters, not the length
which precedes those bytes, because different callers represent the length differently,
as two, four, or even eight bytes. If {@code shortLength} is true, we'll throw an
exception if the string is too long for its length to be represented by a short.
"""
long result = 0;
final int length = s.length();
for (int i = 0; i < length; ++i) {
char ch = s.charAt(i);
if (ch != 0 && ch <= 127) { // U+0000 uses two bytes.
++result;
} else if (ch <= 2047) {
result += 2;
} else {
result += 3;
}
if (shortLength && result > 65535) {
throw new UTFDataFormatException("String more than 65535 UTF bytes long");
}
}
return result;
} | java | public static long countBytes(String s, boolean shortLength) throws UTFDataFormatException {
long result = 0;
final int length = s.length();
for (int i = 0; i < length; ++i) {
char ch = s.charAt(i);
if (ch != 0 && ch <= 127) { // U+0000 uses two bytes.
++result;
} else if (ch <= 2047) {
result += 2;
} else {
result += 3;
}
if (shortLength && result > 65535) {
throw new UTFDataFormatException("String more than 65535 UTF bytes long");
}
}
return result;
} | [
"public",
"static",
"long",
"countBytes",
"(",
"String",
"s",
",",
"boolean",
"shortLength",
")",
"throws",
"UTFDataFormatException",
"{",
"long",
"result",
"=",
"0",
";",
"final",
"int",
"length",
"=",
"s",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
")",
"{",
"char",
"ch",
"=",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"ch",
"!=",
"0",
"&&",
"ch",
"<=",
"127",
")",
"{",
"// U+0000 uses two bytes.",
"++",
"result",
";",
"}",
"else",
"if",
"(",
"ch",
"<=",
"2047",
")",
"{",
"result",
"+=",
"2",
";",
"}",
"else",
"{",
"result",
"+=",
"3",
";",
"}",
"if",
"(",
"shortLength",
"&&",
"result",
">",
"65535",
")",
"{",
"throw",
"new",
"UTFDataFormatException",
"(",
"\"String more than 65535 UTF bytes long\"",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
]
| Returns the number of bytes the modified UTF-8 representation of 's' would take. Note
that this is just the space for the bytes representing the characters, not the length
which precedes those bytes, because different callers represent the length differently,
as two, four, or even eight bytes. If {@code shortLength} is true, we'll throw an
exception if the string is too long for its length to be represented by a short. | [
"Returns",
"the",
"number",
"of",
"bytes",
"the",
"modified",
"UTF",
"-",
"8",
"representation",
"of",
"s",
"would",
"take",
".",
"Note",
"that",
"this",
"is",
"just",
"the",
"space",
"for",
"the",
"bytes",
"representing",
"the",
"characters",
"not",
"the",
"length",
"which",
"precedes",
"those",
"bytes",
"because",
"different",
"callers",
"represent",
"the",
"length",
"differently",
"as",
"two",
"four",
"or",
"even",
"eight",
"bytes",
".",
"If",
"{"
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/java/nio/charset/ModifiedUtf8.java#L73-L90 |
gosu-lang/gosu-lang | gosu-core/src/main/java/gw/internal/gosu/parser/GosuParserFactoryImpl.java | GosuParserFactoryImpl.createParser | public IGosuParser createParser(
String strSource, ISymbolTable symTable, IScriptabilityModifier scriptabilityConstraint ) {
"""
Creates an IGosuParser appropriate for parsing and executing Gosu.
@param strSource The text of the the rule source
@param symTable The symbol table the parser uses to parse and execute the rule
@param scriptabilityConstraint Specifies the types of methods/properties that are visible
@return A parser appropriate for parsing Gosu source.
"""
IGosuParser parser = new GosuParser( symTable, scriptabilityConstraint );
parser.setScript( strSource );
return parser;
} | java | public IGosuParser createParser(
String strSource, ISymbolTable symTable, IScriptabilityModifier scriptabilityConstraint )
{
IGosuParser parser = new GosuParser( symTable, scriptabilityConstraint );
parser.setScript( strSource );
return parser;
} | [
"public",
"IGosuParser",
"createParser",
"(",
"String",
"strSource",
",",
"ISymbolTable",
"symTable",
",",
"IScriptabilityModifier",
"scriptabilityConstraint",
")",
"{",
"IGosuParser",
"parser",
"=",
"new",
"GosuParser",
"(",
"symTable",
",",
"scriptabilityConstraint",
")",
";",
"parser",
".",
"setScript",
"(",
"strSource",
")",
";",
"return",
"parser",
";",
"}"
]
| Creates an IGosuParser appropriate for parsing and executing Gosu.
@param strSource The text of the the rule source
@param symTable The symbol table the parser uses to parse and execute the rule
@param scriptabilityConstraint Specifies the types of methods/properties that are visible
@return A parser appropriate for parsing Gosu source. | [
"Creates",
"an",
"IGosuParser",
"appropriate",
"for",
"parsing",
"and",
"executing",
"Gosu",
"."
]
| train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core/src/main/java/gw/internal/gosu/parser/GosuParserFactoryImpl.java#L33-L39 |
Azure/azure-sdk-for-java | recoveryservices.backup/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2016_06_01/implementation/ProtectedItemOperationResultsInner.java | ProtectedItemOperationResultsInner.getAsync | public Observable<ProtectedItemResourceInner> getAsync(String vaultName, String resourceGroupName, String fabricName, String containerName, String protectedItemName, String operationId) {
"""
Gets the result of any operation on the backup item.
@param vaultName The name of the Recovery Services vault.
@param resourceGroupName The name of the resource group associated with the Recovery Services vault.
@param fabricName The fabric name associated with the backup item.
@param containerName The container name associated with the backup item.
@param protectedItemName The name of backup item used in this GET operation.
@param operationId The OperationID used in this GET operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ProtectedItemResourceInner object
"""
return getWithServiceResponseAsync(vaultName, resourceGroupName, fabricName, containerName, protectedItemName, operationId).map(new Func1<ServiceResponse<ProtectedItemResourceInner>, ProtectedItemResourceInner>() {
@Override
public ProtectedItemResourceInner call(ServiceResponse<ProtectedItemResourceInner> response) {
return response.body();
}
});
} | java | public Observable<ProtectedItemResourceInner> getAsync(String vaultName, String resourceGroupName, String fabricName, String containerName, String protectedItemName, String operationId) {
return getWithServiceResponseAsync(vaultName, resourceGroupName, fabricName, containerName, protectedItemName, operationId).map(new Func1<ServiceResponse<ProtectedItemResourceInner>, ProtectedItemResourceInner>() {
@Override
public ProtectedItemResourceInner call(ServiceResponse<ProtectedItemResourceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ProtectedItemResourceInner",
">",
"getAsync",
"(",
"String",
"vaultName",
",",
"String",
"resourceGroupName",
",",
"String",
"fabricName",
",",
"String",
"containerName",
",",
"String",
"protectedItemName",
",",
"String",
"operationId",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"vaultName",
",",
"resourceGroupName",
",",
"fabricName",
",",
"containerName",
",",
"protectedItemName",
",",
"operationId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ProtectedItemResourceInner",
">",
",",
"ProtectedItemResourceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ProtectedItemResourceInner",
"call",
"(",
"ServiceResponse",
"<",
"ProtectedItemResourceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets the result of any operation on the backup item.
@param vaultName The name of the Recovery Services vault.
@param resourceGroupName The name of the resource group associated with the Recovery Services vault.
@param fabricName The fabric name associated with the backup item.
@param containerName The container name associated with the backup item.
@param protectedItemName The name of backup item used in this GET operation.
@param operationId The OperationID used in this GET operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ProtectedItemResourceInner object | [
"Gets",
"the",
"result",
"of",
"any",
"operation",
"on",
"the",
"backup",
"item",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/recoveryservices.backup/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2016_06_01/implementation/ProtectedItemOperationResultsInner.java#L107-L114 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/BlockTree.java | BlockTree.addCode | boolean addCode(int code, byte []minKey, byte []maxKey, int pid) {
"""
/*
boolean remove(byte []minKey, byte []maxKey)
{
int len = minKey.length + maxKey.length + 9;
byte []buffer = getBuffer();
boolean isRemove = false;
int minOffset = 1;
int maxOffset = minOffset + minKey.length;
for (int ptr = getIndex(); ptr < BLOCK_SIZE; ptr += len) {
if (compareKey(minKey, buffer, ptr + minOffset) == 0
&& compareKey(maxKey, buffer, ptr + maxOffset) == 0) {
buffer[ptr] = REMOVE;
isRemove = true;
}
}
return isRemove;
}
"""
int len = minKey.length + maxKey.length + 5;
int index = getIndex() - len;
int ptr = index;
if (ptr < 0) {
return false;
}
byte []buffer = getBuffer();
buffer[ptr] = (byte) code;
ptr += 1;
System.arraycopy(minKey, 0, buffer, ptr, minKey.length);
ptr += minKey.length;
System.arraycopy(maxKey, 0, buffer, ptr, maxKey.length);
ptr += maxKey.length;
BitsUtil.writeInt(buffer, ptr, pid);
setIndex(index);
/*
System.out.println("ADDC: " + code + " " + pid
+ " " + Hex.toShortHex(minKey)
+ " " + Hex.toShortHex(maxKey));
*/
return true;
} | java | boolean addCode(int code, byte []minKey, byte []maxKey, int pid)
{
int len = minKey.length + maxKey.length + 5;
int index = getIndex() - len;
int ptr = index;
if (ptr < 0) {
return false;
}
byte []buffer = getBuffer();
buffer[ptr] = (byte) code;
ptr += 1;
System.arraycopy(minKey, 0, buffer, ptr, minKey.length);
ptr += minKey.length;
System.arraycopy(maxKey, 0, buffer, ptr, maxKey.length);
ptr += maxKey.length;
BitsUtil.writeInt(buffer, ptr, pid);
setIndex(index);
/*
System.out.println("ADDC: " + code + " " + pid
+ " " + Hex.toShortHex(minKey)
+ " " + Hex.toShortHex(maxKey));
*/
return true;
} | [
"boolean",
"addCode",
"(",
"int",
"code",
",",
"byte",
"[",
"]",
"minKey",
",",
"byte",
"[",
"]",
"maxKey",
",",
"int",
"pid",
")",
"{",
"int",
"len",
"=",
"minKey",
".",
"length",
"+",
"maxKey",
".",
"length",
"+",
"5",
";",
"int",
"index",
"=",
"getIndex",
"(",
")",
"-",
"len",
";",
"int",
"ptr",
"=",
"index",
";",
"if",
"(",
"ptr",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"byte",
"[",
"]",
"buffer",
"=",
"getBuffer",
"(",
")",
";",
"buffer",
"[",
"ptr",
"]",
"=",
"(",
"byte",
")",
"code",
";",
"ptr",
"+=",
"1",
";",
"System",
".",
"arraycopy",
"(",
"minKey",
",",
"0",
",",
"buffer",
",",
"ptr",
",",
"minKey",
".",
"length",
")",
";",
"ptr",
"+=",
"minKey",
".",
"length",
";",
"System",
".",
"arraycopy",
"(",
"maxKey",
",",
"0",
",",
"buffer",
",",
"ptr",
",",
"maxKey",
".",
"length",
")",
";",
"ptr",
"+=",
"maxKey",
".",
"length",
";",
"BitsUtil",
".",
"writeInt",
"(",
"buffer",
",",
"ptr",
",",
"pid",
")",
";",
"setIndex",
"(",
"index",
")",
";",
"/*\n System.out.println(\"ADDC: \" + code + \" \" + pid\n + \" \" + Hex.toShortHex(minKey)\n + \" \" + Hex.toShortHex(maxKey));\n */",
"return",
"true",
";",
"}"
]
| /*
boolean remove(byte []minKey, byte []maxKey)
{
int len = minKey.length + maxKey.length + 9;
byte []buffer = getBuffer();
boolean isRemove = false;
int minOffset = 1;
int maxOffset = minOffset + minKey.length;
for (int ptr = getIndex(); ptr < BLOCK_SIZE; ptr += len) {
if (compareKey(minKey, buffer, ptr + minOffset) == 0
&& compareKey(maxKey, buffer, ptr + maxOffset) == 0) {
buffer[ptr] = REMOVE;
isRemove = true;
}
}
return isRemove;
} | [
"/",
"*",
"boolean",
"remove",
"(",
"byte",
"[]",
"minKey",
"byte",
"[]",
"maxKey",
")",
"{",
"int",
"len",
"=",
"minKey",
".",
"length",
"+",
"maxKey",
".",
"length",
"+",
"9",
";"
]
| train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/BlockTree.java#L105-L139 |
googleapis/cloud-bigtable-client | bigtable-client-core-parent/bigtable-hbase/src/main/java/org/apache/hadoop/hbase/client/AbstractBigtableAdmin.java | AbstractBigtableAdmin.deleteColumn | @Deprecated
public void deleteColumn(String tableName, byte[] columnName) throws IOException {
"""
<p>deleteColumn.</p>
@param tableName a {@link java.lang.String} object.
@param columnName an array of byte.
@throws java.io.IOException if any.
"""
deleteColumn(TableName.valueOf(tableName), columnName);
} | java | @Deprecated
public void deleteColumn(String tableName, byte[] columnName) throws IOException {
deleteColumn(TableName.valueOf(tableName), columnName);
} | [
"@",
"Deprecated",
"public",
"void",
"deleteColumn",
"(",
"String",
"tableName",
",",
"byte",
"[",
"]",
"columnName",
")",
"throws",
"IOException",
"{",
"deleteColumn",
"(",
"TableName",
".",
"valueOf",
"(",
"tableName",
")",
",",
"columnName",
")",
";",
"}"
]
| <p>deleteColumn.</p>
@param tableName a {@link java.lang.String} object.
@param columnName an array of byte.
@throws java.io.IOException if any. | [
"<p",
">",
"deleteColumn",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/googleapis/cloud-bigtable-client/blob/53543f36e4d6f9ed1963640d91a35be2a2047656/bigtable-client-core-parent/bigtable-hbase/src/main/java/org/apache/hadoop/hbase/client/AbstractBigtableAdmin.java#L645-L648 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentSettingsInner.java | EnvironmentSettingsInner.updateAsync | public Observable<EnvironmentSettingInner> updateAsync(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, EnvironmentSettingFragment environmentSetting) {
"""
Modify properties of environment setting.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param environmentSetting Represents settings of an environment, from which environment instances would be created
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the EnvironmentSettingInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting).map(new Func1<ServiceResponse<EnvironmentSettingInner>, EnvironmentSettingInner>() {
@Override
public EnvironmentSettingInner call(ServiceResponse<EnvironmentSettingInner> response) {
return response.body();
}
});
} | java | public Observable<EnvironmentSettingInner> updateAsync(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, EnvironmentSettingFragment environmentSetting) {
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting).map(new Func1<ServiceResponse<EnvironmentSettingInner>, EnvironmentSettingInner>() {
@Override
public EnvironmentSettingInner call(ServiceResponse<EnvironmentSettingInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"EnvironmentSettingInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"String",
"environmentSettingName",
",",
"EnvironmentSettingFragment",
"environmentSetting",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"environmentSettingName",
",",
"environmentSetting",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"EnvironmentSettingInner",
">",
",",
"EnvironmentSettingInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"EnvironmentSettingInner",
"call",
"(",
"ServiceResponse",
"<",
"EnvironmentSettingInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Modify properties of environment setting.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param environmentSetting Represents settings of an environment, from which environment instances would be created
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the EnvironmentSettingInner object | [
"Modify",
"properties",
"of",
"environment",
"setting",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentSettingsInner.java#L1029-L1036 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Normalizer.java | Normalizer.setText | @Deprecated
public void setText(UCharacterIterator newText) {
"""
Set the input text over which this <tt>Normalizer</tt> will iterate.
The iteration position is set to the beginning of the string.
@param newText The new string to be normalized.
@deprecated ICU 56
@hide original deprecated declaration
"""
try{
UCharacterIterator newIter = (UCharacterIterator)newText.clone();
if (newIter == null) {
throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
}catch(CloneNotSupportedException e) {
throw new ICUCloneNotSupportedException("Could not clone the UCharacterIterator", e);
}
} | java | @Deprecated
public void setText(UCharacterIterator newText) {
try{
UCharacterIterator newIter = (UCharacterIterator)newText.clone();
if (newIter == null) {
throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
}catch(CloneNotSupportedException e) {
throw new ICUCloneNotSupportedException("Could not clone the UCharacterIterator", e);
}
} | [
"@",
"Deprecated",
"public",
"void",
"setText",
"(",
"UCharacterIterator",
"newText",
")",
"{",
"try",
"{",
"UCharacterIterator",
"newIter",
"=",
"(",
"UCharacterIterator",
")",
"newText",
".",
"clone",
"(",
")",
";",
"if",
"(",
"newIter",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not create a new UCharacterIterator\"",
")",
";",
"}",
"text",
"=",
"newIter",
";",
"reset",
"(",
")",
";",
"}",
"catch",
"(",
"CloneNotSupportedException",
"e",
")",
"{",
"throw",
"new",
"ICUCloneNotSupportedException",
"(",
"\"Could not clone the UCharacterIterator\"",
",",
"e",
")",
";",
"}",
"}"
]
| Set the input text over which this <tt>Normalizer</tt> will iterate.
The iteration position is set to the beginning of the string.
@param newText The new string to be normalized.
@deprecated ICU 56
@hide original deprecated declaration | [
"Set",
"the",
"input",
"text",
"over",
"which",
"this",
"<tt",
">",
"Normalizer<",
"/",
"tt",
">",
"will",
"iterate",
".",
"The",
"iteration",
"position",
"is",
"set",
"to",
"the",
"beginning",
"of",
"the",
"string",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Normalizer.java#L1937-L1949 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/Continuations.java | Continuations.stringContinuation | static Continuation<String> stringContinuation(
WriteContinuation delegate, final StringBuilder buffer) {
"""
Return a string valued continuation. Rendering logic is delegated to the {@link
WriteContinuation}, but it is assumed that the builder is the render target.
"""
if (delegate.result().isDone()) {
return done(buffer.toString());
}
return new AbstractContinuation<String>(delegate) {
@Override
Continuation<String> nextContinuation(WriteContinuation next) {
return stringContinuation(next, buffer);
}
};
} | java | static Continuation<String> stringContinuation(
WriteContinuation delegate, final StringBuilder buffer) {
if (delegate.result().isDone()) {
return done(buffer.toString());
}
return new AbstractContinuation<String>(delegate) {
@Override
Continuation<String> nextContinuation(WriteContinuation next) {
return stringContinuation(next, buffer);
}
};
} | [
"static",
"Continuation",
"<",
"String",
">",
"stringContinuation",
"(",
"WriteContinuation",
"delegate",
",",
"final",
"StringBuilder",
"buffer",
")",
"{",
"if",
"(",
"delegate",
".",
"result",
"(",
")",
".",
"isDone",
"(",
")",
")",
"{",
"return",
"done",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"new",
"AbstractContinuation",
"<",
"String",
">",
"(",
"delegate",
")",
"{",
"@",
"Override",
"Continuation",
"<",
"String",
">",
"nextContinuation",
"(",
"WriteContinuation",
"next",
")",
"{",
"return",
"stringContinuation",
"(",
"next",
",",
"buffer",
")",
";",
"}",
"}",
";",
"}"
]
| Return a string valued continuation. Rendering logic is delegated to the {@link
WriteContinuation}, but it is assumed that the builder is the render target. | [
"Return",
"a",
"string",
"valued",
"continuation",
".",
"Rendering",
"logic",
"is",
"delegated",
"to",
"the",
"{"
]
| train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/Continuations.java#L50-L61 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java | AbstractQueuedSynchronizer.tryAcquireSharedNanos | public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout)
throws InterruptedException {
"""
Attempts to acquire in shared mode, aborting if interrupted, and
failing if the given timeout elapses. Implemented by first
checking interrupt status, then invoking at least once {@link
#tryAcquireShared}, returning on success. Otherwise, the
thread is queued, possibly repeatedly blocking and unblocking,
invoking {@link #tryAcquireShared} until success or the thread
is interrupted or the timeout elapses.
@param arg the acquire argument. This value is conveyed to
{@link #tryAcquireShared} but is otherwise uninterpreted
and can represent anything you like.
@param nanosTimeout the maximum number of nanoseconds to wait
@return {@code true} if acquired; {@code false} if timed out
@throws InterruptedException if the current thread is interrupted
"""
if (Thread.interrupted())
throw new InterruptedException();
return tryAcquireShared(arg) >= 0 ||
doAcquireSharedNanos(arg, nanosTimeout);
} | java | public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
return tryAcquireShared(arg) >= 0 ||
doAcquireSharedNanos(arg, nanosTimeout);
} | [
"public",
"final",
"boolean",
"tryAcquireSharedNanos",
"(",
"int",
"arg",
",",
"long",
"nanosTimeout",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"Thread",
".",
"interrupted",
"(",
")",
")",
"throw",
"new",
"InterruptedException",
"(",
")",
";",
"return",
"tryAcquireShared",
"(",
"arg",
")",
">=",
"0",
"||",
"doAcquireSharedNanos",
"(",
"arg",
",",
"nanosTimeout",
")",
";",
"}"
]
| Attempts to acquire in shared mode, aborting if interrupted, and
failing if the given timeout elapses. Implemented by first
checking interrupt status, then invoking at least once {@link
#tryAcquireShared}, returning on success. Otherwise, the
thread is queued, possibly repeatedly blocking and unblocking,
invoking {@link #tryAcquireShared} until success or the thread
is interrupted or the timeout elapses.
@param arg the acquire argument. This value is conveyed to
{@link #tryAcquireShared} but is otherwise uninterpreted
and can represent anything you like.
@param nanosTimeout the maximum number of nanoseconds to wait
@return {@code true} if acquired; {@code false} if timed out
@throws InterruptedException if the current thread is interrupted | [
"Attempts",
"to",
"acquire",
"in",
"shared",
"mode",
"aborting",
"if",
"interrupted",
"and",
"failing",
"if",
"the",
"given",
"timeout",
"elapses",
".",
"Implemented",
"by",
"first",
"checking",
"interrupt",
"status",
"then",
"invoking",
"at",
"least",
"once",
"{",
"@link",
"#tryAcquireShared",
"}",
"returning",
"on",
"success",
".",
"Otherwise",
"the",
"thread",
"is",
"queued",
"possibly",
"repeatedly",
"blocking",
"and",
"unblocking",
"invoking",
"{",
"@link",
"#tryAcquireShared",
"}",
"until",
"success",
"or",
"the",
"thread",
"is",
"interrupted",
"or",
"the",
"timeout",
"elapses",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java#L1351-L1357 |
BioPAX/Paxtools | pattern/src/main/java/org/biopax/paxtools/pattern/constraint/Type.java | Type.satisfies | @Override
public boolean satisfies(Match match, int... ind) {
"""
Checks if the element is assignable to a variable of the desired type.
@param match current pattern match
@param ind mapped indices
@return true if the element is assignable to a variable of the desired type
"""
assert ind.length == 1;
return clazz.isAssignableFrom(match.get(ind[0]).getModelInterface());
} | java | @Override
public boolean satisfies(Match match, int... ind)
{
assert ind.length == 1;
return clazz.isAssignableFrom(match.get(ind[0]).getModelInterface());
} | [
"@",
"Override",
"public",
"boolean",
"satisfies",
"(",
"Match",
"match",
",",
"int",
"...",
"ind",
")",
"{",
"assert",
"ind",
".",
"length",
"==",
"1",
";",
"return",
"clazz",
".",
"isAssignableFrom",
"(",
"match",
".",
"get",
"(",
"ind",
"[",
"0",
"]",
")",
".",
"getModelInterface",
"(",
")",
")",
";",
"}"
]
| Checks if the element is assignable to a variable of the desired type.
@param match current pattern match
@param ind mapped indices
@return true if the element is assignable to a variable of the desired type | [
"Checks",
"if",
"the",
"element",
"is",
"assignable",
"to",
"a",
"variable",
"of",
"the",
"desired",
"type",
"."
]
| train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/constraint/Type.java#L34-L40 |
Waikato/moa | moa/src/main/java/moa/clusterers/outliers/AnyOut/util/EMProjectedClustering.java | EMProjectedClustering.getEMClusteringVariances | public int[][] getEMClusteringVariances(double[][] pointArray, int k) {
"""
Performs an EM clustering on the provided data set
!! Only the variances are calculated and used for point assignments !
!!! the number k' of returned clusters might be smaller than k !!!
@param pointArray the data set as an array[n][d] of n points with d dimensions
@param k the number of requested partitions (!might return less)
@return a mapping int[n][k'] of the n given points to the k' resulting clusters
"""
// initialize field and clustering
initFields(pointArray, k);
setInitialPartitions(pointArray, k);
// iterate M and E
double currentExpectation, newExpectation = 0.0;
double expectationDeviation;
int count = 0;
do{
currentExpectation = newExpectation;
// reassign objects
getNewClusterRepresentation();
calculateAllProbabilities();
// calculate new expectation value
newExpectation = expectation();
// stop when the deviation is less than minDeviation
expectationDeviation = 1.0 - (currentExpectation / newExpectation);
count++;
} while (expectationDeviation > minDeviation && count < MAXITER);
// return the resulting mapping from points to clusters
return createProjectedClustering();
} | java | public int[][] getEMClusteringVariances(double[][] pointArray, int k) {
// initialize field and clustering
initFields(pointArray, k);
setInitialPartitions(pointArray, k);
// iterate M and E
double currentExpectation, newExpectation = 0.0;
double expectationDeviation;
int count = 0;
do{
currentExpectation = newExpectation;
// reassign objects
getNewClusterRepresentation();
calculateAllProbabilities();
// calculate new expectation value
newExpectation = expectation();
// stop when the deviation is less than minDeviation
expectationDeviation = 1.0 - (currentExpectation / newExpectation);
count++;
} while (expectationDeviation > minDeviation && count < MAXITER);
// return the resulting mapping from points to clusters
return createProjectedClustering();
} | [
"public",
"int",
"[",
"]",
"[",
"]",
"getEMClusteringVariances",
"(",
"double",
"[",
"]",
"[",
"]",
"pointArray",
",",
"int",
"k",
")",
"{",
"// initialize field and clustering\r",
"initFields",
"(",
"pointArray",
",",
"k",
")",
";",
"setInitialPartitions",
"(",
"pointArray",
",",
"k",
")",
";",
"// iterate M and E\r",
"double",
"currentExpectation",
",",
"newExpectation",
"=",
"0.0",
";",
"double",
"expectationDeviation",
";",
"int",
"count",
"=",
"0",
";",
"do",
"{",
"currentExpectation",
"=",
"newExpectation",
";",
"// reassign objects\r",
"getNewClusterRepresentation",
"(",
")",
";",
"calculateAllProbabilities",
"(",
")",
";",
"// calculate new expectation value\r",
"newExpectation",
"=",
"expectation",
"(",
")",
";",
"// stop when the deviation is less than minDeviation\r",
"expectationDeviation",
"=",
"1.0",
"-",
"(",
"currentExpectation",
"/",
"newExpectation",
")",
";",
"count",
"++",
";",
"}",
"while",
"(",
"expectationDeviation",
">",
"minDeviation",
"&&",
"count",
"<",
"MAXITER",
")",
";",
"// return the resulting mapping from points to clusters\r",
"return",
"createProjectedClustering",
"(",
")",
";",
"}"
]
| Performs an EM clustering on the provided data set
!! Only the variances are calculated and used for point assignments !
!!! the number k' of returned clusters might be smaller than k !!!
@param pointArray the data set as an array[n][d] of n points with d dimensions
@param k the number of requested partitions (!might return less)
@return a mapping int[n][k'] of the n given points to the k' resulting clusters | [
"Performs",
"an",
"EM",
"clustering",
"on",
"the",
"provided",
"data",
"set",
"!!",
"Only",
"the",
"variances",
"are",
"calculated",
"and",
"used",
"for",
"point",
"assignments",
"!",
"!!!",
"the",
"number",
"k",
"of",
"returned",
"clusters",
"might",
"be",
"smaller",
"than",
"k",
"!!!"
]
| train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/clusterers/outliers/AnyOut/util/EMProjectedClustering.java#L75-L98 |
xiancloud/xian | xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java | LeaderSelector.getParticipants | public Collection<Participant> getParticipants() throws Exception {
"""
<p>
Returns the set of current participants in the leader selection
</p>
<p>
<p>
<B>NOTE</B> - this method polls the ZK server. Therefore it can possibly
return a value that does not match {@link #hasLeadership()} as hasLeadership
uses a local field of the class.
</p>
@return participants
@throws Exception ZK errors, interruptions, etc.
"""
Collection<String> participantNodes = mutex.getParticipantNodes();
return getParticipants(client, participantNodes);
} | java | public Collection<Participant> getParticipants() throws Exception
{
Collection<String> participantNodes = mutex.getParticipantNodes();
return getParticipants(client, participantNodes);
} | [
"public",
"Collection",
"<",
"Participant",
">",
"getParticipants",
"(",
")",
"throws",
"Exception",
"{",
"Collection",
"<",
"String",
">",
"participantNodes",
"=",
"mutex",
".",
"getParticipantNodes",
"(",
")",
";",
"return",
"getParticipants",
"(",
"client",
",",
"participantNodes",
")",
";",
"}"
]
| <p>
Returns the set of current participants in the leader selection
</p>
<p>
<p>
<B>NOTE</B> - this method polls the ZK server. Therefore it can possibly
return a value that does not match {@link #hasLeadership()} as hasLeadership
uses a local field of the class.
</p>
@return participants
@throws Exception ZK errors, interruptions, etc. | [
"<p",
">",
"Returns",
"the",
"set",
"of",
"current",
"participants",
"in",
"the",
"leader",
"selection",
"<",
"/",
"p",
">",
"<p",
">",
"<p",
">",
"<B",
">",
"NOTE<",
"/",
"B",
">",
"-",
"this",
"method",
"polls",
"the",
"ZK",
"server",
".",
"Therefore",
"it",
"can",
"possibly",
"return",
"a",
"value",
"that",
"does",
"not",
"match",
"{",
"@link",
"#hasLeadership",
"()",
"}",
"as",
"hasLeadership",
"uses",
"a",
"local",
"field",
"of",
"the",
"class",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java#L292-L297 |
snowflakedb/snowflake-jdbc | src/main/java/net/snowflake/client/core/SFTrustManager.java | SFTrustManager.calculateTolerableVadility | private static long calculateTolerableVadility(Date thisUpdate, Date nextUpdate) {
"""
Calculates the tolerable validity time beyond the next update.
<p>
Sometimes CA's OCSP response update is delayed beyond the clock skew
as the update is not populated to all OCSP servers for certain period.
@param thisUpdate the last update
@param nextUpdate the next update
@return the tolerable validity beyond the next update.
"""
return maxLong((long) ((float) (nextUpdate.getTime() - thisUpdate.getTime()) *
TOLERABLE_VALIDITY_RANGE_RATIO), MIN_CACHE_WARMUP_TIME_IN_MILLISECONDS);
} | java | private static long calculateTolerableVadility(Date thisUpdate, Date nextUpdate)
{
return maxLong((long) ((float) (nextUpdate.getTime() - thisUpdate.getTime()) *
TOLERABLE_VALIDITY_RANGE_RATIO), MIN_CACHE_WARMUP_TIME_IN_MILLISECONDS);
} | [
"private",
"static",
"long",
"calculateTolerableVadility",
"(",
"Date",
"thisUpdate",
",",
"Date",
"nextUpdate",
")",
"{",
"return",
"maxLong",
"(",
"(",
"long",
")",
"(",
"(",
"float",
")",
"(",
"nextUpdate",
".",
"getTime",
"(",
")",
"-",
"thisUpdate",
".",
"getTime",
"(",
")",
")",
"*",
"TOLERABLE_VALIDITY_RANGE_RATIO",
")",
",",
"MIN_CACHE_WARMUP_TIME_IN_MILLISECONDS",
")",
";",
"}"
]
| Calculates the tolerable validity time beyond the next update.
<p>
Sometimes CA's OCSP response update is delayed beyond the clock skew
as the update is not populated to all OCSP servers for certain period.
@param thisUpdate the last update
@param nextUpdate the next update
@return the tolerable validity beyond the next update. | [
"Calculates",
"the",
"tolerable",
"validity",
"time",
"beyond",
"the",
"next",
"update",
".",
"<p",
">",
"Sometimes",
"CA",
"s",
"OCSP",
"response",
"update",
"is",
"delayed",
"beyond",
"the",
"clock",
"skew",
"as",
"the",
"update",
"is",
"not",
"populated",
"to",
"all",
"OCSP",
"servers",
"for",
"certain",
"period",
"."
]
| train | https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/core/SFTrustManager.java#L1578-L1582 |
jenkinsci/jenkins | core/src/main/java/jenkins/util/SystemProperties.java | SystemProperties.getString | public static String getString(String key, @CheckForNull String def) {
"""
Gets the system property indicated by the specified key, or a default value.
This behaves just like {@link System#getProperty(java.lang.String, java.lang.String)}, except
that it also consults the {@link ServletContext}'s "init" parameters.
@param key the name of the system property.
@param def a default value.
@return the string value of the system property,
or {@code null} if the property is missing and the default value is {@code null}.
@exception NullPointerException if {@code key} is {@code null}.
@exception IllegalArgumentException if {@code key} is empty.
"""
return getString(key, def, Level.CONFIG);
} | java | public static String getString(String key, @CheckForNull String def) {
return getString(key, def, Level.CONFIG);
} | [
"public",
"static",
"String",
"getString",
"(",
"String",
"key",
",",
"@",
"CheckForNull",
"String",
"def",
")",
"{",
"return",
"getString",
"(",
"key",
",",
"def",
",",
"Level",
".",
"CONFIG",
")",
";",
"}"
]
| Gets the system property indicated by the specified key, or a default value.
This behaves just like {@link System#getProperty(java.lang.String, java.lang.String)}, except
that it also consults the {@link ServletContext}'s "init" parameters.
@param key the name of the system property.
@param def a default value.
@return the string value of the system property,
or {@code null} if the property is missing and the default value is {@code null}.
@exception NullPointerException if {@code key} is {@code null}.
@exception IllegalArgumentException if {@code key} is empty. | [
"Gets",
"the",
"system",
"property",
"indicated",
"by",
"the",
"specified",
"key",
"or",
"a",
"default",
"value",
".",
"This",
"behaves",
"just",
"like",
"{",
"@link",
"System#getProperty",
"(",
"java",
".",
"lang",
".",
"String",
"java",
".",
"lang",
".",
"String",
")",
"}",
"except",
"that",
"it",
"also",
"consults",
"the",
"{",
"@link",
"ServletContext",
"}",
"s",
"init",
"parameters",
"."
]
| train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/util/SystemProperties.java#L220-L222 |
threerings/playn | android/src/playn/android/AndroidGraphics.java | AndroidGraphics.registerFont | public void registerFont(String path, String name, Font.Style style, String... ligatureGlyphs) {
"""
Registers a font with the graphics system.
@param path the path to the font resource (relative to the asset manager's path prefix).
@param name the name under which to register the font.
@param style the style variant of the specified name provided by the font file. For example
one might {@code registerFont("myfont.ttf", "My Font", Font.Style.PLAIN)} and
{@code registerFont("myfontb.ttf", "My Font", Font.Style.BOLD)} to provide both the plain and
bold variants of a particular font.
@param ligatureGlyphs any known text sequences that are converted into a single ligature
character in this font. This works around an Android bug where measuring text for wrapping
that contains character sequences that are converted into ligatures (e.g. "fi" or "ae")
incorrectly reports the number of characters "consumed" from the to-be-wrapped string.
"""
try {
registerFont(platform.assets().getTypeface(path), name, style, ligatureGlyphs);
} catch (Exception e) {
platform.reportError("Failed to load font [name=" + name + ", path=" + path + "]", e);
}
} | java | public void registerFont(String path, String name, Font.Style style, String... ligatureGlyphs) {
try {
registerFont(platform.assets().getTypeface(path), name, style, ligatureGlyphs);
} catch (Exception e) {
platform.reportError("Failed to load font [name=" + name + ", path=" + path + "]", e);
}
} | [
"public",
"void",
"registerFont",
"(",
"String",
"path",
",",
"String",
"name",
",",
"Font",
".",
"Style",
"style",
",",
"String",
"...",
"ligatureGlyphs",
")",
"{",
"try",
"{",
"registerFont",
"(",
"platform",
".",
"assets",
"(",
")",
".",
"getTypeface",
"(",
"path",
")",
",",
"name",
",",
"style",
",",
"ligatureGlyphs",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"platform",
".",
"reportError",
"(",
"\"Failed to load font [name=\"",
"+",
"name",
"+",
"\", path=\"",
"+",
"path",
"+",
"\"]\"",
",",
"e",
")",
";",
"}",
"}"
]
| Registers a font with the graphics system.
@param path the path to the font resource (relative to the asset manager's path prefix).
@param name the name under which to register the font.
@param style the style variant of the specified name provided by the font file. For example
one might {@code registerFont("myfont.ttf", "My Font", Font.Style.PLAIN)} and
{@code registerFont("myfontb.ttf", "My Font", Font.Style.BOLD)} to provide both the plain and
bold variants of a particular font.
@param ligatureGlyphs any known text sequences that are converted into a single ligature
character in this font. This works around an Android bug where measuring text for wrapping
that contains character sequences that are converted into ligatures (e.g. "fi" or "ae")
incorrectly reports the number of characters "consumed" from the to-be-wrapped string. | [
"Registers",
"a",
"font",
"with",
"the",
"graphics",
"system",
"."
]
| train | https://github.com/threerings/playn/blob/c266eeb39188dcada4b00992a0d1199759e03d42/android/src/playn/android/AndroidGraphics.java#L94-L100 |
aws/aws-sdk-java | aws-java-sdk-amplify/src/main/java/com/amazonaws/services/amplify/model/App.java | App.withEnvironmentVariables | public App withEnvironmentVariables(java.util.Map<String, String> environmentVariables) {
"""
<p>
Environment Variables for the Amplify App.
</p>
@param environmentVariables
Environment Variables for the Amplify App.
@return Returns a reference to this object so that method calls can be chained together.
"""
setEnvironmentVariables(environmentVariables);
return this;
} | java | public App withEnvironmentVariables(java.util.Map<String, String> environmentVariables) {
setEnvironmentVariables(environmentVariables);
return this;
} | [
"public",
"App",
"withEnvironmentVariables",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"environmentVariables",
")",
"{",
"setEnvironmentVariables",
"(",
"environmentVariables",
")",
";",
"return",
"this",
";",
"}"
]
| <p>
Environment Variables for the Amplify App.
</p>
@param environmentVariables
Environment Variables for the Amplify App.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Environment",
"Variables",
"for",
"the",
"Amplify",
"App",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-amplify/src/main/java/com/amazonaws/services/amplify/model/App.java#L614-L617 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java | GlobalUsersInner.getOperationBatchStatusAsync | public Observable<OperationBatchStatusResponseInner> getOperationBatchStatusAsync(String userName, List<String> urls) {
"""
Get batch operation status.
@param userName The name of the user.
@param urls The operation url of long running operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationBatchStatusResponseInner object
"""
return getOperationBatchStatusWithServiceResponseAsync(userName, urls).map(new Func1<ServiceResponse<OperationBatchStatusResponseInner>, OperationBatchStatusResponseInner>() {
@Override
public OperationBatchStatusResponseInner call(ServiceResponse<OperationBatchStatusResponseInner> response) {
return response.body();
}
});
} | java | public Observable<OperationBatchStatusResponseInner> getOperationBatchStatusAsync(String userName, List<String> urls) {
return getOperationBatchStatusWithServiceResponseAsync(userName, urls).map(new Func1<ServiceResponse<OperationBatchStatusResponseInner>, OperationBatchStatusResponseInner>() {
@Override
public OperationBatchStatusResponseInner call(ServiceResponse<OperationBatchStatusResponseInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationBatchStatusResponseInner",
">",
"getOperationBatchStatusAsync",
"(",
"String",
"userName",
",",
"List",
"<",
"String",
">",
"urls",
")",
"{",
"return",
"getOperationBatchStatusWithServiceResponseAsync",
"(",
"userName",
",",
"urls",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationBatchStatusResponseInner",
">",
",",
"OperationBatchStatusResponseInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationBatchStatusResponseInner",
"call",
"(",
"ServiceResponse",
"<",
"OperationBatchStatusResponseInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Get batch operation status.
@param userName The name of the user.
@param urls The operation url of long running operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationBatchStatusResponseInner object | [
"Get",
"batch",
"operation",
"status",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java#L321-L328 |
spring-projects/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/MultipartConfigFactory.java | MultipartConfigFactory.convertToBytes | private long convertToBytes(DataSize size, int defaultValue) {
"""
Return the amount of bytes from the specified {@link DataSize size}. If the size is
{@code null} or negative, returns {@code defaultValue}.
@param size the data size to handle
@param defaultValue the default value if the size is {@code null} or negative
@return the amount of bytes to use
"""
if (size != null && !size.isNegative()) {
return size.toBytes();
}
return defaultValue;
} | java | private long convertToBytes(DataSize size, int defaultValue) {
if (size != null && !size.isNegative()) {
return size.toBytes();
}
return defaultValue;
} | [
"private",
"long",
"convertToBytes",
"(",
"DataSize",
"size",
",",
"int",
"defaultValue",
")",
"{",
"if",
"(",
"size",
"!=",
"null",
"&&",
"!",
"size",
".",
"isNegative",
"(",
")",
")",
"{",
"return",
"size",
".",
"toBytes",
"(",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
]
| Return the amount of bytes from the specified {@link DataSize size}. If the size is
{@code null} or negative, returns {@code defaultValue}.
@param size the data size to handle
@param defaultValue the default value if the size is {@code null} or negative
@return the amount of bytes to use | [
"Return",
"the",
"amount",
"of",
"bytes",
"from",
"the",
"specified",
"{"
]
| train | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/MultipartConfigFactory.java#L92-L97 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/StaticSemanticSpace.java | StaticSemanticSpace.loadSparseBinary | private Matrix loadSparseBinary(InputStream fileStream) throws IOException {
"""
Loads the {@link SemanticSpace} from the binary formatted file, adding
its words to {@link #termToIndex} and returning the {@code Matrix}
containing the space's vectors.
@param sspaceFile a file in {@link SSpaceFormat#BINARY binary} format
"""
DataInputStream dis = new DataInputStream(fileStream);
int rows = dis.readInt();
int cols = dis.readInt();
// Create the sparse matrix as individual rows since we can fully
// allocate the indices values at once, rather than pay the log(n)
// overhead of sorting them
CompactSparseVector[] rowVectors = new CompactSparseVector[rows];
for (int row = 0; row < rows; ++row) {
String word = dis.readUTF();
termToIndex.put(word, row);
int nonZero = dis.readInt();
int[] indices = new int[nonZero];
double[] values = new double[nonZero];
for (int i = 0; i < nonZero; ++i) {
int nz = dis.readInt();
double val = dis.readDouble();
indices[i] = nz;
values[i] = val;
}
rowVectors[row] = new CompactSparseVector(indices, values, cols);
}
return Matrices.asSparseMatrix(Arrays.asList(rowVectors));
} | java | private Matrix loadSparseBinary(InputStream fileStream) throws IOException {
DataInputStream dis = new DataInputStream(fileStream);
int rows = dis.readInt();
int cols = dis.readInt();
// Create the sparse matrix as individual rows since we can fully
// allocate the indices values at once, rather than pay the log(n)
// overhead of sorting them
CompactSparseVector[] rowVectors = new CompactSparseVector[rows];
for (int row = 0; row < rows; ++row) {
String word = dis.readUTF();
termToIndex.put(word, row);
int nonZero = dis.readInt();
int[] indices = new int[nonZero];
double[] values = new double[nonZero];
for (int i = 0; i < nonZero; ++i) {
int nz = dis.readInt();
double val = dis.readDouble();
indices[i] = nz;
values[i] = val;
}
rowVectors[row] = new CompactSparseVector(indices, values, cols);
}
return Matrices.asSparseMatrix(Arrays.asList(rowVectors));
} | [
"private",
"Matrix",
"loadSparseBinary",
"(",
"InputStream",
"fileStream",
")",
"throws",
"IOException",
"{",
"DataInputStream",
"dis",
"=",
"new",
"DataInputStream",
"(",
"fileStream",
")",
";",
"int",
"rows",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"int",
"cols",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"// Create the sparse matrix as individual rows since we can fully",
"// allocate the indices values at once, rather than pay the log(n)",
"// overhead of sorting them",
"CompactSparseVector",
"[",
"]",
"rowVectors",
"=",
"new",
"CompactSparseVector",
"[",
"rows",
"]",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"rows",
";",
"++",
"row",
")",
"{",
"String",
"word",
"=",
"dis",
".",
"readUTF",
"(",
")",
";",
"termToIndex",
".",
"put",
"(",
"word",
",",
"row",
")",
";",
"int",
"nonZero",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"int",
"[",
"]",
"indices",
"=",
"new",
"int",
"[",
"nonZero",
"]",
";",
"double",
"[",
"]",
"values",
"=",
"new",
"double",
"[",
"nonZero",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nonZero",
";",
"++",
"i",
")",
"{",
"int",
"nz",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"double",
"val",
"=",
"dis",
".",
"readDouble",
"(",
")",
";",
"indices",
"[",
"i",
"]",
"=",
"nz",
";",
"values",
"[",
"i",
"]",
"=",
"val",
";",
"}",
"rowVectors",
"[",
"row",
"]",
"=",
"new",
"CompactSparseVector",
"(",
"indices",
",",
"values",
",",
"cols",
")",
";",
"}",
"return",
"Matrices",
".",
"asSparseMatrix",
"(",
"Arrays",
".",
"asList",
"(",
"rowVectors",
")",
")",
";",
"}"
]
| Loads the {@link SemanticSpace} from the binary formatted file, adding
its words to {@link #termToIndex} and returning the {@code Matrix}
containing the space's vectors.
@param sspaceFile a file in {@link SSpaceFormat#BINARY binary} format | [
"Loads",
"the",
"{",
"@link",
"SemanticSpace",
"}",
"from",
"the",
"binary",
"formatted",
"file",
"adding",
"its",
"words",
"to",
"{",
"@link",
"#termToIndex",
"}",
"and",
"returning",
"the",
"{",
"@code",
"Matrix",
"}",
"containing",
"the",
"space",
"s",
"vectors",
"."
]
| train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/StaticSemanticSpace.java#L322-L347 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.