repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 192 | func_name stringlengths 5 108 | whole_func_string stringlengths 75 3.91k | language stringclasses 1
value | func_code_string stringlengths 75 3.91k | func_code_tokens listlengths 21 629 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 647 | split_name stringclasses 1
value | func_code_url stringlengths 111 306 |
|---|---|---|---|---|---|---|---|---|---|---|
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java | SDBaseOps.replaceWhere | public SDVariable replaceWhere(SDVariable update, SDVariable from, Condition condition) {
return replaceWhere(null, update, from, condition);
} | java | public SDVariable replaceWhere(SDVariable update, SDVariable from, Condition condition) {
return replaceWhere(null, update, from, condition);
} | [
"public",
"SDVariable",
"replaceWhere",
"(",
"SDVariable",
"update",
",",
"SDVariable",
"from",
",",
"Condition",
"condition",
")",
"{",
"return",
"replaceWhere",
"(",
"null",
",",
"update",
",",
"from",
",",
"condition",
")",
";",
"}"
] | Element-wise replace where condition:<br>
out[i] = from[i] if condition(update[i]) is satisfied, or<br>
out[i] = update[i] if condition(update[i]) is NOT satisfied
@param update Source array
@param from Replacement values array (used conditionally). Must be same shape as 'update' array
@param condition Condition to check on update array elements
@return New array with values replaced where condition is satisfied | [
"Element",
"-",
"wise",
"replace",
"where",
"condition",
":",
"<br",
">",
"out",
"[",
"i",
"]",
"=",
"from",
"[",
"i",
"]",
"if",
"condition",
"(",
"update",
"[",
"i",
"]",
")",
"is",
"satisfied",
"or<br",
">",
"out",
"[",
"i",
"]",
"=",
"update"... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L1702-L1704 |
realexpayments/rxp-hpp-java | src/main/java/com/realexpayments/hpp/sdk/RealexHpp.java | RealexHpp.responseToJson | public String responseToJson(HppResponse hppResponse) {
LOGGER.info("Converting HppResponse to JSON.");
String json = null;
//generate hash
LOGGER.debug("Generating hash.");
hppResponse.hash(secret);
//encode
LOGGER.debug("Encoding object.");
try {
hppResponse = hppResponse.encode(ENCODING_CHARSET);
} catch (UnsupportedEncodingException ex) {
LOGGER.error("Exception encoding HPP response.", ex);
throw new RealexException("Exception encoding HPP response.", ex);
}
//convert to JSON
LOGGER.debug("Converting to JSON.");
json = JsonUtils.toJson(hppResponse);
return json;
} | java | public String responseToJson(HppResponse hppResponse) {
LOGGER.info("Converting HppResponse to JSON.");
String json = null;
//generate hash
LOGGER.debug("Generating hash.");
hppResponse.hash(secret);
//encode
LOGGER.debug("Encoding object.");
try {
hppResponse = hppResponse.encode(ENCODING_CHARSET);
} catch (UnsupportedEncodingException ex) {
LOGGER.error("Exception encoding HPP response.", ex);
throw new RealexException("Exception encoding HPP response.", ex);
}
//convert to JSON
LOGGER.debug("Converting to JSON.");
json = JsonUtils.toJson(hppResponse);
return json;
} | [
"public",
"String",
"responseToJson",
"(",
"HppResponse",
"hppResponse",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Converting HppResponse to JSON.\"",
")",
";",
"String",
"json",
"=",
"null",
";",
"//generate hash",
"LOGGER",
".",
"debug",
"(",
"\"Generating hash.\""... | <p>
Method produces JSON from <code>HppResponse</code> object.
Carries out the following actions:
<ul>
<li>Generates security hash</li>
<li>Base64 encodes inputs</li>
<li>Serialises response object to JSON</li>
</ul>
</p>
@param hppResponse
@return String | [
"<p",
">",
"Method",
"produces",
"JSON",
"from",
"<code",
">",
"HppResponse<",
"/",
"code",
">",
"object",
".",
"Carries",
"out",
"the",
"following",
"actions",
":",
"<ul",
">",
"<li",
">",
"Generates",
"security",
"hash<",
"/",
"li",
">",
"<li",
">",
... | train | https://github.com/realexpayments/rxp-hpp-java/blob/29cc5df036af09a6d8ea16ccd7e02e856f72620f/src/main/java/com/realexpayments/hpp/sdk/RealexHpp.java#L204-L228 |
zaproxy/zaproxy | src/org/zaproxy/zap/spider/SpiderController.java | SpiderController.addSeed | protected void addSeed(URI uri, String method) {
// Check if the uri was processed already
String visitedURI;
try {
visitedURI = URLCanonicalizer.buildCleanedParametersURIRepresentation(uri, spider.getSpiderParam()
.getHandleParameters(), spider.getSpiderParam().isHandleODataParametersVisited());
} catch (URIException e) {
return;
}
synchronized (visitedGet) {
if (visitedGet.contains(visitedURI)) {
log.debug("URI already visited: " + visitedURI);
return;
} else {
visitedGet.add(visitedURI);
}
}
// Create and submit the new task
SpiderTask task = new SpiderTask(spider, null, uri, 0, method);
spider.submitTask(task);
// Add the uri to the found list
spider.notifyListenersFoundURI(uri.toString(), method, FetchStatus.SEED);
} | java | protected void addSeed(URI uri, String method) {
// Check if the uri was processed already
String visitedURI;
try {
visitedURI = URLCanonicalizer.buildCleanedParametersURIRepresentation(uri, spider.getSpiderParam()
.getHandleParameters(), spider.getSpiderParam().isHandleODataParametersVisited());
} catch (URIException e) {
return;
}
synchronized (visitedGet) {
if (visitedGet.contains(visitedURI)) {
log.debug("URI already visited: " + visitedURI);
return;
} else {
visitedGet.add(visitedURI);
}
}
// Create and submit the new task
SpiderTask task = new SpiderTask(spider, null, uri, 0, method);
spider.submitTask(task);
// Add the uri to the found list
spider.notifyListenersFoundURI(uri.toString(), method, FetchStatus.SEED);
} | [
"protected",
"void",
"addSeed",
"(",
"URI",
"uri",
",",
"String",
"method",
")",
"{",
"// Check if the uri was processed already",
"String",
"visitedURI",
";",
"try",
"{",
"visitedURI",
"=",
"URLCanonicalizer",
".",
"buildCleanedParametersURIRepresentation",
"(",
"uri",... | Adds a new seed, if it wasn't already processed.
@param uri the uri
@param method the http method used for fetching the resource | [
"Adds",
"a",
"new",
"seed",
"if",
"it",
"wasn",
"t",
"already",
"processed",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/spider/SpiderController.java#L163-L185 |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/client/Iobeam.java | Iobeam.addDataMapToSeries | @Deprecated
public boolean addDataMapToSeries(String[] seriesNames, DataPoint[] points) {
if (seriesNames == null || points == null || points.length != seriesNames.length) {
return false;
}
synchronized (dataStoreLock) {
for (int i = 0; i < seriesNames.length; i++) {
_addDataWithoutLock(seriesNames[i], points[i]);
}
}
return true;
} | java | @Deprecated
public boolean addDataMapToSeries(String[] seriesNames, DataPoint[] points) {
if (seriesNames == null || points == null || points.length != seriesNames.length) {
return false;
}
synchronized (dataStoreLock) {
for (int i = 0; i < seriesNames.length; i++) {
_addDataWithoutLock(seriesNames[i], points[i]);
}
}
return true;
} | [
"@",
"Deprecated",
"public",
"boolean",
"addDataMapToSeries",
"(",
"String",
"[",
"]",
"seriesNames",
",",
"DataPoint",
"[",
"]",
"points",
")",
"{",
"if",
"(",
"seriesNames",
"==",
"null",
"||",
"points",
"==",
"null",
"||",
"points",
".",
"length",
"!=",... | Adds a list of data points to a list of series in the data store. This is essentially a 'zip'
operation on the points and series names, where the first point is put in the first series,
the second point in the second series, etc. Both lists MUST be the same size.
@param points List of DataPoints to be added
@param seriesNames List of corresponding series for the datapoints.
@return True if the points are added; false if the lists are not the same size, or adding
fails.
@deprecated Use {@link DataStore} and {@link #createDataStore(Collection)} instead. | [
"Adds",
"a",
"list",
"of",
"data",
"points",
"to",
"a",
"list",
"of",
"series",
"in",
"the",
"data",
"store",
".",
"This",
"is",
"essentially",
"a",
"zip",
"operation",
"on",
"the",
"points",
"and",
"series",
"names",
"where",
"the",
"first",
"point",
... | train | https://github.com/iobeam/iobeam-client-java/blob/06e7aeb2a313503392358a3671de7d28628d0e33/src/main/java/com/iobeam/api/client/Iobeam.java#L771-L783 |
dropwizard/metrics | metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java | HealthCheckRegistry.runHealthChecks | public SortedMap<String, HealthCheck.Result> runHealthChecks(ExecutorService executor) {
return runHealthChecks(executor, HealthCheckFilter.ALL);
} | java | public SortedMap<String, HealthCheck.Result> runHealthChecks(ExecutorService executor) {
return runHealthChecks(executor, HealthCheckFilter.ALL);
} | [
"public",
"SortedMap",
"<",
"String",
",",
"HealthCheck",
".",
"Result",
">",
"runHealthChecks",
"(",
"ExecutorService",
"executor",
")",
"{",
"return",
"runHealthChecks",
"(",
"executor",
",",
"HealthCheckFilter",
".",
"ALL",
")",
";",
"}"
] | Runs the registered health checks in parallel and returns a map of the results.
@param executor object to launch and track health checks progress
@return a map of the health check results | [
"Runs",
"the",
"registered",
"health",
"checks",
"in",
"parallel",
"and",
"returns",
"a",
"map",
"of",
"the",
"results",
"."
] | train | https://github.com/dropwizard/metrics/blob/3c6105a0b9b4416c59e16b6b841b123052d6f57d/metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java#L197-L199 |
banq/jdonframework | JdonAccessory/jdon-struts1x/src/main/java/com/jdon/model/ModelHandler.java | ModelHandler.findModelIF | public Object findModelIF(Object keyValue, HttpServletRequest request) throws Exception {
return findModelByKey((String) keyValue, request); // for old version
} | java | public Object findModelIF(Object keyValue, HttpServletRequest request) throws Exception {
return findModelByKey((String) keyValue, request); // for old version
} | [
"public",
"Object",
"findModelIF",
"(",
"Object",
"keyValue",
",",
"HttpServletRequest",
"request",
")",
"throws",
"Exception",
"{",
"return",
"findModelByKey",
"(",
"(",
"String",
")",
"keyValue",
",",
"request",
")",
";",
"// for old version\r",
"}"
] | obtain a existed Model instance by his primtive key.
@param keyValue
primtive key
@param request
@return Model
@throws java.lang.Exception | [
"obtain",
"a",
"existed",
"Model",
"instance",
"by",
"his",
"primtive",
"key",
"."
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-struts1x/src/main/java/com/jdon/model/ModelHandler.java#L126-L128 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/cpnl/CpnlElFunctions.java | CpnlElFunctions.externalUrl | public static String externalUrl(SlingHttpServletRequest request, String path) {
return LinkUtil.getAbsoluteUrl(request, LinkUtil.getUrl(request, path));
} | java | public static String externalUrl(SlingHttpServletRequest request, String path) {
return LinkUtil.getAbsoluteUrl(request, LinkUtil.getUrl(request, path));
} | [
"public",
"static",
"String",
"externalUrl",
"(",
"SlingHttpServletRequest",
"request",
",",
"String",
"path",
")",
"{",
"return",
"LinkUtil",
".",
"getAbsoluteUrl",
"(",
"request",
",",
"LinkUtil",
".",
"getUrl",
"(",
"request",
",",
"path",
")",
")",
";",
... | Builds an external (full qualified) URL for a repository path using the LinkUtil.getURL() method.
@param request the current request (domain host hint)
@param path the repository path
@return the URL built in the context of the requested domain host | [
"Builds",
"an",
"external",
"(",
"full",
"qualified",
")",
"URL",
"for",
"a",
"repository",
"path",
"using",
"the",
"LinkUtil",
".",
"getURL",
"()",
"method",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/cpnl/CpnlElFunctions.java#L209-L211 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/view/ViewUtils.java | ViewUtils.sipToPixel | public static float sipToPixel(Resources resources, float sip) {
float density = resources.getDisplayMetrics().scaledDensity;
return sip * density;
} | java | public static float sipToPixel(Resources resources, float sip) {
float density = resources.getDisplayMetrics().scaledDensity;
return sip * density;
} | [
"public",
"static",
"float",
"sipToPixel",
"(",
"Resources",
"resources",
",",
"float",
"sip",
")",
"{",
"float",
"density",
"=",
"resources",
".",
"getDisplayMetrics",
"(",
")",
".",
"scaledDensity",
";",
"return",
"sip",
"*",
"density",
";",
"}"
] | Convert the sip to pixels, based on density scale.
@param resources application resources.
@param sip to be converted value.
@return converted value(px) | [
"Convert",
"the",
"sip",
"to",
"pixels",
"based",
"on",
"density",
"scale",
"."
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/view/ViewUtils.java#L97-L100 |
JoeKerouac/utils | src/main/java/com/joe/utils/secure/impl/AsymmetricCipher.java | AsymmetricCipher.buildInstance | public static CipherUtil buildInstance(String privateKey, String publicKey) {
return buildInstance(privateKey.getBytes(), publicKey.getBytes());
} | java | public static CipherUtil buildInstance(String privateKey, String publicKey) {
return buildInstance(privateKey.getBytes(), publicKey.getBytes());
} | [
"public",
"static",
"CipherUtil",
"buildInstance",
"(",
"String",
"privateKey",
",",
"String",
"publicKey",
")",
"{",
"return",
"buildInstance",
"(",
"privateKey",
".",
"getBytes",
"(",
")",
",",
"publicKey",
".",
"getBytes",
"(",
")",
")",
";",
"}"
] | 非对称加密构造器
@param privateKey PKCS8格式的私钥(BASE64 encode过的)
@param publicKey X509格式的公钥(BASE64 encode过的)
@return AsymmetricCipher | [
"非对称加密构造器"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/secure/impl/AsymmetricCipher.java#L43-L45 |
stratosphere/stratosphere | stratosphere-runtime/src/main/java/eu/stratosphere/runtime/io/network/bufferprovider/LocalBufferPool.java | LocalBufferPool.recycleBuffer | private void recycleBuffer(MemorySegment buffer) {
synchronized (this.buffers) {
if (this.isDestroyed) {
this.globalBufferPool.returnBuffer(buffer);
this.numRequestedBuffers--;
} else {
// if the number of designated buffers changed in the meantime, make sure
// to return the buffer to the global buffer pool
if (this.numRequestedBuffers > this.numDesignatedBuffers) {
this.globalBufferPool.returnBuffer(buffer);
this.numRequestedBuffers--;
} else if (!this.listeners.isEmpty()) {
Buffer availableBuffer = new Buffer(buffer, buffer.size(), this.recycler);
try {
this.listeners.poll().bufferAvailable(availableBuffer);
} catch (Exception e) {
this.buffers.add(buffer);
this.buffers.notify();
}
} else {
this.buffers.add(buffer);
this.buffers.notify();
}
}
}
} | java | private void recycleBuffer(MemorySegment buffer) {
synchronized (this.buffers) {
if (this.isDestroyed) {
this.globalBufferPool.returnBuffer(buffer);
this.numRequestedBuffers--;
} else {
// if the number of designated buffers changed in the meantime, make sure
// to return the buffer to the global buffer pool
if (this.numRequestedBuffers > this.numDesignatedBuffers) {
this.globalBufferPool.returnBuffer(buffer);
this.numRequestedBuffers--;
} else if (!this.listeners.isEmpty()) {
Buffer availableBuffer = new Buffer(buffer, buffer.size(), this.recycler);
try {
this.listeners.poll().bufferAvailable(availableBuffer);
} catch (Exception e) {
this.buffers.add(buffer);
this.buffers.notify();
}
} else {
this.buffers.add(buffer);
this.buffers.notify();
}
}
}
} | [
"private",
"void",
"recycleBuffer",
"(",
"MemorySegment",
"buffer",
")",
"{",
"synchronized",
"(",
"this",
".",
"buffers",
")",
"{",
"if",
"(",
"this",
".",
"isDestroyed",
")",
"{",
"this",
".",
"globalBufferPool",
".",
"returnBuffer",
"(",
"buffer",
")",
... | Returns a buffer to the buffer pool and notifies listeners about the availability of a new buffer.
@param buffer buffer to return to the buffer pool | [
"Returns",
"a",
"buffer",
"to",
"the",
"buffer",
"pool",
"and",
"notifies",
"listeners",
"about",
"the",
"availability",
"of",
"a",
"new",
"buffer",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/runtime/io/network/bufferprovider/LocalBufferPool.java#L291-L318 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java | ParseUtils.nextElement | public static Element nextElement(XMLExtendedStreamReader reader, Namespace expectedNamespace) throws XMLStreamException {
Element element = nextElement(reader);
if (element == null) {
return null;
} else if (element != Element.UNKNOWN
&& expectedNamespace.equals(Namespace.forUri(reader.getNamespaceURI()))) {
return element;
}
throw unexpectedElement(reader);
} | java | public static Element nextElement(XMLExtendedStreamReader reader, Namespace expectedNamespace) throws XMLStreamException {
Element element = nextElement(reader);
if (element == null) {
return null;
} else if (element != Element.UNKNOWN
&& expectedNamespace.equals(Namespace.forUri(reader.getNamespaceURI()))) {
return element;
}
throw unexpectedElement(reader);
} | [
"public",
"static",
"Element",
"nextElement",
"(",
"XMLExtendedStreamReader",
"reader",
",",
"Namespace",
"expectedNamespace",
")",
"throws",
"XMLStreamException",
"{",
"Element",
"element",
"=",
"nextElement",
"(",
"reader",
")",
";",
"if",
"(",
"element",
"==",
... | A variation of nextElement that verifies the nextElement is not in a different namespace.
@param reader the XmlExtendedReader to read from.
@param expectedNamespace the namespace expected.
@return the element or null if the end is reached
@throws XMLStreamException if the namespace is wrong or there is a problem accessing the reader | [
"A",
"variation",
"of",
"nextElement",
"that",
"verifies",
"the",
"nextElement",
"is",
"not",
"in",
"a",
"different",
"namespace",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java#L77-L88 |
alkacon/opencms-core | src/org/opencms/ade/contenteditor/CmsContentTypeVisitor.java | CmsContentTypeVisitor.visitTypes | public void visitTypes(CmsXmlContentDefinition xmlContentDefinition, Locale messageLocale) {
m_rootContentDefinition = xmlContentDefinition;
m_contentHandler = xmlContentDefinition.getContentHandler();
CmsMessages messages = null;
m_messages = new CmsMultiMessages(messageLocale);
m_messages.setFallbackHandler(xmlContentDefinition.getContentHandler().getMessageKeyHandler());
try {
messages = OpenCms.getWorkplaceManager().getMessages(messageLocale);
if (messages != null) {
m_messages.addMessages(messages);
}
messages = m_contentHandler.getMessages(messageLocale);
if (messages != null) {
m_messages.addMessages(messages);
}
} catch (Exception e) {
// may happen during start up
LOG.debug(e.getMessage(), e);
}
// generate a new multi messages object and add the messages from the workplace
m_attributeConfigurations = new HashMap<String, CmsAttributeConfiguration>();
m_widgetConfigurations = new HashMap<String, CmsExternalWidgetConfiguration>();
m_registeredTypes = new HashMap<String, CmsType>();
m_localeSynchronizations = new ArrayList<String>();
m_dynamicallyLoaded = new ArrayList<String>();
m_tabInfos = collectTabInfos(xmlContentDefinition);
readTypes(xmlContentDefinition, "");
} | java | public void visitTypes(CmsXmlContentDefinition xmlContentDefinition, Locale messageLocale) {
m_rootContentDefinition = xmlContentDefinition;
m_contentHandler = xmlContentDefinition.getContentHandler();
CmsMessages messages = null;
m_messages = new CmsMultiMessages(messageLocale);
m_messages.setFallbackHandler(xmlContentDefinition.getContentHandler().getMessageKeyHandler());
try {
messages = OpenCms.getWorkplaceManager().getMessages(messageLocale);
if (messages != null) {
m_messages.addMessages(messages);
}
messages = m_contentHandler.getMessages(messageLocale);
if (messages != null) {
m_messages.addMessages(messages);
}
} catch (Exception e) {
// may happen during start up
LOG.debug(e.getMessage(), e);
}
// generate a new multi messages object and add the messages from the workplace
m_attributeConfigurations = new HashMap<String, CmsAttributeConfiguration>();
m_widgetConfigurations = new HashMap<String, CmsExternalWidgetConfiguration>();
m_registeredTypes = new HashMap<String, CmsType>();
m_localeSynchronizations = new ArrayList<String>();
m_dynamicallyLoaded = new ArrayList<String>();
m_tabInfos = collectTabInfos(xmlContentDefinition);
readTypes(xmlContentDefinition, "");
} | [
"public",
"void",
"visitTypes",
"(",
"CmsXmlContentDefinition",
"xmlContentDefinition",
",",
"Locale",
"messageLocale",
")",
"{",
"m_rootContentDefinition",
"=",
"xmlContentDefinition",
";",
"m_contentHandler",
"=",
"xmlContentDefinition",
".",
"getContentHandler",
"(",
")"... | Visits all types within the XML content definition.<p>
@param xmlContentDefinition the content definition
@param messageLocale the locale | [
"Visits",
"all",
"types",
"within",
"the",
"XML",
"content",
"definition",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/contenteditor/CmsContentTypeVisitor.java#L402-L432 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java | HtmlLinkRendererBase.findNestingForm | protected FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
{
return _ComponentUtils.findNestingForm(uiComponent, facesContext);
} | java | protected FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
{
return _ComponentUtils.findNestingForm(uiComponent, facesContext);
} | [
"protected",
"FormInfo",
"findNestingForm",
"(",
"UIComponent",
"uiComponent",
",",
"FacesContext",
"facesContext",
")",
"{",
"return",
"_ComponentUtils",
".",
"findNestingForm",
"(",
"uiComponent",
",",
"facesContext",
")",
";",
"}"
] | find nesting form<br />
need to be overrideable to deal with dummyForm stuff in tomahawk. | [
"find",
"nesting",
"form<br",
"/",
">",
"need",
"to",
"be",
"overrideable",
"to",
"deal",
"with",
"dummyForm",
"stuff",
"in",
"tomahawk",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java#L728-L731 |
Netflix/conductor | core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java | WorkflowExecutor.retry | public void retry(String workflowId) {
Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, true);
if (!workflow.getStatus().isTerminal()) {
throw new ApplicationException(CONFLICT, "Workflow is still running. status=" + workflow.getStatus());
}
if (workflow.getTasks().isEmpty()) {
throw new ApplicationException(CONFLICT, "Workflow has not started yet");
}
// Get all FAILED or CANCELED tasks that are not COMPLETED (or reach other terminal states) on further executions.
// // Eg: for Seq of tasks task1.CANCELED, task1.COMPLETED, task1 shouldn't be retried.
// Throw an exception if there are no FAILED tasks.
// Handle JOIN task CANCELED status as special case.
Map<String, Task> retriableMap = new HashMap<>();
for (Task task : workflow.getTasks()) {
switch (task.getStatus()) {
case FAILED:
retriableMap.put(task.getReferenceTaskName(), task);
break;
case CANCELED:
if (task.getTaskType().equalsIgnoreCase(TaskType.JOIN.toString())) {
task.setStatus(IN_PROGRESS);
// Task doesn't have to updated yet. Will be updated along with other Workflow tasks downstream.
} else {
retriableMap.put(task.getReferenceTaskName(), task);
}
break;
default:
retriableMap.remove(task.getReferenceTaskName());
break;
}
}
if (retriableMap.values().size() == 0) {
throw new ApplicationException(CONFLICT,
"There are no retriable tasks! Use restart if you want to attempt entire workflow execution again.");
}
// Update Workflow with new status.
// This should load Workflow from archive, if archived.
workflow.setStatus(WorkflowStatus.RUNNING);
executionDAOFacade.updateWorkflow(workflow);
// taskToBeRescheduled would set task `retried` to true, and hence it's important to updateTasks after obtaining task copy from taskToBeRescheduled.
List<Task> retriableTasks = retriableMap.values().stream()
.sorted(Comparator.comparingInt(Task::getSeq))
.map(task -> taskToBeRescheduled(task))
.collect(Collectors.toList());
dedupAndAddTasks(workflow, retriableTasks);
// Note: updateTasks before updateWorkflow might fail when Workflow is archived and doesn't exist in primary store.
executionDAOFacade.updateTasks(workflow.getTasks());
scheduleTask(workflow, retriableTasks);
decide(workflowId);
} | java | public void retry(String workflowId) {
Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, true);
if (!workflow.getStatus().isTerminal()) {
throw new ApplicationException(CONFLICT, "Workflow is still running. status=" + workflow.getStatus());
}
if (workflow.getTasks().isEmpty()) {
throw new ApplicationException(CONFLICT, "Workflow has not started yet");
}
// Get all FAILED or CANCELED tasks that are not COMPLETED (or reach other terminal states) on further executions.
// // Eg: for Seq of tasks task1.CANCELED, task1.COMPLETED, task1 shouldn't be retried.
// Throw an exception if there are no FAILED tasks.
// Handle JOIN task CANCELED status as special case.
Map<String, Task> retriableMap = new HashMap<>();
for (Task task : workflow.getTasks()) {
switch (task.getStatus()) {
case FAILED:
retriableMap.put(task.getReferenceTaskName(), task);
break;
case CANCELED:
if (task.getTaskType().equalsIgnoreCase(TaskType.JOIN.toString())) {
task.setStatus(IN_PROGRESS);
// Task doesn't have to updated yet. Will be updated along with other Workflow tasks downstream.
} else {
retriableMap.put(task.getReferenceTaskName(), task);
}
break;
default:
retriableMap.remove(task.getReferenceTaskName());
break;
}
}
if (retriableMap.values().size() == 0) {
throw new ApplicationException(CONFLICT,
"There are no retriable tasks! Use restart if you want to attempt entire workflow execution again.");
}
// Update Workflow with new status.
// This should load Workflow from archive, if archived.
workflow.setStatus(WorkflowStatus.RUNNING);
executionDAOFacade.updateWorkflow(workflow);
// taskToBeRescheduled would set task `retried` to true, and hence it's important to updateTasks after obtaining task copy from taskToBeRescheduled.
List<Task> retriableTasks = retriableMap.values().stream()
.sorted(Comparator.comparingInt(Task::getSeq))
.map(task -> taskToBeRescheduled(task))
.collect(Collectors.toList());
dedupAndAddTasks(workflow, retriableTasks);
// Note: updateTasks before updateWorkflow might fail when Workflow is archived and doesn't exist in primary store.
executionDAOFacade.updateTasks(workflow.getTasks());
scheduleTask(workflow, retriableTasks);
decide(workflowId);
} | [
"public",
"void",
"retry",
"(",
"String",
"workflowId",
")",
"{",
"Workflow",
"workflow",
"=",
"executionDAOFacade",
".",
"getWorkflowById",
"(",
"workflowId",
",",
"true",
")",
";",
"if",
"(",
"!",
"workflow",
".",
"getStatus",
"(",
")",
".",
"isTerminal",
... | Gets the last instance of each failed task and reschedule each
Gets all cancelled tasks and schedule all of them except JOIN (join should change status to INPROGRESS)
Switch workflow back to RUNNING status and call decider.
@param workflowId the id of the workflow to be retried | [
"Gets",
"the",
"last",
"instance",
"of",
"each",
"failed",
"task",
"and",
"reschedule",
"each",
"Gets",
"all",
"cancelled",
"tasks",
"and",
"schedule",
"all",
"of",
"them",
"except",
"JOIN",
"(",
"join",
"should",
"change",
"status",
"to",
"INPROGRESS",
")",... | train | https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java#L415-L470 |
hypfvieh/java-utils | src/main/java/com/github/hypfvieh/util/StringUtil.java | StringUtil.startsWithAny | public static boolean startsWithAny(boolean _ignoreCase, String _str, String... _args) {
if (_str == null || _args == null || _args.length == 0) {
return false;
}
String heystack = _str;
if (_ignoreCase) {
heystack = _str.toLowerCase();
}
for (String s : _args) {
String needle = _ignoreCase ? s.toLowerCase() : s;
if (heystack.startsWith(needle)) {
return true;
}
}
return false;
} | java | public static boolean startsWithAny(boolean _ignoreCase, String _str, String... _args) {
if (_str == null || _args == null || _args.length == 0) {
return false;
}
String heystack = _str;
if (_ignoreCase) {
heystack = _str.toLowerCase();
}
for (String s : _args) {
String needle = _ignoreCase ? s.toLowerCase() : s;
if (heystack.startsWith(needle)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"startsWithAny",
"(",
"boolean",
"_ignoreCase",
",",
"String",
"_str",
",",
"String",
"...",
"_args",
")",
"{",
"if",
"(",
"_str",
"==",
"null",
"||",
"_args",
"==",
"null",
"||",
"_args",
".",
"length",
"==",
"0",
")",
"... | Checks if given string in _str starts with any of the given strings in _args.
@param _ignoreCase true to ignore case, false to be case sensitive
@param _str string to check
@param _args patterns to find
@return true if given string in _str starts with any of the given strings in _args, false if not or _str/_args is null | [
"Checks",
"if",
"given",
"string",
"in",
"_str",
"starts",
"with",
"any",
"of",
"the",
"given",
"strings",
"in",
"_args",
"."
] | train | https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L547-L564 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/UserAPI.java | UserAPI.userInfoBatchget | public static UserInfoList userInfoBatchget(String access_token,String lang,List<String> openids){
return userInfoBatchget(access_token, lang, openids,0);
} | java | public static UserInfoList userInfoBatchget(String access_token,String lang,List<String> openids){
return userInfoBatchget(access_token, lang, openids,0);
} | [
"public",
"static",
"UserInfoList",
"userInfoBatchget",
"(",
"String",
"access_token",
",",
"String",
"lang",
",",
"List",
"<",
"String",
">",
"openids",
")",
"{",
"return",
"userInfoBatchget",
"(",
"access_token",
",",
"lang",
",",
"openids",
",",
"0",
")",
... | 批量获取用户基本信息
@param access_token access_token
@param lang zh-CN
@param openids 最多支持一次拉取100条
@return UserInfoList | [
"批量获取用户基本信息"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/UserAPI.java#L133-L135 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.deserializeFromString | public static Writable deserializeFromString(Class<? extends Writable> writableClass, String serializedWritableStr)
throws IOException {
return deserializeFromString(writableClass, serializedWritableStr, new Configuration());
} | java | public static Writable deserializeFromString(Class<? extends Writable> writableClass, String serializedWritableStr)
throws IOException {
return deserializeFromString(writableClass, serializedWritableStr, new Configuration());
} | [
"public",
"static",
"Writable",
"deserializeFromString",
"(",
"Class",
"<",
"?",
"extends",
"Writable",
">",
"writableClass",
",",
"String",
"serializedWritableStr",
")",
"throws",
"IOException",
"{",
"return",
"deserializeFromString",
"(",
"writableClass",
",",
"seri... | Deserialize a {@link Writable} object from a string.
@param writableClass the {@link Writable} implementation class
@param serializedWritableStr the string containing a serialized {@link Writable} object
@return a {@link Writable} deserialized from the string
@throws IOException if there's something wrong with the deserialization | [
"Deserialize",
"a",
"{",
"@link",
"Writable",
"}",
"object",
"from",
"a",
"string",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L806-L809 |
kuujo/vertigo | core/src/main/java/net/kuujo/vertigo/Vertigo.java | Vertigo.deployNetwork | public Vertigo deployNetwork(String name) {
return deployNetwork(name, (Handler<AsyncResult<ActiveNetwork>>) null);
} | java | public Vertigo deployNetwork(String name) {
return deployNetwork(name, (Handler<AsyncResult<ActiveNetwork>>) null);
} | [
"public",
"Vertigo",
"deployNetwork",
"(",
"String",
"name",
")",
"{",
"return",
"deployNetwork",
"(",
"name",
",",
"(",
"Handler",
"<",
"AsyncResult",
"<",
"ActiveNetwork",
">",
">",
")",
"null",
")",
";",
"}"
] | Deploys a bare network to an anonymous local-only cluster.<p>
The network will be deployed with no components and no connections. You
can add components and connections to the network with an {@link ActiveNetwork}
instance.
@param name The name of the network to deploy.
@return The Vertigo instance. | [
"Deploys",
"a",
"bare",
"network",
"to",
"an",
"anonymous",
"local",
"-",
"only",
"cluster",
".",
"<p",
">"
] | train | https://github.com/kuujo/vertigo/blob/c5869dbc5fff89eb5262e83f7a81719b01a5ba6f/core/src/main/java/net/kuujo/vertigo/Vertigo.java#L315-L317 |
apache/flink | flink-core/src/main/java/org/apache/flink/util/Preconditions.java | Preconditions.checkArgument | public static void checkArgument(boolean condition,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
if (!condition) {
throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
}
} | java | public static void checkArgument(boolean condition,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
if (!condition) {
throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
}
} | [
"public",
"static",
"void",
"checkArgument",
"(",
"boolean",
"condition",
",",
"@",
"Nullable",
"String",
"errorMessageTemplate",
",",
"@",
"Nullable",
"Object",
"...",
"errorMessageArgs",
")",
"{",
"if",
"(",
"!",
"condition",
")",
"{",
"throw",
"new",
"Illeg... | Checks the given boolean condition, and throws an {@code IllegalArgumentException} if
the condition is not met (evaluates to {@code false}).
@param condition The condition to check
@param errorMessageTemplate The message template for the {@code IllegalArgumentException}
that is thrown if the check fails. The template substitutes its
{@code %s} placeholders with the error message arguments.
@param errorMessageArgs The arguments for the error message, to be inserted into the
message template for the {@code %s} placeholders.
@throws IllegalArgumentException Thrown, if the condition is violated. | [
"Checks",
"the",
"given",
"boolean",
"condition",
"and",
"throws",
"an",
"{",
"@code",
"IllegalArgumentException",
"}",
"if",
"the",
"condition",
"is",
"not",
"met",
"(",
"evaluates",
"to",
"{",
"@code",
"false",
"}",
")",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/Preconditions.java#L156-L163 |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/lastsplits/CircularList.java | CircularList.incrementIndex | private int incrementIndex(int index, int maxIndex) {
int newIndex = index + 1;
if (newIndex >= elements.length) {
newIndex = maxIndex;
}
return newIndex;
} | java | private int incrementIndex(int index, int maxIndex) {
int newIndex = index + 1;
if (newIndex >= elements.length) {
newIndex = maxIndex;
}
return newIndex;
} | [
"private",
"int",
"incrementIndex",
"(",
"int",
"index",
",",
"int",
"maxIndex",
")",
"{",
"int",
"newIndex",
"=",
"index",
"+",
"1",
";",
"if",
"(",
"newIndex",
">=",
"elements",
".",
"length",
")",
"{",
"newIndex",
"=",
"maxIndex",
";",
"}",
"return"... | Increment an index
@param index Input index
@param maxIndex Assigned value when capacity is reached
@return Output index | [
"Increment",
"an",
"index"
] | train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/lastsplits/CircularList.java#L98-L104 |
mguymon/naether | src/main/java/com/tobedevoured/naether/maven/Project.java | Project.writePom | public void writePom(File file) throws ProjectException {
log.debug("Writing pom: {}", file.getPath());
Project copy = this;
copy.removeProperty( "project.basedir" );
Writer writer;
try {
writer = new BufferedWriter(new FileWriter(file));
} catch (IOException e) {
throw new ProjectException(e);
}
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(writer, copy.mavenModel);
} catch (IOException e) {
throw new ProjectException("Failed to write pom", e);
}
} | java | public void writePom(File file) throws ProjectException {
log.debug("Writing pom: {}", file.getPath());
Project copy = this;
copy.removeProperty( "project.basedir" );
Writer writer;
try {
writer = new BufferedWriter(new FileWriter(file));
} catch (IOException e) {
throw new ProjectException(e);
}
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(writer, copy.mavenModel);
} catch (IOException e) {
throw new ProjectException("Failed to write pom", e);
}
} | [
"public",
"void",
"writePom",
"(",
"File",
"file",
")",
"throws",
"ProjectException",
"{",
"log",
".",
"debug",
"(",
"\"Writing pom: {}\"",
",",
"file",
".",
"getPath",
"(",
")",
")",
";",
"Project",
"copy",
"=",
"this",
";",
"copy",
".",
"removeProperty",... | Write pom to {@link File}
@param file {@link File}
@throws ProjectException exception | [
"Write",
"pom",
"to",
"{",
"@link",
"File",
"}"
] | train | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/java/com/tobedevoured/naether/maven/Project.java#L516-L535 |
graknlabs/grakn | server/src/server/exception/TransactionException.java | TransactionException.loopCreated | public static TransactionException loopCreated(SchemaConcept type, SchemaConcept superElement) {
return create(ErrorMessage.SUPER_LOOP_DETECTED.getMessage(type.label(), superElement.label()));
} | java | public static TransactionException loopCreated(SchemaConcept type, SchemaConcept superElement) {
return create(ErrorMessage.SUPER_LOOP_DETECTED.getMessage(type.label(), superElement.label()));
} | [
"public",
"static",
"TransactionException",
"loopCreated",
"(",
"SchemaConcept",
"type",
",",
"SchemaConcept",
"superElement",
")",
"{",
"return",
"create",
"(",
"ErrorMessage",
".",
"SUPER_LOOP_DETECTED",
".",
"getMessage",
"(",
"type",
".",
"label",
"(",
")",
",... | Thrown when setting {@code superType} as the super type of {@code type} and a loop is created | [
"Thrown",
"when",
"setting",
"{"
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/server/exception/TransactionException.java#L143-L145 |
kiswanij/jk-util | src/main/java/com/jk/util/xml/JKXmlHandler.java | JKXmlHandler.toXml | public void toXml(Object object, OutputStream out, Class<?>... clas) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(clas);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(object, out);
} catch (JAXBException e) {
throw new JKException(e);
}
} | java | public void toXml(Object object, OutputStream out, Class<?>... clas) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(clas);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(object, out);
} catch (JAXBException e) {
throw new JKException(e);
}
} | [
"public",
"void",
"toXml",
"(",
"Object",
"object",
",",
"OutputStream",
"out",
",",
"Class",
"<",
"?",
">",
"...",
"clas",
")",
"{",
"try",
"{",
"JAXBContext",
"jaxbContext",
"=",
"JAXBContext",
".",
"newInstance",
"(",
"clas",
")",
";",
"Marshaller",
"... | To xml.
@param object the object
@param out the out
@param clas the clas | [
"To",
"xml",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/xml/JKXmlHandler.java#L79-L89 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java | WikipediaTemplateInfo.getPageIdsNotContainingTemplateNames | public List<Integer> getPageIdsNotContainingTemplateNames(List<String> templateNames) throws WikiApiException{
return getFilteredPageIds(templateNames, false);
} | java | public List<Integer> getPageIdsNotContainingTemplateNames(List<String> templateNames) throws WikiApiException{
return getFilteredPageIds(templateNames, false);
} | [
"public",
"List",
"<",
"Integer",
">",
"getPageIdsNotContainingTemplateNames",
"(",
"List",
"<",
"String",
">",
"templateNames",
")",
"throws",
"WikiApiException",
"{",
"return",
"getFilteredPageIds",
"(",
"templateNames",
",",
"false",
")",
";",
"}"
] | Returns a list containing the ids of all pages that do not contain a template
the name of which equals any of the given Strings.
@param templateNames
the names of the template that we want to match
@return A list with the ids of all pages that do not contain any of the the
specified templates
@throws WikiApiException
If there was any error retrieving the page object (most
likely if the templates are corrupted) | [
"Returns",
"a",
"list",
"containing",
"the",
"ids",
"of",
"all",
"pages",
"that",
"do",
"not",
"contain",
"a",
"template",
"the",
"name",
"of",
"which",
"equals",
"any",
"of",
"the",
"given",
"Strings",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java#L990-L992 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java | Printer.visitTypes | public String visitTypes(List<Type> ts, Locale locale) {
ListBuffer<String> sbuf = new ListBuffer<>();
for (Type t : ts) {
sbuf.append(visit(t, locale));
}
return sbuf.toList().toString();
} | java | public String visitTypes(List<Type> ts, Locale locale) {
ListBuffer<String> sbuf = new ListBuffer<>();
for (Type t : ts) {
sbuf.append(visit(t, locale));
}
return sbuf.toList().toString();
} | [
"public",
"String",
"visitTypes",
"(",
"List",
"<",
"Type",
">",
"ts",
",",
"Locale",
"locale",
")",
"{",
"ListBuffer",
"<",
"String",
">",
"sbuf",
"=",
"new",
"ListBuffer",
"<>",
"(",
")",
";",
"for",
"(",
"Type",
"t",
":",
"ts",
")",
"{",
"sbuf",... | Get a localized string representation for all the types in the input list.
@param ts types to be displayed
@param locale the locale in which the string is to be rendered
@return localized string representation | [
"Get",
"a",
"localized",
"string",
"representation",
"for",
"all",
"the",
"types",
"in",
"the",
"input",
"list",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java#L105-L111 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java | AssemblyAnalyzer.isDotnetPath | private boolean isDotnetPath() {
final String[] args = new String[2];
args[0] = "dotnet";
args[1] = "--version";
final ProcessBuilder pb = new ProcessBuilder(args);
try {
final Process proc = pb.start();
final int retCode = proc.waitFor();
if (retCode == 0) {
return true;
}
final byte[] version = new byte[50];
final int read = proc.getInputStream().read(version);
if (read > 0) {
final String v = new String(version, UTF_8);
if (v.length() > 0) {
return true;
}
}
} catch (IOException | InterruptedException ex) {
LOGGER.debug("Path search failed for dotnet", ex);
}
return false;
} | java | private boolean isDotnetPath() {
final String[] args = new String[2];
args[0] = "dotnet";
args[1] = "--version";
final ProcessBuilder pb = new ProcessBuilder(args);
try {
final Process proc = pb.start();
final int retCode = proc.waitFor();
if (retCode == 0) {
return true;
}
final byte[] version = new byte[50];
final int read = proc.getInputStream().read(version);
if (read > 0) {
final String v = new String(version, UTF_8);
if (v.length() > 0) {
return true;
}
}
} catch (IOException | InterruptedException ex) {
LOGGER.debug("Path search failed for dotnet", ex);
}
return false;
} | [
"private",
"boolean",
"isDotnetPath",
"(",
")",
"{",
"final",
"String",
"[",
"]",
"args",
"=",
"new",
"String",
"[",
"2",
"]",
";",
"args",
"[",
"0",
"]",
"=",
"\"dotnet\"",
";",
"args",
"[",
"1",
"]",
"=",
"\"--version\"",
";",
"final",
"ProcessBuil... | Tests to see if a file is in the system path.
@return <code>true</code> if dotnet could be found in the path; otherwise
<code>false</code> | [
"Tests",
"to",
"see",
"if",
"a",
"file",
"is",
"in",
"the",
"system",
"path",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java#L444-L467 |
yanzhenjie/AndServer | api/src/main/java/com/yanzhenjie/andserver/util/CollectionUtils.java | CollectionUtils.mergeArrayIntoCollection | @SuppressWarnings("unchecked")
public static <E> void mergeArrayIntoCollection(Object array, Collection<E> collection) {
if (collection == null) {
throw new IllegalArgumentException("Collection must not be null");
}
Object[] arr = ObjectUtils.toObjectArray(array);
for (Object elem : arr) {
collection.add((E)elem);
}
} | java | @SuppressWarnings("unchecked")
public static <E> void mergeArrayIntoCollection(Object array, Collection<E> collection) {
if (collection == null) {
throw new IllegalArgumentException("Collection must not be null");
}
Object[] arr = ObjectUtils.toObjectArray(array);
for (Object elem : arr) {
collection.add((E)elem);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"E",
">",
"void",
"mergeArrayIntoCollection",
"(",
"Object",
"array",
",",
"Collection",
"<",
"E",
">",
"collection",
")",
"{",
"if",
"(",
"collection",
"==",
"null",
")",
"{",
"t... | Merge the given array into the given Collection.
@param array the array to merge (may be {@code null}).
@param collection the target Collection to merge the array into. | [
"Merge",
"the",
"given",
"array",
"into",
"the",
"given",
"Collection",
"."
] | train | https://github.com/yanzhenjie/AndServer/blob/f95f316cdfa5755d6a3fec3c6a1b5df783b81517/api/src/main/java/com/yanzhenjie/andserver/util/CollectionUtils.java#L83-L92 |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/struct/convolve/Kernel2D_F32.java | Kernel2D_F32.wrap | public static Kernel2D_F32 wrap(float data[], int width, int offset) {
if (width % 2 == 0 && width <= 0 && width * width > data.length)
throw new IllegalArgumentException("invalid width");
Kernel2D_F32 ret = new Kernel2D_F32();
ret.data = data;
ret.width = width;
ret.offset = offset;
return ret;
} | java | public static Kernel2D_F32 wrap(float data[], int width, int offset) {
if (width % 2 == 0 && width <= 0 && width * width > data.length)
throw new IllegalArgumentException("invalid width");
Kernel2D_F32 ret = new Kernel2D_F32();
ret.data = data;
ret.width = width;
ret.offset = offset;
return ret;
} | [
"public",
"static",
"Kernel2D_F32",
"wrap",
"(",
"float",
"data",
"[",
"]",
",",
"int",
"width",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"width",
"%",
"2",
"==",
"0",
"&&",
"width",
"<=",
"0",
"&&",
"width",
"*",
"width",
">",
"data",
".",
"le... | Creates a kernel whose elements are the specified data array and has
the specified width.
@param data The array who will be the kernel's data. Reference is saved.
@param width The kernel's width.
@param offset Kernel origin's offset from element 0.
@return A new kernel. | [
"Creates",
"a",
"kernel",
"whose",
"elements",
"are",
"the",
"specified",
"data",
"array",
"and",
"has",
"the",
"specified",
"width",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/convolve/Kernel2D_F32.java#L87-L97 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/StringUtils.java | StringUtils.containsAny | public static boolean containsAny(final CharSequence cs, final CharSequence searchChars) {
if (searchChars == null) {
return false;
}
return containsAny(cs, CharSequenceUtils.toCharArray(searchChars));
} | java | public static boolean containsAny(final CharSequence cs, final CharSequence searchChars) {
if (searchChars == null) {
return false;
}
return containsAny(cs, CharSequenceUtils.toCharArray(searchChars));
} | [
"public",
"static",
"boolean",
"containsAny",
"(",
"final",
"CharSequence",
"cs",
",",
"final",
"CharSequence",
"searchChars",
")",
"{",
"if",
"(",
"searchChars",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"containsAny",
"(",
"cs",
",",
... | <p>
Checks if the CharSequence contains any character in the given set of characters.
</p>
<p>
A {@code null} CharSequence will return {@code false}. A {@code null} search CharSequence will return
{@code false}.
</p>
<pre>
StringUtils.containsAny(null, *) = false
StringUtils.containsAny("", *) = false
StringUtils.containsAny(*, null) = false
StringUtils.containsAny(*, "") = false
StringUtils.containsAny("zzabyycdxx", "za") = true
StringUtils.containsAny("zzabyycdxx", "by") = true
StringUtils.containsAny("zzabyycdxx", "zy") = true
StringUtils.containsAny("zzabyycdxx", "\tx") = true
StringUtils.containsAny("zzabyycdxx", "$.#yF") = true
StringUtils.containsAny("aba","z") = false
</pre>
@param cs
the CharSequence to check, may be null
@param searchChars
the chars to search for, may be null
@return the {@code true} if any of the chars are found, {@code false} if no match or null input
@since 2.4
@since 3.0 Changed signature from containsAny(String, String) to containsAny(CharSequence, CharSequence) | [
"<p",
">",
"Checks",
"if",
"the",
"CharSequence",
"contains",
"any",
"character",
"in",
"the",
"given",
"set",
"of",
"characters",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/StringUtils.java#L2217-L2222 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.newArray | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArray (@Nullable final Collection <? extends ELEMENTTYPE> aCollection,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.notNull (aClass, "class");
if (CollectionHelper.isEmpty (aCollection))
return newArray (aClass, 0);
final ELEMENTTYPE [] ret = newArray (aClass, aCollection.size ());
return aCollection.toArray (ret);
} | java | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArray (@Nullable final Collection <? extends ELEMENTTYPE> aCollection,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.notNull (aClass, "class");
if (CollectionHelper.isEmpty (aCollection))
return newArray (aClass, 0);
final ELEMENTTYPE [] ret = newArray (aClass, aCollection.size ());
return aCollection.toArray (ret);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"newArray",
"(",
"@",
"Nullable",
"final",
"Collection",
"<",
"?",
"extends",
"ELEMENTTYPE",
">",
"aCollection",
",",
"@",
"Nonnull",
"final",
"Cla... | Create a new array with the elements in the passed collection..
@param <ELEMENTTYPE>
Type of element
@param aCollection
The collection to be converted to an array. May be <code>null</code>
.
@param aClass
The class of the elements inside the collection. May not be
<code>null</code>.
@return <code>null</code> if the passed collection is empty, a non-
<code>null</code> array with all elements of the collection
otherwise. | [
"Create",
"a",
"new",
"array",
"with",
"the",
"elements",
"in",
"the",
"passed",
"collection",
".."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L3892-L3904 |
grails/grails-core | grails-core/src/main/groovy/org/grails/core/io/MockStringResourceLoader.java | MockStringResourceLoader.registerMockResource | public void registerMockResource(String location, String contents) {
try {
mockResources.put(location, new GrailsByteArrayResource(contents.getBytes("UTF-8"), location));
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} | java | public void registerMockResource(String location, String contents) {
try {
mockResources.put(location, new GrailsByteArrayResource(contents.getBytes("UTF-8"), location));
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} | [
"public",
"void",
"registerMockResource",
"(",
"String",
"location",
",",
"String",
"contents",
")",
"{",
"try",
"{",
"mockResources",
".",
"put",
"(",
"location",
",",
"new",
"GrailsByteArrayResource",
"(",
"contents",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
... | Registers a mock resource with the first argument as the location and the second as the contents
of the resource.
@param location The location
@param contents The contents of the resource | [
"Registers",
"a",
"mock",
"resource",
"with",
"the",
"first",
"argument",
"as",
"the",
"location",
"and",
"the",
"second",
"as",
"the",
"contents",
"of",
"the",
"resource",
"."
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/io/MockStringResourceLoader.java#L60-L67 |
sd4324530/fastweixin | src/main/java/com/github/sd4324530/fastweixin/message/aes/SHA1.java | SHA1.getSHA1 | public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException {
try {
String[] array = new String[]{token, timestamp, nonce, encrypt};
StringBuffer sb = new StringBuffer();
// 字符串排序
Arrays.sort(array);
for (int i = 0; i < 4; i++) {
sb.append(array[i]);
}
String str = sb.toString();
return getSHA1HexString(str);
} catch (Exception e) {
e.printStackTrace();
throw new AesException(AesException.ComputeSignatureError);
}
} | java | public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException {
try {
String[] array = new String[]{token, timestamp, nonce, encrypt};
StringBuffer sb = new StringBuffer();
// 字符串排序
Arrays.sort(array);
for (int i = 0; i < 4; i++) {
sb.append(array[i]);
}
String str = sb.toString();
return getSHA1HexString(str);
} catch (Exception e) {
e.printStackTrace();
throw new AesException(AesException.ComputeSignatureError);
}
} | [
"public",
"static",
"String",
"getSHA1",
"(",
"String",
"token",
",",
"String",
"timestamp",
",",
"String",
"nonce",
",",
"String",
"encrypt",
")",
"throws",
"AesException",
"{",
"try",
"{",
"String",
"[",
"]",
"array",
"=",
"new",
"String",
"[",
"]",
"{... | 用SHA1算法生成安全签名
@param token 票据
@param timestamp 时间戳
@param nonce 随机字符串
@param encrypt 密文
@return 安全签名
@throws AesException AES算法异常 | [
"用SHA1算法生成安全签名"
] | train | https://github.com/sd4324530/fastweixin/blob/6bc0a7abfa23aad0dbad4c3123a47a7fb53f3447/src/main/java/com/github/sd4324530/fastweixin/message/aes/SHA1.java#L30-L46 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java | PythonDistributionAnalyzer.prepareFileTypeAnalyzer | @Override
protected void prepareFileTypeAnalyzer(Engine engine) throws InitializationException {
try {
final File baseDir = getSettings().getTempDirectory();
tempFileLocation = File.createTempFile("check", "tmp", baseDir);
if (!tempFileLocation.delete()) {
setEnabled(false);
final String msg = String.format(
"Unable to delete temporary file '%s'.",
tempFileLocation.getAbsolutePath());
throw new InitializationException(msg);
}
if (!tempFileLocation.mkdirs()) {
setEnabled(false);
final String msg = String.format(
"Unable to create directory '%s'.",
tempFileLocation.getAbsolutePath());
throw new InitializationException(msg);
}
} catch (IOException ex) {
setEnabled(false);
throw new InitializationException("Unable to create a temporary file", ex);
}
} | java | @Override
protected void prepareFileTypeAnalyzer(Engine engine) throws InitializationException {
try {
final File baseDir = getSettings().getTempDirectory();
tempFileLocation = File.createTempFile("check", "tmp", baseDir);
if (!tempFileLocation.delete()) {
setEnabled(false);
final String msg = String.format(
"Unable to delete temporary file '%s'.",
tempFileLocation.getAbsolutePath());
throw new InitializationException(msg);
}
if (!tempFileLocation.mkdirs()) {
setEnabled(false);
final String msg = String.format(
"Unable to create directory '%s'.",
tempFileLocation.getAbsolutePath());
throw new InitializationException(msg);
}
} catch (IOException ex) {
setEnabled(false);
throw new InitializationException("Unable to create a temporary file", ex);
}
} | [
"@",
"Override",
"protected",
"void",
"prepareFileTypeAnalyzer",
"(",
"Engine",
"engine",
")",
"throws",
"InitializationException",
"{",
"try",
"{",
"final",
"File",
"baseDir",
"=",
"getSettings",
"(",
")",
".",
"getTempDirectory",
"(",
")",
";",
"tempFileLocation... | Makes sure a usable temporary directory is available.
@param engine a reference to the dependency-check engine
@throws InitializationException an AnalyzeException is thrown when the
temp directory cannot be created | [
"Makes",
"sure",
"a",
"usable",
"temporary",
"directory",
"is",
"available",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java#L244-L267 |
twitter/scalding | scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java | ScroogeReadSupport.assertGroupsAreCompatible | public static void assertGroupsAreCompatible(GroupType fileType, GroupType projection) {
List<Type> fields = projection.getFields();
for (Type otherType : fields) {
if (fileType.containsField(otherType.getName())) {
Type thisType = fileType.getType(otherType.getName());
assertAreCompatible(thisType, otherType);
if (!otherType.isPrimitive()) {
assertGroupsAreCompatible(thisType.asGroupType(), otherType.asGroupType());
}
} else if (otherType.getRepetition() == Type.Repetition.REQUIRED) {
throw new InvalidRecordException(otherType.getName() + " not found in " + fileType);
}
}
} | java | public static void assertGroupsAreCompatible(GroupType fileType, GroupType projection) {
List<Type> fields = projection.getFields();
for (Type otherType : fields) {
if (fileType.containsField(otherType.getName())) {
Type thisType = fileType.getType(otherType.getName());
assertAreCompatible(thisType, otherType);
if (!otherType.isPrimitive()) {
assertGroupsAreCompatible(thisType.asGroupType(), otherType.asGroupType());
}
} else if (otherType.getRepetition() == Type.Repetition.REQUIRED) {
throw new InvalidRecordException(otherType.getName() + " not found in " + fileType);
}
}
} | [
"public",
"static",
"void",
"assertGroupsAreCompatible",
"(",
"GroupType",
"fileType",
",",
"GroupType",
"projection",
")",
"{",
"List",
"<",
"Type",
">",
"fields",
"=",
"projection",
".",
"getFields",
"(",
")",
";",
"for",
"(",
"Type",
"otherType",
":",
"fi... | Validates that the requested group type projection is compatible.
This allows the projection schema to have extra optional fields.
@param fileType the typed schema of the source
@param projection requested projection schema | [
"Validates",
"that",
"the",
"requested",
"group",
"type",
"projection",
"is",
"compatible",
".",
"This",
"allows",
"the",
"projection",
"schema",
"to",
"have",
"extra",
"optional",
"fields",
"."
] | train | https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java#L160-L173 |
pippo-java/pippo | pippo-core/src/main/java/ro/pippo/core/route/WebjarsResourceHandler.java | WebjarsResourceHandler.locatePomProperties | private List<String> locatePomProperties() {
List<String> propertiesFiles = new ArrayList<>();
List<URL> packageUrls = ClasspathUtils.getResources(getResourceBasePath());
for (URL packageUrl : packageUrls) {
if (packageUrl.getProtocol().equals("jar")) {
// We only care about Webjars jar files
log.debug("Scanning {}", packageUrl);
try {
String jar = packageUrl.toString().substring("jar:".length()).split("!")[0];
File file = new File(new URI(jar));
try (JarInputStream is = new JarInputStream(new FileInputStream(file))) {
JarEntry entry = null;
while ((entry = is.getNextJarEntry()) != null) {
if (!entry.isDirectory() && entry.getName().endsWith("pom.properties")) {
propertiesFiles.add(entry.getName());
}
}
}
} catch (URISyntaxException | IOException e) {
throw new PippoRuntimeException("Failed to get classes for package '{}'", packageUrl);
}
}
}
return propertiesFiles;
} | java | private List<String> locatePomProperties() {
List<String> propertiesFiles = new ArrayList<>();
List<URL> packageUrls = ClasspathUtils.getResources(getResourceBasePath());
for (URL packageUrl : packageUrls) {
if (packageUrl.getProtocol().equals("jar")) {
// We only care about Webjars jar files
log.debug("Scanning {}", packageUrl);
try {
String jar = packageUrl.toString().substring("jar:".length()).split("!")[0];
File file = new File(new URI(jar));
try (JarInputStream is = new JarInputStream(new FileInputStream(file))) {
JarEntry entry = null;
while ((entry = is.getNextJarEntry()) != null) {
if (!entry.isDirectory() && entry.getName().endsWith("pom.properties")) {
propertiesFiles.add(entry.getName());
}
}
}
} catch (URISyntaxException | IOException e) {
throw new PippoRuntimeException("Failed to get classes for package '{}'", packageUrl);
}
}
}
return propertiesFiles;
} | [
"private",
"List",
"<",
"String",
">",
"locatePomProperties",
"(",
")",
"{",
"List",
"<",
"String",
">",
"propertiesFiles",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"URL",
">",
"packageUrls",
"=",
"ClasspathUtils",
".",
"getResources",
"(... | Locate all Webjars Maven pom.properties files on the classpath.
@return a list of Maven pom.properties files on the classpath | [
"Locate",
"all",
"Webjars",
"Maven",
"pom",
".",
"properties",
"files",
"on",
"the",
"classpath",
"."
] | train | https://github.com/pippo-java/pippo/blob/cb5ccb453bffcc3cf386adc660674812d10b9726/pippo-core/src/main/java/ro/pippo/core/route/WebjarsResourceHandler.java#L148-L173 |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library/src/com/tojc/ormlite/android/OrmLiteDefaultContentProvider.java | OrmLiteDefaultContentProvider.onBulkInsert | public Uri onBulkInsert(T helper, SQLiteDatabase db, MatcherPattern target, InsertParameters parameter) {
return onInsert(helper, db, target, parameter);
} | java | public Uri onBulkInsert(T helper, SQLiteDatabase db, MatcherPattern target, InsertParameters parameter) {
return onInsert(helper, db, target, parameter);
} | [
"public",
"Uri",
"onBulkInsert",
"(",
"T",
"helper",
",",
"SQLiteDatabase",
"db",
",",
"MatcherPattern",
"target",
",",
"InsertParameters",
"parameter",
")",
"{",
"return",
"onInsert",
"(",
"helper",
",",
"db",
",",
"target",
",",
"parameter",
")",
";",
"}"
... | You implement this method. At the timing of bulkInsert() method, which calls the
onBulkInsert(). Start the transaction, will be called for each record.
@param helper
This is a helper object. It is the same as one that can be retrieved by
this.getHelper().
@param db
This is a SQLiteDatabase object. Return the object obtained by
helper.getWritableDatabase().
@param target
It is MatcherPattern objects that match to evaluate Uri by UriMatcher. You can
access information in the tables and columns, ContentUri, MimeType etc.
@param parameter
Arguments passed to the insert() method.
@return Please set value to be returned in the original insert() method.
@since 1.0.1 | [
"You",
"implement",
"this",
"method",
".",
"At",
"the",
"timing",
"of",
"bulkInsert",
"()",
"method",
"which",
"calls",
"the",
"onBulkInsert",
"()",
".",
"Start",
"the",
"transaction",
"will",
"be",
"called",
"for",
"each",
"record",
"."
] | train | https://github.com/jakenjarvis/Android-OrmLiteContentProvider/blob/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library/src/com/tojc/ormlite/android/OrmLiteDefaultContentProvider.java#L398-L400 |
Netflix/zuul | zuul-core/src/main/java/com/netflix/netty/common/Http2ConnectionCloseHandler.java | Http2ConnectionCloseHandler.gracefullyWithDelay | protected void gracefullyWithDelay(ChannelHandlerContext ctx, Channel channel, ChannelPromise promise)
{
// See javadoc for explanation of why this may be disabled.
if (! ALLOW_GRACEFUL_DELAYED.get()) {
gracefully(channel, promise);
return;
}
if (isAlreadyClosing(channel)) {
promise.setSuccess();
return;
}
// First send a 'graceful shutdown' GOAWAY frame.
/*
"A server that is attempting to gracefully shut down a connection SHOULD send an initial GOAWAY frame with
the last stream identifier set to 231-1 and a NO_ERROR code. This signals to the client that a shutdown is
imminent and that initiating further requests is prohibited."
-- https://http2.github.io/http2-spec/#GOAWAY
*/
DefaultHttp2GoAwayFrame goaway = new DefaultHttp2GoAwayFrame(Http2Error.NO_ERROR);
goaway.setExtraStreamIds(Integer.MAX_VALUE);
channel.writeAndFlush(goaway);
LOG.debug("gracefullyWithDelay: flushed initial go_away frame. channel=" + channel.id().asShortText());
// In N secs time, throw an error that causes the http2 codec to send another GOAWAY frame
// (this time with accurate lastStreamId) and then close the connection.
ctx.executor().schedule(() -> {
// Check that the client hasn't already closed the connection (due to the earlier goaway we sent).
gracefulConnectionShutdown(channel);
promise.setSuccess();
}, gracefulCloseDelay, TimeUnit.SECONDS);
} | java | protected void gracefullyWithDelay(ChannelHandlerContext ctx, Channel channel, ChannelPromise promise)
{
// See javadoc for explanation of why this may be disabled.
if (! ALLOW_GRACEFUL_DELAYED.get()) {
gracefully(channel, promise);
return;
}
if (isAlreadyClosing(channel)) {
promise.setSuccess();
return;
}
// First send a 'graceful shutdown' GOAWAY frame.
/*
"A server that is attempting to gracefully shut down a connection SHOULD send an initial GOAWAY frame with
the last stream identifier set to 231-1 and a NO_ERROR code. This signals to the client that a shutdown is
imminent and that initiating further requests is prohibited."
-- https://http2.github.io/http2-spec/#GOAWAY
*/
DefaultHttp2GoAwayFrame goaway = new DefaultHttp2GoAwayFrame(Http2Error.NO_ERROR);
goaway.setExtraStreamIds(Integer.MAX_VALUE);
channel.writeAndFlush(goaway);
LOG.debug("gracefullyWithDelay: flushed initial go_away frame. channel=" + channel.id().asShortText());
// In N secs time, throw an error that causes the http2 codec to send another GOAWAY frame
// (this time with accurate lastStreamId) and then close the connection.
ctx.executor().schedule(() -> {
// Check that the client hasn't already closed the connection (due to the earlier goaway we sent).
gracefulConnectionShutdown(channel);
promise.setSuccess();
}, gracefulCloseDelay, TimeUnit.SECONDS);
} | [
"protected",
"void",
"gracefullyWithDelay",
"(",
"ChannelHandlerContext",
"ctx",
",",
"Channel",
"channel",
",",
"ChannelPromise",
"promise",
")",
"{",
"// See javadoc for explanation of why this may be disabled.",
"if",
"(",
"!",
"ALLOW_GRACEFUL_DELAYED",
".",
"get",
"(",
... | WARNING: Found the OkHttp client gets confused by this behaviour (it ends up putting itself in a bad shutdown state
after receiving the first goaway frame, and then dropping any inflight responses but also timing out waiting for them).
And worried that other http/2 stacks may be similar, so for now we should NOT use this.
This is unfortunate, as FTL wanted this, and it is correct according to the spec.
See this code in okhttp where it drops response header frame if state is already shutdown:
https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/internal/http2/Http2Connection.java#L609 | [
"WARNING",
":",
"Found",
"the",
"OkHttp",
"client",
"gets",
"confused",
"by",
"this",
"behaviour",
"(",
"it",
"ends",
"up",
"putting",
"itself",
"in",
"a",
"bad",
"shutdown",
"state",
"after",
"receiving",
"the",
"first",
"goaway",
"frame",
"and",
"then",
... | train | https://github.com/Netflix/zuul/blob/01bc777cf05e3522d37c9ed902ae13eb38a19692/zuul-core/src/main/java/com/netflix/netty/common/Http2ConnectionCloseHandler.java#L149-L183 |
BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/GridLayoutExample.java | GridLayoutExample.addBoxes | private static void addBoxes(final WPanel panel, final int amount) {
for (int i = 1; i <= amount; i++) {
panel.add(new BoxComponent(String.valueOf(i)));
}
} | java | private static void addBoxes(final WPanel panel, final int amount) {
for (int i = 1; i <= amount; i++) {
panel.add(new BoxComponent(String.valueOf(i)));
}
} | [
"private",
"static",
"void",
"addBoxes",
"(",
"final",
"WPanel",
"panel",
",",
"final",
"int",
"amount",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"amount",
";",
"i",
"++",
")",
"{",
"panel",
".",
"add",
"(",
"new",
"BoxComponent"... | Adds a set of boxes to the given panel.
@param panel the panel to add the boxes to.
@param amount the number of boxes to add. | [
"Adds",
"a",
"set",
"of",
"boxes",
"to",
"the",
"given",
"panel",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/GridLayoutExample.java#L133-L137 |
jaredrummler/AndroidShell | library/src/main/java/com/jaredrummler/android/shell/Shell.java | Shell.parseAvailableResult | static boolean parseAvailableResult(List<String> stdout, boolean checkForRoot) {
if (stdout == null) {
return false;
}
// this is only one of many ways this can be done
boolean echoSeen = false;
for (String line : stdout) {
if (line.contains("uid=")) {
// id command is working, let's see if we are actually root
return !checkForRoot || line.contains("uid=0");
} else if (line.contains("-BOC-")) {
// if we end up here, at least the su command starts some kind of shell, let's hope it has root privileges -
// no way to know without additional native binaries
echoSeen = true;
}
}
return echoSeen;
} | java | static boolean parseAvailableResult(List<String> stdout, boolean checkForRoot) {
if (stdout == null) {
return false;
}
// this is only one of many ways this can be done
boolean echoSeen = false;
for (String line : stdout) {
if (line.contains("uid=")) {
// id command is working, let's see if we are actually root
return !checkForRoot || line.contains("uid=0");
} else if (line.contains("-BOC-")) {
// if we end up here, at least the su command starts some kind of shell, let's hope it has root privileges -
// no way to know without additional native binaries
echoSeen = true;
}
}
return echoSeen;
} | [
"static",
"boolean",
"parseAvailableResult",
"(",
"List",
"<",
"String",
">",
"stdout",
",",
"boolean",
"checkForRoot",
")",
"{",
"if",
"(",
"stdout",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// this is only one of many ways this can be done",
"boolea... | See if the shell is alive, and if so, check the UID
@param stdout
Standard output from running AVAILABLE_TEST_COMMANDS
@param checkForRoot
true if we are expecting this shell to be running as root
@return true on success, false on error | [
"See",
"if",
"the",
"shell",
"is",
"alive",
"and",
"if",
"so",
"check",
"the",
"UID"
] | train | https://github.com/jaredrummler/AndroidShell/blob/0826b6f93c208b7bc95344dd20e2989d367a1e43/library/src/main/java/com/jaredrummler/android/shell/Shell.java#L231-L251 |
dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java | AbstractHBaseUtils.getResultScan | public Scan getResultScan(String tableName, String famName,
ByteBuffer startKey, ByteBuffer endKey) throws IOException {
logger.debug("AbstractHBaseUtils Begin of getResultScan(" + tableName + ", " + famName + ")");
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes(famName));
// For a range scan, set start / stop id or just start.
if (startKey != null)
scan.setStartRow(Bytes.toBytes(startKey));
if (endKey != null)
scan.setStopRow(Bytes.toBytes(endKey));
return scan;
} | java | public Scan getResultScan(String tableName, String famName,
ByteBuffer startKey, ByteBuffer endKey) throws IOException {
logger.debug("AbstractHBaseUtils Begin of getResultScan(" + tableName + ", " + famName + ")");
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes(famName));
// For a range scan, set start / stop id or just start.
if (startKey != null)
scan.setStartRow(Bytes.toBytes(startKey));
if (endKey != null)
scan.setStopRow(Bytes.toBytes(endKey));
return scan;
} | [
"public",
"Scan",
"getResultScan",
"(",
"String",
"tableName",
",",
"String",
"famName",
",",
"ByteBuffer",
"startKey",
",",
"ByteBuffer",
"endKey",
")",
"throws",
"IOException",
"{",
"logger",
".",
"debug",
"(",
"\"AbstractHBaseUtils Begin of getResultScan(\"",
"+",
... | Creates a scan
@param tableName to be scan
@param famName to be checked
@param startKey to query the table
@param endKey to query the table
@param conf
@return Scan inside the table
@throws IOException | [
"Creates",
"a",
"scan"
] | train | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java#L229-L240 |
igniterealtime/Smack | smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java | OpenPgpPubSubUtil.fetchPubkeysList | public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection)
throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException,
PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException {
return fetchPubkeysList(connection, null);
} | java | public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection)
throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException,
PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException {
return fetchPubkeysList(connection, null);
} | [
"public",
"static",
"PublicKeysListElement",
"fetchPubkeysList",
"(",
"XMPPConnection",
"connection",
")",
"throws",
"InterruptedException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"PubSubException",
".",
"NotAPubSubNodeException",
",",
"PubSubException",
".",
... | Consult the public key metadata node and fetch a list of all of our published OpenPGP public keys.
@see <a href="https://xmpp.org/extensions/xep-0373.html#discover-pubkey-list">
XEP-0373 §4.3: Discovering Public Keys of a User</a>
@param connection XMPP connection
@return content of our metadata node.
@throws InterruptedException if the thread gets interrupted.
@throws XMPPException.XMPPErrorException in case of an XMPP protocol exception.
@throws PubSubException.NotAPubSubNodeException in case the queried entity is not a PubSub node
@throws PubSubException.NotALeafNodeException in case the queried node is not a {@link LeafNode}
@throws SmackException.NotConnectedException in case we are not connected
@throws SmackException.NoResponseException in case the server doesn't respond | [
"Consult",
"the",
"public",
"key",
"metadata",
"node",
"and",
"fetch",
"a",
"list",
"of",
"all",
"of",
"our",
"published",
"OpenPGP",
"public",
"keys",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java#L180-L184 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java | Expressions.dslTemplate | public static <T> DslTemplate<T> dslTemplate(Class<? extends T> cl, Template template, Object... args) {
return dslTemplate(cl, template, ImmutableList.copyOf(args));
} | java | public static <T> DslTemplate<T> dslTemplate(Class<? extends T> cl, Template template, Object... args) {
return dslTemplate(cl, template, ImmutableList.copyOf(args));
} | [
"public",
"static",
"<",
"T",
">",
"DslTemplate",
"<",
"T",
">",
"dslTemplate",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"cl",
",",
"Template",
"template",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"dslTemplate",
"(",
"cl",
",",
"template",... | Create a new Template expression
@param cl type of expression
@param template template
@param args template parameters
@return template expression | [
"Create",
"a",
"new",
"Template",
"expression"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L359-L361 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/collections/ImmutableMultitable.java | ImmutableMultitable.putAll | @Deprecated
@Override
public boolean putAll(final R rowKey, final C columnKey, final Iterable<? extends V> values) {
throw new UnsupportedOperationException();
} | java | @Deprecated
@Override
public boolean putAll(final R rowKey, final C columnKey, final Iterable<? extends V> values) {
throw new UnsupportedOperationException();
} | [
"@",
"Deprecated",
"@",
"Override",
"public",
"boolean",
"putAll",
"(",
"final",
"R",
"rowKey",
",",
"final",
"C",
"columnKey",
",",
"final",
"Iterable",
"<",
"?",
"extends",
"V",
">",
"values",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",... | Guaranteed to throw an exception and leave the table unmodified.
@throws UnsupportedOperationException always
@deprecated Unsupported operation. | [
"Guaranteed",
"to",
"throw",
"an",
"exception",
"and",
"leave",
"the",
"table",
"unmodified",
"."
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/collections/ImmutableMultitable.java#L129-L133 |
hawkular/hawkular-agent | hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/Address.java | Address.fromModelNodeWrapper | public static Address fromModelNodeWrapper(ModelNode haystack, String needle) {
if (haystack.hasDefined(needle)) {
return fromModelNode(haystack.get(needle));
}
throw new IllegalArgumentException("There is no address under the key [" + needle + "] in the node: "
+ haystack.toJSONString(true));
} | java | public static Address fromModelNodeWrapper(ModelNode haystack, String needle) {
if (haystack.hasDefined(needle)) {
return fromModelNode(haystack.get(needle));
}
throw new IllegalArgumentException("There is no address under the key [" + needle + "] in the node: "
+ haystack.toJSONString(true));
} | [
"public",
"static",
"Address",
"fromModelNodeWrapper",
"(",
"ModelNode",
"haystack",
",",
"String",
"needle",
")",
"{",
"if",
"(",
"haystack",
".",
"hasDefined",
"(",
"needle",
")",
")",
"{",
"return",
"fromModelNode",
"(",
"haystack",
".",
"get",
"(",
"need... | Obtains an address property list from the given ModelNode wrapper. The given haystack must have a
key whose value is the same as needle. The value of that named property must itself be a property list
containing all address parts (and only address parts).
@param haystack the wrapper ModelNode that contains a property whose value is an address property list.
@param needle the name of the property in the given wrapper ModelNode whose value is the address property list.
@return the found address
@throws IllegalArgumentException there is no address property list in the wrapper node with the given name.
@see #fromModelNode(ModelNode) | [
"Obtains",
"an",
"address",
"property",
"list",
"from",
"the",
"given",
"ModelNode",
"wrapper",
".",
"The",
"given",
"haystack",
"must",
"have",
"a",
"key",
"whose",
"value",
"is",
"the",
"same",
"as",
"needle",
".",
"The",
"value",
"of",
"that",
"named",
... | train | https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/Address.java#L119-L126 |
awslabs/amazon-sqs-java-messaging-lib | src/main/java/com/amazon/sqs/javamessaging/AmazonSQSMessagingClientWrapper.java | AmazonSQSMessagingClientWrapper.changeMessageVisibility | public void changeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws JMSException {
try {
prepareRequest(changeMessageVisibilityRequest);
amazonSQSClient.changeMessageVisibility(changeMessageVisibilityRequest);
} catch (AmazonClientException e) {
throw handleException(e, "changeMessageVisibility");
}
} | java | public void changeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws JMSException {
try {
prepareRequest(changeMessageVisibilityRequest);
amazonSQSClient.changeMessageVisibility(changeMessageVisibilityRequest);
} catch (AmazonClientException e) {
throw handleException(e, "changeMessageVisibility");
}
} | [
"public",
"void",
"changeMessageVisibility",
"(",
"ChangeMessageVisibilityRequest",
"changeMessageVisibilityRequest",
")",
"throws",
"JMSException",
"{",
"try",
"{",
"prepareRequest",
"(",
"changeMessageVisibilityRequest",
")",
";",
"amazonSQSClient",
".",
"changeMessageVisibil... | Calls <code>changeMessageVisibility</code> and wraps <code>AmazonClientException</code>. This is
used to for negative acknowledge of a single message, so that messages can be received again without any delay.
@param changeMessageVisibilityRequest
Container for the necessary parameters to execute the
changeMessageVisibility service method on AmazonSQS.
@throws JMSException | [
"Calls",
"<code",
">",
"changeMessageVisibility<",
"/",
"code",
">",
"and",
"wraps",
"<code",
">",
"AmazonClientException<",
"/",
"code",
">",
".",
"This",
"is",
"used",
"to",
"for",
"negative",
"acknowledge",
"of",
"a",
"single",
"message",
"so",
"that",
"m... | train | https://github.com/awslabs/amazon-sqs-java-messaging-lib/blob/efa716d34d51ef1c5572790626cdb795419cb342/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSMessagingClientWrapper.java#L366-L373 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java | WPartialDateField.getDay | public Integer getDay() {
String dateValue = getValue();
if (dateValue != null && dateValue.length() == DAY_END) {
return parseDateComponent(dateValue.substring(DAY_START, DAY_END), getPaddingChar());
} else {
return null;
}
} | java | public Integer getDay() {
String dateValue = getValue();
if (dateValue != null && dateValue.length() == DAY_END) {
return parseDateComponent(dateValue.substring(DAY_START, DAY_END), getPaddingChar());
} else {
return null;
}
} | [
"public",
"Integer",
"getDay",
"(",
")",
"{",
"String",
"dateValue",
"=",
"getValue",
"(",
")",
";",
"if",
"(",
"dateValue",
"!=",
"null",
"&&",
"dateValue",
".",
"length",
"(",
")",
"==",
"DAY_END",
")",
"{",
"return",
"parseDateComponent",
"(",
"dateVa... | Returns the day of the month value.
@return the day of the month, or null if unspecified. | [
"Returns",
"the",
"day",
"of",
"the",
"month",
"value",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L497-L505 |
googleads/googleads-java-lib | examples/adwords_axis/src/main/java/adwords/axis/v201809/remarketing/UploadOfflineData.java | UploadOfflineData.getFieldPathElementIndex | private static Integer getFieldPathElementIndex(ApiError apiError, String field) {
FieldPathElement[] fieldPathElements = apiError.getFieldPathElements();
if (fieldPathElements == null) {
return null;
}
for(int i = 0; i < fieldPathElements.length; i++) {
FieldPathElement fieldPathElement = fieldPathElements[i];
if (field.equals(fieldPathElement.getField())) {
return fieldPathElement.getIndex();
}
}
return null;
} | java | private static Integer getFieldPathElementIndex(ApiError apiError, String field) {
FieldPathElement[] fieldPathElements = apiError.getFieldPathElements();
if (fieldPathElements == null) {
return null;
}
for(int i = 0; i < fieldPathElements.length; i++) {
FieldPathElement fieldPathElement = fieldPathElements[i];
if (field.equals(fieldPathElement.getField())) {
return fieldPathElement.getIndex();
}
}
return null;
} | [
"private",
"static",
"Integer",
"getFieldPathElementIndex",
"(",
"ApiError",
"apiError",
",",
"String",
"field",
")",
"{",
"FieldPathElement",
"[",
"]",
"fieldPathElements",
"=",
"apiError",
".",
"getFieldPathElements",
"(",
")",
";",
"if",
"(",
"fieldPathElements",... | Returns the {@link FieldPathElement#getIndex()} for the specified {@code field} name, if
present in the error's field path elements.
@param apiError the error to inspect.
@param field the name of the field to search for in the error's field path elements.
@return the index of the entry with the specified field, or {@code null} if no such entry
exists or the entry has a null index. | [
"Returns",
"the",
"{",
"@link",
"FieldPathElement#getIndex",
"()",
"}",
"for",
"the",
"specified",
"{",
"@code",
"field",
"}",
"name",
"if",
"present",
"in",
"the",
"error",
"s",
"field",
"path",
"elements",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/adwords_axis/src/main/java/adwords/axis/v201809/remarketing/UploadOfflineData.java#L377-L389 |
groupon/odo | proxylib/src/main/java/com/groupon/odo/proxylib/OverrideService.java | OverrideService.updateRepeatNumber | public void updateRepeatNumber(int overrideId, int pathId, Integer ordinal, Integer repeatNumber, String clientUUID) {
if (ordinal == null) {
ordinal = 1;
}
try {
// get ID of the ordinal
int enabledId = getEnabledEndpoint(pathId, overrideId, ordinal, clientUUID).getId();
updateRepeatNumber(enabledId, repeatNumber);
} catch (Exception e) {
e.printStackTrace();
}
} | java | public void updateRepeatNumber(int overrideId, int pathId, Integer ordinal, Integer repeatNumber, String clientUUID) {
if (ordinal == null) {
ordinal = 1;
}
try {
// get ID of the ordinal
int enabledId = getEnabledEndpoint(pathId, overrideId, ordinal, clientUUID).getId();
updateRepeatNumber(enabledId, repeatNumber);
} catch (Exception e) {
e.printStackTrace();
}
} | [
"public",
"void",
"updateRepeatNumber",
"(",
"int",
"overrideId",
",",
"int",
"pathId",
",",
"Integer",
"ordinal",
",",
"Integer",
"repeatNumber",
",",
"String",
"clientUUID",
")",
"{",
"if",
"(",
"ordinal",
"==",
"null",
")",
"{",
"ordinal",
"=",
"1",
";"... | Update the repeat number for a given enabled override
@param overrideId - override ID to update
@param pathId - path ID to update
@param ordinal - can be null, Index of the enabled override to edit if multiple of the same are enabled
@param repeatNumber - number of times to repeat
@param clientUUID - clientUUID | [
"Update",
"the",
"repeat",
"number",
"for",
"a",
"given",
"enabled",
"override"
] | train | https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/OverrideService.java#L188-L200 |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/flow/TimeoutOperation.java | TimeoutOperation.start | public final void start(final DispatchAsync dispatcher, final ModelNode operation, final Callback callback) {
Command dispatchCmd = new Command() {
@Override
public void execute() {
dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(final Throwable caught) {
callback.onError(caught);
}
@Override
public void onSuccess(final DMRResponse result) {
// No action here: We're polling later on until the condition is satisfied
// or the timeout is reached.
}
});
}
};
start(dispatchCmd, callback);
} | java | public final void start(final DispatchAsync dispatcher, final ModelNode operation, final Callback callback) {
Command dispatchCmd = new Command() {
@Override
public void execute() {
dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(final Throwable caught) {
callback.onError(caught);
}
@Override
public void onSuccess(final DMRResponse result) {
// No action here: We're polling later on until the condition is satisfied
// or the timeout is reached.
}
});
}
};
start(dispatchCmd, callback);
} | [
"public",
"final",
"void",
"start",
"(",
"final",
"DispatchAsync",
"dispatcher",
",",
"final",
"ModelNode",
"operation",
",",
"final",
"Callback",
"callback",
")",
"{",
"Command",
"dispatchCmd",
"=",
"new",
"Command",
"(",
")",
"{",
"@",
"Override",
"public",
... | Executes a DMR operation and repeatedly calls {@code checker} until {@link #setConditionSatisfied(boolean)}
was called with {@code true} or the timeout is reached.
@param dispatcher the dispatcher
@param operation the DMR operation which should be executed
@param callback the final callback | [
"Executes",
"a",
"DMR",
"operation",
"and",
"repeatedly",
"calls",
"{",
"@code",
"checker",
"}",
"until",
"{",
"@link",
"#setConditionSatisfied",
"(",
"boolean",
")",
"}",
"was",
"called",
"with",
"{",
"@code",
"true",
"}",
"or",
"the",
"timeout",
"is",
"r... | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/flow/TimeoutOperation.java#L53-L72 |
ironjacamar/ironjacamar | common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java | AbstractParser.parseCapacity | protected Capacity parseCapacity(XMLStreamReader reader) throws XMLStreamException, ParserException,
ValidateException
{
Extension incrementer = null;
Extension decrementer = null;
while (reader.hasNext())
{
switch (reader.nextTag())
{
case END_ELEMENT : {
switch (reader.getLocalName())
{
case CommonXML.ELEMENT_CAPACITY :
return new CapacityImpl(incrementer, decrementer);
default :
break;
}
}
case START_ELEMENT : {
switch (reader.getLocalName())
{
case CommonXML.ELEMENT_INCREMENTER : {
incrementer = parseExtension(reader, CommonXML.ELEMENT_INCREMENTER);
break;
}
case CommonXML.ELEMENT_DECREMENTER : {
decrementer = parseExtension(reader, CommonXML.ELEMENT_DECREMENTER);
break;
}
default :
// Nothing
}
break;
}
default :
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
} | java | protected Capacity parseCapacity(XMLStreamReader reader) throws XMLStreamException, ParserException,
ValidateException
{
Extension incrementer = null;
Extension decrementer = null;
while (reader.hasNext())
{
switch (reader.nextTag())
{
case END_ELEMENT : {
switch (reader.getLocalName())
{
case CommonXML.ELEMENT_CAPACITY :
return new CapacityImpl(incrementer, decrementer);
default :
break;
}
}
case START_ELEMENT : {
switch (reader.getLocalName())
{
case CommonXML.ELEMENT_INCREMENTER : {
incrementer = parseExtension(reader, CommonXML.ELEMENT_INCREMENTER);
break;
}
case CommonXML.ELEMENT_DECREMENTER : {
decrementer = parseExtension(reader, CommonXML.ELEMENT_DECREMENTER);
break;
}
default :
// Nothing
}
break;
}
default :
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
} | [
"protected",
"Capacity",
"parseCapacity",
"(",
"XMLStreamReader",
"reader",
")",
"throws",
"XMLStreamException",
",",
"ParserException",
",",
"ValidateException",
"{",
"Extension",
"incrementer",
"=",
"null",
";",
"Extension",
"decrementer",
"=",
"null",
";",
"while",... | Parse capacity tag
@param reader reader
@return the parsed capacity object
@throws XMLStreamException in case of error
@throws ParserException in case of error
@throws ValidateException in case of error | [
"Parse",
"capacity",
"tag"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java#L836-L876 |
icode/ameba | src/main/java/ameba/db/ebean/internal/ModelInterceptor.java | ModelInterceptor.applyOrderBy | public static void applyOrderBy(MultivaluedMap<String, String> queryParams, Query query) {
List<String> orders = queryParams.get(SORT_PARAM_NAME);
if (orders != null && orders.size() > 0) {
OrderBy orderBy = query.orderBy();
for (String order : orders) {
EbeanUtils.appendOrder(orderBy, order);
}
}
} | java | public static void applyOrderBy(MultivaluedMap<String, String> queryParams, Query query) {
List<String> orders = queryParams.get(SORT_PARAM_NAME);
if (orders != null && orders.size() > 0) {
OrderBy orderBy = query.orderBy();
for (String order : orders) {
EbeanUtils.appendOrder(orderBy, order);
}
}
} | [
"public",
"static",
"void",
"applyOrderBy",
"(",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"queryParams",
",",
"Query",
"query",
")",
"{",
"List",
"<",
"String",
">",
"orders",
"=",
"queryParams",
".",
"get",
"(",
"SORT_PARAM_NAME",
")",
";",
"i... | <p>applyOrderBy.</p>
@param queryParams a {@link javax.ws.rs.core.MultivaluedMap} object.
@param query a {@link io.ebean.Query} object. | [
"<p",
">",
"applyOrderBy",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/db/ebean/internal/ModelInterceptor.java#L236-L244 |
alkacon/opencms-core | src/org/opencms/relations/CmsLinkUpdateUtil.java | CmsLinkUpdateUtil.updateXmlForHtmlValue | public static void updateXmlForHtmlValue(CmsLink link, String name, Element element) {
// if element is not null
if (element != null) {
// update the additional attributes
if (name != null) {
updateAttribute(element, CmsLink.ATTRIBUTE_NAME, link.getName());
}
updateAttribute(element, CmsLink.ATTRIBUTE_INTERNAL, Boolean.toString(link.isInternal()));
// update the common sub-elements and attributes
updateXmlForVfsFile(link, element);
}
} | java | public static void updateXmlForHtmlValue(CmsLink link, String name, Element element) {
// if element is not null
if (element != null) {
// update the additional attributes
if (name != null) {
updateAttribute(element, CmsLink.ATTRIBUTE_NAME, link.getName());
}
updateAttribute(element, CmsLink.ATTRIBUTE_INTERNAL, Boolean.toString(link.isInternal()));
// update the common sub-elements and attributes
updateXmlForVfsFile(link, element);
}
} | [
"public",
"static",
"void",
"updateXmlForHtmlValue",
"(",
"CmsLink",
"link",
",",
"String",
"name",
",",
"Element",
"element",
")",
"{",
"// if element is not null",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"// update the additional attributes",
"if",
"(",
"n... | Updates the given xml element with this link information.<p>
@param link the link to get the information from
@param name the (optional) name of the link
@param element the <link> element to update | [
"Updates",
"the",
"given",
"xml",
"element",
"with",
"this",
"link",
"information",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/relations/CmsLinkUpdateUtil.java#L89-L101 |
pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/refer/Descriptor.java | Descriptor.exactMatch | public boolean exactMatch(Descriptor descriptor) {
return exactMatchField(_group, descriptor.getGroup()) && exactMatchField(_type, descriptor.getType())
&& exactMatchField(_kind, descriptor.getKind()) && exactMatchField(_name, descriptor.getName())
&& exactMatchField(_version, descriptor.getVersion());
} | java | public boolean exactMatch(Descriptor descriptor) {
return exactMatchField(_group, descriptor.getGroup()) && exactMatchField(_type, descriptor.getType())
&& exactMatchField(_kind, descriptor.getKind()) && exactMatchField(_name, descriptor.getName())
&& exactMatchField(_version, descriptor.getVersion());
} | [
"public",
"boolean",
"exactMatch",
"(",
"Descriptor",
"descriptor",
")",
"{",
"return",
"exactMatchField",
"(",
"_group",
",",
"descriptor",
".",
"getGroup",
"(",
")",
")",
"&&",
"exactMatchField",
"(",
"_type",
",",
"descriptor",
".",
"getType",
"(",
")",
"... | Matches this descriptor to another descriptor by all fields. No exceptions
are made.
@param descriptor the descriptor to match this one against.
@return true if descriptors match and false otherwise.
@see #match(Descriptor) | [
"Matches",
"this",
"descriptor",
"to",
"another",
"descriptor",
"by",
"all",
"fields",
".",
"No",
"exceptions",
"are",
"made",
"."
] | train | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/Descriptor.java#L154-L158 |
duracloud/duracloud | retrievaltool/src/main/java/org/duracloud/retrieval/mgmt/RetrievalWorker.java | RetrievalWorker.applyTimestamps | protected void applyTimestamps(ContentStream content, File localFile) {
FileTime createTime =
convertDateToFileTime(content.getDateCreated());
FileTime lastAccessTime =
convertDateToFileTime(content.getDateLastAccessed());
FileTime lastModTime =
convertDateToFileTime(content.getDateLastModified());
BasicFileAttributeView fileAttributeView =
Files.getFileAttributeView(localFile.toPath(),
BasicFileAttributeView.class,
LinkOption.NOFOLLOW_LINKS);
// If any time value is null, that value is left unchanged
try {
fileAttributeView.setTimes(lastModTime, lastAccessTime, createTime);
} catch (IOException e) {
logger.error("Error setting timestamps for local file " +
localFile.getAbsolutePath() + ": " + e.getMessage(),
e);
}
} | java | protected void applyTimestamps(ContentStream content, File localFile) {
FileTime createTime =
convertDateToFileTime(content.getDateCreated());
FileTime lastAccessTime =
convertDateToFileTime(content.getDateLastAccessed());
FileTime lastModTime =
convertDateToFileTime(content.getDateLastModified());
BasicFileAttributeView fileAttributeView =
Files.getFileAttributeView(localFile.toPath(),
BasicFileAttributeView.class,
LinkOption.NOFOLLOW_LINKS);
// If any time value is null, that value is left unchanged
try {
fileAttributeView.setTimes(lastModTime, lastAccessTime, createTime);
} catch (IOException e) {
logger.error("Error setting timestamps for local file " +
localFile.getAbsolutePath() + ": " + e.getMessage(),
e);
}
} | [
"protected",
"void",
"applyTimestamps",
"(",
"ContentStream",
"content",
",",
"File",
"localFile",
")",
"{",
"FileTime",
"createTime",
"=",
"convertDateToFileTime",
"(",
"content",
".",
"getDateCreated",
"(",
")",
")",
";",
"FileTime",
"lastAccessTime",
"=",
"conv... | /*
Applies timestamps which are found in the content item's properties
to the retrieved file | [
"/",
"*",
"Applies",
"timestamps",
"which",
"are",
"found",
"in",
"the",
"content",
"item",
"s",
"properties",
"to",
"the",
"retrieved",
"file"
] | train | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/retrievaltool/src/main/java/org/duracloud/retrieval/mgmt/RetrievalWorker.java#L275-L295 |
visallo/vertexium | security/src/main/java/org/vertexium/security/WritableComparator.java | WritableComparator.readVLong | public static long readVLong(byte[] bytes, int start) throws IOException {
int len = bytes[start];
if (len >= -112) {
return len;
}
boolean isNegative = (len < -120);
len = isNegative ? -(len + 120) : -(len + 112);
if (start + 1 + len > bytes.length) {
throw new IOException("Not enough number of bytes for a zero-compressed integer");
}
long i = 0;
for (int idx = 0; idx < len; idx++) {
i = i << 8;
i = i | (bytes[start + 1 + idx] & 0xFF);
}
return (isNegative ? (i ^ -1L) : i);
} | java | public static long readVLong(byte[] bytes, int start) throws IOException {
int len = bytes[start];
if (len >= -112) {
return len;
}
boolean isNegative = (len < -120);
len = isNegative ? -(len + 120) : -(len + 112);
if (start + 1 + len > bytes.length) {
throw new IOException("Not enough number of bytes for a zero-compressed integer");
}
long i = 0;
for (int idx = 0; idx < len; idx++) {
i = i << 8;
i = i | (bytes[start + 1 + idx] & 0xFF);
}
return (isNegative ? (i ^ -1L) : i);
} | [
"public",
"static",
"long",
"readVLong",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"start",
")",
"throws",
"IOException",
"{",
"int",
"len",
"=",
"bytes",
"[",
"start",
"]",
";",
"if",
"(",
"len",
">=",
"-",
"112",
")",
"{",
"return",
"len",
";",... | Reads a zero-compressed encoded long from a byte array and returns it.
@param bytes byte array with decode long
@param start starting index
@return deserialized long
@throws java.io.IOException | [
"Reads",
"a",
"zero",
"-",
"compressed",
"encoded",
"long",
"from",
"a",
"byte",
"array",
"and",
"returns",
"it",
"."
] | train | https://github.com/visallo/vertexium/blob/bb132b5425ac168957667164e1409b78adbea769/security/src/main/java/org/vertexium/security/WritableComparator.java#L241-L257 |
mapbox/mapbox-events-android | liblocation/src/main/java/com/mapbox/android/core/permissions/PermissionsManager.java | PermissionsManager.onRequestPermissionsResult | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case REQUEST_PERMISSIONS_CODE:
if (listener != null) {
boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
listener.onPermissionResult(granted);
}
break;
default:
// Ignored
}
} | java | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case REQUEST_PERMISSIONS_CODE:
if (listener != null) {
boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
listener.onPermissionResult(granted);
}
break;
default:
// Ignored
}
} | [
"public",
"void",
"onRequestPermissionsResult",
"(",
"int",
"requestCode",
",",
"String",
"[",
"]",
"permissions",
",",
"int",
"[",
"]",
"grantResults",
")",
"{",
"switch",
"(",
"requestCode",
")",
"{",
"case",
"REQUEST_PERMISSIONS_CODE",
":",
"if",
"(",
"list... | You should call this method from your activity onRequestPermissionsResult.
@param requestCode The request code passed in requestPermissions(android.app.Activity, String[], int)
@param permissions The requested permissions. Never null.
@param grantResults The grant results for the corresponding permissions which is either
PERMISSION_GRANTED or PERMISSION_DENIED. Never null. | [
"You",
"should",
"call",
"this",
"method",
"from",
"your",
"activity",
"onRequestPermissionsResult",
"."
] | train | https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/permissions/PermissionsManager.java#L95-L106 |
otto-de/edison-hal | src/main/java/de/otto/edison/hal/traverson/Traverson.java | Traverson.streamAs | @SuppressWarnings("unchecked")
public <T extends HalRepresentation> Stream<T> streamAs(final Class<T> type,
final EmbeddedTypeInfo embeddedTypeInfo,
final EmbeddedTypeInfo... moreEmbeddedTypeInfos) throws IOException {
if (moreEmbeddedTypeInfos == null || moreEmbeddedTypeInfos.length == 0) {
return streamAs(type, embeddedTypeInfo != null ? singletonList(embeddedTypeInfo) : emptyList());
} else {
final List<EmbeddedTypeInfo> typeInfos = new ArrayList<>();
typeInfos.add(requireNonNull(embeddedTypeInfo));
typeInfos.addAll(asList(moreEmbeddedTypeInfos));
return streamAs(type, typeInfos);
}
} | java | @SuppressWarnings("unchecked")
public <T extends HalRepresentation> Stream<T> streamAs(final Class<T> type,
final EmbeddedTypeInfo embeddedTypeInfo,
final EmbeddedTypeInfo... moreEmbeddedTypeInfos) throws IOException {
if (moreEmbeddedTypeInfos == null || moreEmbeddedTypeInfos.length == 0) {
return streamAs(type, embeddedTypeInfo != null ? singletonList(embeddedTypeInfo) : emptyList());
} else {
final List<EmbeddedTypeInfo> typeInfos = new ArrayList<>();
typeInfos.add(requireNonNull(embeddedTypeInfo));
typeInfos.addAll(asList(moreEmbeddedTypeInfos));
return streamAs(type, typeInfos);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
"extends",
"HalRepresentation",
">",
"Stream",
"<",
"T",
">",
"streamAs",
"(",
"final",
"Class",
"<",
"T",
">",
"type",
",",
"final",
"EmbeddedTypeInfo",
"embeddedTypeInfo",
",",
"final",
... | Follow the {@link Link}s of the current resource, selected by its link-relation type and returns a {@link Stream}
containing the returned {@link HalRepresentation HalRepresentations}.
<p>
The EmbeddedTypeInfo is used to define the specific type of embedded items.
</p>
<p>
Templated links are expanded to URIs using the specified template variables.
</p>
<p>
If the current node has {@link Embedded embedded} items with the specified {@code rel},
these items are used instead of resolving the associated {@link Link}.
</p>
@param type the specific type of the returned HalRepresentations
@param embeddedTypeInfo specification of the type of embedded items
@param moreEmbeddedTypeInfos more embedded type-infos
@param <T> type of the returned HalRepresentations
@return this
@throws IOException if a low-level I/O problem (unexpected end-of-input, network error) occurs.
@throws JsonParseException if the json document can not be parsed by Jackson's ObjectMapper
@throws JsonMappingException if the input JSON structure can not be mapped to the specified HalRepresentation type
@since 1.0.0 | [
"Follow",
"the",
"{"
] | train | https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/traverson/Traverson.java#L1031-L1043 |
mapbox/mapbox-events-android | libcore/src/main/java/com/mapbox/android/core/FileUtils.java | FileUtils.getFile | @NonNull
public static File getFile(@NonNull Context context, @NonNull String fileName) {
return new File(context.getFilesDir(), fileName);
} | java | @NonNull
public static File getFile(@NonNull Context context, @NonNull String fileName) {
return new File(context.getFilesDir(), fileName);
} | [
"@",
"NonNull",
"public",
"static",
"File",
"getFile",
"(",
"@",
"NonNull",
"Context",
"context",
",",
"@",
"NonNull",
"String",
"fileName",
")",
"{",
"return",
"new",
"File",
"(",
"context",
".",
"getFilesDir",
"(",
")",
",",
"fileName",
")",
";",
"}"
] | Return file from context.getFilesDir()/fileName
@param context application context
@param fileName path to the file
@return instance of the file object. | [
"Return",
"file",
"from",
"context",
".",
"getFilesDir",
"()",
"/",
"fileName"
] | train | https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/FileUtils.java#L37-L40 |
jbundle/webapp | base/src/main/java/org/jbundle/util/webapp/base/HttpServiceTracker.java | HttpServiceTracker.addURLPath | public static String addURLPath(String basePath, String path) {
if (basePath == null)
basePath = "";
if ((!basePath.endsWith("/")) && (!path.startsWith("/")))
path = "/" + path;
if (basePath.length() > 0)
path = basePath + path;
if (path.length() == 0)
path = "/";
else if ((path.length() > 1) && (path.endsWith("/")))
path = path.substring(0, path.length() - 1);
return path;
} | java | public static String addURLPath(String basePath, String path) {
if (basePath == null)
basePath = "";
if ((!basePath.endsWith("/")) && (!path.startsWith("/")))
path = "/" + path;
if (basePath.length() > 0)
path = basePath + path;
if (path.length() == 0)
path = "/";
else if ((path.length() > 1) && (path.endsWith("/")))
path = path.substring(0, path.length() - 1);
return path;
} | [
"public",
"static",
"String",
"addURLPath",
"(",
"String",
"basePath",
",",
"String",
"path",
")",
"{",
"if",
"(",
"basePath",
"==",
"null",
")",
"basePath",
"=",
"\"\"",
";",
"if",
"(",
"(",
"!",
"basePath",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
... | Add the base path to get an http path (**Move this to Util?**)
@param basePath
@param path
@return | [
"Add",
"the",
"base",
"path",
"to",
"get",
"an",
"http",
"path",
"(",
"**",
"Move",
"this",
"to",
"Util?",
"**",
")"
] | train | https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/base/src/main/java/org/jbundle/util/webapp/base/HttpServiceTracker.java#L207-L219 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsLinkManager.java | CmsLinkManager.getOnlineLink | public String getOnlineLink(CmsObject cms, String resourceName, boolean forceSecure) {
String result = "";
try {
CmsProject currentProject = cms.getRequestContext().getCurrentProject();
try {
cms.getRequestContext().setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID));
result = substituteLinkForUnknownTarget(cms, resourceName, forceSecure);
result = appendServerPrefix(cms, result, resourceName, false);
} finally {
cms.getRequestContext().setCurrentProject(currentProject);
}
} catch (CmsException e) {
// should never happen
result = e.getLocalizedMessage();
if (LOG.isErrorEnabled()) {
LOG.error(e.getLocalizedMessage(), e);
}
}
return result;
} | java | public String getOnlineLink(CmsObject cms, String resourceName, boolean forceSecure) {
String result = "";
try {
CmsProject currentProject = cms.getRequestContext().getCurrentProject();
try {
cms.getRequestContext().setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID));
result = substituteLinkForUnknownTarget(cms, resourceName, forceSecure);
result = appendServerPrefix(cms, result, resourceName, false);
} finally {
cms.getRequestContext().setCurrentProject(currentProject);
}
} catch (CmsException e) {
// should never happen
result = e.getLocalizedMessage();
if (LOG.isErrorEnabled()) {
LOG.error(e.getLocalizedMessage(), e);
}
}
return result;
} | [
"public",
"String",
"getOnlineLink",
"(",
"CmsObject",
"cms",
",",
"String",
"resourceName",
",",
"boolean",
"forceSecure",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"try",
"{",
"CmsProject",
"currentProject",
"=",
"cms",
".",
"getRequestContext",
"(",
"... | Returns the online link for the given resource, with full server prefix.<p>
Like <code>http://site.enterprise.com:8080/index.html</code>.<p>
In case the resource name is a full root path, the site from the root path will be used.
Otherwise the resource is assumed to be in the current site set be the OpenCms user context.<p>
Please note that this method will always return the link as it will appear in the "Online"
project, that is after the resource has been published. In case you need a method that
just returns the link with the full server prefix, use {@link #getServerLink(CmsObject, String)}.<p>
@param cms the current OpenCms user context
@param resourceName the resource to generate the online link for
@param forceSecure forces the secure server prefix if the target is secure
@return the online link for the given resource, with full server prefix
@see #getServerLink(CmsObject, String) | [
"Returns",
"the",
"online",
"link",
"for",
"the",
"given",
"resource",
"with",
"full",
"server",
"prefix",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L333-L353 |
Activiti/Activiti | activiti-engine/src/main/java/org/activiti/engine/impl/util/BitMaskUtil.java | BitMaskUtil.setBit | public static int setBit(int value, int bitNumber, boolean bitValue) {
if (bitValue) {
return setBitOn(value, bitNumber);
} else {
return setBitOff(value, bitNumber);
}
} | java | public static int setBit(int value, int bitNumber, boolean bitValue) {
if (bitValue) {
return setBitOn(value, bitNumber);
} else {
return setBitOff(value, bitNumber);
}
} | [
"public",
"static",
"int",
"setBit",
"(",
"int",
"value",
",",
"int",
"bitNumber",
",",
"boolean",
"bitValue",
")",
"{",
"if",
"(",
"bitValue",
")",
"{",
"return",
"setBitOn",
"(",
"value",
",",
"bitNumber",
")",
";",
"}",
"else",
"{",
"return",
"setBi... | Set bit to '0' or '1' in the given int.
@param current
integer value
@param bitNumber
number of the bit to set to '0' or '1' (right first bit starting at 1).
@param bitValue
if true, bit set to '1'. If false, '0'. | [
"Set",
"bit",
"to",
"0",
"or",
"1",
"in",
"the",
"given",
"int",
"."
] | train | https://github.com/Activiti/Activiti/blob/82e2b2cd2083b2f734ca0efc7815389c0f2517d9/activiti-engine/src/main/java/org/activiti/engine/impl/util/BitMaskUtil.java#L99-L105 |
CloudSlang/score | runtime-management/runtime-management-impl/src/main/java/io/cloudslang/runtime/impl/python/PythonExecutor.java | PythonExecutor.exec | public PythonExecutionResult exec(String script, Map<String, Serializable> callArguments) {
checkValidInterpreter();
initInterpreter();
prepareInterpreterContext(callArguments);
Exception originException = null;
for(int i = 0; i < RETRIES_NUMBER_ON_THREADED_ISSUE; i++) {
try {
return exec(script);
} catch (Exception e) {
if(!isThreadsRelatedModuleIssue(e)) {
throw new RuntimeException("Error executing python script: " + e, e);
}
if(originException == null) {
originException = e;
}
}
}
throw new RuntimeException("Error executing python script: " + originException, originException);
} | java | public PythonExecutionResult exec(String script, Map<String, Serializable> callArguments) {
checkValidInterpreter();
initInterpreter();
prepareInterpreterContext(callArguments);
Exception originException = null;
for(int i = 0; i < RETRIES_NUMBER_ON_THREADED_ISSUE; i++) {
try {
return exec(script);
} catch (Exception e) {
if(!isThreadsRelatedModuleIssue(e)) {
throw new RuntimeException("Error executing python script: " + e, e);
}
if(originException == null) {
originException = e;
}
}
}
throw new RuntimeException("Error executing python script: " + originException, originException);
} | [
"public",
"PythonExecutionResult",
"exec",
"(",
"String",
"script",
",",
"Map",
"<",
"String",
",",
"Serializable",
">",
"callArguments",
")",
"{",
"checkValidInterpreter",
"(",
")",
";",
"initInterpreter",
"(",
")",
";",
"prepareInterpreterContext",
"(",
"callArg... | we need this method to be synchronized so we will not have multiple scripts run in parallel on the same context | [
"we",
"need",
"this",
"method",
"to",
"be",
"synchronized",
"so",
"we",
"will",
"not",
"have",
"multiple",
"scripts",
"run",
"in",
"parallel",
"on",
"the",
"same",
"context"
] | train | https://github.com/CloudSlang/score/blob/796134e917843f4d95a90f7740d69dc5257a1a0e/runtime-management/runtime-management-impl/src/main/java/io/cloudslang/runtime/impl/python/PythonExecutor.java#L106-L125 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_storage_containerId_cors_POST | public void project_serviceName_storage_containerId_cors_POST(String serviceName, String containerId, String origin) throws IOException {
String qPath = "/cloud/project/{serviceName}/storage/{containerId}/cors";
StringBuilder sb = path(qPath, serviceName, containerId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "origin", origin);
exec(qPath, "POST", sb.toString(), o);
} | java | public void project_serviceName_storage_containerId_cors_POST(String serviceName, String containerId, String origin) throws IOException {
String qPath = "/cloud/project/{serviceName}/storage/{containerId}/cors";
StringBuilder sb = path(qPath, serviceName, containerId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "origin", origin);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"project_serviceName_storage_containerId_cors_POST",
"(",
"String",
"serviceName",
",",
"String",
"containerId",
",",
"String",
"origin",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/storage/{containerId}/cors\"",
... | Add CORS support on your container
REST: POST /cloud/project/{serviceName}/storage/{containerId}/cors
@param containerId [required] Container id
@param origin [required] Allow this origin
@param serviceName [required] Service name | [
"Add",
"CORS",
"support",
"on",
"your",
"container"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L665-L671 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/protocol/CommandArgsAccessor.java | CommandArgsAccessor.getFirstString | @SuppressWarnings("unchecked")
public static <K, V> String getFirstString(CommandArgs<K, V> commandArgs) {
for (SingularArgument singularArgument : commandArgs.singularArguments) {
if (singularArgument instanceof StringArgument) {
return ((StringArgument) singularArgument).val;
}
}
return null;
} | java | @SuppressWarnings("unchecked")
public static <K, V> String getFirstString(CommandArgs<K, V> commandArgs) {
for (SingularArgument singularArgument : commandArgs.singularArguments) {
if (singularArgument instanceof StringArgument) {
return ((StringArgument) singularArgument).val;
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"String",
"getFirstString",
"(",
"CommandArgs",
"<",
"K",
",",
"V",
">",
"commandArgs",
")",
"{",
"for",
"(",
"SingularArgument",
"singularArgument",
":",
"comma... | Get the first {@link String} argument.
@param commandArgs must not be null.
@return the first {@link String} argument or {@literal null}. | [
"Get",
"the",
"first",
"{",
"@link",
"String",
"}",
"argument",
"."
] | train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/protocol/CommandArgsAccessor.java#L58-L69 |
google/error-prone-javac | src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java | ElementFilter.methodsIn | public static Set<ExecutableElement>
methodsIn(Set<? extends Element> elements) {
return setFilter(elements, METHOD_KIND, ExecutableElement.class);
} | java | public static Set<ExecutableElement>
methodsIn(Set<? extends Element> elements) {
return setFilter(elements, METHOD_KIND, ExecutableElement.class);
} | [
"public",
"static",
"Set",
"<",
"ExecutableElement",
">",
"methodsIn",
"(",
"Set",
"<",
"?",
"extends",
"Element",
">",
"elements",
")",
"{",
"return",
"setFilter",
"(",
"elements",
",",
"METHOD_KIND",
",",
"ExecutableElement",
".",
"class",
")",
";",
"}"
] | Returns a set of methods in {@code elements}.
@return a set of methods in {@code elements}
@param elements the elements to filter | [
"Returns",
"a",
"set",
"of",
"methods",
"in",
"{"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java#L142-L145 |
deeplearning4j/deeplearning4j | nd4j/nd4j-parameter-server-parent/nd4j-parameter-server/src/main/java/org/nd4j/parameterserver/ParameterServerListener.java | ParameterServerListener.onNDArrayPartial | @Override
public synchronized void onNDArrayPartial(INDArray arr, long idx, int... dimensions) {
updater.partialUpdate(arr, updater.ndArrayHolder().get(), idx, dimensions);
} | java | @Override
public synchronized void onNDArrayPartial(INDArray arr, long idx, int... dimensions) {
updater.partialUpdate(arr, updater.ndArrayHolder().get(), idx, dimensions);
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"onNDArrayPartial",
"(",
"INDArray",
"arr",
",",
"long",
"idx",
",",
"int",
"...",
"dimensions",
")",
"{",
"updater",
".",
"partialUpdate",
"(",
"arr",
",",
"updater",
".",
"ndArrayHolder",
"(",
")",
".",
... | Used for partial updates using tensor along
dimension
@param arr the array to count as an update
@param idx the index for the tensor along dimension
@param dimensions the dimensions to act on for the tensor along dimension | [
"Used",
"for",
"partial",
"updates",
"using",
"tensor",
"along",
"dimension"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server/src/main/java/org/nd4j/parameterserver/ParameterServerListener.java#L92-L95 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/util/CmsDomUtil.java | CmsDomUtil.safeLoadStylesheets | public static void safeLoadStylesheets(String[] stylesheets, JavaScriptObject callback) {
CmsStylesheetLoader loader = new CmsStylesheetLoader(Arrays.asList(stylesheets), new Runnable() {
public native void call(JavaScriptObject jsCallback) /*-{
jsCallback();
}-*/;
public void run() {
if (callback != null) {
call(callback);
}
}
});
loader.loadWithTimeout(5000);
} | java | public static void safeLoadStylesheets(String[] stylesheets, JavaScriptObject callback) {
CmsStylesheetLoader loader = new CmsStylesheetLoader(Arrays.asList(stylesheets), new Runnable() {
public native void call(JavaScriptObject jsCallback) /*-{
jsCallback();
}-*/;
public void run() {
if (callback != null) {
call(callback);
}
}
});
loader.loadWithTimeout(5000);
} | [
"public",
"static",
"void",
"safeLoadStylesheets",
"(",
"String",
"[",
"]",
"stylesheets",
",",
"JavaScriptObject",
"callback",
")",
"{",
"CmsStylesheetLoader",
"loader",
"=",
"new",
"CmsStylesheetLoader",
"(",
"Arrays",
".",
"asList",
"(",
"stylesheets",
")",
","... | Loads a list of stylesheets and invokes a Javascript callback after everything has been loaded.<p>
@param stylesheets the array of stylesheet uris
@param callback the callback to call after everything is loaded | [
"Loads",
"a",
"list",
"of",
"stylesheets",
"and",
"invokes",
"a",
"Javascript",
"callback",
"after",
"everything",
"has",
"been",
"loaded",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/util/CmsDomUtil.java#L2009-L2026 |
jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java | FhirContext.setDefaultTypeForProfile | public void setDefaultTypeForProfile(String theProfile, Class<? extends IBaseResource> theClass) {
Validate.notBlank(theProfile, "theProfile must not be null or empty");
if (theClass == null) {
myDefaultTypeForProfile.remove(theProfile);
} else {
myDefaultTypeForProfile.put(theProfile, theClass);
}
} | java | public void setDefaultTypeForProfile(String theProfile, Class<? extends IBaseResource> theClass) {
Validate.notBlank(theProfile, "theProfile must not be null or empty");
if (theClass == null) {
myDefaultTypeForProfile.remove(theProfile);
} else {
myDefaultTypeForProfile.put(theProfile, theClass);
}
} | [
"public",
"void",
"setDefaultTypeForProfile",
"(",
"String",
"theProfile",
",",
"Class",
"<",
"?",
"extends",
"IBaseResource",
">",
"theClass",
")",
"{",
"Validate",
".",
"notBlank",
"(",
"theProfile",
",",
"\"theProfile must not be null or empty\"",
")",
";",
"if",... | Sets the default type which will be used when parsing a resource that is found to be
of the given profile.
<p>
For example, this method is invoked with the profile string of
<code>"http://example.com/some_patient_profile"</code> and the type of <code>MyPatient.class</code>,
if the parser is parsing a resource and finds that it declares that it conforms to that profile,
the <code>MyPatient</code> type will be used unless otherwise specified.
</p>
@param theProfile The profile string, e.g. <code>"http://example.com/some_patient_profile"</code>. Must not be
<code>null</code> or empty.
@param theClass The resource type, or <code>null</code> to clear any existing type | [
"Sets",
"the",
"default",
"type",
"which",
"will",
"be",
"used",
"when",
"parsing",
"a",
"resource",
"that",
"is",
"found",
"to",
"be",
"of",
"the",
"given",
"profile",
".",
"<p",
">",
"For",
"example",
"this",
"method",
"is",
"invoked",
"with",
"the",
... | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java#L830-L837 |
Commonjava/webdav-handler | common/src/main/java/net/sf/webdav/locking/LockedObject.java | LockedObject.checkChildren | private boolean checkChildren(boolean exclusive, int depth) {
if (_children == null) {
// a file
return _owner == null || !(_exclusive || exclusive);
} else {
// a folder
if (_owner == null) {
// no owner, checking children
if (depth != 0) {
boolean canLock = true;
int limit = _children.length;
for (int i = 0; i < limit; i++) {
if (!_children[i].checkChildren(exclusive, depth - 1)) {
canLock = false;
}
}
return canLock;
} else {
// depth == 0 -> we don't care for children
return true;
}
} else {
// there already is a owner
return !(_exclusive || exclusive);
}
}
} | java | private boolean checkChildren(boolean exclusive, int depth) {
if (_children == null) {
// a file
return _owner == null || !(_exclusive || exclusive);
} else {
// a folder
if (_owner == null) {
// no owner, checking children
if (depth != 0) {
boolean canLock = true;
int limit = _children.length;
for (int i = 0; i < limit; i++) {
if (!_children[i].checkChildren(exclusive, depth - 1)) {
canLock = false;
}
}
return canLock;
} else {
// depth == 0 -> we don't care for children
return true;
}
} else {
// there already is a owner
return !(_exclusive || exclusive);
}
}
} | [
"private",
"boolean",
"checkChildren",
"(",
"boolean",
"exclusive",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"_children",
"==",
"null",
")",
"{",
"// a file",
"return",
"_owner",
"==",
"null",
"||",
"!",
"(",
"_exclusive",
"||",
"exclusive",
")",
";",
"... | helper of checkLocks(). looks if the children are locked
@param exclusive
wheather the new lock should be exclusive
@return true if no locks at the children paths are forbidding a new lock
@param depth
depth | [
"helper",
"of",
"checkLocks",
"()",
".",
"looks",
"if",
"the",
"children",
"are",
"locked"
] | train | https://github.com/Commonjava/webdav-handler/blob/39bb7032fc75c1b67d3f2440dd1c234ead96cb9d/common/src/main/java/net/sf/webdav/locking/LockedObject.java#L298-L328 |
joniles/mpxj | src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java | ProjectTreeController.addCustomFields | private void addCustomFields(MpxjTreeNode parentNode, ProjectFile file)
{
for (CustomField field : file.getCustomFields())
{
final CustomField c = field;
MpxjTreeNode childNode = new MpxjTreeNode(field)
{
@Override public String toString()
{
FieldType type = c.getFieldType();
return type == null ? "(unknown)" : type.getFieldTypeClass() + "." + type.toString();
}
};
parentNode.add(childNode);
}
} | java | private void addCustomFields(MpxjTreeNode parentNode, ProjectFile file)
{
for (CustomField field : file.getCustomFields())
{
final CustomField c = field;
MpxjTreeNode childNode = new MpxjTreeNode(field)
{
@Override public String toString()
{
FieldType type = c.getFieldType();
return type == null ? "(unknown)" : type.getFieldTypeClass() + "." + type.toString();
}
};
parentNode.add(childNode);
}
} | [
"private",
"void",
"addCustomFields",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"CustomField",
"field",
":",
"file",
".",
"getCustomFields",
"(",
")",
")",
"{",
"final",
"CustomField",
"c",
"=",
"field",
";",
"MpxjT... | Add custom fields to the tree.
@param parentNode parent tree node
@param file custom fields container | [
"Add",
"custom",
"fields",
"to",
"the",
"tree",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L374-L390 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/OIDMap.java | OIDMap.addAttribute | public static void addAttribute(String name, String oid, Class<?> clazz)
throws CertificateException {
ObjectIdentifier objId;
try {
objId = new ObjectIdentifier(oid);
} catch (IOException ioe) {
throw new CertificateException
("Invalid Object identifier: " + oid);
}
OIDInfo info = new OIDInfo(name, objId, clazz);
if (oidMap.put(objId, info) != null) {
throw new CertificateException
("Object identifier already exists: " + oid);
}
if (nameMap.put(name, info) != null) {
throw new CertificateException("Name already exists: " + name);
}
} | java | public static void addAttribute(String name, String oid, Class<?> clazz)
throws CertificateException {
ObjectIdentifier objId;
try {
objId = new ObjectIdentifier(oid);
} catch (IOException ioe) {
throw new CertificateException
("Invalid Object identifier: " + oid);
}
OIDInfo info = new OIDInfo(name, objId, clazz);
if (oidMap.put(objId, info) != null) {
throw new CertificateException
("Object identifier already exists: " + oid);
}
if (nameMap.put(name, info) != null) {
throw new CertificateException("Name already exists: " + name);
}
} | [
"public",
"static",
"void",
"addAttribute",
"(",
"String",
"name",
",",
"String",
"oid",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"throws",
"CertificateException",
"{",
"ObjectIdentifier",
"objId",
";",
"try",
"{",
"objId",
"=",
"new",
"ObjectIdentifier",
... | Add a name to lookup table.
@param name the name of the attr
@param oid the string representation of the object identifier for
the class.
@param clazz the Class object associated with this attribute
@exception CertificateException on errors. | [
"Add",
"a",
"name",
"to",
"lookup",
"table",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/OIDMap.java#L213-L230 |
aoindustries/aoweb-framework | src/main/java/com/aoindustries/website/framework/WebSiteRequest.java | WebSiteRequest.printFormFields | public void printFormFields(ChainWriter out, int indent) throws IOException {
if("true".equals(req.getParameter("search_engine"))) printHiddenField(out, indent, "search_engine", "true");
} | java | public void printFormFields(ChainWriter out, int indent) throws IOException {
if("true".equals(req.getParameter("search_engine"))) printHiddenField(out, indent, "search_engine", "true");
} | [
"public",
"void",
"printFormFields",
"(",
"ChainWriter",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"if",
"(",
"\"true\"",
".",
"equals",
"(",
"req",
".",
"getParameter",
"(",
"\"search_engine\"",
")",
")",
")",
"printHiddenField",
"(",
... | Prints the hidden variables that contain all of the current settings. | [
"Prints",
"the",
"hidden",
"variables",
"that",
"contain",
"all",
"of",
"the",
"current",
"settings",
"."
] | train | https://github.com/aoindustries/aoweb-framework/blob/8e58af4f5dd898cd2fdb855ffa810a1ca6973ae0/src/main/java/com/aoindustries/website/framework/WebSiteRequest.java#L525-L527 |
phax/ph-commons | ph-json/src/main/java/com/helger/json/serialize/JsonReader.java | JsonReader.readFromPath | @Nullable
public static IJson readFromPath (@Nonnull final Path aPath, @Nonnull final Charset aFallbackCharset)
{
return readFromPath (aPath, aFallbackCharset, null);
} | java | @Nullable
public static IJson readFromPath (@Nonnull final Path aPath, @Nonnull final Charset aFallbackCharset)
{
return readFromPath (aPath, aFallbackCharset, null);
} | [
"@",
"Nullable",
"public",
"static",
"IJson",
"readFromPath",
"(",
"@",
"Nonnull",
"final",
"Path",
"aPath",
",",
"@",
"Nonnull",
"final",
"Charset",
"aFallbackCharset",
")",
"{",
"return",
"readFromPath",
"(",
"aPath",
",",
"aFallbackCharset",
",",
"null",
")... | Read the Json from the passed Path.
@param aPath
The file containing the Json to be parsed. May not be
<code>null</code>.
@param aFallbackCharset
The charset to be used in case no is BOM is present. May not be
<code>null</code>.
@return <code>null</code> if reading failed, the Json declarations
otherwise. | [
"Read",
"the",
"Json",
"from",
"the",
"passed",
"Path",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-json/src/main/java/com/helger/json/serialize/JsonReader.java#L543-L547 |
Azure/azure-sdk-for-java | iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/IotHubResourcesInner.java | IotHubResourcesInner.beginCreateOrUpdateAsync | public Observable<IotHubDescriptionInner> beginCreateOrUpdateAsync(String resourceGroupName, String resourceName, IotHubDescriptionInner iotHubDescription) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceName, iotHubDescription).map(new Func1<ServiceResponse<IotHubDescriptionInner>, IotHubDescriptionInner>() {
@Override
public IotHubDescriptionInner call(ServiceResponse<IotHubDescriptionInner> response) {
return response.body();
}
});
} | java | public Observable<IotHubDescriptionInner> beginCreateOrUpdateAsync(String resourceGroupName, String resourceName, IotHubDescriptionInner iotHubDescription) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceName, iotHubDescription).map(new Func1<ServiceResponse<IotHubDescriptionInner>, IotHubDescriptionInner>() {
@Override
public IotHubDescriptionInner call(ServiceResponse<IotHubDescriptionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"IotHubDescriptionInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"IotHubDescriptionInner",
"iotHubDescription",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",... | Create or update the metadata of an IoT hub.
Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@param iotHubDescription The IoT hub metadata and security metadata.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the IotHubDescriptionInner object | [
"Create",
"or",
"update",
"the",
"metadata",
"of",
"an",
"IoT",
"hub",
".",
"Create",
"or",
"update",
"the",
"metadata",
"of",
"an",
"Iot",
"hub",
".",
"The",
"usual",
"pattern",
"to",
"modify",
"a",
"property",
"is",
"to",
"retrieve",
"the",
"IoT",
"h... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/IotHubResourcesInner.java#L513-L520 |
structr/structr | structr-ui/src/main/java/org/structr/web/resource/RegistrationResource.java | RegistrationResource.createUser | public Principal createUser(final SecurityContext securityContext, final PropertyKey credentialKey, final String credentialValue, final Map<String, Object> propertySet, final String confKey) {
return createUser(securityContext, credentialKey, credentialValue, propertySet, false, confKey);
} | java | public Principal createUser(final SecurityContext securityContext, final PropertyKey credentialKey, final String credentialValue, final Map<String, Object> propertySet, final String confKey) {
return createUser(securityContext, credentialKey, credentialValue, propertySet, false, confKey);
} | [
"public",
"Principal",
"createUser",
"(",
"final",
"SecurityContext",
"securityContext",
",",
"final",
"PropertyKey",
"credentialKey",
",",
"final",
"String",
"credentialValue",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"propertySet",
",",
"final",
"... | Create a new user.
If a {@link Person} is found, convert that object to a {@link User} object.
Do not auto-create a new user.
@param securityContext
@param credentialKey
@param credentialValue
@param propertySet
@param confKey
@return user | [
"Create",
"a",
"new",
"user",
"."
] | train | https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-ui/src/main/java/org/structr/web/resource/RegistrationResource.java#L324-L328 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/lb/lbgroup_binding.java | lbgroup_binding.get | public static lbgroup_binding get(nitro_service service, String name) throws Exception{
lbgroup_binding obj = new lbgroup_binding();
obj.set_name(name);
lbgroup_binding response = (lbgroup_binding) obj.get_resource(service);
return response;
} | java | public static lbgroup_binding get(nitro_service service, String name) throws Exception{
lbgroup_binding obj = new lbgroup_binding();
obj.set_name(name);
lbgroup_binding response = (lbgroup_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"lbgroup_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"lbgroup_binding",
"obj",
"=",
"new",
"lbgroup_binding",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"lbg... | Use this API to fetch lbgroup_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"lbgroup_binding",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/lb/lbgroup_binding.java#L103-L108 |
gosu-lang/gosu-lang | gosu-lab/src/main/java/editor/SmartFixManager.java | SmartFixManager.getDistanceFromPosition | private double getDistanceFromPosition( IParseIssue pi, int line, int col )
{
if( pi.getSource() != null && pi.getSource().getLocation() != null )
{
int squaredDist = ((pi.getSource().getLocation().getLineNum() - line) * (pi.getSource().getLocation().getLineNum() - line)) +
((pi.getSource().getLocation().getColumn() - col) * (pi.getSource().getLocation().getColumn() - col));
return Math.sqrt( squaredDist );
}
else
{
return Double.MAX_VALUE;
}
} | java | private double getDistanceFromPosition( IParseIssue pi, int line, int col )
{
if( pi.getSource() != null && pi.getSource().getLocation() != null )
{
int squaredDist = ((pi.getSource().getLocation().getLineNum() - line) * (pi.getSource().getLocation().getLineNum() - line)) +
((pi.getSource().getLocation().getColumn() - col) * (pi.getSource().getLocation().getColumn() - col));
return Math.sqrt( squaredDist );
}
else
{
return Double.MAX_VALUE;
}
} | [
"private",
"double",
"getDistanceFromPosition",
"(",
"IParseIssue",
"pi",
",",
"int",
"line",
",",
"int",
"col",
")",
"{",
"if",
"(",
"pi",
".",
"getSource",
"(",
")",
"!=",
"null",
"&&",
"pi",
".",
"getSource",
"(",
")",
".",
"getLocation",
"(",
")",
... | Returns the cartesian distance of this parse issue from the given column/line
in column/line units | [
"Returns",
"the",
"cartesian",
"distance",
"of",
"this",
"parse",
"issue",
"from",
"the",
"given",
"column",
"/",
"line",
"in",
"column",
"/",
"line",
"units"
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-lab/src/main/java/editor/SmartFixManager.java#L1263-L1275 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/guid/Guid.java | Guid.append | public Guid append(Guid... guids) throws IOException {
if (guids == null || guids.length == 0) {
return this;
}
return combine(ArrayUtils.add(guids, this));
} | java | public Guid append(Guid... guids) throws IOException {
if (guids == null || guids.length == 0) {
return this;
}
return combine(ArrayUtils.add(guids, this));
} | [
"public",
"Guid",
"append",
"(",
"Guid",
"...",
"guids",
")",
"throws",
"IOException",
"{",
"if",
"(",
"guids",
"==",
"null",
"||",
"guids",
".",
"length",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"return",
"combine",
"(",
"ArrayUtils",
".",
... | Creates a new {@link Guid} which is a unique, replicable representation of the pair (this, guids). Equivalent to
combine(this, guid1, guid2, ...)
@param guids an array of {@link Guid}.
@return a new {@link Guid}.
@throws IOException | [
"Creates",
"a",
"new",
"{"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/guid/Guid.java#L162-L167 |
apereo/cas | core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/HttpUtils.java | HttpUtils.executeGet | public static HttpResponse executeGet(final String url,
final Map<String, Object> parameters) {
try {
return executeGet(url, null, null, parameters);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
} | java | public static HttpResponse executeGet(final String url,
final Map<String, Object> parameters) {
try {
return executeGet(url, null, null, parameters);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
} | [
"public",
"static",
"HttpResponse",
"executeGet",
"(",
"final",
"String",
"url",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"try",
"{",
"return",
"executeGet",
"(",
"url",
",",
"null",
",",
"null",
",",
"parameters",
... | Execute get http response.
@param url the url
@param parameters the parameters
@return the http response | [
"Execute",
"get",
"http",
"response",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/HttpUtils.java#L256-L264 |
jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.methodChanged | public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "methodchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeMethodInfo(oldInfo);
this.currentNode = to;
writeMethodInfo(newInfo);
this.currentNode = currentNode;
} | java | public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "methodchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeMethodInfo(oldInfo);
this.currentNode = to;
writeMethodInfo(newInfo);
this.currentNode = currentNode;
} | [
"public",
"void",
"methodChanged",
"(",
"MethodInfo",
"oldInfo",
",",
"MethodInfo",
"newInfo",
")",
"throws",
"DiffException",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",... | Write out info aboout a changed method.
This writes out a <methodchange> node, followed by a
<from> node, with the old information about the method
followed by a <to> node with the new information about the
method.
@param oldInfo Info about the old method.
@param newInfo Info about the new method.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Write",
"out",
"info",
"aboout",
"a",
"changed",
"method",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"methodchange>",
";",
"node",
"followed",
"by",
"a",
"<",
";",
"from>",
";",
"node",
"with",
"the",
"old",
"information",
"about",
"the",
"me... | train | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L433-L448 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.paymentMean_paypal_id_PUT | public void paymentMean_paypal_id_PUT(Long id, OvhPaypal body) throws IOException {
String qPath = "/me/paymentMean/paypal/{id}";
StringBuilder sb = path(qPath, id);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void paymentMean_paypal_id_PUT(Long id, OvhPaypal body) throws IOException {
String qPath = "/me/paymentMean/paypal/{id}";
StringBuilder sb = path(qPath, id);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"paymentMean_paypal_id_PUT",
"(",
"Long",
"id",
",",
"OvhPaypal",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/paymentMean/paypal/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"id",
")",
";",
... | Alter this object properties
REST: PUT /me/paymentMean/paypal/{id}
@param body [required] New object properties
@param id [required] Id of the object | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L643-L647 |
alkacon/opencms-core | src/org/opencms/db/CmsLoginManager.java | CmsLoginManager.canLockBecauseOfInactivity | public boolean canLockBecauseOfInactivity(CmsObject cms, CmsUser user) {
return !user.isManaged()
&& !user.isWebuser()
&& !OpenCms.getDefaultUsers().isDefaultUser(user.getName())
&& !OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ROOT_ADMIN);
} | java | public boolean canLockBecauseOfInactivity(CmsObject cms, CmsUser user) {
return !user.isManaged()
&& !user.isWebuser()
&& !OpenCms.getDefaultUsers().isDefaultUser(user.getName())
&& !OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ROOT_ADMIN);
} | [
"public",
"boolean",
"canLockBecauseOfInactivity",
"(",
"CmsObject",
"cms",
",",
"CmsUser",
"user",
")",
"{",
"return",
"!",
"user",
".",
"isManaged",
"(",
")",
"&&",
"!",
"user",
".",
"isWebuser",
"(",
")",
"&&",
"!",
"OpenCms",
".",
"getDefaultUsers",
"(... | Checks whether a user account can be locked because of inactivity.
@param cms the CMS context
@param user the user to check
@return true if the user may be locked after being inactive for too long | [
"Checks",
"whether",
"a",
"user",
"account",
"can",
"be",
"locked",
"because",
"of",
"inactivity",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsLoginManager.java#L265-L271 |
tvesalainen/util | util/src/main/java/org/vesalainen/util/CollectionHelp.java | CollectionHelp.print | public static final String print(String start, String delim, String quotStart, String quotEnd, String end, Object... array)
{
try
{
StringBuilder out = new StringBuilder();
print(out, start, delim, quotStart, quotEnd, end, array);
return out.toString();
}
catch (IOException ex)
{
throw new IllegalArgumentException(ex);
}
} | java | public static final String print(String start, String delim, String quotStart, String quotEnd, String end, Object... array)
{
try
{
StringBuilder out = new StringBuilder();
print(out, start, delim, quotStart, quotEnd, end, array);
return out.toString();
}
catch (IOException ex)
{
throw new IllegalArgumentException(ex);
}
} | [
"public",
"static",
"final",
"String",
"print",
"(",
"String",
"start",
",",
"String",
"delim",
",",
"String",
"quotStart",
",",
"String",
"quotEnd",
",",
"String",
"end",
",",
"Object",
"...",
"array",
")",
"{",
"try",
"{",
"StringBuilder",
"out",
"=",
... | Returns array items delimited with given strings. If any of delimiters
is null, it is ignored.
@param start
@param delim
@param quotStart
@param quotEnd
@param end
@param array
@return | [
"Returns",
"array",
"items",
"delimited",
"with",
"given",
"strings",
".",
"If",
"any",
"of",
"delimiters",
"is",
"null",
"it",
"is",
"ignored",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CollectionHelp.java#L252-L264 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/UserAPI.java | UserAPI.groupsMembersBatchUpdate | public static BaseResult groupsMembersBatchUpdate(String access_token,List<String> openid_list,String to_groupid){
String openidListStr = JsonUtil.toJSONString(openid_list);
String groupJson = "{\"openid_list\":"+openidListStr+",\"to_groupid\":"+to_groupid+"}";
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI+"/cgi-bin/groups/members/batchupdate")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(groupJson,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
} | java | public static BaseResult groupsMembersBatchUpdate(String access_token,List<String> openid_list,String to_groupid){
String openidListStr = JsonUtil.toJSONString(openid_list);
String groupJson = "{\"openid_list\":"+openidListStr+",\"to_groupid\":"+to_groupid+"}";
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI+"/cgi-bin/groups/members/batchupdate")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(groupJson,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
} | [
"public",
"static",
"BaseResult",
"groupsMembersBatchUpdate",
"(",
"String",
"access_token",
",",
"List",
"<",
"String",
">",
"openid_list",
",",
"String",
"to_groupid",
")",
"{",
"String",
"openidListStr",
"=",
"JsonUtil",
".",
"toJSONString",
"(",
"openid_list",
... | 批量移动用户分组
@param access_token access_token
@param openid_list openid_list
@param to_groupid to_groupid
@return BaseResult | [
"批量移动用户分组"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/UserAPI.java#L246-L256 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.broadcastTransaction | @Override
public TransactionBroadcast broadcastTransaction(final Transaction tx) {
return broadcastTransaction(tx, Math.max(1, getMinBroadcastConnections()));
} | java | @Override
public TransactionBroadcast broadcastTransaction(final Transaction tx) {
return broadcastTransaction(tx, Math.max(1, getMinBroadcastConnections()));
} | [
"@",
"Override",
"public",
"TransactionBroadcast",
"broadcastTransaction",
"(",
"final",
"Transaction",
"tx",
")",
"{",
"return",
"broadcastTransaction",
"(",
"tx",
",",
"Math",
".",
"max",
"(",
"1",
",",
"getMinBroadcastConnections",
"(",
")",
")",
")",
";",
... | Calls {@link PeerGroup#broadcastTransaction(Transaction,int)} with getMinBroadcastConnections() as the number
of connections to wait for before commencing broadcast. | [
"Calls",
"{"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L2019-L2022 |
lucee/Lucee | core/src/main/java/lucee/commons/date/DateTimeUtil.java | DateTimeUtil.toHTTPTimeString | public static String toHTTPTimeString(Date date, boolean oldFormat) {
if (oldFormat) {
synchronized (HTTP_TIME_STRING_FORMAT_OLD) {
return StringUtil.replace(HTTP_TIME_STRING_FORMAT_OLD.format(date), "+00:00", "", true);
}
}
synchronized (HTTP_TIME_STRING_FORMAT) {
return StringUtil.replace(HTTP_TIME_STRING_FORMAT.format(date), "+00:00", "", true);
}
} | java | public static String toHTTPTimeString(Date date, boolean oldFormat) {
if (oldFormat) {
synchronized (HTTP_TIME_STRING_FORMAT_OLD) {
return StringUtil.replace(HTTP_TIME_STRING_FORMAT_OLD.format(date), "+00:00", "", true);
}
}
synchronized (HTTP_TIME_STRING_FORMAT) {
return StringUtil.replace(HTTP_TIME_STRING_FORMAT.format(date), "+00:00", "", true);
}
} | [
"public",
"static",
"String",
"toHTTPTimeString",
"(",
"Date",
"date",
",",
"boolean",
"oldFormat",
")",
"{",
"if",
"(",
"oldFormat",
")",
"{",
"synchronized",
"(",
"HTTP_TIME_STRING_FORMAT_OLD",
")",
"{",
"return",
"StringUtil",
".",
"replace",
"(",
"HTTP_TIME_... | converts a date to a http time String
@param date date to convert
@param oldFormat "old" in that context means the format support the existing functionality in
CFML like the function getHTTPTimeString, in that format the date parts are separated
by a space (like "EE, dd MMM yyyy HH:mm:ss zz"), in the "new" format, the date part is
separated by "-" (like "EE, dd-MMM-yyyy HH:mm:ss zz")
@return | [
"converts",
"a",
"date",
"to",
"a",
"http",
"time",
"String"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/date/DateTimeUtil.java#L279-L288 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/text/codepoint/CodepointHelper.java | CodepointHelper.verify | public static void verify (@Nullable final char [] aArray, @Nonnull final ECodepointProfile eProfile)
{
if (aArray != null)
verify (new CodepointIteratorCharArray (aArray), eProfile);
} | java | public static void verify (@Nullable final char [] aArray, @Nonnull final ECodepointProfile eProfile)
{
if (aArray != null)
verify (new CodepointIteratorCharArray (aArray), eProfile);
} | [
"public",
"static",
"void",
"verify",
"(",
"@",
"Nullable",
"final",
"char",
"[",
"]",
"aArray",
",",
"@",
"Nonnull",
"final",
"ECodepointProfile",
"eProfile",
")",
"{",
"if",
"(",
"aArray",
"!=",
"null",
")",
"verify",
"(",
"new",
"CodepointIteratorCharArra... | Verifies a sequence of codepoints using the specified profile
@param aArray
char array
@param eProfile
profile to use | [
"Verifies",
"a",
"sequence",
"of",
"codepoints",
"using",
"the",
"specified",
"profile"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/text/codepoint/CodepointHelper.java#L775-L779 |
windup/windup | rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/MavenCoord.java | MavenCoord.fromGAVPC | public static MavenCoord fromGAVPC(String coordGavpc)
{
Matcher mat = REGEX_GAVCP.matcher(coordGavpc);
if (!mat.matches())
throw new IllegalArgumentException("Wrong Maven coordinates format, must be G:A:V[:P[:C]] . " + coordGavpc);
return new MavenCoord()
.setGroupId(mat.group(1))
.setArtifactId(mat.group(2))
.setVersion(mat.group(3))
.setPackaging(mat.group(4))
.setClassifier(mat.group(5));
} | java | public static MavenCoord fromGAVPC(String coordGavpc)
{
Matcher mat = REGEX_GAVCP.matcher(coordGavpc);
if (!mat.matches())
throw new IllegalArgumentException("Wrong Maven coordinates format, must be G:A:V[:P[:C]] . " + coordGavpc);
return new MavenCoord()
.setGroupId(mat.group(1))
.setArtifactId(mat.group(2))
.setVersion(mat.group(3))
.setPackaging(mat.group(4))
.setClassifier(mat.group(5));
} | [
"public",
"static",
"MavenCoord",
"fromGAVPC",
"(",
"String",
"coordGavpc",
")",
"{",
"Matcher",
"mat",
"=",
"REGEX_GAVCP",
".",
"matcher",
"(",
"coordGavpc",
")",
";",
"if",
"(",
"!",
"mat",
".",
"matches",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentE... | Creates a {@link MavenCoord} from the given coordinate String. | [
"Creates",
"a",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/MavenCoord.java#L55-L67 |
jayantk/jklol | src/com/jayantkrish/jklol/lisp/Environment.java | Environment.unbindName | public Object unbindName(String name, IndexedList<String> symbolTable) {
if (!symbolTable.contains(name)) {
return null;
}
int index = symbolTable.getIndex(name);
return bindings.remove(index);
} | java | public Object unbindName(String name, IndexedList<String> symbolTable) {
if (!symbolTable.contains(name)) {
return null;
}
int index = symbolTable.getIndex(name);
return bindings.remove(index);
} | [
"public",
"Object",
"unbindName",
"(",
"String",
"name",
",",
"IndexedList",
"<",
"String",
">",
"symbolTable",
")",
"{",
"if",
"(",
"!",
"symbolTable",
".",
"contains",
"(",
"name",
")",
")",
"{",
"return",
"null",
";",
"}",
"int",
"index",
"=",
"symb... | Removes a binding from this environment. Returns the value
bound to that name if the name was bound, otherwise returns
{@code null}.
@param name
@param symbolTable
@return | [
"Removes",
"a",
"binding",
"from",
"this",
"environment",
".",
"Returns",
"the",
"value",
"bound",
"to",
"that",
"name",
"if",
"the",
"name",
"was",
"bound",
"otherwise",
"returns",
"{",
"@code",
"null",
"}",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/lisp/Environment.java#L80-L86 |
ontop/ontop | core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java | OntologyBuilderImpl.createObjectPropertyAssertion | public static ObjectPropertyAssertion createObjectPropertyAssertion(ObjectPropertyExpression ope, ObjectConstant o1, ObjectConstant o2) throws InconsistentOntologyException {
if (ope.isTop())
return null;
if (ope.isBottom())
throw new InconsistentOntologyException();
if (ope.isInverse())
return new ObjectPropertyAssertionImpl(ope.getInverse(), o2, o1);
else
return new ObjectPropertyAssertionImpl(ope, o1, o2);
} | java | public static ObjectPropertyAssertion createObjectPropertyAssertion(ObjectPropertyExpression ope, ObjectConstant o1, ObjectConstant o2) throws InconsistentOntologyException {
if (ope.isTop())
return null;
if (ope.isBottom())
throw new InconsistentOntologyException();
if (ope.isInverse())
return new ObjectPropertyAssertionImpl(ope.getInverse(), o2, o1);
else
return new ObjectPropertyAssertionImpl(ope, o1, o2);
} | [
"public",
"static",
"ObjectPropertyAssertion",
"createObjectPropertyAssertion",
"(",
"ObjectPropertyExpression",
"ope",
",",
"ObjectConstant",
"o1",
",",
"ObjectConstant",
"o2",
")",
"throws",
"InconsistentOntologyException",
"{",
"if",
"(",
"ope",
".",
"isTop",
"(",
")... | Creates an object property assertion
<p>
ObjectPropertyAssertion := 'ObjectPropertyAssertion' '(' axiomAnnotations
ObjectPropertyExpression sourceIndividual targetIndividual ')'
<p>
Implements rule [O4]:
- ignore (return null) if the property is top
- inconsistency if the property is bot
- swap the arguments to eliminate inverses | [
"Creates",
"an",
"object",
"property",
"assertion",
"<p",
">",
"ObjectPropertyAssertion",
":",
"=",
"ObjectPropertyAssertion",
"(",
"axiomAnnotations",
"ObjectPropertyExpression",
"sourceIndividual",
"targetIndividual",
")",
"<p",
">",
"Implements",
"rule",
"[",
"O4",
"... | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java#L457-L467 |
molgenis/molgenis | molgenis-navigator/src/main/java/org/molgenis/navigator/copy/service/LabelGenerator.java | LabelGenerator.generateUniqueLabel | static String generateUniqueLabel(String label, Set<String> existingLabels) {
StringBuilder newLabel = new StringBuilder(label);
while (existingLabels.contains(newLabel.toString())) {
newLabel.append(POSTFIX);
}
return newLabel.toString();
} | java | static String generateUniqueLabel(String label, Set<String> existingLabels) {
StringBuilder newLabel = new StringBuilder(label);
while (existingLabels.contains(newLabel.toString())) {
newLabel.append(POSTFIX);
}
return newLabel.toString();
} | [
"static",
"String",
"generateUniqueLabel",
"(",
"String",
"label",
",",
"Set",
"<",
"String",
">",
"existingLabels",
")",
"{",
"StringBuilder",
"newLabel",
"=",
"new",
"StringBuilder",
"(",
"label",
")",
";",
"while",
"(",
"existingLabels",
".",
"contains",
"(... | Makes sure that a given label will be unique amongst a set of other labels. | [
"Makes",
"sure",
"that",
"a",
"given",
"label",
"will",
"be",
"unique",
"amongst",
"a",
"set",
"of",
"other",
"labels",
"."
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-navigator/src/main/java/org/molgenis/navigator/copy/service/LabelGenerator.java#L11-L17 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/clientlibs/handle/ClientlibExternalUri.java | ClientlibExternalUri.accept | @Override
public void accept(ClientlibVisitor visitor, ClientlibVisitor.VisitorMode mode, ClientlibResourceFolder parent) {
visitor.visit(this, ClientlibVisitor.VisitorMode.DEPENDS, parent);
} | java | @Override
public void accept(ClientlibVisitor visitor, ClientlibVisitor.VisitorMode mode, ClientlibResourceFolder parent) {
visitor.visit(this, ClientlibVisitor.VisitorMode.DEPENDS, parent);
} | [
"@",
"Override",
"public",
"void",
"accept",
"(",
"ClientlibVisitor",
"visitor",
",",
"ClientlibVisitor",
".",
"VisitorMode",
"mode",
",",
"ClientlibResourceFolder",
"parent",
")",
"{",
"visitor",
".",
"visit",
"(",
"this",
",",
"ClientlibVisitor",
".",
"VisitorMo... | Calls the visitor with mode {@link com.composum.sling.clientlibs.handle.ClientlibVisitor.VisitorMode#DEPENDS},
since external references are never embedded. | [
"Calls",
"the",
"visitor",
"with",
"mode",
"{"
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/clientlibs/handle/ClientlibExternalUri.java#L29-L32 |
fuzzylite/jfuzzylite | jfuzzylite/src/main/java/com/fuzzylite/term/Function.java | Function.evaluate | public double evaluate(Map<String, Double> localVariables) {
if (this.root == null) {
throw new RuntimeException("[function error] evaluation failed " +
"because function is not loaded");
}
return this.root.evaluate(localVariables);
} | java | public double evaluate(Map<String, Double> localVariables) {
if (this.root == null) {
throw new RuntimeException("[function error] evaluation failed " +
"because function is not loaded");
}
return this.root.evaluate(localVariables);
} | [
"public",
"double",
"evaluate",
"(",
"Map",
"<",
"String",
",",
"Double",
">",
"localVariables",
")",
"{",
"if",
"(",
"this",
".",
"root",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"[function error] evaluation failed \"",
"+",
"\"becau... | Computes the function value of this term using the given map of variable
substitutions.
@param localVariables is a map of substitution variables
@return the function value of this term using the given map of variable
substitutions. | [
"Computes",
"the",
"function",
"value",
"of",
"this",
"term",
"using",
"the",
"given",
"map",
"of",
"variable",
"substitutions",
"."
] | train | https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/term/Function.java#L592-L598 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/mediaservices/v2018_07_01/implementation/ContentKeyPoliciesInner.java | ContentKeyPoliciesInner.listAsync | public Observable<Page<ContentKeyPolicyInner>> listAsync(final String resourceGroupName, final String accountName, final String filter, final Integer top, final String orderby) {
return listWithServiceResponseAsync(resourceGroupName, accountName, filter, top, orderby)
.map(new Func1<ServiceResponse<Page<ContentKeyPolicyInner>>, Page<ContentKeyPolicyInner>>() {
@Override
public Page<ContentKeyPolicyInner> call(ServiceResponse<Page<ContentKeyPolicyInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ContentKeyPolicyInner>> listAsync(final String resourceGroupName, final String accountName, final String filter, final Integer top, final String orderby) {
return listWithServiceResponseAsync(resourceGroupName, accountName, filter, top, orderby)
.map(new Func1<ServiceResponse<Page<ContentKeyPolicyInner>>, Page<ContentKeyPolicyInner>>() {
@Override
public Page<ContentKeyPolicyInner> call(ServiceResponse<Page<ContentKeyPolicyInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ContentKeyPolicyInner",
">",
">",
"listAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"accountName",
",",
"final",
"String",
"filter",
",",
"final",
"Integer",
"top",
",",
"final",
"String"... | List Content Key Policies.
Lists the Content Key Policies in the account.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param filter Restricts the set of items returned.
@param top Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n.
@param orderby Specifies the the key by which the result collection should be ordered.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ContentKeyPolicyInner> object | [
"List",
"Content",
"Key",
"Policies",
".",
"Lists",
"the",
"Content",
"Key",
"Policies",
"in",
"the",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/mediaservices/v2018_07_01/implementation/ContentKeyPoliciesInner.java#L281-L289 |
PuyallupFoursquare/ccb-api-client-java | src/main/java/com/p4square/ccbapi/CCBAPIClient.java | CCBAPIClient.makeURI | private URI makeURI(final String service, final Map<String, String> parameters) {
try {
StringBuilder queryStringBuilder = new StringBuilder();
if (apiBaseUri.getQuery() != null) {
queryStringBuilder.append(apiBaseUri.getQuery()).append("&");
}
queryStringBuilder.append("srv=").append(service);
for (Map.Entry<String, String> entry: parameters.entrySet()) {
queryStringBuilder.append("&").append(entry.getKey()).append("=").append(entry.getValue());
}
return new URI(apiBaseUri.getScheme(), apiBaseUri.getAuthority(), apiBaseUri.getPath(),
queryStringBuilder.toString(), apiBaseUri.getFragment());
} catch (URISyntaxException e) {
// This shouldn't happen, but needs to be caught regardless.
throw new AssertionError("Could not construct API URI", e);
}
} | java | private URI makeURI(final String service, final Map<String, String> parameters) {
try {
StringBuilder queryStringBuilder = new StringBuilder();
if (apiBaseUri.getQuery() != null) {
queryStringBuilder.append(apiBaseUri.getQuery()).append("&");
}
queryStringBuilder.append("srv=").append(service);
for (Map.Entry<String, String> entry: parameters.entrySet()) {
queryStringBuilder.append("&").append(entry.getKey()).append("=").append(entry.getValue());
}
return new URI(apiBaseUri.getScheme(), apiBaseUri.getAuthority(), apiBaseUri.getPath(),
queryStringBuilder.toString(), apiBaseUri.getFragment());
} catch (URISyntaxException e) {
// This shouldn't happen, but needs to be caught regardless.
throw new AssertionError("Could not construct API URI", e);
}
} | [
"private",
"URI",
"makeURI",
"(",
"final",
"String",
"service",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"try",
"{",
"StringBuilder",
"queryStringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"apiBa... | Build the URI for a particular service call.
@param service The CCB API service to call (i.e. the srv query parameter).
@param parameters A map of query parameters to include on the URI.
@return The apiBaseUri with the additional query parameters appended. | [
"Build",
"the",
"URI",
"for",
"a",
"particular",
"service",
"call",
"."
] | train | https://github.com/PuyallupFoursquare/ccb-api-client-java/blob/54a7a3184dc565fe513aa520e1344b2303ea6834/src/main/java/com/p4square/ccbapi/CCBAPIClient.java#L217-L233 |
mozilla/rhino | src/org/mozilla/javascript/ScriptableObject.java | ScriptableObject.putConst | @Override
public void putConst(String name, Scriptable start, Object value)
{
if (putConstImpl(name, 0, start, value, READONLY))
return;
if (start == this) throw Kit.codeBug();
if (start instanceof ConstProperties)
((ConstProperties)start).putConst(name, start, value);
else
start.put(name, start, value);
} | java | @Override
public void putConst(String name, Scriptable start, Object value)
{
if (putConstImpl(name, 0, start, value, READONLY))
return;
if (start == this) throw Kit.codeBug();
if (start instanceof ConstProperties)
((ConstProperties)start).putConst(name, start, value);
else
start.put(name, start, value);
} | [
"@",
"Override",
"public",
"void",
"putConst",
"(",
"String",
"name",
",",
"Scriptable",
"start",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"putConstImpl",
"(",
"name",
",",
"0",
",",
"start",
",",
"value",
",",
"READONLY",
")",
")",
"return",
";",
... | Sets the value of the named const property, creating it if need be.
If the property was created using defineProperty, the
appropriate setter method is called. <p>
If the property's attributes include READONLY, no action is
taken.
This method will actually set the property in the start
object.
@param name the name of the property
@param start the object whose property is being set
@param value value to set the property to | [
"Sets",
"the",
"value",
"of",
"the",
"named",
"const",
"property",
"creating",
"it",
"if",
"need",
"be",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L626-L637 |
jparsec/jparsec | jparsec/src/main/java/org/jparsec/OperatorTable.java | OperatorTable.infixl | public OperatorTable<T> infixl(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.LASSOC));
return this;
} | java | public OperatorTable<T> infixl(
Parser<? extends BiFunction<? super T, ? super T, ? extends T>> parser, int precedence) {
ops.add(new Operator(parser, precedence, Associativity.LASSOC));
return this;
} | [
"public",
"OperatorTable",
"<",
"T",
">",
"infixl",
"(",
"Parser",
"<",
"?",
"extends",
"BiFunction",
"<",
"?",
"super",
"T",
",",
"?",
"super",
"T",
",",
"?",
"extends",
"T",
">",
">",
"parser",
",",
"int",
"precedence",
")",
"{",
"ops",
".",
"add... | Adds an infix left-associative binary operator.
@param parser the parser for the operator.
@param precedence the precedence number.
@return this. | [
"Adds",
"an",
"infix",
"left",
"-",
"associative",
"binary",
"operator",
"."
] | train | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/OperatorTable.java#L115-L119 |
weld/core | impl/src/main/java/org/jboss/weld/util/BeanMethods.java | BeanMethods.getMethods | private static <T, R> R getMethods(EnhancedAnnotatedType<T> type, MethodListBuilder<T, R> builder) {
Collection<EnhancedAnnotatedMethod<?, ? super T>> methods = filterMethods(builder.getAllMethods(type));
for (Class<? super T> clazz = type.getJavaClass(); clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) {
builder.levelStart(clazz);
for (EnhancedAnnotatedMethod<?, ? super T> method : methods) {
if (method.getJavaMember().getDeclaringClass().equals(clazz)) {
builder.processMethod(method);
}
}
builder.levelFinish();
}
return builder.create();
} | java | private static <T, R> R getMethods(EnhancedAnnotatedType<T> type, MethodListBuilder<T, R> builder) {
Collection<EnhancedAnnotatedMethod<?, ? super T>> methods = filterMethods(builder.getAllMethods(type));
for (Class<? super T> clazz = type.getJavaClass(); clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) {
builder.levelStart(clazz);
for (EnhancedAnnotatedMethod<?, ? super T> method : methods) {
if (method.getJavaMember().getDeclaringClass().equals(clazz)) {
builder.processMethod(method);
}
}
builder.levelFinish();
}
return builder.create();
} | [
"private",
"static",
"<",
"T",
",",
"R",
">",
"R",
"getMethods",
"(",
"EnhancedAnnotatedType",
"<",
"T",
">",
"type",
",",
"MethodListBuilder",
"<",
"T",
",",
"R",
">",
"builder",
")",
"{",
"Collection",
"<",
"EnhancedAnnotatedMethod",
"<",
"?",
",",
"?"... | Get all methods of a given kind using a given {@link MethodListBuilder}. | [
"Get",
"all",
"methods",
"of",
"a",
"given",
"kind",
"using",
"a",
"given",
"{"
] | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/BeanMethods.java#L115-L127 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.revokeResourcePermission | public Map<String, Map<String, List<String>>> revokeResourcePermission(String subjectid, String resourcePath) {
if (StringUtils.isBlank(subjectid) || StringUtils.isBlank(resourcePath)) {
return Collections.emptyMap();
}
resourcePath = Utils.urlEncode(resourcePath);
return getEntity(invokeDelete(Utils.formatMessage("_permissions/{0}/{1}", subjectid, resourcePath),
null), Map.class);
} | java | public Map<String, Map<String, List<String>>> revokeResourcePermission(String subjectid, String resourcePath) {
if (StringUtils.isBlank(subjectid) || StringUtils.isBlank(resourcePath)) {
return Collections.emptyMap();
}
resourcePath = Utils.urlEncode(resourcePath);
return getEntity(invokeDelete(Utils.formatMessage("_permissions/{0}/{1}", subjectid, resourcePath),
null), Map.class);
} | [
"public",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"revokeResourcePermission",
"(",
"String",
"subjectid",
",",
"String",
"resourcePath",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"subjectid... | Revokes a permission for a subject, meaning they no longer will be able to access the given resource.
@param subjectid subject id (user id)
@param resourcePath resource path or object type
@return a map of the permissions for this subject id | [
"Revokes",
"a",
"permission",
"for",
"a",
"subject",
"meaning",
"they",
"no",
"longer",
"will",
"be",
"able",
"to",
"access",
"the",
"given",
"resource",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L1463-L1470 |
gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.setUploadStatusDelegate | protected static void setUploadStatusDelegate(String uploadId, UploadStatusDelegate delegate) {
if (delegate == null)
return;
uploadDelegates.put(uploadId, new WeakReference<>(delegate));
} | java | protected static void setUploadStatusDelegate(String uploadId, UploadStatusDelegate delegate) {
if (delegate == null)
return;
uploadDelegates.put(uploadId, new WeakReference<>(delegate));
} | [
"protected",
"static",
"void",
"setUploadStatusDelegate",
"(",
"String",
"uploadId",
",",
"UploadStatusDelegate",
"delegate",
")",
"{",
"if",
"(",
"delegate",
"==",
"null",
")",
"return",
";",
"uploadDelegates",
".",
"put",
"(",
"uploadId",
",",
"new",
"WeakRefe... | Sets the delegate which will receive the events for the given upload request.
Those events will not be sent in broadcast, but only to the delegate.
@param uploadId uploadID of the upload request
@param delegate the delegate instance | [
"Sets",
"the",
"delegate",
"which",
"will",
"receive",
"the",
"events",
"for",
"the",
"given",
"upload",
"request",
".",
"Those",
"events",
"will",
"not",
"be",
"sent",
"in",
"broadcast",
"but",
"only",
"to",
"the",
"delegate",
"."
] | train | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L423-L428 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.