repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java | PreambleUtil.getHiFieldOffset | static long getHiFieldOffset(final Format format, final HiField hiField) {
"""
Returns the defined byte offset from the start of the preamble given the <i>HiField</i>
and the <i>Format</i>.
Note this can not be used to obtain the stream offsets.
@param format the desired <i>Format</i>
@param hiField the desired preamble <i>HiField</i> after the first eight bytes.
@return the defined byte offset from the start of the preamble for the given <i>HiField</i>
and the <i>Format</i>.
"""
final int formatIdx = format.ordinal();
final int hiFieldIdx = hiField.ordinal();
final long fieldOffset = hiFieldOffset[formatIdx][hiFieldIdx] & 0xFF; //initially a byte
if (fieldOffset == 0) {
throw new SketchesStateException("Undefined preamble field given the Format: "
+ "Format: " + format.toString() + ", HiField: " + hiField.toString());
}
return fieldOffset;
} | java | static long getHiFieldOffset(final Format format, final HiField hiField) {
final int formatIdx = format.ordinal();
final int hiFieldIdx = hiField.ordinal();
final long fieldOffset = hiFieldOffset[formatIdx][hiFieldIdx] & 0xFF; //initially a byte
if (fieldOffset == 0) {
throw new SketchesStateException("Undefined preamble field given the Format: "
+ "Format: " + format.toString() + ", HiField: " + hiField.toString());
}
return fieldOffset;
} | [
"static",
"long",
"getHiFieldOffset",
"(",
"final",
"Format",
"format",
",",
"final",
"HiField",
"hiField",
")",
"{",
"final",
"int",
"formatIdx",
"=",
"format",
".",
"ordinal",
"(",
")",
";",
"final",
"int",
"hiFieldIdx",
"=",
"hiField",
".",
"ordinal",
"(",
")",
";",
"final",
"long",
"fieldOffset",
"=",
"hiFieldOffset",
"[",
"formatIdx",
"]",
"[",
"hiFieldIdx",
"]",
"&",
"0xFF",
";",
"//initially a byte",
"if",
"(",
"fieldOffset",
"==",
"0",
")",
"{",
"throw",
"new",
"SketchesStateException",
"(",
"\"Undefined preamble field given the Format: \"",
"+",
"\"Format: \"",
"+",
"format",
".",
"toString",
"(",
")",
"+",
"\", HiField: \"",
"+",
"hiField",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"fieldOffset",
";",
"}"
] | Returns the defined byte offset from the start of the preamble given the <i>HiField</i>
and the <i>Format</i>.
Note this can not be used to obtain the stream offsets.
@param format the desired <i>Format</i>
@param hiField the desired preamble <i>HiField</i> after the first eight bytes.
@return the defined byte offset from the start of the preamble for the given <i>HiField</i>
and the <i>Format</i>. | [
"Returns",
"the",
"defined",
"byte",
"offset",
"from",
"the",
"start",
"of",
"the",
"preamble",
"given",
"the",
"<i",
">",
"HiField<",
"/",
"i",
">",
"and",
"the",
"<i",
">",
"Format<",
"/",
"i",
">",
".",
"Note",
"this",
"can",
"not",
"be",
"used",
"to",
"obtain",
"the",
"stream",
"offsets",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java#L275-L284 |
michael-rapp/AndroidBottomSheet | library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java | BottomSheet.setItem | public final void setItem(final int index, final int id, @NonNull final CharSequence title,
@Nullable final Drawable icon) {
"""
Replaces the item at a specific index with another item.
@param index
The index of the item, which should be replaced, as an {@link Integer} value
@param id
The id of the item, which should be added, as an {@link Integer} value. The id must
be at least 0
@param title
The title of the item, which should be added, as an instance of the type {@link
CharSequence}. The title may neither be null, nor empty
@param icon
The icon of the item, which should be added, as an instance of the class {@link
Drawable}, or null, if no item should be used
"""
Item item = new Item(id, title);
item.setIcon(icon);
adapter.set(index, item);
adaptGridViewHeight();
} | java | public final void setItem(final int index, final int id, @NonNull final CharSequence title,
@Nullable final Drawable icon) {
Item item = new Item(id, title);
item.setIcon(icon);
adapter.set(index, item);
adaptGridViewHeight();
} | [
"public",
"final",
"void",
"setItem",
"(",
"final",
"int",
"index",
",",
"final",
"int",
"id",
",",
"@",
"NonNull",
"final",
"CharSequence",
"title",
",",
"@",
"Nullable",
"final",
"Drawable",
"icon",
")",
"{",
"Item",
"item",
"=",
"new",
"Item",
"(",
"id",
",",
"title",
")",
";",
"item",
".",
"setIcon",
"(",
"icon",
")",
";",
"adapter",
".",
"set",
"(",
"index",
",",
"item",
")",
";",
"adaptGridViewHeight",
"(",
")",
";",
"}"
] | Replaces the item at a specific index with another item.
@param index
The index of the item, which should be replaced, as an {@link Integer} value
@param id
The id of the item, which should be added, as an {@link Integer} value. The id must
be at least 0
@param title
The title of the item, which should be added, as an instance of the type {@link
CharSequence}. The title may neither be null, nor empty
@param icon
The icon of the item, which should be added, as an instance of the class {@link
Drawable}, or null, if no item should be used | [
"Replaces",
"the",
"item",
"at",
"a",
"specific",
"index",
"with",
"another",
"item",
"."
] | train | https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L2079-L2085 |
awslabs/jsii | packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiObject.java | JsiiObject.jsiiSet | protected final void jsiiSet(final String property, @Nullable final Object value) {
"""
Sets a property value of an object.
@param property The name of the property.
@param value The property value.
"""
engine.getClient().setPropertyValue(this.objRef, property, JsiiObjectMapper.valueToTree(value));
} | java | protected final void jsiiSet(final String property, @Nullable final Object value) {
engine.getClient().setPropertyValue(this.objRef, property, JsiiObjectMapper.valueToTree(value));
} | [
"protected",
"final",
"void",
"jsiiSet",
"(",
"final",
"String",
"property",
",",
"@",
"Nullable",
"final",
"Object",
"value",
")",
"{",
"engine",
".",
"getClient",
"(",
")",
".",
"setPropertyValue",
"(",
"this",
".",
"objRef",
",",
"property",
",",
"JsiiObjectMapper",
".",
"valueToTree",
"(",
"value",
")",
")",
";",
"}"
] | Sets a property value of an object.
@param property The name of the property.
@param value The property value. | [
"Sets",
"a",
"property",
"value",
"of",
"an",
"object",
"."
] | train | https://github.com/awslabs/jsii/blob/6bbf743f5f65e98e5199ad31c93961533ffc40e5/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiObject.java#L129-L131 |
RestComm/Restcomm-Connect | restcomm/restcomm.core/src/main/java/org/restcomm/connect/core/service/number/NumberSelectorServiceImpl.java | NumberSelectorServiceImpl.searchNumberWithResult | @Override
public NumberSelectionResult searchNumberWithResult(String phone,
Sid sourceOrganizationSid, Sid destinationOrganizationSid) {
"""
The main logic is: -Find a perfect match in DB using different formats.
-If not matched, use available Regexes in the organization. -If not
matched, try with the special * match.
@param phone
@param sourceOrganizationSid
@param destinationOrganizationSid
@return
"""
return searchNumberWithResult(phone, sourceOrganizationSid, destinationOrganizationSid, new HashSet<>(Arrays.asList(SearchModifier.ORG_COMPLIANT)));
} | java | @Override
public NumberSelectionResult searchNumberWithResult(String phone,
Sid sourceOrganizationSid, Sid destinationOrganizationSid){
return searchNumberWithResult(phone, sourceOrganizationSid, destinationOrganizationSid, new HashSet<>(Arrays.asList(SearchModifier.ORG_COMPLIANT)));
} | [
"@",
"Override",
"public",
"NumberSelectionResult",
"searchNumberWithResult",
"(",
"String",
"phone",
",",
"Sid",
"sourceOrganizationSid",
",",
"Sid",
"destinationOrganizationSid",
")",
"{",
"return",
"searchNumberWithResult",
"(",
"phone",
",",
"sourceOrganizationSid",
",",
"destinationOrganizationSid",
",",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"SearchModifier",
".",
"ORG_COMPLIANT",
")",
")",
")",
";",
"}"
] | The main logic is: -Find a perfect match in DB using different formats.
-If not matched, use available Regexes in the organization. -If not
matched, try with the special * match.
@param phone
@param sourceOrganizationSid
@param destinationOrganizationSid
@return | [
"The",
"main",
"logic",
"is",
":",
"-",
"Find",
"a",
"perfect",
"match",
"in",
"DB",
"using",
"different",
"formats",
".",
"-",
"If",
"not",
"matched",
"use",
"available",
"Regexes",
"in",
"the",
"organization",
".",
"-",
"If",
"not",
"matched",
"try",
"with",
"the",
"special",
"*",
"match",
"."
] | train | https://github.com/RestComm/Restcomm-Connect/blob/2194dee4fc524cdfd0af77a218ba5f212f97f7c5/restcomm/restcomm.core/src/main/java/org/restcomm/connect/core/service/number/NumberSelectorServiceImpl.java#L260-L264 |
EdwardRaff/JSAT | JSAT/src/jsat/math/optimization/stochastic/SGDMomentum.java | SGDMomentum.setMomentum | public void setMomentum(double momentum) {
"""
Sets the momentum for accumulating gradients.
@param momentum the momentum buildup term in (0, 1)
"""
if(momentum <= 0 || momentum >= 1 || Double.isNaN(momentum))
throw new IllegalArgumentException("Momentum must be in (0,1) not " + momentum);
this.momentum = momentum;
} | java | public void setMomentum(double momentum)
{
if(momentum <= 0 || momentum >= 1 || Double.isNaN(momentum))
throw new IllegalArgumentException("Momentum must be in (0,1) not " + momentum);
this.momentum = momentum;
} | [
"public",
"void",
"setMomentum",
"(",
"double",
"momentum",
")",
"{",
"if",
"(",
"momentum",
"<=",
"0",
"||",
"momentum",
">=",
"1",
"||",
"Double",
".",
"isNaN",
"(",
"momentum",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Momentum must be in (0,1) not \"",
"+",
"momentum",
")",
";",
"this",
".",
"momentum",
"=",
"momentum",
";",
"}"
] | Sets the momentum for accumulating gradients.
@param momentum the momentum buildup term in (0, 1) | [
"Sets",
"the",
"momentum",
"for",
"accumulating",
"gradients",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/optimization/stochastic/SGDMomentum.java#L70-L75 |
lastaflute/lastaflute | src/main/java/org/lastaflute/web/ruts/config/ActionMapping.java | ActionMapping.createNextJourney | public NextJourney createNextJourney(PlannedJourneyProvider journeyProvider, HtmlResponse response) {
"""
o routing path of forward e.g. /member/list/ -> MemberListAction
""" // almost copied from super
String path = response.getRoutingPath();
final boolean redirectTo = response.isRedirectTo();
if (path.indexOf(":") < 0) {
if (!path.startsWith("/")) {
path = buildActionPath(getActionDef().getComponentName()) + path;
}
if (!redirectTo && isHtmlForward(path)) {
path = filterHtmlPath(path);
}
}
return newNextJourney(journeyProvider, path, redirectTo, response.isAsIs(), response.getViewObject());
} | java | public NextJourney createNextJourney(PlannedJourneyProvider journeyProvider, HtmlResponse response) { // almost copied from super
String path = response.getRoutingPath();
final boolean redirectTo = response.isRedirectTo();
if (path.indexOf(":") < 0) {
if (!path.startsWith("/")) {
path = buildActionPath(getActionDef().getComponentName()) + path;
}
if (!redirectTo && isHtmlForward(path)) {
path = filterHtmlPath(path);
}
}
return newNextJourney(journeyProvider, path, redirectTo, response.isAsIs(), response.getViewObject());
} | [
"public",
"NextJourney",
"createNextJourney",
"(",
"PlannedJourneyProvider",
"journeyProvider",
",",
"HtmlResponse",
"response",
")",
"{",
"// almost copied from super",
"String",
"path",
"=",
"response",
".",
"getRoutingPath",
"(",
")",
";",
"final",
"boolean",
"redirectTo",
"=",
"response",
".",
"isRedirectTo",
"(",
")",
";",
"if",
"(",
"path",
".",
"indexOf",
"(",
"\":\"",
")",
"<",
"0",
")",
"{",
"if",
"(",
"!",
"path",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"path",
"=",
"buildActionPath",
"(",
"getActionDef",
"(",
")",
".",
"getComponentName",
"(",
")",
")",
"+",
"path",
";",
"}",
"if",
"(",
"!",
"redirectTo",
"&&",
"isHtmlForward",
"(",
"path",
")",
")",
"{",
"path",
"=",
"filterHtmlPath",
"(",
"path",
")",
";",
"}",
"}",
"return",
"newNextJourney",
"(",
"journeyProvider",
",",
"path",
",",
"redirectTo",
",",
"response",
".",
"isAsIs",
"(",
")",
",",
"response",
".",
"getViewObject",
"(",
")",
")",
";",
"}"
] | o routing path of forward e.g. /member/list/ -> MemberListAction | [
"o",
"routing",
"path",
"of",
"forward",
"e",
".",
"g",
".",
"/",
"member",
"/",
"list",
"/",
"-",
">",
"MemberListAction"
] | train | https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/ruts/config/ActionMapping.java#L126-L138 |
structr/structr | structr-rest/src/main/java/org/structr/rest/auth/AuthHelper.java | AuthHelper.getPrincipalForCredential | public static <T> Principal getPrincipalForCredential(final PropertyKey<T> key, final T value) {
"""
Find a {@link Principal} for the given credential
@param key
@param value
@return principal
"""
return getPrincipalForCredential(key, value, false);
} | java | public static <T> Principal getPrincipalForCredential(final PropertyKey<T> key, final T value) {
return getPrincipalForCredential(key, value, false);
} | [
"public",
"static",
"<",
"T",
">",
"Principal",
"getPrincipalForCredential",
"(",
"final",
"PropertyKey",
"<",
"T",
">",
"key",
",",
"final",
"T",
"value",
")",
"{",
"return",
"getPrincipalForCredential",
"(",
"key",
",",
"value",
",",
"false",
")",
";",
"}"
] | Find a {@link Principal} for the given credential
@param key
@param value
@return principal | [
"Find",
"a",
"{",
"@link",
"Principal",
"}",
"for",
"the",
"given",
"credential"
] | train | https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-rest/src/main/java/org/structr/rest/auth/AuthHelper.java#L64-L68 |
phax/ph-commons | ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroWriter.java | MicroWriter.writeToFile | @Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode, @Nonnull final File aFile) {
"""
Write a Micro Node to a file using the default settings.
@param aNode
The node to be serialized. May be any kind of node (incl.
documents). May not be <code>null</code>.
@param aFile
The file to write to. May not be <code>null</code>.
@return {@link ESuccess}
"""
return writeToFile (aNode, aFile, XMLWriterSettings.DEFAULT_XML_SETTINGS);
} | java | @Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode, @Nonnull final File aFile)
{
return writeToFile (aNode, aFile, XMLWriterSettings.DEFAULT_XML_SETTINGS);
} | [
"@",
"Nonnull",
"public",
"static",
"ESuccess",
"writeToFile",
"(",
"@",
"Nonnull",
"final",
"IMicroNode",
"aNode",
",",
"@",
"Nonnull",
"final",
"File",
"aFile",
")",
"{",
"return",
"writeToFile",
"(",
"aNode",
",",
"aFile",
",",
"XMLWriterSettings",
".",
"DEFAULT_XML_SETTINGS",
")",
";",
"}"
] | Write a Micro Node to a file using the default settings.
@param aNode
The node to be serialized. May be any kind of node (incl.
documents). May not be <code>null</code>.
@param aFile
The file to write to. May not be <code>null</code>.
@return {@link ESuccess} | [
"Write",
"a",
"Micro",
"Node",
"to",
"a",
"file",
"using",
"the",
"default",
"settings",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroWriter.java#L70-L74 |
robinst/autolink-java | src/main/java/org/nibor/autolink/LinkExtractor.java | LinkExtractor.extractSpans | public Iterable<Span> extractSpans(final CharSequence input) {
"""
Extract spans from the input text. A span is a substring of the input and represents either a link
(see {@link LinkSpan}) or plain text outside a link.
<p>
Using this is more convenient than {@link #extractLinks} if you want to transform the whole input text to
a different format.
@param input the input text, must not be null
@return a lazy iterable for the spans in order that they appear in the input, never null
"""
if (input == null) {
throw new NullPointerException("input must not be null");
}
return new Iterable<Span>() {
@Override
public Iterator<Span> iterator() {
return new SpanIterator(input, new LinkIterator(input));
}
};
} | java | public Iterable<Span> extractSpans(final CharSequence input) {
if (input == null) {
throw new NullPointerException("input must not be null");
}
return new Iterable<Span>() {
@Override
public Iterator<Span> iterator() {
return new SpanIterator(input, new LinkIterator(input));
}
};
} | [
"public",
"Iterable",
"<",
"Span",
">",
"extractSpans",
"(",
"final",
"CharSequence",
"input",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"input must not be null\"",
")",
";",
"}",
"return",
"new",
"Iterable",
"<",
"Span",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<",
"Span",
">",
"iterator",
"(",
")",
"{",
"return",
"new",
"SpanIterator",
"(",
"input",
",",
"new",
"LinkIterator",
"(",
"input",
")",
")",
";",
"}",
"}",
";",
"}"
] | Extract spans from the input text. A span is a substring of the input and represents either a link
(see {@link LinkSpan}) or plain text outside a link.
<p>
Using this is more convenient than {@link #extractLinks} if you want to transform the whole input text to
a different format.
@param input the input text, must not be null
@return a lazy iterable for the spans in order that they appear in the input, never null | [
"Extract",
"spans",
"from",
"the",
"input",
"text",
".",
"A",
"span",
"is",
"a",
"substring",
"of",
"the",
"input",
"and",
"represents",
"either",
"a",
"link",
"(",
"see",
"{",
"@link",
"LinkSpan",
"}",
")",
"or",
"plain",
"text",
"outside",
"a",
"link",
".",
"<p",
">",
"Using",
"this",
"is",
"more",
"convenient",
"than",
"{",
"@link",
"#extractLinks",
"}",
"if",
"you",
"want",
"to",
"transform",
"the",
"whole",
"input",
"text",
"to",
"a",
"different",
"format",
"."
] | train | https://github.com/robinst/autolink-java/blob/9b01c2620d450cd51942f4d092e4e7153980c6d8/src/main/java/org/nibor/autolink/LinkExtractor.java#L58-L68 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/BaseProfile.java | BaseProfile.generateMultiMcfClassCode | void generateMultiMcfClassCode(Definition def, String className, int num) {
"""
generate multi mcf class code
@param def Definition
@param className class name
@param num number of order
"""
if (className == null || className.equals(""))
return;
if (num < 0 || num + 1 > def.getMcfDefs().size())
return;
try
{
String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";
String javaFile =
McfDef.class.getMethod("get" + className + "Class").invoke(def.getMcfDefs().get(num), (Object[]) null)
+ ".java";
FileWriter fw;
fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
AbstractCodeGen codeGen = (AbstractCodeGen) clazz.newInstance();
codeGen.setNumOfMcf(num);
codeGen.generate(def, fw);
fw.flush();
fw.close();
}
catch (Exception e)
{
e.printStackTrace();
}
} | java | void generateMultiMcfClassCode(Definition def, String className, int num)
{
if (className == null || className.equals(""))
return;
if (num < 0 || num + 1 > def.getMcfDefs().size())
return;
try
{
String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";
String javaFile =
McfDef.class.getMethod("get" + className + "Class").invoke(def.getMcfDefs().get(num), (Object[]) null)
+ ".java";
FileWriter fw;
fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
AbstractCodeGen codeGen = (AbstractCodeGen) clazz.newInstance();
codeGen.setNumOfMcf(num);
codeGen.generate(def, fw);
fw.flush();
fw.close();
}
catch (Exception e)
{
e.printStackTrace();
}
} | [
"void",
"generateMultiMcfClassCode",
"(",
"Definition",
"def",
",",
"String",
"className",
",",
"int",
"num",
")",
"{",
"if",
"(",
"className",
"==",
"null",
"||",
"className",
".",
"equals",
"(",
"\"\"",
")",
")",
"return",
";",
"if",
"(",
"num",
"<",
"0",
"||",
"num",
"+",
"1",
">",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"size",
"(",
")",
")",
"return",
";",
"try",
"{",
"String",
"clazzName",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".code.\"",
"+",
"className",
"+",
"\"CodeGen\"",
";",
"String",
"javaFile",
"=",
"McfDef",
".",
"class",
".",
"getMethod",
"(",
"\"get\"",
"+",
"className",
"+",
"\"Class\"",
")",
".",
"invoke",
"(",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"num",
")",
",",
"(",
"Object",
"[",
"]",
")",
"null",
")",
"+",
"\".java\"",
";",
"FileWriter",
"fw",
";",
"fw",
"=",
"Utils",
".",
"createSrcFile",
"(",
"javaFile",
",",
"def",
".",
"getRaPackage",
"(",
")",
",",
"def",
".",
"getOutputDir",
"(",
")",
")",
";",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"clazzName",
",",
"true",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"AbstractCodeGen",
"codeGen",
"=",
"(",
"AbstractCodeGen",
")",
"clazz",
".",
"newInstance",
"(",
")",
";",
"codeGen",
".",
"setNumOfMcf",
"(",
"num",
")",
";",
"codeGen",
".",
"generate",
"(",
"def",
",",
"fw",
")",
";",
"fw",
".",
"flush",
"(",
")",
";",
"fw",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | generate multi mcf class code
@param def Definition
@param className class name
@param num number of order | [
"generate",
"multi",
"mcf",
"class",
"code"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/BaseProfile.java#L256-L286 |
i-net-software/jlessc | src/com/inet/lib/less/FunctionExpression.java | FunctionExpression.getPercent | private double getPercent( int idx, double defaultValue, CssFormatter formatter ) {
"""
Get the idx parameter from the parameter list as percent (range 0 - 1).
@param idx
the index starting with 0
@param defaultValue
the result if such a parameter idx does not exists.
@param formatter
current formatter
@return the the percent value
"""
if( parameters.size() <= idx ) {
return defaultValue;
}
return ColorUtils.getPercent( get( idx ), formatter );
} | java | private double getPercent( int idx, double defaultValue, CssFormatter formatter ) {
if( parameters.size() <= idx ) {
return defaultValue;
}
return ColorUtils.getPercent( get( idx ), formatter );
} | [
"private",
"double",
"getPercent",
"(",
"int",
"idx",
",",
"double",
"defaultValue",
",",
"CssFormatter",
"formatter",
")",
"{",
"if",
"(",
"parameters",
".",
"size",
"(",
")",
"<=",
"idx",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"ColorUtils",
".",
"getPercent",
"(",
"get",
"(",
"idx",
")",
",",
"formatter",
")",
";",
"}"
] | Get the idx parameter from the parameter list as percent (range 0 - 1).
@param idx
the index starting with 0
@param defaultValue
the result if such a parameter idx does not exists.
@param formatter
current formatter
@return the the percent value | [
"Get",
"the",
"idx",
"parameter",
"from",
"the",
"parameter",
"list",
"as",
"percent",
"(",
"range",
"0",
"-",
"1",
")",
"."
] | train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/FunctionExpression.java#L963-L968 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.availableAutomaticPaymentMeans_GET | public OvhAutomaticPaymentMean availableAutomaticPaymentMeans_GET() throws IOException {
"""
List available payment methods in this Nic's country
REST: GET /me/availableAutomaticPaymentMeans
"""
String qPath = "/me/availableAutomaticPaymentMeans";
StringBuilder sb = path(qPath);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAutomaticPaymentMean.class);
} | java | public OvhAutomaticPaymentMean availableAutomaticPaymentMeans_GET() throws IOException {
String qPath = "/me/availableAutomaticPaymentMeans";
StringBuilder sb = path(qPath);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAutomaticPaymentMean.class);
} | [
"public",
"OvhAutomaticPaymentMean",
"availableAutomaticPaymentMeans_GET",
"(",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/availableAutomaticPaymentMeans\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhAutomaticPaymentMean",
".",
"class",
")",
";",
"}"
] | List available payment methods in this Nic's country
REST: GET /me/availableAutomaticPaymentMeans | [
"List",
"available",
"payment",
"methods",
"in",
"this",
"Nic",
"s",
"country"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L374-L379 |
voldemort/voldemort | src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java | AbstractFailureDetector.setAvailable | private boolean setAvailable(NodeStatus nodeStatus, boolean isAvailable) {
"""
We need to distinguish the case where we're newly available and the case
where we're already available. So we check the node status before we
update it and return it to the caller.
@param isAvailable True to set to available, false to make unavailable
@return Previous value of isAvailable
"""
synchronized(nodeStatus) {
boolean previous = nodeStatus.isAvailable();
nodeStatus.setAvailable(isAvailable);
nodeStatus.setLastChecked(getConfig().getTime().getMilliseconds());
return previous;
}
} | java | private boolean setAvailable(NodeStatus nodeStatus, boolean isAvailable) {
synchronized(nodeStatus) {
boolean previous = nodeStatus.isAvailable();
nodeStatus.setAvailable(isAvailable);
nodeStatus.setLastChecked(getConfig().getTime().getMilliseconds());
return previous;
}
} | [
"private",
"boolean",
"setAvailable",
"(",
"NodeStatus",
"nodeStatus",
",",
"boolean",
"isAvailable",
")",
"{",
"synchronized",
"(",
"nodeStatus",
")",
"{",
"boolean",
"previous",
"=",
"nodeStatus",
".",
"isAvailable",
"(",
")",
";",
"nodeStatus",
".",
"setAvailable",
"(",
"isAvailable",
")",
";",
"nodeStatus",
".",
"setLastChecked",
"(",
"getConfig",
"(",
")",
".",
"getTime",
"(",
")",
".",
"getMilliseconds",
"(",
")",
")",
";",
"return",
"previous",
";",
"}",
"}"
] | We need to distinguish the case where we're newly available and the case
where we're already available. So we check the node status before we
update it and return it to the caller.
@param isAvailable True to set to available, false to make unavailable
@return Previous value of isAvailable | [
"We",
"need",
"to",
"distinguish",
"the",
"case",
"where",
"we",
"re",
"newly",
"available",
"and",
"the",
"case",
"where",
"we",
"re",
"already",
"available",
".",
"So",
"we",
"check",
"the",
"node",
"status",
"before",
"we",
"update",
"it",
"and",
"return",
"it",
"to",
"the",
"caller",
"."
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java#L273-L282 |
xvik/dropwizard-guicey | src/main/java/ru/vyarus/dropwizard/guice/module/context/ConfigurationContext.java | ConfigurationContext.registerDisablePredicates | @SuppressWarnings("PMD.UseVarargs")
public void registerDisablePredicates(final Predicate<ItemInfo>[] predicates) {
"""
Register disable predicates, used to disable all matched items.
<p>
After registration predicates are applied to all currently registered items to avoid registration
order influence.
@param predicates disable predicates
"""
final List<PredicateHandler> list = Arrays.stream(predicates)
.map(p -> new PredicateHandler(p, getScope()))
.collect(Collectors.toList());
disablePredicates.addAll(list);
applyPredicatesForRegisteredItems(list);
} | java | @SuppressWarnings("PMD.UseVarargs")
public void registerDisablePredicates(final Predicate<ItemInfo>[] predicates) {
final List<PredicateHandler> list = Arrays.stream(predicates)
.map(p -> new PredicateHandler(p, getScope()))
.collect(Collectors.toList());
disablePredicates.addAll(list);
applyPredicatesForRegisteredItems(list);
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.UseVarargs\"",
")",
"public",
"void",
"registerDisablePredicates",
"(",
"final",
"Predicate",
"<",
"ItemInfo",
">",
"[",
"]",
"predicates",
")",
"{",
"final",
"List",
"<",
"PredicateHandler",
">",
"list",
"=",
"Arrays",
".",
"stream",
"(",
"predicates",
")",
".",
"map",
"(",
"p",
"->",
"new",
"PredicateHandler",
"(",
"p",
",",
"getScope",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"disablePredicates",
".",
"addAll",
"(",
"list",
")",
";",
"applyPredicatesForRegisteredItems",
"(",
"list",
")",
";",
"}"
] | Register disable predicates, used to disable all matched items.
<p>
After registration predicates are applied to all currently registered items to avoid registration
order influence.
@param predicates disable predicates | [
"Register",
"disable",
"predicates",
"used",
"to",
"disable",
"all",
"matched",
"items",
".",
"<p",
">",
"After",
"registration",
"predicates",
"are",
"applied",
"to",
"all",
"currently",
"registered",
"items",
"to",
"avoid",
"registration",
"order",
"influence",
"."
] | train | https://github.com/xvik/dropwizard-guicey/blob/dd39ad77283555be21f606d5ebf0f11207a733d4/src/main/java/ru/vyarus/dropwizard/guice/module/context/ConfigurationContext.java#L474-L481 |
jbundle/jbundle | thin/base/db/base/src/main/java/org/jbundle/thin/base/db/FieldTable.java | FieldTable.doSetHandle | public boolean doSetHandle(Object bookmark, int iHandleType) throws DBException {
"""
Reposition to this record using this bookmark.
@param bookmark The handle to use to position the record.
@param iHandleType The type of handle (DATA_SOURCE/OBJECT_ID,OBJECT_SOURCE,BOOKMARK).
@return - true - record found/false - record not found
@exception FILE_NOT_OPEN.
@exception DBException File exception.
"""
String strCurrentOrder = this.getRecord().getKeyName();
this.getRecord().setKeyArea(Constants.PRIMARY_KEY);
this.getRecord().getCounterField().setData(bookmark);
boolean bSuccess = this.seek(Constants.EQUALS);
this.getRecord().setKeyArea(strCurrentOrder);
return bSuccess;
} | java | public boolean doSetHandle(Object bookmark, int iHandleType) throws DBException
{
String strCurrentOrder = this.getRecord().getKeyName();
this.getRecord().setKeyArea(Constants.PRIMARY_KEY);
this.getRecord().getCounterField().setData(bookmark);
boolean bSuccess = this.seek(Constants.EQUALS);
this.getRecord().setKeyArea(strCurrentOrder);
return bSuccess;
} | [
"public",
"boolean",
"doSetHandle",
"(",
"Object",
"bookmark",
",",
"int",
"iHandleType",
")",
"throws",
"DBException",
"{",
"String",
"strCurrentOrder",
"=",
"this",
".",
"getRecord",
"(",
")",
".",
"getKeyName",
"(",
")",
";",
"this",
".",
"getRecord",
"(",
")",
".",
"setKeyArea",
"(",
"Constants",
".",
"PRIMARY_KEY",
")",
";",
"this",
".",
"getRecord",
"(",
")",
".",
"getCounterField",
"(",
")",
".",
"setData",
"(",
"bookmark",
")",
";",
"boolean",
"bSuccess",
"=",
"this",
".",
"seek",
"(",
"Constants",
".",
"EQUALS",
")",
";",
"this",
".",
"getRecord",
"(",
")",
".",
"setKeyArea",
"(",
"strCurrentOrder",
")",
";",
"return",
"bSuccess",
";",
"}"
] | Reposition to this record using this bookmark.
@param bookmark The handle to use to position the record.
@param iHandleType The type of handle (DATA_SOURCE/OBJECT_ID,OBJECT_SOURCE,BOOKMARK).
@return - true - record found/false - record not found
@exception FILE_NOT_OPEN.
@exception DBException File exception. | [
"Reposition",
"to",
"this",
"record",
"using",
"this",
"bookmark",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/FieldTable.java#L492-L502 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/helper/ItemAdapter.java | ItemAdapter.getItemDetail | private ItemDetail getItemDetail(Gson gson, JsonElement itemType, JsonElement detail) {
"""
get the correct type of item detail, will give null if itemType/detail is empty
"""
if (itemType == null || detail == null) return null;
Item.Type type = gson.fromJson(itemType, Item.Type.class);
Class<? extends ItemDetail> detailType;
switch (type) {
case Armor:
detailType = Armor.class;
break;
case Back:
detailType = Back.class;
break;
case Bag:
detailType = Bag.class;
break;
case Consumable:
detailType = Consumable.class;
break;
case MiniPet:
detailType = Mini.class;
break;
case Trinket:
detailType = Trinket.class;
break;
case UpgradeComponent:
detailType = UpgradeComponent.class;
break;
case Weapon:
detailType = Weapon.class;
break;
default:
detailType = Utility.class;
}
return gson.fromJson(detail, detailType);
} | java | private ItemDetail getItemDetail(Gson gson, JsonElement itemType, JsonElement detail) {
if (itemType == null || detail == null) return null;
Item.Type type = gson.fromJson(itemType, Item.Type.class);
Class<? extends ItemDetail> detailType;
switch (type) {
case Armor:
detailType = Armor.class;
break;
case Back:
detailType = Back.class;
break;
case Bag:
detailType = Bag.class;
break;
case Consumable:
detailType = Consumable.class;
break;
case MiniPet:
detailType = Mini.class;
break;
case Trinket:
detailType = Trinket.class;
break;
case UpgradeComponent:
detailType = UpgradeComponent.class;
break;
case Weapon:
detailType = Weapon.class;
break;
default:
detailType = Utility.class;
}
return gson.fromJson(detail, detailType);
} | [
"private",
"ItemDetail",
"getItemDetail",
"(",
"Gson",
"gson",
",",
"JsonElement",
"itemType",
",",
"JsonElement",
"detail",
")",
"{",
"if",
"(",
"itemType",
"==",
"null",
"||",
"detail",
"==",
"null",
")",
"return",
"null",
";",
"Item",
".",
"Type",
"type",
"=",
"gson",
".",
"fromJson",
"(",
"itemType",
",",
"Item",
".",
"Type",
".",
"class",
")",
";",
"Class",
"<",
"?",
"extends",
"ItemDetail",
">",
"detailType",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"Armor",
":",
"detailType",
"=",
"Armor",
".",
"class",
";",
"break",
";",
"case",
"Back",
":",
"detailType",
"=",
"Back",
".",
"class",
";",
"break",
";",
"case",
"Bag",
":",
"detailType",
"=",
"Bag",
".",
"class",
";",
"break",
";",
"case",
"Consumable",
":",
"detailType",
"=",
"Consumable",
".",
"class",
";",
"break",
";",
"case",
"MiniPet",
":",
"detailType",
"=",
"Mini",
".",
"class",
";",
"break",
";",
"case",
"Trinket",
":",
"detailType",
"=",
"Trinket",
".",
"class",
";",
"break",
";",
"case",
"UpgradeComponent",
":",
"detailType",
"=",
"UpgradeComponent",
".",
"class",
";",
"break",
";",
"case",
"Weapon",
":",
"detailType",
"=",
"Weapon",
".",
"class",
";",
"break",
";",
"default",
":",
"detailType",
"=",
"Utility",
".",
"class",
";",
"}",
"return",
"gson",
".",
"fromJson",
"(",
"detail",
",",
"detailType",
")",
";",
"}"
] | get the correct type of item detail, will give null if itemType/detail is empty | [
"get",
"the",
"correct",
"type",
"of",
"item",
"detail",
"will",
"give",
"null",
"if",
"itemType",
"/",
"detail",
"is",
"empty"
] | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/helper/ItemAdapter.java#L50-L86 |
akamai/AkamaiOPEN-edgegrid-java | edgerc-reader/src/main/java/com/akamai/edgegrid/signer/EdgeRcClientCredentialProvider.java | EdgeRcClientCredentialProvider.fromEdgeRc | public static EdgeRcClientCredentialProvider fromEdgeRc(InputStream inputStream, String section)
throws ConfigurationException, IOException {
"""
Loads an EdgeRc configuration file and returns an {@link EdgeRcClientCredentialProvider} to
read {@link ClientCredential}s from it.
@param inputStream an open {@link InputStream} to an EdgeRc file
@param section a config section ({@code null} for the default section)
@return a {@link EdgeRcClientCredentialProvider}
@throws ConfigurationException If an error occurs while reading the configuration
@throws IOException if an I/O error occurs
"""
Objects.requireNonNull(inputStream, "inputStream cannot be null");
return fromEdgeRc(new InputStreamReader(inputStream), section);
} | java | public static EdgeRcClientCredentialProvider fromEdgeRc(InputStream inputStream, String section)
throws ConfigurationException, IOException {
Objects.requireNonNull(inputStream, "inputStream cannot be null");
return fromEdgeRc(new InputStreamReader(inputStream), section);
} | [
"public",
"static",
"EdgeRcClientCredentialProvider",
"fromEdgeRc",
"(",
"InputStream",
"inputStream",
",",
"String",
"section",
")",
"throws",
"ConfigurationException",
",",
"IOException",
"{",
"Objects",
".",
"requireNonNull",
"(",
"inputStream",
",",
"\"inputStream cannot be null\"",
")",
";",
"return",
"fromEdgeRc",
"(",
"new",
"InputStreamReader",
"(",
"inputStream",
")",
",",
"section",
")",
";",
"}"
] | Loads an EdgeRc configuration file and returns an {@link EdgeRcClientCredentialProvider} to
read {@link ClientCredential}s from it.
@param inputStream an open {@link InputStream} to an EdgeRc file
@param section a config section ({@code null} for the default section)
@return a {@link EdgeRcClientCredentialProvider}
@throws ConfigurationException If an error occurs while reading the configuration
@throws IOException if an I/O error occurs | [
"Loads",
"an",
"EdgeRc",
"configuration",
"file",
"and",
"returns",
"an",
"{",
"@link",
"EdgeRcClientCredentialProvider",
"}",
"to",
"read",
"{",
"@link",
"ClientCredential",
"}",
"s",
"from",
"it",
"."
] | train | https://github.com/akamai/AkamaiOPEN-edgegrid-java/blob/29aa39f0f70f62503e6a434c4470ee25cb640f58/edgerc-reader/src/main/java/com/akamai/edgegrid/signer/EdgeRcClientCredentialProvider.java#L78-L82 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/document/json/JsonObject.java | JsonObject.getAndDecryptObject | public JsonObject getAndDecryptObject(String name, String providerName) throws Exception {
"""
Retrieves the decrypted value from the field name and casts it to {@link JsonObject}.
Note: Use of the Field Level Encryption functionality provided in the
com.couchbase.client.encryption namespace provided by Couchbase is
subject to the Couchbase Inc. Enterprise Subscription License Agreement
at https://www.couchbase.com/ESLA-11132015.
@param name the name of the field.
@param providerName Crypto provider name for decryption
@return the result or null if it does not exist.
"""
return (JsonObject) getAndDecrypt(name, providerName);
} | java | public JsonObject getAndDecryptObject(String name, String providerName) throws Exception {
return (JsonObject) getAndDecrypt(name, providerName);
} | [
"public",
"JsonObject",
"getAndDecryptObject",
"(",
"String",
"name",
",",
"String",
"providerName",
")",
"throws",
"Exception",
"{",
"return",
"(",
"JsonObject",
")",
"getAndDecrypt",
"(",
"name",
",",
"providerName",
")",
";",
"}"
] | Retrieves the decrypted value from the field name and casts it to {@link JsonObject}.
Note: Use of the Field Level Encryption functionality provided in the
com.couchbase.client.encryption namespace provided by Couchbase is
subject to the Couchbase Inc. Enterprise Subscription License Agreement
at https://www.couchbase.com/ESLA-11132015.
@param name the name of the field.
@param providerName Crypto provider name for decryption
@return the result or null if it does not exist. | [
"Retrieves",
"the",
"decrypted",
"value",
"from",
"the",
"field",
"name",
"and",
"casts",
"it",
"to",
"{",
"@link",
"JsonObject",
"}",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/document/json/JsonObject.java#L769-L771 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/utils/MpJwtAppSetupUtils.java | MpJwtAppSetupUtils.genericCreateArchiveWithPems | protected WebArchive genericCreateArchiveWithPems(String sourceWarName, String baseWarName, List<String> classList) throws Exception {
"""
Create a test war using files from the source war and the classList. Add a default list of pem files
@param sourceWarName - the source war to get xml files from
@param baseWarName - the base name of the war file to create
@param classList - the list of classes to add to the war
@return - return a war built from the specified built class files, xml's and pem files
@throws Exception
"""
try {
String warName = baseWarName + ".war";
WebArchive newWar = ShrinkWrap.create(WebArchive.class, warName);
addDefaultFileAssetsForAppsToWar(sourceWarName, newWar);
addPemFilesForAppsToWar(warName, newWar);
for (String theClass : classList) {
newWar.addClass(theClass);
}
return newWar;
} catch (Exception e) {
Log.error(thisClass, "genericCreateArchive", e);
throw e;
}
} | java | protected WebArchive genericCreateArchiveWithPems(String sourceWarName, String baseWarName, List<String> classList) throws Exception {
try {
String warName = baseWarName + ".war";
WebArchive newWar = ShrinkWrap.create(WebArchive.class, warName);
addDefaultFileAssetsForAppsToWar(sourceWarName, newWar);
addPemFilesForAppsToWar(warName, newWar);
for (String theClass : classList) {
newWar.addClass(theClass);
}
return newWar;
} catch (Exception e) {
Log.error(thisClass, "genericCreateArchive", e);
throw e;
}
} | [
"protected",
"WebArchive",
"genericCreateArchiveWithPems",
"(",
"String",
"sourceWarName",
",",
"String",
"baseWarName",
",",
"List",
"<",
"String",
">",
"classList",
")",
"throws",
"Exception",
"{",
"try",
"{",
"String",
"warName",
"=",
"baseWarName",
"+",
"\".war\"",
";",
"WebArchive",
"newWar",
"=",
"ShrinkWrap",
".",
"create",
"(",
"WebArchive",
".",
"class",
",",
"warName",
")",
";",
"addDefaultFileAssetsForAppsToWar",
"(",
"sourceWarName",
",",
"newWar",
")",
";",
"addPemFilesForAppsToWar",
"(",
"warName",
",",
"newWar",
")",
";",
"for",
"(",
"String",
"theClass",
":",
"classList",
")",
"{",
"newWar",
".",
"addClass",
"(",
"theClass",
")",
";",
"}",
"return",
"newWar",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"error",
"(",
"thisClass",
",",
"\"genericCreateArchive\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | Create a test war using files from the source war and the classList. Add a default list of pem files
@param sourceWarName - the source war to get xml files from
@param baseWarName - the base name of the war file to create
@param classList - the list of classes to add to the war
@return - return a war built from the specified built class files, xml's and pem files
@throws Exception | [
"Create",
"a",
"test",
"war",
"using",
"files",
"from",
"the",
"source",
"war",
"and",
"the",
"classList",
".",
"Add",
"a",
"default",
"list",
"of",
"pem",
"files"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/utils/MpJwtAppSetupUtils.java#L176-L190 |
segmentio/analytics-android | analytics/src/main/java/com/segment/analytics/ValueMap.java | ValueMap.getDouble | public double getDouble(String key, double defaultValue) {
"""
Returns the value mapped by {@code key} if it exists and is a double or can be coerced to a
double. Returns {@code defaultValue} otherwise.
"""
Object value = get(key);
if (value instanceof Double) {
return (double) value;
}
if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof String) {
try {
return Double.valueOf((String) value);
} catch (NumberFormatException ignored) {
}
}
return defaultValue;
} | java | public double getDouble(String key, double defaultValue) {
Object value = get(key);
if (value instanceof Double) {
return (double) value;
}
if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof String) {
try {
return Double.valueOf((String) value);
} catch (NumberFormatException ignored) {
}
}
return defaultValue;
} | [
"public",
"double",
"getDouble",
"(",
"String",
"key",
",",
"double",
"defaultValue",
")",
"{",
"Object",
"value",
"=",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"instanceof",
"Double",
")",
"{",
"return",
"(",
"double",
")",
"value",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"value",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"try",
"{",
"return",
"Double",
".",
"valueOf",
"(",
"(",
"String",
")",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"ignored",
")",
"{",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] | Returns the value mapped by {@code key} if it exists and is a double or can be coerced to a
double. Returns {@code defaultValue} otherwise. | [
"Returns",
"the",
"value",
"mapped",
"by",
"{"
] | train | https://github.com/segmentio/analytics-android/blob/93c7d5bb09b593440a2347a6089db3e9f74012da/analytics/src/main/java/com/segment/analytics/ValueMap.java#L224-L238 |
Whiley/WhileyCompiler | src/main/java/wyil/check/FlowTypeCheck.java | FlowTypeCheck.checkAssign | private Environment checkAssign(Stmt.Assign stmt, Environment environment, EnclosingScope scope)
throws IOException {
"""
Type check an assignment statement.
@param stmt
Statement to type check
@param environment
Determines the type of all variables immediately going into this
block
@return
"""
Tuple<LVal> lvals = stmt.getLeftHandSide();
Type[] types = new Type[lvals.size()];
for (int i = 0; i != lvals.size(); ++i) {
types[i] = checkLVal(lvals.get(i), environment);
}
checkMultiExpressions(stmt.getRightHandSide(), environment, new Tuple<>(types));
return environment;
} | java | private Environment checkAssign(Stmt.Assign stmt, Environment environment, EnclosingScope scope)
throws IOException {
Tuple<LVal> lvals = stmt.getLeftHandSide();
Type[] types = new Type[lvals.size()];
for (int i = 0; i != lvals.size(); ++i) {
types[i] = checkLVal(lvals.get(i), environment);
}
checkMultiExpressions(stmt.getRightHandSide(), environment, new Tuple<>(types));
return environment;
} | [
"private",
"Environment",
"checkAssign",
"(",
"Stmt",
".",
"Assign",
"stmt",
",",
"Environment",
"environment",
",",
"EnclosingScope",
"scope",
")",
"throws",
"IOException",
"{",
"Tuple",
"<",
"LVal",
">",
"lvals",
"=",
"stmt",
".",
"getLeftHandSide",
"(",
")",
";",
"Type",
"[",
"]",
"types",
"=",
"new",
"Type",
"[",
"lvals",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"!=",
"lvals",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"types",
"[",
"i",
"]",
"=",
"checkLVal",
"(",
"lvals",
".",
"get",
"(",
"i",
")",
",",
"environment",
")",
";",
"}",
"checkMultiExpressions",
"(",
"stmt",
".",
"getRightHandSide",
"(",
")",
",",
"environment",
",",
"new",
"Tuple",
"<>",
"(",
"types",
")",
")",
";",
"return",
"environment",
";",
"}"
] | Type check an assignment statement.
@param stmt
Statement to type check
@param environment
Determines the type of all variables immediately going into this
block
@return | [
"Type",
"check",
"an",
"assignment",
"statement",
"."
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeCheck.java#L441-L450 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalExtractGeometries.java | TrifocalExtractGeometries.extractEpipoles | public void extractEpipoles( Point3D_F64 e2 , Point3D_F64 e3 ) {
"""
Extracts the epipoles from the trifocal tensor. Extracted epipoles will have a norm of 1
as an artifact of using SVD.
@param e2 Output: Epipole in image 2. Homogeneous coordinates. Modified
@param e3 Output: Epipole in image 3. Homogeneous coordinates. Modified
"""
e2.set(this.e2);
e3.set(this.e3);
} | java | public void extractEpipoles( Point3D_F64 e2 , Point3D_F64 e3 ) {
e2.set(this.e2);
e3.set(this.e3);
} | [
"public",
"void",
"extractEpipoles",
"(",
"Point3D_F64",
"e2",
",",
"Point3D_F64",
"e3",
")",
"{",
"e2",
".",
"set",
"(",
"this",
".",
"e2",
")",
";",
"e3",
".",
"set",
"(",
"this",
".",
"e3",
")",
";",
"}"
] | Extracts the epipoles from the trifocal tensor. Extracted epipoles will have a norm of 1
as an artifact of using SVD.
@param e2 Output: Epipole in image 2. Homogeneous coordinates. Modified
@param e3 Output: Epipole in image 3. Homogeneous coordinates. Modified | [
"Extracts",
"the",
"epipoles",
"from",
"the",
"trifocal",
"tensor",
".",
"Extracted",
"epipoles",
"will",
"have",
"a",
"norm",
"of",
"1",
"as",
"an",
"artifact",
"of",
"using",
"SVD",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalExtractGeometries.java#L144-L147 |
undertow-io/undertow | core/src/main/java/io/undertow/util/DateUtils.java | DateUtils.handleIfUnmodifiedSince | public static boolean handleIfUnmodifiedSince(final HttpServerExchange exchange, final Date lastModified) {
"""
Handles the if-unmodified-since header. returns true if the request should proceed, false otherwise
@param exchange the exchange
@param lastModified The last modified date
@return
"""
return handleIfUnmodifiedSince(exchange.getRequestHeaders().getFirst(Headers.IF_UNMODIFIED_SINCE), lastModified);
} | java | public static boolean handleIfUnmodifiedSince(final HttpServerExchange exchange, final Date lastModified) {
return handleIfUnmodifiedSince(exchange.getRequestHeaders().getFirst(Headers.IF_UNMODIFIED_SINCE), lastModified);
} | [
"public",
"static",
"boolean",
"handleIfUnmodifiedSince",
"(",
"final",
"HttpServerExchange",
"exchange",
",",
"final",
"Date",
"lastModified",
")",
"{",
"return",
"handleIfUnmodifiedSince",
"(",
"exchange",
".",
"getRequestHeaders",
"(",
")",
".",
"getFirst",
"(",
"Headers",
".",
"IF_UNMODIFIED_SINCE",
")",
",",
"lastModified",
")",
";",
"}"
] | Handles the if-unmodified-since header. returns true if the request should proceed, false otherwise
@param exchange the exchange
@param lastModified The last modified date
@return | [
"Handles",
"the",
"if",
"-",
"unmodified",
"-",
"since",
"header",
".",
"returns",
"true",
"if",
"the",
"request",
"should",
"proceed",
"false",
"otherwise"
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/util/DateUtils.java#L212-L214 |
infinispan/infinispan | core/src/main/java/org/infinispan/registry/impl/InternalCacheRegistryImpl.java | InternalCacheRegistryImpl.registerInternalCache | @Override
public synchronized void registerInternalCache(String name, Configuration configuration, EnumSet<Flag> flags) {
"""
Synchronized to prevent users from registering the same configuration at the same time
"""
boolean configPresent = cacheManager.getCacheConfiguration(name) != null;
// check if it already has been defined. Currently we don't support existing user-defined configuration.
if ((flags.contains(Flag.EXCLUSIVE) || !internalCaches.containsKey(name)) && configPresent) {
throw log.existingConfigForInternalCache(name);
}
// Don't redefine
if (configPresent) {
return;
}
ConfigurationBuilder builder = new ConfigurationBuilder().read(configuration);
builder.jmxStatistics().disable(); // Internal caches must not be included in stats counts
GlobalConfiguration globalConfiguration = cacheManager.getCacheManagerConfiguration();
if (flags.contains(Flag.GLOBAL) && globalConfiguration.isClustered()) {
// TODO: choose a merge policy
builder.clustering()
.cacheMode(CacheMode.REPL_SYNC)
.stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(true);
}
if (flags.contains(Flag.PERSISTENT) && globalConfiguration.globalState().enabled()) {
builder.persistence().addSingleFileStore().location(globalConfiguration.globalState().persistentLocation()).purgeOnStartup(false).preload(true).fetchPersistentState(true);
}
SecurityActions.defineConfiguration(cacheManager, name, builder.build());
internalCaches.put(name, flags);
if (!flags.contains(Flag.USER)) {
privateCaches.add(name);
}
} | java | @Override
public synchronized void registerInternalCache(String name, Configuration configuration, EnumSet<Flag> flags) {
boolean configPresent = cacheManager.getCacheConfiguration(name) != null;
// check if it already has been defined. Currently we don't support existing user-defined configuration.
if ((flags.contains(Flag.EXCLUSIVE) || !internalCaches.containsKey(name)) && configPresent) {
throw log.existingConfigForInternalCache(name);
}
// Don't redefine
if (configPresent) {
return;
}
ConfigurationBuilder builder = new ConfigurationBuilder().read(configuration);
builder.jmxStatistics().disable(); // Internal caches must not be included in stats counts
GlobalConfiguration globalConfiguration = cacheManager.getCacheManagerConfiguration();
if (flags.contains(Flag.GLOBAL) && globalConfiguration.isClustered()) {
// TODO: choose a merge policy
builder.clustering()
.cacheMode(CacheMode.REPL_SYNC)
.stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(true);
}
if (flags.contains(Flag.PERSISTENT) && globalConfiguration.globalState().enabled()) {
builder.persistence().addSingleFileStore().location(globalConfiguration.globalState().persistentLocation()).purgeOnStartup(false).preload(true).fetchPersistentState(true);
}
SecurityActions.defineConfiguration(cacheManager, name, builder.build());
internalCaches.put(name, flags);
if (!flags.contains(Flag.USER)) {
privateCaches.add(name);
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"registerInternalCache",
"(",
"String",
"name",
",",
"Configuration",
"configuration",
",",
"EnumSet",
"<",
"Flag",
">",
"flags",
")",
"{",
"boolean",
"configPresent",
"=",
"cacheManager",
".",
"getCacheConfiguration",
"(",
"name",
")",
"!=",
"null",
";",
"// check if it already has been defined. Currently we don't support existing user-defined configuration.",
"if",
"(",
"(",
"flags",
".",
"contains",
"(",
"Flag",
".",
"EXCLUSIVE",
")",
"||",
"!",
"internalCaches",
".",
"containsKey",
"(",
"name",
")",
")",
"&&",
"configPresent",
")",
"{",
"throw",
"log",
".",
"existingConfigForInternalCache",
"(",
"name",
")",
";",
"}",
"// Don't redefine",
"if",
"(",
"configPresent",
")",
"{",
"return",
";",
"}",
"ConfigurationBuilder",
"builder",
"=",
"new",
"ConfigurationBuilder",
"(",
")",
".",
"read",
"(",
"configuration",
")",
";",
"builder",
".",
"jmxStatistics",
"(",
")",
".",
"disable",
"(",
")",
";",
"// Internal caches must not be included in stats counts",
"GlobalConfiguration",
"globalConfiguration",
"=",
"cacheManager",
".",
"getCacheManagerConfiguration",
"(",
")",
";",
"if",
"(",
"flags",
".",
"contains",
"(",
"Flag",
".",
"GLOBAL",
")",
"&&",
"globalConfiguration",
".",
"isClustered",
"(",
")",
")",
"{",
"// TODO: choose a merge policy",
"builder",
".",
"clustering",
"(",
")",
".",
"cacheMode",
"(",
"CacheMode",
".",
"REPL_SYNC",
")",
".",
"stateTransfer",
"(",
")",
".",
"fetchInMemoryState",
"(",
"true",
")",
".",
"awaitInitialTransfer",
"(",
"true",
")",
";",
"}",
"if",
"(",
"flags",
".",
"contains",
"(",
"Flag",
".",
"PERSISTENT",
")",
"&&",
"globalConfiguration",
".",
"globalState",
"(",
")",
".",
"enabled",
"(",
")",
")",
"{",
"builder",
".",
"persistence",
"(",
")",
".",
"addSingleFileStore",
"(",
")",
".",
"location",
"(",
"globalConfiguration",
".",
"globalState",
"(",
")",
".",
"persistentLocation",
"(",
")",
")",
".",
"purgeOnStartup",
"(",
"false",
")",
".",
"preload",
"(",
"true",
")",
".",
"fetchPersistentState",
"(",
"true",
")",
";",
"}",
"SecurityActions",
".",
"defineConfiguration",
"(",
"cacheManager",
",",
"name",
",",
"builder",
".",
"build",
"(",
")",
")",
";",
"internalCaches",
".",
"put",
"(",
"name",
",",
"flags",
")",
";",
"if",
"(",
"!",
"flags",
".",
"contains",
"(",
"Flag",
".",
"USER",
")",
")",
"{",
"privateCaches",
".",
"add",
"(",
"name",
")",
";",
"}",
"}"
] | Synchronized to prevent users from registering the same configuration at the same time | [
"Synchronized",
"to",
"prevent",
"users",
"from",
"registering",
"the",
"same",
"configuration",
"at",
"the",
"same",
"time"
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/registry/impl/InternalCacheRegistryImpl.java#L40-L68 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowStack.java | PageFlowStack.popUntil | PageFlowController popUntil( HttpServletRequest request, Class stopAt, boolean onlyIfPresent ) {
"""
Pop page flows from the nesting stack until one of the given type is found.
@return the last popped page flow if one of the given type was found, or <code>null</code>
if none was found.
"""
if (onlyIfPresent && lastIndexOf(stopAt) == -1) {
return null;
}
while ( ! isEmpty() )
{
PageFlowController popped = pop( request ).getPageFlow();
if ( popped.getClass().equals( stopAt ) )
{
//
// If we've popped everything from the stack, remove the stack attribute from the session.
//
if ( isEmpty() ) destroy( request );
return popped;
}
else
{
//
// We're discarding the popped page flow. Invoke its destroy() callback, unless it's longLived.
//
if ( ! popped.isLongLived() ) popped.destroy( request.getSession( false ) );
}
}
destroy( request ); // we're empty -- remove the attribute from the session.
return null;
} | java | PageFlowController popUntil( HttpServletRequest request, Class stopAt, boolean onlyIfPresent )
{
if (onlyIfPresent && lastIndexOf(stopAt) == -1) {
return null;
}
while ( ! isEmpty() )
{
PageFlowController popped = pop( request ).getPageFlow();
if ( popped.getClass().equals( stopAt ) )
{
//
// If we've popped everything from the stack, remove the stack attribute from the session.
//
if ( isEmpty() ) destroy( request );
return popped;
}
else
{
//
// We're discarding the popped page flow. Invoke its destroy() callback, unless it's longLived.
//
if ( ! popped.isLongLived() ) popped.destroy( request.getSession( false ) );
}
}
destroy( request ); // we're empty -- remove the attribute from the session.
return null;
} | [
"PageFlowController",
"popUntil",
"(",
"HttpServletRequest",
"request",
",",
"Class",
"stopAt",
",",
"boolean",
"onlyIfPresent",
")",
"{",
"if",
"(",
"onlyIfPresent",
"&&",
"lastIndexOf",
"(",
"stopAt",
")",
"==",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"while",
"(",
"!",
"isEmpty",
"(",
")",
")",
"{",
"PageFlowController",
"popped",
"=",
"pop",
"(",
"request",
")",
".",
"getPageFlow",
"(",
")",
";",
"if",
"(",
"popped",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"stopAt",
")",
")",
"{",
"//",
"// If we've popped everything from the stack, remove the stack attribute from the session.",
"//",
"if",
"(",
"isEmpty",
"(",
")",
")",
"destroy",
"(",
"request",
")",
";",
"return",
"popped",
";",
"}",
"else",
"{",
"//",
"// We're discarding the popped page flow. Invoke its destroy() callback, unless it's longLived.",
"//",
"if",
"(",
"!",
"popped",
".",
"isLongLived",
"(",
")",
")",
"popped",
".",
"destroy",
"(",
"request",
".",
"getSession",
"(",
"false",
")",
")",
";",
"}",
"}",
"destroy",
"(",
"request",
")",
";",
"// we're empty -- remove the attribute from the session.",
"return",
"null",
";",
"}"
] | Pop page flows from the nesting stack until one of the given type is found.
@return the last popped page flow if one of the given type was found, or <code>null</code>
if none was found. | [
"Pop",
"page",
"flows",
"from",
"the",
"nesting",
"stack",
"until",
"one",
"of",
"the",
"given",
"type",
"is",
"found",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowStack.java#L200-L229 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/httppanel/view/util/HttpTextViewUtils.java | HttpTextViewUtils.validateStartEnd | private static void validateStartEnd(int start, int end) {
"""
Validates the given {@code start} and {@code end} positions.
@param start the start position to be validated
@param end the end position to be validated
@throws IllegalArgumentException if any of the conditions is true:
<ul>
<li>the {@code start} position is negative;</li>
<li>the {@code end} position is negative;</li>
<li>the {@code start} position is greater than the {@code end} position.</li>
</ul>
"""
if (start < 0) {
throw new IllegalArgumentException("Parameter start must not be negative.");
}
if (end < 0) {
throw new IllegalArgumentException("Parameter end must not be negative.");
}
if (start > end) {
throw new IllegalArgumentException("Parameter start must not be greater than end.");
}
} | java | private static void validateStartEnd(int start, int end) {
if (start < 0) {
throw new IllegalArgumentException("Parameter start must not be negative.");
}
if (end < 0) {
throw new IllegalArgumentException("Parameter end must not be negative.");
}
if (start > end) {
throw new IllegalArgumentException("Parameter start must not be greater than end.");
}
} | [
"private",
"static",
"void",
"validateStartEnd",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter start must not be negative.\"",
")",
";",
"}",
"if",
"(",
"end",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter end must not be negative.\"",
")",
";",
"}",
"if",
"(",
"start",
">",
"end",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter start must not be greater than end.\"",
")",
";",
"}",
"}"
] | Validates the given {@code start} and {@code end} positions.
@param start the start position to be validated
@param end the end position to be validated
@throws IllegalArgumentException if any of the conditions is true:
<ul>
<li>the {@code start} position is negative;</li>
<li>the {@code end} position is negative;</li>
<li>the {@code start} position is greater than the {@code end} position.</li>
</ul> | [
"Validates",
"the",
"given",
"{",
"@code",
"start",
"}",
"and",
"{",
"@code",
"end",
"}",
"positions",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/httppanel/view/util/HttpTextViewUtils.java#L145-L155 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/resource/ResourceUtil.java | ResourceUtil.getReader | public static BufferedReader getReader(String resurce, Charset charset) {
"""
从ClassPath资源中获取{@link BufferedReader}
@param resurce ClassPath资源
@param charset 编码
@return {@link InputStream}
@since 3.1.2
"""
return getResourceObj(resurce).getReader(charset);
} | java | public static BufferedReader getReader(String resurce, Charset charset) {
return getResourceObj(resurce).getReader(charset);
} | [
"public",
"static",
"BufferedReader",
"getReader",
"(",
"String",
"resurce",
",",
"Charset",
"charset",
")",
"{",
"return",
"getResourceObj",
"(",
"resurce",
")",
".",
"getReader",
"(",
"charset",
")",
";",
"}"
] | 从ClassPath资源中获取{@link BufferedReader}
@param resurce ClassPath资源
@param charset 编码
@return {@link InputStream}
@since 3.1.2 | [
"从ClassPath资源中获取",
"{",
"@link",
"BufferedReader",
"}"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/resource/ResourceUtil.java#L87-L89 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.createOrUpdateMultiRolePoolAsync | public Observable<WorkerPoolResourceInner> createOrUpdateMultiRolePoolAsync(String resourceGroupName, String name, WorkerPoolResourceInner multiRolePoolEnvelope) {
"""
Create or update a multi-role pool.
Create or update a multi-role pool.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param multiRolePoolEnvelope Properties of the multi-role pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateMultiRolePoolWithServiceResponseAsync(resourceGroupName, name, multiRolePoolEnvelope).map(new Func1<ServiceResponse<WorkerPoolResourceInner>, WorkerPoolResourceInner>() {
@Override
public WorkerPoolResourceInner call(ServiceResponse<WorkerPoolResourceInner> response) {
return response.body();
}
});
} | java | public Observable<WorkerPoolResourceInner> createOrUpdateMultiRolePoolAsync(String resourceGroupName, String name, WorkerPoolResourceInner multiRolePoolEnvelope) {
return createOrUpdateMultiRolePoolWithServiceResponseAsync(resourceGroupName, name, multiRolePoolEnvelope).map(new Func1<ServiceResponse<WorkerPoolResourceInner>, WorkerPoolResourceInner>() {
@Override
public WorkerPoolResourceInner call(ServiceResponse<WorkerPoolResourceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"WorkerPoolResourceInner",
">",
"createOrUpdateMultiRolePoolAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
",",
"WorkerPoolResourceInner",
"multiRolePoolEnvelope",
")",
"{",
"return",
"createOrUpdateMultiRolePoolWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"multiRolePoolEnvelope",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"WorkerPoolResourceInner",
">",
",",
"WorkerPoolResourceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WorkerPoolResourceInner",
"call",
"(",
"ServiceResponse",
"<",
"WorkerPoolResourceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create or update a multi-role pool.
Create or update a multi-role pool.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param multiRolePoolEnvelope Properties of the multi-role pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Create",
"or",
"update",
"a",
"multi",
"-",
"role",
"pool",
".",
"Create",
"or",
"update",
"a",
"multi",
"-",
"role",
"pool",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L2302-L2309 |
Azure/azure-sdk-for-java | policy/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/policy/v2018_03_01/implementation/PolicySetDefinitionsInner.java | PolicySetDefinitionsInner.deleteAtManagementGroup | public void deleteAtManagementGroup(String policySetDefinitionName, String managementGroupId) {
"""
Deletes a policy set definition.
This operation deletes the policy set definition in the given management group with the given name.
@param policySetDefinitionName The name of the policy set definition to delete.
@param managementGroupId The ID of the management group.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
deleteAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId).toBlocking().single().body();
} | java | public void deleteAtManagementGroup(String policySetDefinitionName, String managementGroupId) {
deleteAtManagementGroupWithServiceResponseAsync(policySetDefinitionName, managementGroupId).toBlocking().single().body();
} | [
"public",
"void",
"deleteAtManagementGroup",
"(",
"String",
"policySetDefinitionName",
",",
"String",
"managementGroupId",
")",
"{",
"deleteAtManagementGroupWithServiceResponseAsync",
"(",
"policySetDefinitionName",
",",
"managementGroupId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes a policy set definition.
This operation deletes the policy set definition in the given management group with the given name.
@param policySetDefinitionName The name of the policy set definition to delete.
@param managementGroupId The ID of the management group.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Deletes",
"a",
"policy",
"set",
"definition",
".",
"This",
"operation",
"deletes",
"the",
"policy",
"set",
"definition",
"in",
"the",
"given",
"management",
"group",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policy/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/policy/v2018_03_01/implementation/PolicySetDefinitionsInner.java#L783-L785 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/copy/CopyManager.java | CopyManager.copyIn | public long copyIn(final String sql, Reader from) throws SQLException, IOException {
"""
Use COPY FROM STDIN for very fast copying from a Reader into a database table.
@param sql COPY FROM STDIN statement
@param from a CSV file or such
@return number of rows updated for server 8.2 or newer; -1 for older
@throws SQLException on database usage issues
@throws IOException upon reader or database connection failure
"""
return copyIn(sql, from, DEFAULT_BUFFER_SIZE);
} | java | public long copyIn(final String sql, Reader from) throws SQLException, IOException {
return copyIn(sql, from, DEFAULT_BUFFER_SIZE);
} | [
"public",
"long",
"copyIn",
"(",
"final",
"String",
"sql",
",",
"Reader",
"from",
")",
"throws",
"SQLException",
",",
"IOException",
"{",
"return",
"copyIn",
"(",
"sql",
",",
"from",
",",
"DEFAULT_BUFFER_SIZE",
")",
";",
"}"
] | Use COPY FROM STDIN for very fast copying from a Reader into a database table.
@param sql COPY FROM STDIN statement
@param from a CSV file or such
@return number of rows updated for server 8.2 or newer; -1 for older
@throws SQLException on database usage issues
@throws IOException upon reader or database connection failure | [
"Use",
"COPY",
"FROM",
"STDIN",
"for",
"very",
"fast",
"copying",
"from",
"a",
"Reader",
"into",
"a",
"database",
"table",
"."
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/copy/CopyManager.java#L155-L157 |
js-lib-com/commons | src/main/java/js/util/Files.java | Files.renameTo | public static void renameTo(File source, File destination) throws IOException {
"""
Thin wrapper for {@link File#renameTo(File)} throwing exception on fail. This method ensures destination file
parent directories exist. If destination file already exist its content is silently overwritten.
<p>
Warning: if destination file exists, it is overwritten and its old content lost.
@param source source file,
@param destination destination file.
@throws IOException if rename operation fails.
"""
mkdirs(destination);
// excerpt from File.renameTo API:
// ... and it (n.b. File.renameTo) might not succeed if a file with the destination abstract pathname already exists
//
// so ensure destination does not exist
destination.delete();
if(!source.renameTo(destination)) {
throw new IOException(String.format("Fail to rename file |%s| to |%s|.", source, destination));
}
} | java | public static void renameTo(File source, File destination) throws IOException
{
mkdirs(destination);
// excerpt from File.renameTo API:
// ... and it (n.b. File.renameTo) might not succeed if a file with the destination abstract pathname already exists
//
// so ensure destination does not exist
destination.delete();
if(!source.renameTo(destination)) {
throw new IOException(String.format("Fail to rename file |%s| to |%s|.", source, destination));
}
} | [
"public",
"static",
"void",
"renameTo",
"(",
"File",
"source",
",",
"File",
"destination",
")",
"throws",
"IOException",
"{",
"mkdirs",
"(",
"destination",
")",
";",
"// excerpt from File.renameTo API:\r",
"// ... and it (n.b. File.renameTo) might not succeed if a file with the destination abstract pathname already exists\r",
"//\r",
"// so ensure destination does not exist\r",
"destination",
".",
"delete",
"(",
")",
";",
"if",
"(",
"!",
"source",
".",
"renameTo",
"(",
"destination",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"Fail to rename file |%s| to |%s|.\"",
",",
"source",
",",
"destination",
")",
")",
";",
"}",
"}"
] | Thin wrapper for {@link File#renameTo(File)} throwing exception on fail. This method ensures destination file
parent directories exist. If destination file already exist its content is silently overwritten.
<p>
Warning: if destination file exists, it is overwritten and its old content lost.
@param source source file,
@param destination destination file.
@throws IOException if rename operation fails. | [
"Thin",
"wrapper",
"for",
"{",
"@link",
"File#renameTo",
"(",
"File",
")",
"}",
"throwing",
"exception",
"on",
"fail",
".",
"This",
"method",
"ensures",
"destination",
"file",
"parent",
"directories",
"exist",
".",
"If",
"destination",
"file",
"already",
"exist",
"its",
"content",
"is",
"silently",
"overwritten",
".",
"<p",
">",
"Warning",
":",
"if",
"destination",
"file",
"exists",
"it",
"is",
"overwritten",
"and",
"its",
"old",
"content",
"lost",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Files.java#L492-L505 |
joinfaces/joinfaces | joinfaces-tools/joinfaces-scan-tools/src/main/java/org/joinfaces/tools/ScanResultHandler.java | ScanResultHandler.writeClassMap | protected void writeClassMap(File file, Map<String, ? extends Collection<String>> classMap) throws IOException {
"""
Helper method which writes a map of class names to the given file.
@param file The target file in which the class names should be written.
@param classMap The class names which should be written in the target file.
@throws IOException when the class names could not be written to the target file.
"""
File baseDir = file.getParentFile();
if (baseDir.isDirectory() || baseDir.mkdirs()) {
//noinspection CharsetObjectCanBeUsed
try (PrintWriter printWriter = new PrintWriter(file, "UTF-8")) {
classMap.forEach((key, value) -> {
printWriter.print(key);
printWriter.print("=");
printWriter.println(String.join(",", value));
});
}
}
else {
throw new IOException(baseDir + " does not exist and could not be created");
}
} | java | protected void writeClassMap(File file, Map<String, ? extends Collection<String>> classMap) throws IOException {
File baseDir = file.getParentFile();
if (baseDir.isDirectory() || baseDir.mkdirs()) {
//noinspection CharsetObjectCanBeUsed
try (PrintWriter printWriter = new PrintWriter(file, "UTF-8")) {
classMap.forEach((key, value) -> {
printWriter.print(key);
printWriter.print("=");
printWriter.println(String.join(",", value));
});
}
}
else {
throw new IOException(baseDir + " does not exist and could not be created");
}
} | [
"protected",
"void",
"writeClassMap",
"(",
"File",
"file",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Collection",
"<",
"String",
">",
">",
"classMap",
")",
"throws",
"IOException",
"{",
"File",
"baseDir",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"baseDir",
".",
"isDirectory",
"(",
")",
"||",
"baseDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"//noinspection CharsetObjectCanBeUsed",
"try",
"(",
"PrintWriter",
"printWriter",
"=",
"new",
"PrintWriter",
"(",
"file",
",",
"\"UTF-8\"",
")",
")",
"{",
"classMap",
".",
"forEach",
"(",
"(",
"key",
",",
"value",
")",
"->",
"{",
"printWriter",
".",
"print",
"(",
"key",
")",
";",
"printWriter",
".",
"print",
"(",
"\"=\"",
")",
";",
"printWriter",
".",
"println",
"(",
"String",
".",
"join",
"(",
"\",\"",
",",
"value",
")",
")",
";",
"}",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IOException",
"(",
"baseDir",
"+",
"\" does not exist and could not be created\"",
")",
";",
"}",
"}"
] | Helper method which writes a map of class names to the given file.
@param file The target file in which the class names should be written.
@param classMap The class names which should be written in the target file.
@throws IOException when the class names could not be written to the target file. | [
"Helper",
"method",
"which",
"writes",
"a",
"map",
"of",
"class",
"names",
"to",
"the",
"given",
"file",
"."
] | train | https://github.com/joinfaces/joinfaces/blob/c9fc811a9eaf695820951f2c04715297dd1e6d66/joinfaces-tools/joinfaces-scan-tools/src/main/java/org/joinfaces/tools/ScanResultHandler.java#L76-L93 |
cdk/cdk | storage/io/src/main/java/org/openscience/cdk/io/cml/CMLErrorHandler.java | CMLErrorHandler.print | private void print(String level, SAXParseException exception) {
"""
Internal procedure that outputs an SAXParseException with a significance level
to the cdk.tools.LoggingTool logger.
@param level significance level
@param exception Exception to output
"""
if (level.equals("warning")) {
logger.warn("** " + level + ": " + exception.getMessage());
logger.warn(" URI = " + exception.getSystemId());
logger.warn(" line = " + exception.getLineNumber());
} else {
logger.error("** " + level + ": " + exception.getMessage());
logger.error(" URI = " + exception.getSystemId());
logger.error(" line = " + exception.getLineNumber());
}
} | java | private void print(String level, SAXParseException exception) {
if (level.equals("warning")) {
logger.warn("** " + level + ": " + exception.getMessage());
logger.warn(" URI = " + exception.getSystemId());
logger.warn(" line = " + exception.getLineNumber());
} else {
logger.error("** " + level + ": " + exception.getMessage());
logger.error(" URI = " + exception.getSystemId());
logger.error(" line = " + exception.getLineNumber());
}
} | [
"private",
"void",
"print",
"(",
"String",
"level",
",",
"SAXParseException",
"exception",
")",
"{",
"if",
"(",
"level",
".",
"equals",
"(",
"\"warning\"",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"** \"",
"+",
"level",
"+",
"\": \"",
"+",
"exception",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"warn",
"(",
"\" URI = \"",
"+",
"exception",
".",
"getSystemId",
"(",
")",
")",
";",
"logger",
".",
"warn",
"(",
"\" line = \"",
"+",
"exception",
".",
"getLineNumber",
"(",
")",
")",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"** \"",
"+",
"level",
"+",
"\": \"",
"+",
"exception",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"error",
"(",
"\" URI = \"",
"+",
"exception",
".",
"getSystemId",
"(",
")",
")",
";",
"logger",
".",
"error",
"(",
"\" line = \"",
"+",
"exception",
".",
"getLineNumber",
"(",
")",
")",
";",
"}",
"}"
] | Internal procedure that outputs an SAXParseException with a significance level
to the cdk.tools.LoggingTool logger.
@param level significance level
@param exception Exception to output | [
"Internal",
"procedure",
"that",
"outputs",
"an",
"SAXParseException",
"with",
"a",
"significance",
"level",
"to",
"the",
"cdk",
".",
"tools",
".",
"LoggingTool",
"logger",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/storage/io/src/main/java/org/openscience/cdk/io/cml/CMLErrorHandler.java#L63-L73 |
spring-projects/spring-boot | spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java | MetadataGenerationEnvironment.getFieldDefaultValue | public Object getFieldDefaultValue(TypeElement type, String name) {
"""
Return the default value of the field with the specified {@code name}.
@param type the type to consider
@param name the name of the field
@return the default value or {@code null} if the field does not exist or no default
value has been detected
"""
return this.defaultValues.computeIfAbsent(type, this::resolveFieldValues)
.get(name);
} | java | public Object getFieldDefaultValue(TypeElement type, String name) {
return this.defaultValues.computeIfAbsent(type, this::resolveFieldValues)
.get(name);
} | [
"public",
"Object",
"getFieldDefaultValue",
"(",
"TypeElement",
"type",
",",
"String",
"name",
")",
"{",
"return",
"this",
".",
"defaultValues",
".",
"computeIfAbsent",
"(",
"type",
",",
"this",
"::",
"resolveFieldValues",
")",
".",
"get",
"(",
"name",
")",
";",
"}"
] | Return the default value of the field with the specified {@code name}.
@param type the type to consider
@param name the name of the field
@return the default value or {@code null} if the field does not exist or no default
value has been detected | [
"Return",
"the",
"default",
"value",
"of",
"the",
"field",
"with",
"the",
"specified",
"{"
] | train | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java#L136-L139 |
alkacon/opencms-core | src/org/opencms/cache/CmsVfsMemoryObjectCache.java | CmsVfsMemoryObjectCache.getCacheKeyForCurrentProject | private String getCacheKeyForCurrentProject(CmsObject cms, String rootPath) {
"""
Returns a cache key for the given root path based on the status
of the given CmsObject.<p>
@param cms the cms context
@param rootPath the filename to get the cache key for
@return the cache key for the system id
"""
// check the project
boolean project = (cms != null) ? cms.getRequestContext().getCurrentProject().isOnlineProject() : false;
return getCacheKey(rootPath, project);
} | java | private String getCacheKeyForCurrentProject(CmsObject cms, String rootPath) {
// check the project
boolean project = (cms != null) ? cms.getRequestContext().getCurrentProject().isOnlineProject() : false;
return getCacheKey(rootPath, project);
} | [
"private",
"String",
"getCacheKeyForCurrentProject",
"(",
"CmsObject",
"cms",
",",
"String",
"rootPath",
")",
"{",
"// check the project",
"boolean",
"project",
"=",
"(",
"cms",
"!=",
"null",
")",
"?",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
".",
"isOnlineProject",
"(",
")",
":",
"false",
";",
"return",
"getCacheKey",
"(",
"rootPath",
",",
"project",
")",
";",
"}"
] | Returns a cache key for the given root path based on the status
of the given CmsObject.<p>
@param cms the cms context
@param rootPath the filename to get the cache key for
@return the cache key for the system id | [
"Returns",
"a",
"cache",
"key",
"for",
"the",
"given",
"root",
"path",
"based",
"on",
"the",
"status",
"of",
"the",
"given",
"CmsObject",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/cache/CmsVfsMemoryObjectCache.java#L172-L177 |
apereo/cas | core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/CasVersion.java | CasVersion.getDateTime | @SneakyThrows
public static ZonedDateTime getDateTime() {
"""
Gets last modified date/time for the module.
@return the date/time
"""
val clazz = CasVersion.class;
val resource = clazz.getResource(clazz.getSimpleName() + ".class");
if ("file".equals(resource.getProtocol())) {
return DateTimeUtils.zonedDateTimeOf(new File(resource.toURI()).lastModified());
}
if ("jar".equals(resource.getProtocol())) {
val path = resource.getPath();
val file = new File(path.substring(JAR_PROTOCOL_STARTING_INDEX, path.indexOf('!')));
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
if ("vfs".equals(resource.getProtocol())) {
val file = new VfsResource(resource.openConnection().getContent()).getFile();
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
LOGGER.warn("Unhandled url protocol: [{}] resource: [{}]", resource.getProtocol(), resource);
return ZonedDateTime.now(ZoneOffset.UTC);
} | java | @SneakyThrows
public static ZonedDateTime getDateTime() {
val clazz = CasVersion.class;
val resource = clazz.getResource(clazz.getSimpleName() + ".class");
if ("file".equals(resource.getProtocol())) {
return DateTimeUtils.zonedDateTimeOf(new File(resource.toURI()).lastModified());
}
if ("jar".equals(resource.getProtocol())) {
val path = resource.getPath();
val file = new File(path.substring(JAR_PROTOCOL_STARTING_INDEX, path.indexOf('!')));
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
if ("vfs".equals(resource.getProtocol())) {
val file = new VfsResource(resource.openConnection().getContent()).getFile();
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
LOGGER.warn("Unhandled url protocol: [{}] resource: [{}]", resource.getProtocol(), resource);
return ZonedDateTime.now(ZoneOffset.UTC);
} | [
"@",
"SneakyThrows",
"public",
"static",
"ZonedDateTime",
"getDateTime",
"(",
")",
"{",
"val",
"clazz",
"=",
"CasVersion",
".",
"class",
";",
"val",
"resource",
"=",
"clazz",
".",
"getResource",
"(",
"clazz",
".",
"getSimpleName",
"(",
")",
"+",
"\".class\"",
")",
";",
"if",
"(",
"\"file\"",
".",
"equals",
"(",
"resource",
".",
"getProtocol",
"(",
")",
")",
")",
"{",
"return",
"DateTimeUtils",
".",
"zonedDateTimeOf",
"(",
"new",
"File",
"(",
"resource",
".",
"toURI",
"(",
")",
")",
".",
"lastModified",
"(",
")",
")",
";",
"}",
"if",
"(",
"\"jar\"",
".",
"equals",
"(",
"resource",
".",
"getProtocol",
"(",
")",
")",
")",
"{",
"val",
"path",
"=",
"resource",
".",
"getPath",
"(",
")",
";",
"val",
"file",
"=",
"new",
"File",
"(",
"path",
".",
"substring",
"(",
"JAR_PROTOCOL_STARTING_INDEX",
",",
"path",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
")",
";",
"return",
"DateTimeUtils",
".",
"zonedDateTimeOf",
"(",
"file",
".",
"lastModified",
"(",
")",
")",
";",
"}",
"if",
"(",
"\"vfs\"",
".",
"equals",
"(",
"resource",
".",
"getProtocol",
"(",
")",
")",
")",
"{",
"val",
"file",
"=",
"new",
"VfsResource",
"(",
"resource",
".",
"openConnection",
"(",
")",
".",
"getContent",
"(",
")",
")",
".",
"getFile",
"(",
")",
";",
"return",
"DateTimeUtils",
".",
"zonedDateTimeOf",
"(",
"file",
".",
"lastModified",
"(",
")",
")",
";",
"}",
"LOGGER",
".",
"warn",
"(",
"\"Unhandled url protocol: [{}] resource: [{}]\"",
",",
"resource",
".",
"getProtocol",
"(",
")",
",",
"resource",
")",
";",
"return",
"ZonedDateTime",
".",
"now",
"(",
"ZoneOffset",
".",
"UTC",
")",
";",
"}"
] | Gets last modified date/time for the module.
@return the date/time | [
"Gets",
"last",
"modified",
"date",
"/",
"time",
"for",
"the",
"module",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/CasVersion.java#L57-L75 |
ltearno/hexa.tools | hexa.core/src/main/java/fr/lteconsulting/hexa/client/form/FormManager.java | FormManager.addGroup | public Object addGroup( String display, String name, Object parent ) {
"""
/*
HashMap<FieldInfo,HTMLStream> fieldCommentsSlots = new HashMap<FieldInfo,
HTMLStream>(); public AcceptsOneWidget addCommentSlot( Object field ) {
FieldInfo info = (FieldInfo)field;
HTMLStream stream = fieldCommentsSlots.get( info ); if( stream == null )
{ stream = new HTMLStream(); fieldCommentsSlots.put( info, stream );
table.setWidget( info.row, 3, stream );
table.getCellFormatter().getElement( info.row, 3
).getStyle().setFontWeight( FontWeight.NORMAL ); }
SimplePanel slot = new SimplePanel(); stream.addLeft( slot );
return slot; }
"""
int row = display != null ? table.getRowCount() : -1;
// create the new group
GroupInfo parentInfo = (GroupInfo) parent;
GroupInfo info = new GroupInfo( name, parentInfo, row );
// display the new group
if( display != null && row >= 0 )
{
table.setHTML( row, 0, display );
table.getCellFormatter().getElement( row, 0 ).getStyle().setVerticalAlign( VerticalAlign.TOP );
table.getCellFormatter().getElement( row, 0 ).setAttribute( "colSpan", "2" );
table.getCellFormatter().getElement( row, 0 ).getStyle().setPaddingTop( 25, Unit.PX );
table.getCellFormatter().getElement( row, 0 ).getStyle().setPaddingBottom( 10, Unit.PX );
table.getCellFormatter().getElement( row, 0 ).getStyle().setFontWeight( FontWeight.BOLD );
}
return info;
} | java | public Object addGroup( String display, String name, Object parent )
{
int row = display != null ? table.getRowCount() : -1;
// create the new group
GroupInfo parentInfo = (GroupInfo) parent;
GroupInfo info = new GroupInfo( name, parentInfo, row );
// display the new group
if( display != null && row >= 0 )
{
table.setHTML( row, 0, display );
table.getCellFormatter().getElement( row, 0 ).getStyle().setVerticalAlign( VerticalAlign.TOP );
table.getCellFormatter().getElement( row, 0 ).setAttribute( "colSpan", "2" );
table.getCellFormatter().getElement( row, 0 ).getStyle().setPaddingTop( 25, Unit.PX );
table.getCellFormatter().getElement( row, 0 ).getStyle().setPaddingBottom( 10, Unit.PX );
table.getCellFormatter().getElement( row, 0 ).getStyle().setFontWeight( FontWeight.BOLD );
}
return info;
} | [
"public",
"Object",
"addGroup",
"(",
"String",
"display",
",",
"String",
"name",
",",
"Object",
"parent",
")",
"{",
"int",
"row",
"=",
"display",
"!=",
"null",
"?",
"table",
".",
"getRowCount",
"(",
")",
":",
"-",
"1",
";",
"// create the new group",
"GroupInfo",
"parentInfo",
"=",
"(",
"GroupInfo",
")",
"parent",
";",
"GroupInfo",
"info",
"=",
"new",
"GroupInfo",
"(",
"name",
",",
"parentInfo",
",",
"row",
")",
";",
"// display the new group",
"if",
"(",
"display",
"!=",
"null",
"&&",
"row",
">=",
"0",
")",
"{",
"table",
".",
"setHTML",
"(",
"row",
",",
"0",
",",
"display",
")",
";",
"table",
".",
"getCellFormatter",
"(",
")",
".",
"getElement",
"(",
"row",
",",
"0",
")",
".",
"getStyle",
"(",
")",
".",
"setVerticalAlign",
"(",
"VerticalAlign",
".",
"TOP",
")",
";",
"table",
".",
"getCellFormatter",
"(",
")",
".",
"getElement",
"(",
"row",
",",
"0",
")",
".",
"setAttribute",
"(",
"\"colSpan\"",
",",
"\"2\"",
")",
";",
"table",
".",
"getCellFormatter",
"(",
")",
".",
"getElement",
"(",
"row",
",",
"0",
")",
".",
"getStyle",
"(",
")",
".",
"setPaddingTop",
"(",
"25",
",",
"Unit",
".",
"PX",
")",
";",
"table",
".",
"getCellFormatter",
"(",
")",
".",
"getElement",
"(",
"row",
",",
"0",
")",
".",
"getStyle",
"(",
")",
".",
"setPaddingBottom",
"(",
"10",
",",
"Unit",
".",
"PX",
")",
";",
"table",
".",
"getCellFormatter",
"(",
")",
".",
"getElement",
"(",
"row",
",",
"0",
")",
".",
"getStyle",
"(",
")",
".",
"setFontWeight",
"(",
"FontWeight",
".",
"BOLD",
")",
";",
"}",
"return",
"info",
";",
"}"
] | /*
HashMap<FieldInfo,HTMLStream> fieldCommentsSlots = new HashMap<FieldInfo,
HTMLStream>(); public AcceptsOneWidget addCommentSlot( Object field ) {
FieldInfo info = (FieldInfo)field;
HTMLStream stream = fieldCommentsSlots.get( info ); if( stream == null )
{ stream = new HTMLStream(); fieldCommentsSlots.put( info, stream );
table.setWidget( info.row, 3, stream );
table.getCellFormatter().getElement( info.row, 3
).getStyle().setFontWeight( FontWeight.NORMAL ); }
SimplePanel slot = new SimplePanel(); stream.addLeft( slot );
return slot; } | [
"/",
"*",
"HashMap<FieldInfo",
"HTMLStream",
">",
"fieldCommentsSlots",
"=",
"new",
"HashMap<FieldInfo",
"HTMLStream",
">",
"()",
";",
"public",
"AcceptsOneWidget",
"addCommentSlot",
"(",
"Object",
"field",
")",
"{",
"FieldInfo",
"info",
"=",
"(",
"FieldInfo",
")",
"field",
";"
] | train | https://github.com/ltearno/hexa.tools/blob/604c804901b1bb13fe10b3823cc4a639f8993363/hexa.core/src/main/java/fr/lteconsulting/hexa/client/form/FormManager.java#L296-L316 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/DiscordApiImpl.java | DiscordApiImpl.getKnownCustomEmojiOrCreateCustomEmoji | public CustomEmoji getKnownCustomEmojiOrCreateCustomEmoji(JsonNode data) {
"""
Gets a known custom emoji or creates a new (unknown) custom emoji object.
@param data The data of the emoji.
@return The emoji for the given json object.
"""
long id = Long.parseLong(data.get("id").asText());
CustomEmoji emoji = customEmojis.get(id);
return emoji == null ? new CustomEmojiImpl(this, data) : emoji;
} | java | public CustomEmoji getKnownCustomEmojiOrCreateCustomEmoji(JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
CustomEmoji emoji = customEmojis.get(id);
return emoji == null ? new CustomEmojiImpl(this, data) : emoji;
} | [
"public",
"CustomEmoji",
"getKnownCustomEmojiOrCreateCustomEmoji",
"(",
"JsonNode",
"data",
")",
"{",
"long",
"id",
"=",
"Long",
".",
"parseLong",
"(",
"data",
".",
"get",
"(",
"\"id\"",
")",
".",
"asText",
"(",
")",
")",
";",
"CustomEmoji",
"emoji",
"=",
"customEmojis",
".",
"get",
"(",
"id",
")",
";",
"return",
"emoji",
"==",
"null",
"?",
"new",
"CustomEmojiImpl",
"(",
"this",
",",
"data",
")",
":",
"emoji",
";",
"}"
] | Gets a known custom emoji or creates a new (unknown) custom emoji object.
@param data The data of the emoji.
@return The emoji for the given json object. | [
"Gets",
"a",
"known",
"custom",
"emoji",
"or",
"creates",
"a",
"new",
"(",
"unknown",
")",
"custom",
"emoji",
"object",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/DiscordApiImpl.java#L824-L828 |
twilio/twilio-java | src/main/java/com/twilio/http/Request.java | Request.getAuthString | public String getAuthString() {
"""
Create auth string from username and password.
@return basic authentication string
"""
String credentials = this.username + ":" + this.password;
try {
String encoded = new Base64().encodeAsString(credentials.getBytes("ascii"));
return "Basic " + encoded;
} catch (final UnsupportedEncodingException e) {
throw new InvalidRequestException("It must be possible to encode credentials as ascii", credentials, e);
}
} | java | public String getAuthString() {
String credentials = this.username + ":" + this.password;
try {
String encoded = new Base64().encodeAsString(credentials.getBytes("ascii"));
return "Basic " + encoded;
} catch (final UnsupportedEncodingException e) {
throw new InvalidRequestException("It must be possible to encode credentials as ascii", credentials, e);
}
} | [
"public",
"String",
"getAuthString",
"(",
")",
"{",
"String",
"credentials",
"=",
"this",
".",
"username",
"+",
"\":\"",
"+",
"this",
".",
"password",
";",
"try",
"{",
"String",
"encoded",
"=",
"new",
"Base64",
"(",
")",
".",
"encodeAsString",
"(",
"credentials",
".",
"getBytes",
"(",
"\"ascii\"",
")",
")",
";",
"return",
"\"Basic \"",
"+",
"encoded",
";",
"}",
"catch",
"(",
"final",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"InvalidRequestException",
"(",
"\"It must be possible to encode credentials as ascii\"",
",",
"credentials",
",",
"e",
")",
";",
"}",
"}"
] | Create auth string from username and password.
@return basic authentication string | [
"Create",
"auth",
"string",
"from",
"username",
"and",
"password",
"."
] | train | https://github.com/twilio/twilio-java/blob/0318974c0a6a152994af167d430255684d5e9b9f/src/main/java/com/twilio/http/Request.java#L97-L109 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/JacksonUtils.java | JacksonUtils.asValue | public static <T> T asValue(JsonNode node, Class<T> clazz) {
"""
Extract value from a {@link JsonNode}.
@param node
@param clazz
@return
"""
return node != null ? ValueUtils.convertValue(node, clazz) : null;
} | java | public static <T> T asValue(JsonNode node, Class<T> clazz) {
return node != null ? ValueUtils.convertValue(node, clazz) : null;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"asValue",
"(",
"JsonNode",
"node",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"node",
"!=",
"null",
"?",
"ValueUtils",
".",
"convertValue",
"(",
"node",
",",
"clazz",
")",
":",
"null",
";",
"}"
] | Extract value from a {@link JsonNode}.
@param node
@param clazz
@return | [
"Extract",
"value",
"from",
"a",
"{",
"@link",
"JsonNode",
"}",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/JacksonUtils.java#L191-L193 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addCustomPrebuiltDomainAsync | public Observable<List<UUID>> addCustomPrebuiltDomainAsync(UUID appId, String versionId, AddCustomPrebuiltDomainModelsOptionalParameter addCustomPrebuiltDomainOptionalParameter) {
"""
Adds a customizable prebuilt domain along with all of its models to this application.
@param appId The application ID.
@param versionId The version ID.
@param addCustomPrebuiltDomainOptionalParameter 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 List<UUID> object
"""
return addCustomPrebuiltDomainWithServiceResponseAsync(appId, versionId, addCustomPrebuiltDomainOptionalParameter).map(new Func1<ServiceResponse<List<UUID>>, List<UUID>>() {
@Override
public List<UUID> call(ServiceResponse<List<UUID>> response) {
return response.body();
}
});
} | java | public Observable<List<UUID>> addCustomPrebuiltDomainAsync(UUID appId, String versionId, AddCustomPrebuiltDomainModelsOptionalParameter addCustomPrebuiltDomainOptionalParameter) {
return addCustomPrebuiltDomainWithServiceResponseAsync(appId, versionId, addCustomPrebuiltDomainOptionalParameter).map(new Func1<ServiceResponse<List<UUID>>, List<UUID>>() {
@Override
public List<UUID> call(ServiceResponse<List<UUID>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"UUID",
">",
">",
"addCustomPrebuiltDomainAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"AddCustomPrebuiltDomainModelsOptionalParameter",
"addCustomPrebuiltDomainOptionalParameter",
")",
"{",
"return",
"addCustomPrebuiltDomainWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"addCustomPrebuiltDomainOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"UUID",
">",
">",
",",
"List",
"<",
"UUID",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"UUID",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"UUID",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Adds a customizable prebuilt domain along with all of its models to this application.
@param appId The application ID.
@param versionId The version ID.
@param addCustomPrebuiltDomainOptionalParameter 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 List<UUID> object | [
"Adds",
"a",
"customizable",
"prebuilt",
"domain",
"along",
"with",
"all",
"of",
"its",
"models",
"to",
"this",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L5570-L5577 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java | JournalHelper.createInstanceAccordingToParameter | public static Object createInstanceAccordingToParameter(String parameterName,
Class<?>[] argClasses,
Object[] args,
Map<String, String> parameters)
throws JournalException {
"""
Look in the system parameters and create an instance of the named class.
@param parameterName
The name of the system parameter that contains the classname
@param argClasses
What types of arguments are required by the constructor?
@param args
Arguments to provide to the instance constructor.
@param parameters
The system parameters
@return the new instance created
"""
String className = parameters.get(parameterName);
if (className == null) {
throw new JournalException("No parameter '" + parameterName + "'");
}
return createInstanceFromClassname(className, argClasses, args);
} | java | public static Object createInstanceAccordingToParameter(String parameterName,
Class<?>[] argClasses,
Object[] args,
Map<String, String> parameters)
throws JournalException {
String className = parameters.get(parameterName);
if (className == null) {
throw new JournalException("No parameter '" + parameterName + "'");
}
return createInstanceFromClassname(className, argClasses, args);
} | [
"public",
"static",
"Object",
"createInstanceAccordingToParameter",
"(",
"String",
"parameterName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"argClasses",
",",
"Object",
"[",
"]",
"args",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"throws",
"JournalException",
"{",
"String",
"className",
"=",
"parameters",
".",
"get",
"(",
"parameterName",
")",
";",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"No parameter '\"",
"+",
"parameterName",
"+",
"\"'\"",
")",
";",
"}",
"return",
"createInstanceFromClassname",
"(",
"className",
",",
"argClasses",
",",
"args",
")",
";",
"}"
] | Look in the system parameters and create an instance of the named class.
@param parameterName
The name of the system parameter that contains the classname
@param argClasses
What types of arguments are required by the constructor?
@param args
Arguments to provide to the instance constructor.
@param parameters
The system parameters
@return the new instance created | [
"Look",
"in",
"the",
"system",
"parameters",
"and",
"create",
"an",
"instance",
"of",
"the",
"named",
"class",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L92-L102 |
amzn/ion-java | src/com/amazon/ion/impl/IonBinary.java | IonBinary.unsignedLongToBigInteger | public static BigInteger unsignedLongToBigInteger(int signum, long val) {
"""
Utility method to convert an unsigned magnitude stored as a long to a {@link BigInteger}.
"""
byte[] magnitude = {
(byte) ((val >> 56) & 0xFF),
(byte) ((val >> 48) & 0xFF),
(byte) ((val >> 40) & 0xFF),
(byte) ((val >> 32) & 0xFF),
(byte) ((val >> 24) & 0xFF),
(byte) ((val >> 16) & 0xFF),
(byte) ((val >> 8) & 0xFF),
(byte) (val & 0xFF),
};
return new BigInteger(signum, magnitude);
} | java | public static BigInteger unsignedLongToBigInteger(int signum, long val)
{
byte[] magnitude = {
(byte) ((val >> 56) & 0xFF),
(byte) ((val >> 48) & 0xFF),
(byte) ((val >> 40) & 0xFF),
(byte) ((val >> 32) & 0xFF),
(byte) ((val >> 24) & 0xFF),
(byte) ((val >> 16) & 0xFF),
(byte) ((val >> 8) & 0xFF),
(byte) (val & 0xFF),
};
return new BigInteger(signum, magnitude);
} | [
"public",
"static",
"BigInteger",
"unsignedLongToBigInteger",
"(",
"int",
"signum",
",",
"long",
"val",
")",
"{",
"byte",
"[",
"]",
"magnitude",
"=",
"{",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"56",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"48",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"40",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"32",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"24",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"16",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"val",
">>",
"8",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"val",
"&",
"0xFF",
")",
",",
"}",
";",
"return",
"new",
"BigInteger",
"(",
"signum",
",",
"magnitude",
")",
";",
"}"
] | Utility method to convert an unsigned magnitude stored as a long to a {@link BigInteger}. | [
"Utility",
"method",
"to",
"convert",
"an",
"unsigned",
"magnitude",
"stored",
"as",
"a",
"long",
"to",
"a",
"{"
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/IonBinary.java#L897-L910 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/AbstractCodeGen.java | AbstractCodeGen.writeLeftCurlyBracket | void writeLeftCurlyBracket(Writer out, int indent) throws IOException {
"""
Output left curly bracket
@param out Writer
@param indent space number
@throws IOException ioException
"""
writeEol(out);
writeWithIndent(out, indent, "{\n");
} | java | void writeLeftCurlyBracket(Writer out, int indent) throws IOException
{
writeEol(out);
writeWithIndent(out, indent, "{\n");
} | [
"void",
"writeLeftCurlyBracket",
"(",
"Writer",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"writeEol",
"(",
"out",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"{\\n\"",
")",
";",
"}"
] | Output left curly bracket
@param out Writer
@param indent space number
@throws IOException ioException | [
"Output",
"left",
"curly",
"bracket"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/AbstractCodeGen.java#L189-L193 |
alipay/sofa-rpc | core/api/src/main/java/com/alipay/sofa/rpc/config/ConfigValueHelper.java | ConfigValueHelper.checkNormalWithColon | protected static void checkNormalWithColon(String configKey, String configValue) throws SofaRpcRuntimeException {
"""
检查字符串是否是正常值(含冒号),不是则抛出异常
@param configKey 配置项
@param configValue 配置值
@throws SofaRpcRuntimeException 非法异常
"""
checkPattern(configKey, configValue, NORMAL_COLON, "only allow a-zA-Z0-9 '-' '_' '.' ':'");
} | java | protected static void checkNormalWithColon(String configKey, String configValue) throws SofaRpcRuntimeException {
checkPattern(configKey, configValue, NORMAL_COLON, "only allow a-zA-Z0-9 '-' '_' '.' ':'");
} | [
"protected",
"static",
"void",
"checkNormalWithColon",
"(",
"String",
"configKey",
",",
"String",
"configValue",
")",
"throws",
"SofaRpcRuntimeException",
"{",
"checkPattern",
"(",
"configKey",
",",
"configValue",
",",
"NORMAL_COLON",
",",
"\"only allow a-zA-Z0-9 '-' '_' '.' ':'\"",
")",
";",
"}"
] | 检查字符串是否是正常值(含冒号),不是则抛出异常
@param configKey 配置项
@param configValue 配置值
@throws SofaRpcRuntimeException 非法异常 | [
"检查字符串是否是正常值(含冒号),不是则抛出异常"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/api/src/main/java/com/alipay/sofa/rpc/config/ConfigValueHelper.java#L119-L121 |
phax/ph-commons | ph-datetime/src/main/java/com/helger/datetime/util/PDTHelper.java | PDTHelper.getStartWeekOfMonth | public static int getStartWeekOfMonth (@Nonnull final LocalDateTime aDT, @Nonnull final Locale aLocale) {
"""
Get the start--week number for the passed year and month.
@param aDT
The object to use year and month from.
@param aLocale
Locale to use. May not be <code>null</code>.
@return the start week number.
"""
return getWeekOfWeekBasedYear (aDT.withDayOfMonth (1), aLocale);
} | java | public static int getStartWeekOfMonth (@Nonnull final LocalDateTime aDT, @Nonnull final Locale aLocale)
{
return getWeekOfWeekBasedYear (aDT.withDayOfMonth (1), aLocale);
} | [
"public",
"static",
"int",
"getStartWeekOfMonth",
"(",
"@",
"Nonnull",
"final",
"LocalDateTime",
"aDT",
",",
"@",
"Nonnull",
"final",
"Locale",
"aLocale",
")",
"{",
"return",
"getWeekOfWeekBasedYear",
"(",
"aDT",
".",
"withDayOfMonth",
"(",
"1",
")",
",",
"aLocale",
")",
";",
"}"
] | Get the start--week number for the passed year and month.
@param aDT
The object to use year and month from.
@param aLocale
Locale to use. May not be <code>null</code>.
@return the start week number. | [
"Get",
"the",
"start",
"--",
"week",
"number",
"for",
"the",
"passed",
"year",
"and",
"month",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-datetime/src/main/java/com/helger/datetime/util/PDTHelper.java#L207-L210 |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/core/ProductHandler.java | ProductHandler.setProductModules | public void setProductModules(final String name, final List<String> moduleNames) {
"""
Patches the product module names
@param name String
@param moduleNames List<String>
"""
final DbProduct dbProduct = getProduct(name);
dbProduct.setModules(moduleNames);
repositoryHandler.store(dbProduct);
} | java | public void setProductModules(final String name, final List<String> moduleNames) {
final DbProduct dbProduct = getProduct(name);
dbProduct.setModules(moduleNames);
repositoryHandler.store(dbProduct);
} | [
"public",
"void",
"setProductModules",
"(",
"final",
"String",
"name",
",",
"final",
"List",
"<",
"String",
">",
"moduleNames",
")",
"{",
"final",
"DbProduct",
"dbProduct",
"=",
"getProduct",
"(",
"name",
")",
";",
"dbProduct",
".",
"setModules",
"(",
"moduleNames",
")",
";",
"repositoryHandler",
".",
"store",
"(",
"dbProduct",
")",
";",
"}"
] | Patches the product module names
@param name String
@param moduleNames List<String> | [
"Patches",
"the",
"product",
"module",
"names"
] | train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/core/ProductHandler.java#L90-L94 |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/AmbiguousOptionException.java | AmbiguousOptionException.createMessage | private static String createMessage(String option, Collection<String> matchingOptions) {
"""
Build the exception message from the specified list of options.
@param option
@param matchingOptions
@return
"""
StringBuilder buf = new StringBuilder("Ambiguous option: '");
buf.append(option);
buf.append("' (could be: ");
Iterator<String> it = matchingOptions.iterator();
while (it.hasNext())
{
buf.append("'");
buf.append(it.next());
buf.append("'");
if (it.hasNext())
{
buf.append(", ");
}
}
buf.append(")");
return buf.toString();
} | java | private static String createMessage(String option, Collection<String> matchingOptions)
{
StringBuilder buf = new StringBuilder("Ambiguous option: '");
buf.append(option);
buf.append("' (could be: ");
Iterator<String> it = matchingOptions.iterator();
while (it.hasNext())
{
buf.append("'");
buf.append(it.next());
buf.append("'");
if (it.hasNext())
{
buf.append(", ");
}
}
buf.append(")");
return buf.toString();
} | [
"private",
"static",
"String",
"createMessage",
"(",
"String",
"option",
",",
"Collection",
"<",
"String",
">",
"matchingOptions",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"\"Ambiguous option: '\"",
")",
";",
"buf",
".",
"append",
"(",
"option",
")",
";",
"buf",
".",
"append",
"(",
"\"' (could be: \"",
")",
";",
"Iterator",
"<",
"String",
">",
"it",
"=",
"matchingOptions",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"buf",
".",
"append",
"(",
"\"'\"",
")",
";",
"buf",
".",
"append",
"(",
"it",
".",
"next",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\"'\"",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"buf",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"}",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Build the exception message from the specified list of options.
@param option
@param matchingOptions
@return | [
"Build",
"the",
"exception",
"message",
"from",
"the",
"specified",
"list",
"of",
"options",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/AmbiguousOptionException.java#L67-L87 |
eclipse/xtext-core | org.eclipse.xtext/src-gen/org/eclipse/xtext/serializer/XtextSemanticSequencer.java | XtextSemanticSequencer.sequence_Negation | protected void sequence_Negation(ISerializationContext context, Negation semanticObject) {
"""
Contexts:
Disjunction returns Negation
Disjunction.Disjunction_1_0 returns Negation
Conjunction returns Negation
Conjunction.Conjunction_1_0 returns Negation
Negation returns Negation
Atom returns Negation
ParenthesizedCondition returns Negation
Constraint:
value=Negation
"""
if (errorAcceptor != null) {
if (transientValues.isValueTransient(semanticObject, XtextPackage.Literals.NEGATION__VALUE) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XtextPackage.Literals.NEGATION__VALUE));
}
SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
feeder.accept(grammarAccess.getNegationAccess().getValueNegationParserRuleCall_1_2_0(), semanticObject.getValue());
feeder.finish();
} | java | protected void sequence_Negation(ISerializationContext context, Negation semanticObject) {
if (errorAcceptor != null) {
if (transientValues.isValueTransient(semanticObject, XtextPackage.Literals.NEGATION__VALUE) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XtextPackage.Literals.NEGATION__VALUE));
}
SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
feeder.accept(grammarAccess.getNegationAccess().getValueNegationParserRuleCall_1_2_0(), semanticObject.getValue());
feeder.finish();
} | [
"protected",
"void",
"sequence_Negation",
"(",
"ISerializationContext",
"context",
",",
"Negation",
"semanticObject",
")",
"{",
"if",
"(",
"errorAcceptor",
"!=",
"null",
")",
"{",
"if",
"(",
"transientValues",
".",
"isValueTransient",
"(",
"semanticObject",
",",
"XtextPackage",
".",
"Literals",
".",
"NEGATION__VALUE",
")",
"==",
"ValueTransient",
".",
"YES",
")",
"errorAcceptor",
".",
"accept",
"(",
"diagnosticProvider",
".",
"createFeatureValueMissing",
"(",
"semanticObject",
",",
"XtextPackage",
".",
"Literals",
".",
"NEGATION__VALUE",
")",
")",
";",
"}",
"SequenceFeeder",
"feeder",
"=",
"createSequencerFeeder",
"(",
"context",
",",
"semanticObject",
")",
";",
"feeder",
".",
"accept",
"(",
"grammarAccess",
".",
"getNegationAccess",
"(",
")",
".",
"getValueNegationParserRuleCall_1_2_0",
"(",
")",
",",
"semanticObject",
".",
"getValue",
"(",
")",
")",
";",
"feeder",
".",
"finish",
"(",
")",
";",
"}"
] | Contexts:
Disjunction returns Negation
Disjunction.Disjunction_1_0 returns Negation
Conjunction returns Negation
Conjunction.Conjunction_1_0 returns Negation
Negation returns Negation
Atom returns Negation
ParenthesizedCondition returns Negation
Constraint:
value=Negation | [
"Contexts",
":",
"Disjunction",
"returns",
"Negation",
"Disjunction",
".",
"Disjunction_1_0",
"returns",
"Negation",
"Conjunction",
"returns",
"Negation",
"Conjunction",
".",
"Conjunction_1_0",
"returns",
"Negation",
"Negation",
"returns",
"Negation",
"Atom",
"returns",
"Negation",
"ParenthesizedCondition",
"returns",
"Negation"
] | train | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src-gen/org/eclipse/xtext/serializer/XtextSemanticSequencer.java#L954-L962 |
intellimate/Izou | src/main/java/org/intellimate/izou/resource/ResourceManager.java | ResourceManager.generateResources | public List<ResourceModel> generateResources(EventModel<?> event) {
"""
generates all the resources for an event
@param event the Event to generate the resources for
@return a List containing all the generated resources
"""
if(!event.getAllInformations().stream()
.anyMatch(eventSubscribers::containsKey)) return new LinkedList<>();
List<ResourceBuilderModel> resourceBuilders = event.getAllInformations().stream()
.map(eventSubscribers::get)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
return generateResources(resourceBuilders, event);
} | java | public List<ResourceModel> generateResources(EventModel<?> event) {
if(!event.getAllInformations().stream()
.anyMatch(eventSubscribers::containsKey)) return new LinkedList<>();
List<ResourceBuilderModel> resourceBuilders = event.getAllInformations().stream()
.map(eventSubscribers::get)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
return generateResources(resourceBuilders, event);
} | [
"public",
"List",
"<",
"ResourceModel",
">",
"generateResources",
"(",
"EventModel",
"<",
"?",
">",
"event",
")",
"{",
"if",
"(",
"!",
"event",
".",
"getAllInformations",
"(",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"eventSubscribers",
"::",
"containsKey",
")",
")",
"return",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"List",
"<",
"ResourceBuilderModel",
">",
"resourceBuilders",
"=",
"event",
".",
"getAllInformations",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"eventSubscribers",
"::",
"get",
")",
".",
"filter",
"(",
"Objects",
"::",
"nonNull",
")",
".",
"flatMap",
"(",
"Collection",
"::",
"stream",
")",
".",
"distinct",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"return",
"generateResources",
"(",
"resourceBuilders",
",",
"event",
")",
";",
"}"
] | generates all the resources for an event
@param event the Event to generate the resources for
@return a List containing all the generated resources | [
"generates",
"all",
"the",
"resources",
"for",
"an",
"event"
] | train | https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/resource/ResourceManager.java#L40-L52 |
jbundle/webapp | upload/src/main/java/org/jbundle/util/webapp/upload/UploadServlet.java | UploadServlet.sendForm | public void sendForm(HttpServletRequest req, HttpServletResponse res, String strReceiveMessage, Properties properties)
throws ServletException, IOException {
"""
Process an HTML get or post.
@exception ServletException From inherited class.
@exception IOException From inherited class.
"""
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.write("<html>" + RETURN +
"<head>" + RETURN +
"<title>" + this.getTitle() + "</title>" + RETURN +
"</head>" + RETURN +
"<body>" + RETURN +
"<center><b>" + this.getTitle() + "</b></center><p />" + RETURN);
String strServletPath = null;
try {
strServletPath = req.getRequestURI(); //Path();
} catch (Exception ex)
{
strServletPath = null;
}
if (strServletPath == null)
strServletPath = "servlet/" + UploadServlet.class.getName(); // Never
//strServletPath = "http://localhost/jbackup/servlet/com.tourgeek.jbackup.Servlet";
out.write(strReceiveMessage); // Status of previous upload
out.write("<p /><form action=\"" + strServletPath + "\"");
out.write(" method=\"post\"" + RETURN);
out.write(" enctype=\"multipart/form-data\">" + RETURN);
// TARGET=_top
// out.write(" ACTION="http://www45.visto.com/?uid=219979&service=fileaccess&method=upload&nextpage=fa%3Dafter_upload.html&[email protected]&overwritepage=fa=upload_replace_dialog.html">
// out.write("What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>" + RETURN);
String strFormHTML = this.getFormHTML();
if ((strFormHTML != null) && (strFormHTML.length() > 0))
out.write(strFormHTML);
out.write("Which file to upload? <input type=\"file\" name=\"file\" />" + RETURN);
this.writeAfterHTML(out, req, properties);
out.write("<input type=\"submit\" value=\"upload\" />" + RETURN);
out.write("</form></p>" + RETURN);
out.write("</body>" + RETURN +
"</html>" + RETURN);
} | java | public void sendForm(HttpServletRequest req, HttpServletResponse res, String strReceiveMessage, Properties properties)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.write("<html>" + RETURN +
"<head>" + RETURN +
"<title>" + this.getTitle() + "</title>" + RETURN +
"</head>" + RETURN +
"<body>" + RETURN +
"<center><b>" + this.getTitle() + "</b></center><p />" + RETURN);
String strServletPath = null;
try {
strServletPath = req.getRequestURI(); //Path();
} catch (Exception ex)
{
strServletPath = null;
}
if (strServletPath == null)
strServletPath = "servlet/" + UploadServlet.class.getName(); // Never
//strServletPath = "http://localhost/jbackup/servlet/com.tourgeek.jbackup.Servlet";
out.write(strReceiveMessage); // Status of previous upload
out.write("<p /><form action=\"" + strServletPath + "\"");
out.write(" method=\"post\"" + RETURN);
out.write(" enctype=\"multipart/form-data\">" + RETURN);
// TARGET=_top
// out.write(" ACTION="http://www45.visto.com/?uid=219979&service=fileaccess&method=upload&nextpage=fa%3Dafter_upload.html&[email protected]&overwritepage=fa=upload_replace_dialog.html">
// out.write("What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>" + RETURN);
String strFormHTML = this.getFormHTML();
if ((strFormHTML != null) && (strFormHTML.length() > 0))
out.write(strFormHTML);
out.write("Which file to upload? <input type=\"file\" name=\"file\" />" + RETURN);
this.writeAfterHTML(out, req, properties);
out.write("<input type=\"submit\" value=\"upload\" />" + RETURN);
out.write("</form></p>" + RETURN);
out.write("</body>" + RETURN +
"</html>" + RETURN);
} | [
"public",
"void",
"sendForm",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
",",
"String",
"strReceiveMessage",
",",
"Properties",
"properties",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"res",
".",
"setContentType",
"(",
"\"text/html\"",
")",
";",
"PrintWriter",
"out",
"=",
"res",
".",
"getWriter",
"(",
")",
";",
"out",
".",
"write",
"(",
"\"<html>\"",
"+",
"RETURN",
"+",
"\"<head>\"",
"+",
"RETURN",
"+",
"\"<title>\"",
"+",
"this",
".",
"getTitle",
"(",
")",
"+",
"\"</title>\"",
"+",
"RETURN",
"+",
"\"</head>\"",
"+",
"RETURN",
"+",
"\"<body>\"",
"+",
"RETURN",
"+",
"\"<center><b>\"",
"+",
"this",
".",
"getTitle",
"(",
")",
"+",
"\"</b></center><p />\"",
"+",
"RETURN",
")",
";",
"String",
"strServletPath",
"=",
"null",
";",
"try",
"{",
"strServletPath",
"=",
"req",
".",
"getRequestURI",
"(",
")",
";",
"//Path();",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"strServletPath",
"=",
"null",
";",
"}",
"if",
"(",
"strServletPath",
"==",
"null",
")",
"strServletPath",
"=",
"\"servlet/\"",
"+",
"UploadServlet",
".",
"class",
".",
"getName",
"(",
")",
";",
"// Never",
"//strServletPath = \"http://localhost/jbackup/servlet/com.tourgeek.jbackup.Servlet\";",
"out",
".",
"write",
"(",
"strReceiveMessage",
")",
";",
"// Status of previous upload",
"out",
".",
"write",
"(",
"\"<p /><form action=\\\"\"",
"+",
"strServletPath",
"+",
"\"\\\"\"",
")",
";",
"out",
".",
"write",
"(",
"\" method=\\\"post\\\"\"",
"+",
"RETURN",
")",
";",
"out",
".",
"write",
"(",
"\" enctype=\\\"multipart/form-data\\\">\"",
"+",
"RETURN",
")",
";",
"// TARGET=_top",
"//\t\tout.write(\" ACTION=\"http://www45.visto.com/?uid=219979&service=fileaccess&method=upload&nextpage=fa%3Dafter_upload.html&[email protected]&overwritepage=fa=upload_replace_dialog.html\">",
"//\t\tout.write(\"What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>\" + RETURN);",
"String",
"strFormHTML",
"=",
"this",
".",
"getFormHTML",
"(",
")",
";",
"if",
"(",
"(",
"strFormHTML",
"!=",
"null",
")",
"&&",
"(",
"strFormHTML",
".",
"length",
"(",
")",
">",
"0",
")",
")",
"out",
".",
"write",
"(",
"strFormHTML",
")",
";",
"out",
".",
"write",
"(",
"\"Which file to upload? <input type=\\\"file\\\" name=\\\"file\\\" />\"",
"+",
"RETURN",
")",
";",
"this",
".",
"writeAfterHTML",
"(",
"out",
",",
"req",
",",
"properties",
")",
";",
"out",
".",
"write",
"(",
"\"<input type=\\\"submit\\\" value=\\\"upload\\\" />\"",
"+",
"RETURN",
")",
";",
"out",
".",
"write",
"(",
"\"</form></p>\"",
"+",
"RETURN",
")",
";",
"out",
".",
"write",
"(",
"\"</body>\"",
"+",
"RETURN",
"+",
"\"</html>\"",
"+",
"RETURN",
")",
";",
"}"
] | Process an HTML get or post.
@exception ServletException From inherited class.
@exception IOException From inherited class. | [
"Process",
"an",
"HTML",
"get",
"or",
"post",
"."
] | train | https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/upload/src/main/java/org/jbundle/util/webapp/upload/UploadServlet.java#L167-L207 |
FaritorKang/unmz-common-util | src/main/java/net/unmz/java/util/json/JsonUtils.java | JsonUtils.toBean | public static <T> T toBean(String text, Class<T> clazz) {
"""
指定泛型,JSON串转对象
@param text JSON串
@param clazz 对象类型
@param <T> 对象泛型
@return 转换得到的对象
"""
return JSON.parseObject(text, clazz);
} | java | public static <T> T toBean(String text, Class<T> clazz) {
return JSON.parseObject(text, clazz);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"toBean",
"(",
"String",
"text",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"JSON",
".",
"parseObject",
"(",
"text",
",",
"clazz",
")",
";",
"}"
] | 指定泛型,JSON串转对象
@param text JSON串
@param clazz 对象类型
@param <T> 对象泛型
@return 转换得到的对象 | [
"指定泛型,JSON串转对象"
] | train | https://github.com/FaritorKang/unmz-common-util/blob/2912b8889b85ed910d536f85b24b6fa68035814a/src/main/java/net/unmz/java/util/json/JsonUtils.java#L77-L79 |
kennycason/kumo | kumo-core/src/main/java/com/kennycason/kumo/ParallelLayeredWordCloud.java | ParallelLayeredWordCloud.build | @Override
public void build(final int layer, final List<WordFrequency> wordFrequencies) {
"""
constructs the wordcloud specified by layer using the given
wordfrequencies.<br>
This is a non-blocking call.
@param layer
Wordcloud Layer
@param wordFrequencies
the WordFrequencies to use as input
"""
final Future<?> completionFuture = executorservice.submit(() -> {
LOGGER.info("Starting to build WordCloud Layer {} in new Thread", layer);
super.build(layer, wordFrequencies);
});
executorFutures.add(completionFuture);
} | java | @Override
public void build(final int layer, final List<WordFrequency> wordFrequencies) {
final Future<?> completionFuture = executorservice.submit(() -> {
LOGGER.info("Starting to build WordCloud Layer {} in new Thread", layer);
super.build(layer, wordFrequencies);
});
executorFutures.add(completionFuture);
} | [
"@",
"Override",
"public",
"void",
"build",
"(",
"final",
"int",
"layer",
",",
"final",
"List",
"<",
"WordFrequency",
">",
"wordFrequencies",
")",
"{",
"final",
"Future",
"<",
"?",
">",
"completionFuture",
"=",
"executorservice",
".",
"submit",
"(",
"(",
")",
"->",
"{",
"LOGGER",
".",
"info",
"(",
"\"Starting to build WordCloud Layer {} in new Thread\"",
",",
"layer",
")",
";",
"super",
".",
"build",
"(",
"layer",
",",
"wordFrequencies",
")",
";",
"}",
")",
";",
"executorFutures",
".",
"add",
"(",
"completionFuture",
")",
";",
"}"
] | constructs the wordcloud specified by layer using the given
wordfrequencies.<br>
This is a non-blocking call.
@param layer
Wordcloud Layer
@param wordFrequencies
the WordFrequencies to use as input | [
"constructs",
"the",
"wordcloud",
"specified",
"by",
"layer",
"using",
"the",
"given",
"wordfrequencies",
".",
"<br",
">",
"This",
"is",
"a",
"non",
"-",
"blocking",
"call",
"."
] | train | https://github.com/kennycason/kumo/blob/bc577f468f162dbaf61c327a2d4f1989c61c57a0/kumo-core/src/main/java/com/kennycason/kumo/ParallelLayeredWordCloud.java#L40-L48 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/server/JavacServer.java | JavacServer.connectGetSysInfo | public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) {
"""
Make a request to the server only to get the maximum possible heap size to use for compilations.
@param port_file The port file used to synchronize creation of this server.
@param id The identify of the compilation.
@param out Standard out information.
@param err Standard err information.
@return The maximum heap size in bytes.
"""
SysInfo sysinfo = new SysInfo(-1, -1);
String id = Util.extractStringOption("id", serverSettings);
String portfile = Util.extractStringOption("portfile", serverSettings);
try {
PortFile pf = getPortFile(portfile);
useServer(serverSettings, new String[0],
new HashSet<URI>(),
new HashSet<URI>(),
new HashMap<URI, Set<String>>(),
new HashMap<String, Set<URI>>(),
new HashMap<String, Set<String>>(),
new HashMap<String, String>(),
sysinfo, out, err);
} catch (Exception e) {
e.printStackTrace(err);
}
return sysinfo;
} | java | public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) {
SysInfo sysinfo = new SysInfo(-1, -1);
String id = Util.extractStringOption("id", serverSettings);
String portfile = Util.extractStringOption("portfile", serverSettings);
try {
PortFile pf = getPortFile(portfile);
useServer(serverSettings, new String[0],
new HashSet<URI>(),
new HashSet<URI>(),
new HashMap<URI, Set<String>>(),
new HashMap<String, Set<URI>>(),
new HashMap<String, Set<String>>(),
new HashMap<String, String>(),
sysinfo, out, err);
} catch (Exception e) {
e.printStackTrace(err);
}
return sysinfo;
} | [
"public",
"static",
"SysInfo",
"connectGetSysInfo",
"(",
"String",
"serverSettings",
",",
"PrintStream",
"out",
",",
"PrintStream",
"err",
")",
"{",
"SysInfo",
"sysinfo",
"=",
"new",
"SysInfo",
"(",
"-",
"1",
",",
"-",
"1",
")",
";",
"String",
"id",
"=",
"Util",
".",
"extractStringOption",
"(",
"\"id\"",
",",
"serverSettings",
")",
";",
"String",
"portfile",
"=",
"Util",
".",
"extractStringOption",
"(",
"\"portfile\"",
",",
"serverSettings",
")",
";",
"try",
"{",
"PortFile",
"pf",
"=",
"getPortFile",
"(",
"portfile",
")",
";",
"useServer",
"(",
"serverSettings",
",",
"new",
"String",
"[",
"0",
"]",
",",
"new",
"HashSet",
"<",
"URI",
">",
"(",
")",
",",
"new",
"HashSet",
"<",
"URI",
">",
"(",
")",
",",
"new",
"HashMap",
"<",
"URI",
",",
"Set",
"<",
"String",
">",
">",
"(",
")",
",",
"new",
"HashMap",
"<",
"String",
",",
"Set",
"<",
"URI",
">",
">",
"(",
")",
",",
"new",
"HashMap",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"(",
")",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
",",
"sysinfo",
",",
"out",
",",
"err",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
"err",
")",
";",
"}",
"return",
"sysinfo",
";",
"}"
] | Make a request to the server only to get the maximum possible heap size to use for compilations.
@param port_file The port file used to synchronize creation of this server.
@param id The identify of the compilation.
@param out Standard out information.
@param err Standard err information.
@return The maximum heap size in bytes. | [
"Make",
"a",
"request",
"to",
"the",
"server",
"only",
"to",
"get",
"the",
"maximum",
"possible",
"heap",
"size",
"to",
"use",
"for",
"compilations",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java#L432-L450 |
shrinkwrap/resolver | maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java | MavenManagerBuilder.artifactTypeRegistry | public ArtifactTypeRegistry artifactTypeRegistry() {
"""
Returns artifact type registry. Defines standard Maven stereotypes.
@return
"""
DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
stereotypes.add(new DefaultArtifactType("pom"));
stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java"));
stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java"));
stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java"));
stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false));
stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true));
return stereotypes;
} | java | public ArtifactTypeRegistry artifactTypeRegistry() {
DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
stereotypes.add(new DefaultArtifactType("pom"));
stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java"));
stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java"));
stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java"));
stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false));
stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true));
return stereotypes;
} | [
"public",
"ArtifactTypeRegistry",
"artifactTypeRegistry",
"(",
")",
"{",
"DefaultArtifactTypeRegistry",
"stereotypes",
"=",
"new",
"DefaultArtifactTypeRegistry",
"(",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"pom\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"maven-plugin\"",
",",
"\"jar\"",
",",
"\"\"",
",",
"\"java\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"jar\"",
",",
"\"jar\"",
",",
"\"\"",
",",
"\"java\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"ejb\"",
",",
"\"jar\"",
",",
"\"\"",
",",
"\"java\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"ejb-client\"",
",",
"\"jar\"",
",",
"\"client\"",
",",
"\"java\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"test-jar\"",
",",
"\"jar\"",
",",
"\"tests\"",
",",
"\"java\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"javadoc\"",
",",
"\"jar\"",
",",
"\"javadoc\"",
",",
"\"java\"",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"java-source\"",
",",
"\"jar\"",
",",
"\"sources\"",
",",
"\"java\"",
",",
"false",
",",
"false",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"war\"",
",",
"\"war\"",
",",
"\"\"",
",",
"\"java\"",
",",
"false",
",",
"true",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"ear\"",
",",
"\"ear\"",
",",
"\"\"",
",",
"\"java\"",
",",
"false",
",",
"true",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"rar\"",
",",
"\"rar\"",
",",
"\"\"",
",",
"\"java\"",
",",
"false",
",",
"true",
")",
")",
";",
"stereotypes",
".",
"add",
"(",
"new",
"DefaultArtifactType",
"(",
"\"par\"",
",",
"\"par\"",
",",
"\"\"",
",",
"\"java\"",
",",
"false",
",",
"true",
")",
")",
";",
"return",
"stereotypes",
";",
"}"
] | Returns artifact type registry. Defines standard Maven stereotypes.
@return | [
"Returns",
"artifact",
"type",
"registry",
".",
"Defines",
"standard",
"Maven",
"stereotypes",
"."
] | train | https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java#L223-L238 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java | ShapeGenerator.createProgressBarIndeterminatePattern | public Shape createProgressBarIndeterminatePattern(int x, int y, int w, int h) {
"""
Return a path for the patterned portion of an indeterminate progress bar.
@param x the X coordinate of the upper-left corner of the region
@param y the Y coordinate of the upper-left corner of the region
@param w the width of the region
@param h the height of the region
@return a path representing the shape.
"""
final double wHalf = w / 2.0;
final double xOffset = 5;
path.reset();
path.moveTo(xOffset, 0);
path.lineTo(xOffset+wHalf, 0);
path.curveTo(xOffset+wHalf-5, h/2-4, xOffset+wHalf+5, h/2+4, xOffset+wHalf, h);
path.lineTo(xOffset, h);
path.curveTo(xOffset+5, h/2+4, xOffset-5, h/2-4, xOffset, 0);
path.closePath();
return path;
} | java | public Shape createProgressBarIndeterminatePattern(int x, int y, int w, int h) {
final double wHalf = w / 2.0;
final double xOffset = 5;
path.reset();
path.moveTo(xOffset, 0);
path.lineTo(xOffset+wHalf, 0);
path.curveTo(xOffset+wHalf-5, h/2-4, xOffset+wHalf+5, h/2+4, xOffset+wHalf, h);
path.lineTo(xOffset, h);
path.curveTo(xOffset+5, h/2+4, xOffset-5, h/2-4, xOffset, 0);
path.closePath();
return path;
} | [
"public",
"Shape",
"createProgressBarIndeterminatePattern",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"w",
",",
"int",
"h",
")",
"{",
"final",
"double",
"wHalf",
"=",
"w",
"/",
"2.0",
";",
"final",
"double",
"xOffset",
"=",
"5",
";",
"path",
".",
"reset",
"(",
")",
";",
"path",
".",
"moveTo",
"(",
"xOffset",
",",
"0",
")",
";",
"path",
".",
"lineTo",
"(",
"xOffset",
"+",
"wHalf",
",",
"0",
")",
";",
"path",
".",
"curveTo",
"(",
"xOffset",
"+",
"wHalf",
"-",
"5",
",",
"h",
"/",
"2",
"-",
"4",
",",
"xOffset",
"+",
"wHalf",
"+",
"5",
",",
"h",
"/",
"2",
"+",
"4",
",",
"xOffset",
"+",
"wHalf",
",",
"h",
")",
";",
"path",
".",
"lineTo",
"(",
"xOffset",
",",
"h",
")",
";",
"path",
".",
"curveTo",
"(",
"xOffset",
"+",
"5",
",",
"h",
"/",
"2",
"+",
"4",
",",
"xOffset",
"-",
"5",
",",
"h",
"/",
"2",
"-",
"4",
",",
"xOffset",
",",
"0",
")",
";",
"path",
".",
"closePath",
"(",
")",
";",
"return",
"path",
";",
"}"
] | Return a path for the patterned portion of an indeterminate progress bar.
@param x the X coordinate of the upper-left corner of the region
@param y the Y coordinate of the upper-left corner of the region
@param w the width of the region
@param h the height of the region
@return a path representing the shape. | [
"Return",
"a",
"path",
"for",
"the",
"patterned",
"portion",
"of",
"an",
"indeterminate",
"progress",
"bar",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java#L384-L396 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java | ValueEnforcer.notNull | public static <T> T notNull (final T aValue, @Nonnull final Supplier <? extends String> aName) {
"""
Check that the passed value is not <code>null</code>.
@param <T>
Type to be checked and returned
@param aValue
The value to check.
@param aName
The name of the value (e.g. the parameter name)
@return The passed value.
@throws NullPointerException
if the passed value is <code>null</code>.
"""
if (isEnabled ())
if (aValue == null)
throw new NullPointerException ("The value of '" + aName.get () + "' may not be null!");
return aValue;
} | java | public static <T> T notNull (final T aValue, @Nonnull final Supplier <? extends String> aName)
{
if (isEnabled ())
if (aValue == null)
throw new NullPointerException ("The value of '" + aName.get () + "' may not be null!");
return aValue;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"notNull",
"(",
"final",
"T",
"aValue",
",",
"@",
"Nonnull",
"final",
"Supplier",
"<",
"?",
"extends",
"String",
">",
"aName",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"if",
"(",
"aValue",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"The value of '\"",
"+",
"aName",
".",
"get",
"(",
")",
"+",
"\"' may not be null!\"",
")",
";",
"return",
"aValue",
";",
"}"
] | Check that the passed value is not <code>null</code>.
@param <T>
Type to be checked and returned
@param aValue
The value to check.
@param aName
The name of the value (e.g. the parameter name)
@return The passed value.
@throws NullPointerException
if the passed value is <code>null</code>. | [
"Check",
"that",
"the",
"passed",
"value",
"is",
"not",
"<code",
">",
"null<",
"/",
"code",
">",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L294-L300 |
facebookarchive/hadoop-20 | src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/server/namenode/bookkeeper/BookKeeperJournalOutputStream.java | BookKeeperJournalOutputStream.addBookKeeperEntry | private synchronized void addBookKeeperEntry(byte[] buf, int off, int len)
throws IOException {
"""
Write the buffer to a new entry in a BookKeeper ledger or throw
an IOException if we are unable to successfully write to a quorum
of bookies
@param buf Buffer to write from
@param off Offset in the buffer
@param len How many bytes to write, starting the offset
@throws IOException If we are interrupted while writing to BookKeeper or
if we are unable to successfully add the entry to
a quorum of bookies.
"""
try {
ledger.addEntry(buf, off, len);
if (LOG.isDebugEnabled()) {
LOG.debug("Last add pushed to ledger " + ledger.getId() + " is " +
ledger.getLastAddPushed());
LOG.debug("Last add confirmed to ledger " + ledger.getId() + " is " +
ledger.getLastAddConfirmed());
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted writing to BookKeeper", e);
} catch (BKException e) {
throw new IOException("Failed to write to BookKeeper", e);
}
} | java | private synchronized void addBookKeeperEntry(byte[] buf, int off, int len)
throws IOException {
try {
ledger.addEntry(buf, off, len);
if (LOG.isDebugEnabled()) {
LOG.debug("Last add pushed to ledger " + ledger.getId() + " is " +
ledger.getLastAddPushed());
LOG.debug("Last add confirmed to ledger " + ledger.getId() + " is " +
ledger.getLastAddConfirmed());
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted writing to BookKeeper", e);
} catch (BKException e) {
throw new IOException("Failed to write to BookKeeper", e);
}
} | [
"private",
"synchronized",
"void",
"addBookKeeperEntry",
"(",
"byte",
"[",
"]",
"buf",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"try",
"{",
"ledger",
".",
"addEntry",
"(",
"buf",
",",
"off",
",",
"len",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Last add pushed to ledger \"",
"+",
"ledger",
".",
"getId",
"(",
")",
"+",
"\" is \"",
"+",
"ledger",
".",
"getLastAddPushed",
"(",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Last add confirmed to ledger \"",
"+",
"ledger",
".",
"getId",
"(",
")",
"+",
"\" is \"",
"+",
"ledger",
".",
"getLastAddConfirmed",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"IOException",
"(",
"\"Interrupted writing to BookKeeper\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"BKException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to write to BookKeeper\"",
",",
"e",
")",
";",
"}",
"}"
] | Write the buffer to a new entry in a BookKeeper ledger or throw
an IOException if we are unable to successfully write to a quorum
of bookies
@param buf Buffer to write from
@param off Offset in the buffer
@param len How many bytes to write, starting the offset
@throws IOException If we are interrupted while writing to BookKeeper or
if we are unable to successfully add the entry to
a quorum of bookies. | [
"Write",
"the",
"buffer",
"to",
"a",
"new",
"entry",
"in",
"a",
"BookKeeper",
"ledger",
"or",
"throw",
"an",
"IOException",
"if",
"we",
"are",
"unable",
"to",
"successfully",
"write",
"to",
"a",
"quorum",
"of",
"bookies"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/server/namenode/bookkeeper/BookKeeperJournalOutputStream.java#L69-L85 |
dimaki/refuel | src/main/java/de/dimaki/refuel/Bootstrap.java | Bootstrap.startApp | public void startApp(Path applicationFile, String applicationClass, String methodName) throws IOException {
"""
Start the application
@param applicationFile The application file (e.g. a JAR)
@param applicationClass The application class (e.g. "de.dimaki.jartest.JarTest")
@param methodName The method to be called (e.g. "start")
@throws IOException In case of an error
"""
try {
System.out.println("Loading : " + applicationFile.toAbsolutePath().toString());
this.defaultClassLoader = Thread.currentThread().getContextClassLoader();
this.appClassLoader = URLClassLoader.newInstance(new URL[]{applicationFile.toUri().toURL()}, this.defaultClassLoader);
Thread.currentThread().setContextClassLoader(this.appClassLoader);
Thread.getAllStackTraces().keySet().stream().forEach((thread) -> {
thread.setContextClassLoader(this.appClassLoader);
});
this.appClazz = this.appClassLoader.loadClass(applicationClass);
final Method method = this.appClazz.getMethod(methodName);
this.appInstance = this.appClazz.newInstance();
method.invoke(this.appInstance);
} | java | public void startApp(Path applicationFile, String applicationClass, String methodName) throws IOException {
try {
System.out.println("Loading : " + applicationFile.toAbsolutePath().toString());
this.defaultClassLoader = Thread.currentThread().getContextClassLoader();
this.appClassLoader = URLClassLoader.newInstance(new URL[]{applicationFile.toUri().toURL()}, this.defaultClassLoader);
Thread.currentThread().setContextClassLoader(this.appClassLoader);
Thread.getAllStackTraces().keySet().stream().forEach((thread) -> {
thread.setContextClassLoader(this.appClassLoader);
});
this.appClazz = this.appClassLoader.loadClass(applicationClass);
final Method method = this.appClazz.getMethod(methodName);
this.appInstance = this.appClazz.newInstance();
method.invoke(this.appInstance);
} | [
"public",
"void",
"startApp",
"(",
"Path",
"applicationFile",
",",
"String",
"applicationClass",
",",
"String",
"methodName",
")",
"throws",
"IOException",
"{",
"try",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Loading : \"",
"+",
"applicationFile",
".",
"toAbsolutePath",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"this",
".",
"defaultClassLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"this",
".",
"appClassLoader",
"=",
"URLClassLoader",
".",
"newInstance",
"(",
"new",
"URL",
"[",
"]",
"{",
"applicationFile",
".",
"toUri",
"(",
")",
".",
"toURL",
"(",
")",
"}",
",",
"this",
".",
"defaultClassLoader",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setContextClassLoader",
"(",
"this",
".",
"appClassLoader",
")",
";",
"Thread",
".",
"getAllStackTraces",
"(",
")",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"(",
"thread",
")",
"-",
">",
"{",
"thread",
".",
"setContextClassLoader",
"(",
"this",
".",
"appClassLoader",
")",
"",
";",
"}",
")",
";",
"this",
".",
"appClazz",
"=",
"this",
".",
"appClassLoader",
".",
"loadClass",
"(",
"applicationClass",
")",
";",
"final",
"Method",
"method",
"=",
"this",
".",
"appClazz",
".",
"getMethod",
"(",
"methodName",
")",
";",
"this",
".",
"appInstance",
"=",
"this",
".",
"appClazz",
".",
"newInstance",
"(",
")",
";",
"method",
".",
"invoke",
"(",
"this",
".",
"appInstance",
")",
";",
"}"
] | Start the application
@param applicationFile The application file (e.g. a JAR)
@param applicationClass The application class (e.g. "de.dimaki.jartest.JarTest")
@param methodName The method to be called (e.g. "start")
@throws IOException In case of an error | [
"Start",
"the",
"application"
] | train | https://github.com/dimaki/refuel/blob/8024ac34f52b33de291d859c3b12fc237783f873/src/main/java/de/dimaki/refuel/Bootstrap.java#L83-L96 |
bwkimmel/jdcp | jdcp-server/src/main/java/ca/eandb/jdcp/server/classmanager/FileClassManager.java | FileClassManager.writeClass | private void writeClass(File directory, String name, ByteBuffer def) {
"""
Writes a class definition.
@param directory The directory under which to write the class
definition.
@param name The fully qualified name of the class.
@param def A <code>ByteBuffer</code> containing the class definition.
"""
writeClass(directory, name, def, computeClassDigest(def));
} | java | private void writeClass(File directory, String name, ByteBuffer def) {
writeClass(directory, name, def, computeClassDigest(def));
} | [
"private",
"void",
"writeClass",
"(",
"File",
"directory",
",",
"String",
"name",
",",
"ByteBuffer",
"def",
")",
"{",
"writeClass",
"(",
"directory",
",",
"name",
",",
"def",
",",
"computeClassDigest",
"(",
"def",
")",
")",
";",
"}"
] | Writes a class definition.
@param directory The directory under which to write the class
definition.
@param name The fully qualified name of the class.
@param def A <code>ByteBuffer</code> containing the class definition. | [
"Writes",
"a",
"class",
"definition",
"."
] | train | https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-server/src/main/java/ca/eandb/jdcp/server/classmanager/FileClassManager.java#L166-L168 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpx/MPXReader.java | MPXReader.populateProjectHeader | private void populateProjectHeader(Record record, ProjectProperties properties) throws MPXJException {
"""
Populates the project header.
@param record MPX record
@param properties project properties
@throws MPXJException
"""
properties.setProjectTitle(record.getString(0));
properties.setCompany(record.getString(1));
properties.setManager(record.getString(2));
properties.setDefaultCalendarName(record.getString(3));
properties.setStartDate(record.getDateTime(4));
properties.setFinishDate(record.getDateTime(5));
properties.setScheduleFrom(record.getScheduleFrom(6));
properties.setCurrentDate(record.getDateTime(7));
properties.setComments(record.getString(8));
properties.setCost(record.getCurrency(9));
properties.setBaselineCost(record.getCurrency(10));
properties.setActualCost(record.getCurrency(11));
properties.setWork(record.getDuration(12));
properties.setBaselineWork(record.getDuration(13));
properties.setActualWork(record.getDuration(14));
properties.setWork2(record.getPercentage(15));
properties.setDuration(record.getDuration(16));
properties.setBaselineDuration(record.getDuration(17));
properties.setActualDuration(record.getDuration(18));
properties.setPercentageComplete(record.getPercentage(19));
properties.setBaselineStart(record.getDateTime(20));
properties.setBaselineFinish(record.getDateTime(21));
properties.setActualStart(record.getDateTime(22));
properties.setActualFinish(record.getDateTime(23));
properties.setStartVariance(record.getDuration(24));
properties.setFinishVariance(record.getDuration(25));
properties.setSubject(record.getString(26));
properties.setAuthor(record.getString(27));
properties.setKeywords(record.getString(28));
} | java | private void populateProjectHeader(Record record, ProjectProperties properties) throws MPXJException
{
properties.setProjectTitle(record.getString(0));
properties.setCompany(record.getString(1));
properties.setManager(record.getString(2));
properties.setDefaultCalendarName(record.getString(3));
properties.setStartDate(record.getDateTime(4));
properties.setFinishDate(record.getDateTime(5));
properties.setScheduleFrom(record.getScheduleFrom(6));
properties.setCurrentDate(record.getDateTime(7));
properties.setComments(record.getString(8));
properties.setCost(record.getCurrency(9));
properties.setBaselineCost(record.getCurrency(10));
properties.setActualCost(record.getCurrency(11));
properties.setWork(record.getDuration(12));
properties.setBaselineWork(record.getDuration(13));
properties.setActualWork(record.getDuration(14));
properties.setWork2(record.getPercentage(15));
properties.setDuration(record.getDuration(16));
properties.setBaselineDuration(record.getDuration(17));
properties.setActualDuration(record.getDuration(18));
properties.setPercentageComplete(record.getPercentage(19));
properties.setBaselineStart(record.getDateTime(20));
properties.setBaselineFinish(record.getDateTime(21));
properties.setActualStart(record.getDateTime(22));
properties.setActualFinish(record.getDateTime(23));
properties.setStartVariance(record.getDuration(24));
properties.setFinishVariance(record.getDuration(25));
properties.setSubject(record.getString(26));
properties.setAuthor(record.getString(27));
properties.setKeywords(record.getString(28));
} | [
"private",
"void",
"populateProjectHeader",
"(",
"Record",
"record",
",",
"ProjectProperties",
"properties",
")",
"throws",
"MPXJException",
"{",
"properties",
".",
"setProjectTitle",
"(",
"record",
".",
"getString",
"(",
"0",
")",
")",
";",
"properties",
".",
"setCompany",
"(",
"record",
".",
"getString",
"(",
"1",
")",
")",
";",
"properties",
".",
"setManager",
"(",
"record",
".",
"getString",
"(",
"2",
")",
")",
";",
"properties",
".",
"setDefaultCalendarName",
"(",
"record",
".",
"getString",
"(",
"3",
")",
")",
";",
"properties",
".",
"setStartDate",
"(",
"record",
".",
"getDateTime",
"(",
"4",
")",
")",
";",
"properties",
".",
"setFinishDate",
"(",
"record",
".",
"getDateTime",
"(",
"5",
")",
")",
";",
"properties",
".",
"setScheduleFrom",
"(",
"record",
".",
"getScheduleFrom",
"(",
"6",
")",
")",
";",
"properties",
".",
"setCurrentDate",
"(",
"record",
".",
"getDateTime",
"(",
"7",
")",
")",
";",
"properties",
".",
"setComments",
"(",
"record",
".",
"getString",
"(",
"8",
")",
")",
";",
"properties",
".",
"setCost",
"(",
"record",
".",
"getCurrency",
"(",
"9",
")",
")",
";",
"properties",
".",
"setBaselineCost",
"(",
"record",
".",
"getCurrency",
"(",
"10",
")",
")",
";",
"properties",
".",
"setActualCost",
"(",
"record",
".",
"getCurrency",
"(",
"11",
")",
")",
";",
"properties",
".",
"setWork",
"(",
"record",
".",
"getDuration",
"(",
"12",
")",
")",
";",
"properties",
".",
"setBaselineWork",
"(",
"record",
".",
"getDuration",
"(",
"13",
")",
")",
";",
"properties",
".",
"setActualWork",
"(",
"record",
".",
"getDuration",
"(",
"14",
")",
")",
";",
"properties",
".",
"setWork2",
"(",
"record",
".",
"getPercentage",
"(",
"15",
")",
")",
";",
"properties",
".",
"setDuration",
"(",
"record",
".",
"getDuration",
"(",
"16",
")",
")",
";",
"properties",
".",
"setBaselineDuration",
"(",
"record",
".",
"getDuration",
"(",
"17",
")",
")",
";",
"properties",
".",
"setActualDuration",
"(",
"record",
".",
"getDuration",
"(",
"18",
")",
")",
";",
"properties",
".",
"setPercentageComplete",
"(",
"record",
".",
"getPercentage",
"(",
"19",
")",
")",
";",
"properties",
".",
"setBaselineStart",
"(",
"record",
".",
"getDateTime",
"(",
"20",
")",
")",
";",
"properties",
".",
"setBaselineFinish",
"(",
"record",
".",
"getDateTime",
"(",
"21",
")",
")",
";",
"properties",
".",
"setActualStart",
"(",
"record",
".",
"getDateTime",
"(",
"22",
")",
")",
";",
"properties",
".",
"setActualFinish",
"(",
"record",
".",
"getDateTime",
"(",
"23",
")",
")",
";",
"properties",
".",
"setStartVariance",
"(",
"record",
".",
"getDuration",
"(",
"24",
")",
")",
";",
"properties",
".",
"setFinishVariance",
"(",
"record",
".",
"getDuration",
"(",
"25",
")",
")",
";",
"properties",
".",
"setSubject",
"(",
"record",
".",
"getString",
"(",
"26",
")",
")",
";",
"properties",
".",
"setAuthor",
"(",
"record",
".",
"getString",
"(",
"27",
")",
")",
";",
"properties",
".",
"setKeywords",
"(",
"record",
".",
"getString",
"(",
"28",
")",
")",
";",
"}"
] | Populates the project header.
@param record MPX record
@param properties project properties
@throws MPXJException | [
"Populates",
"the",
"project",
"header",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXReader.java#L592-L623 |
networknt/light-4j | utility/src/main/java/com/networknt/utility/StringUtils.java | StringUtils.startsWith | private static boolean startsWith(final CharSequence str, final CharSequence prefix, final boolean ignoreCase) {
"""
<p>Check if a CharSequence starts with a specified prefix (optionally case insensitive).</p>
@see java.lang.String#startsWith(String)
@param str the CharSequence to check, may be null
@param prefix the prefix to find, may be null
@param ignoreCase indicates whether the compare should ignore case
(case insensitive) or not.
@return {@code true} if the CharSequence starts with the prefix or
both {@code null}
"""
if (str == null || prefix == null) {
return str == prefix;
}
if (prefix.length() > str.length()) {
return false;
}
return CharSequenceUtils.regionMatches(str, ignoreCase, 0, prefix, 0, prefix.length());
} | java | private static boolean startsWith(final CharSequence str, final CharSequence prefix, final boolean ignoreCase) {
if (str == null || prefix == null) {
return str == prefix;
}
if (prefix.length() > str.length()) {
return false;
}
return CharSequenceUtils.regionMatches(str, ignoreCase, 0, prefix, 0, prefix.length());
} | [
"private",
"static",
"boolean",
"startsWith",
"(",
"final",
"CharSequence",
"str",
",",
"final",
"CharSequence",
"prefix",
",",
"final",
"boolean",
"ignoreCase",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"prefix",
"==",
"null",
")",
"{",
"return",
"str",
"==",
"prefix",
";",
"}",
"if",
"(",
"prefix",
".",
"length",
"(",
")",
">",
"str",
".",
"length",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"CharSequenceUtils",
".",
"regionMatches",
"(",
"str",
",",
"ignoreCase",
",",
"0",
",",
"prefix",
",",
"0",
",",
"prefix",
".",
"length",
"(",
")",
")",
";",
"}"
] | <p>Check if a CharSequence starts with a specified prefix (optionally case insensitive).</p>
@see java.lang.String#startsWith(String)
@param str the CharSequence to check, may be null
@param prefix the prefix to find, may be null
@param ignoreCase indicates whether the compare should ignore case
(case insensitive) or not.
@return {@code true} if the CharSequence starts with the prefix or
both {@code null} | [
"<p",
">",
"Check",
"if",
"a",
"CharSequence",
"starts",
"with",
"a",
"specified",
"prefix",
"(",
"optionally",
"case",
"insensitive",
")",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/StringUtils.java#L826-L834 |
tango-controls/JTango | client/src/main/java/org/tango/client/database/Database.java | Database.setDeviceProperties | @Override
public void setDeviceProperties(final String deviceName, final Map<String, String[]> properties) throws DevFailed {
"""
Set values of device properties. (execute DbPutDeviceProperty on DB device)
@param deviceName
The device name
@param properties
The properties names and their values
@throws DevFailed
"""
cache.setDeviceProperties(deviceName, properties);
} | java | @Override
public void setDeviceProperties(final String deviceName, final Map<String, String[]> properties) throws DevFailed {
cache.setDeviceProperties(deviceName, properties);
} | [
"@",
"Override",
"public",
"void",
"setDeviceProperties",
"(",
"final",
"String",
"deviceName",
",",
"final",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"properties",
")",
"throws",
"DevFailed",
"{",
"cache",
".",
"setDeviceProperties",
"(",
"deviceName",
",",
"properties",
")",
";",
"}"
] | Set values of device properties. (execute DbPutDeviceProperty on DB device)
@param deviceName
The device name
@param properties
The properties names and their values
@throws DevFailed | [
"Set",
"values",
"of",
"device",
"properties",
".",
"(",
"execute",
"DbPutDeviceProperty",
"on",
"DB",
"device",
")"
] | train | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/org/tango/client/database/Database.java#L144-L147 |
jboss/jboss-el-api_spec | src/main/java/javax/el/ELProcessor.java | ELProcessor.getValue | public Object getValue(String expression, Class<?> expectedType) {
"""
Evaluates an EL expression, and coerces the result to the specified type.
@param expression The EL expression to be evaluated.
@param expectedType Specifies the type that the resultant evaluation
will be coerced to.
@return The result of the expression evaluation.
"""
ValueExpression exp = factory.createValueExpression(
elManager.getELContext(),
bracket(expression), expectedType);
return exp.getValue(elManager.getELContext());
} | java | public Object getValue(String expression, Class<?> expectedType) {
ValueExpression exp = factory.createValueExpression(
elManager.getELContext(),
bracket(expression), expectedType);
return exp.getValue(elManager.getELContext());
} | [
"public",
"Object",
"getValue",
"(",
"String",
"expression",
",",
"Class",
"<",
"?",
">",
"expectedType",
")",
"{",
"ValueExpression",
"exp",
"=",
"factory",
".",
"createValueExpression",
"(",
"elManager",
".",
"getELContext",
"(",
")",
",",
"bracket",
"(",
"expression",
")",
",",
"expectedType",
")",
";",
"return",
"exp",
".",
"getValue",
"(",
"elManager",
".",
"getELContext",
"(",
")",
")",
";",
"}"
] | Evaluates an EL expression, and coerces the result to the specified type.
@param expression The EL expression to be evaluated.
@param expectedType Specifies the type that the resultant evaluation
will be coerced to.
@return The result of the expression evaluation. | [
"Evaluates",
"an",
"EL",
"expression",
"and",
"coerces",
"the",
"result",
"to",
"the",
"specified",
"type",
"."
] | train | https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELProcessor.java#L125-L130 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java | SqlConnRunner.count | public int count(Connection conn, Entity where) throws SQLException {
"""
结果的条目数
@param conn 数据库连接对象
@param where 查询条件
@return 复合条件的结果数
@throws SQLException SQL执行异常
"""
checkConn(conn);
final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName());
PreparedStatement ps = null;
try {
ps = dialect.psForCount(conn, query);
return SqlExecutor.query(ps, new NumberHandler()).intValue();
} catch (SQLException e) {
throw e;
} finally {
DbUtil.close(ps);
}
} | java | public int count(Connection conn, Entity where) throws SQLException {
checkConn(conn);
final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName());
PreparedStatement ps = null;
try {
ps = dialect.psForCount(conn, query);
return SqlExecutor.query(ps, new NumberHandler()).intValue();
} catch (SQLException e) {
throw e;
} finally {
DbUtil.close(ps);
}
} | [
"public",
"int",
"count",
"(",
"Connection",
"conn",
",",
"Entity",
"where",
")",
"throws",
"SQLException",
"{",
"checkConn",
"(",
"conn",
")",
";",
"final",
"Query",
"query",
"=",
"new",
"Query",
"(",
"SqlUtil",
".",
"buildConditions",
"(",
"where",
")",
",",
"where",
".",
"getTableName",
"(",
")",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"try",
"{",
"ps",
"=",
"dialect",
".",
"psForCount",
"(",
"conn",
",",
"query",
")",
";",
"return",
"SqlExecutor",
".",
"query",
"(",
"ps",
",",
"new",
"NumberHandler",
"(",
")",
")",
".",
"intValue",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"finally",
"{",
"DbUtil",
".",
"close",
"(",
"ps",
")",
";",
"}",
"}"
] | 结果的条目数
@param conn 数据库连接对象
@param where 查询条件
@return 复合条件的结果数
@throws SQLException SQL执行异常 | [
"结果的条目数"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java#L439-L452 |
jlinn/quartz-redis-jobstore | src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java | AbstractRedisStorage.isActiveInstance | protected boolean isActiveInstance(String instanceId, T jedis) {
"""
Determine if the instance with the given id has been active in the last 4 minutes
@param instanceId the instance to check
@param jedis a thread-safe Redis connection
@return true if the instance with the given id has been active in the last 4 minutes
"""
boolean isActive = ( System.currentTimeMillis() - getLastInstanceActiveTime(instanceId, jedis) < clusterCheckInterval);
if (!isActive) {
removeLastInstanceActiveTime(instanceId, jedis);
}
return isActive;
} | java | protected boolean isActiveInstance(String instanceId, T jedis) {
boolean isActive = ( System.currentTimeMillis() - getLastInstanceActiveTime(instanceId, jedis) < clusterCheckInterval);
if (!isActive) {
removeLastInstanceActiveTime(instanceId, jedis);
}
return isActive;
} | [
"protected",
"boolean",
"isActiveInstance",
"(",
"String",
"instanceId",
",",
"T",
"jedis",
")",
"{",
"boolean",
"isActive",
"=",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"getLastInstanceActiveTime",
"(",
"instanceId",
",",
"jedis",
")",
"<",
"clusterCheckInterval",
")",
";",
"if",
"(",
"!",
"isActive",
")",
"{",
"removeLastInstanceActiveTime",
"(",
"instanceId",
",",
"jedis",
")",
";",
"}",
"return",
"isActive",
";",
"}"
] | Determine if the instance with the given id has been active in the last 4 minutes
@param instanceId the instance to check
@param jedis a thread-safe Redis connection
@return true if the instance with the given id has been active in the last 4 minutes | [
"Determine",
"if",
"the",
"instance",
"with",
"the",
"given",
"id",
"has",
"been",
"active",
"in",
"the",
"last",
"4",
"minutes"
] | train | https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java#L657-L663 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/jassimp/GVRNewWrapperProvider.java | GVRNewWrapperProvider.wrapColor | @Override
public AiColor wrapColor(ByteBuffer buffer, int offset) {
"""
Wraps a RGBA color.
<p>
A color consists of 4 float values (r,g,b,a) starting from offset
@param buffer
the buffer to wrap
@param offset
the offset into buffer
@return the wrapped color
"""
AiColor color = new AiColor(buffer, offset);
return color;
} | java | @Override
public AiColor wrapColor(ByteBuffer buffer, int offset) {
AiColor color = new AiColor(buffer, offset);
return color;
} | [
"@",
"Override",
"public",
"AiColor",
"wrapColor",
"(",
"ByteBuffer",
"buffer",
",",
"int",
"offset",
")",
"{",
"AiColor",
"color",
"=",
"new",
"AiColor",
"(",
"buffer",
",",
"offset",
")",
";",
"return",
"color",
";",
"}"
] | Wraps a RGBA color.
<p>
A color consists of 4 float values (r,g,b,a) starting from offset
@param buffer
the buffer to wrap
@param offset
the offset into buffer
@return the wrapped color | [
"Wraps",
"a",
"RGBA",
"color",
".",
"<p",
">"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/jassimp/GVRNewWrapperProvider.java#L23-L27 |
code4everything/util | src/main/java/com/zhazhapan/util/NetUtils.java | NetUtils.evaluate | public static String evaluate(String xpath, String html) throws XPathExpressionException,
ParserConfigurationException {
"""
XPath解析HTML内容
@param xpath xpath表达式
@param html html内容
@return 解析结果
@throws XPathExpressionException 异常
@throws ParserConfigurationException 异常
"""
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document document = new DomSerializer(new CleanerProperties()).createDOM(tn);
XPath xPath = XPathFactory.newInstance().newXPath();
return xPath.evaluate(xpath, document);
} | java | public static String evaluate(String xpath, String html) throws XPathExpressionException,
ParserConfigurationException {
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document document = new DomSerializer(new CleanerProperties()).createDOM(tn);
XPath xPath = XPathFactory.newInstance().newXPath();
return xPath.evaluate(xpath, document);
} | [
"public",
"static",
"String",
"evaluate",
"(",
"String",
"xpath",
",",
"String",
"html",
")",
"throws",
"XPathExpressionException",
",",
"ParserConfigurationException",
"{",
"HtmlCleaner",
"hc",
"=",
"new",
"HtmlCleaner",
"(",
")",
";",
"TagNode",
"tn",
"=",
"hc",
".",
"clean",
"(",
"html",
")",
";",
"Document",
"document",
"=",
"new",
"DomSerializer",
"(",
"new",
"CleanerProperties",
"(",
")",
")",
".",
"createDOM",
"(",
"tn",
")",
";",
"XPath",
"xPath",
"=",
"XPathFactory",
".",
"newInstance",
"(",
")",
".",
"newXPath",
"(",
")",
";",
"return",
"xPath",
".",
"evaluate",
"(",
"xpath",
",",
"document",
")",
";",
"}"
] | XPath解析HTML内容
@param xpath xpath表达式
@param html html内容
@return 解析结果
@throws XPathExpressionException 异常
@throws ParserConfigurationException 异常 | [
"XPath解析HTML内容"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/NetUtils.java#L696-L703 |
sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityIntrospector.java | EntityIntrospector.initEntityMetadata | private void initEntityMetadata(ProjectedEntity projectedEntity) {
"""
Initializes the metadata using the given {@link ProjectedEntity} annotation.
@param projectedEntity
the {@link ProjectedEntity} annotation.
"""
String kind = projectedEntity.kind();
if (kind.trim().length() == 0) {
String message = String.format("Class %s requires a non-blank Kind", entityClass.getName());
throw new EntityManagerException(message);
}
entityMetadata = new EntityMetadata(entityClass, kind, true);
} | java | private void initEntityMetadata(ProjectedEntity projectedEntity) {
String kind = projectedEntity.kind();
if (kind.trim().length() == 0) {
String message = String.format("Class %s requires a non-blank Kind", entityClass.getName());
throw new EntityManagerException(message);
}
entityMetadata = new EntityMetadata(entityClass, kind, true);
} | [
"private",
"void",
"initEntityMetadata",
"(",
"ProjectedEntity",
"projectedEntity",
")",
"{",
"String",
"kind",
"=",
"projectedEntity",
".",
"kind",
"(",
")",
";",
"if",
"(",
"kind",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Class %s requires a non-blank Kind\"",
",",
"entityClass",
".",
"getName",
"(",
")",
")",
";",
"throw",
"new",
"EntityManagerException",
"(",
"message",
")",
";",
"}",
"entityMetadata",
"=",
"new",
"EntityMetadata",
"(",
"entityClass",
",",
"kind",
",",
"true",
")",
";",
"}"
] | Initializes the metadata using the given {@link ProjectedEntity} annotation.
@param projectedEntity
the {@link ProjectedEntity} annotation. | [
"Initializes",
"the",
"metadata",
"using",
"the",
"given",
"{",
"@link",
"ProjectedEntity",
"}",
"annotation",
"."
] | train | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityIntrospector.java#L191-L198 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java | HashtableOnDisk.findEntry | private HashtableEntry findEntry(EvictionTableEntry evt, int retrieveMode, long current, int tableid)
throws IOException,
EOFException,
FileManagerException,
ClassNotFoundException,
HashtableOnDiskException {
"""
************************************************************************
Search disk for the indicated entry and return it and its
predecessor if any.
***********************************************************************
"""
int hashcode = evt.hashcode;
long previous = 0;
long next = 0;
int hash = 0;
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
while (current != 0) {
// System.out.println("current:"+current+" next:"+next);
if (hash == hashcode) { // hash the same?
//
// Need to finish collision resolution and maybe return the object
// System.out.println("hashcode matched, hash:"+ hashcode);
HashtableEntry entry = readEntry2(current, next, hash, previous, retrieveMode, !CHECK_EXPIRED, tableid, null, evt); //493877
if (entry != null) { // 493877 if entry is NOT null, the entry is found.
return entry;
}
}
collisions++;
//
// Try for next object in bucket
//
previous = current;
current = next;
if (current != 0) { // optimize - don't read if we know we can't use it
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
}
}
//
// If we fall through we did not find it
//
return null;
} | java | private HashtableEntry findEntry(EvictionTableEntry evt, int retrieveMode, long current, int tableid)
throws IOException,
EOFException,
FileManagerException,
ClassNotFoundException,
HashtableOnDiskException {
int hashcode = evt.hashcode;
long previous = 0;
long next = 0;
int hash = 0;
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
while (current != 0) {
// System.out.println("current:"+current+" next:"+next);
if (hash == hashcode) { // hash the same?
//
// Need to finish collision resolution and maybe return the object
// System.out.println("hashcode matched, hash:"+ hashcode);
HashtableEntry entry = readEntry2(current, next, hash, previous, retrieveMode, !CHECK_EXPIRED, tableid, null, evt); //493877
if (entry != null) { // 493877 if entry is NOT null, the entry is found.
return entry;
}
}
collisions++;
//
// Try for next object in bucket
//
previous = current;
current = next;
if (current != 0) { // optimize - don't read if we know we can't use it
initReadBuffer(current);
next = headerin.readLong();
hash = headerin.readInt();
}
}
//
// If we fall through we did not find it
//
return null;
} | [
"private",
"HashtableEntry",
"findEntry",
"(",
"EvictionTableEntry",
"evt",
",",
"int",
"retrieveMode",
",",
"long",
"current",
",",
"int",
"tableid",
")",
"throws",
"IOException",
",",
"EOFException",
",",
"FileManagerException",
",",
"ClassNotFoundException",
",",
"HashtableOnDiskException",
"{",
"int",
"hashcode",
"=",
"evt",
".",
"hashcode",
";",
"long",
"previous",
"=",
"0",
";",
"long",
"next",
"=",
"0",
";",
"int",
"hash",
"=",
"0",
";",
"initReadBuffer",
"(",
"current",
")",
";",
"next",
"=",
"headerin",
".",
"readLong",
"(",
")",
";",
"hash",
"=",
"headerin",
".",
"readInt",
"(",
")",
";",
"while",
"(",
"current",
"!=",
"0",
")",
"{",
"// System.out.println(\"current:\"+current+\" next:\"+next);",
"if",
"(",
"hash",
"==",
"hashcode",
")",
"{",
"// hash the same?",
"// \t\t",
"// Need to finish collision resolution and maybe return the object",
"// System.out.println(\"hashcode matched, hash:\"+ hashcode); ",
"HashtableEntry",
"entry",
"=",
"readEntry2",
"(",
"current",
",",
"next",
",",
"hash",
",",
"previous",
",",
"retrieveMode",
",",
"!",
"CHECK_EXPIRED",
",",
"tableid",
",",
"null",
",",
"evt",
")",
";",
"//493877",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"// 493877 if entry is NOT null, the entry is found.",
"return",
"entry",
";",
"}",
"}",
"collisions",
"++",
";",
"//",
"// Try for next object in bucket",
"//",
"previous",
"=",
"current",
";",
"current",
"=",
"next",
";",
"if",
"(",
"current",
"!=",
"0",
")",
"{",
"// optimize - don't read if we know we can't use it",
"initReadBuffer",
"(",
"current",
")",
";",
"next",
"=",
"headerin",
".",
"readLong",
"(",
")",
";",
"hash",
"=",
"headerin",
".",
"readInt",
"(",
")",
";",
"}",
"}",
"//",
"// If we fall through we did not find it",
"//",
"return",
"null",
";",
"}"
] | ************************************************************************
Search disk for the indicated entry and return it and its
predecessor if any.
*********************************************************************** | [
"************************************************************************",
"Search",
"disk",
"for",
"the",
"indicated",
"entry",
"and",
"return",
"it",
"and",
"its",
"predecessor",
"if",
"any",
".",
"***********************************************************************"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java#L2144-L2192 |
op4j/op4j | src/main/java/org/op4j/functions/FnString.java | FnString.matchAndExtract | public static final Function<String,String> matchAndExtract(final String regex, final int group) {
"""
<p>
Matches the entire target String against the specified regular expression and extracts
the specified group from it (as specified by <tt>java.util.regex.Matcher</tt>.
</p>
<p>
Regular expressions must conform to the <tt>java.util.regex.Pattern</tt> format.
</p>
@param regex the regular expression to match against
@param group the group number to be extracted
@return the substring matching the group number
"""
return new MatchAndExtract(regex, group);
} | java | public static final Function<String,String> matchAndExtract(final String regex, final int group) {
return new MatchAndExtract(regex, group);
} | [
"public",
"static",
"final",
"Function",
"<",
"String",
",",
"String",
">",
"matchAndExtract",
"(",
"final",
"String",
"regex",
",",
"final",
"int",
"group",
")",
"{",
"return",
"new",
"MatchAndExtract",
"(",
"regex",
",",
"group",
")",
";",
"}"
] | <p>
Matches the entire target String against the specified regular expression and extracts
the specified group from it (as specified by <tt>java.util.regex.Matcher</tt>.
</p>
<p>
Regular expressions must conform to the <tt>java.util.regex.Pattern</tt> format.
</p>
@param regex the regular expression to match against
@param group the group number to be extracted
@return the substring matching the group number | [
"<p",
">",
"Matches",
"the",
"entire",
"target",
"String",
"against",
"the",
"specified",
"regular",
"expression",
"and",
"extracts",
"the",
"specified",
"group",
"from",
"it",
"(",
"as",
"specified",
"by",
"<tt",
">",
"java",
".",
"util",
".",
"regex",
".",
"Matcher<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Regular",
"expressions",
"must",
"conform",
"to",
"the",
"<tt",
">",
"java",
".",
"util",
".",
"regex",
".",
"Pattern<",
"/",
"tt",
">",
"format",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/FnString.java#L1985-L1987 |
Netflix/spectator | spectator-api/src/main/java/com/netflix/spectator/impl/Scheduler.java | Scheduler.newThreadFactory | private static ThreadFactory newThreadFactory(final String id) {
"""
Create a thread factory using thread names based on the id. All threads will
be configured as daemon threads.
"""
return new ThreadFactory() {
private final AtomicInteger next = new AtomicInteger();
@Override public Thread newThread(Runnable r) {
final String name = "spectator-" + id + "-" + next.getAndIncrement();
final Thread t = new Thread(r, name);
t.setDaemon(true);
return t;
}
};
} | java | private static ThreadFactory newThreadFactory(final String id) {
return new ThreadFactory() {
private final AtomicInteger next = new AtomicInteger();
@Override public Thread newThread(Runnable r) {
final String name = "spectator-" + id + "-" + next.getAndIncrement();
final Thread t = new Thread(r, name);
t.setDaemon(true);
return t;
}
};
} | [
"private",
"static",
"ThreadFactory",
"newThreadFactory",
"(",
"final",
"String",
"id",
")",
"{",
"return",
"new",
"ThreadFactory",
"(",
")",
"{",
"private",
"final",
"AtomicInteger",
"next",
"=",
"new",
"AtomicInteger",
"(",
")",
";",
"@",
"Override",
"public",
"Thread",
"newThread",
"(",
"Runnable",
"r",
")",
"{",
"final",
"String",
"name",
"=",
"\"spectator-\"",
"+",
"id",
"+",
"\"-\"",
"+",
"next",
".",
"getAndIncrement",
"(",
")",
";",
"final",
"Thread",
"t",
"=",
"new",
"Thread",
"(",
"r",
",",
"name",
")",
";",
"t",
".",
"setDaemon",
"(",
"true",
")",
";",
"return",
"t",
";",
"}",
"}",
";",
"}"
] | Create a thread factory using thread names based on the id. All threads will
be configured as daemon threads. | [
"Create",
"a",
"thread",
"factory",
"using",
"thread",
"names",
"based",
"on",
"the",
"id",
".",
"All",
"threads",
"will",
"be",
"configured",
"as",
"daemon",
"threads",
"."
] | train | https://github.com/Netflix/spectator/blob/259318252770de3bad581b85adff187d8f2c6537/spectator-api/src/main/java/com/netflix/spectator/impl/Scheduler.java#L88-L99 |
weld/core | impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironmentFactory.java | BeanDeployerEnvironmentFactory.newConcurrentEnvironment | public static BeanDeployerEnvironment newConcurrentEnvironment(BeanManagerImpl manager) {
"""
Creates a new threadsafe BeanDeployerEnvironment instance. These instances are used by {@link ConcurrentBeanDeployer} during bootstrap.
"""
return new BeanDeployerEnvironment(Collections.newSetFromMap(new ConcurrentHashMap<SlimAnnotatedTypeContext<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<Class<?>, Boolean>()), SetMultimap.<Class<?>, AbstractClassBean<?>> newConcurrentSetMultimap(),
Collections.newSetFromMap(new ConcurrentHashMap<ProducerField<?, ?>, Boolean>()),
SetMultimap.<WeldMethodKey, ProducerMethod<?, ?>> newConcurrentSetMultimap(),
Collections.newSetFromMap(new ConcurrentHashMap<RIBean<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<ObserverInitializationContext<?, ?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<DisposalMethod<?, ?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<DisposalMethod<?, ?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<DecoratorImpl<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<InterceptorImpl<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<Type, Boolean>()), manager);
} | java | public static BeanDeployerEnvironment newConcurrentEnvironment(BeanManagerImpl manager) {
return new BeanDeployerEnvironment(Collections.newSetFromMap(new ConcurrentHashMap<SlimAnnotatedTypeContext<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<Class<?>, Boolean>()), SetMultimap.<Class<?>, AbstractClassBean<?>> newConcurrentSetMultimap(),
Collections.newSetFromMap(new ConcurrentHashMap<ProducerField<?, ?>, Boolean>()),
SetMultimap.<WeldMethodKey, ProducerMethod<?, ?>> newConcurrentSetMultimap(),
Collections.newSetFromMap(new ConcurrentHashMap<RIBean<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<ObserverInitializationContext<?, ?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<DisposalMethod<?, ?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<DisposalMethod<?, ?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<DecoratorImpl<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<InterceptorImpl<?>, Boolean>()),
Collections.newSetFromMap(new ConcurrentHashMap<Type, Boolean>()), manager);
} | [
"public",
"static",
"BeanDeployerEnvironment",
"newConcurrentEnvironment",
"(",
"BeanManagerImpl",
"manager",
")",
"{",
"return",
"new",
"BeanDeployerEnvironment",
"(",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"SlimAnnotatedTypeContext",
"<",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"Class",
"<",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"SetMultimap",
".",
"<",
"Class",
"<",
"?",
">",
",",
"AbstractClassBean",
"<",
"?",
">",
">",
"newConcurrentSetMultimap",
"(",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"ProducerField",
"<",
"?",
",",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"SetMultimap",
".",
"<",
"WeldMethodKey",
",",
"ProducerMethod",
"<",
"?",
",",
"?",
">",
">",
"newConcurrentSetMultimap",
"(",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"RIBean",
"<",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"ObserverInitializationContext",
"<",
"?",
",",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"DisposalMethod",
"<",
"?",
",",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"DisposalMethod",
"<",
"?",
",",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"DecoratorImpl",
"<",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"InterceptorImpl",
"<",
"?",
">",
",",
"Boolean",
">",
"(",
")",
")",
",",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"ConcurrentHashMap",
"<",
"Type",
",",
"Boolean",
">",
"(",
")",
")",
",",
"manager",
")",
";",
"}"
] | Creates a new threadsafe BeanDeployerEnvironment instance. These instances are used by {@link ConcurrentBeanDeployer} during bootstrap. | [
"Creates",
"a",
"new",
"threadsafe",
"BeanDeployerEnvironment",
"instance",
".",
"These",
"instances",
"are",
"used",
"by",
"{"
] | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironmentFactory.java#L47-L59 |
micrometer-metrics/micrometer | micrometer-core/src/main/java/io/micrometer/core/instrument/Metrics.java | Metrics.gaugeMapSize | @Nullable
public static <T extends Map<?, ?>> T gaugeMapSize(String name, Iterable<Tag> tags, T map) {
"""
Register a gauge that reports the size of the {@link java.util.Map}. The registration
will keep a weak reference to the collection so it will not prevent garbage collection.
The collection implementation used should be thread safe. Note that calling
{@link java.util.Map#size()} can be expensive for some collection implementations
and should be considered before registering.
@param name Name of the gauge being registered.
@param tags Sequence of dimensions for breaking down the name.
@param map Thread-safe implementation of {@link Map} used to access the value.
@param <T> The type of the state object from which the gauge value is extracted.
@return The number that was passed in so the registration can be done as part of an assignment
statement.
"""
return globalRegistry.gaugeMapSize(name, tags, map);
} | java | @Nullable
public static <T extends Map<?, ?>> T gaugeMapSize(String name, Iterable<Tag> tags, T map) {
return globalRegistry.gaugeMapSize(name, tags, map);
} | [
"@",
"Nullable",
"public",
"static",
"<",
"T",
"extends",
"Map",
"<",
"?",
",",
"?",
">",
">",
"T",
"gaugeMapSize",
"(",
"String",
"name",
",",
"Iterable",
"<",
"Tag",
">",
"tags",
",",
"T",
"map",
")",
"{",
"return",
"globalRegistry",
".",
"gaugeMapSize",
"(",
"name",
",",
"tags",
",",
"map",
")",
";",
"}"
] | Register a gauge that reports the size of the {@link java.util.Map}. The registration
will keep a weak reference to the collection so it will not prevent garbage collection.
The collection implementation used should be thread safe. Note that calling
{@link java.util.Map#size()} can be expensive for some collection implementations
and should be considered before registering.
@param name Name of the gauge being registered.
@param tags Sequence of dimensions for breaking down the name.
@param map Thread-safe implementation of {@link Map} used to access the value.
@param <T> The type of the state object from which the gauge value is extracted.
@return The number that was passed in so the registration can be done as part of an assignment
statement. | [
"Register",
"a",
"gauge",
"that",
"reports",
"the",
"size",
"of",
"the",
"{",
"@link",
"java",
".",
"util",
".",
"Map",
"}",
".",
"The",
"registration",
"will",
"keep",
"a",
"weak",
"reference",
"to",
"the",
"collection",
"so",
"it",
"will",
"not",
"prevent",
"garbage",
"collection",
".",
"The",
"collection",
"implementation",
"used",
"should",
"be",
"thread",
"safe",
".",
"Note",
"that",
"calling",
"{",
"@link",
"java",
".",
"util",
".",
"Map#size",
"()",
"}",
"can",
"be",
"expensive",
"for",
"some",
"collection",
"implementations",
"and",
"should",
"be",
"considered",
"before",
"registering",
"."
] | train | https://github.com/micrometer-metrics/micrometer/blob/127fa3265325cc894f368312ed8890b76a055d88/micrometer-core/src/main/java/io/micrometer/core/instrument/Metrics.java#L233-L236 |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3d.java | Path3d.quadTo | public void quadTo(double x1, double y1, double z1, double x2, double y2, double z2) {
"""
Adds a curved segment, defined by two new points, to the path by
drawing a Quadratic curve that intersects both the current
coordinates and the specified coordinates {@code (x2,y2,z2)},
using the specified point {@code (x1,y1,z1)} as a quadratic
parametric control point.
All coordinates are specified in double precision.
@param x1 the X coordinate of the quadratic control point
@param y1 the Y coordinate of the quadratic control point
@param z1 the Z coordinate of the quadratic control point
@param x2 the X coordinate of the final end point
@param y2 the Y coordinate of the final end point
@param z2 the Z coordinate of the final end point
"""
ensureSlots(true, 6);
this.types[this.numTypesProperty.get()] = PathElementType.QUAD_TO;
this.numTypesProperty.set(this.numTypesProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(x1);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(y1);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(z1);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(x2);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(y2);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(z2);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.isEmptyProperty = null;
this.isPolylineProperty.set(false);
this.graphicalBounds = null;
this.logicalBounds = null;
} | java | public void quadTo(double x1, double y1, double z1, double x2, double y2, double z2) {
ensureSlots(true, 6);
this.types[this.numTypesProperty.get()] = PathElementType.QUAD_TO;
this.numTypesProperty.set(this.numTypesProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(x1);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(y1);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(z1);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(x2);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(y2);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()].set(z2);
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.isEmptyProperty = null;
this.isPolylineProperty.set(false);
this.graphicalBounds = null;
this.logicalBounds = null;
} | [
"public",
"void",
"quadTo",
"(",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"z1",
",",
"double",
"x2",
",",
"double",
"y2",
",",
"double",
"z2",
")",
"{",
"ensureSlots",
"(",
"true",
",",
"6",
")",
";",
"this",
".",
"types",
"[",
"this",
".",
"numTypesProperty",
".",
"get",
"(",
")",
"]",
"=",
"PathElementType",
".",
"QUAD_TO",
";",
"this",
".",
"numTypesProperty",
".",
"set",
"(",
"this",
".",
"numTypesProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"coordsProperty",
"[",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"]",
".",
"set",
"(",
"x1",
")",
";",
"this",
".",
"numCoordsProperty",
".",
"set",
"(",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"coordsProperty",
"[",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"]",
".",
"set",
"(",
"y1",
")",
";",
"this",
".",
"numCoordsProperty",
".",
"set",
"(",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"coordsProperty",
"[",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"]",
".",
"set",
"(",
"z1",
")",
";",
"this",
".",
"numCoordsProperty",
".",
"set",
"(",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"coordsProperty",
"[",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"]",
".",
"set",
"(",
"x2",
")",
";",
"this",
".",
"numCoordsProperty",
".",
"set",
"(",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"coordsProperty",
"[",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"]",
".",
"set",
"(",
"y2",
")",
";",
"this",
".",
"numCoordsProperty",
".",
"set",
"(",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"coordsProperty",
"[",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"]",
".",
"set",
"(",
"z2",
")",
";",
"this",
".",
"numCoordsProperty",
".",
"set",
"(",
"this",
".",
"numCoordsProperty",
".",
"get",
"(",
")",
"+",
"1",
")",
";",
"this",
".",
"isEmptyProperty",
"=",
"null",
";",
"this",
".",
"isPolylineProperty",
".",
"set",
"(",
"false",
")",
";",
"this",
".",
"graphicalBounds",
"=",
"null",
";",
"this",
".",
"logicalBounds",
"=",
"null",
";",
"}"
] | Adds a curved segment, defined by two new points, to the path by
drawing a Quadratic curve that intersects both the current
coordinates and the specified coordinates {@code (x2,y2,z2)},
using the specified point {@code (x1,y1,z1)} as a quadratic
parametric control point.
All coordinates are specified in double precision.
@param x1 the X coordinate of the quadratic control point
@param y1 the Y coordinate of the quadratic control point
@param z1 the Z coordinate of the quadratic control point
@param x2 the X coordinate of the final end point
@param y2 the Y coordinate of the final end point
@param z2 the Z coordinate of the final end point | [
"Adds",
"a",
"curved",
"segment",
"defined",
"by",
"two",
"new",
"points",
"to",
"the",
"path",
"by",
"drawing",
"a",
"Quadratic",
"curve",
"that",
"intersects",
"both",
"the",
"current",
"coordinates",
"and",
"the",
"specified",
"coordinates",
"{",
"@code",
"(",
"x2",
"y2",
"z2",
")",
"}",
"using",
"the",
"specified",
"point",
"{",
"@code",
"(",
"x1",
"y1",
"z1",
")",
"}",
"as",
"a",
"quadratic",
"parametric",
"control",
"point",
".",
"All",
"coordinates",
"are",
"specified",
"in",
"double",
"precision",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3d.java#L2140-L2169 |
mgm-tp/jfunk | jfunk-data-generator/src/main/java/com/mgmtp/jfunk/data/generator/constraint/ConstraintFactory.java | ConstraintFactory.putToCache | private Constraint putToCache(final String id, final Constraint object) {
"""
Puts the given constraint object into the cache using the key id. If an existing
DummyConstraint object is found in the table, the reference will be set to the constraint and
the constraint will not be put into the table.
"""
Constraint c = this.map.put(id, object);
if (c instanceof DummyConstraint) {
((DummyConstraint) c).constraint = object;
return null;
}
return c;
} | java | private Constraint putToCache(final String id, final Constraint object) {
Constraint c = this.map.put(id, object);
if (c instanceof DummyConstraint) {
((DummyConstraint) c).constraint = object;
return null;
}
return c;
} | [
"private",
"Constraint",
"putToCache",
"(",
"final",
"String",
"id",
",",
"final",
"Constraint",
"object",
")",
"{",
"Constraint",
"c",
"=",
"this",
".",
"map",
".",
"put",
"(",
"id",
",",
"object",
")",
";",
"if",
"(",
"c",
"instanceof",
"DummyConstraint",
")",
"{",
"(",
"(",
"DummyConstraint",
")",
"c",
")",
".",
"constraint",
"=",
"object",
";",
"return",
"null",
";",
"}",
"return",
"c",
";",
"}"
] | Puts the given constraint object into the cache using the key id. If an existing
DummyConstraint object is found in the table, the reference will be set to the constraint and
the constraint will not be put into the table. | [
"Puts",
"the",
"given",
"constraint",
"object",
"into",
"the",
"cache",
"using",
"the",
"key",
"id",
".",
"If",
"an",
"existing",
"DummyConstraint",
"object",
"is",
"found",
"in",
"the",
"table",
"the",
"reference",
"will",
"be",
"set",
"to",
"the",
"constraint",
"and",
"the",
"constraint",
"will",
"not",
"be",
"put",
"into",
"the",
"table",
"."
] | train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-data-generator/src/main/java/com/mgmtp/jfunk/data/generator/constraint/ConstraintFactory.java#L182-L189 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/common/dataobjects/DataframeMatrix.java | DataframeMatrix.parseRecord | public static RealVector parseRecord(Record r, Map<Object, Integer> featureIdsReference) {
"""
Parses a single Record and converts it to RealVector by using an already
existing mapping between feature names and column ids.
@param r
@param featureIdsReference
@return
"""
if(featureIdsReference.isEmpty()) {
throw new IllegalArgumentException("The featureIdsReference map should not be empty.");
}
int d = featureIdsReference.size();
//create an Map-backed vector only if we have available info about configuration.
RealVector v = (storageEngine != null)?new MapRealVector(d):new OpenMapRealVector(d);
boolean addConstantColumn = featureIdsReference.containsKey(Dataframe.COLUMN_NAME_CONSTANT);
if(addConstantColumn) {
v.setEntry(0, 1.0); //add the constant column
}
for(Map.Entry<Object, Object> entry : r.getX().entrySet()) {
Object feature = entry.getKey();
Double value = TypeInference.toDouble(entry.getValue());
if(value!=null) {
Integer featureId = featureIdsReference.get(feature);
if(featureId!=null) {//if the feature exists
v.setEntry(featureId, value);
}
}
else {
//else the X matrix maintains the 0.0 default value
}
}
return v;
} | java | public static RealVector parseRecord(Record r, Map<Object, Integer> featureIdsReference) {
if(featureIdsReference.isEmpty()) {
throw new IllegalArgumentException("The featureIdsReference map should not be empty.");
}
int d = featureIdsReference.size();
//create an Map-backed vector only if we have available info about configuration.
RealVector v = (storageEngine != null)?new MapRealVector(d):new OpenMapRealVector(d);
boolean addConstantColumn = featureIdsReference.containsKey(Dataframe.COLUMN_NAME_CONSTANT);
if(addConstantColumn) {
v.setEntry(0, 1.0); //add the constant column
}
for(Map.Entry<Object, Object> entry : r.getX().entrySet()) {
Object feature = entry.getKey();
Double value = TypeInference.toDouble(entry.getValue());
if(value!=null) {
Integer featureId = featureIdsReference.get(feature);
if(featureId!=null) {//if the feature exists
v.setEntry(featureId, value);
}
}
else {
//else the X matrix maintains the 0.0 default value
}
}
return v;
} | [
"public",
"static",
"RealVector",
"parseRecord",
"(",
"Record",
"r",
",",
"Map",
"<",
"Object",
",",
"Integer",
">",
"featureIdsReference",
")",
"{",
"if",
"(",
"featureIdsReference",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The featureIdsReference map should not be empty.\"",
")",
";",
"}",
"int",
"d",
"=",
"featureIdsReference",
".",
"size",
"(",
")",
";",
"//create an Map-backed vector only if we have available info about configuration.",
"RealVector",
"v",
"=",
"(",
"storageEngine",
"!=",
"null",
")",
"?",
"new",
"MapRealVector",
"(",
"d",
")",
":",
"new",
"OpenMapRealVector",
"(",
"d",
")",
";",
"boolean",
"addConstantColumn",
"=",
"featureIdsReference",
".",
"containsKey",
"(",
"Dataframe",
".",
"COLUMN_NAME_CONSTANT",
")",
";",
"if",
"(",
"addConstantColumn",
")",
"{",
"v",
".",
"setEntry",
"(",
"0",
",",
"1.0",
")",
";",
"//add the constant column",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"r",
".",
"getX",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"Object",
"feature",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Double",
"value",
"=",
"TypeInference",
".",
"toDouble",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"Integer",
"featureId",
"=",
"featureIdsReference",
".",
"get",
"(",
"feature",
")",
";",
"if",
"(",
"featureId",
"!=",
"null",
")",
"{",
"//if the feature exists",
"v",
".",
"setEntry",
"(",
"featureId",
",",
"value",
")",
";",
"}",
"}",
"else",
"{",
"//else the X matrix maintains the 0.0 default value",
"}",
"}",
"return",
"v",
";",
"}"
] | Parses a single Record and converts it to RealVector by using an already
existing mapping between feature names and column ids.
@param r
@param featureIdsReference
@return | [
"Parses",
"a",
"single",
"Record",
"and",
"converts",
"it",
"to",
"RealVector",
"by",
"using",
"an",
"already",
"existing",
"mapping",
"between",
"feature",
"names",
"and",
"column",
"ids",
"."
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/common/dataobjects/DataframeMatrix.java#L251-L282 |
pmwmedia/tinylog | tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java | TinylogLoggingProvider.createLogEntry | private LogEntry createLogEntry(final StackTraceElement stackTraceElement, final String tag, final int tagIndex, final Level level,
final Throwable exception, final Object obj, final Object[] arguments) {
"""
Creates a new log entry.
@param stackTraceElement
Optional stack trace element of caller
@param tag
Tag name if issued from a tagged logger
@param tagIndex
Index of tag
@param level
Severity level
@param exception
Caught exception or throwable to log
@param obj
Message to log
@param arguments
Arguments for message
@return Filled log entry
"""
Collection<LogEntryValue> required = requiredLogEntryValues[tagIndex][level.ordinal()];
Timestamp timestamp = RuntimeProvider.createTimestamp();
Thread thread = required.contains(LogEntryValue.THREAD) ? Thread.currentThread() : null;
Map<String, String> context = required.contains(LogEntryValue.CONTEXT) ? this.context.getMapping() : null;
String className;
String methodName;
String fileName;
int lineNumber;
if (stackTraceElement == null) {
className = null;
methodName = null;
fileName = null;
lineNumber = -1;
} else {
className = stackTraceElement.getClassName();
methodName = stackTraceElement.getMethodName();
fileName = stackTraceElement.getFileName();
lineNumber = stackTraceElement.getLineNumber();
}
String message;
if (arguments == null || arguments.length == 0) {
Object evaluatedObject = obj instanceof Supplier<?> ? ((Supplier<?>) obj).get() : obj;
message = evaluatedObject == null ? null : evaluatedObject.toString();
} else {
message = formatter.format((String) obj, arguments);
}
return new LogEntry(timestamp, thread, context, className, methodName, fileName, lineNumber, tag, level, message, exception);
} | java | private LogEntry createLogEntry(final StackTraceElement stackTraceElement, final String tag, final int tagIndex, final Level level,
final Throwable exception, final Object obj, final Object[] arguments) {
Collection<LogEntryValue> required = requiredLogEntryValues[tagIndex][level.ordinal()];
Timestamp timestamp = RuntimeProvider.createTimestamp();
Thread thread = required.contains(LogEntryValue.THREAD) ? Thread.currentThread() : null;
Map<String, String> context = required.contains(LogEntryValue.CONTEXT) ? this.context.getMapping() : null;
String className;
String methodName;
String fileName;
int lineNumber;
if (stackTraceElement == null) {
className = null;
methodName = null;
fileName = null;
lineNumber = -1;
} else {
className = stackTraceElement.getClassName();
methodName = stackTraceElement.getMethodName();
fileName = stackTraceElement.getFileName();
lineNumber = stackTraceElement.getLineNumber();
}
String message;
if (arguments == null || arguments.length == 0) {
Object evaluatedObject = obj instanceof Supplier<?> ? ((Supplier<?>) obj).get() : obj;
message = evaluatedObject == null ? null : evaluatedObject.toString();
} else {
message = formatter.format((String) obj, arguments);
}
return new LogEntry(timestamp, thread, context, className, methodName, fileName, lineNumber, tag, level, message, exception);
} | [
"private",
"LogEntry",
"createLogEntry",
"(",
"final",
"StackTraceElement",
"stackTraceElement",
",",
"final",
"String",
"tag",
",",
"final",
"int",
"tagIndex",
",",
"final",
"Level",
"level",
",",
"final",
"Throwable",
"exception",
",",
"final",
"Object",
"obj",
",",
"final",
"Object",
"[",
"]",
"arguments",
")",
"{",
"Collection",
"<",
"LogEntryValue",
">",
"required",
"=",
"requiredLogEntryValues",
"[",
"tagIndex",
"]",
"[",
"level",
".",
"ordinal",
"(",
")",
"]",
";",
"Timestamp",
"timestamp",
"=",
"RuntimeProvider",
".",
"createTimestamp",
"(",
")",
";",
"Thread",
"thread",
"=",
"required",
".",
"contains",
"(",
"LogEntryValue",
".",
"THREAD",
")",
"?",
"Thread",
".",
"currentThread",
"(",
")",
":",
"null",
";",
"Map",
"<",
"String",
",",
"String",
">",
"context",
"=",
"required",
".",
"contains",
"(",
"LogEntryValue",
".",
"CONTEXT",
")",
"?",
"this",
".",
"context",
".",
"getMapping",
"(",
")",
":",
"null",
";",
"String",
"className",
";",
"String",
"methodName",
";",
"String",
"fileName",
";",
"int",
"lineNumber",
";",
"if",
"(",
"stackTraceElement",
"==",
"null",
")",
"{",
"className",
"=",
"null",
";",
"methodName",
"=",
"null",
";",
"fileName",
"=",
"null",
";",
"lineNumber",
"=",
"-",
"1",
";",
"}",
"else",
"{",
"className",
"=",
"stackTraceElement",
".",
"getClassName",
"(",
")",
";",
"methodName",
"=",
"stackTraceElement",
".",
"getMethodName",
"(",
")",
";",
"fileName",
"=",
"stackTraceElement",
".",
"getFileName",
"(",
")",
";",
"lineNumber",
"=",
"stackTraceElement",
".",
"getLineNumber",
"(",
")",
";",
"}",
"String",
"message",
";",
"if",
"(",
"arguments",
"==",
"null",
"||",
"arguments",
".",
"length",
"==",
"0",
")",
"{",
"Object",
"evaluatedObject",
"=",
"obj",
"instanceof",
"Supplier",
"<",
"?",
">",
"?",
"(",
"(",
"Supplier",
"<",
"?",
">",
")",
"obj",
")",
".",
"get",
"(",
")",
":",
"obj",
";",
"message",
"=",
"evaluatedObject",
"==",
"null",
"?",
"null",
":",
"evaluatedObject",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"message",
"=",
"formatter",
".",
"format",
"(",
"(",
"String",
")",
"obj",
",",
"arguments",
")",
";",
"}",
"return",
"new",
"LogEntry",
"(",
"timestamp",
",",
"thread",
",",
"context",
",",
"className",
",",
"methodName",
",",
"fileName",
",",
"lineNumber",
",",
"tag",
",",
"level",
",",
"message",
",",
"exception",
")",
";",
"}"
] | Creates a new log entry.
@param stackTraceElement
Optional stack trace element of caller
@param tag
Tag name if issued from a tagged logger
@param tagIndex
Index of tag
@param level
Severity level
@param exception
Caught exception or throwable to log
@param obj
Message to log
@param arguments
Arguments for message
@return Filled log entry | [
"Creates",
"a",
"new",
"log",
"entry",
"."
] | train | https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L352-L385 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/JobAgentsInner.java | JobAgentsInner.createOrUpdate | public JobAgentInner createOrUpdate(String resourceGroupName, String serverName, String jobAgentName, JobAgentInner parameters) {
"""
Creates or updates a job agent.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param jobAgentName The name of the job agent to be created or updated.
@param parameters The requested job agent resource state.
@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 JobAgentInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, parameters).toBlocking().last().body();
} | java | public JobAgentInner createOrUpdate(String resourceGroupName, String serverName, String jobAgentName, JobAgentInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, parameters).toBlocking().last().body();
} | [
"public",
"JobAgentInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"jobAgentName",
",",
"JobAgentInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"jobAgentName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a job agent.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param jobAgentName The name of the job agent to be created or updated.
@param parameters The requested job agent resource state.
@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 JobAgentInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"job",
"agent",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/JobAgentsInner.java#L333-L335 |
webpagebytes/general-cms-plugins | src/main/java/com/webpagebytes/plugins/WPBSQLDataStoreDao.java | WPBSQLDataStoreDao.setObjectProperty | public void setObjectProperty(Object object, String property, Object propertyValue) throws WPBSerializerException {
"""
/*
Given an instance of an object that has a particular property this method will set the object property with the
provided value. It assumes that the object has the setter method for the specified interface
@param object The object instance on which the property will be set
@param property The property name that will be set. This means that there is a setter public method defined for the
object instance
@param propertyValue The new value for the property that will be set
@throws WBSerializerException If the object property was not set with success
"""
try
{
PropertyDescriptor pd = new PropertyDescriptor(property, object.getClass());
pd.getWriteMethod().invoke(object, propertyValue);
} catch (Exception e)
{
log.log(Level.SEVERE, "cannot setObjectProperty on " + property, e);
throw new WPBSerializerException("Cannot set property for object", e);
}
} | java | public void setObjectProperty(Object object, String property, Object propertyValue) throws WPBSerializerException
{
try
{
PropertyDescriptor pd = new PropertyDescriptor(property, object.getClass());
pd.getWriteMethod().invoke(object, propertyValue);
} catch (Exception e)
{
log.log(Level.SEVERE, "cannot setObjectProperty on " + property, e);
throw new WPBSerializerException("Cannot set property for object", e);
}
} | [
"public",
"void",
"setObjectProperty",
"(",
"Object",
"object",
",",
"String",
"property",
",",
"Object",
"propertyValue",
")",
"throws",
"WPBSerializerException",
"{",
"try",
"{",
"PropertyDescriptor",
"pd",
"=",
"new",
"PropertyDescriptor",
"(",
"property",
",",
"object",
".",
"getClass",
"(",
")",
")",
";",
"pd",
".",
"getWriteMethod",
"(",
")",
".",
"invoke",
"(",
"object",
",",
"propertyValue",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"cannot setObjectProperty on \"",
"+",
"property",
",",
"e",
")",
";",
"throw",
"new",
"WPBSerializerException",
"(",
"\"Cannot set property for object\"",
",",
"e",
")",
";",
"}",
"}"
] | /*
Given an instance of an object that has a particular property this method will set the object property with the
provided value. It assumes that the object has the setter method for the specified interface
@param object The object instance on which the property will be set
@param property The property name that will be set. This means that there is a setter public method defined for the
object instance
@param propertyValue The new value for the property that will be set
@throws WBSerializerException If the object property was not set with success | [
"/",
"*",
"Given",
"an",
"instance",
"of",
"an",
"object",
"that",
"has",
"a",
"particular",
"property",
"this",
"method",
"will",
"set",
"the",
"object",
"property",
"with",
"the",
"provided",
"value",
".",
"It",
"assumes",
"that",
"the",
"object",
"has",
"the",
"setter",
"method",
"for",
"the",
"specified",
"interface"
] | train | https://github.com/webpagebytes/general-cms-plugins/blob/610dbaa49d92695be642d1888b30bc4671e1b9c1/src/main/java/com/webpagebytes/plugins/WPBSQLDataStoreDao.java#L112-L124 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/drawable/ImageHeaderReaderAbstract.java | ImageHeaderReaderAbstract.checkSkippedError | protected static void checkSkippedError(long skipped, int instead) throws IOException {
"""
Skipped message error.
@param skipped The skipped value.
@param instead The instead value.
@throws IOException If not skipped the right number of bytes.
"""
if (skipped != instead)
{
throw new IOException(MESSAGE_SKIPPED + skipped + MESSAGE_BYTES_INSTEAD_OF + instead);
}
} | java | protected static void checkSkippedError(long skipped, int instead) throws IOException
{
if (skipped != instead)
{
throw new IOException(MESSAGE_SKIPPED + skipped + MESSAGE_BYTES_INSTEAD_OF + instead);
}
} | [
"protected",
"static",
"void",
"checkSkippedError",
"(",
"long",
"skipped",
",",
"int",
"instead",
")",
"throws",
"IOException",
"{",
"if",
"(",
"skipped",
"!=",
"instead",
")",
"{",
"throw",
"new",
"IOException",
"(",
"MESSAGE_SKIPPED",
"+",
"skipped",
"+",
"MESSAGE_BYTES_INSTEAD_OF",
"+",
"instead",
")",
";",
"}",
"}"
] | Skipped message error.
@param skipped The skipped value.
@param instead The instead value.
@throws IOException If not skipped the right number of bytes. | [
"Skipped",
"message",
"error",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/drawable/ImageHeaderReaderAbstract.java#L88-L94 |
BotMill/fb-botmill | src/main/java/co/aurasphere/botmill/fb/FbBotMillServlet.java | FbBotMillServlet.doPost | @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
"""
Specifies how to handle a POST request. It parses the request as a
{@link MessengerCallback} object. If the request is not a
MessengerCallback, then the FbBotMillServlet logs an error and does
nothing, otherwise it will forward the request to all registered bots in
order to let them process the callbacks.
@param req
the req
@param resp
the resp
@throws ServletException
the servlet exception
@throws IOException
Signals that an I/O exception has occurred.
"""
logger.trace("POST received!");
MessengerCallback callback = new MessengerCallback();
// Extrapolates and logs the JSON for debugging.
String json = readerToString(req.getReader());
logger.debug("JSON input: " + json);
// Parses the request as a MessengerCallback.
try {
callback = FbBotMillJsonUtils.fromJson(json, MessengerCallback.class);
} catch (Exception e) {
logger.error("Error during MessengerCallback parsing: ", e);
return;
}
// If the received POST is a MessengerCallback, it forwards the last
// envelope of all the callbacks received to the registered bots.
if (callback != null) {
List<MessengerCallbackEntry> callbackEntries = callback.getEntry();
if (callbackEntries != null) {
for (MessengerCallbackEntry entry : callbackEntries) {
List<MessageEnvelope> envelopes = entry.getMessaging();
if (envelopes != null) {
MessageEnvelope lastEnvelope = envelopes.get(envelopes.size() - 1);
IncomingToOutgoingMessageHandler.getInstance().process(lastEnvelope);
}
}
}
}
// Always set to ok.
resp.setStatus(HttpServletResponse.SC_OK);
} | java | @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
logger.trace("POST received!");
MessengerCallback callback = new MessengerCallback();
// Extrapolates and logs the JSON for debugging.
String json = readerToString(req.getReader());
logger.debug("JSON input: " + json);
// Parses the request as a MessengerCallback.
try {
callback = FbBotMillJsonUtils.fromJson(json, MessengerCallback.class);
} catch (Exception e) {
logger.error("Error during MessengerCallback parsing: ", e);
return;
}
// If the received POST is a MessengerCallback, it forwards the last
// envelope of all the callbacks received to the registered bots.
if (callback != null) {
List<MessengerCallbackEntry> callbackEntries = callback.getEntry();
if (callbackEntries != null) {
for (MessengerCallbackEntry entry : callbackEntries) {
List<MessageEnvelope> envelopes = entry.getMessaging();
if (envelopes != null) {
MessageEnvelope lastEnvelope = envelopes.get(envelopes.size() - 1);
IncomingToOutgoingMessageHandler.getInstance().process(lastEnvelope);
}
}
}
}
// Always set to ok.
resp.setStatus(HttpServletResponse.SC_OK);
} | [
"@",
"Override",
"protected",
"void",
"doPost",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"logger",
".",
"trace",
"(",
"\"POST received!\"",
")",
";",
"MessengerCallback",
"callback",
"=",
"new",
"MessengerCallback",
"(",
")",
";",
"// Extrapolates and logs the JSON for debugging.\r",
"String",
"json",
"=",
"readerToString",
"(",
"req",
".",
"getReader",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"JSON input: \"",
"+",
"json",
")",
";",
"// Parses the request as a MessengerCallback.\r",
"try",
"{",
"callback",
"=",
"FbBotMillJsonUtils",
".",
"fromJson",
"(",
"json",
",",
"MessengerCallback",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error during MessengerCallback parsing: \"",
",",
"e",
")",
";",
"return",
";",
"}",
"// If the received POST is a MessengerCallback, it forwards the last\r",
"// envelope of all the callbacks received to the registered bots.\r",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"List",
"<",
"MessengerCallbackEntry",
">",
"callbackEntries",
"=",
"callback",
".",
"getEntry",
"(",
")",
";",
"if",
"(",
"callbackEntries",
"!=",
"null",
")",
"{",
"for",
"(",
"MessengerCallbackEntry",
"entry",
":",
"callbackEntries",
")",
"{",
"List",
"<",
"MessageEnvelope",
">",
"envelopes",
"=",
"entry",
".",
"getMessaging",
"(",
")",
";",
"if",
"(",
"envelopes",
"!=",
"null",
")",
"{",
"MessageEnvelope",
"lastEnvelope",
"=",
"envelopes",
".",
"get",
"(",
"envelopes",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"IncomingToOutgoingMessageHandler",
".",
"getInstance",
"(",
")",
".",
"process",
"(",
"lastEnvelope",
")",
";",
"}",
"}",
"}",
"}",
"// Always set to ok.\r",
"resp",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_OK",
")",
";",
"}"
] | Specifies how to handle a POST request. It parses the request as a
{@link MessengerCallback} object. If the request is not a
MessengerCallback, then the FbBotMillServlet logs an error and does
nothing, otherwise it will forward the request to all registered bots in
order to let them process the callbacks.
@param req
the req
@param resp
the resp
@throws ServletException
the servlet exception
@throws IOException
Signals that an I/O exception has occurred. | [
"Specifies",
"how",
"to",
"handle",
"a",
"POST",
"request",
".",
"It",
"parses",
"the",
"request",
"as",
"a",
"{",
"@link",
"MessengerCallback",
"}",
"object",
".",
"If",
"the",
"request",
"is",
"not",
"a",
"MessengerCallback",
"then",
"the",
"FbBotMillServlet",
"logs",
"an",
"error",
"and",
"does",
"nothing",
"otherwise",
"it",
"will",
"forward",
"the",
"request",
"to",
"all",
"registered",
"bots",
"in",
"order",
"to",
"let",
"them",
"process",
"the",
"callbacks",
"."
] | train | https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/FbBotMillServlet.java#L149-L184 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/util/handler/channel/ChannelUpdateHandler.java | ChannelUpdateHandler.handleChannelCategory | private void handleChannelCategory(JsonNode jsonChannel) {
"""
Handles a channel category update.
@param jsonChannel The channel data.
"""
long channelCategoryId = jsonChannel.get("id").asLong();
api.getChannelCategoryById(channelCategoryId).map(ChannelCategoryImpl.class::cast).ifPresent(channel -> {
boolean oldNsfwFlag = channel.isNsfw();
boolean newNsfwFlag = jsonChannel.get("nsfw").asBoolean();
if (oldNsfwFlag != newNsfwFlag) {
channel.setNsfwFlag(newNsfwFlag);
ServerChannelChangeNsfwFlagEvent event =
new ServerChannelChangeNsfwFlagEventImpl(channel, newNsfwFlag, oldNsfwFlag);
api.getEventDispatcher().dispatchServerChannelChangeNsfwFlagEvent(
(DispatchQueueSelector) channel.getServer(), channel, channel.getServer(), null, event);
}
});
} | java | private void handleChannelCategory(JsonNode jsonChannel) {
long channelCategoryId = jsonChannel.get("id").asLong();
api.getChannelCategoryById(channelCategoryId).map(ChannelCategoryImpl.class::cast).ifPresent(channel -> {
boolean oldNsfwFlag = channel.isNsfw();
boolean newNsfwFlag = jsonChannel.get("nsfw").asBoolean();
if (oldNsfwFlag != newNsfwFlag) {
channel.setNsfwFlag(newNsfwFlag);
ServerChannelChangeNsfwFlagEvent event =
new ServerChannelChangeNsfwFlagEventImpl(channel, newNsfwFlag, oldNsfwFlag);
api.getEventDispatcher().dispatchServerChannelChangeNsfwFlagEvent(
(DispatchQueueSelector) channel.getServer(), channel, channel.getServer(), null, event);
}
});
} | [
"private",
"void",
"handleChannelCategory",
"(",
"JsonNode",
"jsonChannel",
")",
"{",
"long",
"channelCategoryId",
"=",
"jsonChannel",
".",
"get",
"(",
"\"id\"",
")",
".",
"asLong",
"(",
")",
";",
"api",
".",
"getChannelCategoryById",
"(",
"channelCategoryId",
")",
".",
"map",
"(",
"ChannelCategoryImpl",
".",
"class",
"::",
"cast",
")",
".",
"ifPresent",
"(",
"channel",
"->",
"{",
"boolean",
"oldNsfwFlag",
"=",
"channel",
".",
"isNsfw",
"(",
")",
";",
"boolean",
"newNsfwFlag",
"=",
"jsonChannel",
".",
"get",
"(",
"\"nsfw\"",
")",
".",
"asBoolean",
"(",
")",
";",
"if",
"(",
"oldNsfwFlag",
"!=",
"newNsfwFlag",
")",
"{",
"channel",
".",
"setNsfwFlag",
"(",
"newNsfwFlag",
")",
";",
"ServerChannelChangeNsfwFlagEvent",
"event",
"=",
"new",
"ServerChannelChangeNsfwFlagEventImpl",
"(",
"channel",
",",
"newNsfwFlag",
",",
"oldNsfwFlag",
")",
";",
"api",
".",
"getEventDispatcher",
"(",
")",
".",
"dispatchServerChannelChangeNsfwFlagEvent",
"(",
"(",
"DispatchQueueSelector",
")",
"channel",
".",
"getServer",
"(",
")",
",",
"channel",
",",
"channel",
".",
"getServer",
"(",
")",
",",
"null",
",",
"event",
")",
";",
"}",
"}",
")",
";",
"}"
] | Handles a channel category update.
@param jsonChannel The channel data. | [
"Handles",
"a",
"channel",
"category",
"update",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/util/handler/channel/ChannelUpdateHandler.java#L251-L265 |
ManfredTremmel/gwt-bean-validators | mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/util/PhoneNumberUtil.java | PhoneNumberUtil.formatDin5008National | public final String formatDin5008National(final String pphoneNumber, final String pcountryCode) {
"""
format phone number in DIN 5008 national format.
@param pphoneNumber phone number to format
@param pcountryCode iso code of country
@return formated phone number as String
"""
return this.formatDin5008National(this.parsePhoneNumber(pphoneNumber, pcountryCode));
} | java | public final String formatDin5008National(final String pphoneNumber, final String pcountryCode) {
return this.formatDin5008National(this.parsePhoneNumber(pphoneNumber, pcountryCode));
} | [
"public",
"final",
"String",
"formatDin5008National",
"(",
"final",
"String",
"pphoneNumber",
",",
"final",
"String",
"pcountryCode",
")",
"{",
"return",
"this",
".",
"formatDin5008National",
"(",
"this",
".",
"parsePhoneNumber",
"(",
"pphoneNumber",
",",
"pcountryCode",
")",
")",
";",
"}"
] | format phone number in DIN 5008 national format.
@param pphoneNumber phone number to format
@param pcountryCode iso code of country
@return formated phone number as String | [
"format",
"phone",
"number",
"in",
"DIN",
"5008",
"national",
"format",
"."
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/util/PhoneNumberUtil.java#L951-L953 |
trustathsh/ironcommon | src/main/java/de/hshannover/f4/trust/ironcommon/properties/Properties.java | Properties.getInt | public int getInt(String propertyPath, int defaultValue) {
"""
Get the int-value from the property path. If the property path does not
exist, the default value is returned.
@param propertyPath
Example: foo.bar.key
@param defaultValue
is returned when the propertyPath does not exist
@return the value for the given propertyPath
"""
Object o = getValue(propertyPath, defaultValue);
return Integer.parseInt(o.toString());
} | java | public int getInt(String propertyPath, int defaultValue) {
Object o = getValue(propertyPath, defaultValue);
return Integer.parseInt(o.toString());
} | [
"public",
"int",
"getInt",
"(",
"String",
"propertyPath",
",",
"int",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getValue",
"(",
"propertyPath",
",",
"defaultValue",
")",
";",
"return",
"Integer",
".",
"parseInt",
"(",
"o",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Get the int-value from the property path. If the property path does not
exist, the default value is returned.
@param propertyPath
Example: foo.bar.key
@param defaultValue
is returned when the propertyPath does not exist
@return the value for the given propertyPath | [
"Get",
"the",
"int",
"-",
"value",
"from",
"the",
"property",
"path",
".",
"If",
"the",
"property",
"path",
"does",
"not",
"exist",
"the",
"default",
"value",
"is",
"returned",
"."
] | train | https://github.com/trustathsh/ironcommon/blob/fee589a9300ab16744ca12fafae4357dd18c9fcb/src/main/java/de/hshannover/f4/trust/ironcommon/properties/Properties.java#L280-L283 |
alipay/sofa-rpc | extension-impl/fault-tolerance/src/main/java/com/alipay/sofa/rpc/common/utils/CalculateUtils.java | CalculateUtils.divide | public static double divide(long numerator, long denominator, int scale) {
"""
计算比率。计算结果四舍五入。
@param numerator 分子
@param denominator 分母
@param scale 保留小数点后位数
@return 比率
"""
BigDecimal numeratorBd = new BigDecimal(numerator);
BigDecimal denominatorBd = new BigDecimal(denominator);
return numeratorBd.divide(denominatorBd, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
} | java | public static double divide(long numerator, long denominator, int scale) {
BigDecimal numeratorBd = new BigDecimal(numerator);
BigDecimal denominatorBd = new BigDecimal(denominator);
return numeratorBd.divide(denominatorBd, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
} | [
"public",
"static",
"double",
"divide",
"(",
"long",
"numerator",
",",
"long",
"denominator",
",",
"int",
"scale",
")",
"{",
"BigDecimal",
"numeratorBd",
"=",
"new",
"BigDecimal",
"(",
"numerator",
")",
";",
"BigDecimal",
"denominatorBd",
"=",
"new",
"BigDecimal",
"(",
"denominator",
")",
";",
"return",
"numeratorBd",
".",
"divide",
"(",
"denominatorBd",
",",
"scale",
",",
"BigDecimal",
".",
"ROUND_HALF_UP",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] | 计算比率。计算结果四舍五入。
@param numerator 分子
@param denominator 分母
@param scale 保留小数点后位数
@return 比率 | [
"计算比率。计算结果四舍五入。"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/fault-tolerance/src/main/java/com/alipay/sofa/rpc/common/utils/CalculateUtils.java#L38-L42 |
motown-io/motown | chargingstation-configuration/view-model/src/main/java/io/motown/chargingstationconfiguration/viewmodel/domain/DomainService.java | DomainService.getEvse | public Evse getEvse(Long chargingStationTypeId, Long id) {
"""
Find an evse based on its id.
@param chargingStationTypeId charging station identifier.
@param id the id of the evse to find.
@return the evse.
"""
ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId);
return getEvseById(chargingStationType, id);
} | java | public Evse getEvse(Long chargingStationTypeId, Long id) {
ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId);
return getEvseById(chargingStationType, id);
} | [
"public",
"Evse",
"getEvse",
"(",
"Long",
"chargingStationTypeId",
",",
"Long",
"id",
")",
"{",
"ChargingStationType",
"chargingStationType",
"=",
"chargingStationTypeRepository",
".",
"findOne",
"(",
"chargingStationTypeId",
")",
";",
"return",
"getEvseById",
"(",
"chargingStationType",
",",
"id",
")",
";",
"}"
] | Find an evse based on its id.
@param chargingStationTypeId charging station identifier.
@param id the id of the evse to find.
@return the evse. | [
"Find",
"an",
"evse",
"based",
"on",
"its",
"id",
"."
] | train | https://github.com/motown-io/motown/blob/783ccda7c28b273a529ddd47defe8673b1ea365b/chargingstation-configuration/view-model/src/main/java/io/motown/chargingstationconfiguration/viewmodel/domain/DomainService.java#L292-L296 |
CenturyLinkCloud/clc-java-sdk | sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java | AutoscalePolicyService.setAutoscalePolicyOnServer | public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
Server... servers
) {
"""
set autoscale policy on servers
@param autoscalePolicy autoscale policy
@param servers servers
@return OperationFuture wrapper for servers
"""
return setAutoscalePolicyOnServer(autoscalePolicy, Arrays.asList(servers));
} | java | public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
Server... servers
) {
return setAutoscalePolicyOnServer(autoscalePolicy, Arrays.asList(servers));
} | [
"public",
"OperationFuture",
"<",
"List",
"<",
"Server",
">",
">",
"setAutoscalePolicyOnServer",
"(",
"AutoscalePolicy",
"autoscalePolicy",
",",
"Server",
"...",
"servers",
")",
"{",
"return",
"setAutoscalePolicyOnServer",
"(",
"autoscalePolicy",
",",
"Arrays",
".",
"asList",
"(",
"servers",
")",
")",
";",
"}"
] | set autoscale policy on servers
@param autoscalePolicy autoscale policy
@param servers servers
@return OperationFuture wrapper for servers | [
"set",
"autoscale",
"policy",
"on",
"servers"
] | train | https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java#L121-L126 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java | PersistenceBrokerImpl.linkOneToOne | public void linkOneToOne(Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean insert) {
"""
Assign FK value of main object with PK values of the reference object.
@param obj real object with reference (proxy) object (or real object with set FK values on insert)
@param cld {@link ClassDescriptor} of the real object
@param rds An {@link ObjectReferenceDescriptor} of real object.
@param insert Show if "linking" is done while insert or update.
"""
storeAndLinkOneToOne(true, obj, cld, rds, true);
} | java | public void linkOneToOne(Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean insert)
{
storeAndLinkOneToOne(true, obj, cld, rds, true);
} | [
"public",
"void",
"linkOneToOne",
"(",
"Object",
"obj",
",",
"ClassDescriptor",
"cld",
",",
"ObjectReferenceDescriptor",
"rds",
",",
"boolean",
"insert",
")",
"{",
"storeAndLinkOneToOne",
"(",
"true",
",",
"obj",
",",
"cld",
",",
"rds",
",",
"true",
")",
";",
"}"
] | Assign FK value of main object with PK values of the reference object.
@param obj real object with reference (proxy) object (or real object with set FK values on insert)
@param cld {@link ClassDescriptor} of the real object
@param rds An {@link ObjectReferenceDescriptor} of real object.
@param insert Show if "linking" is done while insert or update. | [
"Assign",
"FK",
"value",
"of",
"main",
"object",
"with",
"PK",
"values",
"of",
"the",
"reference",
"object",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java#L1299-L1302 |
pressgang-ccms/PressGangCCMSBuilder | src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookXMLPreProcessor.java | DocBookXMLPreProcessor.processTopicAdditionalInfo | public void processTopicAdditionalInfo(final BuildData buildData, final SpecTopic specTopic,
final Document document) throws BuildProcessingException {
"""
Adds some debug information and links to the end of the topic
"""
// First check if we should even bother processing any additional info based on build data
if (!shouldAddAdditionalInfo(buildData, specTopic)) return;
final List<Node> invalidNodes = XMLUtilities.getChildNodes(document.getDocumentElement(), "section");
// Only add injections if the topic doesn't contain any invalid nodes. The reason for this is that adding any links to topics
// that contain <section> will cause the XML to become invalid. Unfortunately there isn't any way around this.
if (invalidNodes == null || invalidNodes.size() == 0) {
final Element rootEle = getRootAdditionalInfoElement(document, document.getDocumentElement());
if (buildData.getBuildOptions().getInsertEditorLinks() && specTopic.getTopicType() != TopicType.AUTHOR_GROUP) {
processTopicEditorLinks(buildData, specTopic, document, rootEle);
}
// Only include a bugzilla link for normal topics
if (buildData.getBuildOptions().getInsertBugLinks() && specTopic.getTopicType() == TopicType.NORMAL) {
processTopicBugLink(buildData, specTopic, document, rootEle);
}
}
} | java | public void processTopicAdditionalInfo(final BuildData buildData, final SpecTopic specTopic,
final Document document) throws BuildProcessingException {
// First check if we should even bother processing any additional info based on build data
if (!shouldAddAdditionalInfo(buildData, specTopic)) return;
final List<Node> invalidNodes = XMLUtilities.getChildNodes(document.getDocumentElement(), "section");
// Only add injections if the topic doesn't contain any invalid nodes. The reason for this is that adding any links to topics
// that contain <section> will cause the XML to become invalid. Unfortunately there isn't any way around this.
if (invalidNodes == null || invalidNodes.size() == 0) {
final Element rootEle = getRootAdditionalInfoElement(document, document.getDocumentElement());
if (buildData.getBuildOptions().getInsertEditorLinks() && specTopic.getTopicType() != TopicType.AUTHOR_GROUP) {
processTopicEditorLinks(buildData, specTopic, document, rootEle);
}
// Only include a bugzilla link for normal topics
if (buildData.getBuildOptions().getInsertBugLinks() && specTopic.getTopicType() == TopicType.NORMAL) {
processTopicBugLink(buildData, specTopic, document, rootEle);
}
}
} | [
"public",
"void",
"processTopicAdditionalInfo",
"(",
"final",
"BuildData",
"buildData",
",",
"final",
"SpecTopic",
"specTopic",
",",
"final",
"Document",
"document",
")",
"throws",
"BuildProcessingException",
"{",
"// First check if we should even bother processing any additional info based on build data",
"if",
"(",
"!",
"shouldAddAdditionalInfo",
"(",
"buildData",
",",
"specTopic",
")",
")",
"return",
";",
"final",
"List",
"<",
"Node",
">",
"invalidNodes",
"=",
"XMLUtilities",
".",
"getChildNodes",
"(",
"document",
".",
"getDocumentElement",
"(",
")",
",",
"\"section\"",
")",
";",
"// Only add injections if the topic doesn't contain any invalid nodes. The reason for this is that adding any links to topics",
"// that contain <section> will cause the XML to become invalid. Unfortunately there isn't any way around this.",
"if",
"(",
"invalidNodes",
"==",
"null",
"||",
"invalidNodes",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"final",
"Element",
"rootEle",
"=",
"getRootAdditionalInfoElement",
"(",
"document",
",",
"document",
".",
"getDocumentElement",
"(",
")",
")",
";",
"if",
"(",
"buildData",
".",
"getBuildOptions",
"(",
")",
".",
"getInsertEditorLinks",
"(",
")",
"&&",
"specTopic",
".",
"getTopicType",
"(",
")",
"!=",
"TopicType",
".",
"AUTHOR_GROUP",
")",
"{",
"processTopicEditorLinks",
"(",
"buildData",
",",
"specTopic",
",",
"document",
",",
"rootEle",
")",
";",
"}",
"// Only include a bugzilla link for normal topics",
"if",
"(",
"buildData",
".",
"getBuildOptions",
"(",
")",
".",
"getInsertBugLinks",
"(",
")",
"&&",
"specTopic",
".",
"getTopicType",
"(",
")",
"==",
"TopicType",
".",
"NORMAL",
")",
"{",
"processTopicBugLink",
"(",
"buildData",
",",
"specTopic",
",",
"document",
",",
"rootEle",
")",
";",
"}",
"}",
"}"
] | Adds some debug information and links to the end of the topic | [
"Adds",
"some",
"debug",
"information",
"and",
"links",
"to",
"the",
"end",
"of",
"the",
"topic"
] | train | https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/DocBookXMLPreProcessor.java#L383-L404 |
bsblabs/embed-for-vaadin | com.bsb.common.vaadin.embed/src/main/java/com/bsb/common/vaadin/embed/util/PropertiesHelper.java | PropertiesHelper.getIntProperty | public int getIntProperty(String key, int defaultValue) {
"""
Returns the int value for the specified property. If no such key is found,
returns the <tt>defaultValue</tt> instead.
@param key the key of the property
@param defaultValue the default value if no such property is found
@return an int value
@see Properties#getProperty(String, String)
"""
final String value = properties.getProperty(key, String.valueOf(defaultValue));
return Integer.valueOf(value);
} | java | public int getIntProperty(String key, int defaultValue) {
final String value = properties.getProperty(key, String.valueOf(defaultValue));
return Integer.valueOf(value);
} | [
"public",
"int",
"getIntProperty",
"(",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"final",
"String",
"value",
"=",
"properties",
".",
"getProperty",
"(",
"key",
",",
"String",
".",
"valueOf",
"(",
"defaultValue",
")",
")",
";",
"return",
"Integer",
".",
"valueOf",
"(",
"value",
")",
";",
"}"
] | Returns the int value for the specified property. If no such key is found,
returns the <tt>defaultValue</tt> instead.
@param key the key of the property
@param defaultValue the default value if no such property is found
@return an int value
@see Properties#getProperty(String, String) | [
"Returns",
"the",
"int",
"value",
"for",
"the",
"specified",
"property",
".",
"If",
"no",
"such",
"key",
"is",
"found",
"returns",
"the",
"<tt",
">",
"defaultValue<",
"/",
"tt",
">",
"instead",
"."
] | train | https://github.com/bsblabs/embed-for-vaadin/blob/f902e70def56ab54d287d2600f9c6eef9e66c225/com.bsb.common.vaadin.embed/src/main/java/com/bsb/common/vaadin/embed/util/PropertiesHelper.java#L65-L68 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/InstanceInfo.java | InstanceInfo.of | public static InstanceInfo of(
InstanceId instanceId,
MachineTypeId machineType,
AttachedDisk disk,
NetworkInterface networkInterface) {
"""
Returns an {@code InstanceInfo} object given the instance identity, the machine type, a disk to
attach to the instance and a network interface. {@code disk} must be a boot disk (i.e. {@link
AttachedDisk.AttachedDiskConfiguration#boot()} returns {@code true}).
"""
return newBuilder(instanceId, machineType)
.setAttachedDisks(ImmutableList.of(disk))
.setNetworkInterfaces(ImmutableList.of(networkInterface))
.build();
} | java | public static InstanceInfo of(
InstanceId instanceId,
MachineTypeId machineType,
AttachedDisk disk,
NetworkInterface networkInterface) {
return newBuilder(instanceId, machineType)
.setAttachedDisks(ImmutableList.of(disk))
.setNetworkInterfaces(ImmutableList.of(networkInterface))
.build();
} | [
"public",
"static",
"InstanceInfo",
"of",
"(",
"InstanceId",
"instanceId",
",",
"MachineTypeId",
"machineType",
",",
"AttachedDisk",
"disk",
",",
"NetworkInterface",
"networkInterface",
")",
"{",
"return",
"newBuilder",
"(",
"instanceId",
",",
"machineType",
")",
".",
"setAttachedDisks",
"(",
"ImmutableList",
".",
"of",
"(",
"disk",
")",
")",
".",
"setNetworkInterfaces",
"(",
"ImmutableList",
".",
"of",
"(",
"networkInterface",
")",
")",
".",
"build",
"(",
")",
";",
"}"
] | Returns an {@code InstanceInfo} object given the instance identity, the machine type, a disk to
attach to the instance and a network interface. {@code disk} must be a boot disk (i.e. {@link
AttachedDisk.AttachedDiskConfiguration#boot()} returns {@code true}). | [
"Returns",
"an",
"{"
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/InstanceInfo.java#L645-L654 |
mlhartme/mork | src/main/java/net/oneandone/mork/grammar/Ebnf.java | Ebnf.translate | public static Grammar translate(Rule[] rules, StringArrayList symbolTable) throws ActionException {
"""
helper symbols are added without gaps, starting with freeHelper.
"""
int i;
Ebnf builder;
Grammar tmp;
Grammar buffer;
int firstHelper;
int lastHelper;
firstHelper = symbolTable.size();
buffer = new Grammar(rules[0].getLeft(), symbolTable);
builder = new Ebnf(firstHelper);
for (i = 0; i < rules.length; i++) {
tmp = (Grammar) rules[i].getRight().visit(builder);
buffer.addProduction(new int[]{rules[i].getLeft(), tmp.getStart()});
buffer.addProductions(tmp);
buffer.expandSymbol(tmp.getStart());
buffer.removeProductions(tmp.getStart());
}
lastHelper = builder.getHelper() - 1;
buffer.removeDuplicateSymbols(firstHelper, lastHelper);
buffer.removeDuplicateRules();
buffer.packSymbols(firstHelper, lastHelper + 1);
return buffer;
} | java | public static Grammar translate(Rule[] rules, StringArrayList symbolTable) throws ActionException {
int i;
Ebnf builder;
Grammar tmp;
Grammar buffer;
int firstHelper;
int lastHelper;
firstHelper = symbolTable.size();
buffer = new Grammar(rules[0].getLeft(), symbolTable);
builder = new Ebnf(firstHelper);
for (i = 0; i < rules.length; i++) {
tmp = (Grammar) rules[i].getRight().visit(builder);
buffer.addProduction(new int[]{rules[i].getLeft(), tmp.getStart()});
buffer.addProductions(tmp);
buffer.expandSymbol(tmp.getStart());
buffer.removeProductions(tmp.getStart());
}
lastHelper = builder.getHelper() - 1;
buffer.removeDuplicateSymbols(firstHelper, lastHelper);
buffer.removeDuplicateRules();
buffer.packSymbols(firstHelper, lastHelper + 1);
return buffer;
} | [
"public",
"static",
"Grammar",
"translate",
"(",
"Rule",
"[",
"]",
"rules",
",",
"StringArrayList",
"symbolTable",
")",
"throws",
"ActionException",
"{",
"int",
"i",
";",
"Ebnf",
"builder",
";",
"Grammar",
"tmp",
";",
"Grammar",
"buffer",
";",
"int",
"firstHelper",
";",
"int",
"lastHelper",
";",
"firstHelper",
"=",
"symbolTable",
".",
"size",
"(",
")",
";",
"buffer",
"=",
"new",
"Grammar",
"(",
"rules",
"[",
"0",
"]",
".",
"getLeft",
"(",
")",
",",
"symbolTable",
")",
";",
"builder",
"=",
"new",
"Ebnf",
"(",
"firstHelper",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"rules",
".",
"length",
";",
"i",
"++",
")",
"{",
"tmp",
"=",
"(",
"Grammar",
")",
"rules",
"[",
"i",
"]",
".",
"getRight",
"(",
")",
".",
"visit",
"(",
"builder",
")",
";",
"buffer",
".",
"addProduction",
"(",
"new",
"int",
"[",
"]",
"{",
"rules",
"[",
"i",
"]",
".",
"getLeft",
"(",
")",
",",
"tmp",
".",
"getStart",
"(",
")",
"}",
")",
";",
"buffer",
".",
"addProductions",
"(",
"tmp",
")",
";",
"buffer",
".",
"expandSymbol",
"(",
"tmp",
".",
"getStart",
"(",
")",
")",
";",
"buffer",
".",
"removeProductions",
"(",
"tmp",
".",
"getStart",
"(",
")",
")",
";",
"}",
"lastHelper",
"=",
"builder",
".",
"getHelper",
"(",
")",
"-",
"1",
";",
"buffer",
".",
"removeDuplicateSymbols",
"(",
"firstHelper",
",",
"lastHelper",
")",
";",
"buffer",
".",
"removeDuplicateRules",
"(",
")",
";",
"buffer",
".",
"packSymbols",
"(",
"firstHelper",
",",
"lastHelper",
"+",
"1",
")",
";",
"return",
"buffer",
";",
"}"
] | helper symbols are added without gaps, starting with freeHelper. | [
"helper",
"symbols",
"are",
"added",
"without",
"gaps",
"starting",
"with",
"freeHelper",
"."
] | train | https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/grammar/Ebnf.java#L30-L53 |
zaproxy/zaproxy | src/org/zaproxy/zap/session/CookieBasedSessionManagementHelper.java | CookieBasedSessionManagementHelper.processMessageToMatchSession | public static void processMessageToMatchSession(HttpMessage message, HttpSession session) {
"""
Modifies a message so its Request Header/Body matches the web session provided.
@param message the message
@param session the session
"""
processMessageToMatchSession(message, message.getRequestHeader().getHttpCookies(), session);
} | java | public static void processMessageToMatchSession(HttpMessage message, HttpSession session) {
processMessageToMatchSession(message, message.getRequestHeader().getHttpCookies(), session);
} | [
"public",
"static",
"void",
"processMessageToMatchSession",
"(",
"HttpMessage",
"message",
",",
"HttpSession",
"session",
")",
"{",
"processMessageToMatchSession",
"(",
"message",
",",
"message",
".",
"getRequestHeader",
"(",
")",
".",
"getHttpCookies",
"(",
")",
",",
"session",
")",
";",
"}"
] | Modifies a message so its Request Header/Body matches the web session provided.
@param message the message
@param session the session | [
"Modifies",
"a",
"message",
"so",
"its",
"Request",
"Header",
"/",
"Body",
"matches",
"the",
"web",
"session",
"provided",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/session/CookieBasedSessionManagementHelper.java#L48-L50 |
wisdom-framework/wisdom | core/content-manager/src/main/java/org/wisdom/content/converters/ParamConverterEngine.java | ParamConverterEngine.newInstance | @Override
public <T> T newInstance(Context context, Class<T> type) throws IllegalArgumentException {
"""
Creates an instance of T from the given HTTP content. Unlike converters, it does not handler generics or
collections.
@param context the HTTP content
@param type the class to instantiate
@return the created object
@throws IllegalArgumentException if there are no {@link org.wisdom.api.content.ParameterFactory} available for
the type T, or if the instantiation failed.
"""
// Retrieve the factory
for (ParameterFactory factory : factories) {
if (factory.getType().equals(type)) {
// Factory found - instantiate
//noinspection unchecked
return (T) factory.newInstance(context);
}
}
throw new IllegalArgumentException("Unable to find a ParameterFactory able to create instance of "
+ type.getName());
} | java | @Override
public <T> T newInstance(Context context, Class<T> type) throws IllegalArgumentException {
// Retrieve the factory
for (ParameterFactory factory : factories) {
if (factory.getType().equals(type)) {
// Factory found - instantiate
//noinspection unchecked
return (T) factory.newInstance(context);
}
}
throw new IllegalArgumentException("Unable to find a ParameterFactory able to create instance of "
+ type.getName());
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"newInstance",
"(",
"Context",
"context",
",",
"Class",
"<",
"T",
">",
"type",
")",
"throws",
"IllegalArgumentException",
"{",
"// Retrieve the factory",
"for",
"(",
"ParameterFactory",
"factory",
":",
"factories",
")",
"{",
"if",
"(",
"factory",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"// Factory found - instantiate",
"//noinspection unchecked",
"return",
"(",
"T",
")",
"factory",
".",
"newInstance",
"(",
"context",
")",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unable to find a ParameterFactory able to create instance of \"",
"+",
"type",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Creates an instance of T from the given HTTP content. Unlike converters, it does not handler generics or
collections.
@param context the HTTP content
@param type the class to instantiate
@return the created object
@throws IllegalArgumentException if there are no {@link org.wisdom.api.content.ParameterFactory} available for
the type T, or if the instantiation failed. | [
"Creates",
"an",
"instance",
"of",
"T",
"from",
"the",
"given",
"HTTP",
"content",
".",
"Unlike",
"converters",
"it",
"does",
"not",
"handler",
"generics",
"or",
"collections",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/content-manager/src/main/java/org/wisdom/content/converters/ParamConverterEngine.java#L138-L150 |
roboconf/roboconf-platform | core/roboconf-core/src/main/java/net/roboconf/core/userdata/UserDataHelpers.java | UserDataHelpers.interceptWritingFiles | static void interceptWritingFiles( Properties props, File outputDirectory ) throws IOException {
"""
Intercepts the properties and writes file contents.
@param props non-null properties
@param outputDirectory a directory into which files should be written
<p>
If null, files sent with {@link #ENCODE_FILE_CONTENT_PREFIX} will not be written.
</p>
@throws IOException
"""
if( outputDirectory == null )
return;
Logger logger = Logger.getLogger( UserDataHelpers.class.getName());
Set<String> keys = props.stringPropertyNames();
for( final String key : keys ) {
if( ! key.startsWith( ENCODE_FILE_CONTENT_PREFIX ))
continue;
// Get the file content
String encodedFileContent = props.getProperty( key );
String realKey = key.substring( ENCODE_FILE_CONTENT_PREFIX.length());
if( encodedFileContent == null ) {
logger.fine( "No file content was provided for " + realKey + ". Skipping it..." );
continue;
}
byte[] fileContent = decodeFromBase64( encodedFileContent );
// Write it to the disk
String targetFile = props.getProperty( realKey );
if( targetFile == null ) {
logger.fine( "No property named " + realKey + " was found. Skipping it..." );
continue;
}
Utils.createDirectory( outputDirectory );
File output = new File( outputDirectory, new File( targetFile ).getName());
Utils.copyStream( new ByteArrayInputStream( fileContent ), output );
logger.finer( "Writing " + key + " from user data in " + output.getAbsolutePath());
// Update the properties
props.remove( key );
props.setProperty( realKey, output.getAbsolutePath());
}
} | java | static void interceptWritingFiles( Properties props, File outputDirectory ) throws IOException {
if( outputDirectory == null )
return;
Logger logger = Logger.getLogger( UserDataHelpers.class.getName());
Set<String> keys = props.stringPropertyNames();
for( final String key : keys ) {
if( ! key.startsWith( ENCODE_FILE_CONTENT_PREFIX ))
continue;
// Get the file content
String encodedFileContent = props.getProperty( key );
String realKey = key.substring( ENCODE_FILE_CONTENT_PREFIX.length());
if( encodedFileContent == null ) {
logger.fine( "No file content was provided for " + realKey + ". Skipping it..." );
continue;
}
byte[] fileContent = decodeFromBase64( encodedFileContent );
// Write it to the disk
String targetFile = props.getProperty( realKey );
if( targetFile == null ) {
logger.fine( "No property named " + realKey + " was found. Skipping it..." );
continue;
}
Utils.createDirectory( outputDirectory );
File output = new File( outputDirectory, new File( targetFile ).getName());
Utils.copyStream( new ByteArrayInputStream( fileContent ), output );
logger.finer( "Writing " + key + " from user data in " + output.getAbsolutePath());
// Update the properties
props.remove( key );
props.setProperty( realKey, output.getAbsolutePath());
}
} | [
"static",
"void",
"interceptWritingFiles",
"(",
"Properties",
"props",
",",
"File",
"outputDirectory",
")",
"throws",
"IOException",
"{",
"if",
"(",
"outputDirectory",
"==",
"null",
")",
"return",
";",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"UserDataHelpers",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"keys",
"=",
"props",
".",
"stringPropertyNames",
"(",
")",
";",
"for",
"(",
"final",
"String",
"key",
":",
"keys",
")",
"{",
"if",
"(",
"!",
"key",
".",
"startsWith",
"(",
"ENCODE_FILE_CONTENT_PREFIX",
")",
")",
"continue",
";",
"// Get the file content",
"String",
"encodedFileContent",
"=",
"props",
".",
"getProperty",
"(",
"key",
")",
";",
"String",
"realKey",
"=",
"key",
".",
"substring",
"(",
"ENCODE_FILE_CONTENT_PREFIX",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"encodedFileContent",
"==",
"null",
")",
"{",
"logger",
".",
"fine",
"(",
"\"No file content was provided for \"",
"+",
"realKey",
"+",
"\". Skipping it...\"",
")",
";",
"continue",
";",
"}",
"byte",
"[",
"]",
"fileContent",
"=",
"decodeFromBase64",
"(",
"encodedFileContent",
")",
";",
"// Write it to the disk",
"String",
"targetFile",
"=",
"props",
".",
"getProperty",
"(",
"realKey",
")",
";",
"if",
"(",
"targetFile",
"==",
"null",
")",
"{",
"logger",
".",
"fine",
"(",
"\"No property named \"",
"+",
"realKey",
"+",
"\" was found. Skipping it...\"",
")",
";",
"continue",
";",
"}",
"Utils",
".",
"createDirectory",
"(",
"outputDirectory",
")",
";",
"File",
"output",
"=",
"new",
"File",
"(",
"outputDirectory",
",",
"new",
"File",
"(",
"targetFile",
")",
".",
"getName",
"(",
")",
")",
";",
"Utils",
".",
"copyStream",
"(",
"new",
"ByteArrayInputStream",
"(",
"fileContent",
")",
",",
"output",
")",
";",
"logger",
".",
"finer",
"(",
"\"Writing \"",
"+",
"key",
"+",
"\" from user data in \"",
"+",
"output",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// Update the properties",
"props",
".",
"remove",
"(",
"key",
")",
";",
"props",
".",
"setProperty",
"(",
"realKey",
",",
"output",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}"
] | Intercepts the properties and writes file contents.
@param props non-null properties
@param outputDirectory a directory into which files should be written
<p>
If null, files sent with {@link #ENCODE_FILE_CONTENT_PREFIX} will not be written.
</p>
@throws IOException | [
"Intercepts",
"the",
"properties",
"and",
"writes",
"file",
"contents",
".",
"@param",
"props",
"non",
"-",
"null",
"properties",
"@param",
"outputDirectory",
"a",
"directory",
"into",
"which",
"files",
"should",
"be",
"written",
"<p",
">",
"If",
"null",
"files",
"sent",
"with",
"{",
"@link",
"#ENCODE_FILE_CONTENT_PREFIX",
"}",
"will",
"not",
"be",
"written",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/userdata/UserDataHelpers.java#L242-L279 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isVisible | public static boolean isVisible(JvmDeclaredType fromType, JvmMember target) {
"""
Replies if the target feature is visible from the type.
@param fromType - the type from which the feature visibility is tested.
@param target - the feature to test for the visibility.
@return <code>true</code> if the given type can see the target feature.
"""
switch (target.getVisibility()) {
case DEFAULT:
return target.getDeclaringType().getPackageName().equals(fromType.getPackageName());
case PROTECTED:
case PUBLIC:
return true;
case PRIVATE:
default:
}
return false;
} | java | public static boolean isVisible(JvmDeclaredType fromType, JvmMember target) {
switch (target.getVisibility()) {
case DEFAULT:
return target.getDeclaringType().getPackageName().equals(fromType.getPackageName());
case PROTECTED:
case PUBLIC:
return true;
case PRIVATE:
default:
}
return false;
} | [
"public",
"static",
"boolean",
"isVisible",
"(",
"JvmDeclaredType",
"fromType",
",",
"JvmMember",
"target",
")",
"{",
"switch",
"(",
"target",
".",
"getVisibility",
"(",
")",
")",
"{",
"case",
"DEFAULT",
":",
"return",
"target",
".",
"getDeclaringType",
"(",
")",
".",
"getPackageName",
"(",
")",
".",
"equals",
"(",
"fromType",
".",
"getPackageName",
"(",
")",
")",
";",
"case",
"PROTECTED",
":",
"case",
"PUBLIC",
":",
"return",
"true",
";",
"case",
"PRIVATE",
":",
"default",
":",
"}",
"return",
"false",
";",
"}"
] | Replies if the target feature is visible from the type.
@param fromType - the type from which the feature visibility is tested.
@param target - the feature to test for the visibility.
@return <code>true</code> if the given type can see the target feature. | [
"Replies",
"if",
"the",
"target",
"feature",
"is",
"visible",
"from",
"the",
"type",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L345-L356 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getDungeonInfo | public void getDungeonInfo(String[] ids, Callback<List<Dungeon>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on Dungeons API go <a href="https://wiki.guildwars2.com/wiki/API:2/dungeons">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 dungeon 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 Dungeon dungeon info
"""
isParamValid(new ParamChecker(ids));
gw2API.getDungeonInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
} | java | public void getDungeonInfo(String[] ids, Callback<List<Dungeon>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getDungeonInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
} | [
"public",
"void",
"getDungeonInfo",
"(",
"String",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Dungeon",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getDungeonInfo",
"(",
"processIds",
"(",
"ids",
")",
",",
"GuildWars2",
".",
"lang",
".",
"getValue",
"(",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] | For more info on Dungeons API go <a href="https://wiki.guildwars2.com/wiki/API:2/dungeons">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 dungeon 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 Dungeon dungeon info | [
"For",
"more",
"info",
"on",
"Dungeons",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"dungeons",
">",
"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#L1287-L1290 |
code4everything/util | src/main/java/com/zhazhapan/util/BeanUtils.java | BeanUtils.bean2Another | public static <T> T bean2Another(Object object, T another, Class<T> clazz) throws IllegalAccessException,
InstantiationException, InvocationTargetException {
"""
将一个Bean的数据装换到另外一个(需实现setter和getter)
@param object 一个Bean
@param clazz 另外一个Bean类
@param another 另一个Bean对象
@param <T> 另外Bean类型
@return {@link T}
@throws IllegalAccessException 异常
@throws InvocationTargetException 异常
@throws InstantiationException 异常
@since 1.1.1
"""
if (Checker.isNull(another)) {
another = clazz.newInstance();
}
return bean2Another(object, clazz, another);
} | java | public static <T> T bean2Another(Object object, T another, Class<T> clazz) throws IllegalAccessException,
InstantiationException, InvocationTargetException {
if (Checker.isNull(another)) {
another = clazz.newInstance();
}
return bean2Another(object, clazz, another);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"bean2Another",
"(",
"Object",
"object",
",",
"T",
"another",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"if",
"(",
"Checker",
".",
"isNull",
"(",
"another",
")",
")",
"{",
"another",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"}",
"return",
"bean2Another",
"(",
"object",
",",
"clazz",
",",
"another",
")",
";",
"}"
] | 将一个Bean的数据装换到另外一个(需实现setter和getter)
@param object 一个Bean
@param clazz 另外一个Bean类
@param another 另一个Bean对象
@param <T> 另外Bean类型
@return {@link T}
@throws IllegalAccessException 异常
@throws InvocationTargetException 异常
@throws InstantiationException 异常
@since 1.1.1 | [
"将一个Bean的数据装换到另外一个(需实现setter和getter)"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/BeanUtils.java#L83-L89 |
andriusvelykis/reflow-maven-skin | reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/HtmlTool.java | HtmlTool.setAttr | public String setAttr(String content, String selector, String attributeKey, String value) {
"""
Sets attribute to the given value on elements in HTML.
@param content
HTML content to set attributes on
@param selector
CSS selector for elements to modify
@param attributeKey
Attribute name
@param value
Attribute value
@return HTML content with modified elements. If no elements are found, the original content
is returned.
@since 1.0
"""
Element body = parseContent(content);
List<Element> elements = body.select(selector);
if (elements.size() > 0) {
for (Element element : elements) {
element.attr(attributeKey, value);
}
return body.html();
} else {
// nothing to update
return content;
}
} | java | public String setAttr(String content, String selector, String attributeKey, String value) {
Element body = parseContent(content);
List<Element> elements = body.select(selector);
if (elements.size() > 0) {
for (Element element : elements) {
element.attr(attributeKey, value);
}
return body.html();
} else {
// nothing to update
return content;
}
} | [
"public",
"String",
"setAttr",
"(",
"String",
"content",
",",
"String",
"selector",
",",
"String",
"attributeKey",
",",
"String",
"value",
")",
"{",
"Element",
"body",
"=",
"parseContent",
"(",
"content",
")",
";",
"List",
"<",
"Element",
">",
"elements",
"=",
"body",
".",
"select",
"(",
"selector",
")",
";",
"if",
"(",
"elements",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"Element",
"element",
":",
"elements",
")",
"{",
"element",
".",
"attr",
"(",
"attributeKey",
",",
"value",
")",
";",
"}",
"return",
"body",
".",
"html",
"(",
")",
";",
"}",
"else",
"{",
"// nothing to update",
"return",
"content",
";",
"}",
"}"
] | Sets attribute to the given value on elements in HTML.
@param content
HTML content to set attributes on
@param selector
CSS selector for elements to modify
@param attributeKey
Attribute name
@param value
Attribute value
@return HTML content with modified elements. If no elements are found, the original content
is returned.
@since 1.0 | [
"Sets",
"attribute",
"to",
"the",
"given",
"value",
"on",
"elements",
"in",
"HTML",
"."
] | train | https://github.com/andriusvelykis/reflow-maven-skin/blob/01170ae1426a1adfe7cc9c199e77aaa2ecb37ef2/reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/HtmlTool.java#L584-L600 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.