repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
GumTreeDiff/gumtree
|
core/src/main/java/com/github/gumtreediff/tree/TreeContext.java
|
TreeContext.setMetadata
|
public Object setMetadata(ITree node, String key, Object value) {
"""
Store a local metadata
@param key of the metadata
@param value of the metadata
@return the previous value of metadata if existed or null
"""
if (node == null)
return setMetadata(key, value);
else {
Object res = node.setMetadata(key, value);
if (res == null)
return getMetadata(key);
return res;
}
}
|
java
|
public Object setMetadata(ITree node, String key, Object value) {
if (node == null)
return setMetadata(key, value);
else {
Object res = node.setMetadata(key, value);
if (res == null)
return getMetadata(key);
return res;
}
}
|
[
"public",
"Object",
"setMetadata",
"(",
"ITree",
"node",
",",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"return",
"setMetadata",
"(",
"key",
",",
"value",
")",
";",
"else",
"{",
"Object",
"res",
"=",
"node",
".",
"setMetadata",
"(",
"key",
",",
"value",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"return",
"getMetadata",
"(",
"key",
")",
";",
"return",
"res",
";",
"}",
"}"
] |
Store a local metadata
@param key of the metadata
@param value of the metadata
@return the previous value of metadata if existed or null
|
[
"Store",
"a",
"local",
"metadata"
] |
train
|
https://github.com/GumTreeDiff/gumtree/blob/a772d4d652af44bff22c38a234ddffbfbd365a37/core/src/main/java/com/github/gumtreediff/tree/TreeContext.java#L108-L117
|
vdmeer/skb-java-base
|
src/main/java/de/vandermeer/skb/base/shell/Ci_ScRun.java
|
Ci_ScRun.interpretLs
|
protected int interpretLs(LineParser lp, MessageMgr mm) {
"""
Interprets the actual ls command
@param lp line parser
@param mm the message manager to use for reporting errors, warnings, and infos
@return 0 for success, non-zero otherwise
"""
String directory = lp.getArgs();
IOFileFilter fileFilter = new WildcardFileFilter(new String[]{
"*.ssc"
});
DirectoryLoader dl = new CommonsDirectoryWalker(directory, DirectoryFileFilter.INSTANCE, fileFilter);
if(dl.getLoadErrors().hasErrors()){
mm.report(dl.getLoadErrors());
return 1;
}
FileSourceList fsl = dl.load();
if(dl.getLoadErrors().hasErrors()){
mm.report(dl.getLoadErrors());
return 1;
}
for(FileSource fs : fsl.getSource()){
//TODO need to adapt to new source return
mm.report(MessageMgr.createInfoMessage("script file - dir <{}> file <{}>", directory, fs.getBaseFileName()));
}
return 0;
}
|
java
|
protected int interpretLs(LineParser lp, MessageMgr mm){
String directory = lp.getArgs();
IOFileFilter fileFilter = new WildcardFileFilter(new String[]{
"*.ssc"
});
DirectoryLoader dl = new CommonsDirectoryWalker(directory, DirectoryFileFilter.INSTANCE, fileFilter);
if(dl.getLoadErrors().hasErrors()){
mm.report(dl.getLoadErrors());
return 1;
}
FileSourceList fsl = dl.load();
if(dl.getLoadErrors().hasErrors()){
mm.report(dl.getLoadErrors());
return 1;
}
for(FileSource fs : fsl.getSource()){
//TODO need to adapt to new source return
mm.report(MessageMgr.createInfoMessage("script file - dir <{}> file <{}>", directory, fs.getBaseFileName()));
}
return 0;
}
|
[
"protected",
"int",
"interpretLs",
"(",
"LineParser",
"lp",
",",
"MessageMgr",
"mm",
")",
"{",
"String",
"directory",
"=",
"lp",
".",
"getArgs",
"(",
")",
";",
"IOFileFilter",
"fileFilter",
"=",
"new",
"WildcardFileFilter",
"(",
"new",
"String",
"[",
"]",
"{",
"\"*.ssc\"",
"}",
")",
";",
"DirectoryLoader",
"dl",
"=",
"new",
"CommonsDirectoryWalker",
"(",
"directory",
",",
"DirectoryFileFilter",
".",
"INSTANCE",
",",
"fileFilter",
")",
";",
"if",
"(",
"dl",
".",
"getLoadErrors",
"(",
")",
".",
"hasErrors",
"(",
")",
")",
"{",
"mm",
".",
"report",
"(",
"dl",
".",
"getLoadErrors",
"(",
")",
")",
";",
"return",
"1",
";",
"}",
"FileSourceList",
"fsl",
"=",
"dl",
".",
"load",
"(",
")",
";",
"if",
"(",
"dl",
".",
"getLoadErrors",
"(",
")",
".",
"hasErrors",
"(",
")",
")",
"{",
"mm",
".",
"report",
"(",
"dl",
".",
"getLoadErrors",
"(",
")",
")",
";",
"return",
"1",
";",
"}",
"for",
"(",
"FileSource",
"fs",
":",
"fsl",
".",
"getSource",
"(",
")",
")",
"{",
"//TODO need to adapt to new source return",
"mm",
".",
"report",
"(",
"MessageMgr",
".",
"createInfoMessage",
"(",
"\"script file - dir <{}> file <{}>\"",
",",
"directory",
",",
"fs",
".",
"getBaseFileName",
"(",
")",
")",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Interprets the actual ls command
@param lp line parser
@param mm the message manager to use for reporting errors, warnings, and infos
@return 0 for success, non-zero otherwise
|
[
"Interprets",
"the",
"actual",
"ls",
"command"
] |
train
|
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/shell/Ci_ScRun.java#L162-L182
|
podio/podio-java
|
src/main/java/com/podio/calendar/CalendarAPI.java
|
CalendarAPI.getSpace
|
public List<Event> getSpace(int spaceId, LocalDate dateFrom,
LocalDate dateTo, ReferenceType... types) {
"""
Returns all items and tasks that the user have access to in the given
space. Tasks with reference to other spaces are not returned or tasks
with no reference.
@param spaceId
The id of the space
@param dateFrom
The from date
@param dateTo
The to date
@param types
The types of events that should be returned. Leave out to get
all types of events.
@return The events in the calendar
"""
return getCalendar("space/" + spaceId, dateFrom, dateTo, null, types);
}
|
java
|
public List<Event> getSpace(int spaceId, LocalDate dateFrom,
LocalDate dateTo, ReferenceType... types) {
return getCalendar("space/" + spaceId, dateFrom, dateTo, null, types);
}
|
[
"public",
"List",
"<",
"Event",
">",
"getSpace",
"(",
"int",
"spaceId",
",",
"LocalDate",
"dateFrom",
",",
"LocalDate",
"dateTo",
",",
"ReferenceType",
"...",
"types",
")",
"{",
"return",
"getCalendar",
"(",
"\"space/\"",
"+",
"spaceId",
",",
"dateFrom",
",",
"dateTo",
",",
"null",
",",
"types",
")",
";",
"}"
] |
Returns all items and tasks that the user have access to in the given
space. Tasks with reference to other spaces are not returned or tasks
with no reference.
@param spaceId
The id of the space
@param dateFrom
The from date
@param dateTo
The to date
@param types
The types of events that should be returned. Leave out to get
all types of events.
@return The events in the calendar
|
[
"Returns",
"all",
"items",
"and",
"tasks",
"that",
"the",
"user",
"have",
"access",
"to",
"in",
"the",
"given",
"space",
".",
"Tasks",
"with",
"reference",
"to",
"other",
"spaces",
"are",
"not",
"returned",
"or",
"tasks",
"with",
"no",
"reference",
"."
] |
train
|
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/calendar/CalendarAPI.java#L84-L87
|
wcm-io/wcm-io-wcm
|
ui/extjs/src/main/java/io/wcm/wcm/ui/extjs/provider/AbstractPageTreeProvider.java
|
AbstractPageTreeProvider.getPages
|
protected final JSONArray getPages(Iterator<Page> pages, int depth, PageFilter pageFilter) throws JSONException {
"""
Generate JSON objects for pages.
@param pages Child page iterator
@param depth Depth
@param pageFilter Page filter
@return Page array
@throws JSONException JSON exception
"""
JSONArray pagesArray = new JSONArray();
while (pages.hasNext()) {
Page page = pages.next();
// map page attributes to JSON object
JSONObject pageObject = getPage(page);
if (pageObject != null) {
// write children
Iterator<Page> children = listChildren(page.adaptTo(Resource.class), pageFilter);
if (!children.hasNext()) {
pageObject.put("leaf", true);
}
else if (depth < getMaxDepth() - 1) {
pageObject.put("children", getPages(children, depth + 1, pageFilter));
}
pagesArray.put(pageObject);
}
}
return pagesArray;
}
|
java
|
protected final JSONArray getPages(Iterator<Page> pages, int depth, PageFilter pageFilter) throws JSONException {
JSONArray pagesArray = new JSONArray();
while (pages.hasNext()) {
Page page = pages.next();
// map page attributes to JSON object
JSONObject pageObject = getPage(page);
if (pageObject != null) {
// write children
Iterator<Page> children = listChildren(page.adaptTo(Resource.class), pageFilter);
if (!children.hasNext()) {
pageObject.put("leaf", true);
}
else if (depth < getMaxDepth() - 1) {
pageObject.put("children", getPages(children, depth + 1, pageFilter));
}
pagesArray.put(pageObject);
}
}
return pagesArray;
}
|
[
"protected",
"final",
"JSONArray",
"getPages",
"(",
"Iterator",
"<",
"Page",
">",
"pages",
",",
"int",
"depth",
",",
"PageFilter",
"pageFilter",
")",
"throws",
"JSONException",
"{",
"JSONArray",
"pagesArray",
"=",
"new",
"JSONArray",
"(",
")",
";",
"while",
"(",
"pages",
".",
"hasNext",
"(",
")",
")",
"{",
"Page",
"page",
"=",
"pages",
".",
"next",
"(",
")",
";",
"// map page attributes to JSON object",
"JSONObject",
"pageObject",
"=",
"getPage",
"(",
"page",
")",
";",
"if",
"(",
"pageObject",
"!=",
"null",
")",
"{",
"// write children",
"Iterator",
"<",
"Page",
">",
"children",
"=",
"listChildren",
"(",
"page",
".",
"adaptTo",
"(",
"Resource",
".",
"class",
")",
",",
"pageFilter",
")",
";",
"if",
"(",
"!",
"children",
".",
"hasNext",
"(",
")",
")",
"{",
"pageObject",
".",
"put",
"(",
"\"leaf\"",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"depth",
"<",
"getMaxDepth",
"(",
")",
"-",
"1",
")",
"{",
"pageObject",
".",
"put",
"(",
"\"children\"",
",",
"getPages",
"(",
"children",
",",
"depth",
"+",
"1",
",",
"pageFilter",
")",
")",
";",
"}",
"pagesArray",
".",
"put",
"(",
"pageObject",
")",
";",
"}",
"}",
"return",
"pagesArray",
";",
"}"
] |
Generate JSON objects for pages.
@param pages Child page iterator
@param depth Depth
@param pageFilter Page filter
@return Page array
@throws JSONException JSON exception
|
[
"Generate",
"JSON",
"objects",
"for",
"pages",
"."
] |
train
|
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/extjs/src/main/java/io/wcm/wcm/ui/extjs/provider/AbstractPageTreeProvider.java#L59-L83
|
moleculer-java/moleculer-java
|
src/main/java/services/moleculer/eventbus/EventEmitter.java
|
EventEmitter.broadcastLocal
|
public void broadcastLocal(String name, Tree payload, Groups groups) {
"""
Emits a <b>LOCAL</b> event to <b>ALL</b> listeners from the specified
event group(s), who are listening this event. Sample code:<br>
<br>
Tree params = new Tree();<br>
params.put("a", true);<br>
params.putList("b").add(1).add(2).add(3);<br>
ctx.broadcastLocal("user.created", params, Groups.of("group1",
"group2"));
@param name
name of event (eg. "user.modified")
@param payload
{@link Tree} structure (payload of the event)
@param groups
{@link Groups event group} container
"""
eventbus.broadcast(name, payload, groups, true);
}
|
java
|
public void broadcastLocal(String name, Tree payload, Groups groups) {
eventbus.broadcast(name, payload, groups, true);
}
|
[
"public",
"void",
"broadcastLocal",
"(",
"String",
"name",
",",
"Tree",
"payload",
",",
"Groups",
"groups",
")",
"{",
"eventbus",
".",
"broadcast",
"(",
"name",
",",
"payload",
",",
"groups",
",",
"true",
")",
";",
"}"
] |
Emits a <b>LOCAL</b> event to <b>ALL</b> listeners from the specified
event group(s), who are listening this event. Sample code:<br>
<br>
Tree params = new Tree();<br>
params.put("a", true);<br>
params.putList("b").add(1).add(2).add(3);<br>
ctx.broadcastLocal("user.created", params, Groups.of("group1",
"group2"));
@param name
name of event (eg. "user.modified")
@param payload
{@link Tree} structure (payload of the event)
@param groups
{@link Groups event group} container
|
[
"Emits",
"a",
"<b",
">",
"LOCAL<",
"/",
"b",
">",
"event",
"to",
"<b",
">",
"ALL<",
"/",
"b",
">",
"listeners",
"from",
"the",
"specified",
"event",
"group",
"(",
"s",
")",
"who",
"are",
"listening",
"this",
"event",
".",
"Sample",
"code",
":",
"<br",
">",
"<br",
">",
"Tree",
"params",
"=",
"new",
"Tree",
"()",
";",
"<br",
">",
"params",
".",
"put",
"(",
"a",
"true",
")",
";",
"<br",
">",
"params",
".",
"putList",
"(",
"b",
")",
".",
"add",
"(",
"1",
")",
".",
"add",
"(",
"2",
")",
".",
"add",
"(",
"3",
")",
";",
"<br",
">",
"ctx",
".",
"broadcastLocal",
"(",
"user",
".",
"created",
"params",
"Groups",
".",
"of",
"(",
"group1",
"group2",
"))",
";"
] |
train
|
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/eventbus/EventEmitter.java#L221-L223
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java
|
Expressions.timeTemplate
|
public static <T extends Comparable<?>> TimeTemplate<T> timeTemplate(Class<? extends T> cl,
String template, Object... args) {
"""
Create a new Template expression
@param cl type of expression
@param template template
@param args template parameters
@return template expression
"""
return timeTemplate(cl, createTemplate(template), ImmutableList.copyOf(args));
}
|
java
|
public static <T extends Comparable<?>> TimeTemplate<T> timeTemplate(Class<? extends T> cl,
String template, Object... args) {
return timeTemplate(cl, createTemplate(template), ImmutableList.copyOf(args));
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
">",
">",
"TimeTemplate",
"<",
"T",
">",
"timeTemplate",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"cl",
",",
"String",
"template",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"timeTemplate",
"(",
"cl",
",",
"createTemplate",
"(",
"template",
")",
",",
"ImmutableList",
".",
"copyOf",
"(",
"args",
")",
")",
";",
"}"
] |
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#L643-L646
|
real-logic/agrona
|
agrona/src/main/java/org/agrona/collections/BiInt2ObjectMap.java
|
BiInt2ObjectMap.computeIfAbsent
|
public V computeIfAbsent(final int keyPartA, final int keyPartB, final EntryFunction<? extends V> mappingFunction) {
"""
If the specified key is not already associated with a value (or is mapped
to {@code null}), attempts to compute its value using the given mapping
function and enters it into this map unless {@code null}.
@param keyPartA for the key
@param keyPartB for the key
@param mappingFunction creates values based upon keys if the key pair is missing
@return the newly created or stored value.
"""
V value = get(keyPartA, keyPartB);
if (value == null)
{
value = mappingFunction.apply(keyPartA, keyPartB);
if (value != null)
{
put(keyPartA, keyPartB, value);
}
}
return value;
}
|
java
|
public V computeIfAbsent(final int keyPartA, final int keyPartB, final EntryFunction<? extends V> mappingFunction)
{
V value = get(keyPartA, keyPartB);
if (value == null)
{
value = mappingFunction.apply(keyPartA, keyPartB);
if (value != null)
{
put(keyPartA, keyPartB, value);
}
}
return value;
}
|
[
"public",
"V",
"computeIfAbsent",
"(",
"final",
"int",
"keyPartA",
",",
"final",
"int",
"keyPartB",
",",
"final",
"EntryFunction",
"<",
"?",
"extends",
"V",
">",
"mappingFunction",
")",
"{",
"V",
"value",
"=",
"get",
"(",
"keyPartA",
",",
"keyPartB",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"mappingFunction",
".",
"apply",
"(",
"keyPartA",
",",
"keyPartB",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"put",
"(",
"keyPartA",
",",
"keyPartB",
",",
"value",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] |
If the specified key is not already associated with a value (or is mapped
to {@code null}), attempts to compute its value using the given mapping
function and enters it into this map unless {@code null}.
@param keyPartA for the key
@param keyPartB for the key
@param mappingFunction creates values based upon keys if the key pair is missing
@return the newly created or stored value.
|
[
"If",
"the",
"specified",
"key",
"is",
"not",
"already",
"associated",
"with",
"a",
"value",
"(",
"or",
"is",
"mapped",
"to",
"{",
"@code",
"null",
"}",
")",
"attempts",
"to",
"compute",
"its",
"value",
"using",
"the",
"given",
"mapping",
"function",
"and",
"enters",
"it",
"into",
"this",
"map",
"unless",
"{",
"@code",
"null",
"}",
"."
] |
train
|
https://github.com/real-logic/agrona/blob/d1ea76e6e3598cd6a0d34879687652ef123f639b/agrona/src/main/java/org/agrona/collections/BiInt2ObjectMap.java#L270-L283
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneFormat.java
|
TimeZoneFormat.parseOffsetLocalizedGMT
|
public int parseOffsetLocalizedGMT(String text, ParsePosition pos) {
"""
Returns offset from GMT(UTC) in milliseconds for the given localized GMT
offset format string. When the given string cannot be parsed, this method
sets the current position as the error index to <code>ParsePosition pos</code>
and returns 0.
@param text the text contains a localized GMT offset string at the position.
@param pos the position.
@return the offset from GMT(UTC) in milliseconds for the given localized GMT
offset format string.
@see #formatOffsetLocalizedGMT(int)
"""
return parseOffsetLocalizedGMT(text, pos, false, null);
}
|
java
|
public int parseOffsetLocalizedGMT(String text, ParsePosition pos) {
return parseOffsetLocalizedGMT(text, pos, false, null);
}
|
[
"public",
"int",
"parseOffsetLocalizedGMT",
"(",
"String",
"text",
",",
"ParsePosition",
"pos",
")",
"{",
"return",
"parseOffsetLocalizedGMT",
"(",
"text",
",",
"pos",
",",
"false",
",",
"null",
")",
";",
"}"
] |
Returns offset from GMT(UTC) in milliseconds for the given localized GMT
offset format string. When the given string cannot be parsed, this method
sets the current position as the error index to <code>ParsePosition pos</code>
and returns 0.
@param text the text contains a localized GMT offset string at the position.
@param pos the position.
@return the offset from GMT(UTC) in milliseconds for the given localized GMT
offset format string.
@see #formatOffsetLocalizedGMT(int)
|
[
"Returns",
"offset",
"from",
"GMT",
"(",
"UTC",
")",
"in",
"milliseconds",
"for",
"the",
"given",
"localized",
"GMT",
"offset",
"format",
"string",
".",
"When",
"the",
"given",
"string",
"cannot",
"be",
"parsed",
"this",
"method",
"sets",
"the",
"current",
"position",
"as",
"the",
"error",
"index",
"to",
"<code",
">",
"ParsePosition",
"pos<",
"/",
"code",
">",
"and",
"returns",
"0",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneFormat.java#L976-L978
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mspdi/MSPDIWriter.java
|
MSPDIWriter.writeTaskExtendedAttributes
|
private void writeTaskExtendedAttributes(Project.Tasks.Task xml, Task mpx) {
"""
This method writes extended attribute data for a task.
@param xml MSPDI task
@param mpx MPXJ task
"""
Project.Tasks.Task.ExtendedAttribute attrib;
List<Project.Tasks.Task.ExtendedAttribute> extendedAttributes = xml.getExtendedAttribute();
for (TaskField mpxFieldID : getAllTaskExtendedAttributes())
{
Object value = mpx.getCachedValue(mpxFieldID);
if (FieldTypeHelper.valueIsNotDefault(mpxFieldID, value))
{
m_extendedAttributesInUse.add(mpxFieldID);
Integer xmlFieldID = Integer.valueOf(MPPTaskField.getID(mpxFieldID) | MPPTaskField.TASK_FIELD_BASE);
attrib = m_factory.createProjectTasksTaskExtendedAttribute();
extendedAttributes.add(attrib);
attrib.setFieldID(xmlFieldID.toString());
attrib.setValue(DatatypeConverter.printExtendedAttribute(this, value, mpxFieldID.getDataType()));
attrib.setDurationFormat(printExtendedAttributeDurationFormat(value));
}
}
}
|
java
|
private void writeTaskExtendedAttributes(Project.Tasks.Task xml, Task mpx)
{
Project.Tasks.Task.ExtendedAttribute attrib;
List<Project.Tasks.Task.ExtendedAttribute> extendedAttributes = xml.getExtendedAttribute();
for (TaskField mpxFieldID : getAllTaskExtendedAttributes())
{
Object value = mpx.getCachedValue(mpxFieldID);
if (FieldTypeHelper.valueIsNotDefault(mpxFieldID, value))
{
m_extendedAttributesInUse.add(mpxFieldID);
Integer xmlFieldID = Integer.valueOf(MPPTaskField.getID(mpxFieldID) | MPPTaskField.TASK_FIELD_BASE);
attrib = m_factory.createProjectTasksTaskExtendedAttribute();
extendedAttributes.add(attrib);
attrib.setFieldID(xmlFieldID.toString());
attrib.setValue(DatatypeConverter.printExtendedAttribute(this, value, mpxFieldID.getDataType()));
attrib.setDurationFormat(printExtendedAttributeDurationFormat(value));
}
}
}
|
[
"private",
"void",
"writeTaskExtendedAttributes",
"(",
"Project",
".",
"Tasks",
".",
"Task",
"xml",
",",
"Task",
"mpx",
")",
"{",
"Project",
".",
"Tasks",
".",
"Task",
".",
"ExtendedAttribute",
"attrib",
";",
"List",
"<",
"Project",
".",
"Tasks",
".",
"Task",
".",
"ExtendedAttribute",
">",
"extendedAttributes",
"=",
"xml",
".",
"getExtendedAttribute",
"(",
")",
";",
"for",
"(",
"TaskField",
"mpxFieldID",
":",
"getAllTaskExtendedAttributes",
"(",
")",
")",
"{",
"Object",
"value",
"=",
"mpx",
".",
"getCachedValue",
"(",
"mpxFieldID",
")",
";",
"if",
"(",
"FieldTypeHelper",
".",
"valueIsNotDefault",
"(",
"mpxFieldID",
",",
"value",
")",
")",
"{",
"m_extendedAttributesInUse",
".",
"add",
"(",
"mpxFieldID",
")",
";",
"Integer",
"xmlFieldID",
"=",
"Integer",
".",
"valueOf",
"(",
"MPPTaskField",
".",
"getID",
"(",
"mpxFieldID",
")",
"|",
"MPPTaskField",
".",
"TASK_FIELD_BASE",
")",
";",
"attrib",
"=",
"m_factory",
".",
"createProjectTasksTaskExtendedAttribute",
"(",
")",
";",
"extendedAttributes",
".",
"add",
"(",
"attrib",
")",
";",
"attrib",
".",
"setFieldID",
"(",
"xmlFieldID",
".",
"toString",
"(",
")",
")",
";",
"attrib",
".",
"setValue",
"(",
"DatatypeConverter",
".",
"printExtendedAttribute",
"(",
"this",
",",
"value",
",",
"mpxFieldID",
".",
"getDataType",
"(",
")",
")",
")",
";",
"attrib",
".",
"setDurationFormat",
"(",
"printExtendedAttributeDurationFormat",
"(",
"value",
")",
")",
";",
"}",
"}",
"}"
] |
This method writes extended attribute data for a task.
@param xml MSPDI task
@param mpx MPXJ task
|
[
"This",
"method",
"writes",
"extended",
"attribute",
"data",
"for",
"a",
"task",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mspdi/MSPDIWriter.java#L1313-L1335
|
jamesagnew/hapi-fhir
|
hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java
|
AbstractJaxRsProvider.handleException
|
public Response handleException(final JaxRsRequest theRequest, final Throwable theException)
throws IOException {
"""
Convert an exception to a response
@param theRequest
the incoming request
@param theException
the exception to convert
@return response
@throws IOException
"""
if (theException instanceof JaxRsResponseException) {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, (JaxRsResponseException) theException);
} else {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest,
new JaxRsExceptionInterceptor().convertException(this, theException));
}
}
|
java
|
public Response handleException(final JaxRsRequest theRequest, final Throwable theException)
throws IOException {
if (theException instanceof JaxRsResponseException) {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, (JaxRsResponseException) theException);
} else {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest,
new JaxRsExceptionInterceptor().convertException(this, theException));
}
}
|
[
"public",
"Response",
"handleException",
"(",
"final",
"JaxRsRequest",
"theRequest",
",",
"final",
"Throwable",
"theException",
")",
"throws",
"IOException",
"{",
"if",
"(",
"theException",
"instanceof",
"JaxRsResponseException",
")",
"{",
"return",
"new",
"JaxRsExceptionInterceptor",
"(",
")",
".",
"convertExceptionIntoResponse",
"(",
"theRequest",
",",
"(",
"JaxRsResponseException",
")",
"theException",
")",
";",
"}",
"else",
"{",
"return",
"new",
"JaxRsExceptionInterceptor",
"(",
")",
".",
"convertExceptionIntoResponse",
"(",
"theRequest",
",",
"new",
"JaxRsExceptionInterceptor",
"(",
")",
".",
"convertException",
"(",
"this",
",",
"theException",
")",
")",
";",
"}",
"}"
] |
Convert an exception to a response
@param theRequest
the incoming request
@param theException
the exception to convert
@return response
@throws IOException
|
[
"Convert",
"an",
"exception",
"to",
"a",
"response"
] |
train
|
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java#L242-L250
|
haraldk/TwelveMonkeys
|
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectReader.java
|
ObjectReader.getPropertyValue
|
private Object getPropertyValue(Object pObj, String pProperty) {
"""
Gets the property value from an object using reflection
@param obj The object to get a property from
@param property The name of the property
@return The property value as an Object
"""
Method m = null;
Class[] cl = new Class[0];
try {
//return Util.getPropertyValue(pObj, pProperty);
// Find method
m = pObj.getClass().
getMethod("get" + StringUtil.capitalize(pProperty),
new Class[0]);
// Invoke it
Object result = m.invoke(pObj, new Object[0]);
return result;
}
catch (NoSuchMethodException e) {
e.printStackTrace();
}
catch (IllegalAccessException iae) {
iae.printStackTrace();
}
catch (InvocationTargetException ite) {
ite.printStackTrace();
}
return null;
}
|
java
|
private Object getPropertyValue(Object pObj, String pProperty) {
Method m = null;
Class[] cl = new Class[0];
try {
//return Util.getPropertyValue(pObj, pProperty);
// Find method
m = pObj.getClass().
getMethod("get" + StringUtil.capitalize(pProperty),
new Class[0]);
// Invoke it
Object result = m.invoke(pObj, new Object[0]);
return result;
}
catch (NoSuchMethodException e) {
e.printStackTrace();
}
catch (IllegalAccessException iae) {
iae.printStackTrace();
}
catch (InvocationTargetException ite) {
ite.printStackTrace();
}
return null;
}
|
[
"private",
"Object",
"getPropertyValue",
"(",
"Object",
"pObj",
",",
"String",
"pProperty",
")",
"{",
"Method",
"m",
"=",
"null",
";",
"Class",
"[",
"]",
"cl",
"=",
"new",
"Class",
"[",
"0",
"]",
";",
"try",
"{",
"//return Util.getPropertyValue(pObj, pProperty);\r",
"// Find method\r",
"m",
"=",
"pObj",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"get\"",
"+",
"StringUtil",
".",
"capitalize",
"(",
"pProperty",
")",
",",
"new",
"Class",
"[",
"0",
"]",
")",
";",
"// Invoke it\r",
"Object",
"result",
"=",
"m",
".",
"invoke",
"(",
"pObj",
",",
"new",
"Object",
"[",
"0",
"]",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"iae",
")",
"{",
"iae",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"ite",
")",
"{",
"ite",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the property value from an object using reflection
@param obj The object to get a property from
@param property The name of the property
@return The property value as an Object
|
[
"Gets",
"the",
"property",
"value",
"from",
"an",
"object",
"using",
"reflection"
] |
train
|
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectReader.java#L368-L395
|
OpenTSDB/opentsdb
|
src/core/Tags.java
|
Tags.resolveIds
|
public static HashMap<String, String> resolveIds(final TSDB tsdb,
final ArrayList<byte[]> tags)
throws NoSuchUniqueId {
"""
Resolves all the tags IDs (name followed by value) into the a map.
This function is the opposite of {@link #resolveAll}.
@param tsdb The TSDB to use for UniqueId lookups.
@param tags The tag IDs to resolve.
@return A map mapping tag names to tag values.
@throws NoSuchUniqueId if one of the elements in the array contained an
invalid ID.
@throws IllegalArgumentException if one of the elements in the array had
the wrong number of bytes.
"""
try {
return resolveIdsAsync(tsdb, tags).joinUninterruptibly();
} catch (NoSuchUniqueId e) {
throw e;
} catch (DeferredGroupException e) {
final Throwable ex = Exceptions.getCause(e);
if (ex instanceof NoSuchUniqueId) {
throw (NoSuchUniqueId)ex;
}
// TODO process e.results()
throw new RuntimeException("Shouldn't be here", e);
} catch (Exception e) {
throw new RuntimeException("Shouldn't be here", e);
}
}
|
java
|
public static HashMap<String, String> resolveIds(final TSDB tsdb,
final ArrayList<byte[]> tags)
throws NoSuchUniqueId {
try {
return resolveIdsAsync(tsdb, tags).joinUninterruptibly();
} catch (NoSuchUniqueId e) {
throw e;
} catch (DeferredGroupException e) {
final Throwable ex = Exceptions.getCause(e);
if (ex instanceof NoSuchUniqueId) {
throw (NoSuchUniqueId)ex;
}
// TODO process e.results()
throw new RuntimeException("Shouldn't be here", e);
} catch (Exception e) {
throw new RuntimeException("Shouldn't be here", e);
}
}
|
[
"public",
"static",
"HashMap",
"<",
"String",
",",
"String",
">",
"resolveIds",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"ArrayList",
"<",
"byte",
"[",
"]",
">",
"tags",
")",
"throws",
"NoSuchUniqueId",
"{",
"try",
"{",
"return",
"resolveIdsAsync",
"(",
"tsdb",
",",
"tags",
")",
".",
"joinUninterruptibly",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueId",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"DeferredGroupException",
"e",
")",
"{",
"final",
"Throwable",
"ex",
"=",
"Exceptions",
".",
"getCause",
"(",
"e",
")",
";",
"if",
"(",
"ex",
"instanceof",
"NoSuchUniqueId",
")",
"{",
"throw",
"(",
"NoSuchUniqueId",
")",
"ex",
";",
"}",
"// TODO process e.results()",
"throw",
"new",
"RuntimeException",
"(",
"\"Shouldn't be here\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Shouldn't be here\"",
",",
"e",
")",
";",
"}",
"}"
] |
Resolves all the tags IDs (name followed by value) into the a map.
This function is the opposite of {@link #resolveAll}.
@param tsdb The TSDB to use for UniqueId lookups.
@param tags The tag IDs to resolve.
@return A map mapping tag names to tag values.
@throws NoSuchUniqueId if one of the elements in the array contained an
invalid ID.
@throws IllegalArgumentException if one of the elements in the array had
the wrong number of bytes.
|
[
"Resolves",
"all",
"the",
"tags",
"IDs",
"(",
"name",
"followed",
"by",
"value",
")",
"into",
"the",
"a",
"map",
".",
"This",
"function",
"is",
"the",
"opposite",
"of",
"{"
] |
train
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/Tags.java#L739-L757
|
forge/core
|
javaee/impl/src/main/java/org/jboss/forge/addon/javaee/rest/generator/dto/DTOCollection.java
|
DTOCollection.getDTOFor
|
public JavaClassSource getDTOFor(JavaClass<?> entity, boolean root) {
"""
Retrieves the DTO created for the JPA entity, depending on whether a top level or nested DTO was requested as the
return value.
@param entity The JPA entity for which the DTOs may have been created
@param root True, if the root/toplevel DTO should be returned. False if nested DTOs are to be returned.
@return The root or nested DTO created for the JPA entity. <code>null</code> if no DTO was found.
"""
if (dtos.get(entity) == null)
{
return null;
}
return root ? (dtos.get(entity).rootDTO) : (dtos.get(entity).nestedDTO);
}
|
java
|
public JavaClassSource getDTOFor(JavaClass<?> entity, boolean root)
{
if (dtos.get(entity) == null)
{
return null;
}
return root ? (dtos.get(entity).rootDTO) : (dtos.get(entity).nestedDTO);
}
|
[
"public",
"JavaClassSource",
"getDTOFor",
"(",
"JavaClass",
"<",
"?",
">",
"entity",
",",
"boolean",
"root",
")",
"{",
"if",
"(",
"dtos",
".",
"get",
"(",
"entity",
")",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"root",
"?",
"(",
"dtos",
".",
"get",
"(",
"entity",
")",
".",
"rootDTO",
")",
":",
"(",
"dtos",
".",
"get",
"(",
"entity",
")",
".",
"nestedDTO",
")",
";",
"}"
] |
Retrieves the DTO created for the JPA entity, depending on whether a top level or nested DTO was requested as the
return value.
@param entity The JPA entity for which the DTOs may have been created
@param root True, if the root/toplevel DTO should be returned. False if nested DTOs are to be returned.
@return The root or nested DTO created for the JPA entity. <code>null</code> if no DTO was found.
|
[
"Retrieves",
"the",
"DTO",
"created",
"for",
"the",
"JPA",
"entity",
"depending",
"on",
"whether",
"a",
"top",
"level",
"or",
"nested",
"DTO",
"was",
"requested",
"as",
"the",
"return",
"value",
"."
] |
train
|
https://github.com/forge/core/blob/e140eb03bbe2b3409478ad70c86c3edbef6d9a0c/javaee/impl/src/main/java/org/jboss/forge/addon/javaee/rest/generator/dto/DTOCollection.java#L101-L108
|
drewnoakes/metadata-extractor
|
Source/com/drew/imaging/riff/RiffReader.java
|
RiffReader.processRiff
|
public void processRiff(@NotNull final SequentialReader reader,
@NotNull final RiffHandler handler) throws RiffProcessingException, IOException {
"""
Processes a RIFF data sequence.
@param reader the {@link SequentialReader} from which the data should be read
@param handler the {@link RiffHandler} that will coordinate processing and accept read values
@throws RiffProcessingException if an error occurred during the processing of RIFF data that could not be
ignored or recovered from
@throws IOException an error occurred while accessing the required data
"""
// RIFF files are always little-endian
reader.setMotorolaByteOrder(false);
// PROCESS FILE HEADER
final String fileFourCC = reader.getString(4);
if (!fileFourCC.equals("RIFF"))
throw new RiffProcessingException("Invalid RIFF header: " + fileFourCC);
// The total size of the chunks that follow plus 4 bytes for the FourCC
final int fileSize = reader.getInt32();
int sizeLeft = fileSize;
final String identifier = reader.getString(4);
sizeLeft -= 4;
if (!handler.shouldAcceptRiffIdentifier(identifier))
return;
// PROCESS CHUNKS
processChunks(reader, sizeLeft, handler);
}
|
java
|
public void processRiff(@NotNull final SequentialReader reader,
@NotNull final RiffHandler handler) throws RiffProcessingException, IOException
{
// RIFF files are always little-endian
reader.setMotorolaByteOrder(false);
// PROCESS FILE HEADER
final String fileFourCC = reader.getString(4);
if (!fileFourCC.equals("RIFF"))
throw new RiffProcessingException("Invalid RIFF header: " + fileFourCC);
// The total size of the chunks that follow plus 4 bytes for the FourCC
final int fileSize = reader.getInt32();
int sizeLeft = fileSize;
final String identifier = reader.getString(4);
sizeLeft -= 4;
if (!handler.shouldAcceptRiffIdentifier(identifier))
return;
// PROCESS CHUNKS
processChunks(reader, sizeLeft, handler);
}
|
[
"public",
"void",
"processRiff",
"(",
"@",
"NotNull",
"final",
"SequentialReader",
"reader",
",",
"@",
"NotNull",
"final",
"RiffHandler",
"handler",
")",
"throws",
"RiffProcessingException",
",",
"IOException",
"{",
"// RIFF files are always little-endian",
"reader",
".",
"setMotorolaByteOrder",
"(",
"false",
")",
";",
"// PROCESS FILE HEADER",
"final",
"String",
"fileFourCC",
"=",
"reader",
".",
"getString",
"(",
"4",
")",
";",
"if",
"(",
"!",
"fileFourCC",
".",
"equals",
"(",
"\"RIFF\"",
")",
")",
"throw",
"new",
"RiffProcessingException",
"(",
"\"Invalid RIFF header: \"",
"+",
"fileFourCC",
")",
";",
"// The total size of the chunks that follow plus 4 bytes for the FourCC",
"final",
"int",
"fileSize",
"=",
"reader",
".",
"getInt32",
"(",
")",
";",
"int",
"sizeLeft",
"=",
"fileSize",
";",
"final",
"String",
"identifier",
"=",
"reader",
".",
"getString",
"(",
"4",
")",
";",
"sizeLeft",
"-=",
"4",
";",
"if",
"(",
"!",
"handler",
".",
"shouldAcceptRiffIdentifier",
"(",
"identifier",
")",
")",
"return",
";",
"// PROCESS CHUNKS",
"processChunks",
"(",
"reader",
",",
"sizeLeft",
",",
"handler",
")",
";",
"}"
] |
Processes a RIFF data sequence.
@param reader the {@link SequentialReader} from which the data should be read
@param handler the {@link RiffHandler} that will coordinate processing and accept read values
@throws RiffProcessingException if an error occurred during the processing of RIFF data that could not be
ignored or recovered from
@throws IOException an error occurred while accessing the required data
|
[
"Processes",
"a",
"RIFF",
"data",
"sequence",
"."
] |
train
|
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/imaging/riff/RiffReader.java#L51-L76
|
JOML-CI/JOML
|
src/org/joml/Matrix4x3f.java
|
Matrix4x3f.ortho2DLH
|
public Matrix4x3f ortho2DLH(float left, float right, float bottom, float top) {
"""
Apply an orthographic projection transformation for a left-handed coordinate system to this matrix.
<p>
This method is equivalent to calling {@link #orthoLH(float, float, float, float, float, float) orthoLH()} with
<code>zNear=-1</code> and <code>zFar=+1</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>O</code> the orthographic projection matrix,
then the new matrix will be <code>M * O</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * O * v</code>, the
orthographic projection transformation will be applied first!
<p>
In order to set the matrix to an orthographic projection without post-multiplying it,
use {@link #setOrtho2DLH(float, float, float, float) setOrtho2DLH()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #orthoLH(float, float, float, float, float, float)
@see #setOrtho2DLH(float, float, float, float)
@param left
the distance from the center to the left frustum edge
@param right
the distance from the center to the right frustum edge
@param bottom
the distance from the center to the bottom frustum edge
@param top
the distance from the center to the top frustum edge
@return this
"""
return ortho2DLH(left, right, bottom, top, this);
}
|
java
|
public Matrix4x3f ortho2DLH(float left, float right, float bottom, float top) {
return ortho2DLH(left, right, bottom, top, this);
}
|
[
"public",
"Matrix4x3f",
"ortho2DLH",
"(",
"float",
"left",
",",
"float",
"right",
",",
"float",
"bottom",
",",
"float",
"top",
")",
"{",
"return",
"ortho2DLH",
"(",
"left",
",",
"right",
",",
"bottom",
",",
"top",
",",
"this",
")",
";",
"}"
] |
Apply an orthographic projection transformation for a left-handed coordinate system to this matrix.
<p>
This method is equivalent to calling {@link #orthoLH(float, float, float, float, float, float) orthoLH()} with
<code>zNear=-1</code> and <code>zFar=+1</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>O</code> the orthographic projection matrix,
then the new matrix will be <code>M * O</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * O * v</code>, the
orthographic projection transformation will be applied first!
<p>
In order to set the matrix to an orthographic projection without post-multiplying it,
use {@link #setOrtho2DLH(float, float, float, float) setOrtho2DLH()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #orthoLH(float, float, float, float, float, float)
@see #setOrtho2DLH(float, float, float, float)
@param left
the distance from the center to the left frustum edge
@param right
the distance from the center to the right frustum edge
@param bottom
the distance from the center to the bottom frustum edge
@param top
the distance from the center to the top frustum edge
@return this
|
[
"Apply",
"an",
"orthographic",
"projection",
"transformation",
"for",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"to",
"this",
"matrix",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
"{",
"@link",
"#orthoLH",
"(",
"float",
"float",
"float",
"float",
"float",
"float",
")",
"orthoLH",
"()",
"}",
"with",
"<code",
">",
"zNear",
"=",
"-",
"1<",
"/",
"code",
">",
"and",
"<code",
">",
"zFar",
"=",
"+",
"1<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"O<",
"/",
"code",
">",
"the",
"orthographic",
"projection",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"O<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"O",
"*",
"v<",
"/",
"code",
">",
"the",
"orthographic",
"projection",
"transformation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"an",
"orthographic",
"projection",
"without",
"post",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#setOrtho2DLH",
"(",
"float",
"float",
"float",
"float",
")",
"setOrtho2DLH",
"()",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca",
"/",
"opengl",
"/",
"gl_projectionmatrix",
".",
"html#ortho",
">",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca<",
"/",
"a",
">"
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3f.java#L5829-L5831
|
ykrasik/jaci
|
jaci-core/src/main/java/com/github/ykrasik/jaci/path/ParsedPath.java
|
ParsedPath.toEntry
|
public static ParsedPath toEntry(String rawPath) {
"""
Create a path that is expected to represent a path to any entry.
This is different from {@link #toDirectory(String)} in that if the path ends with a delimiter '/',
it is <b>not</b> considered the same as if it didn't.
i.e. path/to would be a path with 2 elements: 'path' and 'to', but
but path/to/ would be a path with 3 elements: 'path', 'to' and an empty element ''.
@param rawPath Path to parse.
@return A {@link ParsedPath} out of the given path.
@throws IllegalArgumentException If any element along the path except the last one is empty.
"""
final String path = rawPath.trim();
final boolean startsWithDelimiter = path.startsWith("/");
// Keep the trailing delimiter.
// This allows us to treat paths that end with a delimiter differently from paths that don't.
// i.e. path/to would be a path with 2 elements: 'path' and 'to', but
// but path/to/ would be a path with 3 elements: 'path', 'to' and an empty element ''.
final List<String> pathElements = splitPath(path, true);
return new ParsedPath(startsWithDelimiter, pathElements);
}
|
java
|
public static ParsedPath toEntry(String rawPath) {
final String path = rawPath.trim();
final boolean startsWithDelimiter = path.startsWith("/");
// Keep the trailing delimiter.
// This allows us to treat paths that end with a delimiter differently from paths that don't.
// i.e. path/to would be a path with 2 elements: 'path' and 'to', but
// but path/to/ would be a path with 3 elements: 'path', 'to' and an empty element ''.
final List<String> pathElements = splitPath(path, true);
return new ParsedPath(startsWithDelimiter, pathElements);
}
|
[
"public",
"static",
"ParsedPath",
"toEntry",
"(",
"String",
"rawPath",
")",
"{",
"final",
"String",
"path",
"=",
"rawPath",
".",
"trim",
"(",
")",
";",
"final",
"boolean",
"startsWithDelimiter",
"=",
"path",
".",
"startsWith",
"(",
"\"/\"",
")",
";",
"// Keep the trailing delimiter.",
"// This allows us to treat paths that end with a delimiter differently from paths that don't.",
"// i.e. path/to would be a path with 2 elements: 'path' and 'to', but",
"// but path/to/ would be a path with 3 elements: 'path', 'to' and an empty element ''.",
"final",
"List",
"<",
"String",
">",
"pathElements",
"=",
"splitPath",
"(",
"path",
",",
"true",
")",
";",
"return",
"new",
"ParsedPath",
"(",
"startsWithDelimiter",
",",
"pathElements",
")",
";",
"}"
] |
Create a path that is expected to represent a path to any entry.
This is different from {@link #toDirectory(String)} in that if the path ends with a delimiter '/',
it is <b>not</b> considered the same as if it didn't.
i.e. path/to would be a path with 2 elements: 'path' and 'to', but
but path/to/ would be a path with 3 elements: 'path', 'to' and an empty element ''.
@param rawPath Path to parse.
@return A {@link ParsedPath} out of the given path.
@throws IllegalArgumentException If any element along the path except the last one is empty.
|
[
"Create",
"a",
"path",
"that",
"is",
"expected",
"to",
"represent",
"a",
"path",
"to",
"any",
"entry",
".",
"This",
"is",
"different",
"from",
"{",
"@link",
"#toDirectory",
"(",
"String",
")",
"}",
"in",
"that",
"if",
"the",
"path",
"ends",
"with",
"a",
"delimiter",
"/",
"it",
"is",
"<b",
">",
"not<",
"/",
"b",
">",
"considered",
"the",
"same",
"as",
"if",
"it",
"didn",
"t",
".",
"i",
".",
"e",
".",
"path",
"/",
"to",
"would",
"be",
"a",
"path",
"with",
"2",
"elements",
":",
"path",
"and",
"to",
"but",
"but",
"path",
"/",
"to",
"/",
"would",
"be",
"a",
"path",
"with",
"3",
"elements",
":",
"path",
"to",
"and",
"an",
"empty",
"element",
"."
] |
train
|
https://github.com/ykrasik/jaci/blob/4615edef7c76288ad5ea8d678132b161645ca1e3/jaci-core/src/main/java/com/github/ykrasik/jaci/path/ParsedPath.java#L181-L192
|
SUSE/salt-netapi-client
|
src/main/java/com/suse/salt/netapi/calls/LocalCall.java
|
LocalCall.callSync
|
public CompletionStage<Map<String, Result<R>>> callSync(final SaltClient client, Target<?> target,
AuthMethod auth) {
"""
Calls a execution module function on the given target and synchronously
waits for the result. Authentication is done with the token therefore you
have to login prior to using this function.
@param client SaltClient instance
@param target the target for the function
@param auth authentication credentials to use
@return a map containing the results with the minion name as key
"""
return callSyncHelperNonBlock(client, target, auth, Optional.empty())
.thenApply(r -> r.get(0));
}
|
java
|
public CompletionStage<Map<String, Result<R>>> callSync(final SaltClient client, Target<?> target,
AuthMethod auth) {
return callSyncHelperNonBlock(client, target, auth, Optional.empty())
.thenApply(r -> r.get(0));
}
|
[
"public",
"CompletionStage",
"<",
"Map",
"<",
"String",
",",
"Result",
"<",
"R",
">",
">",
">",
"callSync",
"(",
"final",
"SaltClient",
"client",
",",
"Target",
"<",
"?",
">",
"target",
",",
"AuthMethod",
"auth",
")",
"{",
"return",
"callSyncHelperNonBlock",
"(",
"client",
",",
"target",
",",
"auth",
",",
"Optional",
".",
"empty",
"(",
")",
")",
".",
"thenApply",
"(",
"r",
"->",
"r",
".",
"get",
"(",
"0",
")",
")",
";",
"}"
] |
Calls a execution module function on the given target and synchronously
waits for the result. Authentication is done with the token therefore you
have to login prior to using this function.
@param client SaltClient instance
@param target the target for the function
@param auth authentication credentials to use
@return a map containing the results with the minion name as key
|
[
"Calls",
"a",
"execution",
"module",
"function",
"on",
"the",
"given",
"target",
"and",
"synchronously",
"waits",
"for",
"the",
"result",
".",
"Authentication",
"is",
"done",
"with",
"the",
"token",
"therefore",
"you",
"have",
"to",
"login",
"prior",
"to",
"using",
"this",
"function",
"."
] |
train
|
https://github.com/SUSE/salt-netapi-client/blob/a0bdf643c8e34fa4def4b915366594c1491fdad5/src/main/java/com/suse/salt/netapi/calls/LocalCall.java#L332-L336
|
knightliao/apollo
|
src/main/java/com/github/knightliao/apollo/utils/time/DateUtils.java
|
DateUtils.getWeekDay
|
public static Date getWeekDay(Date dt, int weekDay) {
"""
@param dt Date 给定的java.util.Date对象
@param weekDay int 就是周几的”几“,周日是7
@return Date java.util.Date对象
"""
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
if (weekDay == 7) {
weekDay = 1;
} else {
weekDay++;
}
cal.set(GregorianCalendar.DAY_OF_WEEK, weekDay);
return cal.getTime();
}
|
java
|
public static Date getWeekDay(Date dt, int weekDay) {
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
if (weekDay == 7) {
weekDay = 1;
} else {
weekDay++;
}
cal.set(GregorianCalendar.DAY_OF_WEEK, weekDay);
return cal.getTime();
}
|
[
"public",
"static",
"Date",
"getWeekDay",
"(",
"Date",
"dt",
",",
"int",
"weekDay",
")",
"{",
"Calendar",
"cal",
"=",
"new",
"GregorianCalendar",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"dt",
")",
";",
"if",
"(",
"weekDay",
"==",
"7",
")",
"{",
"weekDay",
"=",
"1",
";",
"}",
"else",
"{",
"weekDay",
"++",
";",
"}",
"cal",
".",
"set",
"(",
"GregorianCalendar",
".",
"DAY_OF_WEEK",
",",
"weekDay",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] |
@param dt Date 给定的java.util.Date对象
@param weekDay int 就是周几的”几“,周日是7
@return Date java.util.Date对象
|
[
"@param",
"dt",
"Date",
"给定的java",
".",
"util",
".",
"Date对象",
"@param",
"weekDay",
"int",
"就是周几的”几“,周日是7"
] |
train
|
https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/utils/time/DateUtils.java#L576-L586
|
m-m-m/util
|
text/src/main/java/net/sf/mmm/util/text/base/DefaultLineWrapper.java
|
DefaultLineWrapper.isIn
|
private static boolean isIn(char c, char[] chars) {
"""
This method determines if the given character {@code c} is contained in {@code chars}.
@param c is the character to check.
@param chars is the array with the matching characters.
@return {@code true} if {@code c} is contained in {@code chars}, {@code false} otherwise.
"""
if (chars != null) {
for (char current : chars) {
if (current == c) {
return true;
}
}
}
return false;
}
|
java
|
private static boolean isIn(char c, char[] chars) {
if (chars != null) {
for (char current : chars) {
if (current == c) {
return true;
}
}
}
return false;
}
|
[
"private",
"static",
"boolean",
"isIn",
"(",
"char",
"c",
",",
"char",
"[",
"]",
"chars",
")",
"{",
"if",
"(",
"chars",
"!=",
"null",
")",
"{",
"for",
"(",
"char",
"current",
":",
"chars",
")",
"{",
"if",
"(",
"current",
"==",
"c",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
This method determines if the given character {@code c} is contained in {@code chars}.
@param c is the character to check.
@param chars is the array with the matching characters.
@return {@code true} if {@code c} is contained in {@code chars}, {@code false} otherwise.
|
[
"This",
"method",
"determines",
"if",
"the",
"given",
"character",
"{",
"@code",
"c",
"}",
"is",
"contained",
"in",
"{",
"@code",
"chars",
"}",
"."
] |
train
|
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/text/src/main/java/net/sf/mmm/util/text/base/DefaultLineWrapper.java#L285-L295
|
hibernate/hibernate-ogm
|
core/src/main/java/org/hibernate/ogm/persister/impl/EntityAssociationUpdater.java
|
EntityAssociationUpdater.getInverseRowKey
|
private RowKey getInverseRowKey(AssociationKeyMetadata associationKeyMetadata, Object[] associationColumnValues) {
"""
Gets the row key of the inverse association represented by the given meta-data, pointing the entity with current
{@link EntityAssociationUpdater#id}
@param associationKeyMetadata meta-data for the inverse association of interest
@param associationColumnValues the column values identifying the entity on the inverse side of the association
@return the row key of the inverse association
"""
Tuple rowKeyValues = new Tuple();
// add the fk column
for ( int index = 0; index < associationKeyMetadata.getColumnNames().length; index++ ) {
rowKeyValues.put( associationKeyMetadata.getColumnNames()[index], associationColumnValues[index] );
}
// add the id column
persister.getGridIdentifierType().nullSafeSet( rowKeyValues, id, persister.getIdentifierColumnNames(), session );
return new RowKeyBuilder()
.addColumns( associationKeyMetadata.getRowKeyColumnNames() )
.values( rowKeyValues )
.build();
}
|
java
|
private RowKey getInverseRowKey(AssociationKeyMetadata associationKeyMetadata, Object[] associationColumnValues) {
Tuple rowKeyValues = new Tuple();
// add the fk column
for ( int index = 0; index < associationKeyMetadata.getColumnNames().length; index++ ) {
rowKeyValues.put( associationKeyMetadata.getColumnNames()[index], associationColumnValues[index] );
}
// add the id column
persister.getGridIdentifierType().nullSafeSet( rowKeyValues, id, persister.getIdentifierColumnNames(), session );
return new RowKeyBuilder()
.addColumns( associationKeyMetadata.getRowKeyColumnNames() )
.values( rowKeyValues )
.build();
}
|
[
"private",
"RowKey",
"getInverseRowKey",
"(",
"AssociationKeyMetadata",
"associationKeyMetadata",
",",
"Object",
"[",
"]",
"associationColumnValues",
")",
"{",
"Tuple",
"rowKeyValues",
"=",
"new",
"Tuple",
"(",
")",
";",
"// add the fk column",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"associationKeyMetadata",
".",
"getColumnNames",
"(",
")",
".",
"length",
";",
"index",
"++",
")",
"{",
"rowKeyValues",
".",
"put",
"(",
"associationKeyMetadata",
".",
"getColumnNames",
"(",
")",
"[",
"index",
"]",
",",
"associationColumnValues",
"[",
"index",
"]",
")",
";",
"}",
"// add the id column",
"persister",
".",
"getGridIdentifierType",
"(",
")",
".",
"nullSafeSet",
"(",
"rowKeyValues",
",",
"id",
",",
"persister",
".",
"getIdentifierColumnNames",
"(",
")",
",",
"session",
")",
";",
"return",
"new",
"RowKeyBuilder",
"(",
")",
".",
"addColumns",
"(",
"associationKeyMetadata",
".",
"getRowKeyColumnNames",
"(",
")",
")",
".",
"values",
"(",
"rowKeyValues",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Gets the row key of the inverse association represented by the given meta-data, pointing the entity with current
{@link EntityAssociationUpdater#id}
@param associationKeyMetadata meta-data for the inverse association of interest
@param associationColumnValues the column values identifying the entity on the inverse side of the association
@return the row key of the inverse association
|
[
"Gets",
"the",
"row",
"key",
"of",
"the",
"inverse",
"association",
"represented",
"by",
"the",
"given",
"meta",
"-",
"data",
"pointing",
"the",
"entity",
"with",
"current",
"{",
"@link",
"EntityAssociationUpdater#id",
"}"
] |
train
|
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/EntityAssociationUpdater.java#L267-L282
|
alkacon/opencms-core
|
src/org/opencms/ui/login/CmsLoginController.java
|
CmsLoginController.logout
|
public static void logout(CmsObject cms, HttpServletRequest request, HttpServletResponse response)
throws IOException {
"""
Logs out the current user redirecting to the login form afterwards.<p>
@param cms the cms context
@param request the servlet request
@param response the servlet response
@throws IOException if writing to the response fails
"""
String loggedInUser = cms.getRequestContext().getCurrentUser().getName();
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
/* we need this because a new session might be created after this method,
but before the session info is updated in OpenCmsCore.showResource. */
cms.getRequestContext().setUpdateSessionEnabled(false);
}
// logout was successful
if (LOG.isInfoEnabled()) {
LOG.info(
org.opencms.jsp.Messages.get().getBundle().key(
org.opencms.jsp.Messages.LOG_LOGOUT_SUCCESFUL_3,
loggedInUser,
cms.getRequestContext().addSiteRoot(cms.getRequestContext().getUri()),
cms.getRequestContext().getRemoteAddress()));
}
response.sendRedirect(getFormLink(cms));
}
|
java
|
public static void logout(CmsObject cms, HttpServletRequest request, HttpServletResponse response)
throws IOException {
String loggedInUser = cms.getRequestContext().getCurrentUser().getName();
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
/* we need this because a new session might be created after this method,
but before the session info is updated in OpenCmsCore.showResource. */
cms.getRequestContext().setUpdateSessionEnabled(false);
}
// logout was successful
if (LOG.isInfoEnabled()) {
LOG.info(
org.opencms.jsp.Messages.get().getBundle().key(
org.opencms.jsp.Messages.LOG_LOGOUT_SUCCESFUL_3,
loggedInUser,
cms.getRequestContext().addSiteRoot(cms.getRequestContext().getUri()),
cms.getRequestContext().getRemoteAddress()));
}
response.sendRedirect(getFormLink(cms));
}
|
[
"public",
"static",
"void",
"logout",
"(",
"CmsObject",
"cms",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
"{",
"String",
"loggedInUser",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
".",
"getName",
"(",
")",
";",
"HttpSession",
"session",
"=",
"request",
".",
"getSession",
"(",
"false",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"session",
".",
"invalidate",
"(",
")",
";",
"/* we need this because a new session might be created after this method,\n but before the session info is updated in OpenCmsCore.showResource. */",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setUpdateSessionEnabled",
"(",
"false",
")",
";",
"}",
"// logout was successful",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"org",
".",
"opencms",
".",
"jsp",
".",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"org",
".",
"opencms",
".",
"jsp",
".",
"Messages",
".",
"LOG_LOGOUT_SUCCESFUL_3",
",",
"loggedInUser",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"addSiteRoot",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getUri",
"(",
")",
")",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getRemoteAddress",
"(",
")",
")",
")",
";",
"}",
"response",
".",
"sendRedirect",
"(",
"getFormLink",
"(",
"cms",
")",
")",
";",
"}"
] |
Logs out the current user redirecting to the login form afterwards.<p>
@param cms the cms context
@param request the servlet request
@param response the servlet response
@throws IOException if writing to the response fails
|
[
"Logs",
"out",
"the",
"current",
"user",
"redirecting",
"to",
"the",
"login",
"form",
"afterwards",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/login/CmsLoginController.java#L357-L378
|
Ordinastie/MalisisCore
|
src/main/java/net/malisis/core/util/syncer/Syncer.java
|
Syncer.updateValues
|
public <T> void updateValues(T receiver, ISyncHandler<T, ? extends ISyncableData> handler, Map<String, Object> values) {
"""
Update the fields values for the receiver object.
@param receiver the caller
@param handler the handler
@param values the values
"""
if (receiver == null || handler == null)
return;
for (Entry<String, Object> entry : values.entrySet())
{
ObjectData od = handler.getObjectData(entry.getKey());
if (od != null)
od.set(receiver, entry.getValue());
}
}
|
java
|
public <T> void updateValues(T receiver, ISyncHandler<T, ? extends ISyncableData> handler, Map<String, Object> values)
{
if (receiver == null || handler == null)
return;
for (Entry<String, Object> entry : values.entrySet())
{
ObjectData od = handler.getObjectData(entry.getKey());
if (od != null)
od.set(receiver, entry.getValue());
}
}
|
[
"public",
"<",
"T",
">",
"void",
"updateValues",
"(",
"T",
"receiver",
",",
"ISyncHandler",
"<",
"T",
",",
"?",
"extends",
"ISyncableData",
">",
"handler",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"values",
")",
"{",
"if",
"(",
"receiver",
"==",
"null",
"||",
"handler",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"values",
".",
"entrySet",
"(",
")",
")",
"{",
"ObjectData",
"od",
"=",
"handler",
".",
"getObjectData",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"if",
"(",
"od",
"!=",
"null",
")",
"od",
".",
"set",
"(",
"receiver",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Update the fields values for the receiver object.
@param receiver the caller
@param handler the handler
@param values the values
|
[
"Update",
"the",
"fields",
"values",
"for",
"the",
"receiver",
"object",
"."
] |
train
|
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/syncer/Syncer.java#L324-L335
|
weld/core
|
impl/src/main/java/org/jboss/weld/config/WeldConfiguration.java
|
WeldConfiguration.processKeyValue
|
private void processKeyValue(Map<ConfigurationKey, Object> properties, String stringKey, Object value) {
"""
Process the given string key and value. First try to convert the <code>stringKey</code> - unsupported keys are ignored. Then delegate to
{@link #processKeyValue(Map, ConfigurationKey, Object)}.
@param properties
@param stringKey
@param value
"""
processKeyValue(properties, stringKey, value, false);
}
|
java
|
private void processKeyValue(Map<ConfigurationKey, Object> properties, String stringKey, Object value) {
processKeyValue(properties, stringKey, value, false);
}
|
[
"private",
"void",
"processKeyValue",
"(",
"Map",
"<",
"ConfigurationKey",
",",
"Object",
">",
"properties",
",",
"String",
"stringKey",
",",
"Object",
"value",
")",
"{",
"processKeyValue",
"(",
"properties",
",",
"stringKey",
",",
"value",
",",
"false",
")",
";",
"}"
] |
Process the given string key and value. First try to convert the <code>stringKey</code> - unsupported keys are ignored. Then delegate to
{@link #processKeyValue(Map, ConfigurationKey, Object)}.
@param properties
@param stringKey
@param value
|
[
"Process",
"the",
"given",
"string",
"key",
"and",
"value",
".",
"First",
"try",
"to",
"convert",
"the",
"<code",
">",
"stringKey<",
"/",
"code",
">",
"-",
"unsupported",
"keys",
"are",
"ignored",
".",
"Then",
"delegate",
"to",
"{",
"@link",
"#processKeyValue",
"(",
"Map",
"ConfigurationKey",
"Object",
")",
"}",
"."
] |
train
|
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/config/WeldConfiguration.java#L449-L451
|
stackify/stackify-api-java
|
src/main/java/com/stackify/api/common/log/direct/Logger.java
|
Logger.queueException
|
public static void queueException(final String level, final String message, final Throwable e) {
"""
Queues an exception to be sent to Stackify
@param level The log level
@param message The log message
@param e The exception
"""
try {
LogAppender<LogEvent> appender = LogManager.getAppender();
if (appender != null) {
appender.append(LogEvent.newBuilder().level(level).message(message).exception(e).build());
}
} catch (Throwable t) {
LOGGER.info("Unable to queue exception to Stackify Log API service: {} {} {}", level, message, e, t);
}
}
|
java
|
public static void queueException(final String level, final String message, final Throwable e) {
try {
LogAppender<LogEvent> appender = LogManager.getAppender();
if (appender != null) {
appender.append(LogEvent.newBuilder().level(level).message(message).exception(e).build());
}
} catch (Throwable t) {
LOGGER.info("Unable to queue exception to Stackify Log API service: {} {} {}", level, message, e, t);
}
}
|
[
"public",
"static",
"void",
"queueException",
"(",
"final",
"String",
"level",
",",
"final",
"String",
"message",
",",
"final",
"Throwable",
"e",
")",
"{",
"try",
"{",
"LogAppender",
"<",
"LogEvent",
">",
"appender",
"=",
"LogManager",
".",
"getAppender",
"(",
")",
";",
"if",
"(",
"appender",
"!=",
"null",
")",
"{",
"appender",
".",
"append",
"(",
"LogEvent",
".",
"newBuilder",
"(",
")",
".",
"level",
"(",
"level",
")",
".",
"message",
"(",
"message",
")",
".",
"exception",
"(",
"e",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Unable to queue exception to Stackify Log API service: {} {} {}\"",
",",
"level",
",",
"message",
",",
"e",
",",
"t",
")",
";",
"}",
"}"
] |
Queues an exception to be sent to Stackify
@param level The log level
@param message The log message
@param e The exception
|
[
"Queues",
"an",
"exception",
"to",
"be",
"sent",
"to",
"Stackify"
] |
train
|
https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/direct/Logger.java#L89-L99
|
mapcode-foundation/mapcode-java
|
src/main/java/com/mapcode/Mapcode.java
|
Mapcode.getCode
|
@Nonnull
public String getCode(final int precision, @Nullable final Alphabet alphabet) {
"""
Get the mapcode code (without territory information) with a specified precision.
The returned mapcode includes a '-' separator and additional digits for precisions 1 to 8.
The precision defines the size of a geographical area a single mapcode covers. This means It also defines
the maximum distance to the location, a (latitude, longitude) pair, that encoded to this mapcode.
Precision 0: area is approx 10 x 10 meters (100 m2); max. distance from original location less than 7.5 meters.
Precision 1: area is approx 3.33 m2; max. distance from original location less than 1.5 meters.
Precision 1: area is approx 0.11 m2; max. distance from original location less than 0.4 meters.
etc. (each level reduces the area by a factor of 30)
The accuracy is slightly better than the figures above, but these figures are safe assumptions.
@param precision Precision. Range: 0..8.
@param alphabet Alphabet.
@return Mapcode code.
@throws IllegalArgumentException Thrown if precision is out of range (must be in [0, 8]).
"""
if (precision == 0) {
return convertStringToAlphabet(codePrecision8.substring(0, codePrecision8.length() - 9), alphabet);
} else if (precision <= 8) {
return convertStringToAlphabet(codePrecision8.substring(0, (codePrecision8.length() - 8) + precision),
alphabet);
} else {
throw new IllegalArgumentException("getCodePrecision: precision must be in [0, 8]");
}
}
|
java
|
@Nonnull
public String getCode(final int precision, @Nullable final Alphabet alphabet) {
if (precision == 0) {
return convertStringToAlphabet(codePrecision8.substring(0, codePrecision8.length() - 9), alphabet);
} else if (precision <= 8) {
return convertStringToAlphabet(codePrecision8.substring(0, (codePrecision8.length() - 8) + precision),
alphabet);
} else {
throw new IllegalArgumentException("getCodePrecision: precision must be in [0, 8]");
}
}
|
[
"@",
"Nonnull",
"public",
"String",
"getCode",
"(",
"final",
"int",
"precision",
",",
"@",
"Nullable",
"final",
"Alphabet",
"alphabet",
")",
"{",
"if",
"(",
"precision",
"==",
"0",
")",
"{",
"return",
"convertStringToAlphabet",
"(",
"codePrecision8",
".",
"substring",
"(",
"0",
",",
"codePrecision8",
".",
"length",
"(",
")",
"-",
"9",
")",
",",
"alphabet",
")",
";",
"}",
"else",
"if",
"(",
"precision",
"<=",
"8",
")",
"{",
"return",
"convertStringToAlphabet",
"(",
"codePrecision8",
".",
"substring",
"(",
"0",
",",
"(",
"codePrecision8",
".",
"length",
"(",
")",
"-",
"8",
")",
"+",
"precision",
")",
",",
"alphabet",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"getCodePrecision: precision must be in [0, 8]\"",
")",
";",
"}",
"}"
] |
Get the mapcode code (without territory information) with a specified precision.
The returned mapcode includes a '-' separator and additional digits for precisions 1 to 8.
The precision defines the size of a geographical area a single mapcode covers. This means It also defines
the maximum distance to the location, a (latitude, longitude) pair, that encoded to this mapcode.
Precision 0: area is approx 10 x 10 meters (100 m2); max. distance from original location less than 7.5 meters.
Precision 1: area is approx 3.33 m2; max. distance from original location less than 1.5 meters.
Precision 1: area is approx 0.11 m2; max. distance from original location less than 0.4 meters.
etc. (each level reduces the area by a factor of 30)
The accuracy is slightly better than the figures above, but these figures are safe assumptions.
@param precision Precision. Range: 0..8.
@param alphabet Alphabet.
@return Mapcode code.
@throws IllegalArgumentException Thrown if precision is out of range (must be in [0, 8]).
|
[
"Get",
"the",
"mapcode",
"code",
"(",
"without",
"territory",
"information",
")",
"with",
"a",
"specified",
"precision",
".",
"The",
"returned",
"mapcode",
"includes",
"a",
"-",
"separator",
"and",
"additional",
"digits",
"for",
"precisions",
"1",
"to",
"8",
"."
] |
train
|
https://github.com/mapcode-foundation/mapcode-java/blob/f12d4d9fbd460472ac0fff1f702f2ac716bc0ab8/src/main/java/com/mapcode/Mapcode.java#L152-L162
|
ngageoint/geopackage-java
|
src/main/java/mil/nga/geopackage/property/GeoPackageJavaProperties.java
|
GeoPackageJavaProperties.getIntegerProperty
|
public static Integer getIntegerProperty(String key, boolean required) {
"""
Get an integer property by key
@param key
key
@param required
required flag
@return property value
"""
Integer value = null;
String stringValue = getProperty(key, required);
if (stringValue != null) {
value = Integer.valueOf(stringValue);
}
return value;
}
|
java
|
public static Integer getIntegerProperty(String key, boolean required) {
Integer value = null;
String stringValue = getProperty(key, required);
if (stringValue != null) {
value = Integer.valueOf(stringValue);
}
return value;
}
|
[
"public",
"static",
"Integer",
"getIntegerProperty",
"(",
"String",
"key",
",",
"boolean",
"required",
")",
"{",
"Integer",
"value",
"=",
"null",
";",
"String",
"stringValue",
"=",
"getProperty",
"(",
"key",
",",
"required",
")",
";",
"if",
"(",
"stringValue",
"!=",
"null",
")",
"{",
"value",
"=",
"Integer",
".",
"valueOf",
"(",
"stringValue",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Get an integer property by key
@param key
key
@param required
required flag
@return property value
|
[
"Get",
"an",
"integer",
"property",
"by",
"key"
] |
train
|
https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/property/GeoPackageJavaProperties.java#L110-L117
|
VoltDB/voltdb
|
third_party/java/src/com/google_voltpatches/common/base/internal/Finalizer.java
|
Finalizer.startFinalizer
|
public static void startFinalizer(
Class<?> finalizableReferenceClass,
ReferenceQueue<Object> queue,
PhantomReference<Object> frqReference) {
"""
Starts the Finalizer thread. FinalizableReferenceQueue calls this method reflectively.
@param finalizableReferenceClass FinalizableReference.class.
@param queue a reference queue that the thread will poll.
@param frqReference a phantom reference to the FinalizableReferenceQueue, which will be queued
either when the FinalizableReferenceQueue is no longer referenced anywhere, or when its
close() method is called.
"""
/*
* We use FinalizableReference.class for two things:
*
* 1) To invoke FinalizableReference.finalizeReferent()
*
* 2) To detect when FinalizableReference's class loader has to be garbage collected, at which
* point, Finalizer can stop running
*/
if (!finalizableReferenceClass.getName().equals(FINALIZABLE_REFERENCE)) {
throw new IllegalArgumentException("Expected " + FINALIZABLE_REFERENCE + ".");
}
Finalizer finalizer = new Finalizer(finalizableReferenceClass, queue, frqReference);
Thread thread = new Thread(finalizer);
thread.setName(Finalizer.class.getName());
thread.setDaemon(true);
try {
if (inheritableThreadLocals != null) {
inheritableThreadLocals.set(thread, null);
}
} catch (Throwable t) {
logger.log(
Level.INFO,
"Failed to clear thread local values inherited by reference finalizer thread.",
t);
}
thread.start();
}
|
java
|
public static void startFinalizer(
Class<?> finalizableReferenceClass,
ReferenceQueue<Object> queue,
PhantomReference<Object> frqReference) {
/*
* We use FinalizableReference.class for two things:
*
* 1) To invoke FinalizableReference.finalizeReferent()
*
* 2) To detect when FinalizableReference's class loader has to be garbage collected, at which
* point, Finalizer can stop running
*/
if (!finalizableReferenceClass.getName().equals(FINALIZABLE_REFERENCE)) {
throw new IllegalArgumentException("Expected " + FINALIZABLE_REFERENCE + ".");
}
Finalizer finalizer = new Finalizer(finalizableReferenceClass, queue, frqReference);
Thread thread = new Thread(finalizer);
thread.setName(Finalizer.class.getName());
thread.setDaemon(true);
try {
if (inheritableThreadLocals != null) {
inheritableThreadLocals.set(thread, null);
}
} catch (Throwable t) {
logger.log(
Level.INFO,
"Failed to clear thread local values inherited by reference finalizer thread.",
t);
}
thread.start();
}
|
[
"public",
"static",
"void",
"startFinalizer",
"(",
"Class",
"<",
"?",
">",
"finalizableReferenceClass",
",",
"ReferenceQueue",
"<",
"Object",
">",
"queue",
",",
"PhantomReference",
"<",
"Object",
">",
"frqReference",
")",
"{",
"/*\n * We use FinalizableReference.class for two things:\n *\n * 1) To invoke FinalizableReference.finalizeReferent()\n *\n * 2) To detect when FinalizableReference's class loader has to be garbage collected, at which\n * point, Finalizer can stop running\n */",
"if",
"(",
"!",
"finalizableReferenceClass",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"FINALIZABLE_REFERENCE",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected \"",
"+",
"FINALIZABLE_REFERENCE",
"+",
"\".\"",
")",
";",
"}",
"Finalizer",
"finalizer",
"=",
"new",
"Finalizer",
"(",
"finalizableReferenceClass",
",",
"queue",
",",
"frqReference",
")",
";",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"finalizer",
")",
";",
"thread",
".",
"setName",
"(",
"Finalizer",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"thread",
".",
"setDaemon",
"(",
"true",
")",
";",
"try",
"{",
"if",
"(",
"inheritableThreadLocals",
"!=",
"null",
")",
"{",
"inheritableThreadLocals",
".",
"set",
"(",
"thread",
",",
"null",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Failed to clear thread local values inherited by reference finalizer thread.\"",
",",
"t",
")",
";",
"}",
"thread",
".",
"start",
"(",
")",
";",
"}"
] |
Starts the Finalizer thread. FinalizableReferenceQueue calls this method reflectively.
@param finalizableReferenceClass FinalizableReference.class.
@param queue a reference queue that the thread will poll.
@param frqReference a phantom reference to the FinalizableReferenceQueue, which will be queued
either when the FinalizableReferenceQueue is no longer referenced anywhere, or when its
close() method is called.
|
[
"Starts",
"the",
"Finalizer",
"thread",
".",
"FinalizableReferenceQueue",
"calls",
"this",
"method",
"reflectively",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/base/internal/Finalizer.java#L61-L94
|
mozilla/rhino
|
src/org/mozilla/javascript/ScriptableObject.java
|
ScriptableObject.defineFunctionProperties
|
public void defineFunctionProperties(String[] names, Class<?> clazz,
int attributes) {
"""
Search for names in a class, adding the resulting methods
as properties.
<p> Uses reflection to find the methods of the given names. Then
FunctionObjects are constructed from the methods found, and
are added to this object as properties with the given names.
@param names the names of the Methods to add as function properties
@param clazz the class to search for the Methods
@param attributes the attributes of the new properties
@see org.mozilla.javascript.FunctionObject
"""
Method[] methods = FunctionObject.getMethodList(clazz);
for (int i=0; i < names.length; i++) {
String name = names[i];
Method m = FunctionObject.findSingleMethod(methods, name);
if (m == null) {
throw Context.reportRuntimeError2(
"msg.method.not.found", name, clazz.getName());
}
FunctionObject f = new FunctionObject(name, m, this);
defineProperty(name, f, attributes);
}
}
|
java
|
public void defineFunctionProperties(String[] names, Class<?> clazz,
int attributes)
{
Method[] methods = FunctionObject.getMethodList(clazz);
for (int i=0; i < names.length; i++) {
String name = names[i];
Method m = FunctionObject.findSingleMethod(methods, name);
if (m == null) {
throw Context.reportRuntimeError2(
"msg.method.not.found", name, clazz.getName());
}
FunctionObject f = new FunctionObject(name, m, this);
defineProperty(name, f, attributes);
}
}
|
[
"public",
"void",
"defineFunctionProperties",
"(",
"String",
"[",
"]",
"names",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"int",
"attributes",
")",
"{",
"Method",
"[",
"]",
"methods",
"=",
"FunctionObject",
".",
"getMethodList",
"(",
"clazz",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"name",
"=",
"names",
"[",
"i",
"]",
";",
"Method",
"m",
"=",
"FunctionObject",
".",
"findSingleMethod",
"(",
"methods",
",",
"name",
")",
";",
"if",
"(",
"m",
"==",
"null",
")",
"{",
"throw",
"Context",
".",
"reportRuntimeError2",
"(",
"\"msg.method.not.found\"",
",",
"name",
",",
"clazz",
".",
"getName",
"(",
")",
")",
";",
"}",
"FunctionObject",
"f",
"=",
"new",
"FunctionObject",
"(",
"name",
",",
"m",
",",
"this",
")",
";",
"defineProperty",
"(",
"name",
",",
"f",
",",
"attributes",
")",
";",
"}",
"}"
] |
Search for names in a class, adding the resulting methods
as properties.
<p> Uses reflection to find the methods of the given names. Then
FunctionObjects are constructed from the methods found, and
are added to this object as properties with the given names.
@param names the names of the Methods to add as function properties
@param clazz the class to search for the Methods
@param attributes the attributes of the new properties
@see org.mozilla.javascript.FunctionObject
|
[
"Search",
"for",
"names",
"in",
"a",
"class",
"adding",
"the",
"resulting",
"methods",
"as",
"properties",
"."
] |
train
|
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2148-L2162
|
couchbase/java-dcp-client
|
src/main/java/com/couchbase/client/dcp/util/PatchedNettySnappyDecoder.java
|
PatchedNettySnappyDecoder.decodeCopyWith4ByteOffset
|
private static int decodeCopyWith4ByteOffset(byte tag, ByteBuf in, ByteBuf out, int writtenSoFar) {
"""
Reads a compressed reference offset and length from the supplied input
buffer, seeks back to the appropriate place in the input buffer and
writes the found data to the supplied output stream.
@param tag The tag used to identify this as a copy is also used to encode
the length and part of the offset
@param in The input buffer to read from
@param out The output buffer to write to
@return The number of bytes appended to the output buffer, or -1 to indicate
"try again later"
@throws DecompressionException If the read offset is invalid
"""
if (in.readableBytes() < 4) {
return NOT_ENOUGH_INPUT;
}
int initialIndex = out.writerIndex();
int length = 1 + (tag >> 2 & 0x03F);
// This should arguably be an unsigned int for consistency with the other offset types,
// but we're unlikely to see offsets larger than Integer.MAX_VALUE in the wild.
int offset = ByteBufUtil.swapInt(in.readInt());
validateOffset(offset, writtenSoFar);
out.markReaderIndex();
if (offset < length) {
int copies = length / offset;
for (; copies > 0; copies--) {
out.readerIndex(initialIndex - offset);
out.readBytes(out, offset);
}
if (length % offset != 0) {
out.readerIndex(initialIndex - offset);
out.readBytes(out, length % offset);
}
} else {
out.readerIndex(initialIndex - offset);
out.readBytes(out, length);
}
out.resetReaderIndex();
return length;
}
|
java
|
private static int decodeCopyWith4ByteOffset(byte tag, ByteBuf in, ByteBuf out, int writtenSoFar) {
if (in.readableBytes() < 4) {
return NOT_ENOUGH_INPUT;
}
int initialIndex = out.writerIndex();
int length = 1 + (tag >> 2 & 0x03F);
// This should arguably be an unsigned int for consistency with the other offset types,
// but we're unlikely to see offsets larger than Integer.MAX_VALUE in the wild.
int offset = ByteBufUtil.swapInt(in.readInt());
validateOffset(offset, writtenSoFar);
out.markReaderIndex();
if (offset < length) {
int copies = length / offset;
for (; copies > 0; copies--) {
out.readerIndex(initialIndex - offset);
out.readBytes(out, offset);
}
if (length % offset != 0) {
out.readerIndex(initialIndex - offset);
out.readBytes(out, length % offset);
}
} else {
out.readerIndex(initialIndex - offset);
out.readBytes(out, length);
}
out.resetReaderIndex();
return length;
}
|
[
"private",
"static",
"int",
"decodeCopyWith4ByteOffset",
"(",
"byte",
"tag",
",",
"ByteBuf",
"in",
",",
"ByteBuf",
"out",
",",
"int",
"writtenSoFar",
")",
"{",
"if",
"(",
"in",
".",
"readableBytes",
"(",
")",
"<",
"4",
")",
"{",
"return",
"NOT_ENOUGH_INPUT",
";",
"}",
"int",
"initialIndex",
"=",
"out",
".",
"writerIndex",
"(",
")",
";",
"int",
"length",
"=",
"1",
"+",
"(",
"tag",
">>",
"2",
"&",
"0x03F",
")",
";",
"// This should arguably be an unsigned int for consistency with the other offset types,",
"// but we're unlikely to see offsets larger than Integer.MAX_VALUE in the wild.",
"int",
"offset",
"=",
"ByteBufUtil",
".",
"swapInt",
"(",
"in",
".",
"readInt",
"(",
")",
")",
";",
"validateOffset",
"(",
"offset",
",",
"writtenSoFar",
")",
";",
"out",
".",
"markReaderIndex",
"(",
")",
";",
"if",
"(",
"offset",
"<",
"length",
")",
"{",
"int",
"copies",
"=",
"length",
"/",
"offset",
";",
"for",
"(",
";",
"copies",
">",
"0",
";",
"copies",
"--",
")",
"{",
"out",
".",
"readerIndex",
"(",
"initialIndex",
"-",
"offset",
")",
";",
"out",
".",
"readBytes",
"(",
"out",
",",
"offset",
")",
";",
"}",
"if",
"(",
"length",
"%",
"offset",
"!=",
"0",
")",
"{",
"out",
".",
"readerIndex",
"(",
"initialIndex",
"-",
"offset",
")",
";",
"out",
".",
"readBytes",
"(",
"out",
",",
"length",
"%",
"offset",
")",
";",
"}",
"}",
"else",
"{",
"out",
".",
"readerIndex",
"(",
"initialIndex",
"-",
"offset",
")",
";",
"out",
".",
"readBytes",
"(",
"out",
",",
"length",
")",
";",
"}",
"out",
".",
"resetReaderIndex",
"(",
")",
";",
"return",
"length",
";",
"}"
] |
Reads a compressed reference offset and length from the supplied input
buffer, seeks back to the appropriate place in the input buffer and
writes the found data to the supplied output stream.
@param tag The tag used to identify this as a copy is also used to encode
the length and part of the offset
@param in The input buffer to read from
@param out The output buffer to write to
@return The number of bytes appended to the output buffer, or -1 to indicate
"try again later"
@throws DecompressionException If the read offset is invalid
|
[
"Reads",
"a",
"compressed",
"reference",
"offset",
"and",
"length",
"from",
"the",
"supplied",
"input",
"buffer",
"seeks",
"back",
"to",
"the",
"appropriate",
"place",
"in",
"the",
"input",
"buffer",
"and",
"writes",
"the",
"found",
"data",
"to",
"the",
"supplied",
"output",
"stream",
"."
] |
train
|
https://github.com/couchbase/java-dcp-client/blob/75359d8c081d6c575f8087cf7c28d24ab24c6421/src/main/java/com/couchbase/client/dcp/util/PatchedNettySnappyDecoder.java#L343-L375
|
apache/incubator-gobblin
|
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/MRCompactor.java
|
MRCompactor.datasetAlreadyCompacted
|
public static boolean datasetAlreadyCompacted(FileSystem fs, Dataset dataset, boolean renameSourceEnable) {
"""
A {@link Dataset} is considered already compacted if either condition is true:
1) When completion file strategy is used, a compaction completion means there is a file named
{@link MRCompactor#COMPACTION_COMPLETE_FILE_NAME} in its {@link Dataset#outputPath()}.
2) When renaming source directory strategy is used, a compaction completion means source directories
{@link Dataset#inputPaths()} contains at least one directory which has been renamed to something with
{@link MRCompactor#COMPACTION_RENAME_SOURCE_DIR_SUFFIX}.
"""
if (renameSourceEnable) {
return checkAlreadyCompactedBasedOnSourceDirName (fs, dataset);
} else {
return checkAlreadyCompactedBasedOnCompletionFile(fs, dataset);
}
}
|
java
|
public static boolean datasetAlreadyCompacted(FileSystem fs, Dataset dataset, boolean renameSourceEnable) {
if (renameSourceEnable) {
return checkAlreadyCompactedBasedOnSourceDirName (fs, dataset);
} else {
return checkAlreadyCompactedBasedOnCompletionFile(fs, dataset);
}
}
|
[
"public",
"static",
"boolean",
"datasetAlreadyCompacted",
"(",
"FileSystem",
"fs",
",",
"Dataset",
"dataset",
",",
"boolean",
"renameSourceEnable",
")",
"{",
"if",
"(",
"renameSourceEnable",
")",
"{",
"return",
"checkAlreadyCompactedBasedOnSourceDirName",
"(",
"fs",
",",
"dataset",
")",
";",
"}",
"else",
"{",
"return",
"checkAlreadyCompactedBasedOnCompletionFile",
"(",
"fs",
",",
"dataset",
")",
";",
"}",
"}"
] |
A {@link Dataset} is considered already compacted if either condition is true:
1) When completion file strategy is used, a compaction completion means there is a file named
{@link MRCompactor#COMPACTION_COMPLETE_FILE_NAME} in its {@link Dataset#outputPath()}.
2) When renaming source directory strategy is used, a compaction completion means source directories
{@link Dataset#inputPaths()} contains at least one directory which has been renamed to something with
{@link MRCompactor#COMPACTION_RENAME_SOURCE_DIR_SUFFIX}.
|
[
"A",
"{"
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/MRCompactor.java#L607-L613
|
wildfly/wildfly-core
|
controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java
|
ParseUtils.unsupportedElement
|
public static XMLStreamException unsupportedElement(final XMLExtendedStreamReader reader, String supportedElement) {
"""
Get an exception reporting a missing, required XML attribute.
@param reader the stream reader
@param supportedElement the element that is to be used in place of the unsupported one.
@return the exception
"""
XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unsupportedElement(
new QName(reader.getNamespaceURI(), reader.getLocalName(),reader.getPrefix()), reader.getLocation(), supportedElement);
return new XMLStreamValidationException(ex.getMessage(),
ValidationError.from(ex, ErrorType.UNSUPPORTED_ELEMENT)
.element(reader.getName())
.alternatives(new HashSet<String>() {{add(supportedElement);}}),
ex);
}
|
java
|
public static XMLStreamException unsupportedElement(final XMLExtendedStreamReader reader, String supportedElement) {
XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unsupportedElement(
new QName(reader.getNamespaceURI(), reader.getLocalName(),reader.getPrefix()), reader.getLocation(), supportedElement);
return new XMLStreamValidationException(ex.getMessage(),
ValidationError.from(ex, ErrorType.UNSUPPORTED_ELEMENT)
.element(reader.getName())
.alternatives(new HashSet<String>() {{add(supportedElement);}}),
ex);
}
|
[
"public",
"static",
"XMLStreamException",
"unsupportedElement",
"(",
"final",
"XMLExtendedStreamReader",
"reader",
",",
"String",
"supportedElement",
")",
"{",
"XMLStreamException",
"ex",
"=",
"ControllerLogger",
".",
"ROOT_LOGGER",
".",
"unsupportedElement",
"(",
"new",
"QName",
"(",
"reader",
".",
"getNamespaceURI",
"(",
")",
",",
"reader",
".",
"getLocalName",
"(",
")",
",",
"reader",
".",
"getPrefix",
"(",
")",
")",
",",
"reader",
".",
"getLocation",
"(",
")",
",",
"supportedElement",
")",
";",
"return",
"new",
"XMLStreamValidationException",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ValidationError",
".",
"from",
"(",
"ex",
",",
"ErrorType",
".",
"UNSUPPORTED_ELEMENT",
")",
".",
"element",
"(",
"reader",
".",
"getName",
"(",
")",
")",
".",
"alternatives",
"(",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
"{",
"{",
"add",
"(",
"supportedElement",
")",
";",
"}",
"}",
")",
",",
"ex",
")",
";",
"}"
] |
Get an exception reporting a missing, required XML attribute.
@param reader the stream reader
@param supportedElement the element that is to be used in place of the unsupported one.
@return the exception
|
[
"Get",
"an",
"exception",
"reporting",
"a",
"missing",
"required",
"XML",
"attribute",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java#L644-L653
|
aspectran/aspectran
|
core/src/main/java/com/aspectran/core/activity/request/FileParameter.java
|
FileParameter.saveAs
|
public File saveAs(File destFile, boolean overwrite) throws IOException {
"""
Save an file as a given destination file.
@param destFile the destination file
@param overwrite whether to overwrite if it already exists
@return a saved file
@throws IOException if an I/O error has occurred
"""
if (destFile == null) {
throw new IllegalArgumentException("destFile can not be null");
}
try {
destFile = determineDestinationFile(destFile, overwrite);
final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int len;
try (InputStream input = getInputStream(); OutputStream output = new FileOutputStream(destFile)) {
while ((len = input.read(buffer)) != -1) {
output.write(buffer, 0, len);
}
}
} catch (Exception e) {
throw new IOException("Could not save as file " + destFile, e);
}
setSavedFile(destFile);
return destFile;
}
|
java
|
public File saveAs(File destFile, boolean overwrite) throws IOException {
if (destFile == null) {
throw new IllegalArgumentException("destFile can not be null");
}
try {
destFile = determineDestinationFile(destFile, overwrite);
final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int len;
try (InputStream input = getInputStream(); OutputStream output = new FileOutputStream(destFile)) {
while ((len = input.read(buffer)) != -1) {
output.write(buffer, 0, len);
}
}
} catch (Exception e) {
throw new IOException("Could not save as file " + destFile, e);
}
setSavedFile(destFile);
return destFile;
}
|
[
"public",
"File",
"saveAs",
"(",
"File",
"destFile",
",",
"boolean",
"overwrite",
")",
"throws",
"IOException",
"{",
"if",
"(",
"destFile",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"destFile can not be null\"",
")",
";",
"}",
"try",
"{",
"destFile",
"=",
"determineDestinationFile",
"(",
"destFile",
",",
"overwrite",
")",
";",
"final",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"DEFAULT_BUFFER_SIZE",
"]",
";",
"int",
"len",
";",
"try",
"(",
"InputStream",
"input",
"=",
"getInputStream",
"(",
")",
";",
"OutputStream",
"output",
"=",
"new",
"FileOutputStream",
"(",
"destFile",
")",
")",
"{",
"while",
"(",
"(",
"len",
"=",
"input",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"output",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"len",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not save as file \"",
"+",
"destFile",
",",
"e",
")",
";",
"}",
"setSavedFile",
"(",
"destFile",
")",
";",
"return",
"destFile",
";",
"}"
] |
Save an file as a given destination file.
@param destFile the destination file
@param overwrite whether to overwrite if it already exists
@return a saved file
@throws IOException if an I/O error has occurred
|
[
"Save",
"an",
"file",
"as",
"a",
"given",
"destination",
"file",
"."
] |
train
|
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/request/FileParameter.java#L177-L198
|
Ordinastie/MalisisCore
|
src/main/java/net/malisis/core/renderer/icon/provider/IconProviderBuilder.java
|
IconProviderBuilder.withSide
|
public IconProviderBuilder withSide(EnumFacing side, String iconName) {
"""
Sets the {@link Icon} to use for specific side.
@param side the side
@param iconName the name
@return the icon provider builder
"""
return withSide(side, icon(iconName));
}
|
java
|
public IconProviderBuilder withSide(EnumFacing side, String iconName)
{
return withSide(side, icon(iconName));
}
|
[
"public",
"IconProviderBuilder",
"withSide",
"(",
"EnumFacing",
"side",
",",
"String",
"iconName",
")",
"{",
"return",
"withSide",
"(",
"side",
",",
"icon",
"(",
"iconName",
")",
")",
";",
"}"
] |
Sets the {@link Icon} to use for specific side.
@param side the side
@param iconName the name
@return the icon provider builder
|
[
"Sets",
"the",
"{",
"@link",
"Icon",
"}",
"to",
"use",
"for",
"specific",
"side",
"."
] |
train
|
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/icon/provider/IconProviderBuilder.java#L149-L152
|
samskivert/samskivert
|
src/main/java/com/samskivert/servlet/util/ParameterUtil.java
|
ParameterUtil.getParameter
|
public static String getParameter (HttpServletRequest req, String name, String defval) {
"""
Fetches the supplied parameter from the request. If the parameter does not exist,
<code>defval</code> is returned.
"""
String value = req.getParameter(name);
return StringUtil.isBlank(value) ? defval : value.trim();
}
|
java
|
public static String getParameter (HttpServletRequest req, String name, String defval)
{
String value = req.getParameter(name);
return StringUtil.isBlank(value) ? defval : value.trim();
}
|
[
"public",
"static",
"String",
"getParameter",
"(",
"HttpServletRequest",
"req",
",",
"String",
"name",
",",
"String",
"defval",
")",
"{",
"String",
"value",
"=",
"req",
".",
"getParameter",
"(",
"name",
")",
";",
"return",
"StringUtil",
".",
"isBlank",
"(",
"value",
")",
"?",
"defval",
":",
"value",
".",
"trim",
"(",
")",
";",
"}"
] |
Fetches the supplied parameter from the request. If the parameter does not exist,
<code>defval</code> is returned.
|
[
"Fetches",
"the",
"supplied",
"parameter",
"from",
"the",
"request",
".",
"If",
"the",
"parameter",
"does",
"not",
"exist",
"<code",
">",
"defval<",
"/",
"code",
">",
"is",
"returned",
"."
] |
train
|
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/ParameterUtil.java#L162-L166
|
guardtime/ksi-java-sdk
|
ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java
|
HashTreeBuilder.calculateHeight
|
public long calculateHeight(ImprintNode node, IdentityMetadata metadata) throws HashException, KSIException {
"""
Calculates the height of the hash tree in case a new node with metadata would be added.
@param node a leaf to be added to the tree, must not be null.
@param metadata metadata associated with the node.
@return Height of the hash tree.
@throws HashException
@throws KSIException
"""
return calculateHeight(aggregate(node, metadata));
}
|
java
|
public long calculateHeight(ImprintNode node, IdentityMetadata metadata) throws HashException, KSIException {
return calculateHeight(aggregate(node, metadata));
}
|
[
"public",
"long",
"calculateHeight",
"(",
"ImprintNode",
"node",
",",
"IdentityMetadata",
"metadata",
")",
"throws",
"HashException",
",",
"KSIException",
"{",
"return",
"calculateHeight",
"(",
"aggregate",
"(",
"node",
",",
"metadata",
")",
")",
";",
"}"
] |
Calculates the height of the hash tree in case a new node with metadata would be added.
@param node a leaf to be added to the tree, must not be null.
@param metadata metadata associated with the node.
@return Height of the hash tree.
@throws HashException
@throws KSIException
|
[
"Calculates",
"the",
"height",
"of",
"the",
"hash",
"tree",
"in",
"case",
"a",
"new",
"node",
"with",
"metadata",
"would",
"be",
"added",
"."
] |
train
|
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java#L137-L139
|
primefaces-extensions/core
|
src/main/java/org/primefaces/extensions/component/sheet/SheetRenderer.java
|
SheetRenderer.encodeScript
|
protected void encodeScript(final FacesContext context, final Sheet sheet, final ResponseWriter responseWriter)
throws IOException {
"""
Encodes the Javascript for the sheet.
@param context
@param sheet
@throws IOException
"""
final WidgetBuilder wb = getWidgetBuilder(context);
final String clientId = sheet.getClientId(context);
wb.init("ExtSheet", sheet.resolveWidgetVar(), clientId);
// errors
encodeInvalidData(context, sheet, wb);
// data
encodeData(context, sheet, wb);
// the delta var that will be used to track changes client side
// stringified and placed in hidden input for submission
wb.nativeAttr("delta", "{}");
// filters
encodeFilterVar(context, sheet, wb);
// sortable
encodeSortVar(context, sheet, wb);
// behaviors
encodeBehaviors(context, sheet, wb);
encodeOptionalNativeAttr(wb, "readOnly", sheet.isReadOnly());
encodeOptionalNativeAttr(wb, "fixedColumnsLeft", sheet.getFixedCols());
encodeOptionalNativeAttr(wb, "fixedRowsTop", sheet.getFixedRows());
encodeOptionalNativeAttr(wb, "fixedRowsBottom", sheet.getFixedRowsBottom());
encodeOptionalNativeAttr(wb, "manualColumnResize", sheet.isResizableCols());
encodeOptionalNativeAttr(wb, "manualRowResize", sheet.isResizableRows());
encodeOptionalNativeAttr(wb, "manualColumnMove", sheet.isMovableCols());
encodeOptionalNativeAttr(wb, "manualRowMove", sheet.isMovableRows());
encodeOptionalNativeAttr(wb, "width", sheet.getWidth());
encodeOptionalNativeAttr(wb, "height", sheet.getHeight());
encodeOptionalNativeAttr(wb, "minRows", sheet.getMinRows());
encodeOptionalNativeAttr(wb, "minCols", sheet.getMinCols());
encodeOptionalNativeAttr(wb, "maxRows", sheet.getMaxRows());
encodeOptionalNativeAttr(wb, "maxCols", sheet.getMaxCols());
encodeOptionalAttr(wb, "stretchH", sheet.getStretchH());
encodeOptionalAttr(wb, "language", sheet.getLocale());
encodeOptionalAttr(wb, "selectionMode", sheet.getSelectionMode());
encodeOptionalAttr(wb, "activeHeaderClassName", sheet.getActiveHeaderStyleClass());
encodeOptionalAttr(wb, "commentedCellClassName", sheet.getCommentedCellStyleClass());
encodeOptionalAttr(wb, "currentRowClassName", sheet.getCurrentRowStyleClass());
encodeOptionalAttr(wb, "currentColClassName", sheet.getCurrentColStyleClass());
encodeOptionalAttr(wb, "currentHeaderClassName", sheet.getCurrentHeaderStyleClass());
encodeOptionalAttr(wb, "invalidCellClassName", sheet.getInvalidCellStyleClass());
encodeOptionalAttr(wb, "noWordWrapClassName", sheet.getNoWordWrapStyleClass());
encodeOptionalAttr(wb, "placeholderCellClassName", sheet.getPlaceholderCellStyleClass());
encodeOptionalAttr(wb, "readOnlyCellClassName", sheet.getReadOnlyCellStyleClass());
encodeOptionalNativeAttr(wb, "extender", sheet.getExtender());
String emptyMessage = sheet.getEmptyMessage();
if (LangUtils.isValueBlank(emptyMessage)) {
emptyMessage = "No Records Found";
}
encodeOptionalAttr(wb, "emptyMessage", emptyMessage);
encodeColHeaders(context, sheet, wb);
encodeColOptions(context, sheet, wb);
wb.finish();
}
|
java
|
protected void encodeScript(final FacesContext context, final Sheet sheet, final ResponseWriter responseWriter)
throws IOException {
final WidgetBuilder wb = getWidgetBuilder(context);
final String clientId = sheet.getClientId(context);
wb.init("ExtSheet", sheet.resolveWidgetVar(), clientId);
// errors
encodeInvalidData(context, sheet, wb);
// data
encodeData(context, sheet, wb);
// the delta var that will be used to track changes client side
// stringified and placed in hidden input for submission
wb.nativeAttr("delta", "{}");
// filters
encodeFilterVar(context, sheet, wb);
// sortable
encodeSortVar(context, sheet, wb);
// behaviors
encodeBehaviors(context, sheet, wb);
encodeOptionalNativeAttr(wb, "readOnly", sheet.isReadOnly());
encodeOptionalNativeAttr(wb, "fixedColumnsLeft", sheet.getFixedCols());
encodeOptionalNativeAttr(wb, "fixedRowsTop", sheet.getFixedRows());
encodeOptionalNativeAttr(wb, "fixedRowsBottom", sheet.getFixedRowsBottom());
encodeOptionalNativeAttr(wb, "manualColumnResize", sheet.isResizableCols());
encodeOptionalNativeAttr(wb, "manualRowResize", sheet.isResizableRows());
encodeOptionalNativeAttr(wb, "manualColumnMove", sheet.isMovableCols());
encodeOptionalNativeAttr(wb, "manualRowMove", sheet.isMovableRows());
encodeOptionalNativeAttr(wb, "width", sheet.getWidth());
encodeOptionalNativeAttr(wb, "height", sheet.getHeight());
encodeOptionalNativeAttr(wb, "minRows", sheet.getMinRows());
encodeOptionalNativeAttr(wb, "minCols", sheet.getMinCols());
encodeOptionalNativeAttr(wb, "maxRows", sheet.getMaxRows());
encodeOptionalNativeAttr(wb, "maxCols", sheet.getMaxCols());
encodeOptionalAttr(wb, "stretchH", sheet.getStretchH());
encodeOptionalAttr(wb, "language", sheet.getLocale());
encodeOptionalAttr(wb, "selectionMode", sheet.getSelectionMode());
encodeOptionalAttr(wb, "activeHeaderClassName", sheet.getActiveHeaderStyleClass());
encodeOptionalAttr(wb, "commentedCellClassName", sheet.getCommentedCellStyleClass());
encodeOptionalAttr(wb, "currentRowClassName", sheet.getCurrentRowStyleClass());
encodeOptionalAttr(wb, "currentColClassName", sheet.getCurrentColStyleClass());
encodeOptionalAttr(wb, "currentHeaderClassName", sheet.getCurrentHeaderStyleClass());
encodeOptionalAttr(wb, "invalidCellClassName", sheet.getInvalidCellStyleClass());
encodeOptionalAttr(wb, "noWordWrapClassName", sheet.getNoWordWrapStyleClass());
encodeOptionalAttr(wb, "placeholderCellClassName", sheet.getPlaceholderCellStyleClass());
encodeOptionalAttr(wb, "readOnlyCellClassName", sheet.getReadOnlyCellStyleClass());
encodeOptionalNativeAttr(wb, "extender", sheet.getExtender());
String emptyMessage = sheet.getEmptyMessage();
if (LangUtils.isValueBlank(emptyMessage)) {
emptyMessage = "No Records Found";
}
encodeOptionalAttr(wb, "emptyMessage", emptyMessage);
encodeColHeaders(context, sheet, wb);
encodeColOptions(context, sheet, wb);
wb.finish();
}
|
[
"protected",
"void",
"encodeScript",
"(",
"final",
"FacesContext",
"context",
",",
"final",
"Sheet",
"sheet",
",",
"final",
"ResponseWriter",
"responseWriter",
")",
"throws",
"IOException",
"{",
"final",
"WidgetBuilder",
"wb",
"=",
"getWidgetBuilder",
"(",
"context",
")",
";",
"final",
"String",
"clientId",
"=",
"sheet",
".",
"getClientId",
"(",
"context",
")",
";",
"wb",
".",
"init",
"(",
"\"ExtSheet\"",
",",
"sheet",
".",
"resolveWidgetVar",
"(",
")",
",",
"clientId",
")",
";",
"// errors",
"encodeInvalidData",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"// data",
"encodeData",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"// the delta var that will be used to track changes client side",
"// stringified and placed in hidden input for submission",
"wb",
".",
"nativeAttr",
"(",
"\"delta\"",
",",
"\"{}\"",
")",
";",
"// filters",
"encodeFilterVar",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"// sortable",
"encodeSortVar",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"// behaviors",
"encodeBehaviors",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"readOnly\"",
",",
"sheet",
".",
"isReadOnly",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"fixedColumnsLeft\"",
",",
"sheet",
".",
"getFixedCols",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"fixedRowsTop\"",
",",
"sheet",
".",
"getFixedRows",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"fixedRowsBottom\"",
",",
"sheet",
".",
"getFixedRowsBottom",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"manualColumnResize\"",
",",
"sheet",
".",
"isResizableCols",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"manualRowResize\"",
",",
"sheet",
".",
"isResizableRows",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"manualColumnMove\"",
",",
"sheet",
".",
"isMovableCols",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"manualRowMove\"",
",",
"sheet",
".",
"isMovableRows",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"width\"",
",",
"sheet",
".",
"getWidth",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"height\"",
",",
"sheet",
".",
"getHeight",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"minRows\"",
",",
"sheet",
".",
"getMinRows",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"minCols\"",
",",
"sheet",
".",
"getMinCols",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"maxRows\"",
",",
"sheet",
".",
"getMaxRows",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"maxCols\"",
",",
"sheet",
".",
"getMaxCols",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"stretchH\"",
",",
"sheet",
".",
"getStretchH",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"language\"",
",",
"sheet",
".",
"getLocale",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"selectionMode\"",
",",
"sheet",
".",
"getSelectionMode",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"activeHeaderClassName\"",
",",
"sheet",
".",
"getActiveHeaderStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"commentedCellClassName\"",
",",
"sheet",
".",
"getCommentedCellStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"currentRowClassName\"",
",",
"sheet",
".",
"getCurrentRowStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"currentColClassName\"",
",",
"sheet",
".",
"getCurrentColStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"currentHeaderClassName\"",
",",
"sheet",
".",
"getCurrentHeaderStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"invalidCellClassName\"",
",",
"sheet",
".",
"getInvalidCellStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"noWordWrapClassName\"",
",",
"sheet",
".",
"getNoWordWrapStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"placeholderCellClassName\"",
",",
"sheet",
".",
"getPlaceholderCellStyleClass",
"(",
")",
")",
";",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"readOnlyCellClassName\"",
",",
"sheet",
".",
"getReadOnlyCellStyleClass",
"(",
")",
")",
";",
"encodeOptionalNativeAttr",
"(",
"wb",
",",
"\"extender\"",
",",
"sheet",
".",
"getExtender",
"(",
")",
")",
";",
"String",
"emptyMessage",
"=",
"sheet",
".",
"getEmptyMessage",
"(",
")",
";",
"if",
"(",
"LangUtils",
".",
"isValueBlank",
"(",
"emptyMessage",
")",
")",
"{",
"emptyMessage",
"=",
"\"No Records Found\"",
";",
"}",
"encodeOptionalAttr",
"(",
"wb",
",",
"\"emptyMessage\"",
",",
"emptyMessage",
")",
";",
"encodeColHeaders",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"encodeColOptions",
"(",
"context",
",",
"sheet",
",",
"wb",
")",
";",
"wb",
".",
"finish",
"(",
")",
";",
"}"
] |
Encodes the Javascript for the sheet.
@param context
@param sheet
@throws IOException
|
[
"Encodes",
"the",
"Javascript",
"for",
"the",
"sheet",
"."
] |
train
|
https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetRenderer.java#L182-L241
|
kiswanij/jk-util
|
src/main/java/com/jk/util/mime/MagicMimeEntry.java
|
MagicMimeEntry.matchShort
|
private boolean matchShort(final ByteBuffer bbuf, final ByteOrder bo, final boolean needMask, final short sMask) throws IOException {
"""
Match short.
@param bbuf the bbuf
@param bo the bo
@param needMask the need mask
@param sMask the s mask
@return true, if successful
@throws IOException Signals that an I/O exception has occurred.
"""
bbuf.order(bo);
short got;
final String testContent = getContent();
if (testContent.startsWith("0x")) {
got = (short) Integer.parseInt(testContent.substring(2), 16);
} else if (testContent.startsWith("&")) {
got = (short) Integer.parseInt(testContent.substring(3), 16);
} else {
got = (short) Integer.parseInt(testContent);
}
short found = bbuf.getShort();
if (needMask) {
found = (short) (found & sMask);
}
if (got != found) {
return false;
}
return true;
}
|
java
|
private boolean matchShort(final ByteBuffer bbuf, final ByteOrder bo, final boolean needMask, final short sMask) throws IOException {
bbuf.order(bo);
short got;
final String testContent = getContent();
if (testContent.startsWith("0x")) {
got = (short) Integer.parseInt(testContent.substring(2), 16);
} else if (testContent.startsWith("&")) {
got = (short) Integer.parseInt(testContent.substring(3), 16);
} else {
got = (short) Integer.parseInt(testContent);
}
short found = bbuf.getShort();
if (needMask) {
found = (short) (found & sMask);
}
if (got != found) {
return false;
}
return true;
}
|
[
"private",
"boolean",
"matchShort",
"(",
"final",
"ByteBuffer",
"bbuf",
",",
"final",
"ByteOrder",
"bo",
",",
"final",
"boolean",
"needMask",
",",
"final",
"short",
"sMask",
")",
"throws",
"IOException",
"{",
"bbuf",
".",
"order",
"(",
"bo",
")",
";",
"short",
"got",
";",
"final",
"String",
"testContent",
"=",
"getContent",
"(",
")",
";",
"if",
"(",
"testContent",
".",
"startsWith",
"(",
"\"0x\"",
")",
")",
"{",
"got",
"=",
"(",
"short",
")",
"Integer",
".",
"parseInt",
"(",
"testContent",
".",
"substring",
"(",
"2",
")",
",",
"16",
")",
";",
"}",
"else",
"if",
"(",
"testContent",
".",
"startsWith",
"(",
"\"&\"",
")",
")",
"{",
"got",
"=",
"(",
"short",
")",
"Integer",
".",
"parseInt",
"(",
"testContent",
".",
"substring",
"(",
"3",
")",
",",
"16",
")",
";",
"}",
"else",
"{",
"got",
"=",
"(",
"short",
")",
"Integer",
".",
"parseInt",
"(",
"testContent",
")",
";",
"}",
"short",
"found",
"=",
"bbuf",
".",
"getShort",
"(",
")",
";",
"if",
"(",
"needMask",
")",
"{",
"found",
"=",
"(",
"short",
")",
"(",
"found",
"&",
"sMask",
")",
";",
"}",
"if",
"(",
"got",
"!=",
"found",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Match short.
@param bbuf the bbuf
@param bo the bo
@param needMask the need mask
@param sMask the s mask
@return true, if successful
@throws IOException Signals that an I/O exception has occurred.
|
[
"Match",
"short",
"."
] |
train
|
https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/mime/MagicMimeEntry.java#L595-L618
|
jbossws/jbossws-common
|
src/main/java/org/jboss/ws/common/injection/finders/ReflectionUtils.java
|
ReflectionUtils.assertOneParameter
|
public static void assertOneParameter(final Method method, Class<? extends Annotation> annotation) {
"""
Asserts method have exactly one parameter.
@param method to validate
@param annotation annotation to propagate in exception message
"""
if (method.getParameterTypes().length != 1)
{
throw annotation == null ? MESSAGES.methodHasToDeclareExactlyOneParameter(method) : MESSAGES.methodHasToDeclareExactlyOneParameter2(method, annotation);
}
}
|
java
|
public static void assertOneParameter(final Method method, Class<? extends Annotation> annotation)
{
if (method.getParameterTypes().length != 1)
{
throw annotation == null ? MESSAGES.methodHasToDeclareExactlyOneParameter(method) : MESSAGES.methodHasToDeclareExactlyOneParameter2(method, annotation);
}
}
|
[
"public",
"static",
"void",
"assertOneParameter",
"(",
"final",
"Method",
"method",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
")",
"{",
"if",
"(",
"method",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"!=",
"1",
")",
"{",
"throw",
"annotation",
"==",
"null",
"?",
"MESSAGES",
".",
"methodHasToDeclareExactlyOneParameter",
"(",
"method",
")",
":",
"MESSAGES",
".",
"methodHasToDeclareExactlyOneParameter2",
"(",
"method",
",",
"annotation",
")",
";",
"}",
"}"
] |
Asserts method have exactly one parameter.
@param method to validate
@param annotation annotation to propagate in exception message
|
[
"Asserts",
"method",
"have",
"exactly",
"one",
"parameter",
"."
] |
train
|
https://github.com/jbossws/jbossws-common/blob/fcff8a3ef9bfe046d6fa8c855a3fe4f62841add7/src/main/java/org/jboss/ws/common/injection/finders/ReflectionUtils.java#L277-L283
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java
|
ApiOvhDedicatedserver.serviceName_serviceMonitoring_monitoringId_alert_sms_alertId_GET
|
public OvhSmsAlert serviceName_serviceMonitoring_monitoringId_alert_sms_alertId_GET(String serviceName, Long monitoringId, Long alertId) throws IOException {
"""
Get this object properties
REST: GET /dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/sms/{alertId}
@param serviceName [required] The internal name of your dedicated server
@param monitoringId [required] This monitoring id
@param alertId [required] Id of this alert
"""
String qPath = "/dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/sms/{alertId}";
StringBuilder sb = path(qPath, serviceName, monitoringId, alertId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhSmsAlert.class);
}
|
java
|
public OvhSmsAlert serviceName_serviceMonitoring_monitoringId_alert_sms_alertId_GET(String serviceName, Long monitoringId, Long alertId) throws IOException {
String qPath = "/dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/sms/{alertId}";
StringBuilder sb = path(qPath, serviceName, monitoringId, alertId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhSmsAlert.class);
}
|
[
"public",
"OvhSmsAlert",
"serviceName_serviceMonitoring_monitoringId_alert_sms_alertId_GET",
"(",
"String",
"serviceName",
",",
"Long",
"monitoringId",
",",
"Long",
"alertId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/sms/{alertId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"monitoringId",
",",
"alertId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhSmsAlert",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/sms/{alertId}
@param serviceName [required] The internal name of your dedicated server
@param monitoringId [required] This monitoring id
@param alertId [required] Id of this alert
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L2148-L2153
|
groovy/groovy-core
|
src/main/groovy/ui/GroovyMain.java
|
GroovyMain.getScriptSource
|
protected GroovyCodeSource getScriptSource(boolean isScriptFile, String script) throws IOException, URISyntaxException {
"""
Get a new GroovyCodeSource for a script which may be given as a location
(isScript is true) or as text (isScript is false).
@param isScriptFile indicates whether the script parameter is a location or content
@param script the location or context of the script
@return a new GroovyCodeSource for the given script
@throws IOException
@throws URISyntaxException
@since 2.3.0
"""
//check the script is currently valid before starting a server against the script
if (isScriptFile) {
if (uriPattern.matcher(script).matches()) {
return new GroovyCodeSource(new URI(script));
} else {
return new GroovyCodeSource(huntForTheScriptFile(script));
}
} else {
return new GroovyCodeSource(script, "script_from_command_line", GroovyShell.DEFAULT_CODE_BASE);
}
}
|
java
|
protected GroovyCodeSource getScriptSource(boolean isScriptFile, String script) throws IOException, URISyntaxException {
//check the script is currently valid before starting a server against the script
if (isScriptFile) {
if (uriPattern.matcher(script).matches()) {
return new GroovyCodeSource(new URI(script));
} else {
return new GroovyCodeSource(huntForTheScriptFile(script));
}
} else {
return new GroovyCodeSource(script, "script_from_command_line", GroovyShell.DEFAULT_CODE_BASE);
}
}
|
[
"protected",
"GroovyCodeSource",
"getScriptSource",
"(",
"boolean",
"isScriptFile",
",",
"String",
"script",
")",
"throws",
"IOException",
",",
"URISyntaxException",
"{",
"//check the script is currently valid before starting a server against the script",
"if",
"(",
"isScriptFile",
")",
"{",
"if",
"(",
"uriPattern",
".",
"matcher",
"(",
"script",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"new",
"GroovyCodeSource",
"(",
"new",
"URI",
"(",
"script",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"GroovyCodeSource",
"(",
"huntForTheScriptFile",
"(",
"script",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"new",
"GroovyCodeSource",
"(",
"script",
",",
"\"script_from_command_line\"",
",",
"GroovyShell",
".",
"DEFAULT_CODE_BASE",
")",
";",
"}",
"}"
] |
Get a new GroovyCodeSource for a script which may be given as a location
(isScript is true) or as text (isScript is false).
@param isScriptFile indicates whether the script parameter is a location or content
@param script the location or context of the script
@return a new GroovyCodeSource for the given script
@throws IOException
@throws URISyntaxException
@since 2.3.0
|
[
"Get",
"a",
"new",
"GroovyCodeSource",
"for",
"a",
"script",
"which",
"may",
"be",
"given",
"as",
"a",
"location",
"(",
"isScript",
"is",
"true",
")",
"or",
"as",
"text",
"(",
"isScript",
"is",
"false",
")",
"."
] |
train
|
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/ui/GroovyMain.java#L449-L460
|
VoltDB/voltdb
|
src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java
|
JDBC4CallableStatement.setObject
|
@Override
public void setObject(String parameterName, Object x) throws SQLException {
"""
Sets the value of the designated parameter with the given object.
"""
checkClosed();
throw SQLError.noSupport();
}
|
java
|
@Override
public void setObject(String parameterName, Object x) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
}
|
[
"@",
"Override",
"public",
"void",
"setObject",
"(",
"String",
"parameterName",
",",
"Object",
"x",
")",
"throws",
"SQLException",
"{",
"checkClosed",
"(",
")",
";",
"throw",
"SQLError",
".",
"noSupport",
"(",
")",
";",
"}"
] |
Sets the value of the designated parameter with the given object.
|
[
"Sets",
"the",
"value",
"of",
"the",
"designated",
"parameter",
"with",
"the",
"given",
"object",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java#L831-L836
|
oehf/ipf-oht-atna
|
auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java
|
GenericAuditEventMessageImpl.setAuditSourceId
|
public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypes[] typeCodes) {
"""
Sets a Audit Source Identification block for a given Audit Source ID,
Audit Source Enterprise Site ID, and a list of audit source type codes
@param sourceId The Audit Source ID to use
@param enterpriseSiteId The Audit Enterprise Site ID to use
@param typeCodes The RFC 3881 Audit Source Type codes to use
"""
addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes);
}
|
java
|
public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypes[] typeCodes)
{
addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes);
}
|
[
"public",
"void",
"setAuditSourceId",
"(",
"String",
"sourceId",
",",
"String",
"enterpriseSiteId",
",",
"RFC3881AuditSourceTypes",
"[",
"]",
"typeCodes",
")",
"{",
"addAuditSourceIdentification",
"(",
"sourceId",
",",
"enterpriseSiteId",
",",
"typeCodes",
")",
";",
"}"
] |
Sets a Audit Source Identification block for a given Audit Source ID,
Audit Source Enterprise Site ID, and a list of audit source type codes
@param sourceId The Audit Source ID to use
@param enterpriseSiteId The Audit Enterprise Site ID to use
@param typeCodes The RFC 3881 Audit Source Type codes to use
|
[
"Sets",
"a",
"Audit",
"Source",
"Identification",
"block",
"for",
"a",
"given",
"Audit",
"Source",
"ID",
"Audit",
"Source",
"Enterprise",
"Site",
"ID",
"and",
"a",
"list",
"of",
"audit",
"source",
"type",
"codes"
] |
train
|
https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java#L103-L106
|
alkacon/opencms-core
|
src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java
|
CmsMessageBundleEditorModel.getDefaultState
|
private EditorState getDefaultState() {
"""
Creates the default editor state for editing a bundle with descriptor.
@return the default editor state for editing a bundle with descriptor.
"""
List<TableProperty> cols = new ArrayList<TableProperty>(1);
cols.add(TableProperty.TRANSLATION);
return new EditorState(cols, false);
}
|
java
|
private EditorState getDefaultState() {
List<TableProperty> cols = new ArrayList<TableProperty>(1);
cols.add(TableProperty.TRANSLATION);
return new EditorState(cols, false);
}
|
[
"private",
"EditorState",
"getDefaultState",
"(",
")",
"{",
"List",
"<",
"TableProperty",
">",
"cols",
"=",
"new",
"ArrayList",
"<",
"TableProperty",
">",
"(",
"1",
")",
";",
"cols",
".",
"add",
"(",
"TableProperty",
".",
"TRANSLATION",
")",
";",
"return",
"new",
"EditorState",
"(",
"cols",
",",
"false",
")",
";",
"}"
] |
Creates the default editor state for editing a bundle with descriptor.
@return the default editor state for editing a bundle with descriptor.
|
[
"Creates",
"the",
"default",
"editor",
"state",
"for",
"editing",
"a",
"bundle",
"with",
"descriptor",
"."
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L1243-L1249
|
liferay/com-liferay-commerce
|
commerce-product-api/src/main/java/com/liferay/commerce/product/service/persistence/CProductUtil.java
|
CProductUtil.removeByUUID_G
|
public static CProduct removeByUUID_G(String uuid, long groupId)
throws com.liferay.commerce.product.exception.NoSuchCProductException {
"""
Removes the c product where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the c product that was removed
"""
return getPersistence().removeByUUID_G(uuid, groupId);
}
|
java
|
public static CProduct removeByUUID_G(String uuid, long groupId)
throws com.liferay.commerce.product.exception.NoSuchCProductException {
return getPersistence().removeByUUID_G(uuid, groupId);
}
|
[
"public",
"static",
"CProduct",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"com",
".",
"liferay",
".",
"commerce",
".",
"product",
".",
"exception",
".",
"NoSuchCProductException",
"{",
"return",
"getPersistence",
"(",
")",
".",
"removeByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"}"
] |
Removes the c product where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the c product that was removed
|
[
"Removes",
"the",
"c",
"product",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-api/src/main/java/com/liferay/commerce/product/service/persistence/CProductUtil.java#L310-L313
|
alkacon/opencms-core
|
src/org/opencms/main/CmsAliasResourceHandler.java
|
CmsAliasResourceHandler.redirectToTarget
|
private void redirectToTarget(HttpServletRequest req, HttpServletResponse res, String link, boolean isPermanent)
throws IOException, CmsResourceInitException {
"""
Helper method for sending a redirect to a new URI.<p>
@param req the current request
@param res the current response
@param link the redirect target
@param isPermanent if true, sends a 'moved permanently' redirect
@throws IOException
@throws CmsResourceInitException
"""
CmsResourceInitException resInitException = new CmsResourceInitException(getClass());
if (res != null) {
// preserve request parameters for the redirect
String query = req.getQueryString();
if (query != null) {
link += "?" + query;
}
// disable 404 handler
resInitException.setClearErrors(true);
if (isPermanent) {
res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
res.setHeader("Location", link);
} else {
res.sendRedirect(link);
}
}
throw resInitException;
}
|
java
|
private void redirectToTarget(HttpServletRequest req, HttpServletResponse res, String link, boolean isPermanent)
throws IOException, CmsResourceInitException {
CmsResourceInitException resInitException = new CmsResourceInitException(getClass());
if (res != null) {
// preserve request parameters for the redirect
String query = req.getQueryString();
if (query != null) {
link += "?" + query;
}
// disable 404 handler
resInitException.setClearErrors(true);
if (isPermanent) {
res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
res.setHeader("Location", link);
} else {
res.sendRedirect(link);
}
}
throw resInitException;
}
|
[
"private",
"void",
"redirectToTarget",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
",",
"String",
"link",
",",
"boolean",
"isPermanent",
")",
"throws",
"IOException",
",",
"CmsResourceInitException",
"{",
"CmsResourceInitException",
"resInitException",
"=",
"new",
"CmsResourceInitException",
"(",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"res",
"!=",
"null",
")",
"{",
"// preserve request parameters for the redirect",
"String",
"query",
"=",
"req",
".",
"getQueryString",
"(",
")",
";",
"if",
"(",
"query",
"!=",
"null",
")",
"{",
"link",
"+=",
"\"?\"",
"+",
"query",
";",
"}",
"// disable 404 handler",
"resInitException",
".",
"setClearErrors",
"(",
"true",
")",
";",
"if",
"(",
"isPermanent",
")",
"{",
"res",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_MOVED_PERMANENTLY",
")",
";",
"res",
".",
"setHeader",
"(",
"\"Location\"",
",",
"link",
")",
";",
"}",
"else",
"{",
"res",
".",
"sendRedirect",
"(",
"link",
")",
";",
"}",
"}",
"throw",
"resInitException",
";",
"}"
] |
Helper method for sending a redirect to a new URI.<p>
@param req the current request
@param res the current response
@param link the redirect target
@param isPermanent if true, sends a 'moved permanently' redirect
@throws IOException
@throws CmsResourceInitException
|
[
"Helper",
"method",
"for",
"sending",
"a",
"redirect",
"to",
"a",
"new",
"URI",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsAliasResourceHandler.java#L166-L186
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java
|
Transforms.lessThanOrEqual
|
public static INDArray lessThanOrEqual(INDArray first, INDArray ndArray) {
"""
1 if less than or equal to 0 otherwise (at each element)
@param first
@param ndArray
@return
"""
return lessThanOrEqual(first, ndArray, true);
}
|
java
|
public static INDArray lessThanOrEqual(INDArray first, INDArray ndArray) {
return lessThanOrEqual(first, ndArray, true);
}
|
[
"public",
"static",
"INDArray",
"lessThanOrEqual",
"(",
"INDArray",
"first",
",",
"INDArray",
"ndArray",
")",
"{",
"return",
"lessThanOrEqual",
"(",
"first",
",",
"ndArray",
",",
"true",
")",
";",
"}"
] |
1 if less than or equal to 0 otherwise (at each element)
@param first
@param ndArray
@return
|
[
"1",
"if",
"less",
"than",
"or",
"equal",
"to",
"0",
"otherwise",
"(",
"at",
"each",
"element",
")"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java#L772-L774
|
rzwitserloot/lombok
|
src/core/lombok/bytecode/ClassFileMetaData.java
|
ClassFileMetaData.usesMethod
|
public boolean usesMethod(String className, String methodName, String descriptor) {
"""
Checks if the constant pool contains a reference to a given method.
@param className must be provided JVM-style, such as {@code java/lang/String}
@param descriptor must be provided JVM-style, such as {@code (IZ)Ljava/lang/String;}
"""
int classIndex = findClass(className);
if (classIndex == NOT_FOUND) return false;
int nameAndTypeIndex = findNameAndType(methodName, descriptor);
if (nameAndTypeIndex == NOT_FOUND) return false;
for (int i = 1; i < maxPoolSize; i++) {
if (isMethod(i) &&
readValue(offsets[i]) == classIndex &&
readValue(offsets[i] + 2) == nameAndTypeIndex) return true;
}
return false;
}
|
java
|
public boolean usesMethod(String className, String methodName, String descriptor) {
int classIndex = findClass(className);
if (classIndex == NOT_FOUND) return false;
int nameAndTypeIndex = findNameAndType(methodName, descriptor);
if (nameAndTypeIndex == NOT_FOUND) return false;
for (int i = 1; i < maxPoolSize; i++) {
if (isMethod(i) &&
readValue(offsets[i]) == classIndex &&
readValue(offsets[i] + 2) == nameAndTypeIndex) return true;
}
return false;
}
|
[
"public",
"boolean",
"usesMethod",
"(",
"String",
"className",
",",
"String",
"methodName",
",",
"String",
"descriptor",
")",
"{",
"int",
"classIndex",
"=",
"findClass",
"(",
"className",
")",
";",
"if",
"(",
"classIndex",
"==",
"NOT_FOUND",
")",
"return",
"false",
";",
"int",
"nameAndTypeIndex",
"=",
"findNameAndType",
"(",
"methodName",
",",
"descriptor",
")",
";",
"if",
"(",
"nameAndTypeIndex",
"==",
"NOT_FOUND",
")",
"return",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"maxPoolSize",
";",
"i",
"++",
")",
"{",
"if",
"(",
"isMethod",
"(",
"i",
")",
"&&",
"readValue",
"(",
"offsets",
"[",
"i",
"]",
")",
"==",
"classIndex",
"&&",
"readValue",
"(",
"offsets",
"[",
"i",
"]",
"+",
"2",
")",
"==",
"nameAndTypeIndex",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the constant pool contains a reference to a given method.
@param className must be provided JVM-style, such as {@code java/lang/String}
@param descriptor must be provided JVM-style, such as {@code (IZ)Ljava/lang/String;}
|
[
"Checks",
"if",
"the",
"constant",
"pool",
"contains",
"a",
"reference",
"to",
"a",
"given",
"method",
"."
] |
train
|
https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/bytecode/ClassFileMetaData.java#L205-L217
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java
|
Expressions.stringPath
|
public static StringPath stringPath(Path<?> parent, String property) {
"""
Create a new Path expression
@param parent parent path
@param property property name
@return property path
"""
return new StringPath(PathMetadataFactory.forProperty(parent, property));
}
|
java
|
public static StringPath stringPath(Path<?> parent, String property) {
return new StringPath(PathMetadataFactory.forProperty(parent, property));
}
|
[
"public",
"static",
"StringPath",
"stringPath",
"(",
"Path",
"<",
"?",
">",
"parent",
",",
"String",
"property",
")",
"{",
"return",
"new",
"StringPath",
"(",
"PathMetadataFactory",
".",
"forProperty",
"(",
"parent",
",",
"property",
")",
")",
";",
"}"
] |
Create a new Path expression
@param parent parent path
@param property property name
@return property path
|
[
"Create",
"a",
"new",
"Path",
"expression"
] |
train
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L1506-L1508
|
roboconf/roboconf-platform
|
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
|
Utils.expandTemplate
|
public static String expandTemplate(String s, Properties params) {
"""
Expands a template, replacing each {{ param }} by the corresponding value.
<p>
Eg. "My name is {{ name }}" will result in "My name is Bond", provided that "params" contains "name=Bond".
</p>
@param s the template to expand
@param params the parameters to be expanded in the template
@return the expanded template
"""
String result;
if( params == null || params.size() < 1 ) {
result = s;
} else {
StringBuffer sb = new StringBuffer();
Pattern pattern = Pattern.compile( "\\{\\{\\s*\\S+\\s*\\}\\}" );
Matcher m = pattern.matcher( s );
while( m.find()) {
String raw = m.group();
String varName = m.group().replace('{', ' ').replace('}', ' ').trim();
String val = params.getProperty(varName);
val = (val == null ? raw : val.trim());
m.appendReplacement(sb, val);
}
m.appendTail( sb );
result = sb.toString();
}
return result;
}
|
java
|
public static String expandTemplate(String s, Properties params) {
String result;
if( params == null || params.size() < 1 ) {
result = s;
} else {
StringBuffer sb = new StringBuffer();
Pattern pattern = Pattern.compile( "\\{\\{\\s*\\S+\\s*\\}\\}" );
Matcher m = pattern.matcher( s );
while( m.find()) {
String raw = m.group();
String varName = m.group().replace('{', ' ').replace('}', ' ').trim();
String val = params.getProperty(varName);
val = (val == null ? raw : val.trim());
m.appendReplacement(sb, val);
}
m.appendTail( sb );
result = sb.toString();
}
return result;
}
|
[
"public",
"static",
"String",
"expandTemplate",
"(",
"String",
"s",
",",
"Properties",
"params",
")",
"{",
"String",
"result",
";",
"if",
"(",
"params",
"==",
"null",
"||",
"params",
".",
"size",
"(",
")",
"<",
"1",
")",
"{",
"result",
"=",
"s",
";",
"}",
"else",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"\\\\{\\\\{\\\\s*\\\\S+\\\\s*\\\\}\\\\}\"",
")",
";",
"Matcher",
"m",
"=",
"pattern",
".",
"matcher",
"(",
"s",
")",
";",
"while",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"String",
"raw",
"=",
"m",
".",
"group",
"(",
")",
";",
"String",
"varName",
"=",
"m",
".",
"group",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
".",
"trim",
"(",
")",
";",
"String",
"val",
"=",
"params",
".",
"getProperty",
"(",
"varName",
")",
";",
"val",
"=",
"(",
"val",
"==",
"null",
"?",
"raw",
":",
"val",
".",
"trim",
"(",
")",
")",
";",
"m",
".",
"appendReplacement",
"(",
"sb",
",",
"val",
")",
";",
"}",
"m",
".",
"appendTail",
"(",
"sb",
")",
";",
"result",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Expands a template, replacing each {{ param }} by the corresponding value.
<p>
Eg. "My name is {{ name }}" will result in "My name is Bond", provided that "params" contains "name=Bond".
</p>
@param s the template to expand
@param params the parameters to be expanded in the template
@return the expanded template
|
[
"Expands",
"a",
"template",
"replacing",
"each",
"{{",
"param",
"}}",
"by",
"the",
"corresponding",
"value",
".",
"<p",
">",
"Eg",
".",
"My",
"name",
"is",
"{{",
"name",
"}}",
"will",
"result",
"in",
"My",
"name",
"is",
"Bond",
"provided",
"that",
"params",
"contains",
"name",
"=",
"Bond",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L208-L233
|
apache/reef
|
lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/cli/TFileParser.java
|
TFileParser.parseOneFile
|
void parseOneFile(final Path inputPath, final File outputFolder) throws IOException {
"""
Parses the given file and stores the logs for each container in a file named after the container in the given.
outputFolder
@param inputPath
@param outputFolder
@throws IOException
"""
try (final TFile.Reader.Scanner scanner = this.getScanner(inputPath)) {
while (!scanner.atEnd()) {
new LogFileEntry(scanner.entry()).write(outputFolder);
scanner.advance();
}
}
}
|
java
|
void parseOneFile(final Path inputPath, final File outputFolder) throws IOException {
try (final TFile.Reader.Scanner scanner = this.getScanner(inputPath)) {
while (!scanner.atEnd()) {
new LogFileEntry(scanner.entry()).write(outputFolder);
scanner.advance();
}
}
}
|
[
"void",
"parseOneFile",
"(",
"final",
"Path",
"inputPath",
",",
"final",
"File",
"outputFolder",
")",
"throws",
"IOException",
"{",
"try",
"(",
"final",
"TFile",
".",
"Reader",
".",
"Scanner",
"scanner",
"=",
"this",
".",
"getScanner",
"(",
"inputPath",
")",
")",
"{",
"while",
"(",
"!",
"scanner",
".",
"atEnd",
"(",
")",
")",
"{",
"new",
"LogFileEntry",
"(",
"scanner",
".",
"entry",
"(",
")",
")",
".",
"write",
"(",
"outputFolder",
")",
";",
"scanner",
".",
"advance",
"(",
")",
";",
"}",
"}",
"}"
] |
Parses the given file and stores the logs for each container in a file named after the container in the given.
outputFolder
@param inputPath
@param outputFolder
@throws IOException
|
[
"Parses",
"the",
"given",
"file",
"and",
"stores",
"the",
"logs",
"for",
"each",
"container",
"in",
"a",
"file",
"named",
"after",
"the",
"container",
"in",
"the",
"given",
".",
"outputFolder"
] |
train
|
https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/cli/TFileParser.java#L69-L76
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-hostingprivateDatabase/src/main/java/net/minidev/ovh/api/ApiOvhHostingprivateDatabase.java
|
ApiOvhHostingprivateDatabase.serviceName_dump_dumpId_GET
|
public OvhDump serviceName_dump_dumpId_GET(String serviceName, Long dumpId) throws IOException {
"""
Get this object properties
REST: GET /hosting/privateDatabase/{serviceName}/dump/{dumpId}
@param serviceName [required] The internal name of your private database
@param dumpId [required] Dump id
"""
String qPath = "/hosting/privateDatabase/{serviceName}/dump/{dumpId}";
StringBuilder sb = path(qPath, serviceName, dumpId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDump.class);
}
|
java
|
public OvhDump serviceName_dump_dumpId_GET(String serviceName, Long dumpId) throws IOException {
String qPath = "/hosting/privateDatabase/{serviceName}/dump/{dumpId}";
StringBuilder sb = path(qPath, serviceName, dumpId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDump.class);
}
|
[
"public",
"OvhDump",
"serviceName_dump_dumpId_GET",
"(",
"String",
"serviceName",
",",
"Long",
"dumpId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/privateDatabase/{serviceName}/dump/{dumpId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"dumpId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDump",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /hosting/privateDatabase/{serviceName}/dump/{dumpId}
@param serviceName [required] The internal name of your private database
@param dumpId [required] Dump id
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingprivateDatabase/src/main/java/net/minidev/ovh/api/ApiOvhHostingprivateDatabase.java#L671-L676
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java
|
ComputerVisionImpl.analyzeImageByDomainInStreamAsync
|
public Observable<DomainModelResults> analyzeImageByDomainInStreamAsync(String model, byte[] image, AnalyzeImageByDomainInStreamOptionalParameter analyzeImageByDomainInStreamOptionalParameter) {
"""
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
@param model The domain-specific content to recognize.
@param image An image stream.
@param analyzeImageByDomainInStreamOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DomainModelResults object
"""
return analyzeImageByDomainInStreamWithServiceResponseAsync(model, image, analyzeImageByDomainInStreamOptionalParameter).map(new Func1<ServiceResponse<DomainModelResults>, DomainModelResults>() {
@Override
public DomainModelResults call(ServiceResponse<DomainModelResults> response) {
return response.body();
}
});
}
|
java
|
public Observable<DomainModelResults> analyzeImageByDomainInStreamAsync(String model, byte[] image, AnalyzeImageByDomainInStreamOptionalParameter analyzeImageByDomainInStreamOptionalParameter) {
return analyzeImageByDomainInStreamWithServiceResponseAsync(model, image, analyzeImageByDomainInStreamOptionalParameter).map(new Func1<ServiceResponse<DomainModelResults>, DomainModelResults>() {
@Override
public DomainModelResults call(ServiceResponse<DomainModelResults> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"DomainModelResults",
">",
"analyzeImageByDomainInStreamAsync",
"(",
"String",
"model",
",",
"byte",
"[",
"]",
"image",
",",
"AnalyzeImageByDomainInStreamOptionalParameter",
"analyzeImageByDomainInStreamOptionalParameter",
")",
"{",
"return",
"analyzeImageByDomainInStreamWithServiceResponseAsync",
"(",
"model",
",",
"image",
",",
"analyzeImageByDomainInStreamOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DomainModelResults",
">",
",",
"DomainModelResults",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DomainModelResults",
"call",
"(",
"ServiceResponse",
"<",
"DomainModelResults",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
@param model The domain-specific content to recognize.
@param image An image stream.
@param analyzeImageByDomainInStreamOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DomainModelResults object
|
[
"This",
"operation",
"recognizes",
"content",
"within",
"an",
"image",
"by",
"applying",
"a",
"domain",
"-",
"specific",
"model",
".",
"The",
"list",
"of",
"domain",
"-",
"specific",
"models",
"that",
"are",
"supported",
"by",
"the",
"Computer",
"Vision",
"API",
"can",
"be",
"retrieved",
"using",
"the",
"/",
"models",
"GET",
"request",
".",
"Currently",
"the",
"API",
"only",
"provides",
"a",
"single",
"domain",
"-",
"specific",
"model",
":",
"celebrities",
".",
"Two",
"input",
"methods",
"are",
"supported",
"--",
"(",
"1",
")",
"Uploading",
"an",
"image",
"or",
"(",
"2",
")",
"specifying",
"an",
"image",
"URL",
".",
"A",
"successful",
"response",
"will",
"be",
"returned",
"in",
"JSON",
".",
"If",
"the",
"request",
"failed",
"the",
"response",
"will",
"contain",
"an",
"error",
"code",
"and",
"a",
"message",
"to",
"help",
"understand",
"what",
"went",
"wrong",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java#L284-L291
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java
|
NetworkWatchersInner.getNextHop
|
public NextHopResultInner getNextHop(String resourceGroupName, String networkWatcherName, NextHopParameters parameters) {
"""
Gets the next hop from the specified VM.
@param resourceGroupName The name of the resource group.
@param networkWatcherName The name of the network watcher.
@param parameters Parameters that define the source and destination endpoint.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the NextHopResultInner object if successful.
"""
return getNextHopWithServiceResponseAsync(resourceGroupName, networkWatcherName, parameters).toBlocking().last().body();
}
|
java
|
public NextHopResultInner getNextHop(String resourceGroupName, String networkWatcherName, NextHopParameters parameters) {
return getNextHopWithServiceResponseAsync(resourceGroupName, networkWatcherName, parameters).toBlocking().last().body();
}
|
[
"public",
"NextHopResultInner",
"getNextHop",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkWatcherName",
",",
"NextHopParameters",
"parameters",
")",
"{",
"return",
"getNextHopWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkWatcherName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Gets the next hop from the specified VM.
@param resourceGroupName The name of the resource group.
@param networkWatcherName The name of the network watcher.
@param parameters Parameters that define the source and destination endpoint.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the NextHopResultInner object if successful.
|
[
"Gets",
"the",
"next",
"hop",
"from",
"the",
"specified",
"VM",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/NetworkWatchersInner.java#L1126-L1128
|
agmip/agmip-common-functions
|
src/main/java/org/agmip/functions/ExperimentHelper.java
|
ExperimentHelper.getFstPdate
|
public static String getFstPdate(Map data, String defValue) {
"""
Get the first planting date from given data set.
@param data The experiment data holder
@param defValue The value used for return when planting date is unavailable
@return The planting date
"""
ArrayList<HashMap<String, String>> events = getBucket(data, "management").getDataList();
Event event = new Event(events, "planting");
return getValueOr(event.getCurrentEvent(), "date", defValue);
}
|
java
|
public static String getFstPdate(Map data, String defValue) {
ArrayList<HashMap<String, String>> events = getBucket(data, "management").getDataList();
Event event = new Event(events, "planting");
return getValueOr(event.getCurrentEvent(), "date", defValue);
}
|
[
"public",
"static",
"String",
"getFstPdate",
"(",
"Map",
"data",
",",
"String",
"defValue",
")",
"{",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"String",
">",
">",
"events",
"=",
"getBucket",
"(",
"data",
",",
"\"management\"",
")",
".",
"getDataList",
"(",
")",
";",
"Event",
"event",
"=",
"new",
"Event",
"(",
"events",
",",
"\"planting\"",
")",
";",
"return",
"getValueOr",
"(",
"event",
".",
"getCurrentEvent",
"(",
")",
",",
"\"date\"",
",",
"defValue",
")",
";",
"}"
] |
Get the first planting date from given data set.
@param data The experiment data holder
@param defValue The value used for return when planting date is unavailable
@return The planting date
|
[
"Get",
"the",
"first",
"planting",
"date",
"from",
"given",
"data",
"set",
"."
] |
train
|
https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/functions/ExperimentHelper.java#L1199-L1203
|
lucee/Lucee
|
core/src/main/java/lucee/runtime/type/scope/client/ClientDatasource.java
|
ClientDatasource.getInstance
|
public static Client getInstance(String datasourceName, PageContext pc, Log log) throws PageException {
"""
load an new instance of the client datasource scope
@param datasourceName
@param appName
@param pc
@param log
@return client datasource scope
@throws PageException
"""
Struct _sct = _loadData(pc, datasourceName, "client", SCOPE_CLIENT, log, false);
if (_sct == null) _sct = new StructImpl();
return new ClientDatasource(pc, datasourceName, _sct);
}
|
java
|
public static Client getInstance(String datasourceName, PageContext pc, Log log) throws PageException {
Struct _sct = _loadData(pc, datasourceName, "client", SCOPE_CLIENT, log, false);
if (_sct == null) _sct = new StructImpl();
return new ClientDatasource(pc, datasourceName, _sct);
}
|
[
"public",
"static",
"Client",
"getInstance",
"(",
"String",
"datasourceName",
",",
"PageContext",
"pc",
",",
"Log",
"log",
")",
"throws",
"PageException",
"{",
"Struct",
"_sct",
"=",
"_loadData",
"(",
"pc",
",",
"datasourceName",
",",
"\"client\"",
",",
"SCOPE_CLIENT",
",",
"log",
",",
"false",
")",
";",
"if",
"(",
"_sct",
"==",
"null",
")",
"_sct",
"=",
"new",
"StructImpl",
"(",
")",
";",
"return",
"new",
"ClientDatasource",
"(",
"pc",
",",
"datasourceName",
",",
"_sct",
")",
";",
"}"
] |
load an new instance of the client datasource scope
@param datasourceName
@param appName
@param pc
@param log
@return client datasource scope
@throws PageException
|
[
"load",
"an",
"new",
"instance",
"of",
"the",
"client",
"datasource",
"scope"
] |
train
|
https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/type/scope/client/ClientDatasource.java#L55-L61
|
google/closure-compiler
|
src/com/google/javascript/jscomp/NodeUtil.java
|
NodeUtil.deleteNode
|
public static void deleteNode(Node n, AbstractCompiler compiler) {
"""
Permanently delete the given node from the AST, as well as report
the related AST changes/deletions to the given compiler.
"""
Node parent = n.getParent();
NodeUtil.markFunctionsDeleted(n, compiler);
n.detach();
compiler.reportChangeToEnclosingScope(parent);
}
|
java
|
public static void deleteNode(Node n, AbstractCompiler compiler) {
Node parent = n.getParent();
NodeUtil.markFunctionsDeleted(n, compiler);
n.detach();
compiler.reportChangeToEnclosingScope(parent);
}
|
[
"public",
"static",
"void",
"deleteNode",
"(",
"Node",
"n",
",",
"AbstractCompiler",
"compiler",
")",
"{",
"Node",
"parent",
"=",
"n",
".",
"getParent",
"(",
")",
";",
"NodeUtil",
".",
"markFunctionsDeleted",
"(",
"n",
",",
"compiler",
")",
";",
"n",
".",
"detach",
"(",
")",
";",
"compiler",
".",
"reportChangeToEnclosingScope",
"(",
"parent",
")",
";",
"}"
] |
Permanently delete the given node from the AST, as well as report
the related AST changes/deletions to the given compiler.
|
[
"Permanently",
"delete",
"the",
"given",
"node",
"from",
"the",
"AST",
"as",
"well",
"as",
"report",
"the",
"related",
"AST",
"changes",
"/",
"deletions",
"to",
"the",
"given",
"compiler",
"."
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2746-L2751
|
BlueBrain/bluima
|
modules/bluima_abbreviations/src/main/java/com/wcohen/ss/Mixture.java
|
Mixture.score
|
public double score(StringWrapper s,StringWrapper t) {
"""
Distance is argmax_lambda prod_{w in s} lambda Pr(w|t) * (1-lambda) Pr(w|background).
This is computed with E/M.
"""
BagOfTokens sBag = asBagOfTokens(s);
BagOfTokens tBag = asBagOfTokens(t);
double lambda = 0.5;
int iterations = 0;
while (true) {
double newLamba = 0.0;
// E step: compute prob each token is draw from T
for (Iterator i = sBag.tokenIterator(); i.hasNext(); ) {
Token tok = (Token)i.next();
double sWeight = sBag.getWeight(tok);
double tWeight = tBag.getWeight(tok);
double probTokGivenT = tWeight/tBag.getTotalWeight();
double probTokGivenCorpus = ((double)getDocumentFrequency(tok))/totalTokenCount;
double probDrawnFromT = lambda * probTokGivenT;
double probDrawnFromCorpus = (1.0-lambda) * probTokGivenCorpus;
double normalizingConstant = probTokGivenT + probTokGivenCorpus;
probDrawnFromT /= normalizingConstant;
probDrawnFromCorpus /= normalizingConstant;
newLamba += probDrawnFromT * sWeight;
}
// M step: find best value of lambda
newLamba /= sBag.getTotalWeight();
// halt if converged
double change = newLamba - lambda;
if (iterations>maxIterate || (change>= -minChange && change<=minChange)) break;
else lambda = newLamba;
}
return lambda;
}
|
java
|
public double score(StringWrapper s,StringWrapper t)
{
BagOfTokens sBag = asBagOfTokens(s);
BagOfTokens tBag = asBagOfTokens(t);
double lambda = 0.5;
int iterations = 0;
while (true) {
double newLamba = 0.0;
// E step: compute prob each token is draw from T
for (Iterator i = sBag.tokenIterator(); i.hasNext(); ) {
Token tok = (Token)i.next();
double sWeight = sBag.getWeight(tok);
double tWeight = tBag.getWeight(tok);
double probTokGivenT = tWeight/tBag.getTotalWeight();
double probTokGivenCorpus = ((double)getDocumentFrequency(tok))/totalTokenCount;
double probDrawnFromT = lambda * probTokGivenT;
double probDrawnFromCorpus = (1.0-lambda) * probTokGivenCorpus;
double normalizingConstant = probTokGivenT + probTokGivenCorpus;
probDrawnFromT /= normalizingConstant;
probDrawnFromCorpus /= normalizingConstant;
newLamba += probDrawnFromT * sWeight;
}
// M step: find best value of lambda
newLamba /= sBag.getTotalWeight();
// halt if converged
double change = newLamba - lambda;
if (iterations>maxIterate || (change>= -minChange && change<=minChange)) break;
else lambda = newLamba;
}
return lambda;
}
|
[
"public",
"double",
"score",
"(",
"StringWrapper",
"s",
",",
"StringWrapper",
"t",
")",
"{",
"BagOfTokens",
"sBag",
"=",
"asBagOfTokens",
"(",
"s",
")",
";",
"BagOfTokens",
"tBag",
"=",
"asBagOfTokens",
"(",
"t",
")",
";",
"double",
"lambda",
"=",
"0.5",
";",
"int",
"iterations",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"double",
"newLamba",
"=",
"0.0",
";",
"// E step: compute prob each token is draw from T",
"for",
"(",
"Iterator",
"i",
"=",
"sBag",
".",
"tokenIterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Token",
"tok",
"=",
"(",
"Token",
")",
"i",
".",
"next",
"(",
")",
";",
"double",
"sWeight",
"=",
"sBag",
".",
"getWeight",
"(",
"tok",
")",
";",
"double",
"tWeight",
"=",
"tBag",
".",
"getWeight",
"(",
"tok",
")",
";",
"double",
"probTokGivenT",
"=",
"tWeight",
"/",
"tBag",
".",
"getTotalWeight",
"(",
")",
";",
"double",
"probTokGivenCorpus",
"=",
"(",
"(",
"double",
")",
"getDocumentFrequency",
"(",
"tok",
")",
")",
"/",
"totalTokenCount",
";",
"double",
"probDrawnFromT",
"=",
"lambda",
"*",
"probTokGivenT",
";",
"double",
"probDrawnFromCorpus",
"=",
"(",
"1.0",
"-",
"lambda",
")",
"*",
"probTokGivenCorpus",
";",
"double",
"normalizingConstant",
"=",
"probTokGivenT",
"+",
"probTokGivenCorpus",
";",
"probDrawnFromT",
"/=",
"normalizingConstant",
";",
"probDrawnFromCorpus",
"/=",
"normalizingConstant",
";",
"newLamba",
"+=",
"probDrawnFromT",
"*",
"sWeight",
";",
"}",
"// M step: find best value of lambda",
"newLamba",
"/=",
"sBag",
".",
"getTotalWeight",
"(",
")",
";",
"// halt if converged",
"double",
"change",
"=",
"newLamba",
"-",
"lambda",
";",
"if",
"(",
"iterations",
">",
"maxIterate",
"||",
"(",
"change",
">=",
"-",
"minChange",
"&&",
"change",
"<=",
"minChange",
")",
")",
"break",
";",
"else",
"lambda",
"=",
"newLamba",
";",
"}",
"return",
"lambda",
";",
"}"
] |
Distance is argmax_lambda prod_{w in s} lambda Pr(w|t) * (1-lambda) Pr(w|background).
This is computed with E/M.
|
[
"Distance",
"is",
"argmax_lambda",
"prod_",
"{",
"w",
"in",
"s",
"}",
"lambda",
"Pr",
"(",
"w|t",
")",
"*",
"(",
"1",
"-",
"lambda",
")",
"Pr",
"(",
"w|background",
")",
".",
"This",
"is",
"computed",
"with",
"E",
"/",
"M",
"."
] |
train
|
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_abbreviations/src/main/java/com/wcohen/ss/Mixture.java#L21-L51
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java
|
AbstractMemberPropertyAccessor.introspectFields
|
private void introspectFields(Class type, Set introspectedClasses) {
"""
Introspect fields of a class. This excludes static fields and handles
final fields as readOnly.
@param type the class to inspect.
@param introspectedClasses a set of already inspected classes.
"""
if (type == null || Object.class.equals(type) || type.isInterface() || introspectedClasses.contains(type)) {
return;
}
introspectedClasses.add(type);
introspectFields(type.getSuperclass(), introspectedClasses);
Field[] fields = type.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
if (!Modifier.isStatic(fields[i].getModifiers())) {
readAccessors.put(fields[i].getName(), fields[i]);
if (!Modifier.isFinal(fields[i].getModifiers())) {
writeAccessors.put(fields[i].getName(), fields[i]);
}
}
}
}
|
java
|
private void introspectFields(Class type, Set introspectedClasses) {
if (type == null || Object.class.equals(type) || type.isInterface() || introspectedClasses.contains(type)) {
return;
}
introspectedClasses.add(type);
introspectFields(type.getSuperclass(), introspectedClasses);
Field[] fields = type.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
if (!Modifier.isStatic(fields[i].getModifiers())) {
readAccessors.put(fields[i].getName(), fields[i]);
if (!Modifier.isFinal(fields[i].getModifiers())) {
writeAccessors.put(fields[i].getName(), fields[i]);
}
}
}
}
|
[
"private",
"void",
"introspectFields",
"(",
"Class",
"type",
",",
"Set",
"introspectedClasses",
")",
"{",
"if",
"(",
"type",
"==",
"null",
"||",
"Object",
".",
"class",
".",
"equals",
"(",
"type",
")",
"||",
"type",
".",
"isInterface",
"(",
")",
"||",
"introspectedClasses",
".",
"contains",
"(",
"type",
")",
")",
"{",
"return",
";",
"}",
"introspectedClasses",
".",
"add",
"(",
"type",
")",
";",
"introspectFields",
"(",
"type",
".",
"getSuperclass",
"(",
")",
",",
"introspectedClasses",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"type",
".",
"getDeclaredFields",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"Modifier",
".",
"isStatic",
"(",
"fields",
"[",
"i",
"]",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"readAccessors",
".",
"put",
"(",
"fields",
"[",
"i",
"]",
".",
"getName",
"(",
")",
",",
"fields",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"Modifier",
".",
"isFinal",
"(",
"fields",
"[",
"i",
"]",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"writeAccessors",
".",
"put",
"(",
"fields",
"[",
"i",
"]",
".",
"getName",
"(",
")",
",",
"fields",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"}"
] |
Introspect fields of a class. This excludes static fields and handles
final fields as readOnly.
@param type the class to inspect.
@param introspectedClasses a set of already inspected classes.
|
[
"Introspect",
"fields",
"of",
"a",
"class",
".",
"This",
"excludes",
"static",
"fields",
"and",
"handles",
"final",
"fields",
"as",
"readOnly",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/beans/AbstractMemberPropertyAccessor.java#L90-L105
|
GenesysPureEngage/provisioning-client-java
|
src/main/java/com/genesys/internal/provisioning/api/NotificationsApi.java
|
NotificationsApi.postHandshakeWithHttpInfo
|
public ApiResponse<Void> postHandshakeWithHttpInfo() throws ApiException {
"""
CometD handshake
CometD handshake, see https://docs.cometd.org/current/reference/#_bayeux_meta_handshake
@return ApiResponse<Void>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
com.squareup.okhttp.Call call = postHandshakeValidateBeforeCall(null, null);
return apiClient.execute(call);
}
|
java
|
public ApiResponse<Void> postHandshakeWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = postHandshakeValidateBeforeCall(null, null);
return apiClient.execute(call);
}
|
[
"public",
"ApiResponse",
"<",
"Void",
">",
"postHandshakeWithHttpInfo",
"(",
")",
"throws",
"ApiException",
"{",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"postHandshakeValidateBeforeCall",
"(",
"null",
",",
"null",
")",
";",
"return",
"apiClient",
".",
"execute",
"(",
"call",
")",
";",
"}"
] |
CometD handshake
CometD handshake, see https://docs.cometd.org/current/reference/#_bayeux_meta_handshake
@return ApiResponse<Void>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
[
"CometD",
"handshake",
"CometD",
"handshake",
"see",
"https",
":",
"//",
"docs",
".",
"cometd",
".",
"org",
"/",
"current",
"/",
"reference",
"/",
"#_bayeux_meta_handshake"
] |
train
|
https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/NotificationsApi.java#L564-L567
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_ovhPabx_serviceName_menu_menuId_entry_POST
|
public OvhOvhPabxMenuEntry billingAccount_ovhPabx_serviceName_menu_menuId_entry_POST(String billingAccount, String serviceName, Long menuId, OvhOvhPabxIvrMenuEntryActionEnum action, String actionParam, String dtmf, Long position) throws IOException {
"""
Create a new menu entry
REST: POST /telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry
@param dtmf [required] The DTMF that triggers the action
@param position [required] The position of the entry in the menu
@param action [required] The action triggered by the DTMF
@param actionParam [required] The additionnal parameter of the action
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param menuId [required]
"""
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry";
StringBuilder sb = path(qPath, billingAccount, serviceName, menuId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "action", action);
addBody(o, "actionParam", actionParam);
addBody(o, "dtmf", dtmf);
addBody(o, "position", position);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOvhPabxMenuEntry.class);
}
|
java
|
public OvhOvhPabxMenuEntry billingAccount_ovhPabx_serviceName_menu_menuId_entry_POST(String billingAccount, String serviceName, Long menuId, OvhOvhPabxIvrMenuEntryActionEnum action, String actionParam, String dtmf, Long position) throws IOException {
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry";
StringBuilder sb = path(qPath, billingAccount, serviceName, menuId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "action", action);
addBody(o, "actionParam", actionParam);
addBody(o, "dtmf", dtmf);
addBody(o, "position", position);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOvhPabxMenuEntry.class);
}
|
[
"public",
"OvhOvhPabxMenuEntry",
"billingAccount_ovhPabx_serviceName_menu_menuId_entry_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"menuId",
",",
"OvhOvhPabxIvrMenuEntryActionEnum",
"action",
",",
"String",
"actionParam",
",",
"String",
"dtmf",
",",
"Long",
"position",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"menuId",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"action\"",
",",
"action",
")",
";",
"addBody",
"(",
"o",
",",
"\"actionParam\"",
",",
"actionParam",
")",
";",
"addBody",
"(",
"o",
",",
"\"dtmf\"",
",",
"dtmf",
")",
";",
"addBody",
"(",
"o",
",",
"\"position\"",
",",
"position",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOvhPabxMenuEntry",
".",
"class",
")",
";",
"}"
] |
Create a new menu entry
REST: POST /telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry
@param dtmf [required] The DTMF that triggers the action
@param position [required] The position of the entry in the menu
@param action [required] The action triggered by the DTMF
@param actionParam [required] The additionnal parameter of the action
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param menuId [required]
|
[
"Create",
"a",
"new",
"menu",
"entry"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7471-L7481
|
NoraUi/NoraUi
|
src/main/java/com/github/noraui/application/steps/Step.java
|
Step.saveElementValue
|
protected void saveElementValue(String field, Page page) throws TechnicalException, FailureException {
"""
Save value in memory using default target key (Page key + field).
@param field
is name of the field to retrieve.
@param page
is target page.
@throws TechnicalException
is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} message (with screenshot, with exception) or with
{@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_RETRIEVE_VALUE} message
(with screenshot, with exception)
@throws FailureException
if the scenario encounters a functional error
"""
logger.debug("saveValueInStep: {} in {}.", field, page.getApplication());
saveElementValue(field, page.getPageKey() + field, page);
}
|
java
|
protected void saveElementValue(String field, Page page) throws TechnicalException, FailureException {
logger.debug("saveValueInStep: {} in {}.", field, page.getApplication());
saveElementValue(field, page.getPageKey() + field, page);
}
|
[
"protected",
"void",
"saveElementValue",
"(",
"String",
"field",
",",
"Page",
"page",
")",
"throws",
"TechnicalException",
",",
"FailureException",
"{",
"logger",
".",
"debug",
"(",
"\"saveValueInStep: {} in {}.\"",
",",
"field",
",",
"page",
".",
"getApplication",
"(",
")",
")",
";",
"saveElementValue",
"(",
"field",
",",
"page",
".",
"getPageKey",
"(",
")",
"+",
"field",
",",
"page",
")",
";",
"}"
] |
Save value in memory using default target key (Page key + field).
@param field
is name of the field to retrieve.
@param page
is target page.
@throws TechnicalException
is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} message (with screenshot, with exception) or with
{@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_RETRIEVE_VALUE} message
(with screenshot, with exception)
@throws FailureException
if the scenario encounters a functional error
|
[
"Save",
"value",
"in",
"memory",
"using",
"default",
"target",
"key",
"(",
"Page",
"key",
"+",
"field",
")",
"."
] |
train
|
https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/Step.java#L546-L549
|
hector-client/hector
|
core/src/main/java/me/prettyprint/cassandra/connection/security/KerberosHelper.java
|
KerberosHelper.authenticateClient
|
public static GSSContext authenticateClient(final Socket socket, Subject subject, final String servicePrincipalName) {
"""
Authenticate client to use this service and return secure context
@param socket
The socket used for communication
@param subject
The Kerberos service subject
@param servicePrincipalName
Service principal name
@return context if authorized or null
"""
return Subject.doAs(subject, new PrivilegedAction<GSSContext>() {
public GSSContext run() {
try {
GSSManager manager = GSSManager.getInstance();
GSSName peerName = manager.createName(servicePrincipalName, GSSName.NT_HOSTBASED_SERVICE);
GSSContext context = manager.createContext(peerName, null, null, GSSContext.DEFAULT_LIFETIME);
// Loop while the context is still not established
while (!context.isEstablished()) {
context.initSecContext(socket.getInputStream(), socket.getOutputStream());
}
return context;
} catch (Exception e) {
log.error("Unable to authenticate client against Kerberos", e);
return null;
}
}
});
}
|
java
|
public static GSSContext authenticateClient(final Socket socket, Subject subject, final String servicePrincipalName) {
return Subject.doAs(subject, new PrivilegedAction<GSSContext>() {
public GSSContext run() {
try {
GSSManager manager = GSSManager.getInstance();
GSSName peerName = manager.createName(servicePrincipalName, GSSName.NT_HOSTBASED_SERVICE);
GSSContext context = manager.createContext(peerName, null, null, GSSContext.DEFAULT_LIFETIME);
// Loop while the context is still not established
while (!context.isEstablished()) {
context.initSecContext(socket.getInputStream(), socket.getOutputStream());
}
return context;
} catch (Exception e) {
log.error("Unable to authenticate client against Kerberos", e);
return null;
}
}
});
}
|
[
"public",
"static",
"GSSContext",
"authenticateClient",
"(",
"final",
"Socket",
"socket",
",",
"Subject",
"subject",
",",
"final",
"String",
"servicePrincipalName",
")",
"{",
"return",
"Subject",
".",
"doAs",
"(",
"subject",
",",
"new",
"PrivilegedAction",
"<",
"GSSContext",
">",
"(",
")",
"{",
"public",
"GSSContext",
"run",
"(",
")",
"{",
"try",
"{",
"GSSManager",
"manager",
"=",
"GSSManager",
".",
"getInstance",
"(",
")",
";",
"GSSName",
"peerName",
"=",
"manager",
".",
"createName",
"(",
"servicePrincipalName",
",",
"GSSName",
".",
"NT_HOSTBASED_SERVICE",
")",
";",
"GSSContext",
"context",
"=",
"manager",
".",
"createContext",
"(",
"peerName",
",",
"null",
",",
"null",
",",
"GSSContext",
".",
"DEFAULT_LIFETIME",
")",
";",
"// Loop while the context is still not established",
"while",
"(",
"!",
"context",
".",
"isEstablished",
"(",
")",
")",
"{",
"context",
".",
"initSecContext",
"(",
"socket",
".",
"getInputStream",
"(",
")",
",",
"socket",
".",
"getOutputStream",
"(",
")",
")",
";",
"}",
"return",
"context",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to authenticate client against Kerberos\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Authenticate client to use this service and return secure context
@param socket
The socket used for communication
@param subject
The Kerberos service subject
@param servicePrincipalName
Service principal name
@return context if authorized or null
|
[
"Authenticate",
"client",
"to",
"use",
"this",
"service",
"and",
"return",
"secure",
"context"
] |
train
|
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/connection/security/KerberosHelper.java#L72-L92
|
Omertron/api-rottentomatoes
|
src/main/java/com/omertron/rottentomatoesapi/tools/ResponseBuilder.java
|
ResponseBuilder.getContent
|
private String getContent(String url) throws RottenTomatoesException {
"""
Get the content from a string, decoding it if it is in GZIP format
@param urlString
@return
@throws RottenTomatoesException
"""
LOG.trace("Requesting: {}", url);
try {
final HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("accept", "application/json");
final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, charset);
if (response.getStatusCode() >= HTTP_STATUS_500) {
throw new RottenTomatoesException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url);
} else if (response.getStatusCode() >= HTTP_STATUS_300) {
throw new RottenTomatoesException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url);
}
return response.getContent();
} catch (IOException ex) {
throw new RottenTomatoesException(ApiExceptionType.CONNECTION_ERROR, "Error retrieving URL", url, ex);
}
}
|
java
|
private String getContent(String url) throws RottenTomatoesException {
LOG.trace("Requesting: {}", url);
try {
final HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("accept", "application/json");
final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, charset);
if (response.getStatusCode() >= HTTP_STATUS_500) {
throw new RottenTomatoesException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url);
} else if (response.getStatusCode() >= HTTP_STATUS_300) {
throw new RottenTomatoesException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url);
}
return response.getContent();
} catch (IOException ex) {
throw new RottenTomatoesException(ApiExceptionType.CONNECTION_ERROR, "Error retrieving URL", url, ex);
}
}
|
[
"private",
"String",
"getContent",
"(",
"String",
"url",
")",
"throws",
"RottenTomatoesException",
"{",
"LOG",
".",
"trace",
"(",
"\"Requesting: {}\"",
",",
"url",
")",
";",
"try",
"{",
"final",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"url",
")",
";",
"httpGet",
".",
"addHeader",
"(",
"\"accept\"",
",",
"\"application/json\"",
")",
";",
"final",
"DigestedResponse",
"response",
"=",
"DigestedResponseReader",
".",
"requestContent",
"(",
"httpClient",
",",
"httpGet",
",",
"charset",
")",
";",
"if",
"(",
"response",
".",
"getStatusCode",
"(",
")",
">=",
"HTTP_STATUS_500",
")",
"{",
"throw",
"new",
"RottenTomatoesException",
"(",
"ApiExceptionType",
".",
"HTTP_503_ERROR",
",",
"response",
".",
"getContent",
"(",
")",
",",
"response",
".",
"getStatusCode",
"(",
")",
",",
"url",
")",
";",
"}",
"else",
"if",
"(",
"response",
".",
"getStatusCode",
"(",
")",
">=",
"HTTP_STATUS_300",
")",
"{",
"throw",
"new",
"RottenTomatoesException",
"(",
"ApiExceptionType",
".",
"HTTP_404_ERROR",
",",
"response",
".",
"getContent",
"(",
")",
",",
"response",
".",
"getStatusCode",
"(",
")",
",",
"url",
")",
";",
"}",
"return",
"response",
".",
"getContent",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RottenTomatoesException",
"(",
"ApiExceptionType",
".",
"CONNECTION_ERROR",
",",
"\"Error retrieving URL\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"}"
] |
Get the content from a string, decoding it if it is in GZIP format
@param urlString
@return
@throws RottenTomatoesException
|
[
"Get",
"the",
"content",
"from",
"a",
"string",
"decoding",
"it",
"if",
"it",
"is",
"in",
"GZIP",
"format"
] |
train
|
https://github.com/Omertron/api-rottentomatoes/blob/abaf1833acafc6ada593d52b14ff1bacb4e441ee/src/main/java/com/omertron/rottentomatoesapi/tools/ResponseBuilder.java#L136-L153
|
MariaDB/mariadb-connector-j
|
src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java
|
MastersFailoverListener.initializeConnection
|
@Override
public void initializeConnection() throws SQLException {
"""
Connect to database.
@throws SQLException if connection is on error.
"""
super.initializeConnection();
this.currentProtocol = null;
//launching initial loop
reconnectFailedConnection(new SearchFilter(true, false));
resetMasterFailoverData();
}
|
java
|
@Override
public void initializeConnection() throws SQLException {
super.initializeConnection();
this.currentProtocol = null;
//launching initial loop
reconnectFailedConnection(new SearchFilter(true, false));
resetMasterFailoverData();
}
|
[
"@",
"Override",
"public",
"void",
"initializeConnection",
"(",
")",
"throws",
"SQLException",
"{",
"super",
".",
"initializeConnection",
"(",
")",
";",
"this",
".",
"currentProtocol",
"=",
"null",
";",
"//launching initial loop",
"reconnectFailedConnection",
"(",
"new",
"SearchFilter",
"(",
"true",
",",
"false",
")",
")",
";",
"resetMasterFailoverData",
"(",
")",
";",
"}"
] |
Connect to database.
@throws SQLException if connection is on error.
|
[
"Connect",
"to",
"database",
"."
] |
train
|
https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L97-L104
|
qspin/qtaste
|
kernel/src/main/java/com/qspin/qtaste/ui/tools/Utils.java
|
Utils.collapseJTree
|
public static void collapseJTree(javax.swing.JTree tree, int depth) {
"""
Expands all nodes in a JTree.
@param tree The JTree to expand.
@param depth The depth to which the tree should be expanded. Zero
will just expand the root node, a negative value will
fully expand the tree, and a positive value will
recursively expand the tree to that depth.
"""
javax.swing.tree.TreeModel model = tree.getModel();
collapseJTreeNode(tree, model, model.getRoot(), 0, depth);
}
|
java
|
public static void collapseJTree(javax.swing.JTree tree, int depth) {
javax.swing.tree.TreeModel model = tree.getModel();
collapseJTreeNode(tree, model, model.getRoot(), 0, depth);
}
|
[
"public",
"static",
"void",
"collapseJTree",
"(",
"javax",
".",
"swing",
".",
"JTree",
"tree",
",",
"int",
"depth",
")",
"{",
"javax",
".",
"swing",
".",
"tree",
".",
"TreeModel",
"model",
"=",
"tree",
".",
"getModel",
"(",
")",
";",
"collapseJTreeNode",
"(",
"tree",
",",
"model",
",",
"model",
".",
"getRoot",
"(",
")",
",",
"0",
",",
"depth",
")",
";",
"}"
] |
Expands all nodes in a JTree.
@param tree The JTree to expand.
@param depth The depth to which the tree should be expanded. Zero
will just expand the root node, a negative value will
fully expand the tree, and a positive value will
recursively expand the tree to that depth.
|
[
"Expands",
"all",
"nodes",
"in",
"a",
"JTree",
"."
] |
train
|
https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/tools/Utils.java#L125-L128
|
resilience4j/resilience4j
|
resilience4j-prometheus/src/main/java/io/github/resilience4j/prometheus/collectors/BulkheadMetricsCollector.java
|
BulkheadMetricsCollector.ofSupplier
|
public static BulkheadMetricsCollector ofSupplier(MetricNames names, Supplier<? extends Iterable<? extends Bulkhead>> supplier) {
"""
Creates a new collector with custom metric names and
using given {@code supplier} as source of bulkheads.
@param names the custom metric names
@param supplier the supplier of bulkheads, note that supplier will be called one every {@link #collect()}
"""
return new BulkheadMetricsCollector(names, supplier);
}
|
java
|
public static BulkheadMetricsCollector ofSupplier(MetricNames names, Supplier<? extends Iterable<? extends Bulkhead>> supplier) {
return new BulkheadMetricsCollector(names, supplier);
}
|
[
"public",
"static",
"BulkheadMetricsCollector",
"ofSupplier",
"(",
"MetricNames",
"names",
",",
"Supplier",
"<",
"?",
"extends",
"Iterable",
"<",
"?",
"extends",
"Bulkhead",
">",
">",
"supplier",
")",
"{",
"return",
"new",
"BulkheadMetricsCollector",
"(",
"names",
",",
"supplier",
")",
";",
"}"
] |
Creates a new collector with custom metric names and
using given {@code supplier} as source of bulkheads.
@param names the custom metric names
@param supplier the supplier of bulkheads, note that supplier will be called one every {@link #collect()}
|
[
"Creates",
"a",
"new",
"collector",
"with",
"custom",
"metric",
"names",
"and",
"using",
"given",
"{",
"@code",
"supplier",
"}",
"as",
"source",
"of",
"bulkheads",
"."
] |
train
|
https://github.com/resilience4j/resilience4j/blob/fa843d30f531c00f0c3dc218b65a7f2bb51af336/resilience4j-prometheus/src/main/java/io/github/resilience4j/prometheus/collectors/BulkheadMetricsCollector.java#L42-L44
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/ui/CmsListItem.java
|
CmsListItem.initContent
|
protected void initContent(CmsCheckBox checkbox, Widget mainWidget) {
"""
This method is a convenience method which sets the checkbox and main widget of this widget, and then calls {@link CmsListItem#initContent()}.<p>
@param checkbox the checkbox to add
@param mainWidget the mainWidget to add
"""
addCheckBox(checkbox);
addMainWidget(mainWidget);
initContent();
}
|
java
|
protected void initContent(CmsCheckBox checkbox, Widget mainWidget) {
addCheckBox(checkbox);
addMainWidget(mainWidget);
initContent();
}
|
[
"protected",
"void",
"initContent",
"(",
"CmsCheckBox",
"checkbox",
",",
"Widget",
"mainWidget",
")",
"{",
"addCheckBox",
"(",
"checkbox",
")",
";",
"addMainWidget",
"(",
"mainWidget",
")",
";",
"initContent",
"(",
")",
";",
"}"
] |
This method is a convenience method which sets the checkbox and main widget of this widget, and then calls {@link CmsListItem#initContent()}.<p>
@param checkbox the checkbox to add
@param mainWidget the mainWidget to add
|
[
"This",
"method",
"is",
"a",
"convenience",
"method",
"which",
"sets",
"the",
"checkbox",
"and",
"main",
"widget",
"of",
"this",
"widget",
"and",
"then",
"calls",
"{",
"@link",
"CmsListItem#initContent",
"()",
"}",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsListItem.java#L652-L657
|
atomix/atomix
|
protocols/raft/src/main/java/io/atomix/protocols/raft/storage/snapshot/SnapshotStore.java
|
SnapshotStore.newSnapshot
|
public Snapshot newSnapshot(long index, WallClockTimestamp timestamp) {
"""
Creates a new snapshot.
@param index The snapshot index.
@param timestamp The snapshot timestamp.
@return The snapshot.
"""
SnapshotDescriptor descriptor = SnapshotDescriptor.builder()
.withIndex(index)
.withTimestamp(timestamp.unixTimestamp())
.build();
return newSnapshot(descriptor, storage.storageLevel());
}
|
java
|
public Snapshot newSnapshot(long index, WallClockTimestamp timestamp) {
SnapshotDescriptor descriptor = SnapshotDescriptor.builder()
.withIndex(index)
.withTimestamp(timestamp.unixTimestamp())
.build();
return newSnapshot(descriptor, storage.storageLevel());
}
|
[
"public",
"Snapshot",
"newSnapshot",
"(",
"long",
"index",
",",
"WallClockTimestamp",
"timestamp",
")",
"{",
"SnapshotDescriptor",
"descriptor",
"=",
"SnapshotDescriptor",
".",
"builder",
"(",
")",
".",
"withIndex",
"(",
"index",
")",
".",
"withTimestamp",
"(",
"timestamp",
".",
"unixTimestamp",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"newSnapshot",
"(",
"descriptor",
",",
"storage",
".",
"storageLevel",
"(",
")",
")",
";",
"}"
] |
Creates a new snapshot.
@param index The snapshot index.
@param timestamp The snapshot timestamp.
@return The snapshot.
|
[
"Creates",
"a",
"new",
"snapshot",
"."
] |
train
|
https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/storage/snapshot/SnapshotStore.java#L171-L177
|
samskivert/samskivert
|
src/main/java/com/samskivert/velocity/DispatcherServlet.java
|
DispatcherServlet.setContentType
|
protected void setContentType (HttpServletRequest request, HttpServletResponse response) {
"""
Sets the content type of the response, defaulting to {@link #_defaultContentType} if not
overriden. Delegates to {@link #chooseCharacterEncoding(HttpServletRequest)} to select the
appropriate character encoding.
"""
String contentType = _defaultContentType;
int index = contentType.lastIndexOf(';') + 1;
if (index <= 0 || (index < contentType.length() &&
contentType.indexOf("charset", index) == -1)) {
// append the character encoding which we'd like to use
String encoding = chooseCharacterEncoding(request);
if (!DEFAULT_OUTPUT_ENCODING.equalsIgnoreCase(encoding)) {
contentType += "; charset=" + encoding;
}
}
response.setContentType(contentType);
}
|
java
|
protected void setContentType (HttpServletRequest request, HttpServletResponse response)
{
String contentType = _defaultContentType;
int index = contentType.lastIndexOf(';') + 1;
if (index <= 0 || (index < contentType.length() &&
contentType.indexOf("charset", index) == -1)) {
// append the character encoding which we'd like to use
String encoding = chooseCharacterEncoding(request);
if (!DEFAULT_OUTPUT_ENCODING.equalsIgnoreCase(encoding)) {
contentType += "; charset=" + encoding;
}
}
response.setContentType(contentType);
}
|
[
"protected",
"void",
"setContentType",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"{",
"String",
"contentType",
"=",
"_defaultContentType",
";",
"int",
"index",
"=",
"contentType",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
";",
"if",
"(",
"index",
"<=",
"0",
"||",
"(",
"index",
"<",
"contentType",
".",
"length",
"(",
")",
"&&",
"contentType",
".",
"indexOf",
"(",
"\"charset\"",
",",
"index",
")",
"==",
"-",
"1",
")",
")",
"{",
"// append the character encoding which we'd like to use",
"String",
"encoding",
"=",
"chooseCharacterEncoding",
"(",
"request",
")",
";",
"if",
"(",
"!",
"DEFAULT_OUTPUT_ENCODING",
".",
"equalsIgnoreCase",
"(",
"encoding",
")",
")",
"{",
"contentType",
"+=",
"\"; charset=\"",
"+",
"encoding",
";",
"}",
"}",
"response",
".",
"setContentType",
"(",
"contentType",
")",
";",
"}"
] |
Sets the content type of the response, defaulting to {@link #_defaultContentType} if not
overriden. Delegates to {@link #chooseCharacterEncoding(HttpServletRequest)} to select the
appropriate character encoding.
|
[
"Sets",
"the",
"content",
"type",
"of",
"the",
"response",
"defaulting",
"to",
"{"
] |
train
|
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/DispatcherServlet.java#L467-L480
|
phax/ph-commons
|
ph-commons/src/main/java/com/helger/commons/string/StringParser.java
|
StringParser.parseIntObj
|
@Nullable
public static Integer parseIntObj (@Nullable final Object aObject, @Nullable final Integer aDefault) {
"""
Parse the given {@link Object} as {@link Integer} with radix
{@value #DEFAULT_RADIX}.
@param aObject
The object to parse. May be <code>null</code>.
@param aDefault
The default value to be returned if the passed object cannot be
converted to an Integer. May be <code>null</code>.
@return <code>aDefault</code> if the object does not represent a valid
value.
"""
return parseIntObj (aObject, DEFAULT_RADIX, aDefault);
}
|
java
|
@Nullable
public static Integer parseIntObj (@Nullable final Object aObject, @Nullable final Integer aDefault)
{
return parseIntObj (aObject, DEFAULT_RADIX, aDefault);
}
|
[
"@",
"Nullable",
"public",
"static",
"Integer",
"parseIntObj",
"(",
"@",
"Nullable",
"final",
"Object",
"aObject",
",",
"@",
"Nullable",
"final",
"Integer",
"aDefault",
")",
"{",
"return",
"parseIntObj",
"(",
"aObject",
",",
"DEFAULT_RADIX",
",",
"aDefault",
")",
";",
"}"
] |
Parse the given {@link Object} as {@link Integer} with radix
{@value #DEFAULT_RADIX}.
@param aObject
The object to parse. May be <code>null</code>.
@param aDefault
The default value to be returned if the passed object cannot be
converted to an Integer. May be <code>null</code>.
@return <code>aDefault</code> if the object does not represent a valid
value.
|
[
"Parse",
"the",
"given",
"{",
"@link",
"Object",
"}",
"as",
"{",
"@link",
"Integer",
"}",
"with",
"radix",
"{",
"@value",
"#DEFAULT_RADIX",
"}",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L806-L810
|
ocpsoft/prettytime
|
nlp/src/main/java/org/ocpsoft/prettytime/nlp/PrettyTimeParser.java
|
PrettyTimeParser.parseSyntax
|
public List<DateGroup> parseSyntax(String language) {
"""
Parse the given language and return a {@link List} with all discovered {@link DateGroup} instances.
"""
language = words2numbers(language);
List<DateGroup> result = new ArrayList<DateGroup>();
List<com.joestelmach.natty.DateGroup> groups = parser.parse(language);
Date now = new Date();
for (com.joestelmach.natty.DateGroup group : groups) {
result.add(new DateGroupImpl(now, group));
}
return result;
}
|
java
|
public List<DateGroup> parseSyntax(String language)
{
language = words2numbers(language);
List<DateGroup> result = new ArrayList<DateGroup>();
List<com.joestelmach.natty.DateGroup> groups = parser.parse(language);
Date now = new Date();
for (com.joestelmach.natty.DateGroup group : groups) {
result.add(new DateGroupImpl(now, group));
}
return result;
}
|
[
"public",
"List",
"<",
"DateGroup",
">",
"parseSyntax",
"(",
"String",
"language",
")",
"{",
"language",
"=",
"words2numbers",
"(",
"language",
")",
";",
"List",
"<",
"DateGroup",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"DateGroup",
">",
"(",
")",
";",
"List",
"<",
"com",
".",
"joestelmach",
".",
"natty",
".",
"DateGroup",
">",
"groups",
"=",
"parser",
".",
"parse",
"(",
"language",
")",
";",
"Date",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"for",
"(",
"com",
".",
"joestelmach",
".",
"natty",
".",
"DateGroup",
"group",
":",
"groups",
")",
"{",
"result",
".",
"add",
"(",
"new",
"DateGroupImpl",
"(",
"now",
",",
"group",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Parse the given language and return a {@link List} with all discovered {@link DateGroup} instances.
|
[
"Parse",
"the",
"given",
"language",
"and",
"return",
"a",
"{"
] |
train
|
https://github.com/ocpsoft/prettytime/blob/8a742bd1d8eaacc2a36865d144a43ea0211e25b7/nlp/src/main/java/org/ocpsoft/prettytime/nlp/PrettyTimeParser.java#L160-L171
|
GeoLatte/geolatte-common
|
src/main/java/org/geolatte/common/expressions/Expressions.java
|
Expressions.isBefore
|
public static IsBefore isBefore(Expression<Date> left, Expression<Date> right) {
"""
Creates an IsBefore expression from the given expressions.
@param left The left hand side of the comparison
@param right The right hand side of the comparison.
@return An IsBefore expression.
"""
return new IsBefore(left, right);
}
|
java
|
public static IsBefore isBefore(Expression<Date> left, Expression<Date> right) {
return new IsBefore(left, right);
}
|
[
"public",
"static",
"IsBefore",
"isBefore",
"(",
"Expression",
"<",
"Date",
">",
"left",
",",
"Expression",
"<",
"Date",
">",
"right",
")",
"{",
"return",
"new",
"IsBefore",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates an IsBefore expression from the given expressions.
@param left The left hand side of the comparison
@param right The right hand side of the comparison.
@return An IsBefore expression.
|
[
"Creates",
"an",
"IsBefore",
"expression",
"from",
"the",
"given",
"expressions",
"."
] |
train
|
https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/expressions/Expressions.java#L744-L746
|
raydac/java-binary-block-parser
|
jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java
|
JBBPDslBuilder.Short
|
public JBBPDslBuilder Short(final String name) {
"""
Add named signed short field.
@param name name of the field, can be null for anonymous one
@return the builder instance, must not be null
"""
final Item item = new Item(BinType.SHORT, name, this.byteOrder);
this.addItem(item);
return this;
}
|
java
|
public JBBPDslBuilder Short(final String name) {
final Item item = new Item(BinType.SHORT, name, this.byteOrder);
this.addItem(item);
return this;
}
|
[
"public",
"JBBPDslBuilder",
"Short",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"SHORT",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
";",
"this",
".",
"addItem",
"(",
"item",
")",
";",
"return",
"this",
";",
"}"
] |
Add named signed short field.
@param name name of the field, can be null for anonymous one
@return the builder instance, must not be null
|
[
"Add",
"named",
"signed",
"short",
"field",
"."
] |
train
|
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L959-L963
|
coursera/courier
|
swift/generator/src/main/java/org/coursera/courier/swift/SwiftSyntax.java
|
SwiftSyntax.toType
|
public String toType(ClassTemplateSpec spec, boolean isOptional) {
"""
Returns the Swift type of an optional field for the given {@link ClassTemplateSpec} as a
Swift source code string.
Even if the field is required, it still will be represented as optional when
Optionality is set to {@link SwiftProperties.Optionality#REQUIRED_FIELDS_MAY_BE_ABSENT}.
@param spec to get a Swift type name for.
@param isOptional indicates if the type is optional or not.
@return Swift source code string identifying the given type.
"""
String type = toTypeString(spec);
return type + (isOptional ? "?" : "");
}
|
java
|
public String toType(ClassTemplateSpec spec, boolean isOptional) {
String type = toTypeString(spec);
return type + (isOptional ? "?" : "");
}
|
[
"public",
"String",
"toType",
"(",
"ClassTemplateSpec",
"spec",
",",
"boolean",
"isOptional",
")",
"{",
"String",
"type",
"=",
"toTypeString",
"(",
"spec",
")",
";",
"return",
"type",
"+",
"(",
"isOptional",
"?",
"\"?\"",
":",
"\"\"",
")",
";",
"}"
] |
Returns the Swift type of an optional field for the given {@link ClassTemplateSpec} as a
Swift source code string.
Even if the field is required, it still will be represented as optional when
Optionality is set to {@link SwiftProperties.Optionality#REQUIRED_FIELDS_MAY_BE_ABSENT}.
@param spec to get a Swift type name for.
@param isOptional indicates if the type is optional or not.
@return Swift source code string identifying the given type.
|
[
"Returns",
"the",
"Swift",
"type",
"of",
"an",
"optional",
"field",
"for",
"the",
"given",
"{",
"@link",
"ClassTemplateSpec",
"}",
"as",
"a",
"Swift",
"source",
"code",
"string",
"."
] |
train
|
https://github.com/coursera/courier/blob/749674fa7ee33804ad11b6c8ecb560f455cb4c22/swift/generator/src/main/java/org/coursera/courier/swift/SwiftSyntax.java#L142-L145
|
soi-toolkit/soi-toolkit-mule
|
commons/components/studio-components/src/main/java/org/soitoolkit/commons/studio/components/logger/LoggerModule.java
|
LoggerModule.logDebug
|
@Processor
public Object logDebug(
@Optional @FriendlyName("Log Message") String message,
@Optional String integrationScenario,
@Optional String messageType,
@Optional String contractId,
@Optional String correlationId,
@Optional @FriendlyName("Extra Info") Map<String, String> extraInfo) {
"""
Log processor for level DEBUG
{@sample.xml ../../../doc/soitoolkit-connector.xml.sample soitoolkit:log-debug}
@param message Log-message to be processed
@param integrationScenario Optional name of the integration scenario or business process
@param messageType Optional name of the message type, e.g. a XML Schema namespace for a XML payload
@param contractId Optional name of the contract in use
@param correlationId Optional correlation identity of the message
@param extraInfo Optional extra info
@return The incoming payload
"""
return doLog(LogLevelType.DEBUG, message, integrationScenario, contractId, correlationId, extraInfo);
}
|
java
|
@Processor
public Object logDebug(
@Optional @FriendlyName("Log Message") String message,
@Optional String integrationScenario,
@Optional String messageType,
@Optional String contractId,
@Optional String correlationId,
@Optional @FriendlyName("Extra Info") Map<String, String> extraInfo) {
return doLog(LogLevelType.DEBUG, message, integrationScenario, contractId, correlationId, extraInfo);
}
|
[
"@",
"Processor",
"public",
"Object",
"logDebug",
"(",
"@",
"Optional",
"@",
"FriendlyName",
"(",
"\"Log Message\"",
")",
"String",
"message",
",",
"@",
"Optional",
"String",
"integrationScenario",
",",
"@",
"Optional",
"String",
"messageType",
",",
"@",
"Optional",
"String",
"contractId",
",",
"@",
"Optional",
"String",
"correlationId",
",",
"@",
"Optional",
"@",
"FriendlyName",
"(",
"\"Extra Info\"",
")",
"Map",
"<",
"String",
",",
"String",
">",
"extraInfo",
")",
"{",
"return",
"doLog",
"(",
"LogLevelType",
".",
"DEBUG",
",",
"message",
",",
"integrationScenario",
",",
"contractId",
",",
"correlationId",
",",
"extraInfo",
")",
";",
"}"
] |
Log processor for level DEBUG
{@sample.xml ../../../doc/soitoolkit-connector.xml.sample soitoolkit:log-debug}
@param message Log-message to be processed
@param integrationScenario Optional name of the integration scenario or business process
@param messageType Optional name of the message type, e.g. a XML Schema namespace for a XML payload
@param contractId Optional name of the contract in use
@param correlationId Optional correlation identity of the message
@param extraInfo Optional extra info
@return The incoming payload
|
[
"Log",
"processor",
"for",
"level",
"DEBUG"
] |
train
|
https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/studio-components/src/main/java/org/soitoolkit/commons/studio/components/logger/LoggerModule.java#L277-L287
|
thinkaurelius/titan
|
titan-core/src/main/java/com/thinkaurelius/titan/graphdb/idmanagement/IDManager.java
|
IDManager.constructId
|
private long constructId(long count, long partition, VertexIDType type) {
"""
/* --- TitanElement id bit format ---
[ 0 | count | partition | ID padding (if any) ]
"""
Preconditions.checkArgument(partition<partitionIDBound && partition>=0,"Invalid partition: %s",partition);
Preconditions.checkArgument(count>=0);
Preconditions.checkArgument(VariableLong.unsignedBitLength(count)+partitionBits+
(type==null?0:type.offset())<=TOTAL_BITS);
Preconditions.checkArgument(type==null || type.isProper());
long id = (count<<partitionBits)+partition;
if (type!=null) id = type.addPadding(id);
return id;
}
|
java
|
private long constructId(long count, long partition, VertexIDType type) {
Preconditions.checkArgument(partition<partitionIDBound && partition>=0,"Invalid partition: %s",partition);
Preconditions.checkArgument(count>=0);
Preconditions.checkArgument(VariableLong.unsignedBitLength(count)+partitionBits+
(type==null?0:type.offset())<=TOTAL_BITS);
Preconditions.checkArgument(type==null || type.isProper());
long id = (count<<partitionBits)+partition;
if (type!=null) id = type.addPadding(id);
return id;
}
|
[
"private",
"long",
"constructId",
"(",
"long",
"count",
",",
"long",
"partition",
",",
"VertexIDType",
"type",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"partition",
"<",
"partitionIDBound",
"&&",
"partition",
">=",
"0",
",",
"\"Invalid partition: %s\"",
",",
"partition",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"count",
">=",
"0",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"VariableLong",
".",
"unsignedBitLength",
"(",
"count",
")",
"+",
"partitionBits",
"+",
"(",
"type",
"==",
"null",
"?",
"0",
":",
"type",
".",
"offset",
"(",
")",
")",
"<=",
"TOTAL_BITS",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"type",
"==",
"null",
"||",
"type",
".",
"isProper",
"(",
")",
")",
";",
"long",
"id",
"=",
"(",
"count",
"<<",
"partitionBits",
")",
"+",
"partition",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"id",
"=",
"type",
".",
"addPadding",
"(",
"id",
")",
";",
"return",
"id",
";",
"}"
] |
/* --- TitanElement id bit format ---
[ 0 | count | partition | ID padding (if any) ]
|
[
"/",
"*",
"---",
"TitanElement",
"id",
"bit",
"format",
"---",
"[",
"0",
"|",
"count",
"|",
"partition",
"|",
"ID",
"padding",
"(",
"if",
"any",
")",
"]"
] |
train
|
https://github.com/thinkaurelius/titan/blob/ee226e52415b8bf43b700afac75fa5b9767993a5/titan-core/src/main/java/com/thinkaurelius/titan/graphdb/idmanagement/IDManager.java#L432-L441
|
jeremybrooks/jinx
|
src/main/java/net/jeremybrooks/jinx/api/TagsApi.java
|
TagsApi.getHotList
|
public HotList getHotList(JinxConstants.Period period, Integer count) throws JinxException {
"""
Returns a list of hot tags for the given period.
This method does not require authentication.
@param period period for which to fetch hot tags. Optional.
@param count number of tags to return. Defaults to 20. Maximum allowed value is 200. Optional.
@return hot tags for the given period.
@throws JinxException if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.tags.getHotList.html">flickr.tags.getHotList</a>
"""
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.tags.getHotList");
if (period != null) {
params.put("period", period.toString());
}
if (count != null && count > 0) {
params.put("count", count.toString());
}
return jinx.flickrGet(params, HotList.class, false);
}
|
java
|
public HotList getHotList(JinxConstants.Period period, Integer count) throws JinxException {
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.tags.getHotList");
if (period != null) {
params.put("period", period.toString());
}
if (count != null && count > 0) {
params.put("count", count.toString());
}
return jinx.flickrGet(params, HotList.class, false);
}
|
[
"public",
"HotList",
"getHotList",
"(",
"JinxConstants",
".",
"Period",
"period",
",",
"Integer",
"count",
")",
"throws",
"JinxException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.tags.getHotList\"",
")",
";",
"if",
"(",
"period",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"period\"",
",",
"period",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"count",
"!=",
"null",
"&&",
"count",
">",
"0",
")",
"{",
"params",
".",
"put",
"(",
"\"count\"",
",",
"count",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"jinx",
".",
"flickrGet",
"(",
"params",
",",
"HotList",
".",
"class",
",",
"false",
")",
";",
"}"
] |
Returns a list of hot tags for the given period.
This method does not require authentication.
@param period period for which to fetch hot tags. Optional.
@param count number of tags to return. Defaults to 20. Maximum allowed value is 200. Optional.
@return hot tags for the given period.
@throws JinxException if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.tags.getHotList.html">flickr.tags.getHotList</a>
|
[
"Returns",
"a",
"list",
"of",
"hot",
"tags",
"for",
"the",
"given",
"period",
"."
] |
train
|
https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/TagsApi.java#L126-L136
|
moparisthebest/beehive
|
beehive-netui-core/src/main/java/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java
|
ImplicitObjectUtil.getPageFlow
|
public static PageFlowController getPageFlow(ServletRequest request, ServletResponse response) {
"""
Internal method!
This method is used by the expression engine to get the current page flow. If no page flow is
found, an exception will be thrown.
@param request the request
@param response the response
@return the page flow
"""
assert request instanceof HttpServletRequest;
PageFlowController jpf = PageFlowUtils.getCurrentPageFlow((HttpServletRequest)request);
if(jpf != null)
return jpf;
else {
String message = "There is no current Page Flow!";
LOGGER.error(message);
throw new RuntimeException(message);
}
}
|
java
|
public static PageFlowController getPageFlow(ServletRequest request, ServletResponse response) {
assert request instanceof HttpServletRequest;
PageFlowController jpf = PageFlowUtils.getCurrentPageFlow((HttpServletRequest)request);
if(jpf != null)
return jpf;
else {
String message = "There is no current Page Flow!";
LOGGER.error(message);
throw new RuntimeException(message);
}
}
|
[
"public",
"static",
"PageFlowController",
"getPageFlow",
"(",
"ServletRequest",
"request",
",",
"ServletResponse",
"response",
")",
"{",
"assert",
"request",
"instanceof",
"HttpServletRequest",
";",
"PageFlowController",
"jpf",
"=",
"PageFlowUtils",
".",
"getCurrentPageFlow",
"(",
"(",
"HttpServletRequest",
")",
"request",
")",
";",
"if",
"(",
"jpf",
"!=",
"null",
")",
"return",
"jpf",
";",
"else",
"{",
"String",
"message",
"=",
"\"There is no current Page Flow!\"",
";",
"LOGGER",
".",
"error",
"(",
"message",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"message",
")",
";",
"}",
"}"
] |
Internal method!
This method is used by the expression engine to get the current page flow. If no page flow is
found, an exception will be thrown.
@param request the request
@param response the response
@return the page flow
|
[
"Internal",
"method!"
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java#L205-L216
|
xhsun/gw2wrapper
|
src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java
|
AsynchronousRequest.getTraitInfo
|
public void getTraitInfo(int[] ids, Callback<List<Trait>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on traits API go <a href="https://wiki.guildwars2.com/wiki/API:2/traits">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of trait id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Trait trait info
"""
isParamValid(new ParamChecker(ids));
gw2API.getTraitInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
}
|
java
|
public void getTraitInfo(int[] ids, Callback<List<Trait>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getTraitInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
}
|
[
"public",
"void",
"getTraitInfo",
"(",
"int",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Trait",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getTraitInfo",
"(",
"processIds",
"(",
"ids",
")",
",",
"GuildWars2",
".",
"lang",
".",
"getValue",
"(",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] |
For more info on traits API go <a href="https://wiki.guildwars2.com/wiki/API:2/traits">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of trait id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Trait trait info
|
[
"For",
"more",
"info",
"on",
"traits",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"traits",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions"
] |
train
|
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L2524-L2527
|
google/gson
|
codegen/src/main/java/com/google/gson/codegen/CodeGen.java
|
CodeGen.adapterName
|
public static String adapterName(TypeElement typeElement, String suffix) {
"""
Returns a fully qualified class name to complement {@code type}.
"""
StringBuilder builder = new StringBuilder();
rawTypeToString(builder, typeElement, '$');
builder.append(suffix);
return builder.toString();
}
|
java
|
public static String adapterName(TypeElement typeElement, String suffix) {
StringBuilder builder = new StringBuilder();
rawTypeToString(builder, typeElement, '$');
builder.append(suffix);
return builder.toString();
}
|
[
"public",
"static",
"String",
"adapterName",
"(",
"TypeElement",
"typeElement",
",",
"String",
"suffix",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"rawTypeToString",
"(",
"builder",
",",
"typeElement",
",",
"'",
"'",
")",
";",
"builder",
".",
"append",
"(",
"suffix",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns a fully qualified class name to complement {@code type}.
|
[
"Returns",
"a",
"fully",
"qualified",
"class",
"name",
"to",
"complement",
"{"
] |
train
|
https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/codegen/src/main/java/com/google/gson/codegen/CodeGen.java#L38-L43
|
carewebframework/carewebframework-core
|
org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextItems.java
|
ContextItems.getItem
|
public String getItem(String itemName, String suffix) {
"""
Retrieves a context item qualified by a suffix.
@param itemName Item name
@param suffix Item suffix
@return Item value
"""
return items.get(lookupItemName(itemName, suffix, false));
}
|
java
|
public String getItem(String itemName, String suffix) {
return items.get(lookupItemName(itemName, suffix, false));
}
|
[
"public",
"String",
"getItem",
"(",
"String",
"itemName",
",",
"String",
"suffix",
")",
"{",
"return",
"items",
".",
"get",
"(",
"lookupItemName",
"(",
"itemName",
",",
"suffix",
",",
"false",
")",
")",
";",
"}"
] |
Retrieves a context item qualified by a suffix.
@param itemName Item name
@param suffix Item suffix
@return Item value
|
[
"Retrieves",
"a",
"context",
"item",
"qualified",
"by",
"a",
"suffix",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextItems.java#L195-L197
|
messagebird/java-rest-api
|
api/src/main/java/com/messagebird/MessageBirdClient.java
|
MessageBirdClient.listContacts
|
public ContactList listContacts(int offset, int limit) throws UnauthorizedException, GeneralException {
"""
Gets a contact listing with specified pagination options.
@return Listing of Contact objects.
"""
return messageBirdService.requestList(CONTACTPATH, offset, limit, ContactList.class);
}
|
java
|
public ContactList listContacts(int offset, int limit) throws UnauthorizedException, GeneralException {
return messageBirdService.requestList(CONTACTPATH, offset, limit, ContactList.class);
}
|
[
"public",
"ContactList",
"listContacts",
"(",
"int",
"offset",
",",
"int",
"limit",
")",
"throws",
"UnauthorizedException",
",",
"GeneralException",
"{",
"return",
"messageBirdService",
".",
"requestList",
"(",
"CONTACTPATH",
",",
"offset",
",",
"limit",
",",
"ContactList",
".",
"class",
")",
";",
"}"
] |
Gets a contact listing with specified pagination options.
@return Listing of Contact objects.
|
[
"Gets",
"a",
"contact",
"listing",
"with",
"specified",
"pagination",
"options",
"."
] |
train
|
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L553-L555
|
xwiki/xwiki-commons
|
xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/AbstractXARMojo.java
|
AbstractXARMojo.unpackXARToOutputDirectory
|
protected void unpackXARToOutputDirectory(Artifact artifact, String[] includes, String[] excludes)
throws MojoExecutionException {
"""
Unpacks A XAR artifacts into the build output directory, along with the project's XAR files.
@param artifact the XAR artifact to unpack.
@throws MojoExecutionException in case of unpack error
"""
if (!this.outputBuildDirectory.exists()) {
this.outputBuildDirectory.mkdirs();
}
File file = artifact.getFile();
unpack(file, this.outputBuildDirectory, "XAR Plugin", false, includes, excludes);
}
|
java
|
protected void unpackXARToOutputDirectory(Artifact artifact, String[] includes, String[] excludes)
throws MojoExecutionException
{
if (!this.outputBuildDirectory.exists()) {
this.outputBuildDirectory.mkdirs();
}
File file = artifact.getFile();
unpack(file, this.outputBuildDirectory, "XAR Plugin", false, includes, excludes);
}
|
[
"protected",
"void",
"unpackXARToOutputDirectory",
"(",
"Artifact",
"artifact",
",",
"String",
"[",
"]",
"includes",
",",
"String",
"[",
"]",
"excludes",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"!",
"this",
".",
"outputBuildDirectory",
".",
"exists",
"(",
")",
")",
"{",
"this",
".",
"outputBuildDirectory",
".",
"mkdirs",
"(",
")",
";",
"}",
"File",
"file",
"=",
"artifact",
".",
"getFile",
"(",
")",
";",
"unpack",
"(",
"file",
",",
"this",
".",
"outputBuildDirectory",
",",
"\"XAR Plugin\"",
",",
"false",
",",
"includes",
",",
"excludes",
")",
";",
"}"
] |
Unpacks A XAR artifacts into the build output directory, along with the project's XAR files.
@param artifact the XAR artifact to unpack.
@throws MojoExecutionException in case of unpack error
|
[
"Unpacks",
"A",
"XAR",
"artifacts",
"into",
"the",
"build",
"output",
"directory",
"along",
"with",
"the",
"project",
"s",
"XAR",
"files",
"."
] |
train
|
https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/AbstractXARMojo.java#L256-L265
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/inbound/HttpInboundServiceContextImpl.java
|
HttpInboundServiceContextImpl.getRawRequestBodyBuffer
|
@Override
public VirtualConnection getRawRequestBodyBuffer(InterChannelCallback cb, boolean bForce) throws BodyCompleteException {
"""
Retrieve the next buffer of the body asynchronously. This will avoid any
body modifications, such as decompression or removal of chunked-encoding
markers.
<p>
If the read can be performed immediately, then a VirtualConnection will be
returned and the provided callback will not be used. If the read is being
done asychronously, then null will be returned and the callback used when
complete. The force input flag allows the caller to force the asynchronous
read to always occur, and thus the callback to always be used.
<p>
The caller is responsible for releasing these buffers when finished with
them as the HTTP Channel keeps no reference to them.
@param cb
@param bForce
@return VirtualConnection
@throws BodyCompleteException
-- if the entire body has already been read
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "getRawRequestBodyBuffer(async)");
}
setRawBody(true);
VirtualConnection vc = getRequestBodyBuffer(cb, bForce);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "getRawRequestBodyBuffer(async): " + vc);
}
return vc;
}
|
java
|
@Override
public VirtualConnection getRawRequestBodyBuffer(InterChannelCallback cb, boolean bForce) throws BodyCompleteException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "getRawRequestBodyBuffer(async)");
}
setRawBody(true);
VirtualConnection vc = getRequestBodyBuffer(cb, bForce);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "getRawRequestBodyBuffer(async): " + vc);
}
return vc;
}
|
[
"@",
"Override",
"public",
"VirtualConnection",
"getRawRequestBodyBuffer",
"(",
"InterChannelCallback",
"cb",
",",
"boolean",
"bForce",
")",
"throws",
"BodyCompleteException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"getRawRequestBodyBuffer(async)\"",
")",
";",
"}",
"setRawBody",
"(",
"true",
")",
";",
"VirtualConnection",
"vc",
"=",
"getRequestBodyBuffer",
"(",
"cb",
",",
"bForce",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"getRawRequestBodyBuffer(async): \"",
"+",
"vc",
")",
";",
"}",
"return",
"vc",
";",
"}"
] |
Retrieve the next buffer of the body asynchronously. This will avoid any
body modifications, such as decompression or removal of chunked-encoding
markers.
<p>
If the read can be performed immediately, then a VirtualConnection will be
returned and the provided callback will not be used. If the read is being
done asychronously, then null will be returned and the callback used when
complete. The force input flag allows the caller to force the asynchronous
read to always occur, and thus the callback to always be used.
<p>
The caller is responsible for releasing these buffers when finished with
them as the HTTP Channel keeps no reference to them.
@param cb
@param bForce
@return VirtualConnection
@throws BodyCompleteException
-- if the entire body has already been read
|
[
"Retrieve",
"the",
"next",
"buffer",
"of",
"the",
"body",
"asynchronously",
".",
"This",
"will",
"avoid",
"any",
"body",
"modifications",
"such",
"as",
"decompression",
"or",
"removal",
"of",
"chunked",
"-",
"encoding",
"markers",
".",
"<p",
">",
"If",
"the",
"read",
"can",
"be",
"performed",
"immediately",
"then",
"a",
"VirtualConnection",
"will",
"be",
"returned",
"and",
"the",
"provided",
"callback",
"will",
"not",
"be",
"used",
".",
"If",
"the",
"read",
"is",
"being",
"done",
"asychronously",
"then",
"null",
"will",
"be",
"returned",
"and",
"the",
"callback",
"used",
"when",
"complete",
".",
"The",
"force",
"input",
"flag",
"allows",
"the",
"caller",
"to",
"force",
"the",
"asynchronous",
"read",
"to",
"always",
"occur",
"and",
"thus",
"the",
"callback",
"to",
"always",
"be",
"used",
".",
"<p",
">",
"The",
"caller",
"is",
"responsible",
"for",
"releasing",
"these",
"buffers",
"when",
"finished",
"with",
"them",
"as",
"the",
"HTTP",
"Channel",
"keeps",
"no",
"reference",
"to",
"them",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/inbound/HttpInboundServiceContextImpl.java#L1798-L1809
|
larsga/Duke
|
duke-core/src/main/java/no/priv/garshol/duke/ConfigLoader.java
|
ConfigLoader.load
|
public static Configuration load(String file)
throws IOException, SAXException {
"""
Note that if file starts with 'classpath:' the resource is looked
up on the classpath instead.
"""
ConfigurationImpl cfg = new ConfigurationImpl();
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(new ConfigHandler(cfg, file));
if (file.startsWith("classpath:")) {
String resource = file.substring("classpath:".length());
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
InputStream istream = cloader.getResourceAsStream(resource);
parser.parse(new InputSource(istream));
} else
parser.parse(file);
return cfg;
}
|
java
|
public static Configuration load(String file)
throws IOException, SAXException {
ConfigurationImpl cfg = new ConfigurationImpl();
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(new ConfigHandler(cfg, file));
if (file.startsWith("classpath:")) {
String resource = file.substring("classpath:".length());
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
InputStream istream = cloader.getResourceAsStream(resource);
parser.parse(new InputSource(istream));
} else
parser.parse(file);
return cfg;
}
|
[
"public",
"static",
"Configuration",
"load",
"(",
"String",
"file",
")",
"throws",
"IOException",
",",
"SAXException",
"{",
"ConfigurationImpl",
"cfg",
"=",
"new",
"ConfigurationImpl",
"(",
")",
";",
"XMLReader",
"parser",
"=",
"XMLReaderFactory",
".",
"createXMLReader",
"(",
")",
";",
"parser",
".",
"setContentHandler",
"(",
"new",
"ConfigHandler",
"(",
"cfg",
",",
"file",
")",
")",
";",
"if",
"(",
"file",
".",
"startsWith",
"(",
"\"classpath:\"",
")",
")",
"{",
"String",
"resource",
"=",
"file",
".",
"substring",
"(",
"\"classpath:\"",
".",
"length",
"(",
")",
")",
";",
"ClassLoader",
"cloader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"InputStream",
"istream",
"=",
"cloader",
".",
"getResourceAsStream",
"(",
"resource",
")",
";",
"parser",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"istream",
")",
")",
";",
"}",
"else",
"parser",
".",
"parse",
"(",
"file",
")",
";",
"return",
"cfg",
";",
"}"
] |
Note that if file starts with 'classpath:' the resource is looked
up on the classpath instead.
|
[
"Note",
"that",
"if",
"file",
"starts",
"with",
"classpath",
":",
"the",
"resource",
"is",
"looked",
"up",
"on",
"the",
"classpath",
"instead",
"."
] |
train
|
https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/ConfigLoader.java#L37-L52
|
Deep-Symmetry/beat-link
|
src/main/java/org/deepsymmetry/beatlink/data/CueList.java
|
CueList.addEntriesFromTag
|
private void addEntriesFromTag(List<Entry> entries, RekordboxAnlz.CueTag tag) {
"""
Helper method to add cue list entries from a parsed ANLZ cue tag
@param entries the list of entries being accumulated
@param tag the tag whose entries are to be added
"""
for (RekordboxAnlz.CueEntry cueEntry : tag.cues()) { // TODO: Need to figure out how to identify deleted entries to ignore.
if (cueEntry.type() == RekordboxAnlz.CueEntryType.LOOP) {
entries.add(new Entry((int)cueEntry.hotCue(), Util.timeToHalfFrame(cueEntry.time()),
Util.timeToHalfFrame(cueEntry.loopTime())));
} else {
entries.add(new Entry((int)cueEntry.hotCue(), Util.timeToHalfFrame(cueEntry.time())));
}
}
}
|
java
|
private void addEntriesFromTag(List<Entry> entries, RekordboxAnlz.CueTag tag) {
for (RekordboxAnlz.CueEntry cueEntry : tag.cues()) { // TODO: Need to figure out how to identify deleted entries to ignore.
if (cueEntry.type() == RekordboxAnlz.CueEntryType.LOOP) {
entries.add(new Entry((int)cueEntry.hotCue(), Util.timeToHalfFrame(cueEntry.time()),
Util.timeToHalfFrame(cueEntry.loopTime())));
} else {
entries.add(new Entry((int)cueEntry.hotCue(), Util.timeToHalfFrame(cueEntry.time())));
}
}
}
|
[
"private",
"void",
"addEntriesFromTag",
"(",
"List",
"<",
"Entry",
">",
"entries",
",",
"RekordboxAnlz",
".",
"CueTag",
"tag",
")",
"{",
"for",
"(",
"RekordboxAnlz",
".",
"CueEntry",
"cueEntry",
":",
"tag",
".",
"cues",
"(",
")",
")",
"{",
"// TODO: Need to figure out how to identify deleted entries to ignore.",
"if",
"(",
"cueEntry",
".",
"type",
"(",
")",
"==",
"RekordboxAnlz",
".",
"CueEntryType",
".",
"LOOP",
")",
"{",
"entries",
".",
"add",
"(",
"new",
"Entry",
"(",
"(",
"int",
")",
"cueEntry",
".",
"hotCue",
"(",
")",
",",
"Util",
".",
"timeToHalfFrame",
"(",
"cueEntry",
".",
"time",
"(",
")",
")",
",",
"Util",
".",
"timeToHalfFrame",
"(",
"cueEntry",
".",
"loopTime",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"entries",
".",
"add",
"(",
"new",
"Entry",
"(",
"(",
"int",
")",
"cueEntry",
".",
"hotCue",
"(",
")",
",",
"Util",
".",
"timeToHalfFrame",
"(",
"cueEntry",
".",
"time",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Helper method to add cue list entries from a parsed ANLZ cue tag
@param entries the list of entries being accumulated
@param tag the tag whose entries are to be added
|
[
"Helper",
"method",
"to",
"add",
"cue",
"list",
"entries",
"from",
"a",
"parsed",
"ANLZ",
"cue",
"tag"
] |
train
|
https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/CueList.java#L226-L235
|
CodeNarc/CodeNarc
|
src/main/java/org/codenarc/rule/AbstractMethodVisitor.java
|
AbstractMethodVisitor.addViolation
|
protected void addViolation(MethodNode node, String message) {
"""
Add a new Violation to the list of violations found by this visitor.
Only add the violation if the node lineNumber >= 0.
@param node - the Groovy AST Node
@param message - the message for the violation; defaults to null
"""
addViolation((ASTNode) node, String.format(
"Violation in class %s. %s", node.getDeclaringClass().getNameWithoutPackage(), message
));
}
|
java
|
protected void addViolation(MethodNode node, String message) {
addViolation((ASTNode) node, String.format(
"Violation in class %s. %s", node.getDeclaringClass().getNameWithoutPackage(), message
));
}
|
[
"protected",
"void",
"addViolation",
"(",
"MethodNode",
"node",
",",
"String",
"message",
")",
"{",
"addViolation",
"(",
"(",
"ASTNode",
")",
"node",
",",
"String",
".",
"format",
"(",
"\"Violation in class %s. %s\"",
",",
"node",
".",
"getDeclaringClass",
"(",
")",
".",
"getNameWithoutPackage",
"(",
")",
",",
"message",
")",
")",
";",
"}"
] |
Add a new Violation to the list of violations found by this visitor.
Only add the violation if the node lineNumber >= 0.
@param node - the Groovy AST Node
@param message - the message for the violation; defaults to null
|
[
"Add",
"a",
"new",
"Violation",
"to",
"the",
"list",
"of",
"violations",
"found",
"by",
"this",
"visitor",
".",
"Only",
"add",
"the",
"violation",
"if",
"the",
"node",
"lineNumber",
">",
"=",
"0",
"."
] |
train
|
https://github.com/CodeNarc/CodeNarc/blob/9a7cec02cb8cbaf845030f2434309e8968f5d7a7/src/main/java/org/codenarc/rule/AbstractMethodVisitor.java#L76-L80
|
Azure/azure-sdk-for-java
|
automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/ConnectionsInner.java
|
ConnectionsInner.getAsync
|
public Observable<ConnectionInner> getAsync(String resourceGroupName, String automationAccountName, String connectionName) {
"""
Retrieve the connection identified by connection name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param connectionName The name of connection.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ConnectionInner object
"""
return getWithServiceResponseAsync(resourceGroupName, automationAccountName, connectionName).map(new Func1<ServiceResponse<ConnectionInner>, ConnectionInner>() {
@Override
public ConnectionInner call(ServiceResponse<ConnectionInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<ConnectionInner> getAsync(String resourceGroupName, String automationAccountName, String connectionName) {
return getWithServiceResponseAsync(resourceGroupName, automationAccountName, connectionName).map(new Func1<ServiceResponse<ConnectionInner>, ConnectionInner>() {
@Override
public ConnectionInner call(ServiceResponse<ConnectionInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"ConnectionInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"connectionName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"connectionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ConnectionInner",
">",
",",
"ConnectionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ConnectionInner",
"call",
"(",
"ServiceResponse",
"<",
"ConnectionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Retrieve the connection identified by connection name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param connectionName The name of connection.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ConnectionInner object
|
[
"Retrieve",
"the",
"connection",
"identified",
"by",
"connection",
"name",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/ConnectionsInner.java#L223-L230
|
apache/groovy
|
src/main/groovy/groovy/lang/MetaClassImpl.java
|
MetaClassImpl.getAttribute
|
public Object getAttribute(Object object, String attribute) {
"""
Retrieves the value of an attribute (field). This method is to support the Groovy runtime and not for general client API usage.
@param object The object to get the attribute from
@param attribute The name of the attribute
@return The attribute value
"""
return getAttribute(theClass, object, attribute, false, false);
}
|
java
|
public Object getAttribute(Object object, String attribute) {
return getAttribute(theClass, object, attribute, false, false);
}
|
[
"public",
"Object",
"getAttribute",
"(",
"Object",
"object",
",",
"String",
"attribute",
")",
"{",
"return",
"getAttribute",
"(",
"theClass",
",",
"object",
",",
"attribute",
",",
"false",
",",
"false",
")",
";",
"}"
] |
Retrieves the value of an attribute (field). This method is to support the Groovy runtime and not for general client API usage.
@param object The object to get the attribute from
@param attribute The name of the attribute
@return The attribute value
|
[
"Retrieves",
"the",
"value",
"of",
"an",
"attribute",
"(",
"field",
")",
".",
"This",
"method",
"is",
"to",
"support",
"the",
"Groovy",
"runtime",
"and",
"not",
"for",
"general",
"client",
"API",
"usage",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/MetaClassImpl.java#L3881-L3883
|
jamesagnew/hapi-fhir
|
hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/model/Period.java
|
Period.setStart
|
public Period setStart( Date theDate, TemporalPrecisionEnum thePrecision) {
"""
Sets the value for <b>start</b> ()
<p>
<b>Definition:</b>
The start of the period. The boundary is inclusive.
</p>
"""
start = new DateTimeType(theDate, thePrecision);
return this;
}
|
java
|
public Period setStart( Date theDate, TemporalPrecisionEnum thePrecision) {
start = new DateTimeType(theDate, thePrecision);
return this;
}
|
[
"public",
"Period",
"setStart",
"(",
"Date",
"theDate",
",",
"TemporalPrecisionEnum",
"thePrecision",
")",
"{",
"start",
"=",
"new",
"DateTimeType",
"(",
"theDate",
",",
"thePrecision",
")",
";",
"return",
"this",
";",
"}"
] |
Sets the value for <b>start</b> ()
<p>
<b>Definition:</b>
The start of the period. The boundary is inclusive.
</p>
|
[
"Sets",
"the",
"value",
"for",
"<b",
">",
"start<",
"/",
"b",
">",
"()"
] |
train
|
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/model/Period.java#L177-L180
|
elki-project/elki
|
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
|
APRIORI.binarySearch
|
private int binarySearch(List<SparseItemset> candidates, SparseItemset scratch, int begin, int end) {
"""
Binary-search for the next-larger element.
@param candidates Candidates to search for
@param scratch Scratch space
@param begin Search interval begin
@param end Search interval end
@return Position of first equal-or-larger element
"""
--end;
while(begin < end) {
final int mid = (begin + end) >>> 1;
SparseItemset midVal = candidates.get(mid);
int cmp = midVal.compareTo(scratch);
if(cmp < 0) {
begin = mid + 1;
}
else if(cmp > 0) {
end = mid - 1;
}
else {
return mid; // key found
}
}
return -(begin + 1); // key not found, return next
}
|
java
|
private int binarySearch(List<SparseItemset> candidates, SparseItemset scratch, int begin, int end) {
--end;
while(begin < end) {
final int mid = (begin + end) >>> 1;
SparseItemset midVal = candidates.get(mid);
int cmp = midVal.compareTo(scratch);
if(cmp < 0) {
begin = mid + 1;
}
else if(cmp > 0) {
end = mid - 1;
}
else {
return mid; // key found
}
}
return -(begin + 1); // key not found, return next
}
|
[
"private",
"int",
"binarySearch",
"(",
"List",
"<",
"SparseItemset",
">",
"candidates",
",",
"SparseItemset",
"scratch",
",",
"int",
"begin",
",",
"int",
"end",
")",
"{",
"--",
"end",
";",
"while",
"(",
"begin",
"<",
"end",
")",
"{",
"final",
"int",
"mid",
"=",
"(",
"begin",
"+",
"end",
")",
">>>",
"1",
";",
"SparseItemset",
"midVal",
"=",
"candidates",
".",
"get",
"(",
"mid",
")",
";",
"int",
"cmp",
"=",
"midVal",
".",
"compareTo",
"(",
"scratch",
")",
";",
"if",
"(",
"cmp",
"<",
"0",
")",
"{",
"begin",
"=",
"mid",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"cmp",
">",
"0",
")",
"{",
"end",
"=",
"mid",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"mid",
";",
"// key found",
"}",
"}",
"return",
"-",
"(",
"begin",
"+",
"1",
")",
";",
"// key not found, return next",
"}"
] |
Binary-search for the next-larger element.
@param candidates Candidates to search for
@param scratch Scratch space
@param begin Search interval begin
@param end Search interval end
@return Position of first equal-or-larger element
|
[
"Binary",
"-",
"search",
"for",
"the",
"next",
"-",
"larger",
"element",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L541-L559
|
shrinkwrap/shrinkwrap
|
impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/io/IOUtil.java
|
IOUtil.asUTF8String
|
public static String asUTF8String(InputStream in) {
"""
Obtains the contents of the specified stream as a String in UTF-8 charset.
@param in
@throws IllegalArgumentException
If the stream was not specified
"""
// Precondition check
Validate.notNull(in, "Stream must be specified");
StringBuilder buffer = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in, CHARSET_UTF8));
while ((line = reader.readLine()) != null) {
buffer.append(line).append(Character.LINE_SEPARATOR);
}
} catch (IOException ioe) {
throw new RuntimeException("Error in obtaining string from " + in, ioe);
} finally {
try {
in.close();
} catch (IOException ignore) {
if (log.isLoggable(Level.FINER)) {
log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring");
}
}
}
return buffer.toString();
}
|
java
|
public static String asUTF8String(InputStream in) {
// Precondition check
Validate.notNull(in, "Stream must be specified");
StringBuilder buffer = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in, CHARSET_UTF8));
while ((line = reader.readLine()) != null) {
buffer.append(line).append(Character.LINE_SEPARATOR);
}
} catch (IOException ioe) {
throw new RuntimeException("Error in obtaining string from " + in, ioe);
} finally {
try {
in.close();
} catch (IOException ignore) {
if (log.isLoggable(Level.FINER)) {
log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring");
}
}
}
return buffer.toString();
}
|
[
"public",
"static",
"String",
"asUTF8String",
"(",
"InputStream",
"in",
")",
"{",
"// Precondition check",
"Validate",
".",
"notNull",
"(",
"in",
",",
"\"Stream must be specified\"",
")",
";",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"line",
";",
"try",
"{",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
",",
"CHARSET_UTF8",
")",
")",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"buffer",
".",
"append",
"(",
"line",
")",
".",
"append",
"(",
"Character",
".",
"LINE_SEPARATOR",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error in obtaining string from \"",
"+",
"in",
",",
"ioe",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ignore",
")",
"{",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"FINER",
")",
")",
"{",
"log",
".",
"finer",
"(",
"\"Could not close stream due to: \"",
"+",
"ignore",
".",
"getMessage",
"(",
")",
"+",
"\"; ignoring\"",
")",
";",
"}",
"}",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] |
Obtains the contents of the specified stream as a String in UTF-8 charset.
@param in
@throws IllegalArgumentException
If the stream was not specified
|
[
"Obtains",
"the",
"contents",
"of",
"the",
"specified",
"stream",
"as",
"a",
"String",
"in",
"UTF",
"-",
"8",
"charset",
"."
] |
train
|
https://github.com/shrinkwrap/shrinkwrap/blob/3f8a1a6d344651428c709a63ebb52d35343c5387/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/io/IOUtil.java#L99-L124
|
killbilling/recurly-java-library
|
src/main/java/com/ning/billing/recurly/RecurlyClient.java
|
RecurlyClient.getTransactions
|
public Transactions getTransactions(final TransactionState state, final TransactionType type, final QueryParams params) {
"""
Get site's transaction history
<p>
All transactions on the site
@param state {@link TransactionState}
@param type {@link TransactionType}
@param params {@link QueryParams}
@return the transaction history of the site on success, null otherwise
"""
if (state != null) params.put("state", state.getType());
if (type != null) params.put("type", type.getType());
return doGET(Transactions.TRANSACTIONS_RESOURCE, Transactions.class, params);
}
|
java
|
public Transactions getTransactions(final TransactionState state, final TransactionType type, final QueryParams params) {
if (state != null) params.put("state", state.getType());
if (type != null) params.put("type", type.getType());
return doGET(Transactions.TRANSACTIONS_RESOURCE, Transactions.class, params);
}
|
[
"public",
"Transactions",
"getTransactions",
"(",
"final",
"TransactionState",
"state",
",",
"final",
"TransactionType",
"type",
",",
"final",
"QueryParams",
"params",
")",
"{",
"if",
"(",
"state",
"!=",
"null",
")",
"params",
".",
"put",
"(",
"\"state\"",
",",
"state",
".",
"getType",
"(",
")",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"params",
".",
"put",
"(",
"\"type\"",
",",
"type",
".",
"getType",
"(",
")",
")",
";",
"return",
"doGET",
"(",
"Transactions",
".",
"TRANSACTIONS_RESOURCE",
",",
"Transactions",
".",
"class",
",",
"params",
")",
";",
"}"
] |
Get site's transaction history
<p>
All transactions on the site
@param state {@link TransactionState}
@param type {@link TransactionType}
@param params {@link QueryParams}
@return the transaction history of the site on success, null otherwise
|
[
"Get",
"site",
"s",
"transaction",
"history",
"<p",
">",
"All",
"transactions",
"on",
"the",
"site"
] |
train
|
https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L908-L913
|
facebookarchive/hadoop-20
|
src/hdfs/org/apache/hadoop/hdfs/server/datanode/NameSpaceSliceStorage.java
|
NameSpaceSliceStorage.recoverTransitionRead
|
void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo,
Collection<File> dataDirs, StartupOption startOpt) throws IOException {
"""
Analyze storage directories. Recover from previous transitions if required.
@param datanode Datanode to which this storage belongs to
@param nsInfo namespace information
@param dataDirs storage directories of namespace
@param startOpt startup option
@throws IOException on error
"""
assert FSConstants.LAYOUT_VERSION == nsInfo.getLayoutVersion()
: "Block-pool and name-node layout versions must be the same.";
// 1. For each Namespace data directory analyze the state and
// check whether all is consistent before transitioning.
this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size());
ArrayList<StorageState> dataDirStates = new ArrayList<StorageState>(
dataDirs.size());
for (Iterator<File> it = dataDirs.iterator(); it.hasNext();) {
File dataDir = it.next();
StorageDirectory sd = new StorageDirectory(dataDir, null, false);
StorageState curState;
try {
curState = sd.analyzeStorage(startOpt);
// sd is locked but not opened
switch (curState) {
case NORMAL:
break;
case NON_EXISTENT:
// ignore this storage
LOG.info("Storage directory " + dataDir + " does not exist.");
it.remove();
continue;
case NOT_FORMATTED: // format
LOG.info("Storage directory " + dataDir + " is not formatted.");
if (!sd.isEmpty()) {
LOG.error("Storage directory " + dataDir
+ " is not empty, and will not be formatted! Exiting.");
throw new IOException(
"Storage directory " + dataDir + " is not empty!");
}
LOG.info("Formatting ...");
format(sd, nsInfo);
break;
default: // recovery part is common
sd.doRecover(curState);
}
} catch (IOException ioe) {
sd.unlock();
throw ioe;
}
// add to the storage list. This is inherited from parent class, Storage.
addStorageDir(sd);
dataDirStates.add(curState);
}
if (dataDirs.size() == 0) // none of the data dirs exist
throw new IOException(
"All specified directories are not accessible or do not exist.");
// 2. Do transitions
// Each storage directory is treated individually.
// During startup some of them can upgrade or roll back
// while others could be up-to-date for the regular startup.
doTransition(datanode, nsInfo, startOpt);
// 3. Update all storages. Some of them might have just been formatted.
this.writeAll();
}
|
java
|
void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo,
Collection<File> dataDirs, StartupOption startOpt) throws IOException {
assert FSConstants.LAYOUT_VERSION == nsInfo.getLayoutVersion()
: "Block-pool and name-node layout versions must be the same.";
// 1. For each Namespace data directory analyze the state and
// check whether all is consistent before transitioning.
this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size());
ArrayList<StorageState> dataDirStates = new ArrayList<StorageState>(
dataDirs.size());
for (Iterator<File> it = dataDirs.iterator(); it.hasNext();) {
File dataDir = it.next();
StorageDirectory sd = new StorageDirectory(dataDir, null, false);
StorageState curState;
try {
curState = sd.analyzeStorage(startOpt);
// sd is locked but not opened
switch (curState) {
case NORMAL:
break;
case NON_EXISTENT:
// ignore this storage
LOG.info("Storage directory " + dataDir + " does not exist.");
it.remove();
continue;
case NOT_FORMATTED: // format
LOG.info("Storage directory " + dataDir + " is not formatted.");
if (!sd.isEmpty()) {
LOG.error("Storage directory " + dataDir
+ " is not empty, and will not be formatted! Exiting.");
throw new IOException(
"Storage directory " + dataDir + " is not empty!");
}
LOG.info("Formatting ...");
format(sd, nsInfo);
break;
default: // recovery part is common
sd.doRecover(curState);
}
} catch (IOException ioe) {
sd.unlock();
throw ioe;
}
// add to the storage list. This is inherited from parent class, Storage.
addStorageDir(sd);
dataDirStates.add(curState);
}
if (dataDirs.size() == 0) // none of the data dirs exist
throw new IOException(
"All specified directories are not accessible or do not exist.");
// 2. Do transitions
// Each storage directory is treated individually.
// During startup some of them can upgrade or roll back
// while others could be up-to-date for the regular startup.
doTransition(datanode, nsInfo, startOpt);
// 3. Update all storages. Some of them might have just been formatted.
this.writeAll();
}
|
[
"void",
"recoverTransitionRead",
"(",
"DataNode",
"datanode",
",",
"NamespaceInfo",
"nsInfo",
",",
"Collection",
"<",
"File",
">",
"dataDirs",
",",
"StartupOption",
"startOpt",
")",
"throws",
"IOException",
"{",
"assert",
"FSConstants",
".",
"LAYOUT_VERSION",
"==",
"nsInfo",
".",
"getLayoutVersion",
"(",
")",
":",
"\"Block-pool and name-node layout versions must be the same.\"",
";",
"// 1. For each Namespace data directory analyze the state and",
"// check whether all is consistent before transitioning.",
"this",
".",
"storageDirs",
"=",
"new",
"ArrayList",
"<",
"StorageDirectory",
">",
"(",
"dataDirs",
".",
"size",
"(",
")",
")",
";",
"ArrayList",
"<",
"StorageState",
">",
"dataDirStates",
"=",
"new",
"ArrayList",
"<",
"StorageState",
">",
"(",
"dataDirs",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Iterator",
"<",
"File",
">",
"it",
"=",
"dataDirs",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"File",
"dataDir",
"=",
"it",
".",
"next",
"(",
")",
";",
"StorageDirectory",
"sd",
"=",
"new",
"StorageDirectory",
"(",
"dataDir",
",",
"null",
",",
"false",
")",
";",
"StorageState",
"curState",
";",
"try",
"{",
"curState",
"=",
"sd",
".",
"analyzeStorage",
"(",
"startOpt",
")",
";",
"// sd is locked but not opened",
"switch",
"(",
"curState",
")",
"{",
"case",
"NORMAL",
":",
"break",
";",
"case",
"NON_EXISTENT",
":",
"// ignore this storage",
"LOG",
".",
"info",
"(",
"\"Storage directory \"",
"+",
"dataDir",
"+",
"\" does not exist.\"",
")",
";",
"it",
".",
"remove",
"(",
")",
";",
"continue",
";",
"case",
"NOT_FORMATTED",
":",
"// format",
"LOG",
".",
"info",
"(",
"\"Storage directory \"",
"+",
"dataDir",
"+",
"\" is not formatted.\"",
")",
";",
"if",
"(",
"!",
"sd",
".",
"isEmpty",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Storage directory \"",
"+",
"dataDir",
"+",
"\" is not empty, and will not be formatted! Exiting.\"",
")",
";",
"throw",
"new",
"IOException",
"(",
"\"Storage directory \"",
"+",
"dataDir",
"+",
"\" is not empty!\"",
")",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Formatting ...\"",
")",
";",
"format",
"(",
"sd",
",",
"nsInfo",
")",
";",
"break",
";",
"default",
":",
"// recovery part is common",
"sd",
".",
"doRecover",
"(",
"curState",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"sd",
".",
"unlock",
"(",
")",
";",
"throw",
"ioe",
";",
"}",
"// add to the storage list. This is inherited from parent class, Storage.",
"addStorageDir",
"(",
"sd",
")",
";",
"dataDirStates",
".",
"add",
"(",
"curState",
")",
";",
"}",
"if",
"(",
"dataDirs",
".",
"size",
"(",
")",
"==",
"0",
")",
"// none of the data dirs exist",
"throw",
"new",
"IOException",
"(",
"\"All specified directories are not accessible or do not exist.\"",
")",
";",
"// 2. Do transitions",
"// Each storage directory is treated individually.",
"// During startup some of them can upgrade or roll back",
"// while others could be up-to-date for the regular startup.",
"doTransition",
"(",
"datanode",
",",
"nsInfo",
",",
"startOpt",
")",
";",
"// 3. Update all storages. Some of them might have just been formatted.",
"this",
".",
"writeAll",
"(",
")",
";",
"}"
] |
Analyze storage directories. Recover from previous transitions if required.
@param datanode Datanode to which this storage belongs to
@param nsInfo namespace information
@param dataDirs storage directories of namespace
@param startOpt startup option
@throws IOException on error
|
[
"Analyze",
"storage",
"directories",
".",
"Recover",
"from",
"previous",
"transitions",
"if",
"required",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/datanode/NameSpaceSliceStorage.java#L89-L149
|
CenturyLinkCloud/mdw
|
mdw-common/src/com/centurylink/mdw/dataaccess/file/PackageDir.java
|
PackageDir.getAssetFile
|
@ApiModelProperty(hidden=true)
public AssetFile getAssetFile(File file, AssetRevision rev) throws IOException {
"""
Called during initial load the file param is a standard file.
"""
AssetFile assetFile;
if (rev == null) {
rev = versionControl.getRevision(file);
if (rev == null) {
// presumably dropped-in asset
rev = new AssetRevision();
rev.setVersion(0);
rev.setModDate(new Date());
}
assetFile = new AssetFile(this, file.getName(), rev);
assetFile.setRevision(rev);
}
else {
versionControl.setRevision(file, rev);
assetFile = new AssetFile(this, file.getName(), rev);
versionControl.clearId(assetFile);
}
assetFile.setId(versionControl.getId(assetFile.getLogicalFile()));
assetFiles.put(assetFile.getLogicalFile(), assetFile);
return assetFile;
}
|
java
|
@ApiModelProperty(hidden=true)
public AssetFile getAssetFile(File file, AssetRevision rev) throws IOException {
AssetFile assetFile;
if (rev == null) {
rev = versionControl.getRevision(file);
if (rev == null) {
// presumably dropped-in asset
rev = new AssetRevision();
rev.setVersion(0);
rev.setModDate(new Date());
}
assetFile = new AssetFile(this, file.getName(), rev);
assetFile.setRevision(rev);
}
else {
versionControl.setRevision(file, rev);
assetFile = new AssetFile(this, file.getName(), rev);
versionControl.clearId(assetFile);
}
assetFile.setId(versionControl.getId(assetFile.getLogicalFile()));
assetFiles.put(assetFile.getLogicalFile(), assetFile);
return assetFile;
}
|
[
"@",
"ApiModelProperty",
"(",
"hidden",
"=",
"true",
")",
"public",
"AssetFile",
"getAssetFile",
"(",
"File",
"file",
",",
"AssetRevision",
"rev",
")",
"throws",
"IOException",
"{",
"AssetFile",
"assetFile",
";",
"if",
"(",
"rev",
"==",
"null",
")",
"{",
"rev",
"=",
"versionControl",
".",
"getRevision",
"(",
"file",
")",
";",
"if",
"(",
"rev",
"==",
"null",
")",
"{",
"// presumably dropped-in asset",
"rev",
"=",
"new",
"AssetRevision",
"(",
")",
";",
"rev",
".",
"setVersion",
"(",
"0",
")",
";",
"rev",
".",
"setModDate",
"(",
"new",
"Date",
"(",
")",
")",
";",
"}",
"assetFile",
"=",
"new",
"AssetFile",
"(",
"this",
",",
"file",
".",
"getName",
"(",
")",
",",
"rev",
")",
";",
"assetFile",
".",
"setRevision",
"(",
"rev",
")",
";",
"}",
"else",
"{",
"versionControl",
".",
"setRevision",
"(",
"file",
",",
"rev",
")",
";",
"assetFile",
"=",
"new",
"AssetFile",
"(",
"this",
",",
"file",
".",
"getName",
"(",
")",
",",
"rev",
")",
";",
"versionControl",
".",
"clearId",
"(",
"assetFile",
")",
";",
"}",
"assetFile",
".",
"setId",
"(",
"versionControl",
".",
"getId",
"(",
"assetFile",
".",
"getLogicalFile",
"(",
")",
")",
")",
";",
"assetFiles",
".",
"put",
"(",
"assetFile",
".",
"getLogicalFile",
"(",
")",
",",
"assetFile",
")",
";",
"return",
"assetFile",
";",
"}"
] |
Called during initial load the file param is a standard file.
|
[
"Called",
"during",
"initial",
"load",
"the",
"file",
"param",
"is",
"a",
"standard",
"file",
"."
] |
train
|
https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/dataaccess/file/PackageDir.java#L215-L237
|
Wikidata/Wikidata-Toolkit
|
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
|
Timer.getNamedTotalTimer
|
public static Timer getNamedTotalTimer(String timerName) {
"""
Collect the total times measured by all known named timers of the given
name. This is useful to add up times that were collected across separate
threads.
@param timerName
@return timer
"""
long totalCpuTime = 0;
long totalSystemTime = 0;
int measurements = 0;
int timerCount = 0;
int todoFlags = RECORD_NONE;
Timer previousTimer = null;
for (Map.Entry<Timer, Timer> entry : registeredTimers.entrySet()) {
if (entry.getValue().name.equals(timerName)) {
previousTimer = entry.getValue();
timerCount += 1;
totalCpuTime += previousTimer.totalCpuTime;
totalSystemTime += previousTimer.totalWallTime;
measurements += previousTimer.measurements;
todoFlags |= previousTimer.todoFlags;
}
}
if (timerCount == 1) {
return previousTimer;
} else {
Timer result = new Timer(timerName, todoFlags, 0);
result.totalCpuTime = totalCpuTime;
result.totalWallTime = totalSystemTime;
result.measurements = measurements;
result.threadCount = timerCount;
return result;
}
}
|
java
|
public static Timer getNamedTotalTimer(String timerName) {
long totalCpuTime = 0;
long totalSystemTime = 0;
int measurements = 0;
int timerCount = 0;
int todoFlags = RECORD_NONE;
Timer previousTimer = null;
for (Map.Entry<Timer, Timer> entry : registeredTimers.entrySet()) {
if (entry.getValue().name.equals(timerName)) {
previousTimer = entry.getValue();
timerCount += 1;
totalCpuTime += previousTimer.totalCpuTime;
totalSystemTime += previousTimer.totalWallTime;
measurements += previousTimer.measurements;
todoFlags |= previousTimer.todoFlags;
}
}
if (timerCount == 1) {
return previousTimer;
} else {
Timer result = new Timer(timerName, todoFlags, 0);
result.totalCpuTime = totalCpuTime;
result.totalWallTime = totalSystemTime;
result.measurements = measurements;
result.threadCount = timerCount;
return result;
}
}
|
[
"public",
"static",
"Timer",
"getNamedTotalTimer",
"(",
"String",
"timerName",
")",
"{",
"long",
"totalCpuTime",
"=",
"0",
";",
"long",
"totalSystemTime",
"=",
"0",
";",
"int",
"measurements",
"=",
"0",
";",
"int",
"timerCount",
"=",
"0",
";",
"int",
"todoFlags",
"=",
"RECORD_NONE",
";",
"Timer",
"previousTimer",
"=",
"null",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Timer",
",",
"Timer",
">",
"entry",
":",
"registeredTimers",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"name",
".",
"equals",
"(",
"timerName",
")",
")",
"{",
"previousTimer",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"timerCount",
"+=",
"1",
";",
"totalCpuTime",
"+=",
"previousTimer",
".",
"totalCpuTime",
";",
"totalSystemTime",
"+=",
"previousTimer",
".",
"totalWallTime",
";",
"measurements",
"+=",
"previousTimer",
".",
"measurements",
";",
"todoFlags",
"|=",
"previousTimer",
".",
"todoFlags",
";",
"}",
"}",
"if",
"(",
"timerCount",
"==",
"1",
")",
"{",
"return",
"previousTimer",
";",
"}",
"else",
"{",
"Timer",
"result",
"=",
"new",
"Timer",
"(",
"timerName",
",",
"todoFlags",
",",
"0",
")",
";",
"result",
".",
"totalCpuTime",
"=",
"totalCpuTime",
";",
"result",
".",
"totalWallTime",
"=",
"totalSystemTime",
";",
"result",
".",
"measurements",
"=",
"measurements",
";",
"result",
".",
"threadCount",
"=",
"timerCount",
";",
"return",
"result",
";",
"}",
"}"
] |
Collect the total times measured by all known named timers of the given
name. This is useful to add up times that were collected across separate
threads.
@param timerName
@return timer
|
[
"Collect",
"the",
"total",
"times",
"measured",
"by",
"all",
"known",
"named",
"timers",
"of",
"the",
"given",
"name",
".",
"This",
"is",
"useful",
"to",
"add",
"up",
"times",
"that",
"were",
"collected",
"across",
"separate",
"threads",
"."
] |
train
|
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L526-L555
|
Stratio/deep-spark
|
deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java
|
ExtractorConfig.getPair
|
public <K, V> Pair<K, V> getPair(String key, Class<K> keyClass, Class<V> valueClass) {
"""
Gets pair.
@param key the key
@param keyClass the key class
@param valueClass the value class
@return the pair
"""
return getValue(Pair.class, key);
}
|
java
|
public <K, V> Pair<K, V> getPair(String key, Class<K> keyClass, Class<V> valueClass) {
return getValue(Pair.class, key);
}
|
[
"public",
"<",
"K",
",",
"V",
">",
"Pair",
"<",
"K",
",",
"V",
">",
"getPair",
"(",
"String",
"key",
",",
"Class",
"<",
"K",
">",
"keyClass",
",",
"Class",
"<",
"V",
">",
"valueClass",
")",
"{",
"return",
"getValue",
"(",
"Pair",
".",
"class",
",",
"key",
")",
";",
"}"
] |
Gets pair.
@param key the key
@param keyClass the key class
@param valueClass the value class
@return the pair
|
[
"Gets",
"pair",
"."
] |
train
|
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java#L221-L223
|
terrestris/shogun-core
|
src/shogun-core-main/src/main/java/de/terrestris/shoguncore/security/access/entity/AlwaysAllowReadPermissionEvaluator.java
|
AlwaysAllowReadPermissionEvaluator.hasPermission
|
@Override
public boolean hasPermission(User user, E entity, Permission permission) {
"""
Grants READ permission on the user object of the currently logged in
user. Uses default implementation otherwise.
"""
// always grant READ access ("unsecured" object)
if (permission.equals(Permission.READ)) {
LOG.trace("Granting READ access on " + entity.getClass().getSimpleName() + " with ID " + entity.getId());
return true;
}
// call parent implementation
return super.hasPermission(user, entity, permission);
}
|
java
|
@Override
public boolean hasPermission(User user, E entity, Permission permission) {
// always grant READ access ("unsecured" object)
if (permission.equals(Permission.READ)) {
LOG.trace("Granting READ access on " + entity.getClass().getSimpleName() + " with ID " + entity.getId());
return true;
}
// call parent implementation
return super.hasPermission(user, entity, permission);
}
|
[
"@",
"Override",
"public",
"boolean",
"hasPermission",
"(",
"User",
"user",
",",
"E",
"entity",
",",
"Permission",
"permission",
")",
"{",
"// always grant READ access (\"unsecured\" object)",
"if",
"(",
"permission",
".",
"equals",
"(",
"Permission",
".",
"READ",
")",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"Granting READ access on \"",
"+",
"entity",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\" with ID \"",
"+",
"entity",
".",
"getId",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"// call parent implementation",
"return",
"super",
".",
"hasPermission",
"(",
"user",
",",
"entity",
",",
"permission",
")",
";",
"}"
] |
Grants READ permission on the user object of the currently logged in
user. Uses default implementation otherwise.
|
[
"Grants",
"READ",
"permission",
"on",
"the",
"user",
"object",
"of",
"the",
"currently",
"logged",
"in",
"user",
".",
"Uses",
"default",
"implementation",
"otherwise",
"."
] |
train
|
https://github.com/terrestris/shogun-core/blob/3dbabda35ae63235265913c865dba389b050b6e6/src/shogun-core-main/src/main/java/de/terrestris/shoguncore/security/access/entity/AlwaysAllowReadPermissionEvaluator.java#L34-L45
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
|
ResourceGroovyMethods.withInputStream
|
public static <T> T withInputStream(URL url, @ClosureParams(value = SimpleType.class, options = "java.io.InputStream") Closure<T> closure) throws IOException {
"""
Creates a new InputStream for this URL and passes it into the closure.
This method ensures the stream is closed after the closure returns.
@param url a URL
@param closure a closure
@return the value returned by the closure
@throws IOException if an IOException occurs.
@see IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure)
@since 1.5.2
"""
return IOGroovyMethods.withStream(newInputStream(url), closure);
}
|
java
|
public static <T> T withInputStream(URL url, @ClosureParams(value = SimpleType.class, options = "java.io.InputStream") Closure<T> closure) throws IOException {
return IOGroovyMethods.withStream(newInputStream(url), closure);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"withInputStream",
"(",
"URL",
"url",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.InputStream\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"IOGroovyMethods",
".",
"withStream",
"(",
"newInputStream",
"(",
"url",
")",
",",
"closure",
")",
";",
"}"
] |
Creates a new InputStream for this URL and passes it into the closure.
This method ensures the stream is closed after the closure returns.
@param url a URL
@param closure a closure
@return the value returned by the closure
@throws IOException if an IOException occurs.
@see IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure)
@since 1.5.2
|
[
"Creates",
"a",
"new",
"InputStream",
"for",
"this",
"URL",
"and",
"passes",
"it",
"into",
"the",
"closure",
".",
"This",
"method",
"ensures",
"the",
"stream",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1857-L1859
|
cdk/cdk
|
display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/StandardAtomGenerator.java
|
StandardAtomGenerator.positionMassLabel
|
TextOutline positionMassLabel(TextOutline massLabel, TextOutline elementLabel) {
"""
Position the mass label relative to the element label. The mass adjunct is position to the
top left of the element label.
@param massLabel mass label outline
@param elementLabel element label outline
@return positioned mass label
"""
final Rectangle2D elementBounds = elementLabel.getBounds();
final Rectangle2D massBounds = massLabel.getBounds();
return massLabel.translate((elementBounds.getMinX() - padding) - massBounds.getMaxX(),
(elementBounds.getMinY() - (massBounds.getHeight() / 2)) - massBounds.getMinY());
}
|
java
|
TextOutline positionMassLabel(TextOutline massLabel, TextOutline elementLabel) {
final Rectangle2D elementBounds = elementLabel.getBounds();
final Rectangle2D massBounds = massLabel.getBounds();
return massLabel.translate((elementBounds.getMinX() - padding) - massBounds.getMaxX(),
(elementBounds.getMinY() - (massBounds.getHeight() / 2)) - massBounds.getMinY());
}
|
[
"TextOutline",
"positionMassLabel",
"(",
"TextOutline",
"massLabel",
",",
"TextOutline",
"elementLabel",
")",
"{",
"final",
"Rectangle2D",
"elementBounds",
"=",
"elementLabel",
".",
"getBounds",
"(",
")",
";",
"final",
"Rectangle2D",
"massBounds",
"=",
"massLabel",
".",
"getBounds",
"(",
")",
";",
"return",
"massLabel",
".",
"translate",
"(",
"(",
"elementBounds",
".",
"getMinX",
"(",
")",
"-",
"padding",
")",
"-",
"massBounds",
".",
"getMaxX",
"(",
")",
",",
"(",
"elementBounds",
".",
"getMinY",
"(",
")",
"-",
"(",
"massBounds",
".",
"getHeight",
"(",
")",
"/",
"2",
")",
")",
"-",
"massBounds",
".",
"getMinY",
"(",
")",
")",
";",
"}"
] |
Position the mass label relative to the element label. The mass adjunct is position to the
top left of the element label.
@param massLabel mass label outline
@param elementLabel element label outline
@return positioned mass label
|
[
"Position",
"the",
"mass",
"label",
"relative",
"to",
"the",
"element",
"label",
".",
"The",
"mass",
"adjunct",
"is",
"position",
"to",
"the",
"top",
"left",
"of",
"the",
"element",
"label",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/StandardAtomGenerator.java#L505-L510
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.