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
|
---|---|---|---|---|---|---|---|---|---|---|
dwdyer/watchmaker | examples/src/java/main/org/uncommons/watchmaker/examples/geneticprogramming/TreeFactory.java | TreeFactory.makeNode | private Node makeNode(Random rng, int maxDepth) {
"""
Recursively constructs a tree of Nodes, up to the specified maximum depth.
@param rng The RNG used to random create nodes.
@param maxDepth The maximum depth of the generated tree.
@return A tree of nodes.
"""
if (functionProbability.nextEvent(rng) && maxDepth > 1)
{
// Max depth for sub-trees is one less than max depth for this node.
int depth = maxDepth - 1;
switch (rng.nextInt(5))
{
case 0: return new Addition(makeNode(rng, depth), makeNode(rng, depth));
case 1: return new Subtraction(makeNode(rng, depth), makeNode(rng, depth));
case 2: return new Multiplication(makeNode(rng, depth), makeNode(rng, depth));
case 3: return new IfThenElse(makeNode(rng, depth), makeNode(rng, depth), makeNode(rng, depth));
default: return new IsGreater(makeNode(rng, depth), makeNode(rng, depth));
}
}
else if (parameterProbability.nextEvent(rng))
{
return new Parameter(rng.nextInt(parameterCount));
}
else
{
return new Constant(rng.nextInt(11));
}
} | java | private Node makeNode(Random rng, int maxDepth)
{
if (functionProbability.nextEvent(rng) && maxDepth > 1)
{
// Max depth for sub-trees is one less than max depth for this node.
int depth = maxDepth - 1;
switch (rng.nextInt(5))
{
case 0: return new Addition(makeNode(rng, depth), makeNode(rng, depth));
case 1: return new Subtraction(makeNode(rng, depth), makeNode(rng, depth));
case 2: return new Multiplication(makeNode(rng, depth), makeNode(rng, depth));
case 3: return new IfThenElse(makeNode(rng, depth), makeNode(rng, depth), makeNode(rng, depth));
default: return new IsGreater(makeNode(rng, depth), makeNode(rng, depth));
}
}
else if (parameterProbability.nextEvent(rng))
{
return new Parameter(rng.nextInt(parameterCount));
}
else
{
return new Constant(rng.nextInt(11));
}
} | [
"private",
"Node",
"makeNode",
"(",
"Random",
"rng",
",",
"int",
"maxDepth",
")",
"{",
"if",
"(",
"functionProbability",
".",
"nextEvent",
"(",
"rng",
")",
"&&",
"maxDepth",
">",
"1",
")",
"{",
"// Max depth for sub-trees is one less than max depth for this node.",
"int",
"depth",
"=",
"maxDepth",
"-",
"1",
";",
"switch",
"(",
"rng",
".",
"nextInt",
"(",
"5",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"Addition",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"case",
"1",
":",
"return",
"new",
"Subtraction",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"Multiplication",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"IfThenElse",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"default",
":",
"return",
"new",
"IsGreater",
"(",
"makeNode",
"(",
"rng",
",",
"depth",
")",
",",
"makeNode",
"(",
"rng",
",",
"depth",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"parameterProbability",
".",
"nextEvent",
"(",
"rng",
")",
")",
"{",
"return",
"new",
"Parameter",
"(",
"rng",
".",
"nextInt",
"(",
"parameterCount",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Constant",
"(",
"rng",
".",
"nextInt",
"(",
"11",
")",
")",
";",
"}",
"}"
] | Recursively constructs a tree of Nodes, up to the specified maximum depth.
@param rng The RNG used to random create nodes.
@param maxDepth The maximum depth of the generated tree.
@return A tree of nodes. | [
"Recursively",
"constructs",
"a",
"tree",
"of",
"Nodes",
"up",
"to",
"the",
"specified",
"maximum",
"depth",
"."
] | train | https://github.com/dwdyer/watchmaker/blob/33d942350e6bf7d9a17b9262a4f898158530247e/examples/src/java/main/org/uncommons/watchmaker/examples/geneticprogramming/TreeFactory.java#L91-L114 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionValuePersistenceImpl.java | CPOptionValuePersistenceImpl.fetchByC_K | @Override
public CPOptionValue fetchByC_K(long CPOptionId, String key) {
"""
Returns the cp option value where CPOptionId = ? and key = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param CPOptionId the cp option ID
@param key the key
@return the matching cp option value, or <code>null</code> if a matching cp option value could not be found
"""
return fetchByC_K(CPOptionId, key, true);
} | java | @Override
public CPOptionValue fetchByC_K(long CPOptionId, String key) {
return fetchByC_K(CPOptionId, key, true);
} | [
"@",
"Override",
"public",
"CPOptionValue",
"fetchByC_K",
"(",
"long",
"CPOptionId",
",",
"String",
"key",
")",
"{",
"return",
"fetchByC_K",
"(",
"CPOptionId",
",",
"key",
",",
"true",
")",
";",
"}"
] | Returns the cp option value where CPOptionId = ? and key = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param CPOptionId the cp option ID
@param key the key
@return the matching cp option value, or <code>null</code> if a matching cp option value could not be found | [
"Returns",
"the",
"cp",
"option",
"value",
"where",
"CPOptionId",
"=",
"?",
";",
"and",
"key",
"=",
"?",
";",
"or",
"returns",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"it",
"could",
"not",
"be",
"found",
".",
"Uses",
"the",
"finder",
"cache",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionValuePersistenceImpl.java#L3060-L3063 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/exception/fault/FaultException.java | FaultException.formatMessage | protected void formatMessage(String aID, Map<Object,Object> aBindValues) {
"""
Format the exception message using the presenter getText method
@param aID the key of the message
@param aBindValues the values to plug into the message.
"""
Presenter presenter = Presenter.getPresenter(this.getClass());
message = presenter.getText(aID,aBindValues);
} | java | protected void formatMessage(String aID, Map<Object,Object> aBindValues)
{
Presenter presenter = Presenter.getPresenter(this.getClass());
message = presenter.getText(aID,aBindValues);
} | [
"protected",
"void",
"formatMessage",
"(",
"String",
"aID",
",",
"Map",
"<",
"Object",
",",
"Object",
">",
"aBindValues",
")",
"{",
"Presenter",
"presenter",
"=",
"Presenter",
".",
"getPresenter",
"(",
"this",
".",
"getClass",
"(",
")",
")",
";",
"message",
"=",
"presenter",
".",
"getText",
"(",
"aID",
",",
"aBindValues",
")",
";",
"}"
] | Format the exception message using the presenter getText method
@param aID the key of the message
@param aBindValues the values to plug into the message. | [
"Format",
"the",
"exception",
"message",
"using",
"the",
"presenter",
"getText",
"method"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/exception/fault/FaultException.java#L215-L220 |
lestard/advanced-bindings | src/main/java/eu/lestard/advanced_bindings/api/NumberBindings.java | NumberBindings.divideSafe | public static NumberBinding divideSafe(ObservableValue<Number> dividend, ObservableValue<Number> divisor, ObservableValue<Number> defaultValue) {
"""
An number binding of a division that won't throw an {@link java.lang.ArithmeticException}
when a division by zero happens. See {@link #divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue)}
for more informations.
@param dividend the observable value used as dividend
@param divisor the observable value used as divisor
@param defaultValue the observable value that is used as default value. The binding will have this value when a
division by zero happens.
@return the resulting number binding
"""
return Bindings.createDoubleBinding(() -> {
if (divisor.getValue().doubleValue() == 0) {
return defaultValue.getValue().doubleValue();
} else {
return dividend.getValue().doubleValue() / divisor.getValue().doubleValue();
}
}, dividend, divisor);
} | java | public static NumberBinding divideSafe(ObservableValue<Number> dividend, ObservableValue<Number> divisor, ObservableValue<Number> defaultValue) {
return Bindings.createDoubleBinding(() -> {
if (divisor.getValue().doubleValue() == 0) {
return defaultValue.getValue().doubleValue();
} else {
return dividend.getValue().doubleValue() / divisor.getValue().doubleValue();
}
}, dividend, divisor);
} | [
"public",
"static",
"NumberBinding",
"divideSafe",
"(",
"ObservableValue",
"<",
"Number",
">",
"dividend",
",",
"ObservableValue",
"<",
"Number",
">",
"divisor",
",",
"ObservableValue",
"<",
"Number",
">",
"defaultValue",
")",
"{",
"return",
"Bindings",
".",
"createDoubleBinding",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"divisor",
".",
"getValue",
"(",
")",
".",
"doubleValue",
"(",
")",
"==",
"0",
")",
"{",
"return",
"defaultValue",
".",
"getValue",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"else",
"{",
"return",
"dividend",
".",
"getValue",
"(",
")",
".",
"doubleValue",
"(",
")",
"/",
"divisor",
".",
"getValue",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"}",
",",
"dividend",
",",
"divisor",
")",
";",
"}"
] | An number binding of a division that won't throw an {@link java.lang.ArithmeticException}
when a division by zero happens. See {@link #divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue)}
for more informations.
@param dividend the observable value used as dividend
@param divisor the observable value used as divisor
@param defaultValue the observable value that is used as default value. The binding will have this value when a
division by zero happens.
@return the resulting number binding | [
"An",
"number",
"binding",
"of",
"a",
"division",
"that",
"won",
"t",
"throw",
"an",
"{",
"@link",
"java",
".",
"lang",
".",
"ArithmeticException",
"}",
"when",
"a",
"division",
"by",
"zero",
"happens",
".",
"See",
"{",
"@link",
"#divideSafe",
"(",
"javafx",
".",
"beans",
".",
"value",
".",
"ObservableIntegerValue",
"javafx",
".",
"beans",
".",
"value",
".",
"ObservableIntegerValue",
")",
"}",
"for",
"more",
"informations",
"."
] | train | https://github.com/lestard/advanced-bindings/blob/054a5dde261c29f862b971765fa3da3704a13ab4/src/main/java/eu/lestard/advanced_bindings/api/NumberBindings.java#L110-L120 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/TimePicker.java | TimePicker.zDrawTextFieldIndicators | public void zDrawTextFieldIndicators() {
"""
zDrawTextFieldIndicators, This will draw the text field indicators, to indicate to the user
the state of any text in the text field, including the validity of any time that has been
typed. The text field indicators include the text field background color, foreground color,
font color, and font.
Note: This function is called automatically by the time picker. Under most circumstances, the
programmer will not need to call this function.
List of possible text field states: DisabledComponent, ValidFullOrEmptyValue,
UnparsableValue, VetoedValue, DisallowedEmptyValue.
"""
if (!isEnabled()) {
// (Possibility: DisabledComponent)
// Note: The time should always be validated (as if the component lost focus), before
// the component is disabled.
timeTextField.setBackground(new Color(240, 240, 240));
timeTextField.setForeground(new Color(109, 109, 109));
timeTextField.setFont(settings.fontValidTime);
return;
}
// Reset all atributes to normal before going further.
// (Possibility: ValidFullOrEmptyValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundValidTime));
timeTextField.setForeground(settings.getColor(TimeArea.TimePickerTextValidTime));
timeTextField.setFont(settings.fontValidTime);
// Get the text, and check to see if it is empty.
String timeText = timeTextField.getText();
boolean textIsEmpty = timeText.trim().isEmpty();
// Handle the various possibilities.
if (textIsEmpty) {
if (settings.getAllowEmptyTimes()) {
// (Possibility: ValidFullOrEmptyValue)
} else {
// (Possibility: DisallowedEmptyValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundDisallowedEmptyTime));
}
return;
}
// The text is not empty.
LocalTime parsedTime = InternalUtilities.getParsedTimeOrNull(timeText, settings.getFormatForDisplayTime(), settings.getFormatForMenuTimes(),
settings.formatsForParsing, settings.getLocale());
if (parsedTime == null) {
// (Possibility: UnparsableValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundInvalidTime));
timeTextField.setForeground(settings.getColor(TimeArea.TimePickerTextInvalidTime));
timeTextField.setFont(settings.fontInvalidTime);
return;
}
// The text was parsed to a value.
TimeVetoPolicy vetoPolicy = settings.getVetoPolicy();
boolean isTimeVetoed = InternalUtilities.isTimeVetoed(vetoPolicy, parsedTime);
if (isTimeVetoed) {
// (Possibility: VetoedValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundVetoedTime));
timeTextField.setForeground(settings.getColor(TimeArea.TimePickerTextVetoedTime));
timeTextField.setFont(settings.fontVetoedTime);
}
} | java | public void zDrawTextFieldIndicators() {
if (!isEnabled()) {
// (Possibility: DisabledComponent)
// Note: The time should always be validated (as if the component lost focus), before
// the component is disabled.
timeTextField.setBackground(new Color(240, 240, 240));
timeTextField.setForeground(new Color(109, 109, 109));
timeTextField.setFont(settings.fontValidTime);
return;
}
// Reset all atributes to normal before going further.
// (Possibility: ValidFullOrEmptyValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundValidTime));
timeTextField.setForeground(settings.getColor(TimeArea.TimePickerTextValidTime));
timeTextField.setFont(settings.fontValidTime);
// Get the text, and check to see if it is empty.
String timeText = timeTextField.getText();
boolean textIsEmpty = timeText.trim().isEmpty();
// Handle the various possibilities.
if (textIsEmpty) {
if (settings.getAllowEmptyTimes()) {
// (Possibility: ValidFullOrEmptyValue)
} else {
// (Possibility: DisallowedEmptyValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundDisallowedEmptyTime));
}
return;
}
// The text is not empty.
LocalTime parsedTime = InternalUtilities.getParsedTimeOrNull(timeText, settings.getFormatForDisplayTime(), settings.getFormatForMenuTimes(),
settings.formatsForParsing, settings.getLocale());
if (parsedTime == null) {
// (Possibility: UnparsableValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundInvalidTime));
timeTextField.setForeground(settings.getColor(TimeArea.TimePickerTextInvalidTime));
timeTextField.setFont(settings.fontInvalidTime);
return;
}
// The text was parsed to a value.
TimeVetoPolicy vetoPolicy = settings.getVetoPolicy();
boolean isTimeVetoed = InternalUtilities.isTimeVetoed(vetoPolicy, parsedTime);
if (isTimeVetoed) {
// (Possibility: VetoedValue)
timeTextField.setBackground(settings.getColor(TimeArea.TextFieldBackgroundVetoedTime));
timeTextField.setForeground(settings.getColor(TimeArea.TimePickerTextVetoedTime));
timeTextField.setFont(settings.fontVetoedTime);
}
} | [
"public",
"void",
"zDrawTextFieldIndicators",
"(",
")",
"{",
"if",
"(",
"!",
"isEnabled",
"(",
")",
")",
"{",
"// (Possibility: DisabledComponent)",
"// Note: The time should always be validated (as if the component lost focus), before",
"// the component is disabled.",
"timeTextField",
".",
"setBackground",
"(",
"new",
"Color",
"(",
"240",
",",
"240",
",",
"240",
")",
")",
";",
"timeTextField",
".",
"setForeground",
"(",
"new",
"Color",
"(",
"109",
",",
"109",
",",
"109",
")",
")",
";",
"timeTextField",
".",
"setFont",
"(",
"settings",
".",
"fontValidTime",
")",
";",
"return",
";",
"}",
"// Reset all atributes to normal before going further.",
"// (Possibility: ValidFullOrEmptyValue)",
"timeTextField",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TextFieldBackgroundValidTime",
")",
")",
";",
"timeTextField",
".",
"setForeground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TimePickerTextValidTime",
")",
")",
";",
"timeTextField",
".",
"setFont",
"(",
"settings",
".",
"fontValidTime",
")",
";",
"// Get the text, and check to see if it is empty.",
"String",
"timeText",
"=",
"timeTextField",
".",
"getText",
"(",
")",
";",
"boolean",
"textIsEmpty",
"=",
"timeText",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
";",
"// Handle the various possibilities.",
"if",
"(",
"textIsEmpty",
")",
"{",
"if",
"(",
"settings",
".",
"getAllowEmptyTimes",
"(",
")",
")",
"{",
"// (Possibility: ValidFullOrEmptyValue)",
"}",
"else",
"{",
"// (Possibility: DisallowedEmptyValue)",
"timeTextField",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TextFieldBackgroundDisallowedEmptyTime",
")",
")",
";",
"}",
"return",
";",
"}",
"// The text is not empty.",
"LocalTime",
"parsedTime",
"=",
"InternalUtilities",
".",
"getParsedTimeOrNull",
"(",
"timeText",
",",
"settings",
".",
"getFormatForDisplayTime",
"(",
")",
",",
"settings",
".",
"getFormatForMenuTimes",
"(",
")",
",",
"settings",
".",
"formatsForParsing",
",",
"settings",
".",
"getLocale",
"(",
")",
")",
";",
"if",
"(",
"parsedTime",
"==",
"null",
")",
"{",
"// (Possibility: UnparsableValue)",
"timeTextField",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TextFieldBackgroundInvalidTime",
")",
")",
";",
"timeTextField",
".",
"setForeground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TimePickerTextInvalidTime",
")",
")",
";",
"timeTextField",
".",
"setFont",
"(",
"settings",
".",
"fontInvalidTime",
")",
";",
"return",
";",
"}",
"// The text was parsed to a value.",
"TimeVetoPolicy",
"vetoPolicy",
"=",
"settings",
".",
"getVetoPolicy",
"(",
")",
";",
"boolean",
"isTimeVetoed",
"=",
"InternalUtilities",
".",
"isTimeVetoed",
"(",
"vetoPolicy",
",",
"parsedTime",
")",
";",
"if",
"(",
"isTimeVetoed",
")",
"{",
"// (Possibility: VetoedValue)",
"timeTextField",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TextFieldBackgroundVetoedTime",
")",
")",
";",
"timeTextField",
".",
"setForeground",
"(",
"settings",
".",
"getColor",
"(",
"TimeArea",
".",
"TimePickerTextVetoedTime",
")",
")",
";",
"timeTextField",
".",
"setFont",
"(",
"settings",
".",
"fontVetoedTime",
")",
";",
"}",
"}"
] | zDrawTextFieldIndicators, This will draw the text field indicators, to indicate to the user
the state of any text in the text field, including the validity of any time that has been
typed. The text field indicators include the text field background color, foreground color,
font color, and font.
Note: This function is called automatically by the time picker. Under most circumstances, the
programmer will not need to call this function.
List of possible text field states: DisabledComponent, ValidFullOrEmptyValue,
UnparsableValue, VetoedValue, DisallowedEmptyValue. | [
"zDrawTextFieldIndicators",
"This",
"will",
"draw",
"the",
"text",
"field",
"indicators",
"to",
"indicate",
"to",
"the",
"user",
"the",
"state",
"of",
"any",
"text",
"in",
"the",
"text",
"field",
"including",
"the",
"validity",
"of",
"any",
"time",
"that",
"has",
"been",
"typed",
".",
"The",
"text",
"field",
"indicators",
"include",
"the",
"text",
"field",
"background",
"color",
"foreground",
"color",
"font",
"color",
"and",
"font",
"."
] | train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/TimePicker.java#L844-L891 |
hal/elemento | core/src/main/java/org/jboss/gwt/elemento/core/Elements.java | Elements.lazyInsertBefore | public static void lazyInsertBefore(Element newElement, Element before) {
"""
Inserts the specified element into the parent of the before element if not already present. If parent already
contains child, this method does nothing.
"""
if (!before.parentNode.contains(newElement)) {
before.parentNode.insertBefore(newElement, before);
}
} | java | public static void lazyInsertBefore(Element newElement, Element before) {
if (!before.parentNode.contains(newElement)) {
before.parentNode.insertBefore(newElement, before);
}
} | [
"public",
"static",
"void",
"lazyInsertBefore",
"(",
"Element",
"newElement",
",",
"Element",
"before",
")",
"{",
"if",
"(",
"!",
"before",
".",
"parentNode",
".",
"contains",
"(",
"newElement",
")",
")",
"{",
"before",
".",
"parentNode",
".",
"insertBefore",
"(",
"newElement",
",",
"before",
")",
";",
"}",
"}"
] | Inserts the specified element into the parent of the before element if not already present. If parent already
contains child, this method does nothing. | [
"Inserts",
"the",
"specified",
"element",
"into",
"the",
"parent",
"of",
"the",
"before",
"element",
"if",
"not",
"already",
"present",
".",
"If",
"parent",
"already",
"contains",
"child",
"this",
"method",
"does",
"nothing",
"."
] | train | https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L688-L692 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.nextClearBit | public static int nextClearBit(long v, int start) {
"""
Find the next clear bit.
@param v Value to process
@param start Start position (inclusive)
@return Position of next clear bit, or -1.
"""
if(start >= Long.SIZE) {
return -1;
}
start = start < 0 ? 0 : start;
long cur = ~v & (LONG_ALL_BITS << start);
return cur == 0 ? -1 : Long.numberOfTrailingZeros(cur);
} | java | public static int nextClearBit(long v, int start) {
if(start >= Long.SIZE) {
return -1;
}
start = start < 0 ? 0 : start;
long cur = ~v & (LONG_ALL_BITS << start);
return cur == 0 ? -1 : Long.numberOfTrailingZeros(cur);
} | [
"public",
"static",
"int",
"nextClearBit",
"(",
"long",
"v",
",",
"int",
"start",
")",
"{",
"if",
"(",
"start",
">=",
"Long",
".",
"SIZE",
")",
"{",
"return",
"-",
"1",
";",
"}",
"start",
"=",
"start",
"<",
"0",
"?",
"0",
":",
"start",
";",
"long",
"cur",
"=",
"~",
"v",
"&",
"(",
"LONG_ALL_BITS",
"<<",
"start",
")",
";",
"return",
"cur",
"==",
"0",
"?",
"-",
"1",
":",
"Long",
".",
"numberOfTrailingZeros",
"(",
"cur",
")",
";",
"}"
] | Find the next clear bit.
@param v Value to process
@param start Start position (inclusive)
@return Position of next clear bit, or -1. | [
"Find",
"the",
"next",
"clear",
"bit",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1350-L1357 |
Jasig/uPortal | uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/cache/ThreadLocalCacheEntryFactory.java | ThreadLocalCacheEntryFactory.getWithData | public Element getWithData(Ehcache cache, Object key, A data) {
"""
Wraps an {@link Ehcache#get(Object)} call with setting/clearing the {@link ThreadLocal}
"""
this.threadData.set(data);
try {
return cache.get(key);
} finally {
this.threadData.remove();
}
} | java | public Element getWithData(Ehcache cache, Object key, A data) {
this.threadData.set(data);
try {
return cache.get(key);
} finally {
this.threadData.remove();
}
} | [
"public",
"Element",
"getWithData",
"(",
"Ehcache",
"cache",
",",
"Object",
"key",
",",
"A",
"data",
")",
"{",
"this",
".",
"threadData",
".",
"set",
"(",
"data",
")",
";",
"try",
"{",
"return",
"cache",
".",
"get",
"(",
"key",
")",
";",
"}",
"finally",
"{",
"this",
".",
"threadData",
".",
"remove",
"(",
")",
";",
"}",
"}"
] | Wraps an {@link Ehcache#get(Object)} call with setting/clearing the {@link ThreadLocal} | [
"Wraps",
"an",
"{"
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/cache/ThreadLocalCacheEntryFactory.java#L38-L45 |
neoremind/fluent-validator | fluent-validator/src/main/java/com/baidu/unbiz/fluentvalidator/support/ConcurrentCache.java | ConcurrentCache.get | public V get(K key, Callable<V> callable) {
"""
通过关键字获取数据,如果存在则直接返回,如果不存在,则通过计算<code>callable</code>来生成
@param key 查找关键字
@param callable # @see Callable
@return 计算结果
"""
Future<V> future = concurrentMap.get(key);
if (future == null) {
FutureTask<V> futureTask = new FutureTask<V>(callable);
future = concurrentMap.putIfAbsent(key, futureTask);
if (future == null) {
future = futureTask;
futureTask.run();
}
}
try {
// 此时阻塞
return future.get();
} catch (Exception e) {
concurrentMap.remove(key);
return null;
}
} | java | public V get(K key, Callable<V> callable) {
Future<V> future = concurrentMap.get(key);
if (future == null) {
FutureTask<V> futureTask = new FutureTask<V>(callable);
future = concurrentMap.putIfAbsent(key, futureTask);
if (future == null) {
future = futureTask;
futureTask.run();
}
}
try {
// 此时阻塞
return future.get();
} catch (Exception e) {
concurrentMap.remove(key);
return null;
}
} | [
"public",
"V",
"get",
"(",
"K",
"key",
",",
"Callable",
"<",
"V",
">",
"callable",
")",
"{",
"Future",
"<",
"V",
">",
"future",
"=",
"concurrentMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"future",
"==",
"null",
")",
"{",
"FutureTask",
"<",
"V",
">",
"futureTask",
"=",
"new",
"FutureTask",
"<",
"V",
">",
"(",
"callable",
")",
";",
"future",
"=",
"concurrentMap",
".",
"putIfAbsent",
"(",
"key",
",",
"futureTask",
")",
";",
"if",
"(",
"future",
"==",
"null",
")",
"{",
"future",
"=",
"futureTask",
";",
"futureTask",
".",
"run",
"(",
")",
";",
"}",
"}",
"try",
"{",
"// 此时阻塞",
"return",
"future",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"concurrentMap",
".",
"remove",
"(",
"key",
")",
";",
"return",
"null",
";",
"}",
"}"
] | 通过关键字获取数据,如果存在则直接返回,如果不存在,则通过计算<code>callable</code>来生成
@param key 查找关键字
@param callable # @see Callable
@return 计算结果 | [
"通过关键字获取数据,如果存在则直接返回,如果不存在,则通过计算<code",
">",
"callable<",
"/",
"code",
">",
"来生成"
] | train | https://github.com/neoremind/fluent-validator/blob/b516970591aa9468b44ba63938b98ec341fd6ead/fluent-validator/src/main/java/com/baidu/unbiz/fluentvalidator/support/ConcurrentCache.java#L32-L49 |
udoprog/ffwd-client-java | src/main/java/com/google/protobuf250/CodedOutputStream.java | CodedOutputStream.writeSFixed64 | public void writeSFixed64(final int fieldNumber, final long value)
throws IOException {
"""
Write an {@code sfixed64} field, including tag, to the stream.
"""
writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED64);
writeSFixed64NoTag(value);
} | java | public void writeSFixed64(final int fieldNumber, final long value)
throws IOException {
writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED64);
writeSFixed64NoTag(value);
} | [
"public",
"void",
"writeSFixed64",
"(",
"final",
"int",
"fieldNumber",
",",
"final",
"long",
"value",
")",
"throws",
"IOException",
"{",
"writeTag",
"(",
"fieldNumber",
",",
"WireFormat",
".",
"WIRETYPE_FIXED64",
")",
";",
"writeSFixed64NoTag",
"(",
"value",
")",
";",
"}"
] | Write an {@code sfixed64} field, including tag, to the stream. | [
"Write",
"an",
"{"
] | train | https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/CodedOutputStream.java#L257-L261 |
BioPAX/Paxtools | pattern/src/main/java/org/biopax/paxtools/pattern/PatternBox.java | PatternBox.neighborOf | public static Pattern neighborOf() {
"""
Constructs a pattern where first and last proteins are related through an interaction. They
can be participants or controllers. No limitation.
@return the pattern
"""
Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
p.add(linkedER(true), "Protein 1", "generic Protein 1");
p.add(erToPE(), "generic Protein 1", "SPE1");
p.add(linkToComplex(), "SPE1", "PE1");
p.add(peToInter(), "PE1", "Inter");
p.add(interToPE(), "Inter", "PE2");
p.add(linkToSpecific(), "PE2", "SPE2");
p.add(equal(false), "SPE1", "SPE2");
p.add(type(SequenceEntity.class), "SPE2");
p.add(peToER(), "SPE2", "generic Protein 2");
p.add(linkedER(false), "generic Protein 2", "Protein 2");
p.add(equal(false), "Protein 1", "Protein 2");
return p;
} | java | public static Pattern neighborOf()
{
Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
p.add(linkedER(true), "Protein 1", "generic Protein 1");
p.add(erToPE(), "generic Protein 1", "SPE1");
p.add(linkToComplex(), "SPE1", "PE1");
p.add(peToInter(), "PE1", "Inter");
p.add(interToPE(), "Inter", "PE2");
p.add(linkToSpecific(), "PE2", "SPE2");
p.add(equal(false), "SPE1", "SPE2");
p.add(type(SequenceEntity.class), "SPE2");
p.add(peToER(), "SPE2", "generic Protein 2");
p.add(linkedER(false), "generic Protein 2", "Protein 2");
p.add(equal(false), "Protein 1", "Protein 2");
return p;
} | [
"public",
"static",
"Pattern",
"neighborOf",
"(",
")",
"{",
"Pattern",
"p",
"=",
"new",
"Pattern",
"(",
"SequenceEntityReference",
".",
"class",
",",
"\"Protein 1\"",
")",
";",
"p",
".",
"add",
"(",
"linkedER",
"(",
"true",
")",
",",
"\"Protein 1\"",
",",
"\"generic Protein 1\"",
")",
";",
"p",
".",
"add",
"(",
"erToPE",
"(",
")",
",",
"\"generic Protein 1\"",
",",
"\"SPE1\"",
")",
";",
"p",
".",
"add",
"(",
"linkToComplex",
"(",
")",
",",
"\"SPE1\"",
",",
"\"PE1\"",
")",
";",
"p",
".",
"add",
"(",
"peToInter",
"(",
")",
",",
"\"PE1\"",
",",
"\"Inter\"",
")",
";",
"p",
".",
"add",
"(",
"interToPE",
"(",
")",
",",
"\"Inter\"",
",",
"\"PE2\"",
")",
";",
"p",
".",
"add",
"(",
"linkToSpecific",
"(",
")",
",",
"\"PE2\"",
",",
"\"SPE2\"",
")",
";",
"p",
".",
"add",
"(",
"equal",
"(",
"false",
")",
",",
"\"SPE1\"",
",",
"\"SPE2\"",
")",
";",
"p",
".",
"add",
"(",
"type",
"(",
"SequenceEntity",
".",
"class",
")",
",",
"\"SPE2\"",
")",
";",
"p",
".",
"add",
"(",
"peToER",
"(",
")",
",",
"\"SPE2\"",
",",
"\"generic Protein 2\"",
")",
";",
"p",
".",
"add",
"(",
"linkedER",
"(",
"false",
")",
",",
"\"generic Protein 2\"",
",",
"\"Protein 2\"",
")",
";",
"p",
".",
"add",
"(",
"equal",
"(",
"false",
")",
",",
"\"Protein 1\"",
",",
"\"Protein 2\"",
")",
";",
"return",
"p",
";",
"}"
] | Constructs a pattern where first and last proteins are related through an interaction. They
can be participants or controllers. No limitation.
@return the pattern | [
"Constructs",
"a",
"pattern",
"where",
"first",
"and",
"last",
"proteins",
"are",
"related",
"through",
"an",
"interaction",
".",
"They",
"can",
"be",
"participants",
"or",
"controllers",
".",
"No",
"limitation",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/PatternBox.java#L570-L585 |
datoin/http-requests | src/main/java/org/datoin/net/http/Request.java | Request.setContent | public Request setContent(String text, ContentType contentType) {
"""
set request content from input text string with given content type
@param text : text to be sent as http content
@param contentType : type of content set in header
@return : Request Object with content type header and conetnt entity value set
"""
entity = new StringEntity(text, contentType);
return this;
} | java | public Request setContent(String text, ContentType contentType) {
entity = new StringEntity(text, contentType);
return this;
} | [
"public",
"Request",
"setContent",
"(",
"String",
"text",
",",
"ContentType",
"contentType",
")",
"{",
"entity",
"=",
"new",
"StringEntity",
"(",
"text",
",",
"contentType",
")",
";",
"return",
"this",
";",
"}"
] | set request content from input text string with given content type
@param text : text to be sent as http content
@param contentType : type of content set in header
@return : Request Object with content type header and conetnt entity value set | [
"set",
"request",
"content",
"from",
"input",
"text",
"string",
"with",
"given",
"content",
"type"
] | train | https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L400-L403 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java | JDBCResultSet.updateInt | public void updateInt(int columnIndex, int x) throws SQLException {
"""
<!-- start generic documentation -->
Updates the designated column with an <code>int</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet)
"""
startUpdate(columnIndex);
preparedStatement.setIntParameter(columnIndex, x);
} | java | public void updateInt(int columnIndex, int x) throws SQLException {
startUpdate(columnIndex);
preparedStatement.setIntParameter(columnIndex, x);
} | [
"public",
"void",
"updateInt",
"(",
"int",
"columnIndex",
",",
"int",
"x",
")",
"throws",
"SQLException",
"{",
"startUpdate",
"(",
"columnIndex",
")",
";",
"preparedStatement",
".",
"setIntParameter",
"(",
"columnIndex",
",",
"x",
")",
";",
"}"
] | <!-- start generic documentation -->
Updates the designated column with an <code>int</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet) | [
"<!",
"--",
"start",
"generic",
"documentation",
"--",
">",
"Updates",
"the",
"designated",
"column",
"with",
"an",
"<code",
">",
"int<",
"/",
"code",
">",
"value",
".",
"The",
"updater",
"methods",
"are",
"used",
"to",
"update",
"column",
"values",
"in",
"the",
"current",
"row",
"or",
"the",
"insert",
"row",
".",
"The",
"updater",
"methods",
"do",
"not",
"update",
"the",
"underlying",
"database",
";",
"instead",
"the",
"<code",
">",
"updateRow<",
"/",
"code",
">",
"or",
"<code",
">",
"insertRow<",
"/",
"code",
">",
"methods",
"are",
"called",
"to",
"update",
"the",
"database",
".",
"<!",
"--",
"end",
"generic",
"documentation",
"--",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java#L2749-L2752 |
landawn/AbacusUtil | src/com/landawn/abacus/util/CSVUtil.java | CSVUtil.loadCSV | @SuppressWarnings("rawtypes")
public static <E extends Exception> DataSet loadCSV(final File csvFile, final long offset, final long count, final Try.Predicate<String[], E> filter,
final Map<String, ? extends Type> columnTypeMap) throws UncheckedIOException, E {
"""
Load the data from CSV.
@param csvFile
@param offset
@param count
@param filter
@param columnTypeMap
@return
"""
InputStream csvInputStream = null;
try {
csvInputStream = new FileInputStream(csvFile);
return loadCSV(csvInputStream, offset, count, filter, columnTypeMap);
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
IOUtil.closeQuietly(csvInputStream);
}
} | java | @SuppressWarnings("rawtypes")
public static <E extends Exception> DataSet loadCSV(final File csvFile, final long offset, final long count, final Try.Predicate<String[], E> filter,
final Map<String, ? extends Type> columnTypeMap) throws UncheckedIOException, E {
InputStream csvInputStream = null;
try {
csvInputStream = new FileInputStream(csvFile);
return loadCSV(csvInputStream, offset, count, filter, columnTypeMap);
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
IOUtil.closeQuietly(csvInputStream);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"<",
"E",
"extends",
"Exception",
">",
"DataSet",
"loadCSV",
"(",
"final",
"File",
"csvFile",
",",
"final",
"long",
"offset",
",",
"final",
"long",
"count",
",",
"final",
"Try",
".",
"Predicate",
"<",
"String",
"[",
"]",
",",
"E",
">",
"filter",
",",
"final",
"Map",
"<",
"String",
",",
"?",
"extends",
"Type",
">",
"columnTypeMap",
")",
"throws",
"UncheckedIOException",
",",
"E",
"{",
"InputStream",
"csvInputStream",
"=",
"null",
";",
"try",
"{",
"csvInputStream",
"=",
"new",
"FileInputStream",
"(",
"csvFile",
")",
";",
"return",
"loadCSV",
"(",
"csvInputStream",
",",
"offset",
",",
"count",
",",
"filter",
",",
"columnTypeMap",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"UncheckedIOException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"IOUtil",
".",
"closeQuietly",
"(",
"csvInputStream",
")",
";",
"}",
"}"
] | Load the data from CSV.
@param csvFile
@param offset
@param count
@param filter
@param columnTypeMap
@return | [
"Load",
"the",
"data",
"from",
"CSV",
".",
"@param",
"csvFile",
"@param",
"offset",
"@param",
"count",
"@param",
"filter",
"@param",
"columnTypeMap"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/CSVUtil.java#L404-L418 |
Red5/red5-server-common | src/main/java/org/red5/server/net/rtmp/RTMPHandler.java | RTMPHandler.invokeCall | protected void invokeCall(RTMPConnection conn, IServiceCall call) {
"""
Remoting call invocation handler.
@param conn
RTMP connection
@param call
Service call
"""
final IScope scope = conn.getScope();
if (scope != null) {
if (scope.hasHandler()) {
final IScopeHandler handler = scope.getHandler();
log.debug("Scope: {} handler: {}", scope, handler);
if (!handler.serviceCall(conn, call)) {
// XXX: What to do here? Return an error?
log.warn("Scope: {} handler failed on service call", scope.getName(), new Exception("Service call failed"));
return;
}
}
final IContext context = scope.getContext();
log.debug("Context: {}", context);
context.getServiceInvoker().invoke(call, scope);
} else {
log.warn("Scope was null for invoke: {} connection state: {}", call.getServiceMethodName(), conn.getStateCode());
}
} | java | protected void invokeCall(RTMPConnection conn, IServiceCall call) {
final IScope scope = conn.getScope();
if (scope != null) {
if (scope.hasHandler()) {
final IScopeHandler handler = scope.getHandler();
log.debug("Scope: {} handler: {}", scope, handler);
if (!handler.serviceCall(conn, call)) {
// XXX: What to do here? Return an error?
log.warn("Scope: {} handler failed on service call", scope.getName(), new Exception("Service call failed"));
return;
}
}
final IContext context = scope.getContext();
log.debug("Context: {}", context);
context.getServiceInvoker().invoke(call, scope);
} else {
log.warn("Scope was null for invoke: {} connection state: {}", call.getServiceMethodName(), conn.getStateCode());
}
} | [
"protected",
"void",
"invokeCall",
"(",
"RTMPConnection",
"conn",
",",
"IServiceCall",
"call",
")",
"{",
"final",
"IScope",
"scope",
"=",
"conn",
".",
"getScope",
"(",
")",
";",
"if",
"(",
"scope",
"!=",
"null",
")",
"{",
"if",
"(",
"scope",
".",
"hasHandler",
"(",
")",
")",
"{",
"final",
"IScopeHandler",
"handler",
"=",
"scope",
".",
"getHandler",
"(",
")",
";",
"log",
".",
"debug",
"(",
"\"Scope: {} handler: {}\"",
",",
"scope",
",",
"handler",
")",
";",
"if",
"(",
"!",
"handler",
".",
"serviceCall",
"(",
"conn",
",",
"call",
")",
")",
"{",
"// XXX: What to do here? Return an error?\r",
"log",
".",
"warn",
"(",
"\"Scope: {} handler failed on service call\"",
",",
"scope",
".",
"getName",
"(",
")",
",",
"new",
"Exception",
"(",
"\"Service call failed\"",
")",
")",
";",
"return",
";",
"}",
"}",
"final",
"IContext",
"context",
"=",
"scope",
".",
"getContext",
"(",
")",
";",
"log",
".",
"debug",
"(",
"\"Context: {}\"",
",",
"context",
")",
";",
"context",
".",
"getServiceInvoker",
"(",
")",
".",
"invoke",
"(",
"call",
",",
"scope",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"\"Scope was null for invoke: {} connection state: {}\"",
",",
"call",
".",
"getServiceMethodName",
"(",
")",
",",
"conn",
".",
"getStateCode",
"(",
")",
")",
";",
"}",
"}"
] | Remoting call invocation handler.
@param conn
RTMP connection
@param call
Service call | [
"Remoting",
"call",
"invocation",
"handler",
"."
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/net/rtmp/RTMPHandler.java#L177-L195 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpx/MPXReader.java | MPXReader.addDateRange | private void addDateRange(ProjectCalendarHours hours, Date start, Date end) {
"""
Get a date range that correctly handles the case where the end time
is midnight. In this instance the end time should be the start of the
next day.
@param hours calendar hours
@param start start date
@param end end date
"""
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
}
end = cal.getTime();
DateHelper.pushCalendar(cal);
hours.addRange(new DateRange(start, end));
}
} | java | private void addDateRange(ProjectCalendarHours hours, Date start, Date end)
{
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
}
end = cal.getTime();
DateHelper.pushCalendar(cal);
hours.addRange(new DateRange(start, end));
}
} | [
"private",
"void",
"addDateRange",
"(",
"ProjectCalendarHours",
"hours",
",",
"Date",
"start",
",",
"Date",
"end",
")",
"{",
"if",
"(",
"start",
"!=",
"null",
"&&",
"end",
"!=",
"null",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"end",
")",
";",
"// If the time ends on midnight, the date should be the next day. Otherwise problems occur.",
"if",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
")",
"==",
"0",
"&&",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MINUTE",
")",
"==",
"0",
"&&",
"cal",
".",
"get",
"(",
"Calendar",
".",
"SECOND",
")",
"==",
"0",
"&&",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MILLISECOND",
")",
"==",
"0",
")",
"{",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"1",
")",
";",
"}",
"end",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"hours",
".",
"addRange",
"(",
"new",
"DateRange",
"(",
"start",
",",
"end",
")",
")",
";",
"}",
"}"
] | Get a date range that correctly handles the case where the end time
is midnight. In this instance the end time should be the start of the
next day.
@param hours calendar hours
@param start start date
@param end end date | [
"Get",
"a",
"date",
"range",
"that",
"correctly",
"handles",
"the",
"case",
"where",
"the",
"end",
"time",
"is",
"midnight",
".",
"In",
"this",
"instance",
"the",
"end",
"time",
"should",
"be",
"the",
"start",
"of",
"the",
"next",
"day",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXReader.java#L649-L664 |
matthewhorridge/mdock | src/main/java/org/coode/mdock/SplitterNode.java | SplitterNode.insertNodeAfter | public void insertNodeAfter(Node insert, Node after, double split) {
"""
Inserts a node after (right of or bottom of) a given node by splitting the inserted
node with the given node.
@param insert The node to be inserted
@param after The node that the inserted node will be split with.
@param split The weight
"""
addChild(insert, children.indexOf(after) + 1, split);
notifyStateChange();
} | java | public void insertNodeAfter(Node insert, Node after, double split) {
addChild(insert, children.indexOf(after) + 1, split);
notifyStateChange();
} | [
"public",
"void",
"insertNodeAfter",
"(",
"Node",
"insert",
",",
"Node",
"after",
",",
"double",
"split",
")",
"{",
"addChild",
"(",
"insert",
",",
"children",
".",
"indexOf",
"(",
"after",
")",
"+",
"1",
",",
"split",
")",
";",
"notifyStateChange",
"(",
")",
";",
"}"
] | Inserts a node after (right of or bottom of) a given node by splitting the inserted
node with the given node.
@param insert The node to be inserted
@param after The node that the inserted node will be split with.
@param split The weight | [
"Inserts",
"a",
"node",
"after",
"(",
"right",
"of",
"or",
"bottom",
"of",
")",
"a",
"given",
"node",
"by",
"splitting",
"the",
"inserted",
"node",
"with",
"the",
"given",
"node",
"."
] | train | https://github.com/matthewhorridge/mdock/blob/37839a56f30bdb73d56d82c4d1afe548d66b404b/src/main/java/org/coode/mdock/SplitterNode.java#L291-L294 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java | BloatedAssignmentScope.sawLoad | private void sawLoad(int seen, int pc) {
"""
processes a register store by updating the appropriate scope block to mark this register as being read in the block
@param seen
the currently parsed opcode
@param pc
the current program counter
"""
int reg = RegisterUtils.getLoadReg(this, seen);
if (!ignoreRegs.get(reg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
if (sb != null) {
sb.addLoad(reg, pc);
} else {
ignoreRegs.set(reg);
}
}
} | java | private void sawLoad(int seen, int pc) {
int reg = RegisterUtils.getLoadReg(this, seen);
if (!ignoreRegs.get(reg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
if (sb != null) {
sb.addLoad(reg, pc);
} else {
ignoreRegs.set(reg);
}
}
} | [
"private",
"void",
"sawLoad",
"(",
"int",
"seen",
",",
"int",
"pc",
")",
"{",
"int",
"reg",
"=",
"RegisterUtils",
".",
"getLoadReg",
"(",
"this",
",",
"seen",
")",
";",
"if",
"(",
"!",
"ignoreRegs",
".",
"get",
"(",
"reg",
")",
")",
"{",
"ScopeBlock",
"sb",
"=",
"findScopeBlock",
"(",
"rootScopeBlock",
",",
"pc",
")",
";",
"if",
"(",
"sb",
"!=",
"null",
")",
"{",
"sb",
".",
"addLoad",
"(",
"reg",
",",
"pc",
")",
";",
"}",
"else",
"{",
"ignoreRegs",
".",
"set",
"(",
"reg",
")",
";",
"}",
"}",
"}"
] | processes a register store by updating the appropriate scope block to mark this register as being read in the block
@param seen
the currently parsed opcode
@param pc
the current program counter | [
"processes",
"a",
"register",
"store",
"by",
"updating",
"the",
"appropriate",
"scope",
"block",
"to",
"mark",
"this",
"register",
"as",
"being",
"read",
"in",
"the",
"block"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java#L355-L365 |
ixa-ehu/ixa-pipe-pos | src/main/java/eus/ixa/ixa/pipe/pos/MorphoFactory.java | MorphoFactory.createMorpheme | public final Morpheme createMorpheme(final String word, final String tag) {
"""
Construct morpheme object with word and morphological tag.
@param word
the word
@param tag
the morphological tag
@return the morpheme object
"""
final Morpheme morpheme = new Morpheme();
morpheme.setValue(word);
morpheme.setTag(tag);
return morpheme;
} | java | public final Morpheme createMorpheme(final String word, final String tag) {
final Morpheme morpheme = new Morpheme();
morpheme.setValue(word);
morpheme.setTag(tag);
return morpheme;
} | [
"public",
"final",
"Morpheme",
"createMorpheme",
"(",
"final",
"String",
"word",
",",
"final",
"String",
"tag",
")",
"{",
"final",
"Morpheme",
"morpheme",
"=",
"new",
"Morpheme",
"(",
")",
";",
"morpheme",
".",
"setValue",
"(",
"word",
")",
";",
"morpheme",
".",
"setTag",
"(",
"tag",
")",
";",
"return",
"morpheme",
";",
"}"
] | Construct morpheme object with word and morphological tag.
@param word
the word
@param tag
the morphological tag
@return the morpheme object | [
"Construct",
"morpheme",
"object",
"with",
"word",
"and",
"morphological",
"tag",
"."
] | train | https://github.com/ixa-ehu/ixa-pipe-pos/blob/083c986103f95ae8063b8ddc89a2caa8047d29b9/src/main/java/eus/ixa/ixa/pipe/pos/MorphoFactory.java#L36-L41 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java | ConstructorBuilder.getInstance | public static ConstructorBuilder getInstance(Context context,
TypeElement typeElement, ConstructorWriter writer) {
"""
Construct a new ConstructorBuilder.
@param context the build context.
@param typeElement the class whoses members are being documented.
@param writer the doclet specific writer.
@return the new ConstructorBuilder
"""
return new ConstructorBuilder(context, typeElement, writer);
} | java | public static ConstructorBuilder getInstance(Context context,
TypeElement typeElement, ConstructorWriter writer) {
return new ConstructorBuilder(context, typeElement, writer);
} | [
"public",
"static",
"ConstructorBuilder",
"getInstance",
"(",
"Context",
"context",
",",
"TypeElement",
"typeElement",
",",
"ConstructorWriter",
"writer",
")",
"{",
"return",
"new",
"ConstructorBuilder",
"(",
"context",
",",
"typeElement",
",",
"writer",
")",
";",
"}"
] | Construct a new ConstructorBuilder.
@param context the build context.
@param typeElement the class whoses members are being documented.
@param writer the doclet specific writer.
@return the new ConstructorBuilder | [
"Construct",
"a",
"new",
"ConstructorBuilder",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java#L115-L118 |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedCollection.java | FileBasedCollection.addEntry | public Entry addEntry(final Entry entry) throws Exception {
"""
Add entry to collection.
@param entry Entry to be added to collection. Entry will be saved to disk in a directory
under the collection's directory and the path will follow the pattern
[collection-plural]/[entryid]/entry.xml. The entry will be added to the
collection's feed in [collection-plural]/feed.xml.
@throws java.lang.Exception On error.
@return Entry as it exists on the server.
"""
synchronized (FileStore.getFileStore()) {
final Feed f = getFeedDocument();
final String fsid = FileStore.getFileStore().getNextId();
updateTimestamps(entry);
// Save entry to file
final String entryPath = getEntryPath(fsid);
final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
updateEntryAppLinks(entry, fsid, true);
Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
os.flush();
os.close();
// Update feed file
updateEntryAppLinks(entry, fsid, false);
updateFeedDocumentWithNewEntry(f, entry);
return entry;
}
} | java | public Entry addEntry(final Entry entry) throws Exception {
synchronized (FileStore.getFileStore()) {
final Feed f = getFeedDocument();
final String fsid = FileStore.getFileStore().getNextId();
updateTimestamps(entry);
// Save entry to file
final String entryPath = getEntryPath(fsid);
final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
updateEntryAppLinks(entry, fsid, true);
Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
os.flush();
os.close();
// Update feed file
updateEntryAppLinks(entry, fsid, false);
updateFeedDocumentWithNewEntry(f, entry);
return entry;
}
} | [
"public",
"Entry",
"addEntry",
"(",
"final",
"Entry",
"entry",
")",
"throws",
"Exception",
"{",
"synchronized",
"(",
"FileStore",
".",
"getFileStore",
"(",
")",
")",
"{",
"final",
"Feed",
"f",
"=",
"getFeedDocument",
"(",
")",
";",
"final",
"String",
"fsid",
"=",
"FileStore",
".",
"getFileStore",
"(",
")",
".",
"getNextId",
"(",
")",
";",
"updateTimestamps",
"(",
"entry",
")",
";",
"// Save entry to file",
"final",
"String",
"entryPath",
"=",
"getEntryPath",
"(",
"fsid",
")",
";",
"final",
"OutputStream",
"os",
"=",
"FileStore",
".",
"getFileStore",
"(",
")",
".",
"getFileOutputStream",
"(",
"entryPath",
")",
";",
"updateEntryAppLinks",
"(",
"entry",
",",
"fsid",
",",
"true",
")",
";",
"Atom10Generator",
".",
"serializeEntry",
"(",
"entry",
",",
"new",
"OutputStreamWriter",
"(",
"os",
",",
"\"UTF-8\"",
")",
")",
";",
"os",
".",
"flush",
"(",
")",
";",
"os",
".",
"close",
"(",
")",
";",
"// Update feed file",
"updateEntryAppLinks",
"(",
"entry",
",",
"fsid",
",",
"false",
")",
";",
"updateFeedDocumentWithNewEntry",
"(",
"f",
",",
"entry",
")",
";",
"return",
"entry",
";",
"}",
"}"
] | Add entry to collection.
@param entry Entry to be added to collection. Entry will be saved to disk in a directory
under the collection's directory and the path will follow the pattern
[collection-plural]/[entryid]/entry.xml. The entry will be added to the
collection's feed in [collection-plural]/feed.xml.
@throws java.lang.Exception On error.
@return Entry as it exists on the server. | [
"Add",
"entry",
"to",
"collection",
"."
] | train | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedCollection.java#L188-L210 |
michael-rapp/AndroidMaterialDialog | library/src/main/java/de/mrapp/android/dialog/adapter/ViewPagerAdapter.java | ViewPagerAdapter.addItem | public final void addItem(@Nullable final CharSequence title,
@NonNull final Class<? extends Fragment> fragmentClass,
@Nullable final Bundle arguments) {
"""
Adds a new fragment to the adapter.
@param title
The title of the fragment, which should be added, as an instance of the type {@link
CharSequence} or null, if no title should be set
@param fragmentClass
The class of the fragment, which should be added, as an instance of the class {@link
Class}. The class may not be null
@param arguments
A bundle, which should be passed to the fragment, when it is shown, as an instance of
the class {@link Bundle} or null, if no arguments should be passed to the fragment
"""
Condition.INSTANCE.ensureNotNull(fragmentClass, "The fragment class may not be null");
items.add(new ViewPagerItem(title, fragmentClass, arguments));
notifyDataSetChanged();
} | java | public final void addItem(@Nullable final CharSequence title,
@NonNull final Class<? extends Fragment> fragmentClass,
@Nullable final Bundle arguments) {
Condition.INSTANCE.ensureNotNull(fragmentClass, "The fragment class may not be null");
items.add(new ViewPagerItem(title, fragmentClass, arguments));
notifyDataSetChanged();
} | [
"public",
"final",
"void",
"addItem",
"(",
"@",
"Nullable",
"final",
"CharSequence",
"title",
",",
"@",
"NonNull",
"final",
"Class",
"<",
"?",
"extends",
"Fragment",
">",
"fragmentClass",
",",
"@",
"Nullable",
"final",
"Bundle",
"arguments",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"fragmentClass",
",",
"\"The fragment class may not be null\"",
")",
";",
"items",
".",
"add",
"(",
"new",
"ViewPagerItem",
"(",
"title",
",",
"fragmentClass",
",",
"arguments",
")",
")",
";",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] | Adds a new fragment to the adapter.
@param title
The title of the fragment, which should be added, as an instance of the type {@link
CharSequence} or null, if no title should be set
@param fragmentClass
The class of the fragment, which should be added, as an instance of the class {@link
Class}. The class may not be null
@param arguments
A bundle, which should be passed to the fragment, when it is shown, as an instance of
the class {@link Bundle} or null, if no arguments should be passed to the fragment | [
"Adds",
"a",
"new",
"fragment",
"to",
"the",
"adapter",
"."
] | train | https://github.com/michael-rapp/AndroidMaterialDialog/blob/8990eed72ee5f5a9720836ee708f71ac0d43053b/library/src/main/java/de/mrapp/android/dialog/adapter/ViewPagerAdapter.java#L84-L90 |
sagiegurari/fax4j | src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java | HylaFaxJob.getSenderName | public String getSenderName() {
"""
This function returns the fax job sender name.
@return The fax job sender name
"""
String value=null;
try
{
value=this.JOB.getFromUser();
}
catch(Exception exception)
{
throw new FaxException("Error while extracting job sender name.",exception);
}
return value;
} | java | public String getSenderName()
{
String value=null;
try
{
value=this.JOB.getFromUser();
}
catch(Exception exception)
{
throw new FaxException("Error while extracting job sender name.",exception);
}
return value;
} | [
"public",
"String",
"getSenderName",
"(",
")",
"{",
"String",
"value",
"=",
"null",
";",
"try",
"{",
"value",
"=",
"this",
".",
"JOB",
".",
"getFromUser",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"exception",
")",
"{",
"throw",
"new",
"FaxException",
"(",
"\"Error while extracting job sender name.\"",
",",
"exception",
")",
";",
"}",
"return",
"value",
";",
"}"
] | This function returns the fax job sender name.
@return The fax job sender name | [
"This",
"function",
"returns",
"the",
"fax",
"job",
"sender",
"name",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxJob.java#L225-L238 |
google/closure-compiler | src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java | PeepholeMinimizeConditions.maybeReplaceChildWithNumber | private Node maybeReplaceChildWithNumber(Node n, Node parent, int num) {
"""
Replaces a node with a number node if the new number node is not equivalent
to the current node.
Returns the replacement for n if it was replaced, otherwise returns n.
"""
Node newNode = IR.number(num);
if (!newNode.isEquivalentTo(n)) {
parent.replaceChild(n, newNode);
reportChangeToEnclosingScope(newNode);
markFunctionsDeleted(n);
return newNode;
}
return n;
} | java | private Node maybeReplaceChildWithNumber(Node n, Node parent, int num) {
Node newNode = IR.number(num);
if (!newNode.isEquivalentTo(n)) {
parent.replaceChild(n, newNode);
reportChangeToEnclosingScope(newNode);
markFunctionsDeleted(n);
return newNode;
}
return n;
} | [
"private",
"Node",
"maybeReplaceChildWithNumber",
"(",
"Node",
"n",
",",
"Node",
"parent",
",",
"int",
"num",
")",
"{",
"Node",
"newNode",
"=",
"IR",
".",
"number",
"(",
"num",
")",
";",
"if",
"(",
"!",
"newNode",
".",
"isEquivalentTo",
"(",
"n",
")",
")",
"{",
"parent",
".",
"replaceChild",
"(",
"n",
",",
"newNode",
")",
";",
"reportChangeToEnclosingScope",
"(",
"newNode",
")",
";",
"markFunctionsDeleted",
"(",
"n",
")",
";",
"return",
"newNode",
";",
"}",
"return",
"n",
";",
"}"
] | Replaces a node with a number node if the new number node is not equivalent
to the current node.
Returns the replacement for n if it was replaced, otherwise returns n. | [
"Replaces",
"a",
"node",
"with",
"a",
"number",
"node",
"if",
"the",
"new",
"number",
"node",
"is",
"not",
"equivalent",
"to",
"the",
"current",
"node",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L1140-L1151 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_historyConsumption_date_file_GET | public OvhPcsFile billingAccount_historyConsumption_date_file_GET(String billingAccount, java.util.Date date, OvhBillDocument extension) throws IOException {
"""
Previous billed consumption files
REST: GET /telephony/{billingAccount}/historyConsumption/{date}/file
@param extension [required] Document suffix
@param billingAccount [required] The name of your billingAccount
@param date [required]
"""
String qPath = "/telephony/{billingAccount}/historyConsumption/{date}/file";
StringBuilder sb = path(qPath, billingAccount, date);
query(sb, "extension", extension);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPcsFile.class);
} | java | public OvhPcsFile billingAccount_historyConsumption_date_file_GET(String billingAccount, java.util.Date date, OvhBillDocument extension) throws IOException {
String qPath = "/telephony/{billingAccount}/historyConsumption/{date}/file";
StringBuilder sb = path(qPath, billingAccount, date);
query(sb, "extension", extension);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPcsFile.class);
} | [
"public",
"OvhPcsFile",
"billingAccount_historyConsumption_date_file_GET",
"(",
"String",
"billingAccount",
",",
"java",
".",
"util",
".",
"Date",
"date",
",",
"OvhBillDocument",
"extension",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/historyConsumption/{date}/file\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"date",
")",
";",
"query",
"(",
"sb",
",",
"\"extension\"",
",",
"extension",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPcsFile",
".",
"class",
")",
";",
"}"
] | Previous billed consumption files
REST: GET /telephony/{billingAccount}/historyConsumption/{date}/file
@param extension [required] Document suffix
@param billingAccount [required] The name of your billingAccount
@param date [required] | [
"Previous",
"billed",
"consumption",
"files"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L685-L691 |
VoltDB/voltdb | src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java | JDBC4ClientConnection.updateApplicationCatalog | public ClientResponse updateApplicationCatalog(File catalogPath, File deploymentPath)
throws IOException, NoConnectionsException, ProcCallException {
"""
Synchronously invokes UpdateApplicationCatalog procedure. Blocks until a result is available.
A {@link ProcCallException} is thrown if the response is anything other then success.
@param catalogPath
Path to the catalog jar file.
@param deploymentPath
Path to the deployment file
@return array of VoltTable results
@throws IOException
If the files cannot be serialized
@throws NoConnectionException
@throws ProcCallException
"""
ClientImpl currentClient = this.getClient();
try {
return currentClient.updateApplicationCatalog(catalogPath, deploymentPath);
}
catch (NoConnectionsException e) {
this.dropClient(currentClient);
throw e;
}
} | java | public ClientResponse updateApplicationCatalog(File catalogPath, File deploymentPath)
throws IOException, NoConnectionsException, ProcCallException
{
ClientImpl currentClient = this.getClient();
try {
return currentClient.updateApplicationCatalog(catalogPath, deploymentPath);
}
catch (NoConnectionsException e) {
this.dropClient(currentClient);
throw e;
}
} | [
"public",
"ClientResponse",
"updateApplicationCatalog",
"(",
"File",
"catalogPath",
",",
"File",
"deploymentPath",
")",
"throws",
"IOException",
",",
"NoConnectionsException",
",",
"ProcCallException",
"{",
"ClientImpl",
"currentClient",
"=",
"this",
".",
"getClient",
"(",
")",
";",
"try",
"{",
"return",
"currentClient",
".",
"updateApplicationCatalog",
"(",
"catalogPath",
",",
"deploymentPath",
")",
";",
"}",
"catch",
"(",
"NoConnectionsException",
"e",
")",
"{",
"this",
".",
"dropClient",
"(",
"currentClient",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | Synchronously invokes UpdateApplicationCatalog procedure. Blocks until a result is available.
A {@link ProcCallException} is thrown if the response is anything other then success.
@param catalogPath
Path to the catalog jar file.
@param deploymentPath
Path to the deployment file
@return array of VoltTable results
@throws IOException
If the files cannot be serialized
@throws NoConnectionException
@throws ProcCallException | [
"Synchronously",
"invokes",
"UpdateApplicationCatalog",
"procedure",
".",
"Blocks",
"until",
"a",
"result",
"is",
"available",
".",
"A",
"{",
"@link",
"ProcCallException",
"}",
"is",
"thrown",
"if",
"the",
"response",
"is",
"anything",
"other",
"then",
"success",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4ClientConnection.java#L540-L551 |
amaembo/streamex | src/main/java/one/util/streamex/IntStreamEx.java | IntStreamEx.rangeClosed | public static IntStreamEx rangeClosed(int startInclusive, int endInclusive, int step) {
"""
Returns a sequential ordered {@code IntStreamEx} from
{@code startInclusive} (inclusive) to {@code endInclusive} (inclusive) by
the specified incremental step. The negative step values are also
supported. In this case the {@code startInclusive} should be greater than
{@code endInclusive}.
<p>
Note that depending on the step value the {@code endInclusive} bound may
still not be reached. For example
{@code IntStreamEx.rangeClosed(0, 5, 2)} will yield the stream of three
numbers: 0, 2 and 4.
@param startInclusive the (inclusive) initial value
@param endInclusive the inclusive upper bound
@param step the non-zero value which designates the difference between
the consecutive values of the resulting stream.
@return a sequential {@code IntStreamEx} for the range of {@code int}
elements
@throws IllegalArgumentException if step is zero
@see IntStreamEx#rangeClosed(int, int)
@since 0.4.0
"""
if (step == 0)
throw new IllegalArgumentException("step = 0");
if (step == 1)
return seq(IntStream.rangeClosed(startInclusive, endInclusive));
if (step == -1) {
// Handled specially as number of elements can exceed
// Integer.MAX_VALUE
int sum = endInclusive + startInclusive;
return seq(IntStream.rangeClosed(endInclusive, startInclusive).map(x -> sum - x));
}
if (endInclusive > startInclusive ^ step > 0)
return empty();
int limit = (endInclusive - startInclusive) * Integer.signum(step);
limit = Integer.divideUnsigned(limit, Math.abs(step));
return seq(IntStream.rangeClosed(0, limit).map(x -> x * step + startInclusive));
} | java | public static IntStreamEx rangeClosed(int startInclusive, int endInclusive, int step) {
if (step == 0)
throw new IllegalArgumentException("step = 0");
if (step == 1)
return seq(IntStream.rangeClosed(startInclusive, endInclusive));
if (step == -1) {
// Handled specially as number of elements can exceed
// Integer.MAX_VALUE
int sum = endInclusive + startInclusive;
return seq(IntStream.rangeClosed(endInclusive, startInclusive).map(x -> sum - x));
}
if (endInclusive > startInclusive ^ step > 0)
return empty();
int limit = (endInclusive - startInclusive) * Integer.signum(step);
limit = Integer.divideUnsigned(limit, Math.abs(step));
return seq(IntStream.rangeClosed(0, limit).map(x -> x * step + startInclusive));
} | [
"public",
"static",
"IntStreamEx",
"rangeClosed",
"(",
"int",
"startInclusive",
",",
"int",
"endInclusive",
",",
"int",
"step",
")",
"{",
"if",
"(",
"step",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"step = 0\"",
")",
";",
"if",
"(",
"step",
"==",
"1",
")",
"return",
"seq",
"(",
"IntStream",
".",
"rangeClosed",
"(",
"startInclusive",
",",
"endInclusive",
")",
")",
";",
"if",
"(",
"step",
"==",
"-",
"1",
")",
"{",
"// Handled specially as number of elements can exceed",
"// Integer.MAX_VALUE",
"int",
"sum",
"=",
"endInclusive",
"+",
"startInclusive",
";",
"return",
"seq",
"(",
"IntStream",
".",
"rangeClosed",
"(",
"endInclusive",
",",
"startInclusive",
")",
".",
"map",
"(",
"x",
"->",
"sum",
"-",
"x",
")",
")",
";",
"}",
"if",
"(",
"endInclusive",
">",
"startInclusive",
"^",
"step",
">",
"0",
")",
"return",
"empty",
"(",
")",
";",
"int",
"limit",
"=",
"(",
"endInclusive",
"-",
"startInclusive",
")",
"*",
"Integer",
".",
"signum",
"(",
"step",
")",
";",
"limit",
"=",
"Integer",
".",
"divideUnsigned",
"(",
"limit",
",",
"Math",
".",
"abs",
"(",
"step",
")",
")",
";",
"return",
"seq",
"(",
"IntStream",
".",
"rangeClosed",
"(",
"0",
",",
"limit",
")",
".",
"map",
"(",
"x",
"->",
"x",
"*",
"step",
"+",
"startInclusive",
")",
")",
";",
"}"
] | Returns a sequential ordered {@code IntStreamEx} from
{@code startInclusive} (inclusive) to {@code endInclusive} (inclusive) by
the specified incremental step. The negative step values are also
supported. In this case the {@code startInclusive} should be greater than
{@code endInclusive}.
<p>
Note that depending on the step value the {@code endInclusive} bound may
still not be reached. For example
{@code IntStreamEx.rangeClosed(0, 5, 2)} will yield the stream of three
numbers: 0, 2 and 4.
@param startInclusive the (inclusive) initial value
@param endInclusive the inclusive upper bound
@param step the non-zero value which designates the difference between
the consecutive values of the resulting stream.
@return a sequential {@code IntStreamEx} for the range of {@code int}
elements
@throws IllegalArgumentException if step is zero
@see IntStreamEx#rangeClosed(int, int)
@since 0.4.0 | [
"Returns",
"a",
"sequential",
"ordered",
"{",
"@code",
"IntStreamEx",
"}",
"from",
"{",
"@code",
"startInclusive",
"}",
"(",
"inclusive",
")",
"to",
"{",
"@code",
"endInclusive",
"}",
"(",
"inclusive",
")",
"by",
"the",
"specified",
"incremental",
"step",
".",
"The",
"negative",
"step",
"values",
"are",
"also",
"supported",
".",
"In",
"this",
"case",
"the",
"{",
"@code",
"startInclusive",
"}",
"should",
"be",
"greater",
"than",
"{",
"@code",
"endInclusive",
"}",
"."
] | train | https://github.com/amaembo/streamex/blob/936bbd1b7dfbcf64a3b990682bfc848213441d14/src/main/java/one/util/streamex/IntStreamEx.java#L2579-L2595 |
Coveros/selenified | src/main/java/com/coveros/selenified/element/Element.java | Element.isNotPresentDisplayedEnabledInput | private boolean isNotPresentDisplayedEnabledInput(String action, String expected, String extra) {
"""
Determines if something is present, displayed, enabled, and an input.
This returns true if all four are true, otherwise, it returns false
@param action - what action is occurring
@param expected - what is the expected result
@param extra - what actually is occurring
@return Boolean: is the element present, displayed, enabled, and an
input?
"""
// wait for element to be present
if (isNotPresent(action, expected, extra)) {
return true;
}
// wait for element to be displayed
if (isNotDisplayed(action, expected, extra)) {
return true;
}
// wait for element to be enabled
return isNotEnabled(action, expected, extra) || isNotInput(action, expected, extra);
} | java | private boolean isNotPresentDisplayedEnabledInput(String action, String expected, String extra) {
// wait for element to be present
if (isNotPresent(action, expected, extra)) {
return true;
}
// wait for element to be displayed
if (isNotDisplayed(action, expected, extra)) {
return true;
}
// wait for element to be enabled
return isNotEnabled(action, expected, extra) || isNotInput(action, expected, extra);
} | [
"private",
"boolean",
"isNotPresentDisplayedEnabledInput",
"(",
"String",
"action",
",",
"String",
"expected",
",",
"String",
"extra",
")",
"{",
"// wait for element to be present",
"if",
"(",
"isNotPresent",
"(",
"action",
",",
"expected",
",",
"extra",
")",
")",
"{",
"return",
"true",
";",
"}",
"// wait for element to be displayed",
"if",
"(",
"isNotDisplayed",
"(",
"action",
",",
"expected",
",",
"extra",
")",
")",
"{",
"return",
"true",
";",
"}",
"// wait for element to be enabled",
"return",
"isNotEnabled",
"(",
"action",
",",
"expected",
",",
"extra",
")",
"||",
"isNotInput",
"(",
"action",
",",
"expected",
",",
"extra",
")",
";",
"}"
] | Determines if something is present, displayed, enabled, and an input.
This returns true if all four are true, otherwise, it returns false
@param action - what action is occurring
@param expected - what is the expected result
@param extra - what actually is occurring
@return Boolean: is the element present, displayed, enabled, and an
input? | [
"Determines",
"if",
"something",
"is",
"present",
"displayed",
"enabled",
"and",
"an",
"input",
".",
"This",
"returns",
"true",
"if",
"all",
"four",
"are",
"true",
"otherwise",
"it",
"returns",
"false"
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/element/Element.java#L734-L745 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java | BaseTaglet.getTagletOutput | public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) {
"""
{@inheritDoc}
@throws UnsupportedTagletOperationException thrown when the method is
not supported by the taglet.
"""
throw new UnsupportedTagletOperationException("Method not supported in taglet " + getName() + ".");
} | java | public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) {
throw new UnsupportedTagletOperationException("Method not supported in taglet " + getName() + ".");
} | [
"public",
"Content",
"getTagletOutput",
"(",
"Element",
"element",
",",
"DocTree",
"tag",
",",
"TagletWriter",
"writer",
")",
"{",
"throw",
"new",
"UnsupportedTagletOperationException",
"(",
"\"Method not supported in taglet \"",
"+",
"getName",
"(",
")",
"+",
"\".\"",
")",
";",
"}"
] | {@inheritDoc}
@throws UnsupportedTagletOperationException thrown when the method is
not supported by the taglet. | [
"{"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java#L147-L149 |
nguillaumin/slick2d-maven | slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/TTFFile.java | TTFFile.checkTTC | protected final boolean checkTTC(FontFileReader in, String name) throws IOException {
"""
Check if this is a TrueType collection and that the given
name exists in the collection.
If it does, set offset in fontfile to the beginning of
the Table Directory for that font.
@param in FontFileReader to read from
@param name The name to check
@return True if not collection or font name present, false otherwise
@throws IOException In case of an I/O problem
"""
String tag = in.readTTFString(4);
if ("ttcf".equals(tag)) {
// This is a TrueType Collection
in.skip(4);
// Read directory offsets
int numDirectories = (int)in.readTTFULong();
// int numDirectories=in.readTTFUShort();
long[] dirOffsets = new long[numDirectories];
for (int i = 0; i < numDirectories; i++) {
dirOffsets[i] = in.readTTFULong();
}
log.info("This is a TrueType collection file with "
+ numDirectories + " fonts");
log.info("Containing the following fonts: ");
// Read all the directories and name tables to check
// If the font exists - this is a bit ugly, but...
boolean found = false;
// Iterate through all name tables even if font
// Is found, just to show all the names
long dirTabOffset = 0;
for (int i = 0; (i < numDirectories); i++) {
in.seekSet(dirOffsets[i]);
readDirTabs(in);
readName(in);
if (fullName.equals(name)) {
found = true;
dirTabOffset = dirOffsets[i];
log.info(fullName + " <-- selected");
} else {
log.info(fullName);
}
// Reset names
notice = "";
fullName = "";
familyName = "";
fontName = "";
subFamilyName = "";
}
in.seekSet(dirTabOffset);
return found;
} else {
in.seekSet(0);
return true;
}
} | java | protected final boolean checkTTC(FontFileReader in, String name) throws IOException {
String tag = in.readTTFString(4);
if ("ttcf".equals(tag)) {
// This is a TrueType Collection
in.skip(4);
// Read directory offsets
int numDirectories = (int)in.readTTFULong();
// int numDirectories=in.readTTFUShort();
long[] dirOffsets = new long[numDirectories];
for (int i = 0; i < numDirectories; i++) {
dirOffsets[i] = in.readTTFULong();
}
log.info("This is a TrueType collection file with "
+ numDirectories + " fonts");
log.info("Containing the following fonts: ");
// Read all the directories and name tables to check
// If the font exists - this is a bit ugly, but...
boolean found = false;
// Iterate through all name tables even if font
// Is found, just to show all the names
long dirTabOffset = 0;
for (int i = 0; (i < numDirectories); i++) {
in.seekSet(dirOffsets[i]);
readDirTabs(in);
readName(in);
if (fullName.equals(name)) {
found = true;
dirTabOffset = dirOffsets[i];
log.info(fullName + " <-- selected");
} else {
log.info(fullName);
}
// Reset names
notice = "";
fullName = "";
familyName = "";
fontName = "";
subFamilyName = "";
}
in.seekSet(dirTabOffset);
return found;
} else {
in.seekSet(0);
return true;
}
} | [
"protected",
"final",
"boolean",
"checkTTC",
"(",
"FontFileReader",
"in",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"String",
"tag",
"=",
"in",
".",
"readTTFString",
"(",
"4",
")",
";",
"if",
"(",
"\"ttcf\"",
".",
"equals",
"(",
"tag",
")",
")",
"{",
"// This is a TrueType Collection",
"in",
".",
"skip",
"(",
"4",
")",
";",
"// Read directory offsets",
"int",
"numDirectories",
"=",
"(",
"int",
")",
"in",
".",
"readTTFULong",
"(",
")",
";",
"// int numDirectories=in.readTTFUShort();",
"long",
"[",
"]",
"dirOffsets",
"=",
"new",
"long",
"[",
"numDirectories",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numDirectories",
";",
"i",
"++",
")",
"{",
"dirOffsets",
"[",
"i",
"]",
"=",
"in",
".",
"readTTFULong",
"(",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"This is a TrueType collection file with \"",
"+",
"numDirectories",
"+",
"\" fonts\"",
")",
";",
"log",
".",
"info",
"(",
"\"Containing the following fonts: \"",
")",
";",
"// Read all the directories and name tables to check",
"// If the font exists - this is a bit ugly, but...",
"boolean",
"found",
"=",
"false",
";",
"// Iterate through all name tables even if font",
"// Is found, just to show all the names",
"long",
"dirTabOffset",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"(",
"i",
"<",
"numDirectories",
")",
";",
"i",
"++",
")",
"{",
"in",
".",
"seekSet",
"(",
"dirOffsets",
"[",
"i",
"]",
")",
";",
"readDirTabs",
"(",
"in",
")",
";",
"readName",
"(",
"in",
")",
";",
"if",
"(",
"fullName",
".",
"equals",
"(",
"name",
")",
")",
"{",
"found",
"=",
"true",
";",
"dirTabOffset",
"=",
"dirOffsets",
"[",
"i",
"]",
";",
"log",
".",
"info",
"(",
"fullName",
"+",
"\" <-- selected\"",
")",
";",
"}",
"else",
"{",
"log",
".",
"info",
"(",
"fullName",
")",
";",
"}",
"// Reset names",
"notice",
"=",
"\"\"",
";",
"fullName",
"=",
"\"\"",
";",
"familyName",
"=",
"\"\"",
";",
"fontName",
"=",
"\"\"",
";",
"subFamilyName",
"=",
"\"\"",
";",
"}",
"in",
".",
"seekSet",
"(",
"dirTabOffset",
")",
";",
"return",
"found",
";",
"}",
"else",
"{",
"in",
".",
"seekSet",
"(",
"0",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Check if this is a TrueType collection and that the given
name exists in the collection.
If it does, set offset in fontfile to the beginning of
the Table Directory for that font.
@param in FontFileReader to read from
@param name The name to check
@return True if not collection or font name present, false otherwise
@throws IOException In case of an I/O problem | [
"Check",
"if",
"this",
"is",
"a",
"TrueType",
"collection",
"and",
"that",
"the",
"given",
"name",
"exists",
"in",
"the",
"collection",
".",
"If",
"it",
"does",
"set",
"offset",
"in",
"fontfile",
"to",
"the",
"beginning",
"of",
"the",
"Table",
"Directory",
"for",
"that",
"font",
"."
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/TTFFile.java#L1427-L1480 |
datacleaner/DataCleaner | desktop/ui/src/main/java/org/datacleaner/widgets/tabs/CloseableTabbedPaneUI.java | CloseableTabbedPaneUI.calculateTabWidth | @Override
protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) {
"""
Override this to provide extra space on right for close button
"""
if (_pane.getSeparators().contains(tabIndex)) {
return SEPARATOR_WIDTH;
}
int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
if (!_pane.getUnclosables().contains(tabIndex)) {
width += CLOSE_ICON_WIDTH;
}
return width;
} | java | @Override
protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) {
if (_pane.getSeparators().contains(tabIndex)) {
return SEPARATOR_WIDTH;
}
int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
if (!_pane.getUnclosables().contains(tabIndex)) {
width += CLOSE_ICON_WIDTH;
}
return width;
} | [
"@",
"Override",
"protected",
"int",
"calculateTabWidth",
"(",
"final",
"int",
"tabPlacement",
",",
"final",
"int",
"tabIndex",
",",
"final",
"FontMetrics",
"metrics",
")",
"{",
"if",
"(",
"_pane",
".",
"getSeparators",
"(",
")",
".",
"contains",
"(",
"tabIndex",
")",
")",
"{",
"return",
"SEPARATOR_WIDTH",
";",
"}",
"int",
"width",
"=",
"super",
".",
"calculateTabWidth",
"(",
"tabPlacement",
",",
"tabIndex",
",",
"metrics",
")",
";",
"if",
"(",
"!",
"_pane",
".",
"getUnclosables",
"(",
")",
".",
"contains",
"(",
"tabIndex",
")",
")",
"{",
"width",
"+=",
"CLOSE_ICON_WIDTH",
";",
"}",
"return",
"width",
";",
"}"
] | Override this to provide extra space on right for close button | [
"Override",
"this",
"to",
"provide",
"extra",
"space",
"on",
"right",
"for",
"close",
"button"
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/desktop/ui/src/main/java/org/datacleaner/widgets/tabs/CloseableTabbedPaneUI.java#L131-L141 |
cesarferreira/AndroidQuickUtils | library/src/main/java/quickutils/core/categories/math.java | math.getRandomDouble | public static double getRandomDouble(double min, double max) {
"""
Returns a random double between MIN inclusive and MAX inclusive.
@param min
value inclusive
@param max
value inclusive
@return an int between 0 inclusive and MAX exclusive.
"""
Random r = new Random();
return min + (max - min) * r.nextDouble();
} | java | public static double getRandomDouble(double min, double max) {
Random r = new Random();
return min + (max - min) * r.nextDouble();
} | [
"public",
"static",
"double",
"getRandomDouble",
"(",
"double",
"min",
",",
"double",
"max",
")",
"{",
"Random",
"r",
"=",
"new",
"Random",
"(",
")",
";",
"return",
"min",
"+",
"(",
"max",
"-",
"min",
")",
"*",
"r",
".",
"nextDouble",
"(",
")",
";",
"}"
] | Returns a random double between MIN inclusive and MAX inclusive.
@param min
value inclusive
@param max
value inclusive
@return an int between 0 inclusive and MAX exclusive. | [
"Returns",
"a",
"random",
"double",
"between",
"MIN",
"inclusive",
"and",
"MAX",
"inclusive",
"."
] | train | https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/categories/math.java#L125-L128 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bcc/BccClient.java | BccClient.createInstance | public CreateInstanceResponse createInstance(CreateInstanceRequest request)
throws BceClientException {
"""
Create a bcc Instance with the specified options,
see all the supported instance in {@link com.baidubce.services.bcc.model.instance.InstanceType}
You must fill the field of clientToken,which is especially for keeping idempotent.
This is an asynchronous interface,
you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)}
@param request The request containing all options for creating a bcc Instance.
@return List of instanceId newly created
@throws BceClientException
"""
checkNotNull(request, "request should not be null.");
if (Strings.isNullOrEmpty(request.getClientToken())) {
request.setClientToken(this.generateClientToken());
}
if (null == request.getBilling()) {
request.setBilling(generateDefaultBilling());
}
checkStringNotEmpty(request.getImageId(), "imageId should not be empty");
InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX);
internalRequest.addParameter("clientToken", request.getClientToken());
if (!Strings.isNullOrEmpty(request.getAdminPass())) {
BceCredentials credentials = config.getCredentials();
if (internalRequest.getCredentials() != null) {
credentials = internalRequest.getCredentials();
}
try {
request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey()));
} catch (GeneralSecurityException e) {
throw new BceClientException("Encryption procedure exception", e);
}
}
fillPayload(internalRequest, request);
return invokeHttpClient(internalRequest, CreateInstanceResponse.class);
} | java | public CreateInstanceResponse createInstance(CreateInstanceRequest request)
throws BceClientException {
checkNotNull(request, "request should not be null.");
if (Strings.isNullOrEmpty(request.getClientToken())) {
request.setClientToken(this.generateClientToken());
}
if (null == request.getBilling()) {
request.setBilling(generateDefaultBilling());
}
checkStringNotEmpty(request.getImageId(), "imageId should not be empty");
InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX);
internalRequest.addParameter("clientToken", request.getClientToken());
if (!Strings.isNullOrEmpty(request.getAdminPass())) {
BceCredentials credentials = config.getCredentials();
if (internalRequest.getCredentials() != null) {
credentials = internalRequest.getCredentials();
}
try {
request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey()));
} catch (GeneralSecurityException e) {
throw new BceClientException("Encryption procedure exception", e);
}
}
fillPayload(internalRequest, request);
return invokeHttpClient(internalRequest, CreateInstanceResponse.class);
} | [
"public",
"CreateInstanceResponse",
"createInstance",
"(",
"CreateInstanceRequest",
"request",
")",
"throws",
"BceClientException",
"{",
"checkNotNull",
"(",
"request",
",",
"\"request should not be null.\"",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"request",
".",
"getClientToken",
"(",
")",
")",
")",
"{",
"request",
".",
"setClientToken",
"(",
"this",
".",
"generateClientToken",
"(",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"request",
".",
"getBilling",
"(",
")",
")",
"{",
"request",
".",
"setBilling",
"(",
"generateDefaultBilling",
"(",
")",
")",
";",
"}",
"checkStringNotEmpty",
"(",
"request",
".",
"getImageId",
"(",
")",
",",
"\"imageId should not be empty\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"this",
".",
"createRequest",
"(",
"request",
",",
"HttpMethodName",
".",
"POST",
",",
"INSTANCE_PREFIX",
")",
";",
"internalRequest",
".",
"addParameter",
"(",
"\"clientToken\"",
",",
"request",
".",
"getClientToken",
"(",
")",
")",
";",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"request",
".",
"getAdminPass",
"(",
")",
")",
")",
"{",
"BceCredentials",
"credentials",
"=",
"config",
".",
"getCredentials",
"(",
")",
";",
"if",
"(",
"internalRequest",
".",
"getCredentials",
"(",
")",
"!=",
"null",
")",
"{",
"credentials",
"=",
"internalRequest",
".",
"getCredentials",
"(",
")",
";",
"}",
"try",
"{",
"request",
".",
"setAdminPass",
"(",
"this",
".",
"aes128WithFirst16Char",
"(",
"request",
".",
"getAdminPass",
"(",
")",
",",
"credentials",
".",
"getSecretKey",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"BceClientException",
"(",
"\"Encryption procedure exception\"",
",",
"e",
")",
";",
"}",
"}",
"fillPayload",
"(",
"internalRequest",
",",
"request",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"CreateInstanceResponse",
".",
"class",
")",
";",
"}"
] | Create a bcc Instance with the specified options,
see all the supported instance in {@link com.baidubce.services.bcc.model.instance.InstanceType}
You must fill the field of clientToken,which is especially for keeping idempotent.
This is an asynchronous interface,
you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)}
@param request The request containing all options for creating a bcc Instance.
@return List of instanceId newly created
@throws BceClientException | [
"Create",
"a",
"bcc",
"Instance",
"with",
"the",
"specified",
"options",
"see",
"all",
"the",
"supported",
"instance",
"in",
"{",
"@link",
"com",
".",
"baidubce",
".",
"services",
".",
"bcc",
".",
"model",
".",
"instance",
".",
"InstanceType",
"}",
"You",
"must",
"fill",
"the",
"field",
"of",
"clientToken",
"which",
"is",
"especially",
"for",
"keeping",
"idempotent",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bcc/BccClient.java#L272-L297 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java | LiveEventsInner.resetAsync | public Observable<Void> resetAsync(String resourceGroupName, String accountName, String liveEventName) {
"""
Reset Live Event.
Resets an existing Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return resetWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> resetAsync(String resourceGroupName, String accountName, String liveEventName) {
return resetWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"resetAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"liveEventName",
")",
"{",
"return",
"resetWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"liveEventName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Reset Live Event.
Resets an existing Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Reset",
"Live",
"Event",
".",
"Resets",
"an",
"existing",
"Live",
"Event",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java#L1684-L1691 |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java | LogBuffer.getDecimal | public final BigDecimal getDecimal(final int pos, final int precision, final int scale) {
"""
Return big decimal from buffer.
@see mysql-5.1.60/strings/decimal.c - bin2decimal()
"""
final int intg = precision - scale;
final int frac = scale;
final int intg0 = intg / DIG_PER_INT32;
final int frac0 = frac / DIG_PER_INT32;
final int intg0x = intg - intg0 * DIG_PER_INT32;
final int frac0x = frac - frac0 * DIG_PER_INT32;
final int binSize = intg0 * SIZE_OF_INT32 + dig2bytes[intg0x] + frac0 * SIZE_OF_INT32 + dig2bytes[frac0x];
if (pos + binSize > limit || pos < 0) {
throw new IllegalArgumentException("limit excceed: " + (pos < 0 ? pos : (pos + binSize)));
}
return getDecimal0(origin + pos, intg, frac, // NL
intg0,
frac0,
intg0x,
frac0x);
} | java | public final BigDecimal getDecimal(final int pos, final int precision, final int scale) {
final int intg = precision - scale;
final int frac = scale;
final int intg0 = intg / DIG_PER_INT32;
final int frac0 = frac / DIG_PER_INT32;
final int intg0x = intg - intg0 * DIG_PER_INT32;
final int frac0x = frac - frac0 * DIG_PER_INT32;
final int binSize = intg0 * SIZE_OF_INT32 + dig2bytes[intg0x] + frac0 * SIZE_OF_INT32 + dig2bytes[frac0x];
if (pos + binSize > limit || pos < 0) {
throw new IllegalArgumentException("limit excceed: " + (pos < 0 ? pos : (pos + binSize)));
}
return getDecimal0(origin + pos, intg, frac, // NL
intg0,
frac0,
intg0x,
frac0x);
} | [
"public",
"final",
"BigDecimal",
"getDecimal",
"(",
"final",
"int",
"pos",
",",
"final",
"int",
"precision",
",",
"final",
"int",
"scale",
")",
"{",
"final",
"int",
"intg",
"=",
"precision",
"-",
"scale",
";",
"final",
"int",
"frac",
"=",
"scale",
";",
"final",
"int",
"intg0",
"=",
"intg",
"/",
"DIG_PER_INT32",
";",
"final",
"int",
"frac0",
"=",
"frac",
"/",
"DIG_PER_INT32",
";",
"final",
"int",
"intg0x",
"=",
"intg",
"-",
"intg0",
"*",
"DIG_PER_INT32",
";",
"final",
"int",
"frac0x",
"=",
"frac",
"-",
"frac0",
"*",
"DIG_PER_INT32",
";",
"final",
"int",
"binSize",
"=",
"intg0",
"*",
"SIZE_OF_INT32",
"+",
"dig2bytes",
"[",
"intg0x",
"]",
"+",
"frac0",
"*",
"SIZE_OF_INT32",
"+",
"dig2bytes",
"[",
"frac0x",
"]",
";",
"if",
"(",
"pos",
"+",
"binSize",
">",
"limit",
"||",
"pos",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"limit excceed: \"",
"+",
"(",
"pos",
"<",
"0",
"?",
"pos",
":",
"(",
"pos",
"+",
"binSize",
")",
")",
")",
";",
"}",
"return",
"getDecimal0",
"(",
"origin",
"+",
"pos",
",",
"intg",
",",
"frac",
",",
"// NL\r",
"intg0",
",",
"frac0",
",",
"intg0x",
",",
"frac0x",
")",
";",
"}"
] | Return big decimal from buffer.
@see mysql-5.1.60/strings/decimal.c - bin2decimal() | [
"Return",
"big",
"decimal",
"from",
"buffer",
"."
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L1229-L1246 |
ttddyy/datasource-proxy | src/main/java/net/ttddyy/dsproxy/listener/logging/DefaultQueryLogEntryCreator.java | DefaultQueryLogEntryCreator.writeParamsEntry | protected void writeParamsEntry(StringBuilder sb, ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
"""
Write query parameters.
<p>default for prepared: Params:[(foo,100),(bar,101)],
<p>default for callable: Params:[(1=foo,key=100),(1=bar,key=101)],
@param sb StringBuilder to write
@param execInfo execution info
@param queryInfoList query info list
@since 1.3.3
"""
boolean isPrepared = execInfo.getStatementType() == StatementType.PREPARED;
sb.append("Params:[");
for (QueryInfo queryInfo : queryInfoList) {
for (List<ParameterSetOperation> parameters : queryInfo.getParametersList()) {
SortedMap<String, String> paramMap = getParametersToDisplay(parameters);
// parameters per batch.
// for prepared: (val1,val2,...)
// for callable: (key1=val1,key2=val2,...)
if (isPrepared) {
writeParamsForSinglePreparedEntry(sb, paramMap, execInfo, queryInfoList);
} else {
writeParamsForSingleCallableEntry(sb, paramMap, execInfo, queryInfoList);
}
}
}
chompIfEndWith(sb, ',');
sb.append("]");
} | java | protected void writeParamsEntry(StringBuilder sb, ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
boolean isPrepared = execInfo.getStatementType() == StatementType.PREPARED;
sb.append("Params:[");
for (QueryInfo queryInfo : queryInfoList) {
for (List<ParameterSetOperation> parameters : queryInfo.getParametersList()) {
SortedMap<String, String> paramMap = getParametersToDisplay(parameters);
// parameters per batch.
// for prepared: (val1,val2,...)
// for callable: (key1=val1,key2=val2,...)
if (isPrepared) {
writeParamsForSinglePreparedEntry(sb, paramMap, execInfo, queryInfoList);
} else {
writeParamsForSingleCallableEntry(sb, paramMap, execInfo, queryInfoList);
}
}
}
chompIfEndWith(sb, ',');
sb.append("]");
} | [
"protected",
"void",
"writeParamsEntry",
"(",
"StringBuilder",
"sb",
",",
"ExecutionInfo",
"execInfo",
",",
"List",
"<",
"QueryInfo",
">",
"queryInfoList",
")",
"{",
"boolean",
"isPrepared",
"=",
"execInfo",
".",
"getStatementType",
"(",
")",
"==",
"StatementType",
".",
"PREPARED",
";",
"sb",
".",
"append",
"(",
"\"Params:[\"",
")",
";",
"for",
"(",
"QueryInfo",
"queryInfo",
":",
"queryInfoList",
")",
"{",
"for",
"(",
"List",
"<",
"ParameterSetOperation",
">",
"parameters",
":",
"queryInfo",
".",
"getParametersList",
"(",
")",
")",
"{",
"SortedMap",
"<",
"String",
",",
"String",
">",
"paramMap",
"=",
"getParametersToDisplay",
"(",
"parameters",
")",
";",
"// parameters per batch.",
"// for prepared: (val1,val2,...)",
"// for callable: (key1=val1,key2=val2,...)",
"if",
"(",
"isPrepared",
")",
"{",
"writeParamsForSinglePreparedEntry",
"(",
"sb",
",",
"paramMap",
",",
"execInfo",
",",
"queryInfoList",
")",
";",
"}",
"else",
"{",
"writeParamsForSingleCallableEntry",
"(",
"sb",
",",
"paramMap",
",",
"execInfo",
",",
"queryInfoList",
")",
";",
"}",
"}",
"}",
"chompIfEndWith",
"(",
"sb",
",",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"}"
] | Write query parameters.
<p>default for prepared: Params:[(foo,100),(bar,101)],
<p>default for callable: Params:[(1=foo,key=100),(1=bar,key=101)],
@param sb StringBuilder to write
@param execInfo execution info
@param queryInfoList query info list
@since 1.3.3 | [
"Write",
"query",
"parameters",
"."
] | train | https://github.com/ttddyy/datasource-proxy/blob/62163ccf9a569a99aa3ad9f9151a32567447a62e/src/main/java/net/ttddyy/dsproxy/listener/logging/DefaultQueryLogEntryCreator.java#L258-L282 |
EdwardRaff/JSAT | JSAT/src/jsat/clustering/OPTICS.java | OPTICS.setXi | public void setXi(double xi) {
"""
Sets the xi value used in {@link ExtractionMethod#XI_STEEP_ORIGINAL} to
produce cluster results.
@param xi the value in the range (0, 1)
@throws ArithmeticException if the value is not in the appropriate range
"""
if(xi <= 0 || xi >= 1 || Double.isNaN(xi))
throw new ArithmeticException("xi must be in the range (0, 1) not " + xi);
this.xi = xi;
this.one_min_xi = 1.0 - xi;
} | java | public void setXi(double xi)
{
if(xi <= 0 || xi >= 1 || Double.isNaN(xi))
throw new ArithmeticException("xi must be in the range (0, 1) not " + xi);
this.xi = xi;
this.one_min_xi = 1.0 - xi;
} | [
"public",
"void",
"setXi",
"(",
"double",
"xi",
")",
"{",
"if",
"(",
"xi",
"<=",
"0",
"||",
"xi",
">=",
"1",
"||",
"Double",
".",
"isNaN",
"(",
"xi",
")",
")",
"throw",
"new",
"ArithmeticException",
"(",
"\"xi must be in the range (0, 1) not \"",
"+",
"xi",
")",
";",
"this",
".",
"xi",
"=",
"xi",
";",
"this",
".",
"one_min_xi",
"=",
"1.0",
"-",
"xi",
";",
"}"
] | Sets the xi value used in {@link ExtractionMethod#XI_STEEP_ORIGINAL} to
produce cluster results.
@param xi the value in the range (0, 1)
@throws ArithmeticException if the value is not in the appropriate range | [
"Sets",
"the",
"xi",
"value",
"used",
"in",
"{",
"@link",
"ExtractionMethod#XI_STEEP_ORIGINAL",
"}",
"to",
"produce",
"cluster",
"results",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/clustering/OPTICS.java#L226-L232 |
VoltDB/voltdb | src/frontend/org/voltdb/importer/ChannelDistributer.java | ChannelDistributer.shutdown | public void shutdown() {
"""
Sets the done flag, shuts down its executor thread, and deletes its own host
and candidate nodes
"""
if (m_done.compareAndSet(false, true)) {
m_es.shutdown();
m_buses.shutdown();
DeleteNode deleteHost = new DeleteNode(joinZKPath(HOST_DN, m_hostId));
DeleteNode deleteCandidate = new DeleteNode(m_candidate);
try {
m_es.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
try {
m_buses.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
deleteHost.onComplete();
deleteCandidate.onComplete();
}
} | java | public void shutdown() {
if (m_done.compareAndSet(false, true)) {
m_es.shutdown();
m_buses.shutdown();
DeleteNode deleteHost = new DeleteNode(joinZKPath(HOST_DN, m_hostId));
DeleteNode deleteCandidate = new DeleteNode(m_candidate);
try {
m_es.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
try {
m_buses.awaitTermination(365, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw loggedDistributerException(e, "interrupted while waiting for executor termination");
}
deleteHost.onComplete();
deleteCandidate.onComplete();
}
} | [
"public",
"void",
"shutdown",
"(",
")",
"{",
"if",
"(",
"m_done",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"m_es",
".",
"shutdown",
"(",
")",
";",
"m_buses",
".",
"shutdown",
"(",
")",
";",
"DeleteNode",
"deleteHost",
"=",
"new",
"DeleteNode",
"(",
"joinZKPath",
"(",
"HOST_DN",
",",
"m_hostId",
")",
")",
";",
"DeleteNode",
"deleteCandidate",
"=",
"new",
"DeleteNode",
"(",
"m_candidate",
")",
";",
"try",
"{",
"m_es",
".",
"awaitTermination",
"(",
"365",
",",
"TimeUnit",
".",
"DAYS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"loggedDistributerException",
"(",
"e",
",",
"\"interrupted while waiting for executor termination\"",
")",
";",
"}",
"try",
"{",
"m_buses",
".",
"awaitTermination",
"(",
"365",
",",
"TimeUnit",
".",
"DAYS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"loggedDistributerException",
"(",
"e",
",",
"\"interrupted while waiting for executor termination\"",
")",
";",
"}",
"deleteHost",
".",
"onComplete",
"(",
")",
";",
"deleteCandidate",
".",
"onComplete",
"(",
")",
";",
"}",
"}"
] | Sets the done flag, shuts down its executor thread, and deletes its own host
and candidate nodes | [
"Sets",
"the",
"done",
"flag",
"shuts",
"down",
"its",
"executor",
"thread",
"and",
"deletes",
"its",
"own",
"host",
"and",
"candidate",
"nodes"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/ChannelDistributer.java#L515-L534 |
carewebframework/carewebframework-core | org.carewebframework.plugin-parent/org.carewebframework.plugin.infopanel/src/main/java/org/carewebframework/plugin/infopanel/controller/ActionListener.java | ActionListener.eventCallback | @Override
public void eventCallback(String eventName, Object eventData) {
"""
This is the callback for the generic event that is monitored by this listener. It will result
in the invocation of the doAction method of each bound action target.
"""
for (IActionTarget target : new ArrayList<>(targets)) {
try {
target.doAction(action);
} catch (Throwable t) {
}
}
} | java | @Override
public void eventCallback(String eventName, Object eventData) {
for (IActionTarget target : new ArrayList<>(targets)) {
try {
target.doAction(action);
} catch (Throwable t) {
}
}
} | [
"@",
"Override",
"public",
"void",
"eventCallback",
"(",
"String",
"eventName",
",",
"Object",
"eventData",
")",
"{",
"for",
"(",
"IActionTarget",
"target",
":",
"new",
"ArrayList",
"<>",
"(",
"targets",
")",
")",
"{",
"try",
"{",
"target",
".",
"doAction",
"(",
"action",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"}",
"}"
] | This is the callback for the generic event that is monitored by this listener. It will result
in the invocation of the doAction method of each bound action target. | [
"This",
"is",
"the",
"callback",
"for",
"the",
"generic",
"event",
"that",
"is",
"monitored",
"by",
"this",
"listener",
".",
"It",
"will",
"result",
"in",
"the",
"invocation",
"of",
"the",
"doAction",
"method",
"of",
"each",
"bound",
"action",
"target",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.plugin-parent/org.carewebframework.plugin.infopanel/src/main/java/org/carewebframework/plugin/infopanel/controller/ActionListener.java#L88-L97 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/RuntimeExceptionsFactory.java | RuntimeExceptionsFactory.newUnsupportedOperationException | public static UnsupportedOperationException newUnsupportedOperationException(Throwable cause,
String message, Object... args) {
"""
Constructs and initializes a new {@link UnsupportedOperationException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link UnsupportedOperationException} was thrown.
@param message {@link String} describing the {@link UnsupportedOperationException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link UnsupportedOperationException} with the given {@link Throwable cause}
and {@link String message}.
@see java.lang.UnsupportedOperationException
"""
return new UnsupportedOperationException(format(message, args), cause);
} | java | public static UnsupportedOperationException newUnsupportedOperationException(Throwable cause,
String message, Object... args) {
return new UnsupportedOperationException(format(message, args), cause);
} | [
"public",
"static",
"UnsupportedOperationException",
"newUnsupportedOperationException",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"UnsupportedOperationException",
"(",
"format",
"(",
"message",
",",
"args",
")",
",",
"cause",
")",
";",
"}"
] | Constructs and initializes a new {@link UnsupportedOperationException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link UnsupportedOperationException} was thrown.
@param message {@link String} describing the {@link UnsupportedOperationException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link UnsupportedOperationException} with the given {@link Throwable cause}
and {@link String message}.
@see java.lang.UnsupportedOperationException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"UnsupportedOperationException",
"}",
"with",
"the",
"given",
"{",
"@link",
"Throwable",
"cause",
"}",
"and",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/RuntimeExceptionsFactory.java#L268-L272 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildContent | public void buildContent(XMLNode node, Content contentTree) {
"""
Build the content for the profile doc.
@param node the XML element that specifies which components to document
@param contentTree the content tree to which the profile contents
will be added
"""
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
} | java | public void buildContent(XMLNode node, Content contentTree) {
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
} | [
"public",
"void",
"buildContent",
"(",
"XMLNode",
"node",
",",
"Content",
"contentTree",
")",
"{",
"Content",
"profileContentTree",
"=",
"profileWriter",
".",
"getContentHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"profileContentTree",
")",
";",
"contentTree",
".",
"addContent",
"(",
"profileContentTree",
")",
";",
"}"
] | Build the content for the profile doc.
@param node the XML element that specifies which components to document
@param contentTree the content tree to which the profile contents
will be added | [
"Build",
"the",
"content",
"for",
"the",
"profile",
"doc",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L141-L145 |
grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java | GroovyPagesUriSupport.getDeployedViewURI | public String getDeployedViewURI(String controllerName, String viewName) {
"""
Obtains a view URI when deployed within the /WEB-INF/grails-app/views context
@param controllerName The name of the controller
@param viewName The name of the view
@return The view URI
"""
FastStringWriter buf = new FastStringWriter(PATH_TO_VIEWS);
return getViewURIInternal(controllerName, viewName, buf, true);
} | java | public String getDeployedViewURI(String controllerName, String viewName) {
FastStringWriter buf = new FastStringWriter(PATH_TO_VIEWS);
return getViewURIInternal(controllerName, viewName, buf, true);
} | [
"public",
"String",
"getDeployedViewURI",
"(",
"String",
"controllerName",
",",
"String",
"viewName",
")",
"{",
"FastStringWriter",
"buf",
"=",
"new",
"FastStringWriter",
"(",
"PATH_TO_VIEWS",
")",
";",
"return",
"getViewURIInternal",
"(",
"controllerName",
",",
"viewName",
",",
"buf",
",",
"true",
")",
";",
"}"
] | Obtains a view URI when deployed within the /WEB-INF/grails-app/views context
@param controllerName The name of the controller
@param viewName The name of the view
@return The view URI | [
"Obtains",
"a",
"view",
"URI",
"when",
"deployed",
"within",
"the",
"/",
"WEB",
"-",
"INF",
"/",
"grails",
"-",
"app",
"/",
"views",
"context"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L221-L224 |
EMCECS/nfs-client-java | src/main/java/com/emc/ecs/nfsclient/rpc/RpcWrapper.java | RpcWrapper.callRpcChecked | public void callRpcChecked(S request, RpcResponseHandler<? extends T> responseHandler) throws IOException {
"""
Convenience wrapper for NFS RPC calls where the IP is determined by a
byte[] key. This method just determines the IP address and calls the
basic method.
@param request
The request to send.
@param responseHandler
A response handler.
@throws IOException
"""
callRpcChecked(request, responseHandler, chooseIP(request.getIpKey()));
} | java | public void callRpcChecked(S request, RpcResponseHandler<? extends T> responseHandler) throws IOException {
callRpcChecked(request, responseHandler, chooseIP(request.getIpKey()));
} | [
"public",
"void",
"callRpcChecked",
"(",
"S",
"request",
",",
"RpcResponseHandler",
"<",
"?",
"extends",
"T",
">",
"responseHandler",
")",
"throws",
"IOException",
"{",
"callRpcChecked",
"(",
"request",
",",
"responseHandler",
",",
"chooseIP",
"(",
"request",
".",
"getIpKey",
"(",
")",
")",
")",
";",
"}"
] | Convenience wrapper for NFS RPC calls where the IP is determined by a
byte[] key. This method just determines the IP address and calls the
basic method.
@param request
The request to send.
@param responseHandler
A response handler.
@throws IOException | [
"Convenience",
"wrapper",
"for",
"NFS",
"RPC",
"calls",
"where",
"the",
"IP",
"is",
"determined",
"by",
"a",
"byte",
"[]",
"key",
".",
"This",
"method",
"just",
"determines",
"the",
"IP",
"address",
"and",
"calls",
"the",
"basic",
"method",
"."
] | train | https://github.com/EMCECS/nfs-client-java/blob/7ba25bad5052b95cd286052745327729288b2843/src/main/java/com/emc/ecs/nfsclient/rpc/RpcWrapper.java#L175-L177 |
google/jimfs | jimfs/src/main/java/com/google/common/jimfs/RegularFile.java | RegularFile.get | private static int get(byte[] block, int offset, ByteBuffer buf, int len) {
"""
Reads len bytes starting at the given offset in the given block into the given byte buffer.
"""
buf.put(block, offset, len);
return len;
} | java | private static int get(byte[] block, int offset, ByteBuffer buf, int len) {
buf.put(block, offset, len);
return len;
} | [
"private",
"static",
"int",
"get",
"(",
"byte",
"[",
"]",
"block",
",",
"int",
"offset",
",",
"ByteBuffer",
"buf",
",",
"int",
"len",
")",
"{",
"buf",
".",
"put",
"(",
"block",
",",
"offset",
",",
"len",
")",
";",
"return",
"len",
";",
"}"
] | Reads len bytes starting at the given offset in the given block into the given byte buffer. | [
"Reads",
"len",
"bytes",
"starting",
"at",
"the",
"given",
"offset",
"in",
"the",
"given",
"block",
"into",
"the",
"given",
"byte",
"buffer",
"."
] | train | https://github.com/google/jimfs/blob/3eadff747a3afa7b498030f420d2d04ce700534a/jimfs/src/main/java/com/google/common/jimfs/RegularFile.java#L657-L660 |
igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java | SASLAuthentication.challengeReceived | public void challengeReceived(String challenge, boolean finalChallenge) throws SmackSaslException, NotConnectedException, InterruptedException {
"""
The server is challenging the SASL authentication we just sent. Forward the challenge
to the current SASLMechanism we are using. The SASLMechanism will eventually send a response to
the server. The length of the challenge-response sequence varies according to the
SASLMechanism in use.
@param challenge a base64 encoded string representing the challenge.
@param finalChallenge true if this is the last challenge send by the server within the success stanza
@throws SmackSaslException
@throws NotConnectedException
@throws InterruptedException
"""
try {
currentMechanism.challengeReceived(challenge, finalChallenge);
} catch (InterruptedException | SmackSaslException | NotConnectedException e) {
authenticationFailed(e);
throw e;
}
} | java | public void challengeReceived(String challenge, boolean finalChallenge) throws SmackSaslException, NotConnectedException, InterruptedException {
try {
currentMechanism.challengeReceived(challenge, finalChallenge);
} catch (InterruptedException | SmackSaslException | NotConnectedException e) {
authenticationFailed(e);
throw e;
}
} | [
"public",
"void",
"challengeReceived",
"(",
"String",
"challenge",
",",
"boolean",
"finalChallenge",
")",
"throws",
"SmackSaslException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"try",
"{",
"currentMechanism",
".",
"challengeReceived",
"(",
"challenge",
",",
"finalChallenge",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"SmackSaslException",
"|",
"NotConnectedException",
"e",
")",
"{",
"authenticationFailed",
"(",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | The server is challenging the SASL authentication we just sent. Forward the challenge
to the current SASLMechanism we are using. The SASLMechanism will eventually send a response to
the server. The length of the challenge-response sequence varies according to the
SASLMechanism in use.
@param challenge a base64 encoded string representing the challenge.
@param finalChallenge true if this is the last challenge send by the server within the success stanza
@throws SmackSaslException
@throws NotConnectedException
@throws InterruptedException | [
"The",
"server",
"is",
"challenging",
"the",
"SASL",
"authentication",
"we",
"just",
"sent",
".",
"Forward",
"the",
"challenge",
"to",
"the",
"current",
"SASLMechanism",
"we",
"are",
"using",
".",
"The",
"SASLMechanism",
"will",
"eventually",
"send",
"a",
"response",
"to",
"the",
"server",
".",
"The",
"length",
"of",
"the",
"challenge",
"-",
"response",
"sequence",
"varies",
"according",
"to",
"the",
"SASLMechanism",
"in",
"use",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java#L261-L268 |
haraldk/TwelveMonkeys | common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java | FileUtil.getDirectoryname | public static String getDirectoryname(final String pPath, final char pSeparator) {
"""
Extracts the directory path without the filename, from a complete
filename path.
@param pPath The full filename path.
@param pSeparator the separator char used in {@code pPath}
@return the path without the filename.
@see File#getParent
@see #getFilename
"""
int index = pPath.lastIndexOf(pSeparator);
if (index < 0) {
return ""; // Assume only filename
}
return pPath.substring(0, index);
} | java | public static String getDirectoryname(final String pPath, final char pSeparator) {
int index = pPath.lastIndexOf(pSeparator);
if (index < 0) {
return ""; // Assume only filename
}
return pPath.substring(0, index);
} | [
"public",
"static",
"String",
"getDirectoryname",
"(",
"final",
"String",
"pPath",
",",
"final",
"char",
"pSeparator",
")",
"{",
"int",
"index",
"=",
"pPath",
".",
"lastIndexOf",
"(",
"pSeparator",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"\"\"",
";",
"// Assume only filename\r",
"}",
"return",
"pPath",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"}"
] | Extracts the directory path without the filename, from a complete
filename path.
@param pPath The full filename path.
@param pSeparator the separator char used in {@code pPath}
@return the path without the filename.
@see File#getParent
@see #getFilename | [
"Extracts",
"the",
"directory",
"path",
"without",
"the",
"filename",
"from",
"a",
"complete",
"filename",
"path",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L436-L443 |
apereo/cas | core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java | WebUtils.putAuthenticationResultBuilder | public static void putAuthenticationResultBuilder(final AuthenticationResultBuilder builder, final RequestContext ctx) {
"""
Put authentication result builder.
@param builder the builder
@param ctx the ctx
"""
ctx.getConversationScope().put(PARAMETER_AUTHENTICATION_RESULT_BUILDER, builder);
} | java | public static void putAuthenticationResultBuilder(final AuthenticationResultBuilder builder, final RequestContext ctx) {
ctx.getConversationScope().put(PARAMETER_AUTHENTICATION_RESULT_BUILDER, builder);
} | [
"public",
"static",
"void",
"putAuthenticationResultBuilder",
"(",
"final",
"AuthenticationResultBuilder",
"builder",
",",
"final",
"RequestContext",
"ctx",
")",
"{",
"ctx",
".",
"getConversationScope",
"(",
")",
".",
"put",
"(",
"PARAMETER_AUTHENTICATION_RESULT_BUILDER",
",",
"builder",
")",
";",
"}"
] | Put authentication result builder.
@param builder the builder
@param ctx the ctx | [
"Put",
"authentication",
"result",
"builder",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java#L486-L488 |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ReflectionUtils.java | ReflectionUtils.findSetter | public static Method findSetter(final Object object, final String fieldName, final Class<?> argumentType) {
"""
Returns the setter method associated with the object's field.
<p>
This method handles any autoboxing/unboxing of the argument passed to the setter (e.g. if the setter type is a
primitive {@code int} but the argument passed to the setter is an {@code Integer}) by looking for a setter with
the same type, and failing that checking for a setter with the corresponding primitive/wrapper type.
<p>
It also allows for an argument type that is a subclass or implementation of the setter type (when the setter type
is an {@code Object} or {@code interface} respectively).
@param object
the object
@param fieldName
the name of the field
@param argumentType
the type to be passed to the setter
@return the setter method
@throws NullPointerException
if object, fieldName or fieldType is null
@throws SuperCsvReflectionException
if the setter doesn't exist or is not visible
"""
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
} else if( argumentType == null ) {
throw new NullPointerException("argumentType should not be null");
}
final String setterName = getMethodNameForField(SET_PREFIX, fieldName);
final Class<?> clazz = object.getClass();
// find a setter compatible with the supplied argument type
Method setter = findSetterWithCompatibleParamType(clazz, setterName, argumentType);
// if that failed, try the corresponding primitive/wrapper if it's a type that can be autoboxed/unboxed
if( setter == null && AUTOBOXING_CONVERTER.containsKey(argumentType) ) {
setter = findSetterWithCompatibleParamType(clazz, setterName, AUTOBOXING_CONVERTER.get(argumentType));
}
if( setter == null ) {
throw new SuperCsvReflectionException(
String
.format(
"unable to find method %s(%s) in class %s - check that the corresponding nameMapping element matches the field name in the bean, "
+ "and the cell processor returns a type compatible with the field", setterName,
argumentType.getName(), clazz.getName()));
}
return setter;
} | java | public static Method findSetter(final Object object, final String fieldName, final Class<?> argumentType) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
} else if( argumentType == null ) {
throw new NullPointerException("argumentType should not be null");
}
final String setterName = getMethodNameForField(SET_PREFIX, fieldName);
final Class<?> clazz = object.getClass();
// find a setter compatible with the supplied argument type
Method setter = findSetterWithCompatibleParamType(clazz, setterName, argumentType);
// if that failed, try the corresponding primitive/wrapper if it's a type that can be autoboxed/unboxed
if( setter == null && AUTOBOXING_CONVERTER.containsKey(argumentType) ) {
setter = findSetterWithCompatibleParamType(clazz, setterName, AUTOBOXING_CONVERTER.get(argumentType));
}
if( setter == null ) {
throw new SuperCsvReflectionException(
String
.format(
"unable to find method %s(%s) in class %s - check that the corresponding nameMapping element matches the field name in the bean, "
+ "and the cell processor returns a type compatible with the field", setterName,
argumentType.getName(), clazz.getName()));
}
return setter;
} | [
"public",
"static",
"Method",
"findSetter",
"(",
"final",
"Object",
"object",
",",
"final",
"String",
"fieldName",
",",
"final",
"Class",
"<",
"?",
">",
"argumentType",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"object should not be null\"",
")",
";",
"}",
"else",
"if",
"(",
"fieldName",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"fieldName should not be null\"",
")",
";",
"}",
"else",
"if",
"(",
"argumentType",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"argumentType should not be null\"",
")",
";",
"}",
"final",
"String",
"setterName",
"=",
"getMethodNameForField",
"(",
"SET_PREFIX",
",",
"fieldName",
")",
";",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"// find a setter compatible with the supplied argument type",
"Method",
"setter",
"=",
"findSetterWithCompatibleParamType",
"(",
"clazz",
",",
"setterName",
",",
"argumentType",
")",
";",
"// if that failed, try the corresponding primitive/wrapper if it's a type that can be autoboxed/unboxed",
"if",
"(",
"setter",
"==",
"null",
"&&",
"AUTOBOXING_CONVERTER",
".",
"containsKey",
"(",
"argumentType",
")",
")",
"{",
"setter",
"=",
"findSetterWithCompatibleParamType",
"(",
"clazz",
",",
"setterName",
",",
"AUTOBOXING_CONVERTER",
".",
"get",
"(",
"argumentType",
")",
")",
";",
"}",
"if",
"(",
"setter",
"==",
"null",
")",
"{",
"throw",
"new",
"SuperCsvReflectionException",
"(",
"String",
".",
"format",
"(",
"\"unable to find method %s(%s) in class %s - check that the corresponding nameMapping element matches the field name in the bean, \"",
"+",
"\"and the cell processor returns a type compatible with the field\"",
",",
"setterName",
",",
"argumentType",
".",
"getName",
"(",
")",
",",
"clazz",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"setter",
";",
"}"
] | Returns the setter method associated with the object's field.
<p>
This method handles any autoboxing/unboxing of the argument passed to the setter (e.g. if the setter type is a
primitive {@code int} but the argument passed to the setter is an {@code Integer}) by looking for a setter with
the same type, and failing that checking for a setter with the corresponding primitive/wrapper type.
<p>
It also allows for an argument type that is a subclass or implementation of the setter type (when the setter type
is an {@code Object} or {@code interface} respectively).
@param object
the object
@param fieldName
the name of the field
@param argumentType
the type to be passed to the setter
@return the setter method
@throws NullPointerException
if object, fieldName or fieldType is null
@throws SuperCsvReflectionException
if the setter doesn't exist or is not visible | [
"Returns",
"the",
"setter",
"method",
"associated",
"with",
"the",
"object",
"s",
"field",
".",
"<p",
">",
"This",
"method",
"handles",
"any",
"autoboxing",
"/",
"unboxing",
"of",
"the",
"argument",
"passed",
"to",
"the",
"setter",
"(",
"e",
".",
"g",
".",
"if",
"the",
"setter",
"type",
"is",
"a",
"primitive",
"{",
"@code",
"int",
"}",
"but",
"the",
"argument",
"passed",
"to",
"the",
"setter",
"is",
"an",
"{",
"@code",
"Integer",
"}",
")",
"by",
"looking",
"for",
"a",
"setter",
"with",
"the",
"same",
"type",
"and",
"failing",
"that",
"checking",
"for",
"a",
"setter",
"with",
"the",
"corresponding",
"primitive",
"/",
"wrapper",
"type",
".",
"<p",
">",
"It",
"also",
"allows",
"for",
"an",
"argument",
"type",
"that",
"is",
"a",
"subclass",
"or",
"implementation",
"of",
"the",
"setter",
"type",
"(",
"when",
"the",
"setter",
"type",
"is",
"an",
"{",
"@code",
"Object",
"}",
"or",
"{",
"@code",
"interface",
"}",
"respectively",
")",
"."
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ReflectionUtils.java#L163-L193 |
Red5/red5-io | src/main/java/org/red5/io/object/Serializer.java | Serializer.serializeField | public static boolean serializeField(String keyName, Field field, Method getter) {
"""
Checks whether the field should be serialized or not
@param keyName
key name
@param field
The field to be serialized
@param getter
Getter method for field
@return <tt>true</tt> if the field should be serialized, otherwise <tt>false</tt>
"""
log.trace("serializeField - keyName: {} field: {} method: {}", new Object[] { keyName, field, getter });
// if "field" is a class or is transient, skip it
if ("class".equals(keyName)) {
return false;
}
if (field != null) {
if (Modifier.isTransient(field.getModifiers())) {
log.trace("Skipping {} because its transient", keyName);
return false;
} else if (field.isAnnotationPresent(DontSerialize.class)) {
log.trace("Skipping {} because its marked with @DontSerialize", keyName);
return false;
}
}
if (getter != null && getter.isAnnotationPresent(DontSerialize.class)) {
log.trace("Skipping {} because its marked with @DontSerialize", keyName);
return false;
}
log.trace("Serialize field: {}", field);
return true;
} | java | public static boolean serializeField(String keyName, Field field, Method getter) {
log.trace("serializeField - keyName: {} field: {} method: {}", new Object[] { keyName, field, getter });
// if "field" is a class or is transient, skip it
if ("class".equals(keyName)) {
return false;
}
if (field != null) {
if (Modifier.isTransient(field.getModifiers())) {
log.trace("Skipping {} because its transient", keyName);
return false;
} else if (field.isAnnotationPresent(DontSerialize.class)) {
log.trace("Skipping {} because its marked with @DontSerialize", keyName);
return false;
}
}
if (getter != null && getter.isAnnotationPresent(DontSerialize.class)) {
log.trace("Skipping {} because its marked with @DontSerialize", keyName);
return false;
}
log.trace("Serialize field: {}", field);
return true;
} | [
"public",
"static",
"boolean",
"serializeField",
"(",
"String",
"keyName",
",",
"Field",
"field",
",",
"Method",
"getter",
")",
"{",
"log",
".",
"trace",
"(",
"\"serializeField - keyName: {} field: {} method: {}\"",
",",
"new",
"Object",
"[",
"]",
"{",
"keyName",
",",
"field",
",",
"getter",
"}",
")",
";",
"// if \"field\" is a class or is transient, skip it",
"if",
"(",
"\"class\"",
".",
"equals",
"(",
"keyName",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"field",
"!=",
"null",
")",
"{",
"if",
"(",
"Modifier",
".",
"isTransient",
"(",
"field",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"log",
".",
"trace",
"(",
"\"Skipping {} because its transient\"",
",",
"keyName",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"field",
".",
"isAnnotationPresent",
"(",
"DontSerialize",
".",
"class",
")",
")",
"{",
"log",
".",
"trace",
"(",
"\"Skipping {} because its marked with @DontSerialize\"",
",",
"keyName",
")",
";",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"getter",
"!=",
"null",
"&&",
"getter",
".",
"isAnnotationPresent",
"(",
"DontSerialize",
".",
"class",
")",
")",
"{",
"log",
".",
"trace",
"(",
"\"Skipping {} because its marked with @DontSerialize\"",
",",
"keyName",
")",
";",
"return",
"false",
";",
"}",
"log",
".",
"trace",
"(",
"\"Serialize field: {}\"",
",",
"field",
")",
";",
"return",
"true",
";",
"}"
] | Checks whether the field should be serialized or not
@param keyName
key name
@param field
The field to be serialized
@param getter
Getter method for field
@return <tt>true</tt> if the field should be serialized, otherwise <tt>false</tt> | [
"Checks",
"whether",
"the",
"field",
"should",
"be",
"serialized",
"or",
"not"
] | train | https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/object/Serializer.java#L374-L395 |
mangstadt/biweekly | src/main/java/biweekly/util/com/google/ical/iter/Generators.java | Generators.serialSecondGenerator | static Generator serialSecondGenerator(final int interval, final DateValue dtStart) {
"""
Constructs a generator that generates seconds in the given date's minute
successively counting from the first second passed in.
@param interval number of seconds to advance each step
@param dtStart the date
@return the second in dtStart the first time called and interval + last
return value on subsequent calls
"""
final TimeValue dtStartTime = TimeUtils.timeOf(dtStart);
return new Generator() {
int second = dtStartTime.second() - interval;
int minute = dtStartTime.minute();
int hour = dtStartTime.hour();
int day = dtStart.day();
int month = dtStart.month();
int year = dtStart.year();
@Override
boolean generate(DTBuilder builder) {
int nsecond;
if (minute != builder.minute || hour != builder.hour || day != builder.day || month != builder.month || year != builder.year) {
int secondsBetween = ((daysBetween(builder, year, month, day) * 24 + builder.hour - hour) * 60 + builder.minute - minute) * 60 - second;
nsecond = ((interval - (secondsBetween % interval)) % interval);
if (nsecond > 59) {
/*
* Don't update day so that the difference calculation
* above is correct when this function is reentered with
* a different day.
*/
return false;
}
minute = builder.minute;
hour = builder.hour;
day = builder.day;
month = builder.month;
year = builder.year;
} else {
nsecond = second + interval;
if (nsecond > 59) {
return false;
}
}
second = builder.second = nsecond;
return true;
}
@Override
public String toString() {
return "serialSecondGenerator:" + interval;
}
};
} | java | static Generator serialSecondGenerator(final int interval, final DateValue dtStart) {
final TimeValue dtStartTime = TimeUtils.timeOf(dtStart);
return new Generator() {
int second = dtStartTime.second() - interval;
int minute = dtStartTime.minute();
int hour = dtStartTime.hour();
int day = dtStart.day();
int month = dtStart.month();
int year = dtStart.year();
@Override
boolean generate(DTBuilder builder) {
int nsecond;
if (minute != builder.minute || hour != builder.hour || day != builder.day || month != builder.month || year != builder.year) {
int secondsBetween = ((daysBetween(builder, year, month, day) * 24 + builder.hour - hour) * 60 + builder.minute - minute) * 60 - second;
nsecond = ((interval - (secondsBetween % interval)) % interval);
if (nsecond > 59) {
/*
* Don't update day so that the difference calculation
* above is correct when this function is reentered with
* a different day.
*/
return false;
}
minute = builder.minute;
hour = builder.hour;
day = builder.day;
month = builder.month;
year = builder.year;
} else {
nsecond = second + interval;
if (nsecond > 59) {
return false;
}
}
second = builder.second = nsecond;
return true;
}
@Override
public String toString() {
return "serialSecondGenerator:" + interval;
}
};
} | [
"static",
"Generator",
"serialSecondGenerator",
"(",
"final",
"int",
"interval",
",",
"final",
"DateValue",
"dtStart",
")",
"{",
"final",
"TimeValue",
"dtStartTime",
"=",
"TimeUtils",
".",
"timeOf",
"(",
"dtStart",
")",
";",
"return",
"new",
"Generator",
"(",
")",
"{",
"int",
"second",
"=",
"dtStartTime",
".",
"second",
"(",
")",
"-",
"interval",
";",
"int",
"minute",
"=",
"dtStartTime",
".",
"minute",
"(",
")",
";",
"int",
"hour",
"=",
"dtStartTime",
".",
"hour",
"(",
")",
";",
"int",
"day",
"=",
"dtStart",
".",
"day",
"(",
")",
";",
"int",
"month",
"=",
"dtStart",
".",
"month",
"(",
")",
";",
"int",
"year",
"=",
"dtStart",
".",
"year",
"(",
")",
";",
"@",
"Override",
"boolean",
"generate",
"(",
"DTBuilder",
"builder",
")",
"{",
"int",
"nsecond",
";",
"if",
"(",
"minute",
"!=",
"builder",
".",
"minute",
"||",
"hour",
"!=",
"builder",
".",
"hour",
"||",
"day",
"!=",
"builder",
".",
"day",
"||",
"month",
"!=",
"builder",
".",
"month",
"||",
"year",
"!=",
"builder",
".",
"year",
")",
"{",
"int",
"secondsBetween",
"=",
"(",
"(",
"daysBetween",
"(",
"builder",
",",
"year",
",",
"month",
",",
"day",
")",
"*",
"24",
"+",
"builder",
".",
"hour",
"-",
"hour",
")",
"*",
"60",
"+",
"builder",
".",
"minute",
"-",
"minute",
")",
"*",
"60",
"-",
"second",
";",
"nsecond",
"=",
"(",
"(",
"interval",
"-",
"(",
"secondsBetween",
"%",
"interval",
")",
")",
"%",
"interval",
")",
";",
"if",
"(",
"nsecond",
">",
"59",
")",
"{",
"/*\n\t\t\t\t\t\t * Don't update day so that the difference calculation\n\t\t\t\t\t\t * above is correct when this function is reentered with\n\t\t\t\t\t\t * a different day.\n\t\t\t\t\t\t */",
"return",
"false",
";",
"}",
"minute",
"=",
"builder",
".",
"minute",
";",
"hour",
"=",
"builder",
".",
"hour",
";",
"day",
"=",
"builder",
".",
"day",
";",
"month",
"=",
"builder",
".",
"month",
";",
"year",
"=",
"builder",
".",
"year",
";",
"}",
"else",
"{",
"nsecond",
"=",
"second",
"+",
"interval",
";",
"if",
"(",
"nsecond",
">",
"59",
")",
"{",
"return",
"false",
";",
"}",
"}",
"second",
"=",
"builder",
".",
"second",
"=",
"nsecond",
";",
"return",
"true",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"serialSecondGenerator:\"",
"+",
"interval",
";",
"}",
"}",
";",
"}"
] | Constructs a generator that generates seconds in the given date's minute
successively counting from the first second passed in.
@param interval number of seconds to advance each step
@param dtStart the date
@return the second in dtStart the first time called and interval + last
return value on subsequent calls | [
"Constructs",
"a",
"generator",
"that",
"generates",
"seconds",
"in",
"the",
"given",
"date",
"s",
"minute",
"successively",
"counting",
"from",
"the",
"first",
"second",
"passed",
"in",
"."
] | train | https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/util/com/google/ical/iter/Generators.java#L348-L392 |
realtime-framework/RealtimeStorage-Android | library/src/main/java/co/realtime/storage/StorageRef.java | StorageRef.getTables | public StorageRef getTables(OnTableSnapshot onTableSnapshot, OnError onError) {
"""
Retrieves a list of the names of all tables created by the user's subscription.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
storage.getTables(new OnTableSnapshot() {
@Override
public void run(TableSnapshot tableSnapshot) {
if(tableSnapshot != null) {
Log.d("StorageRef", "Table Name: " + tableSnapshot.val());
}
}
},new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("StorageRef","Error retrieving tables: " + errorMessage);
}
});
</pre>
@param onTableSnapshot
The callback to call once the values are available. The function will be called with a table snapshot as argument, as many times as the number of tables existent. In the end, when all calls are done, the success function will be called with null as argument to signal that there are no more tables.
@param onError
The callback to call if an exception occurred
@return Current storage reference
"""
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.LISTTABLES, pbb, null);
r.onError = onError;
r.onTableSnapshot = onTableSnapshot;
context.processRest(r);
return this;
} | java | public StorageRef getTables(OnTableSnapshot onTableSnapshot, OnError onError){
PostBodyBuilder pbb = new PostBodyBuilder(context);
Rest r = new Rest(context, RestType.LISTTABLES, pbb, null);
r.onError = onError;
r.onTableSnapshot = onTableSnapshot;
context.processRest(r);
return this;
} | [
"public",
"StorageRef",
"getTables",
"(",
"OnTableSnapshot",
"onTableSnapshot",
",",
"OnError",
"onError",
")",
"{",
"PostBodyBuilder",
"pbb",
"=",
"new",
"PostBodyBuilder",
"(",
"context",
")",
";",
"Rest",
"r",
"=",
"new",
"Rest",
"(",
"context",
",",
"RestType",
".",
"LISTTABLES",
",",
"pbb",
",",
"null",
")",
";",
"r",
".",
"onError",
"=",
"onError",
";",
"r",
".",
"onTableSnapshot",
"=",
"onTableSnapshot",
";",
"context",
".",
"processRest",
"(",
"r",
")",
";",
"return",
"this",
";",
"}"
] | Retrieves a list of the names of all tables created by the user's subscription.
<pre>
StorageRef storage = new StorageRef("your_app_key", "your_token");
storage.getTables(new OnTableSnapshot() {
@Override
public void run(TableSnapshot tableSnapshot) {
if(tableSnapshot != null) {
Log.d("StorageRef", "Table Name: " + tableSnapshot.val());
}
}
},new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("StorageRef","Error retrieving tables: " + errorMessage);
}
});
</pre>
@param onTableSnapshot
The callback to call once the values are available. The function will be called with a table snapshot as argument, as many times as the number of tables existent. In the end, when all calls are done, the success function will be called with null as argument to signal that there are no more tables.
@param onError
The callback to call if an exception occurred
@return Current storage reference | [
"Retrieves",
"a",
"list",
"of",
"the",
"names",
"of",
"all",
"tables",
"created",
"by",
"the",
"user",
"s",
"subscription",
"."
] | train | https://github.com/realtime-framework/RealtimeStorage-Android/blob/05816a6b7a6dcc83f9e7400ac3048494dadca302/library/src/main/java/co/realtime/storage/StorageRef.java#L372-L379 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/convert/BitConverter.java | BitConverter.setState | public int setState(boolean bState, boolean bDisplayOption, int iMoveMode) {
"""
For binary fields, set the current state.
Sets the target bit to the state.
@param state The state to set this field.
@param bDisplayOption Display changed fields if true.
@param iMoveMode The move mode.
@return The error code (or NORMAL_RETURN).
"""
int iFieldValue = (int)this.getValue();
if (!m_bTrueIfMatch)
bState = !bState; // Do opposite operation
if (bState)
iFieldValue |= (1 << m_iBitNumber); // Set the bit
else
iFieldValue &= ~(1 << m_iBitNumber); // Clear the bit
return this.setValue(iFieldValue, bDisplayOption, iMoveMode);
} | java | public int setState(boolean bState, boolean bDisplayOption, int iMoveMode)
{
int iFieldValue = (int)this.getValue();
if (!m_bTrueIfMatch)
bState = !bState; // Do opposite operation
if (bState)
iFieldValue |= (1 << m_iBitNumber); // Set the bit
else
iFieldValue &= ~(1 << m_iBitNumber); // Clear the bit
return this.setValue(iFieldValue, bDisplayOption, iMoveMode);
} | [
"public",
"int",
"setState",
"(",
"boolean",
"bState",
",",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"int",
"iFieldValue",
"=",
"(",
"int",
")",
"this",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"m_bTrueIfMatch",
")",
"bState",
"=",
"!",
"bState",
";",
"// Do opposite operation",
"if",
"(",
"bState",
")",
"iFieldValue",
"|=",
"(",
"1",
"<<",
"m_iBitNumber",
")",
";",
"// Set the bit",
"else",
"iFieldValue",
"&=",
"~",
"(",
"1",
"<<",
"m_iBitNumber",
")",
";",
"// Clear the bit",
"return",
"this",
".",
"setValue",
"(",
"iFieldValue",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}"
] | For binary fields, set the current state.
Sets the target bit to the state.
@param state The state to set this field.
@param bDisplayOption Display changed fields if true.
@param iMoveMode The move mode.
@return The error code (or NORMAL_RETURN). | [
"For",
"binary",
"fields",
"set",
"the",
"current",
"state",
".",
"Sets",
"the",
"target",
"bit",
"to",
"the",
"state",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/BitConverter.java#L122-L132 |
grails/grails-gdoc-engine | src/main/java/org/radeox/macro/Preserved.java | Preserved.addSpecial | protected void addSpecial(String c, String replacement) {
"""
Add a replacement for the special character c which may be a string
@param c the character to replace
@param replacement the new string
"""
specialString += c;
special.put(c, replacement);
} | java | protected void addSpecial(String c, String replacement) {
specialString += c;
special.put(c, replacement);
} | [
"protected",
"void",
"addSpecial",
"(",
"String",
"c",
",",
"String",
"replacement",
")",
"{",
"specialString",
"+=",
"c",
";",
"special",
".",
"put",
"(",
"c",
",",
"replacement",
")",
";",
"}"
] | Add a replacement for the special character c which may be a string
@param c the character to replace
@param replacement the new string | [
"Add",
"a",
"replacement",
"for",
"the",
"special",
"character",
"c",
"which",
"may",
"be",
"a",
"string"
] | train | https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/macro/Preserved.java#L53-L56 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/objects/XNodeSet.java | XNodeSet.notEquals | public boolean notEquals(XObject obj2) throws javax.xml.transform.TransformerException {
"""
Tell if two objects are functionally not equal.
@param obj2 object to compare this nodeset to
@return see this.compare(...)
@throws javax.xml.transform.TransformerException
"""
return compare(obj2, S_NEQ);
} | java | public boolean notEquals(XObject obj2) throws javax.xml.transform.TransformerException
{
return compare(obj2, S_NEQ);
} | [
"public",
"boolean",
"notEquals",
"(",
"XObject",
"obj2",
")",
"throws",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"{",
"return",
"compare",
"(",
"obj2",
",",
"S_NEQ",
")",
";",
"}"
] | Tell if two objects are functionally not equal.
@param obj2 object to compare this nodeset to
@return see this.compare(...)
@throws javax.xml.transform.TransformerException | [
"Tell",
"if",
"two",
"objects",
"are",
"functionally",
"not",
"equal",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/objects/XNodeSet.java#L722-L725 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/trees/SemanticHeadFinder.java | SemanticHeadFinder.ruleChanges | private void ruleChanges() {
"""
makes modifications of Collins' rules to better fit with semantic notions of heads
"""
// NP: don't want a POS to be the head
nonTerminalInfo.put("NP", new String[][]{{"rightdis", "NN", "NNP", "NNPS", "NNS", "NX", "NML", "JJR"}, {"left", "NP", "PRP"}, {"rightdis", "$", "ADJP", "FW"}, {"right", "CD"}, {"rightdis", "JJ", "JJS", "QP", "DT", "WDT", "NML", "PRN", "RB", "RBR", "ADVP"}, {"left", "POS"}, rightExceptPunct});
// WHNP clauses should have the same sort of head as an NP
// but it a WHNP has a NP and a WHNP under it, the WHNP should be the head. E.g., (WHNP (WHNP (WP$ whose) (JJ chief) (JJ executive) (NN officer))(, ,) (NP (NNP James) (NNP Gatward))(, ,))
nonTerminalInfo.put("WHNP", new String[][]{{"rightdis", "NN", "NNP", "NNPS", "NNS", "NX", "NML", "JJR", "WP"}, {"left", "WHNP", "NP"}, {"rightdis", "$", "ADJP", "PRN", "FW"}, {"right", "CD"}, {"rightdis", "JJ", "JJS", "RB", "QP"}, {"left", "WHPP", "WHADJP", "WP$", "WDT"}});
//WHADJP
nonTerminalInfo.put("WHADJP", new String[][]{{"left", "ADJP", "JJ", "JJR"}, {"right", "RB"}, rightExceptPunct});
//WHADJP
nonTerminalInfo.put("WHADVP", new String[][]{{"rightdis", "WRB", "WHADVP", "RB", "JJ"}, rightExceptPunct}); // if not WRB or WHADVP, probably has flat NP structure, allow JJ for "how long" constructions
// QP: we don't want the first CD to be the semantic head (e.g., "three billion": head should be "billion"), so we go from right to left
nonTerminalInfo.put("QP", new String[][]{{"right", "$", "NNS", "NN", "CD", "JJ", "PDT", "DT", "IN", "RB", "NCD", "QP", "JJR", "JJS"}});
// S, SBAR and SQ clauses should prefer the main verb as the head
// S: "He considered him a friend" -> we want a friend to be the head
nonTerminalInfo.put("S", new String[][]{{"left", "VP", "S", "FRAG", "SBAR", "ADJP", "UCP", "TO"}, {"right", "NP"}});
nonTerminalInfo.put("SBAR", new String[][]{{"left", "S", "SQ", "SINV", "SBAR", "FRAG", "VP", "WHNP", "WHPP", "WHADVP", "WHADJP", "IN", "DT"}});
// VP shouldn't be needed in SBAR, but occurs in one buggy tree in PTB3 wsj_1457 and otherwise does no harm
nonTerminalInfo.put("SQ", new String[][]{{"left", "VP", "SQ", "ADJP", "VB", "VBZ", "VBD", "VBP", "MD", "AUX", "AUXG"}});
// UCP take the first element as head
nonTerminalInfo.put("UCP", new String[][]{leftExceptPunct});
// CONJP: we want different heads for "but also" and "but not" and we don't want "not" to be the head in "not to mention"; now make "mention" head of "not to mention"
nonTerminalInfo.put("CONJP", new String[][]{{"right", "VB", "JJ", "RB", "IN", "CC"}, rightExceptPunct});
// FRAG: crap rule needs to be change if you want to parse glosses
nonTerminalInfo.put("FRAG", new String[][]{{"left", "IN"}, {"right", "RB"}, {"left", "NP"}, {"left", "ADJP", "ADVP", "FRAG", "S", "SBAR", "VP"}, leftExceptPunct});
// PP first word (especially in coordination of PPs)
nonTerminalInfo.put("PP", new String[][]{{"right", "IN", "TO", "VBG", "VBN", "RP", "FW", "JJ"}, {"left", "PP"}});
// PRN: sentence first
nonTerminalInfo.put("PRN", new String[][]{{"left", "VP", "SQ", "S", "SINV", "SBAR", "NP", "ADJP", "PP", "ADVP", "INTJ", "WHNP", "NAC", "VBP", "JJ", "NN", "NNP"}, leftExceptPunct});
// add the constituent XS (special node to add a layer in a QP tree introduced in our QPTreeTransformer)
nonTerminalInfo.put("XS", new String[][]{{"right", "IN"}});
} | java | private void ruleChanges() {
// NP: don't want a POS to be the head
nonTerminalInfo.put("NP", new String[][]{{"rightdis", "NN", "NNP", "NNPS", "NNS", "NX", "NML", "JJR"}, {"left", "NP", "PRP"}, {"rightdis", "$", "ADJP", "FW"}, {"right", "CD"}, {"rightdis", "JJ", "JJS", "QP", "DT", "WDT", "NML", "PRN", "RB", "RBR", "ADVP"}, {"left", "POS"}, rightExceptPunct});
// WHNP clauses should have the same sort of head as an NP
// but it a WHNP has a NP and a WHNP under it, the WHNP should be the head. E.g., (WHNP (WHNP (WP$ whose) (JJ chief) (JJ executive) (NN officer))(, ,) (NP (NNP James) (NNP Gatward))(, ,))
nonTerminalInfo.put("WHNP", new String[][]{{"rightdis", "NN", "NNP", "NNPS", "NNS", "NX", "NML", "JJR", "WP"}, {"left", "WHNP", "NP"}, {"rightdis", "$", "ADJP", "PRN", "FW"}, {"right", "CD"}, {"rightdis", "JJ", "JJS", "RB", "QP"}, {"left", "WHPP", "WHADJP", "WP$", "WDT"}});
//WHADJP
nonTerminalInfo.put("WHADJP", new String[][]{{"left", "ADJP", "JJ", "JJR"}, {"right", "RB"}, rightExceptPunct});
//WHADJP
nonTerminalInfo.put("WHADVP", new String[][]{{"rightdis", "WRB", "WHADVP", "RB", "JJ"}, rightExceptPunct}); // if not WRB or WHADVP, probably has flat NP structure, allow JJ for "how long" constructions
// QP: we don't want the first CD to be the semantic head (e.g., "three billion": head should be "billion"), so we go from right to left
nonTerminalInfo.put("QP", new String[][]{{"right", "$", "NNS", "NN", "CD", "JJ", "PDT", "DT", "IN", "RB", "NCD", "QP", "JJR", "JJS"}});
// S, SBAR and SQ clauses should prefer the main verb as the head
// S: "He considered him a friend" -> we want a friend to be the head
nonTerminalInfo.put("S", new String[][]{{"left", "VP", "S", "FRAG", "SBAR", "ADJP", "UCP", "TO"}, {"right", "NP"}});
nonTerminalInfo.put("SBAR", new String[][]{{"left", "S", "SQ", "SINV", "SBAR", "FRAG", "VP", "WHNP", "WHPP", "WHADVP", "WHADJP", "IN", "DT"}});
// VP shouldn't be needed in SBAR, but occurs in one buggy tree in PTB3 wsj_1457 and otherwise does no harm
nonTerminalInfo.put("SQ", new String[][]{{"left", "VP", "SQ", "ADJP", "VB", "VBZ", "VBD", "VBP", "MD", "AUX", "AUXG"}});
// UCP take the first element as head
nonTerminalInfo.put("UCP", new String[][]{leftExceptPunct});
// CONJP: we want different heads for "but also" and "but not" and we don't want "not" to be the head in "not to mention"; now make "mention" head of "not to mention"
nonTerminalInfo.put("CONJP", new String[][]{{"right", "VB", "JJ", "RB", "IN", "CC"}, rightExceptPunct});
// FRAG: crap rule needs to be change if you want to parse glosses
nonTerminalInfo.put("FRAG", new String[][]{{"left", "IN"}, {"right", "RB"}, {"left", "NP"}, {"left", "ADJP", "ADVP", "FRAG", "S", "SBAR", "VP"}, leftExceptPunct});
// PP first word (especially in coordination of PPs)
nonTerminalInfo.put("PP", new String[][]{{"right", "IN", "TO", "VBG", "VBN", "RP", "FW", "JJ"}, {"left", "PP"}});
// PRN: sentence first
nonTerminalInfo.put("PRN", new String[][]{{"left", "VP", "SQ", "S", "SINV", "SBAR", "NP", "ADJP", "PP", "ADVP", "INTJ", "WHNP", "NAC", "VBP", "JJ", "NN", "NNP"}, leftExceptPunct});
// add the constituent XS (special node to add a layer in a QP tree introduced in our QPTreeTransformer)
nonTerminalInfo.put("XS", new String[][]{{"right", "IN"}});
} | [
"private",
"void",
"ruleChanges",
"(",
")",
"{",
"// NP: don't want a POS to be the head\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"NP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"rightdis\"",
",",
"\"NN\"",
",",
"\"NNP\"",
",",
"\"NNPS\"",
",",
"\"NNS\"",
",",
"\"NX\"",
",",
"\"NML\"",
",",
"\"JJR\"",
"}",
",",
"{",
"\"left\"",
",",
"\"NP\"",
",",
"\"PRP\"",
"}",
",",
"{",
"\"rightdis\"",
",",
"\"$\"",
",",
"\"ADJP\"",
",",
"\"FW\"",
"}",
",",
"{",
"\"right\"",
",",
"\"CD\"",
"}",
",",
"{",
"\"rightdis\"",
",",
"\"JJ\"",
",",
"\"JJS\"",
",",
"\"QP\"",
",",
"\"DT\"",
",",
"\"WDT\"",
",",
"\"NML\"",
",",
"\"PRN\"",
",",
"\"RB\"",
",",
"\"RBR\"",
",",
"\"ADVP\"",
"}",
",",
"{",
"\"left\"",
",",
"\"POS\"",
"}",
",",
"rightExceptPunct",
"}",
")",
";",
"// WHNP clauses should have the same sort of head as an NP\r",
"// but it a WHNP has a NP and a WHNP under it, the WHNP should be the head. E.g., (WHNP (WHNP (WP$ whose) (JJ chief) (JJ executive) (NN officer))(, ,) (NP (NNP James) (NNP Gatward))(, ,))\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"WHNP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"rightdis\"",
",",
"\"NN\"",
",",
"\"NNP\"",
",",
"\"NNPS\"",
",",
"\"NNS\"",
",",
"\"NX\"",
",",
"\"NML\"",
",",
"\"JJR\"",
",",
"\"WP\"",
"}",
",",
"{",
"\"left\"",
",",
"\"WHNP\"",
",",
"\"NP\"",
"}",
",",
"{",
"\"rightdis\"",
",",
"\"$\"",
",",
"\"ADJP\"",
",",
"\"PRN\"",
",",
"\"FW\"",
"}",
",",
"{",
"\"right\"",
",",
"\"CD\"",
"}",
",",
"{",
"\"rightdis\"",
",",
"\"JJ\"",
",",
"\"JJS\"",
",",
"\"RB\"",
",",
"\"QP\"",
"}",
",",
"{",
"\"left\"",
",",
"\"WHPP\"",
",",
"\"WHADJP\"",
",",
"\"WP$\"",
",",
"\"WDT\"",
"}",
"}",
")",
";",
"//WHADJP\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"WHADJP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"left\"",
",",
"\"ADJP\"",
",",
"\"JJ\"",
",",
"\"JJR\"",
"}",
",",
"{",
"\"right\"",
",",
"\"RB\"",
"}",
",",
"rightExceptPunct",
"}",
")",
";",
"//WHADJP\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"WHADVP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"rightdis\"",
",",
"\"WRB\"",
",",
"\"WHADVP\"",
",",
"\"RB\"",
",",
"\"JJ\"",
"}",
",",
"rightExceptPunct",
"}",
")",
";",
"// if not WRB or WHADVP, probably has flat NP structure, allow JJ for \"how long\" constructions\r",
"// QP: we don't want the first CD to be the semantic head (e.g., \"three billion\": head should be \"billion\"), so we go from right to left\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"QP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"right\"",
",",
"\"$\"",
",",
"\"NNS\"",
",",
"\"NN\"",
",",
"\"CD\"",
",",
"\"JJ\"",
",",
"\"PDT\"",
",",
"\"DT\"",
",",
"\"IN\"",
",",
"\"RB\"",
",",
"\"NCD\"",
",",
"\"QP\"",
",",
"\"JJR\"",
",",
"\"JJS\"",
"}",
"}",
")",
";",
"// S, SBAR and SQ clauses should prefer the main verb as the head\r",
"// S: \"He considered him a friend\" -> we want a friend to be the head\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"S\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"left\"",
",",
"\"VP\"",
",",
"\"S\"",
",",
"\"FRAG\"",
",",
"\"SBAR\"",
",",
"\"ADJP\"",
",",
"\"UCP\"",
",",
"\"TO\"",
"}",
",",
"{",
"\"right\"",
",",
"\"NP\"",
"}",
"}",
")",
";",
"nonTerminalInfo",
".",
"put",
"(",
"\"SBAR\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"left\"",
",",
"\"S\"",
",",
"\"SQ\"",
",",
"\"SINV\"",
",",
"\"SBAR\"",
",",
"\"FRAG\"",
",",
"\"VP\"",
",",
"\"WHNP\"",
",",
"\"WHPP\"",
",",
"\"WHADVP\"",
",",
"\"WHADJP\"",
",",
"\"IN\"",
",",
"\"DT\"",
"}",
"}",
")",
";",
"// VP shouldn't be needed in SBAR, but occurs in one buggy tree in PTB3 wsj_1457 and otherwise does no harm\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"SQ\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"left\"",
",",
"\"VP\"",
",",
"\"SQ\"",
",",
"\"ADJP\"",
",",
"\"VB\"",
",",
"\"VBZ\"",
",",
"\"VBD\"",
",",
"\"VBP\"",
",",
"\"MD\"",
",",
"\"AUX\"",
",",
"\"AUXG\"",
"}",
"}",
")",
";",
"// UCP take the first element as head\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"UCP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"leftExceptPunct",
"}",
")",
";",
"// CONJP: we want different heads for \"but also\" and \"but not\" and we don't want \"not\" to be the head in \"not to mention\"; now make \"mention\" head of \"not to mention\"\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"CONJP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"right\"",
",",
"\"VB\"",
",",
"\"JJ\"",
",",
"\"RB\"",
",",
"\"IN\"",
",",
"\"CC\"",
"}",
",",
"rightExceptPunct",
"}",
")",
";",
"// FRAG: crap rule needs to be change if you want to parse glosses\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"FRAG\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"left\"",
",",
"\"IN\"",
"}",
",",
"{",
"\"right\"",
",",
"\"RB\"",
"}",
",",
"{",
"\"left\"",
",",
"\"NP\"",
"}",
",",
"{",
"\"left\"",
",",
"\"ADJP\"",
",",
"\"ADVP\"",
",",
"\"FRAG\"",
",",
"\"S\"",
",",
"\"SBAR\"",
",",
"\"VP\"",
"}",
",",
"leftExceptPunct",
"}",
")",
";",
"// PP first word (especially in coordination of PPs)\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"PP\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"right\"",
",",
"\"IN\"",
",",
"\"TO\"",
",",
"\"VBG\"",
",",
"\"VBN\"",
",",
"\"RP\"",
",",
"\"FW\"",
",",
"\"JJ\"",
"}",
",",
"{",
"\"left\"",
",",
"\"PP\"",
"}",
"}",
")",
";",
"// PRN: sentence first\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"PRN\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"left\"",
",",
"\"VP\"",
",",
"\"SQ\"",
",",
"\"S\"",
",",
"\"SINV\"",
",",
"\"SBAR\"",
",",
"\"NP\"",
",",
"\"ADJP\"",
",",
"\"PP\"",
",",
"\"ADVP\"",
",",
"\"INTJ\"",
",",
"\"WHNP\"",
",",
"\"NAC\"",
",",
"\"VBP\"",
",",
"\"JJ\"",
",",
"\"NN\"",
",",
"\"NNP\"",
"}",
",",
"leftExceptPunct",
"}",
")",
";",
"// add the constituent XS (special node to add a layer in a QP tree introduced in our QPTreeTransformer)\r",
"nonTerminalInfo",
".",
"put",
"(",
"\"XS\"",
",",
"new",
"String",
"[",
"]",
"[",
"]",
"{",
"{",
"\"right\"",
",",
"\"IN\"",
"}",
"}",
")",
";",
"}"
] | makes modifications of Collins' rules to better fit with semantic notions of heads | [
"makes",
"modifications",
"of",
"Collins",
"rules",
"to",
"better",
"fit",
"with",
"semantic",
"notions",
"of",
"heads"
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/trees/SemanticHeadFinder.java#L110-L151 |
Talend/tesb-rt-se | locator/src/main/java/org/talend/esb/servicelocator/client/SLPropertiesImpl.java | SLPropertiesImpl.addProperty | public void addProperty(String name, String... values) {
"""
Add a property with the given name and the given list of values to this Properties object. Name
and values are trimmed before the property is added.
@param name the name of the property, must not be <code>null</code>.
@param values the values of the property, must no be <code>null</code>,
none of the values must be <code>null</code>
"""
List<String> valueList = new ArrayList<String>();
for (String value : values) {
valueList.add(value.trim());
}
properties.put(name.trim(), valueList);
} | java | public void addProperty(String name, String... values) {
List<String> valueList = new ArrayList<String>();
for (String value : values) {
valueList.add(value.trim());
}
properties.put(name.trim(), valueList);
} | [
"public",
"void",
"addProperty",
"(",
"String",
"name",
",",
"String",
"...",
"values",
")",
"{",
"List",
"<",
"String",
">",
"valueList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"value",
":",
"values",
")",
"{",
"valueList",
".",
"add",
"(",
"value",
".",
"trim",
"(",
")",
")",
";",
"}",
"properties",
".",
"put",
"(",
"name",
".",
"trim",
"(",
")",
",",
"valueList",
")",
";",
"}"
] | Add a property with the given name and the given list of values to this Properties object. Name
and values are trimmed before the property is added.
@param name the name of the property, must not be <code>null</code>.
@param values the values of the property, must no be <code>null</code>,
none of the values must be <code>null</code> | [
"Add",
"a",
"property",
"with",
"the",
"given",
"name",
"and",
"the",
"given",
"list",
"of",
"values",
"to",
"this",
"Properties",
"object",
".",
"Name",
"and",
"values",
"are",
"trimmed",
"before",
"the",
"property",
"is",
"added",
"."
] | train | https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/client/SLPropertiesImpl.java#L52-L58 |
google/j2objc | jre_emul/android/platform/external/mockwebserver/src/main/java/com/google/mockwebserver/MockResponse.java | MockResponse.setChunkedBody | public MockResponse setChunkedBody(byte[] body, int maxChunkSize) {
"""
Sets the response body to {@code body}, chunked every {@code
maxChunkSize} bytes.
"""
removeHeader("Content-Length");
headers.add(CHUNKED_BODY_HEADER);
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
int pos = 0;
while (pos < body.length) {
int chunkSize = Math.min(body.length - pos, maxChunkSize);
bytesOut.write(Integer.toHexString(chunkSize).getBytes(US_ASCII));
bytesOut.write("\r\n".getBytes(US_ASCII));
bytesOut.write(body, pos, chunkSize);
bytesOut.write("\r\n".getBytes(US_ASCII));
pos += chunkSize;
}
bytesOut.write("0\r\n\r\n".getBytes(US_ASCII)); // last chunk + empty trailer + crlf
this.body = bytesOut.toByteArray();
return this;
} catch (IOException e) {
throw new AssertionError(); // In-memory I/O doesn't throw IOExceptions.
}
} | java | public MockResponse setChunkedBody(byte[] body, int maxChunkSize) {
removeHeader("Content-Length");
headers.add(CHUNKED_BODY_HEADER);
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
int pos = 0;
while (pos < body.length) {
int chunkSize = Math.min(body.length - pos, maxChunkSize);
bytesOut.write(Integer.toHexString(chunkSize).getBytes(US_ASCII));
bytesOut.write("\r\n".getBytes(US_ASCII));
bytesOut.write(body, pos, chunkSize);
bytesOut.write("\r\n".getBytes(US_ASCII));
pos += chunkSize;
}
bytesOut.write("0\r\n\r\n".getBytes(US_ASCII)); // last chunk + empty trailer + crlf
this.body = bytesOut.toByteArray();
return this;
} catch (IOException e) {
throw new AssertionError(); // In-memory I/O doesn't throw IOExceptions.
}
} | [
"public",
"MockResponse",
"setChunkedBody",
"(",
"byte",
"[",
"]",
"body",
",",
"int",
"maxChunkSize",
")",
"{",
"removeHeader",
"(",
"\"Content-Length\"",
")",
";",
"headers",
".",
"add",
"(",
"CHUNKED_BODY_HEADER",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"bytesOut",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"int",
"pos",
"=",
"0",
";",
"while",
"(",
"pos",
"<",
"body",
".",
"length",
")",
"{",
"int",
"chunkSize",
"=",
"Math",
".",
"min",
"(",
"body",
".",
"length",
"-",
"pos",
",",
"maxChunkSize",
")",
";",
"bytesOut",
".",
"write",
"(",
"Integer",
".",
"toHexString",
"(",
"chunkSize",
")",
".",
"getBytes",
"(",
"US_ASCII",
")",
")",
";",
"bytesOut",
".",
"write",
"(",
"\"\\r\\n\"",
".",
"getBytes",
"(",
"US_ASCII",
")",
")",
";",
"bytesOut",
".",
"write",
"(",
"body",
",",
"pos",
",",
"chunkSize",
")",
";",
"bytesOut",
".",
"write",
"(",
"\"\\r\\n\"",
".",
"getBytes",
"(",
"US_ASCII",
")",
")",
";",
"pos",
"+=",
"chunkSize",
";",
"}",
"bytesOut",
".",
"write",
"(",
"\"0\\r\\n\\r\\n\"",
".",
"getBytes",
"(",
"US_ASCII",
")",
")",
";",
"// last chunk + empty trailer + crlf",
"this",
".",
"body",
"=",
"bytesOut",
".",
"toByteArray",
"(",
")",
";",
"return",
"this",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"// In-memory I/O doesn't throw IOExceptions.",
"}",
"}"
] | Sets the response body to {@code body}, chunked every {@code
maxChunkSize} bytes. | [
"Sets",
"the",
"response",
"body",
"to",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/mockwebserver/src/main/java/com/google/mockwebserver/MockResponse.java#L186-L208 |
googleapis/google-cloud-java | google-cloud-examples/src/main/java/com/google/cloud/examples/compute/v1/ComputeExample.java | ComputeExample.insertAddressUsingCallable | private static void insertAddressUsingCallable(AddressClient client, String newAddressName)
throws InterruptedException, ExecutionException {
"""
Use an callable object to make an addresses.insert method call.
"""
// Begin samplegen code for insertAddress().
ProjectRegionName region = ProjectRegionName.of(PROJECT_NAME, REGION);
Address address = Address.newBuilder().build();
InsertAddressHttpRequest request =
InsertAddressHttpRequest.newBuilder()
.setRegion(region.toString())
.setAddressResource(address)
.build();
ApiFuture<Operation> future = client.insertAddressCallable().futureCall(request);
// Do something
Operation response = future.get();
// End samplegen code for insertAddress().
System.out.format("Result of insert: %s\n", response.toString());
} | java | private static void insertAddressUsingCallable(AddressClient client, String newAddressName)
throws InterruptedException, ExecutionException {
// Begin samplegen code for insertAddress().
ProjectRegionName region = ProjectRegionName.of(PROJECT_NAME, REGION);
Address address = Address.newBuilder().build();
InsertAddressHttpRequest request =
InsertAddressHttpRequest.newBuilder()
.setRegion(region.toString())
.setAddressResource(address)
.build();
ApiFuture<Operation> future = client.insertAddressCallable().futureCall(request);
// Do something
Operation response = future.get();
// End samplegen code for insertAddress().
System.out.format("Result of insert: %s\n", response.toString());
} | [
"private",
"static",
"void",
"insertAddressUsingCallable",
"(",
"AddressClient",
"client",
",",
"String",
"newAddressName",
")",
"throws",
"InterruptedException",
",",
"ExecutionException",
"{",
"// Begin samplegen code for insertAddress().",
"ProjectRegionName",
"region",
"=",
"ProjectRegionName",
".",
"of",
"(",
"PROJECT_NAME",
",",
"REGION",
")",
";",
"Address",
"address",
"=",
"Address",
".",
"newBuilder",
"(",
")",
".",
"build",
"(",
")",
";",
"InsertAddressHttpRequest",
"request",
"=",
"InsertAddressHttpRequest",
".",
"newBuilder",
"(",
")",
".",
"setRegion",
"(",
"region",
".",
"toString",
"(",
")",
")",
".",
"setAddressResource",
"(",
"address",
")",
".",
"build",
"(",
")",
";",
"ApiFuture",
"<",
"Operation",
">",
"future",
"=",
"client",
".",
"insertAddressCallable",
"(",
")",
".",
"futureCall",
"(",
"request",
")",
";",
"// Do something",
"Operation",
"response",
"=",
"future",
".",
"get",
"(",
")",
";",
"// End samplegen code for insertAddress().",
"System",
".",
"out",
".",
"format",
"(",
"\"Result of insert: %s\\n\"",
",",
"response",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Use an callable object to make an addresses.insert method call. | [
"Use",
"an",
"callable",
"object",
"to",
"make",
"an",
"addresses",
".",
"insert",
"method",
"call",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/v1/ComputeExample.java#L103-L119 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java | PersonGroupPersonsImpl.getFaceAsync | public Observable<PersistedFace> getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) {
"""
Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId).
@param personGroupId Id referencing a particular person group.
@param personId Id referencing a particular person.
@param persistedFaceId Id referencing a particular persistedFaceId of an existing face.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PersistedFace object
"""
return getFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1<ServiceResponse<PersistedFace>, PersistedFace>() {
@Override
public PersistedFace call(ServiceResponse<PersistedFace> response) {
return response.body();
}
});
} | java | public Observable<PersistedFace> getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) {
return getFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1<ServiceResponse<PersistedFace>, PersistedFace>() {
@Override
public PersistedFace call(ServiceResponse<PersistedFace> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"PersistedFace",
">",
"getFaceAsync",
"(",
"String",
"personGroupId",
",",
"UUID",
"personId",
",",
"UUID",
"persistedFaceId",
")",
"{",
"return",
"getFaceWithServiceResponseAsync",
"(",
"personGroupId",
",",
"personId",
",",
"persistedFaceId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"PersistedFace",
">",
",",
"PersistedFace",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"PersistedFace",
"call",
"(",
"ServiceResponse",
"<",
"PersistedFace",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId).
@param personGroupId Id referencing a particular person group.
@param personId Id referencing a particular person.
@param persistedFaceId Id referencing a particular persistedFaceId of an existing face.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PersistedFace object | [
"Retrieve",
"information",
"about",
"a",
"persisted",
"face",
"(",
"specified",
"by",
"persistedFaceId",
"personId",
"and",
"its",
"belonging",
"personGroupId",
")",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java#L917-L924 |
craftercms/deployer | src/main/java/org/craftercms/deployer/utils/ConfigUtils.java | ConfigUtils.getLongProperty | public static Long getLongProperty(Configuration config, String key) throws DeployerConfigurationException {
"""
Returns the specified Long property from the configuration
@param config the configuration
@param key the key of the property
@return the Long value of the property, or null if not found
@throws DeployerConfigurationException if an error occurred
"""
return getLongProperty(config, key, null);
} | java | public static Long getLongProperty(Configuration config, String key) throws DeployerConfigurationException {
return getLongProperty(config, key, null);
} | [
"public",
"static",
"Long",
"getLongProperty",
"(",
"Configuration",
"config",
",",
"String",
"key",
")",
"throws",
"DeployerConfigurationException",
"{",
"return",
"getLongProperty",
"(",
"config",
",",
"key",
",",
"null",
")",
";",
"}"
] | Returns the specified Long property from the configuration
@param config the configuration
@param key the key of the property
@return the Long value of the property, or null if not found
@throws DeployerConfigurationException if an error occurred | [
"Returns",
"the",
"specified",
"Long",
"property",
"from",
"the",
"configuration"
] | train | https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/ConfigUtils.java#L200-L202 |
carewebframework/carewebframework-core | org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/TreeUtil.java | TreeUtil.compare | private static int compare(Treenode item1, Treenode item2) {
"""
Case insensitive comparison of labels of two tree items.
@param item1 First tree item.
@param item2 Second tree item.
@return Result of the comparison.
"""
String label1 = item1.getLabel();
String label2 = item2.getLabel();
return label1 == label2 ? 0 : label1 == null ? -1 : label2 == null ? -1 : label1.compareToIgnoreCase(label2);
} | java | private static int compare(Treenode item1, Treenode item2) {
String label1 = item1.getLabel();
String label2 = item2.getLabel();
return label1 == label2 ? 0 : label1 == null ? -1 : label2 == null ? -1 : label1.compareToIgnoreCase(label2);
} | [
"private",
"static",
"int",
"compare",
"(",
"Treenode",
"item1",
",",
"Treenode",
"item2",
")",
"{",
"String",
"label1",
"=",
"item1",
".",
"getLabel",
"(",
")",
";",
"String",
"label2",
"=",
"item2",
".",
"getLabel",
"(",
")",
";",
"return",
"label1",
"==",
"label2",
"?",
"0",
":",
"label1",
"==",
"null",
"?",
"-",
"1",
":",
"label2",
"==",
"null",
"?",
"-",
"1",
":",
"label1",
".",
"compareToIgnoreCase",
"(",
"label2",
")",
";",
"}"
] | Case insensitive comparison of labels of two tree items.
@param item1 First tree item.
@param item2 Second tree item.
@return Result of the comparison. | [
"Case",
"insensitive",
"comparison",
"of",
"labels",
"of",
"two",
"tree",
"items",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/TreeUtil.java#L258-L262 |
ixa-ehu/ixa-pipe-ml | src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java | Parse.setChild | public void setChild(final int index, final String label) {
"""
Replaces the child at the specified index with a new child with the
specified label.
@param index
The index of the child to be replaced.
@param label
The label to be assigned to the new child.
"""
final Parse newChild = (Parse) this.parts.get(index).clone();
newChild.setLabel(label);
this.parts.set(index, newChild);
} | java | public void setChild(final int index, final String label) {
final Parse newChild = (Parse) this.parts.get(index).clone();
newChild.setLabel(label);
this.parts.set(index, newChild);
} | [
"public",
"void",
"setChild",
"(",
"final",
"int",
"index",
",",
"final",
"String",
"label",
")",
"{",
"final",
"Parse",
"newChild",
"=",
"(",
"Parse",
")",
"this",
".",
"parts",
".",
"get",
"(",
"index",
")",
".",
"clone",
"(",
")",
";",
"newChild",
".",
"setLabel",
"(",
"label",
")",
";",
"this",
".",
"parts",
".",
"set",
"(",
"index",
",",
"newChild",
")",
";",
"}"
] | Replaces the child at the specified index with a new child with the
specified label.
@param index
The index of the child to be replaced.
@param label
The label to be assigned to the new child. | [
"Replaces",
"the",
"child",
"at",
"the",
"specified",
"index",
"with",
"a",
"new",
"child",
"with",
"the",
"specified",
"label",
"."
] | train | https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/parse/Parse.java#L542-L546 |
thymeleaf/thymeleaf-spring | thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/util/SpringValueFormatter.java | SpringValueFormatter.getDisplayString | public static String getDisplayString(final Object value, final boolean htmlEscape) {
"""
/*
NOTE This code is based on org.springframework.web.servlet.tags.form.ValueFormatter as of Spring 5.0.0
Original license is Apache License 2.0, which is the same as the license for this file.
Original copyright notice is "Copyright 2002-2012 the original author or authors".
Original authors are Rob Harrop and Juergen Hoeller.
"""
final String displayValue = ObjectUtils.getDisplayString(value);
return (htmlEscape ? HtmlUtils.htmlEscape(displayValue) : displayValue);
} | java | public static String getDisplayString(final Object value, final boolean htmlEscape) {
final String displayValue = ObjectUtils.getDisplayString(value);
return (htmlEscape ? HtmlUtils.htmlEscape(displayValue) : displayValue);
} | [
"public",
"static",
"String",
"getDisplayString",
"(",
"final",
"Object",
"value",
",",
"final",
"boolean",
"htmlEscape",
")",
"{",
"final",
"String",
"displayValue",
"=",
"ObjectUtils",
".",
"getDisplayString",
"(",
"value",
")",
";",
"return",
"(",
"htmlEscape",
"?",
"HtmlUtils",
".",
"htmlEscape",
"(",
"displayValue",
")",
":",
"displayValue",
")",
";",
"}"
] | /*
NOTE This code is based on org.springframework.web.servlet.tags.form.ValueFormatter as of Spring 5.0.0
Original license is Apache License 2.0, which is the same as the license for this file.
Original copyright notice is "Copyright 2002-2012 the original author or authors".
Original authors are Rob Harrop and Juergen Hoeller. | [
"/",
"*",
"NOTE",
"This",
"code",
"is",
"based",
"on",
"org",
".",
"springframework",
".",
"web",
".",
"servlet",
".",
"tags",
".",
"form",
".",
"ValueFormatter",
"as",
"of",
"Spring",
"5",
".",
"0",
".",
"0",
"Original",
"license",
"is",
"Apache",
"License",
"2",
".",
"0",
"which",
"is",
"the",
"same",
"as",
"the",
"license",
"for",
"this",
"file",
".",
"Original",
"copyright",
"notice",
"is",
"Copyright",
"2002",
"-",
"2012",
"the",
"original",
"author",
"or",
"authors",
".",
"Original",
"authors",
"are",
"Rob",
"Harrop",
"and",
"Juergen",
"Hoeller",
"."
] | train | https://github.com/thymeleaf/thymeleaf-spring/blob/9aa15a19017a0938e57646e3deefb8a90ab78dcb/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/util/SpringValueFormatter.java#L50-L53 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java | ValueEnforcer.notNullAndEquals | public static <T> T notNullAndEquals (final T aValue, final String sName, @Nonnull final T aExpectedValue) {
"""
Check that the passed value is not <code>null</code> and equal to the
provided expected value.
@param <T>
Type to be checked and returned
@param aValue
The value to check.
@param sName
The name of the value (e.g. the parameter name)
@param aExpectedValue
The expected value. May not be <code>null</code>.
@return The passed value.
@throws IllegalArgumentException
if the passed value is not <code>null</code>.
"""
if (isEnabled ())
return notNullAndEquals (aValue, () -> sName, aExpectedValue);
return aValue;
} | java | public static <T> T notNullAndEquals (final T aValue, final String sName, @Nonnull final T aExpectedValue)
{
if (isEnabled ())
return notNullAndEquals (aValue, () -> sName, aExpectedValue);
return aValue;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"notNullAndEquals",
"(",
"final",
"T",
"aValue",
",",
"final",
"String",
"sName",
",",
"@",
"Nonnull",
"final",
"T",
"aExpectedValue",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"return",
"notNullAndEquals",
"(",
"aValue",
",",
"(",
")",
"->",
"sName",
",",
"aExpectedValue",
")",
";",
"return",
"aValue",
";",
"}"
] | Check that the passed value is not <code>null</code> and equal to the
provided expected value.
@param <T>
Type to be checked and returned
@param aValue
The value to check.
@param sName
The name of the value (e.g. the parameter name)
@param aExpectedValue
The expected value. May not be <code>null</code>.
@return The passed value.
@throws IllegalArgumentException
if the passed value is not <code>null</code>. | [
"Check",
"that",
"the",
"passed",
"value",
"is",
"not",
"<code",
">",
"null<",
"/",
"code",
">",
"and",
"equal",
"to",
"the",
"provided",
"expected",
"value",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L1370-L1375 |
Jasig/uPortal | uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/ReferenceIndividualGroupService.java | ReferenceIndividualGroupService.findLocalMemberGroups | protected Iterator findLocalMemberGroups(IEntityGroup eg) throws GroupsException {
"""
Returns and caches the member groups for the <code>IEntityGroup</code>
@param eg IEntityGroup
"""
Collection groups = new ArrayList(10);
IEntityGroup group = null;
for (Iterator it = getGroupStore().findMemberGroups(eg); it.hasNext(); ) {
group = (IEntityGroup) it.next();
if (group == null) {
log.warn(
"A null IEntityGroup object was part of a list groupStore.findMemberGroups");
continue;
}
group.setLocalGroupService(this);
groups.add(group);
if (cacheInUse()) {
try {
if (getGroupFromCache(group.getEntityIdentifier().getKey()) == null) {
cacheAdd(group);
}
} catch (CachingException ce) {
throw new GroupsException("Problem finding member groups", ce);
}
}
}
return groups.iterator();
} | java | protected Iterator findLocalMemberGroups(IEntityGroup eg) throws GroupsException {
Collection groups = new ArrayList(10);
IEntityGroup group = null;
for (Iterator it = getGroupStore().findMemberGroups(eg); it.hasNext(); ) {
group = (IEntityGroup) it.next();
if (group == null) {
log.warn(
"A null IEntityGroup object was part of a list groupStore.findMemberGroups");
continue;
}
group.setLocalGroupService(this);
groups.add(group);
if (cacheInUse()) {
try {
if (getGroupFromCache(group.getEntityIdentifier().getKey()) == null) {
cacheAdd(group);
}
} catch (CachingException ce) {
throw new GroupsException("Problem finding member groups", ce);
}
}
}
return groups.iterator();
} | [
"protected",
"Iterator",
"findLocalMemberGroups",
"(",
"IEntityGroup",
"eg",
")",
"throws",
"GroupsException",
"{",
"Collection",
"groups",
"=",
"new",
"ArrayList",
"(",
"10",
")",
";",
"IEntityGroup",
"group",
"=",
"null",
";",
"for",
"(",
"Iterator",
"it",
"=",
"getGroupStore",
"(",
")",
".",
"findMemberGroups",
"(",
"eg",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"group",
"=",
"(",
"IEntityGroup",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"group",
"==",
"null",
")",
"{",
"log",
".",
"warn",
"(",
"\"A null IEntityGroup object was part of a list groupStore.findMemberGroups\"",
")",
";",
"continue",
";",
"}",
"group",
".",
"setLocalGroupService",
"(",
"this",
")",
";",
"groups",
".",
"add",
"(",
"group",
")",
";",
"if",
"(",
"cacheInUse",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"getGroupFromCache",
"(",
"group",
".",
"getEntityIdentifier",
"(",
")",
".",
"getKey",
"(",
")",
")",
"==",
"null",
")",
"{",
"cacheAdd",
"(",
"group",
")",
";",
"}",
"}",
"catch",
"(",
"CachingException",
"ce",
")",
"{",
"throw",
"new",
"GroupsException",
"(",
"\"Problem finding member groups\"",
",",
"ce",
")",
";",
"}",
"}",
"}",
"return",
"groups",
".",
"iterator",
"(",
")",
";",
"}"
] | Returns and caches the member groups for the <code>IEntityGroup</code>
@param eg IEntityGroup | [
"Returns",
"and",
"caches",
"the",
"member",
"groups",
"for",
"the",
"<code",
">",
"IEntityGroup<",
"/",
"code",
">"
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/ReferenceIndividualGroupService.java#L268-L291 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/filter/DependentFileFilter.java | DependentFileFilter.init | public void init(Record record, String thisFileFieldName, BaseField fldThisFile, String thisFileFieldName2, BaseField fldThisFile2, String thisFileFieldName3, BaseField fldThisFile3) {
"""
Constructor.
@param record My owner (usually passed as null, and set on addListener in setOwner()).
@param iFieldSeq The First field sequence of the key.
@param fldThisFile The first field
@param iFieldSeq2 The Second field sequence of the key (-1 for none).
@param fldThisFile2 The second field
@param iFieldSeq3 The Third field sequence of the key (-1 for none).
@param fldThisFile3 The third field
"""
super.init(record);
this.thisFileFieldName = thisFileFieldName;
m_fldThisFile = fldThisFile;
this.thisFileFieldName2 = thisFileFieldName2;
m_fldThisFile2 = fldThisFile2;
this.thisFileFieldName3 = thisFileFieldName3;
m_fldThisFile3 = fldThisFile3;
m_bInitialKey = true;
m_bEndKey = true;
} | java | public void init(Record record, String thisFileFieldName, BaseField fldThisFile, String thisFileFieldName2, BaseField fldThisFile2, String thisFileFieldName3, BaseField fldThisFile3)
{
super.init(record);
this.thisFileFieldName = thisFileFieldName;
m_fldThisFile = fldThisFile;
this.thisFileFieldName2 = thisFileFieldName2;
m_fldThisFile2 = fldThisFile2;
this.thisFileFieldName3 = thisFileFieldName3;
m_fldThisFile3 = fldThisFile3;
m_bInitialKey = true;
m_bEndKey = true;
} | [
"public",
"void",
"init",
"(",
"Record",
"record",
",",
"String",
"thisFileFieldName",
",",
"BaseField",
"fldThisFile",
",",
"String",
"thisFileFieldName2",
",",
"BaseField",
"fldThisFile2",
",",
"String",
"thisFileFieldName3",
",",
"BaseField",
"fldThisFile3",
")",
"{",
"super",
".",
"init",
"(",
"record",
")",
";",
"this",
".",
"thisFileFieldName",
"=",
"thisFileFieldName",
";",
"m_fldThisFile",
"=",
"fldThisFile",
";",
"this",
".",
"thisFileFieldName2",
"=",
"thisFileFieldName2",
";",
"m_fldThisFile2",
"=",
"fldThisFile2",
";",
"this",
".",
"thisFileFieldName3",
"=",
"thisFileFieldName3",
";",
"m_fldThisFile3",
"=",
"fldThisFile3",
";",
"m_bInitialKey",
"=",
"true",
";",
"m_bEndKey",
"=",
"true",
";",
"}"
] | Constructor.
@param record My owner (usually passed as null, and set on addListener in setOwner()).
@param iFieldSeq The First field sequence of the key.
@param fldThisFile The first field
@param iFieldSeq2 The Second field sequence of the key (-1 for none).
@param fldThisFile2 The second field
@param iFieldSeq3 The Third field sequence of the key (-1 for none).
@param fldThisFile3 The third field | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/filter/DependentFileFilter.java#L68-L79 |
Cornutum/tcases | tcases-lib/src/main/java/org/cornutum/tcases/conditions/Conditions.java | Conditions.betweenExclusiveMin | public static Between betweenExclusiveMin( String property, int minimum, int maximum) {
"""
Returns a {@link ICondition condition} that is satisfied by a {@link org.cornutum.tcases.PropertySet} that contains
between a specified minimum (exclusive) and maximum (inclusive) number of instances of a property.
"""
return new Between( moreThan( property, minimum), notMoreThan( property, maximum));
} | java | public static Between betweenExclusiveMin( String property, int minimum, int maximum)
{
return new Between( moreThan( property, minimum), notMoreThan( property, maximum));
} | [
"public",
"static",
"Between",
"betweenExclusiveMin",
"(",
"String",
"property",
",",
"int",
"minimum",
",",
"int",
"maximum",
")",
"{",
"return",
"new",
"Between",
"(",
"moreThan",
"(",
"property",
",",
"minimum",
")",
",",
"notMoreThan",
"(",
"property",
",",
"maximum",
")",
")",
";",
"}"
] | Returns a {@link ICondition condition} that is satisfied by a {@link org.cornutum.tcases.PropertySet} that contains
between a specified minimum (exclusive) and maximum (inclusive) number of instances of a property. | [
"Returns",
"a",
"{"
] | train | https://github.com/Cornutum/tcases/blob/21e15cf107fa149620c40f4bda1829c1224fcfb1/tcases-lib/src/main/java/org/cornutum/tcases/conditions/Conditions.java#L154-L157 |
SeleniumHQ/fluent-selenium | java/src/main/java/org/seleniumhq/selenium/fluent/FluentSelect.java | FluentSelect.selectByVisibleText | public FluentSelect selectByVisibleText(final String text) {
"""
<p>
Select all options that display text matching the argument. That is, when given "Bar" this
would select an option like:
</p>
<option value="foo">Bar</option>
@param text The visible text to match against
"""
executeAndWrapReThrowIfNeeded(new SelectByVisibleText(text), Context.singular(context, "selectByVisibleText", null, text), true);
return new FluentSelect(super.delegate, currentElement.getFound(), this.context, monitor, booleanInsteadOfNotFoundException);
} | java | public FluentSelect selectByVisibleText(final String text) {
executeAndWrapReThrowIfNeeded(new SelectByVisibleText(text), Context.singular(context, "selectByVisibleText", null, text), true);
return new FluentSelect(super.delegate, currentElement.getFound(), this.context, monitor, booleanInsteadOfNotFoundException);
} | [
"public",
"FluentSelect",
"selectByVisibleText",
"(",
"final",
"String",
"text",
")",
"{",
"executeAndWrapReThrowIfNeeded",
"(",
"new",
"SelectByVisibleText",
"(",
"text",
")",
",",
"Context",
".",
"singular",
"(",
"context",
",",
"\"selectByVisibleText\"",
",",
"null",
",",
"text",
")",
",",
"true",
")",
";",
"return",
"new",
"FluentSelect",
"(",
"super",
".",
"delegate",
",",
"currentElement",
".",
"getFound",
"(",
")",
",",
"this",
".",
"context",
",",
"monitor",
",",
"booleanInsteadOfNotFoundException",
")",
";",
"}"
] | <p>
Select all options that display text matching the argument. That is, when given "Bar" this
would select an option like:
</p>
<option value="foo">Bar</option>
@param text The visible text to match against | [
"<p",
">",
"Select",
"all",
"options",
"that",
"display",
"text",
"matching",
"the",
"argument",
".",
"That",
"is",
"when",
"given",
"Bar",
"this",
"would",
"select",
"an",
"option",
"like",
":",
"<",
"/",
"p",
">",
"<",
";",
"option",
"value",
"=",
"foo",
">",
";",
"Bar<",
";",
"/",
"option>",
";"
] | train | https://github.com/SeleniumHQ/fluent-selenium/blob/fcb171471a7d1abb2800bcbca21b3ae3e6c12472/java/src/main/java/org/seleniumhq/selenium/fluent/FluentSelect.java#L88-L91 |
rpau/javalang | src/main/java/org/walkmod/javalang/actions/ReplaceAction.java | ReplaceAction.getText | public String getText(String indentation, char indentationChar) {
"""
Returns the new text to insert with the appropriate indentation and comments
@param indentation
the existing indentation at the file. It never should be null and it is needed for
files that mix tabs and spaces in the same line.
@param indentationChar
the used indentation char (' ', or '\t')
@return the new text that replaces the existing one
"""
newCode = FormatterHelper.indent(
newNode.getPrettySource(indentationChar, indentationLevel, indentationSize, acceptedComments),
indentation, indentationChar, indentationLevel, indentationSize, requiresExtraIndentationOnFirstLine());
return newCode;
} | java | public String getText(String indentation, char indentationChar) {
newCode = FormatterHelper.indent(
newNode.getPrettySource(indentationChar, indentationLevel, indentationSize, acceptedComments),
indentation, indentationChar, indentationLevel, indentationSize, requiresExtraIndentationOnFirstLine());
return newCode;
} | [
"public",
"String",
"getText",
"(",
"String",
"indentation",
",",
"char",
"indentationChar",
")",
"{",
"newCode",
"=",
"FormatterHelper",
".",
"indent",
"(",
"newNode",
".",
"getPrettySource",
"(",
"indentationChar",
",",
"indentationLevel",
",",
"indentationSize",
",",
"acceptedComments",
")",
",",
"indentation",
",",
"indentationChar",
",",
"indentationLevel",
",",
"indentationSize",
",",
"requiresExtraIndentationOnFirstLine",
"(",
")",
")",
";",
"return",
"newCode",
";",
"}"
] | Returns the new text to insert with the appropriate indentation and comments
@param indentation
the existing indentation at the file. It never should be null and it is needed for
files that mix tabs and spaces in the same line.
@param indentationChar
the used indentation char (' ', or '\t')
@return the new text that replaces the existing one | [
"Returns",
"the",
"new",
"text",
"to",
"insert",
"with",
"the",
"appropriate",
"indentation",
"and",
"comments"
] | train | https://github.com/rpau/javalang/blob/17ab1d6cbe7527a2f272049c4958354328de2171/src/main/java/org/walkmod/javalang/actions/ReplaceAction.java#L105-L112 |
nightcode/yaranga | core/src/org/nightcode/common/base/Hexs.java | Hexs.fromByteArray | public String fromByteArray(byte[] bytes, int offset, int length) {
"""
Returns a hexadecimal string representation of {@code length} bytes of {@code bytes}
starting at offset {@code offset}.
@param bytes a bytes to convert
@param offset start offset in the bytes
@param length maximum number of bytes to use
@return a hexadecimal string representation of each bytes of {@code bytes}
"""
java.util.Objects.requireNonNull(bytes, "bytes");
Objects.validArgument(offset >= 0, "offset must be equal or greater than zero");
Objects.validArgument(length > 0, "length must be greater than zero");
Objects.validArgument(offset + length <= bytes.length
, "(offset + length) must be less than %s", bytes.length);
if (byteSeparator != null && byteSeparator.length() > 0) {
return fromByteArrayInternal(bytes, offset, length, byteSeparator);
} else {
return fromByteArrayInternal(bytes, offset, length);
}
} | java | public String fromByteArray(byte[] bytes, int offset, int length) {
java.util.Objects.requireNonNull(bytes, "bytes");
Objects.validArgument(offset >= 0, "offset must be equal or greater than zero");
Objects.validArgument(length > 0, "length must be greater than zero");
Objects.validArgument(offset + length <= bytes.length
, "(offset + length) must be less than %s", bytes.length);
if (byteSeparator != null && byteSeparator.length() > 0) {
return fromByteArrayInternal(bytes, offset, length, byteSeparator);
} else {
return fromByteArrayInternal(bytes, offset, length);
}
} | [
"public",
"String",
"fromByteArray",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"java",
".",
"util",
".",
"Objects",
".",
"requireNonNull",
"(",
"bytes",
",",
"\"bytes\"",
")",
";",
"Objects",
".",
"validArgument",
"(",
"offset",
">=",
"0",
",",
"\"offset must be equal or greater than zero\"",
")",
";",
"Objects",
".",
"validArgument",
"(",
"length",
">",
"0",
",",
"\"length must be greater than zero\"",
")",
";",
"Objects",
".",
"validArgument",
"(",
"offset",
"+",
"length",
"<=",
"bytes",
".",
"length",
",",
"\"(offset + length) must be less than %s\"",
",",
"bytes",
".",
"length",
")",
";",
"if",
"(",
"byteSeparator",
"!=",
"null",
"&&",
"byteSeparator",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"return",
"fromByteArrayInternal",
"(",
"bytes",
",",
"offset",
",",
"length",
",",
"byteSeparator",
")",
";",
"}",
"else",
"{",
"return",
"fromByteArrayInternal",
"(",
"bytes",
",",
"offset",
",",
"length",
")",
";",
"}",
"}"
] | Returns a hexadecimal string representation of {@code length} bytes of {@code bytes}
starting at offset {@code offset}.
@param bytes a bytes to convert
@param offset start offset in the bytes
@param length maximum number of bytes to use
@return a hexadecimal string representation of each bytes of {@code bytes} | [
"Returns",
"a",
"hexadecimal",
"string",
"representation",
"of",
"{",
"@code",
"length",
"}",
"bytes",
"of",
"{",
"@code",
"bytes",
"}",
"starting",
"at",
"offset",
"{",
"@code",
"offset",
"}",
"."
] | train | https://github.com/nightcode/yaranga/blob/f02cf8d8bcd365b6b1d55638938631a00e9ee808/core/src/org/nightcode/common/base/Hexs.java#L78-L89 |
twitter/cloudhopper-commons | ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/PropertiesReplacementUtil.java | PropertiesReplacementUtil.replaceProperties | static public InputStream replaceProperties(InputStream source, Properties props, String startStr, String endStr) throws IOException, SubstitutionException {
"""
Creates an InputStream containing the document resulting from replacing template
parameters in the given InputStream source.
@param source The source stream
@param props The properties
@param startStr The String that marks the start of a replacement key such as "${"
@param endStr The String that marks the end of a replacement key such as "}"
@return An InputStream containing the resulting document.
"""
String template = streamToString(source);
String replaced = StringUtil.substituteWithProperties(template, startStr, endStr, props);
System.err.println(template);
System.err.println(replaced);
return new ByteArrayInputStream(replaced.getBytes());
} | java | static public InputStream replaceProperties(InputStream source, Properties props, String startStr, String endStr) throws IOException, SubstitutionException {
String template = streamToString(source);
String replaced = StringUtil.substituteWithProperties(template, startStr, endStr, props);
System.err.println(template);
System.err.println(replaced);
return new ByteArrayInputStream(replaced.getBytes());
} | [
"static",
"public",
"InputStream",
"replaceProperties",
"(",
"InputStream",
"source",
",",
"Properties",
"props",
",",
"String",
"startStr",
",",
"String",
"endStr",
")",
"throws",
"IOException",
",",
"SubstitutionException",
"{",
"String",
"template",
"=",
"streamToString",
"(",
"source",
")",
";",
"String",
"replaced",
"=",
"StringUtil",
".",
"substituteWithProperties",
"(",
"template",
",",
"startStr",
",",
"endStr",
",",
"props",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"template",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"replaced",
")",
";",
"return",
"new",
"ByteArrayInputStream",
"(",
"replaced",
".",
"getBytes",
"(",
")",
")",
";",
"}"
] | Creates an InputStream containing the document resulting from replacing template
parameters in the given InputStream source.
@param source The source stream
@param props The properties
@param startStr The String that marks the start of a replacement key such as "${"
@param endStr The String that marks the end of a replacement key such as "}"
@return An InputStream containing the resulting document. | [
"Creates",
"an",
"InputStream",
"containing",
"the",
"document",
"resulting",
"from",
"replacing",
"template",
"parameters",
"in",
"the",
"given",
"InputStream",
"source",
"."
] | train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/PropertiesReplacementUtil.java#L123-L129 |
Impetus/Kundera | src/kundera-rethinkdb/src/main/java/com/impetus/client/rethink/RethinkDBClient.java | RethinkDBClient.iterateAndPopulateRmap | private MapObject iterateAndPopulateRmap(Object entity, MetamodelImpl metaModel, Iterator<Attribute> iterator) {
"""
Iterate and populate rmap.
@param entity
the entity
@param metaModel
the meta model
@param iterator
the iterator
@return the map object
"""
MapObject map = r.hashMap();
while (iterator.hasNext())
{
Attribute attribute = iterator.next();
Field field = (Field) attribute.getJavaMember();
Object value = PropertyAccessorHelper.getObject(entity, field);
if (field.isAnnotationPresent(Id.class))
{
map.with(ID, value);
}
else
{
map.with(((AbstractAttribute) attribute).getJPAColumnName(), value);
}
}
return map;
} | java | private MapObject iterateAndPopulateRmap(Object entity, MetamodelImpl metaModel, Iterator<Attribute> iterator)
{
MapObject map = r.hashMap();
while (iterator.hasNext())
{
Attribute attribute = iterator.next();
Field field = (Field) attribute.getJavaMember();
Object value = PropertyAccessorHelper.getObject(entity, field);
if (field.isAnnotationPresent(Id.class))
{
map.with(ID, value);
}
else
{
map.with(((AbstractAttribute) attribute).getJPAColumnName(), value);
}
}
return map;
} | [
"private",
"MapObject",
"iterateAndPopulateRmap",
"(",
"Object",
"entity",
",",
"MetamodelImpl",
"metaModel",
",",
"Iterator",
"<",
"Attribute",
">",
"iterator",
")",
"{",
"MapObject",
"map",
"=",
"r",
".",
"hashMap",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"Attribute",
"attribute",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"Field",
"field",
"=",
"(",
"Field",
")",
"attribute",
".",
"getJavaMember",
"(",
")",
";",
"Object",
"value",
"=",
"PropertyAccessorHelper",
".",
"getObject",
"(",
"entity",
",",
"field",
")",
";",
"if",
"(",
"field",
".",
"isAnnotationPresent",
"(",
"Id",
".",
"class",
")",
")",
"{",
"map",
".",
"with",
"(",
"ID",
",",
"value",
")",
";",
"}",
"else",
"{",
"map",
".",
"with",
"(",
"(",
"(",
"AbstractAttribute",
")",
"attribute",
")",
".",
"getJPAColumnName",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"return",
"map",
";",
"}"
] | Iterate and populate rmap.
@param entity
the entity
@param metaModel
the meta model
@param iterator
the iterator
@return the map object | [
"Iterate",
"and",
"populate",
"rmap",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-rethinkdb/src/main/java/com/impetus/client/rethink/RethinkDBClient.java#L347-L365 |
Azure/azure-sdk-for-java | cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java | DatabaseAccountsInner.beginOnlineRegionAsync | public Observable<Void> beginOnlineRegionAsync(String resourceGroupName, String accountName, String region) {
"""
Online the specified region for the specified Azure Cosmos DB database account.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param region Cosmos DB region, with spaces between words and each word capitalized.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginOnlineRegionWithServiceResponseAsync(resourceGroupName, accountName, region).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginOnlineRegionAsync(String resourceGroupName, String accountName, String region) {
return beginOnlineRegionWithServiceResponseAsync(resourceGroupName, accountName, region).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginOnlineRegionAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"region",
")",
"{",
"return",
"beginOnlineRegionWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"region",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Online the specified region for the specified Azure Cosmos DB database account.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param region Cosmos DB region, with spaces between words and each word capitalized.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Online",
"the",
"specified",
"region",
"for",
"the",
"specified",
"Azure",
"Cosmos",
"DB",
"database",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java#L1560-L1567 |
LAW-Unimi/BUbiNG | src/it/unimi/di/law/warc/io/gzarc/GZIPIndexer.java | GZIPIndexer.index | public static LongBigArrayBigList index(final InputStream in, final ProgressLogger pl) throws IOException {
"""
Returns a list of pointers to a GZIP archive entries positions (including the end of file).
@param in the stream from which to read the GZIP archive.
@param pl a progress logger.
@return a list of longs where the <em>i</em>-th long is the offset in the stream of the first byte of the <em>i</em>-th archive entry.
"""
final LongBigArrayBigList pointers = new LongBigArrayBigList();
long current = 0;
final GZIPArchiveReader gzar = new GZIPArchiveReader(in);
GZIPArchive.ReadEntry re;
for (;;) {
re = gzar.skipEntry();
if (re == null) break;
pointers.add(current);
current += re.compressedSkipLength;
if (pl != null) pl.lightUpdate();
}
in.close();
return pointers;
} | java | public static LongBigArrayBigList index(final InputStream in, final ProgressLogger pl) throws IOException {
final LongBigArrayBigList pointers = new LongBigArrayBigList();
long current = 0;
final GZIPArchiveReader gzar = new GZIPArchiveReader(in);
GZIPArchive.ReadEntry re;
for (;;) {
re = gzar.skipEntry();
if (re == null) break;
pointers.add(current);
current += re.compressedSkipLength;
if (pl != null) pl.lightUpdate();
}
in.close();
return pointers;
} | [
"public",
"static",
"LongBigArrayBigList",
"index",
"(",
"final",
"InputStream",
"in",
",",
"final",
"ProgressLogger",
"pl",
")",
"throws",
"IOException",
"{",
"final",
"LongBigArrayBigList",
"pointers",
"=",
"new",
"LongBigArrayBigList",
"(",
")",
";",
"long",
"current",
"=",
"0",
";",
"final",
"GZIPArchiveReader",
"gzar",
"=",
"new",
"GZIPArchiveReader",
"(",
"in",
")",
";",
"GZIPArchive",
".",
"ReadEntry",
"re",
";",
"for",
"(",
";",
";",
")",
"{",
"re",
"=",
"gzar",
".",
"skipEntry",
"(",
")",
";",
"if",
"(",
"re",
"==",
"null",
")",
"break",
";",
"pointers",
".",
"add",
"(",
"current",
")",
";",
"current",
"+=",
"re",
".",
"compressedSkipLength",
";",
"if",
"(",
"pl",
"!=",
"null",
")",
"pl",
".",
"lightUpdate",
"(",
")",
";",
"}",
"in",
".",
"close",
"(",
")",
";",
"return",
"pointers",
";",
"}"
] | Returns a list of pointers to a GZIP archive entries positions (including the end of file).
@param in the stream from which to read the GZIP archive.
@param pl a progress logger.
@return a list of longs where the <em>i</em>-th long is the offset in the stream of the first byte of the <em>i</em>-th archive entry. | [
"Returns",
"a",
"list",
"of",
"pointers",
"to",
"a",
"GZIP",
"archive",
"entries",
"positions",
"(",
"including",
"the",
"end",
"of",
"file",
")",
"."
] | train | https://github.com/LAW-Unimi/BUbiNG/blob/e148acc90031a4f3967422705a9fb07ddaf155e4/src/it/unimi/di/law/warc/io/gzarc/GZIPIndexer.java#L62-L76 |
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java | ContentSpecParser.createEmptyLevelFromType | protected Level createEmptyLevelFromType(final int lineNumber, final LevelType levelType, final String input) {
"""
Creates an empty Level using the LevelType to determine which Level subclass to instantiate.
@param lineNumber The line number of the level.
@param levelType The Level Type.
@param input The string that represents the level, if one exists,
@return The empty Level subclass object, or a plain Level object if no type matches a subclass.
"""
// Create the level based on the type
switch (levelType) {
case APPENDIX:
return new Appendix(null, lineNumber, input);
case CHAPTER:
return new Chapter(null, lineNumber, input);
case SECTION:
return new Section(null, lineNumber, input);
case PART:
return new Part(null, lineNumber, input);
case PROCESS:
return new Process(null, lineNumber, input);
case INITIAL_CONTENT:
return new InitialContent(lineNumber, input);
default:
return new Level(null, lineNumber, input, levelType);
}
} | java | protected Level createEmptyLevelFromType(final int lineNumber, final LevelType levelType, final String input) {
// Create the level based on the type
switch (levelType) {
case APPENDIX:
return new Appendix(null, lineNumber, input);
case CHAPTER:
return new Chapter(null, lineNumber, input);
case SECTION:
return new Section(null, lineNumber, input);
case PART:
return new Part(null, lineNumber, input);
case PROCESS:
return new Process(null, lineNumber, input);
case INITIAL_CONTENT:
return new InitialContent(lineNumber, input);
default:
return new Level(null, lineNumber, input, levelType);
}
} | [
"protected",
"Level",
"createEmptyLevelFromType",
"(",
"final",
"int",
"lineNumber",
",",
"final",
"LevelType",
"levelType",
",",
"final",
"String",
"input",
")",
"{",
"// Create the level based on the type",
"switch",
"(",
"levelType",
")",
"{",
"case",
"APPENDIX",
":",
"return",
"new",
"Appendix",
"(",
"null",
",",
"lineNumber",
",",
"input",
")",
";",
"case",
"CHAPTER",
":",
"return",
"new",
"Chapter",
"(",
"null",
",",
"lineNumber",
",",
"input",
")",
";",
"case",
"SECTION",
":",
"return",
"new",
"Section",
"(",
"null",
",",
"lineNumber",
",",
"input",
")",
";",
"case",
"PART",
":",
"return",
"new",
"Part",
"(",
"null",
",",
"lineNumber",
",",
"input",
")",
";",
"case",
"PROCESS",
":",
"return",
"new",
"Process",
"(",
"null",
",",
"lineNumber",
",",
"input",
")",
";",
"case",
"INITIAL_CONTENT",
":",
"return",
"new",
"InitialContent",
"(",
"lineNumber",
",",
"input",
")",
";",
"default",
":",
"return",
"new",
"Level",
"(",
"null",
",",
"lineNumber",
",",
"input",
",",
"levelType",
")",
";",
"}",
"}"
] | Creates an empty Level using the LevelType to determine which Level subclass to instantiate.
@param lineNumber The line number of the level.
@param levelType The Level Type.
@param input The string that represents the level, if one exists,
@return The empty Level subclass object, or a plain Level object if no type matches a subclass. | [
"Creates",
"an",
"empty",
"Level",
"using",
"the",
"LevelType",
"to",
"determine",
"which",
"Level",
"subclass",
"to",
"instantiate",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L1243-L1261 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFile.java | BoxFile.uploadNewVersion | public BoxFile.Info uploadNewVersion(InputStream fileContent, String fileContentSHA1) {
"""
Uploads a new version of this file, replacing the current version. Note that only users with premium accounts
will be able to view and recover previous versions of the file.
@param fileContent a stream containing the new file contents.
@param fileContentSHA1 a string containing the SHA1 hash of the new file contents.
@return the uploaded file version.
"""
return this.uploadNewVersion(fileContent, fileContentSHA1, null);
} | java | public BoxFile.Info uploadNewVersion(InputStream fileContent, String fileContentSHA1) {
return this.uploadNewVersion(fileContent, fileContentSHA1, null);
} | [
"public",
"BoxFile",
".",
"Info",
"uploadNewVersion",
"(",
"InputStream",
"fileContent",
",",
"String",
"fileContentSHA1",
")",
"{",
"return",
"this",
".",
"uploadNewVersion",
"(",
"fileContent",
",",
"fileContentSHA1",
",",
"null",
")",
";",
"}"
] | Uploads a new version of this file, replacing the current version. Note that only users with premium accounts
will be able to view and recover previous versions of the file.
@param fileContent a stream containing the new file contents.
@param fileContentSHA1 a string containing the SHA1 hash of the new file contents.
@return the uploaded file version. | [
"Uploads",
"a",
"new",
"version",
"of",
"this",
"file",
"replacing",
"the",
"current",
"version",
".",
"Note",
"that",
"only",
"users",
"with",
"premium",
"accounts",
"will",
"be",
"able",
"to",
"view",
"and",
"recover",
"previous",
"versions",
"of",
"the",
"file",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L810-L812 |
guardtime/ksi-java-sdk | ksi-service-client/src/main/java/com/guardtime/ksi/pdu/v1/AbstractKSIRequest.java | AbstractKSIRequest.calculateMac | protected DataHash calculateMac() throws KSIException {
"""
Calculates the MAC based on header and payload TLVs.
@return Calculated data hash.
@throws KSIException
if HMAC generation fails.
"""
try {
HashAlgorithm algorithm = HashAlgorithm.getByName("DEFAULT");
algorithm.checkExpiration();
return new DataHash(algorithm, Util.calculateHMAC(getContent(), this.loginKey, algorithm.getName()));
} catch (IOException e) {
throw new KSIProtocolException("Problem with HMAC", e);
} catch (InvalidKeyException e) {
throw new KSIProtocolException("Problem with HMAC key.", e);
} catch (NoSuchAlgorithmException e) {
// If the default algorithm changes to be outside of MD5 / SHA1 /
// SHA256 list.
throw new KSIProtocolException("Unsupported HMAC algorithm.", e);
} catch (HashException e) {
throw new KSIProtocolException(e.getMessage(), e);
}
} | java | protected DataHash calculateMac() throws KSIException {
try {
HashAlgorithm algorithm = HashAlgorithm.getByName("DEFAULT");
algorithm.checkExpiration();
return new DataHash(algorithm, Util.calculateHMAC(getContent(), this.loginKey, algorithm.getName()));
} catch (IOException e) {
throw new KSIProtocolException("Problem with HMAC", e);
} catch (InvalidKeyException e) {
throw new KSIProtocolException("Problem with HMAC key.", e);
} catch (NoSuchAlgorithmException e) {
// If the default algorithm changes to be outside of MD5 / SHA1 /
// SHA256 list.
throw new KSIProtocolException("Unsupported HMAC algorithm.", e);
} catch (HashException e) {
throw new KSIProtocolException(e.getMessage(), e);
}
} | [
"protected",
"DataHash",
"calculateMac",
"(",
")",
"throws",
"KSIException",
"{",
"try",
"{",
"HashAlgorithm",
"algorithm",
"=",
"HashAlgorithm",
".",
"getByName",
"(",
"\"DEFAULT\"",
")",
";",
"algorithm",
".",
"checkExpiration",
"(",
")",
";",
"return",
"new",
"DataHash",
"(",
"algorithm",
",",
"Util",
".",
"calculateHMAC",
"(",
"getContent",
"(",
")",
",",
"this",
".",
"loginKey",
",",
"algorithm",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"KSIProtocolException",
"(",
"\"Problem with HMAC\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InvalidKeyException",
"e",
")",
"{",
"throw",
"new",
"KSIProtocolException",
"(",
"\"Problem with HMAC key.\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"// If the default algorithm changes to be outside of MD5 / SHA1 /",
"// SHA256 list.",
"throw",
"new",
"KSIProtocolException",
"(",
"\"Unsupported HMAC algorithm.\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"HashException",
"e",
")",
"{",
"throw",
"new",
"KSIProtocolException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Calculates the MAC based on header and payload TLVs.
@return Calculated data hash.
@throws KSIException
if HMAC generation fails. | [
"Calculates",
"the",
"MAC",
"based",
"on",
"header",
"and",
"payload",
"TLVs",
"."
] | train | https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-service-client/src/main/java/com/guardtime/ksi/pdu/v1/AbstractKSIRequest.java#L132-L148 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/utils/MpJwtAppSetupUtils.java | MpJwtAppSetupUtils.genericCreateArchiveWithoutJsps | public WebArchive genericCreateArchiveWithoutJsps(String baseWarName, List<String> classList) throws Exception {
"""
Create a new war with "standard" content for tests using these utils.
Finally add the classes that are specific to this war (they come from the classList passed in)
@param baseWarName - the base name of the war
@param classList - the list of classes specific to this war
@return - the generated war
@throws Exception
"""
try {
String warName = getWarName(baseWarName);
WebArchive newWar = ShrinkWrap.create(WebArchive.class, warName);
addDefaultFileAssetsForAppsToWar(warName, newWar);
for (String theClass : classList) {
newWar.addClass(theClass);
}
return newWar;
} catch (Exception e) {
Log.error(thisClass, "genericCreateArchive", e);
throw e;
}
} | java | public WebArchive genericCreateArchiveWithoutJsps(String baseWarName, List<String> classList) throws Exception {
try {
String warName = getWarName(baseWarName);
WebArchive newWar = ShrinkWrap.create(WebArchive.class, warName);
addDefaultFileAssetsForAppsToWar(warName, newWar);
for (String theClass : classList) {
newWar.addClass(theClass);
}
return newWar;
} catch (Exception e) {
Log.error(thisClass, "genericCreateArchive", e);
throw e;
}
} | [
"public",
"WebArchive",
"genericCreateArchiveWithoutJsps",
"(",
"String",
"baseWarName",
",",
"List",
"<",
"String",
">",
"classList",
")",
"throws",
"Exception",
"{",
"try",
"{",
"String",
"warName",
"=",
"getWarName",
"(",
"baseWarName",
")",
";",
"WebArchive",
"newWar",
"=",
"ShrinkWrap",
".",
"create",
"(",
"WebArchive",
".",
"class",
",",
"warName",
")",
";",
"addDefaultFileAssetsForAppsToWar",
"(",
"warName",
",",
"newWar",
")",
";",
"for",
"(",
"String",
"theClass",
":",
"classList",
")",
"{",
"newWar",
".",
"addClass",
"(",
"theClass",
")",
";",
"}",
"return",
"newWar",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"error",
"(",
"thisClass",
",",
"\"genericCreateArchive\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | Create a new war with "standard" content for tests using these utils.
Finally add the classes that are specific to this war (they come from the classList passed in)
@param baseWarName - the base name of the war
@param classList - the list of classes specific to this war
@return - the generated war
@throws Exception | [
"Create",
"a",
"new",
"war",
"with",
"standard",
"content",
"for",
"tests",
"using",
"these",
"utils",
".",
"Finally",
"add",
"the",
"classes",
"that",
"are",
"specific",
"to",
"this",
"war",
"(",
"they",
"come",
"from",
"the",
"classList",
"passed",
"in",
")"
] | 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#L254-L267 |
Squarespace/cldr | core/src/main/java/com/squarespace/cldr/numbers/NumberFormatContext.java | NumberFormatContext.setPattern | public void setPattern(NumberPattern pattern, int _maxSigDigits, int _minSigDigits) {
"""
Set the pattern and initialize parameters based on the arguments, pattern and options settings.
"""
Format format = pattern.format();
minIntDigits = orDefault(options.minimumIntegerDigits(), format.minimumIntegerDigits());
maxFracDigits = currencyDigits == -1 ? format.maximumFractionDigits() : currencyDigits;
maxFracDigits = orDefault(options.maximumFractionDigits(), maxFracDigits);
minFracDigits = currencyDigits == -1 ? format.minimumFractionDigits() : currencyDigits;
minFracDigits = orDefault(options.minimumFractionDigits(), minFracDigits);
boolean useSignificant = formatMode == SIGNIFICANT || formatMode == SIGNIFICANT_MAXFRAC;
if (useSignificant) {
maxSigDigits = orDefault(options.maximumSignificantDigits(), _maxSigDigits);
minSigDigits = orDefault(options.minimumSignificantDigits(), _minSigDigits);
} else {
maxSigDigits = -1;
minSigDigits = -1;
}
} | java | public void setPattern(NumberPattern pattern, int _maxSigDigits, int _minSigDigits) {
Format format = pattern.format();
minIntDigits = orDefault(options.minimumIntegerDigits(), format.minimumIntegerDigits());
maxFracDigits = currencyDigits == -1 ? format.maximumFractionDigits() : currencyDigits;
maxFracDigits = orDefault(options.maximumFractionDigits(), maxFracDigits);
minFracDigits = currencyDigits == -1 ? format.minimumFractionDigits() : currencyDigits;
minFracDigits = orDefault(options.minimumFractionDigits(), minFracDigits);
boolean useSignificant = formatMode == SIGNIFICANT || formatMode == SIGNIFICANT_MAXFRAC;
if (useSignificant) {
maxSigDigits = orDefault(options.maximumSignificantDigits(), _maxSigDigits);
minSigDigits = orDefault(options.minimumSignificantDigits(), _minSigDigits);
} else {
maxSigDigits = -1;
minSigDigits = -1;
}
} | [
"public",
"void",
"setPattern",
"(",
"NumberPattern",
"pattern",
",",
"int",
"_maxSigDigits",
",",
"int",
"_minSigDigits",
")",
"{",
"Format",
"format",
"=",
"pattern",
".",
"format",
"(",
")",
";",
"minIntDigits",
"=",
"orDefault",
"(",
"options",
".",
"minimumIntegerDigits",
"(",
")",
",",
"format",
".",
"minimumIntegerDigits",
"(",
")",
")",
";",
"maxFracDigits",
"=",
"currencyDigits",
"==",
"-",
"1",
"?",
"format",
".",
"maximumFractionDigits",
"(",
")",
":",
"currencyDigits",
";",
"maxFracDigits",
"=",
"orDefault",
"(",
"options",
".",
"maximumFractionDigits",
"(",
")",
",",
"maxFracDigits",
")",
";",
"minFracDigits",
"=",
"currencyDigits",
"==",
"-",
"1",
"?",
"format",
".",
"minimumFractionDigits",
"(",
")",
":",
"currencyDigits",
";",
"minFracDigits",
"=",
"orDefault",
"(",
"options",
".",
"minimumFractionDigits",
"(",
")",
",",
"minFracDigits",
")",
";",
"boolean",
"useSignificant",
"=",
"formatMode",
"==",
"SIGNIFICANT",
"||",
"formatMode",
"==",
"SIGNIFICANT_MAXFRAC",
";",
"if",
"(",
"useSignificant",
")",
"{",
"maxSigDigits",
"=",
"orDefault",
"(",
"options",
".",
"maximumSignificantDigits",
"(",
")",
",",
"_maxSigDigits",
")",
";",
"minSigDigits",
"=",
"orDefault",
"(",
"options",
".",
"minimumSignificantDigits",
"(",
")",
",",
"_minSigDigits",
")",
";",
"}",
"else",
"{",
"maxSigDigits",
"=",
"-",
"1",
";",
"minSigDigits",
"=",
"-",
"1",
";",
"}",
"}"
] | Set the pattern and initialize parameters based on the arguments, pattern and options settings. | [
"Set",
"the",
"pattern",
"and",
"initialize",
"parameters",
"based",
"on",
"the",
"arguments",
"pattern",
"and",
"options",
"settings",
"."
] | train | https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/numbers/NumberFormatContext.java#L54-L72 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/FindBugs.java | FindBugs.configureTrainingDatabases | public static void configureTrainingDatabases(IFindBugsEngine findBugs) throws IOException {
"""
Configure training databases.
@param findBugs
the IFindBugsEngine to configure
@throws IOException
"""
if (findBugs.emitTrainingOutput()) {
String trainingOutputDir = findBugs.getTrainingOutputDir();
if (!new File(trainingOutputDir).isDirectory()) {
throw new IOException("Training output directory " + trainingOutputDir + " does not exist");
}
AnalysisContext.currentAnalysisContext().setDatabaseOutputDir(trainingOutputDir);
// XXX: hack
System.setProperty("findbugs.checkreturn.savetraining", new File(trainingOutputDir, "checkReturn.db").getPath());
}
if (findBugs.useTrainingInput()) {
String trainingInputDir = findBugs.getTrainingInputDir();
if (!new File(trainingInputDir).isDirectory()) {
throw new IOException("Training input directory " + trainingInputDir + " does not exist");
}
AnalysisContext.currentAnalysisContext().setDatabaseInputDir(trainingInputDir);
AnalysisContext.currentAnalysisContext().loadInterproceduralDatabases();
// XXX: hack
System.setProperty("findbugs.checkreturn.loadtraining", new File(trainingInputDir, "checkReturn.db").getPath());
} else {
AnalysisContext.currentAnalysisContext().loadDefaultInterproceduralDatabases();
}
} | java | public static void configureTrainingDatabases(IFindBugsEngine findBugs) throws IOException {
if (findBugs.emitTrainingOutput()) {
String trainingOutputDir = findBugs.getTrainingOutputDir();
if (!new File(trainingOutputDir).isDirectory()) {
throw new IOException("Training output directory " + trainingOutputDir + " does not exist");
}
AnalysisContext.currentAnalysisContext().setDatabaseOutputDir(trainingOutputDir);
// XXX: hack
System.setProperty("findbugs.checkreturn.savetraining", new File(trainingOutputDir, "checkReturn.db").getPath());
}
if (findBugs.useTrainingInput()) {
String trainingInputDir = findBugs.getTrainingInputDir();
if (!new File(trainingInputDir).isDirectory()) {
throw new IOException("Training input directory " + trainingInputDir + " does not exist");
}
AnalysisContext.currentAnalysisContext().setDatabaseInputDir(trainingInputDir);
AnalysisContext.currentAnalysisContext().loadInterproceduralDatabases();
// XXX: hack
System.setProperty("findbugs.checkreturn.loadtraining", new File(trainingInputDir, "checkReturn.db").getPath());
} else {
AnalysisContext.currentAnalysisContext().loadDefaultInterproceduralDatabases();
}
} | [
"public",
"static",
"void",
"configureTrainingDatabases",
"(",
"IFindBugsEngine",
"findBugs",
")",
"throws",
"IOException",
"{",
"if",
"(",
"findBugs",
".",
"emitTrainingOutput",
"(",
")",
")",
"{",
"String",
"trainingOutputDir",
"=",
"findBugs",
".",
"getTrainingOutputDir",
"(",
")",
";",
"if",
"(",
"!",
"new",
"File",
"(",
"trainingOutputDir",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Training output directory \"",
"+",
"trainingOutputDir",
"+",
"\" does not exist\"",
")",
";",
"}",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"setDatabaseOutputDir",
"(",
"trainingOutputDir",
")",
";",
"// XXX: hack",
"System",
".",
"setProperty",
"(",
"\"findbugs.checkreturn.savetraining\"",
",",
"new",
"File",
"(",
"trainingOutputDir",
",",
"\"checkReturn.db\"",
")",
".",
"getPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"findBugs",
".",
"useTrainingInput",
"(",
")",
")",
"{",
"String",
"trainingInputDir",
"=",
"findBugs",
".",
"getTrainingInputDir",
"(",
")",
";",
"if",
"(",
"!",
"new",
"File",
"(",
"trainingInputDir",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Training input directory \"",
"+",
"trainingInputDir",
"+",
"\" does not exist\"",
")",
";",
"}",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"setDatabaseInputDir",
"(",
"trainingInputDir",
")",
";",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"loadInterproceduralDatabases",
"(",
")",
";",
"// XXX: hack",
"System",
".",
"setProperty",
"(",
"\"findbugs.checkreturn.loadtraining\"",
",",
"new",
"File",
"(",
"trainingInputDir",
",",
"\"checkReturn.db\"",
")",
".",
"getPath",
"(",
")",
")",
";",
"}",
"else",
"{",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"loadDefaultInterproceduralDatabases",
"(",
")",
";",
"}",
"}"
] | Configure training databases.
@param findBugs
the IFindBugsEngine to configure
@throws IOException | [
"Configure",
"training",
"databases",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/FindBugs.java#L218-L242 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.createImagesFromUrlsAsync | public Observable<ImageCreateSummary> createImagesFromUrlsAsync(UUID projectId, ImageUrlCreateBatch batch) {
"""
Add the provided images urls to the set of training images.
This API accepts a batch of urls, and optionally tags, to create images. There is a limit of 64 images and 20 tags.
@param projectId The project id
@param batch Image urls and tag ids. Limited to 64 images and 20 tags per batch
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImageCreateSummary object
"""
return createImagesFromUrlsWithServiceResponseAsync(projectId, batch).map(new Func1<ServiceResponse<ImageCreateSummary>, ImageCreateSummary>() {
@Override
public ImageCreateSummary call(ServiceResponse<ImageCreateSummary> response) {
return response.body();
}
});
} | java | public Observable<ImageCreateSummary> createImagesFromUrlsAsync(UUID projectId, ImageUrlCreateBatch batch) {
return createImagesFromUrlsWithServiceResponseAsync(projectId, batch).map(new Func1<ServiceResponse<ImageCreateSummary>, ImageCreateSummary>() {
@Override
public ImageCreateSummary call(ServiceResponse<ImageCreateSummary> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ImageCreateSummary",
">",
"createImagesFromUrlsAsync",
"(",
"UUID",
"projectId",
",",
"ImageUrlCreateBatch",
"batch",
")",
"{",
"return",
"createImagesFromUrlsWithServiceResponseAsync",
"(",
"projectId",
",",
"batch",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ImageCreateSummary",
">",
",",
"ImageCreateSummary",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ImageCreateSummary",
"call",
"(",
"ServiceResponse",
"<",
"ImageCreateSummary",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Add the provided images urls to the set of training images.
This API accepts a batch of urls, and optionally tags, to create images. There is a limit of 64 images and 20 tags.
@param projectId The project id
@param batch Image urls and tag ids. Limited to 64 images and 20 tags per batch
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImageCreateSummary object | [
"Add",
"the",
"provided",
"images",
"urls",
"to",
"the",
"set",
"of",
"training",
"images",
".",
"This",
"API",
"accepts",
"a",
"batch",
"of",
"urls",
"and",
"optionally",
"tags",
"to",
"create",
"images",
".",
"There",
"is",
"a",
"limit",
"of",
"64",
"images",
"and",
"20",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L3867-L3874 |
census-instrumentation/opencensus-java | impl_core/src/main/java/io/opencensus/implcore/internal/VarInt.java | VarInt.putVarLong | public static void putVarLong(long v, ByteBuffer sink) {
"""
Encodes a long integer in a variable-length encoding, 7 bits per byte, to a ByteBuffer sink.
@param v the value to encode
@param sink the ByteBuffer to add the encoded value
"""
while (true) {
int bits = ((int) v) & 0x7f;
v >>>= 7;
if (v == 0) {
sink.put((byte) bits);
return;
}
sink.put((byte) (bits | 0x80));
}
} | java | public static void putVarLong(long v, ByteBuffer sink) {
while (true) {
int bits = ((int) v) & 0x7f;
v >>>= 7;
if (v == 0) {
sink.put((byte) bits);
return;
}
sink.put((byte) (bits | 0x80));
}
} | [
"public",
"static",
"void",
"putVarLong",
"(",
"long",
"v",
",",
"ByteBuffer",
"sink",
")",
"{",
"while",
"(",
"true",
")",
"{",
"int",
"bits",
"=",
"(",
"(",
"int",
")",
"v",
")",
"&",
"0x7f",
";",
"v",
">>>=",
"7",
";",
"if",
"(",
"v",
"==",
"0",
")",
"{",
"sink",
".",
"put",
"(",
"(",
"byte",
")",
"bits",
")",
";",
"return",
";",
"}",
"sink",
".",
"put",
"(",
"(",
"byte",
")",
"(",
"bits",
"|",
"0x80",
")",
")",
";",
"}",
"}"
] | Encodes a long integer in a variable-length encoding, 7 bits per byte, to a ByteBuffer sink.
@param v the value to encode
@param sink the ByteBuffer to add the encoded value | [
"Encodes",
"a",
"long",
"integer",
"in",
"a",
"variable",
"-",
"length",
"encoding",
"7",
"bits",
"per",
"byte",
"to",
"a",
"ByteBuffer",
"sink",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/impl_core/src/main/java/io/opencensus/implcore/internal/VarInt.java#L272-L282 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/GitlabAPI.java | GitlabAPI.getBuildVariable | public GitlabBuildVariable getBuildVariable(Integer projectId, String key)
throws IOException {
"""
Gets build variable associated with a project and key.
@param projectId The ID of the project.
@param key The key of the variable.
@return A variable.
@throws IOException on gitlab api call error
"""
String tailUrl = GitlabProject.URL + "/" +
projectId +
GitlabBuildVariable.URL + "/" +
key;
return retrieve().to(tailUrl, GitlabBuildVariable.class);
} | java | public GitlabBuildVariable getBuildVariable(Integer projectId, String key)
throws IOException {
String tailUrl = GitlabProject.URL + "/" +
projectId +
GitlabBuildVariable.URL + "/" +
key;
return retrieve().to(tailUrl, GitlabBuildVariable.class);
} | [
"public",
"GitlabBuildVariable",
"getBuildVariable",
"(",
"Integer",
"projectId",
",",
"String",
"key",
")",
"throws",
"IOException",
"{",
"String",
"tailUrl",
"=",
"GitlabProject",
".",
"URL",
"+",
"\"/\"",
"+",
"projectId",
"+",
"GitlabBuildVariable",
".",
"URL",
"+",
"\"/\"",
"+",
"key",
";",
"return",
"retrieve",
"(",
")",
".",
"to",
"(",
"tailUrl",
",",
"GitlabBuildVariable",
".",
"class",
")",
";",
"}"
] | Gets build variable associated with a project and key.
@param projectId The ID of the project.
@param key The key of the variable.
@return A variable.
@throws IOException on gitlab api call error | [
"Gets",
"build",
"variable",
"associated",
"with",
"a",
"project",
"and",
"key",
"."
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L3645-L3652 |
aws/aws-sdk-java | aws-java-sdk-health/src/main/java/com/amazonaws/services/health/model/AffectedEntity.java | AffectedEntity.withTags | public AffectedEntity withTags(java.util.Map<String, String> tags) {
"""
<p>
A map of entity tags attached to the affected entity.
</p>
@param tags
A map of entity tags attached to the affected entity.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
} | java | public AffectedEntity withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | [
"public",
"AffectedEntity",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] | <p>
A map of entity tags attached to the affected entity.
</p>
@param tags
A map of entity tags attached to the affected entity.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"map",
"of",
"entity",
"tags",
"attached",
"to",
"the",
"affected",
"entity",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-health/src/main/java/com/amazonaws/services/health/model/AffectedEntity.java#L456-L459 |
joniles/mpxj | src/main/java/net/sf/mpxj/asta/TextFileRow.java | TextFileRow.getColumnValue | private Object getColumnValue(String table, String column, String data, int type, boolean epochDateFormat) throws MPXJException {
"""
Maps the text representation of column data to Java types.
@param table table name
@param column column name
@param data text representation of column data
@param type column data type
@param epochDateFormat true if date is represented as an offset from an epoch
@return Java representation of column data
@throws MPXJException
"""
try
{
Object value = null;
switch (type)
{
case Types.BIT:
{
value = DatatypeConverter.parseBoolean(data);
break;
}
case Types.VARCHAR:
case Types.LONGVARCHAR:
{
value = DatatypeConverter.parseString(data);
break;
}
case Types.TIME:
{
value = DatatypeConverter.parseBasicTime(data);
break;
}
case Types.TIMESTAMP:
{
if (epochDateFormat)
{
value = DatatypeConverter.parseEpochTimestamp(data);
}
else
{
value = DatatypeConverter.parseBasicTimestamp(data);
}
break;
}
case Types.DOUBLE:
{
value = DatatypeConverter.parseDouble(data);
break;
}
case Types.INTEGER:
{
value = DatatypeConverter.parseInteger(data);
break;
}
default:
{
throw new IllegalArgumentException("Unsupported SQL type: " + type);
}
}
return value;
}
catch (Exception ex)
{
throw new MPXJException("Failed to parse " + table + "." + column + " (data=" + data + ", type=" + type + ")", ex);
}
} | java | private Object getColumnValue(String table, String column, String data, int type, boolean epochDateFormat) throws MPXJException
{
try
{
Object value = null;
switch (type)
{
case Types.BIT:
{
value = DatatypeConverter.parseBoolean(data);
break;
}
case Types.VARCHAR:
case Types.LONGVARCHAR:
{
value = DatatypeConverter.parseString(data);
break;
}
case Types.TIME:
{
value = DatatypeConverter.parseBasicTime(data);
break;
}
case Types.TIMESTAMP:
{
if (epochDateFormat)
{
value = DatatypeConverter.parseEpochTimestamp(data);
}
else
{
value = DatatypeConverter.parseBasicTimestamp(data);
}
break;
}
case Types.DOUBLE:
{
value = DatatypeConverter.parseDouble(data);
break;
}
case Types.INTEGER:
{
value = DatatypeConverter.parseInteger(data);
break;
}
default:
{
throw new IllegalArgumentException("Unsupported SQL type: " + type);
}
}
return value;
}
catch (Exception ex)
{
throw new MPXJException("Failed to parse " + table + "." + column + " (data=" + data + ", type=" + type + ")", ex);
}
} | [
"private",
"Object",
"getColumnValue",
"(",
"String",
"table",
",",
"String",
"column",
",",
"String",
"data",
",",
"int",
"type",
",",
"boolean",
"epochDateFormat",
")",
"throws",
"MPXJException",
"{",
"try",
"{",
"Object",
"value",
"=",
"null",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"Types",
".",
"BIT",
":",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseBoolean",
"(",
"data",
")",
";",
"break",
";",
"}",
"case",
"Types",
".",
"VARCHAR",
":",
"case",
"Types",
".",
"LONGVARCHAR",
":",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseString",
"(",
"data",
")",
";",
"break",
";",
"}",
"case",
"Types",
".",
"TIME",
":",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseBasicTime",
"(",
"data",
")",
";",
"break",
";",
"}",
"case",
"Types",
".",
"TIMESTAMP",
":",
"{",
"if",
"(",
"epochDateFormat",
")",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseEpochTimestamp",
"(",
"data",
")",
";",
"}",
"else",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseBasicTimestamp",
"(",
"data",
")",
";",
"}",
"break",
";",
"}",
"case",
"Types",
".",
"DOUBLE",
":",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseDouble",
"(",
"data",
")",
";",
"break",
";",
"}",
"case",
"Types",
".",
"INTEGER",
":",
"{",
"value",
"=",
"DatatypeConverter",
".",
"parseInteger",
"(",
"data",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported SQL type: \"",
"+",
"type",
")",
";",
"}",
"}",
"return",
"value",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"MPXJException",
"(",
"\"Failed to parse \"",
"+",
"table",
"+",
"\".\"",
"+",
"column",
"+",
"\" (data=\"",
"+",
"data",
"+",
"\", type=\"",
"+",
"type",
"+",
"\")\"",
",",
"ex",
")",
";",
"}",
"}"
] | Maps the text representation of column data to Java types.
@param table table name
@param column column name
@param data text representation of column data
@param type column data type
@param epochDateFormat true if date is represented as an offset from an epoch
@return Java representation of column data
@throws MPXJException | [
"Maps",
"the",
"text",
"representation",
"of",
"column",
"data",
"to",
"Java",
"types",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/TextFileRow.java#L75-L140 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java | ResourceBundlesHandlerImpl.executeGlobalPreprocessing | private void executeGlobalPreprocessing(List<JoinableResourceBundle> bundlesToBuild, boolean processBundleFlag,
StopWatch stopWatch) {
"""
Executes the global preprocessing
@param bundlesToBuild
The list of bundles to rebuild
@param processBundleFlag
the flag indicating if the bundles needs to be processed
@param stopWatch
the stopWatch
"""
stopProcessIfNeeded();
if (resourceTypePreprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global preprocessing");
}
GlobalPreprocessingContext ctx = new GlobalPreprocessingContext(config, resourceHandler, processBundleFlag);
resourceTypePreprocessor.processBundles(ctx, bundles);
// Update the list of bundle to rebuild if new bundles have been
// detected as dirty in the global preprocessing phase
List<JoinableResourceBundle> currentBundles = getBundlesToRebuild();
for (JoinableResourceBundle b : currentBundles) {
if (!bundlesToBuild.contains(b)) {
bundlesToBuild.add(b);
}
}
if (stopWatch != null) {
stopWatch.stop();
}
}
} | java | private void executeGlobalPreprocessing(List<JoinableResourceBundle> bundlesToBuild, boolean processBundleFlag,
StopWatch stopWatch) {
stopProcessIfNeeded();
if (resourceTypePreprocessor != null) {
if (stopWatch != null) {
stopWatch.start("Global preprocessing");
}
GlobalPreprocessingContext ctx = new GlobalPreprocessingContext(config, resourceHandler, processBundleFlag);
resourceTypePreprocessor.processBundles(ctx, bundles);
// Update the list of bundle to rebuild if new bundles have been
// detected as dirty in the global preprocessing phase
List<JoinableResourceBundle> currentBundles = getBundlesToRebuild();
for (JoinableResourceBundle b : currentBundles) {
if (!bundlesToBuild.contains(b)) {
bundlesToBuild.add(b);
}
}
if (stopWatch != null) {
stopWatch.stop();
}
}
} | [
"private",
"void",
"executeGlobalPreprocessing",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundlesToBuild",
",",
"boolean",
"processBundleFlag",
",",
"StopWatch",
"stopWatch",
")",
"{",
"stopProcessIfNeeded",
"(",
")",
";",
"if",
"(",
"resourceTypePreprocessor",
"!=",
"null",
")",
"{",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"start",
"(",
"\"Global preprocessing\"",
")",
";",
"}",
"GlobalPreprocessingContext",
"ctx",
"=",
"new",
"GlobalPreprocessingContext",
"(",
"config",
",",
"resourceHandler",
",",
"processBundleFlag",
")",
";",
"resourceTypePreprocessor",
".",
"processBundles",
"(",
"ctx",
",",
"bundles",
")",
";",
"// Update the list of bundle to rebuild if new bundles have been",
"// detected as dirty in the global preprocessing phase",
"List",
"<",
"JoinableResourceBundle",
">",
"currentBundles",
"=",
"getBundlesToRebuild",
"(",
")",
";",
"for",
"(",
"JoinableResourceBundle",
"b",
":",
"currentBundles",
")",
"{",
"if",
"(",
"!",
"bundlesToBuild",
".",
"contains",
"(",
"b",
")",
")",
"{",
"bundlesToBuild",
".",
"add",
"(",
"b",
")",
";",
"}",
"}",
"if",
"(",
"stopWatch",
"!=",
"null",
")",
"{",
"stopWatch",
".",
"stop",
"(",
")",
";",
"}",
"}",
"}"
] | Executes the global preprocessing
@param bundlesToBuild
The list of bundles to rebuild
@param processBundleFlag
the flag indicating if the bundles needs to be processed
@param stopWatch
the stopWatch | [
"Executes",
"the",
"global",
"preprocessing"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ResourceBundlesHandlerImpl.java#L732-L756 |
tuenti/ButtonMenu | library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java | ScrollAnimator.onScrollPositionChanged | private void onScrollPositionChanged(int oldScrollPosition, int newScrollPosition) {
"""
Perform the "translateY" animation using the new scroll position and the old scroll position to show or hide
the animated view.
@param oldScrollPosition
@param newScrollPosition
"""
int newScrollDirection;
if (newScrollPosition < oldScrollPosition) {
newScrollDirection = SCROLL_TO_TOP;
} else {
newScrollDirection = SCROLL_TO_BOTTOM;
}
if (directionHasChanged(newScrollDirection)) {
translateYAnimatedView(newScrollDirection);
}
} | java | private void onScrollPositionChanged(int oldScrollPosition, int newScrollPosition) {
int newScrollDirection;
if (newScrollPosition < oldScrollPosition) {
newScrollDirection = SCROLL_TO_TOP;
} else {
newScrollDirection = SCROLL_TO_BOTTOM;
}
if (directionHasChanged(newScrollDirection)) {
translateYAnimatedView(newScrollDirection);
}
} | [
"private",
"void",
"onScrollPositionChanged",
"(",
"int",
"oldScrollPosition",
",",
"int",
"newScrollPosition",
")",
"{",
"int",
"newScrollDirection",
";",
"if",
"(",
"newScrollPosition",
"<",
"oldScrollPosition",
")",
"{",
"newScrollDirection",
"=",
"SCROLL_TO_TOP",
";",
"}",
"else",
"{",
"newScrollDirection",
"=",
"SCROLL_TO_BOTTOM",
";",
"}",
"if",
"(",
"directionHasChanged",
"(",
"newScrollDirection",
")",
")",
"{",
"translateYAnimatedView",
"(",
"newScrollDirection",
")",
";",
"}",
"}"
] | Perform the "translateY" animation using the new scroll position and the old scroll position to show or hide
the animated view.
@param oldScrollPosition
@param newScrollPosition | [
"Perform",
"the",
"translateY",
"animation",
"using",
"the",
"new",
"scroll",
"position",
"and",
"the",
"old",
"scroll",
"position",
"to",
"show",
"or",
"hide",
"the",
"animated",
"view",
"."
] | train | https://github.com/tuenti/ButtonMenu/blob/95791383f6f976933496542b54e8c6dbdd73e669/library/src/main/java/com/tuenti/buttonmenu/animator/ScrollAnimator.java#L192-L204 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java | ClassUtility.buildGenericType | public static Object buildGenericType(final Class<?> mainClass, final Class<?> assignableClass, final Object... parameters) throws CoreException {
"""
Build the nth generic type of a class.
@param mainClass The main class used (that contain at least one generic type)
@param assignableClass the parent type of the generic to build
@param parameters used by the constructor of the generic type
@return a new instance of the generic type
@throws CoreException if the instantiation fails
"""
return buildGenericType(mainClass, new Class<?>[] { assignableClass }, parameters);
} | java | public static Object buildGenericType(final Class<?> mainClass, final Class<?> assignableClass, final Object... parameters) throws CoreException {
return buildGenericType(mainClass, new Class<?>[] { assignableClass }, parameters);
} | [
"public",
"static",
"Object",
"buildGenericType",
"(",
"final",
"Class",
"<",
"?",
">",
"mainClass",
",",
"final",
"Class",
"<",
"?",
">",
"assignableClass",
",",
"final",
"Object",
"...",
"parameters",
")",
"throws",
"CoreException",
"{",
"return",
"buildGenericType",
"(",
"mainClass",
",",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"assignableClass",
"}",
",",
"parameters",
")",
";",
"}"
] | Build the nth generic type of a class.
@param mainClass The main class used (that contain at least one generic type)
@param assignableClass the parent type of the generic to build
@param parameters used by the constructor of the generic type
@return a new instance of the generic type
@throws CoreException if the instantiation fails | [
"Build",
"the",
"nth",
"generic",
"type",
"of",
"a",
"class",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ClassUtility.java#L85-L87 |
unbescape/unbescape | src/main/java/org/unbescape/uri/UriEscape.java | UriEscape.escapeUriQueryParam | public static void escapeUriQueryParam(final Reader reader, final Writer writer, final String encoding)
throws IOException {
"""
<p>
Perform am URI query parameter (name or value) <strong>escape</strong> operation
on a <tt>Reader</tt> input, writing results to a <tt>Writer</tt>.
</p>
<p>
The following are the only allowed chars in an URI query parameter (will not be escaped):
</p>
<ul>
<li><tt>A-Z a-z 0-9</tt></li>
<li><tt>- . _ ~</tt></li>
<li><tt>! $ ' ( ) * , ;</tt></li>
<li><tt>: @</tt></li>
<li><tt>/ ?</tt></li>
</ul>
<p>
All other chars will be escaped by converting them to the sequence of bytes that
represents them in the specified <em>encoding</em> and then representing each byte
in <tt>%HH</tt> syntax, being <tt>HH</tt> the hexadecimal representation of the byte.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param encoding the encoding to be used for escaping.
@throws IOException if an input/output exception occurs
@since 1.1.2
"""
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
if (encoding == null) {
throw new IllegalArgumentException("Argument 'encoding' cannot be null");
}
UriEscapeUtil.escape(reader, writer, UriEscapeUtil.UriEscapeType.QUERY_PARAM, encoding);
} | java | public static void escapeUriQueryParam(final Reader reader, final Writer writer, final String encoding)
throws IOException {
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
if (encoding == null) {
throw new IllegalArgumentException("Argument 'encoding' cannot be null");
}
UriEscapeUtil.escape(reader, writer, UriEscapeUtil.UriEscapeType.QUERY_PARAM, encoding);
} | [
"public",
"static",
"void",
"escapeUriQueryParam",
"(",
"final",
"Reader",
"reader",
",",
"final",
"Writer",
"writer",
",",
"final",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"if",
"(",
"writer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'writer' cannot be null\"",
")",
";",
"}",
"if",
"(",
"encoding",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'encoding' cannot be null\"",
")",
";",
"}",
"UriEscapeUtil",
".",
"escape",
"(",
"reader",
",",
"writer",
",",
"UriEscapeUtil",
".",
"UriEscapeType",
".",
"QUERY_PARAM",
",",
"encoding",
")",
";",
"}"
] | <p>
Perform am URI query parameter (name or value) <strong>escape</strong> operation
on a <tt>Reader</tt> input, writing results to a <tt>Writer</tt>.
</p>
<p>
The following are the only allowed chars in an URI query parameter (will not be escaped):
</p>
<ul>
<li><tt>A-Z a-z 0-9</tt></li>
<li><tt>- . _ ~</tt></li>
<li><tt>! $ ' ( ) * , ;</tt></li>
<li><tt>: @</tt></li>
<li><tt>/ ?</tt></li>
</ul>
<p>
All other chars will be escaped by converting them to the sequence of bytes that
represents them in the specified <em>encoding</em> and then representing each byte
in <tt>%HH</tt> syntax, being <tt>HH</tt> the hexadecimal representation of the byte.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param encoding the encoding to be used for escaping.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"am",
"URI",
"query",
"parameter",
"(",
"name",
"or",
"value",
")",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"Reader<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"following",
"are",
"the",
"only",
"allowed",
"chars",
"in",
"an",
"URI",
"query",
"parameter",
"(",
"will",
"not",
"be",
"escaped",
")",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"<tt",
">",
"A",
"-",
"Z",
"a",
"-",
"z",
"0",
"-",
"9<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
"-",
".",
"_",
"~<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
"!",
"$",
"(",
")",
"*",
";",
"<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
":",
"@<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
"/",
"?<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"All",
"other",
"chars",
"will",
"be",
"escaped",
"by",
"converting",
"them",
"to",
"the",
"sequence",
"of",
"bytes",
"that",
"represents",
"them",
"in",
"the",
"specified",
"<em",
">",
"encoding<",
"/",
"em",
">",
"and",
"then",
"representing",
"each",
"byte",
"in",
"<tt",
">",
"%HH<",
"/",
"tt",
">",
"syntax",
"being",
"<tt",
">",
"HH<",
"/",
"tt",
">",
"the",
"hexadecimal",
"representation",
"of",
"the",
"byte",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/uri/UriEscape.java#L1007-L1020 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceClient.java | InstanceClient.setTagsInstance | @BetaApi
public final Operation setTagsInstance(String instance, Tags tagsResource) {
"""
Sets network tags for the specified instance to the data included in the request.
<p>Sample code:
<pre><code>
try (InstanceClient instanceClient = InstanceClient.create()) {
ProjectZoneInstanceName instance = ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]");
Tags tagsResource = Tags.newBuilder().build();
Operation response = instanceClient.setTagsInstance(instance.toString(), tagsResource);
}
</code></pre>
@param instance Name of the instance scoping this request.
@param tagsResource A set of instance tags.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
SetTagsInstanceHttpRequest request =
SetTagsInstanceHttpRequest.newBuilder()
.setInstance(instance)
.setTagsResource(tagsResource)
.build();
return setTagsInstance(request);
} | java | @BetaApi
public final Operation setTagsInstance(String instance, Tags tagsResource) {
SetTagsInstanceHttpRequest request =
SetTagsInstanceHttpRequest.newBuilder()
.setInstance(instance)
.setTagsResource(tagsResource)
.build();
return setTagsInstance(request);
} | [
"@",
"BetaApi",
"public",
"final",
"Operation",
"setTagsInstance",
"(",
"String",
"instance",
",",
"Tags",
"tagsResource",
")",
"{",
"SetTagsInstanceHttpRequest",
"request",
"=",
"SetTagsInstanceHttpRequest",
".",
"newBuilder",
"(",
")",
".",
"setInstance",
"(",
"instance",
")",
".",
"setTagsResource",
"(",
"tagsResource",
")",
".",
"build",
"(",
")",
";",
"return",
"setTagsInstance",
"(",
"request",
")",
";",
"}"
] | Sets network tags for the specified instance to the data included in the request.
<p>Sample code:
<pre><code>
try (InstanceClient instanceClient = InstanceClient.create()) {
ProjectZoneInstanceName instance = ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]");
Tags tagsResource = Tags.newBuilder().build();
Operation response = instanceClient.setTagsInstance(instance.toString(), tagsResource);
}
</code></pre>
@param instance Name of the instance scoping this request.
@param tagsResource A set of instance tags.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Sets",
"network",
"tags",
"for",
"the",
"specified",
"instance",
"to",
"the",
"data",
"included",
"in",
"the",
"request",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceClient.java#L3161-L3170 |
windup/windup | rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ArchiveCoordinateService.java | ArchiveCoordinateService.getSingleOrCreate | public ArchiveCoordinateModel getSingleOrCreate(String groupId, String artifactId, String version) {
"""
Returns a single ArchiveCoordinateModel with given G:A:V. Creates it if it does not already exist.
"""
ArchiveCoordinateModel archive = findSingle(groupId, artifactId, version);
if (archive != null)
return archive;
else
return create().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
} | java | public ArchiveCoordinateModel getSingleOrCreate(String groupId, String artifactId, String version)
{
ArchiveCoordinateModel archive = findSingle(groupId, artifactId, version);
if (archive != null)
return archive;
else
return create().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
} | [
"public",
"ArchiveCoordinateModel",
"getSingleOrCreate",
"(",
"String",
"groupId",
",",
"String",
"artifactId",
",",
"String",
"version",
")",
"{",
"ArchiveCoordinateModel",
"archive",
"=",
"findSingle",
"(",
"groupId",
",",
"artifactId",
",",
"version",
")",
";",
"if",
"(",
"archive",
"!=",
"null",
")",
"return",
"archive",
";",
"else",
"return",
"create",
"(",
")",
".",
"setGroupId",
"(",
"groupId",
")",
".",
"setArtifactId",
"(",
"artifactId",
")",
".",
"setVersion",
"(",
"version",
")",
";",
"}"
] | Returns a single ArchiveCoordinateModel with given G:A:V. Creates it if it does not already exist. | [
"Returns",
"a",
"single",
"ArchiveCoordinateModel",
"with",
"given",
"G",
":",
"A",
":",
"V",
".",
"Creates",
"it",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ArchiveCoordinateService.java#L29-L36 |
devnied/EMV-NFC-Paycard-Enrollment | library/src/main/java/com/github/devnied/emvnfccard/parser/apdu/impl/AbstractByteBean.java | AbstractByteBean.setField | protected void setField(final Field field, final IFile pData, final Object pValue) {
"""
Method used to set the value of a field
@param field
the field to set
@param pData
Object containing the field
@param pValue
the value of the field
"""
if (field != null) {
try {
field.set(pData, pValue);
} catch (IllegalArgumentException e) {
LOGGER.error("Parameters of fied.set are not valid", e);
} catch (IllegalAccessException e) {
LOGGER.error("Impossible to set the Field :" + field.getName(), e);
}
}
} | java | protected void setField(final Field field, final IFile pData, final Object pValue) {
if (field != null) {
try {
field.set(pData, pValue);
} catch (IllegalArgumentException e) {
LOGGER.error("Parameters of fied.set are not valid", e);
} catch (IllegalAccessException e) {
LOGGER.error("Impossible to set the Field :" + field.getName(), e);
}
}
} | [
"protected",
"void",
"setField",
"(",
"final",
"Field",
"field",
",",
"final",
"IFile",
"pData",
",",
"final",
"Object",
"pValue",
")",
"{",
"if",
"(",
"field",
"!=",
"null",
")",
"{",
"try",
"{",
"field",
".",
"set",
"(",
"pData",
",",
"pValue",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Parameters of fied.set are not valid\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Impossible to set the Field :\"",
"+",
"field",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Method used to set the value of a field
@param field
the field to set
@param pData
Object containing the field
@param pValue
the value of the field | [
"Method",
"used",
"to",
"set",
"the",
"value",
"of",
"a",
"field"
] | train | https://github.com/devnied/EMV-NFC-Paycard-Enrollment/blob/bfbd3960708689154a7a75c8a9a934197d738a5b/library/src/main/java/com/github/devnied/emvnfccard/parser/apdu/impl/AbstractByteBean.java#L113-L123 |
infinispan/infinispan | extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java | CacheStatisticManager.beginTransaction | public final void beginTransaction(GlobalTransaction globalTransaction, boolean local) {
"""
Signals the start of a transaction.
@param local {@code true} if the transaction is local.
"""
if (local) {
//Not overriding the InitialValue method leads me to have "null" at the first invocation of get()
TransactionStatistics lts = createTransactionStatisticIfAbsent(globalTransaction, true);
if (trace) {
log.tracef("Local transaction statistic is already initialized: %s", lts);
}
} else {
TransactionStatistics rts = createTransactionStatisticIfAbsent(globalTransaction, false);
if (trace) {
log.tracef("Using the remote transaction statistic %s for transaction %s", rts, globalTransaction);
}
}
} | java | public final void beginTransaction(GlobalTransaction globalTransaction, boolean local) {
if (local) {
//Not overriding the InitialValue method leads me to have "null" at the first invocation of get()
TransactionStatistics lts = createTransactionStatisticIfAbsent(globalTransaction, true);
if (trace) {
log.tracef("Local transaction statistic is already initialized: %s", lts);
}
} else {
TransactionStatistics rts = createTransactionStatisticIfAbsent(globalTransaction, false);
if (trace) {
log.tracef("Using the remote transaction statistic %s for transaction %s", rts, globalTransaction);
}
}
} | [
"public",
"final",
"void",
"beginTransaction",
"(",
"GlobalTransaction",
"globalTransaction",
",",
"boolean",
"local",
")",
"{",
"if",
"(",
"local",
")",
"{",
"//Not overriding the InitialValue method leads me to have \"null\" at the first invocation of get()",
"TransactionStatistics",
"lts",
"=",
"createTransactionStatisticIfAbsent",
"(",
"globalTransaction",
",",
"true",
")",
";",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"Local transaction statistic is already initialized: %s\"",
",",
"lts",
")",
";",
"}",
"}",
"else",
"{",
"TransactionStatistics",
"rts",
"=",
"createTransactionStatisticIfAbsent",
"(",
"globalTransaction",
",",
"false",
")",
";",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"Using the remote transaction statistic %s for transaction %s\"",
",",
"rts",
",",
"globalTransaction",
")",
";",
"}",
"}",
"}"
] | Signals the start of a transaction.
@param local {@code true} if the transaction is local. | [
"Signals",
"the",
"start",
"of",
"a",
"transaction",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/extended-statistics/src/main/java/org/infinispan/stats/CacheStatisticManager.java#L170-L183 |
landawn/AbacusUtil | src/com/landawn/abacus/util/Fraction.java | Fraction.of | public static Fraction of(String str) {
"""
<p>
Creates a Fraction from a <code>String</code>.
</p>
<p>
The formats accepted are:
</p>
<ol>
<li><code>double</code> String containing a dot</li>
<li>'X Y/Z'</li>
<li>'Y/Z'</li>
<li>'X' (a simple whole number)</li>
</ol>
<p>
and a .
</p>
@param str
the string to parse, must not be <code>null</code>
@return the new <code>Fraction</code> instance
@throws IllegalArgumentException
if the string is <code>null</code>
@throws NumberFormatException
if the number format is invalid
"""
if (str == null) {
throw new IllegalArgumentException("The string must not be null");
}
// parse double format
int pos = str.indexOf('.');
if (pos >= 0) {
return of(Double.parseDouble(str));
}
// parse X Y/Z format
pos = str.indexOf(' ');
if (pos > 0) {
final int whole = Integer.parseInt(str.substring(0, pos));
str = str.substring(pos + 1);
pos = str.indexOf('/');
if (pos < 0) {
throw new NumberFormatException("The fraction could not be parsed as the format X Y/Z");
} else {
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return of(whole, numer, denom);
}
}
// parse Y/Z format
pos = str.indexOf('/');
if (pos < 0) {
// simple whole number
return of(Integer.parseInt(str), 1);
} else {
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return of(numer, denom);
}
} | java | public static Fraction of(String str) {
if (str == null) {
throw new IllegalArgumentException("The string must not be null");
}
// parse double format
int pos = str.indexOf('.');
if (pos >= 0) {
return of(Double.parseDouble(str));
}
// parse X Y/Z format
pos = str.indexOf(' ');
if (pos > 0) {
final int whole = Integer.parseInt(str.substring(0, pos));
str = str.substring(pos + 1);
pos = str.indexOf('/');
if (pos < 0) {
throw new NumberFormatException("The fraction could not be parsed as the format X Y/Z");
} else {
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return of(whole, numer, denom);
}
}
// parse Y/Z format
pos = str.indexOf('/');
if (pos < 0) {
// simple whole number
return of(Integer.parseInt(str), 1);
} else {
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return of(numer, denom);
}
} | [
"public",
"static",
"Fraction",
"of",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The string must not be null\"",
")",
";",
"}",
"// parse double format",
"int",
"pos",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
">=",
"0",
")",
"{",
"return",
"of",
"(",
"Double",
".",
"parseDouble",
"(",
"str",
")",
")",
";",
"}",
"// parse X Y/Z format",
"pos",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
">",
"0",
")",
"{",
"final",
"int",
"whole",
"=",
"Integer",
".",
"parseInt",
"(",
"str",
".",
"substring",
"(",
"0",
",",
"pos",
")",
")",
";",
"str",
"=",
"str",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
";",
"pos",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
"<",
"0",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"The fraction could not be parsed as the format X Y/Z\"",
")",
";",
"}",
"else",
"{",
"final",
"int",
"numer",
"=",
"Integer",
".",
"parseInt",
"(",
"str",
".",
"substring",
"(",
"0",
",",
"pos",
")",
")",
";",
"final",
"int",
"denom",
"=",
"Integer",
".",
"parseInt",
"(",
"str",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
")",
";",
"return",
"of",
"(",
"whole",
",",
"numer",
",",
"denom",
")",
";",
"}",
"}",
"// parse Y/Z format",
"pos",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
"<",
"0",
")",
"{",
"// simple whole number",
"return",
"of",
"(",
"Integer",
".",
"parseInt",
"(",
"str",
")",
",",
"1",
")",
";",
"}",
"else",
"{",
"final",
"int",
"numer",
"=",
"Integer",
".",
"parseInt",
"(",
"str",
".",
"substring",
"(",
"0",
",",
"pos",
")",
")",
";",
"final",
"int",
"denom",
"=",
"Integer",
".",
"parseInt",
"(",
"str",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
")",
";",
"return",
"of",
"(",
"numer",
",",
"denom",
")",
";",
"}",
"}"
] | <p>
Creates a Fraction from a <code>String</code>.
</p>
<p>
The formats accepted are:
</p>
<ol>
<li><code>double</code> String containing a dot</li>
<li>'X Y/Z'</li>
<li>'Y/Z'</li>
<li>'X' (a simple whole number)</li>
</ol>
<p>
and a .
</p>
@param str
the string to parse, must not be <code>null</code>
@return the new <code>Fraction</code> instance
@throws IllegalArgumentException
if the string is <code>null</code>
@throws NumberFormatException
if the number format is invalid | [
"<p",
">",
"Creates",
"a",
"Fraction",
"from",
"a",
"<code",
">",
"String<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Fraction.java#L366-L401 |
dita-ot/dita-ot | src/main/java/org/dita/dost/invoker/Main.java | Main.findBuildFile | private File findBuildFile(final String start, final String suffix) {
"""
Search parent directories for the build file.
<p>
Takes the given target as a suffix to append to each parent directory in
search of a build file. Once the root of the file-system has been reached
<code>null</code> is returned.
@param start Leaf directory of search. Must not be <code>null</code>.
@param suffix Suffix filename to look for in parents. Must not be
<code>null</code>.
@return A handle to the build file if one is found, <code>null</code> if
not
"""
if (args.msgOutputLevel >= Project.MSG_INFO) {
System.out.println("Searching for " + suffix + " ...");
}
File parent = new File(new File(start).getAbsolutePath());
File file = new File(parent, suffix);
// check if the target file exists in the current directory
while (!file.exists()) {
// change to parent directory
parent = getParentFile(parent);
// if parent is null, then we are at the root of the fs,
// complain that we can't find the build file.
if (parent == null) {
return null;
}
// refresh our file handle
file = new File(parent, suffix);
}
return file;
} | java | private File findBuildFile(final String start, final String suffix) {
if (args.msgOutputLevel >= Project.MSG_INFO) {
System.out.println("Searching for " + suffix + " ...");
}
File parent = new File(new File(start).getAbsolutePath());
File file = new File(parent, suffix);
// check if the target file exists in the current directory
while (!file.exists()) {
// change to parent directory
parent = getParentFile(parent);
// if parent is null, then we are at the root of the fs,
// complain that we can't find the build file.
if (parent == null) {
return null;
}
// refresh our file handle
file = new File(parent, suffix);
}
return file;
} | [
"private",
"File",
"findBuildFile",
"(",
"final",
"String",
"start",
",",
"final",
"String",
"suffix",
")",
"{",
"if",
"(",
"args",
".",
"msgOutputLevel",
">=",
"Project",
".",
"MSG_INFO",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Searching for \"",
"+",
"suffix",
"+",
"\" ...\"",
")",
";",
"}",
"File",
"parent",
"=",
"new",
"File",
"(",
"new",
"File",
"(",
"start",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"parent",
",",
"suffix",
")",
";",
"// check if the target file exists in the current directory",
"while",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"// change to parent directory",
"parent",
"=",
"getParentFile",
"(",
"parent",
")",
";",
"// if parent is null, then we are at the root of the fs,",
"// complain that we can't find the build file.",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// refresh our file handle",
"file",
"=",
"new",
"File",
"(",
"parent",
",",
"suffix",
")",
";",
"}",
"return",
"file",
";",
"}"
] | Search parent directories for the build file.
<p>
Takes the given target as a suffix to append to each parent directory in
search of a build file. Once the root of the file-system has been reached
<code>null</code> is returned.
@param start Leaf directory of search. Must not be <code>null</code>.
@param suffix Suffix filename to look for in parents. Must not be
<code>null</code>.
@return A handle to the build file if one is found, <code>null</code> if
not | [
"Search",
"parent",
"directories",
"for",
"the",
"build",
"file",
".",
"<p",
">",
"Takes",
"the",
"given",
"target",
"as",
"a",
"suffix",
"to",
"append",
"to",
"each",
"parent",
"directory",
"in",
"search",
"of",
"a",
"build",
"file",
".",
"Once",
"the",
"root",
"of",
"the",
"file",
"-",
"system",
"has",
"been",
"reached",
"<code",
">",
"null<",
"/",
"code",
">",
"is",
"returned",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/Main.java#L515-L539 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java | SegmentServiceImpl.readMetaSegment | private boolean readMetaSegment(ReadStream is, int crc)
throws IOException {
"""
metadata for a segment
<pre><code>
address int48
length int16
crc int32
</code></pre>
"""
long value = BitsUtil.readLong(is);
crc = Crc32Caucho.generate(crc, value);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-segment crc mismatch");
return false;
}
long address = value & ~0xffff;
int length = (int) ((value & 0xffff) << 16);
SegmentExtent segment = new SegmentExtent(_segmentId++, address, length);
SegmentMeta segmentMeta = findSegmentMeta(length);
segmentMeta.addSegment(segment);
return true;
} | java | private boolean readMetaSegment(ReadStream is, int crc)
throws IOException
{
long value = BitsUtil.readLong(is);
crc = Crc32Caucho.generate(crc, value);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-segment crc mismatch");
return false;
}
long address = value & ~0xffff;
int length = (int) ((value & 0xffff) << 16);
SegmentExtent segment = new SegmentExtent(_segmentId++, address, length);
SegmentMeta segmentMeta = findSegmentMeta(length);
segmentMeta.addSegment(segment);
return true;
} | [
"private",
"boolean",
"readMetaSegment",
"(",
"ReadStream",
"is",
",",
"int",
"crc",
")",
"throws",
"IOException",
"{",
"long",
"value",
"=",
"BitsUtil",
".",
"readLong",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generate",
"(",
"crc",
",",
"value",
")",
";",
"int",
"crcFile",
"=",
"BitsUtil",
".",
"readInt",
"(",
"is",
")",
";",
"if",
"(",
"crcFile",
"!=",
"crc",
")",
"{",
"log",
".",
"fine",
"(",
"\"meta-segment crc mismatch\"",
")",
";",
"return",
"false",
";",
"}",
"long",
"address",
"=",
"value",
"&",
"~",
"0xffff",
";",
"int",
"length",
"=",
"(",
"int",
")",
"(",
"(",
"value",
"&",
"0xffff",
")",
"<<",
"16",
")",
";",
"SegmentExtent",
"segment",
"=",
"new",
"SegmentExtent",
"(",
"_segmentId",
"++",
",",
"address",
",",
"length",
")",
";",
"SegmentMeta",
"segmentMeta",
"=",
"findSegmentMeta",
"(",
"length",
")",
";",
"segmentMeta",
".",
"addSegment",
"(",
"segment",
")",
";",
"return",
"true",
";",
"}"
] | metadata for a segment
<pre><code>
address int48
length int16
crc int32
</code></pre> | [
"metadata",
"for",
"a",
"segment"
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java#L822-L846 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/SliceOps.java | SliceOps.calcSliceFence | private static long calcSliceFence(long skip, long limit) {
"""
Calculates the slice fence, which is one past the index of the slice
range
@param skip the number of elements to skip, assumed to be >= 0
@param limit the number of elements to limit, assumed to be >= 0, with
a value of {@code Long.MAX_VALUE} if there is no limit
@return the slice fence.
"""
long sliceFence = limit >= 0 ? skip + limit : Long.MAX_VALUE;
// Check for overflow
return (sliceFence >= 0) ? sliceFence : Long.MAX_VALUE;
} | java | private static long calcSliceFence(long skip, long limit) {
long sliceFence = limit >= 0 ? skip + limit : Long.MAX_VALUE;
// Check for overflow
return (sliceFence >= 0) ? sliceFence : Long.MAX_VALUE;
} | [
"private",
"static",
"long",
"calcSliceFence",
"(",
"long",
"skip",
",",
"long",
"limit",
")",
"{",
"long",
"sliceFence",
"=",
"limit",
">=",
"0",
"?",
"skip",
"+",
"limit",
":",
"Long",
".",
"MAX_VALUE",
";",
"// Check for overflow",
"return",
"(",
"sliceFence",
">=",
"0",
")",
"?",
"sliceFence",
":",
"Long",
".",
"MAX_VALUE",
";",
"}"
] | Calculates the slice fence, which is one past the index of the slice
range
@param skip the number of elements to skip, assumed to be >= 0
@param limit the number of elements to limit, assumed to be >= 0, with
a value of {@code Long.MAX_VALUE} if there is no limit
@return the slice fence. | [
"Calculates",
"the",
"slice",
"fence",
"which",
"is",
"one",
"past",
"the",
"index",
"of",
"the",
"slice",
"range"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/SliceOps.java#L64-L68 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/containerregistry/v2018_09_01/implementation/TasksInner.java | TasksInner.beginCreateAsync | public Observable<TaskInner> beginCreateAsync(String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
"""
Creates a task for a container registry with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param taskName The name of the container registry task.
@param taskCreateParameters The parameters for creating a task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the TaskInner object
"""
return beginCreateWithServiceResponseAsync(resourceGroupName, registryName, taskName, taskCreateParameters).map(new Func1<ServiceResponse<TaskInner>, TaskInner>() {
@Override
public TaskInner call(ServiceResponse<TaskInner> response) {
return response.body();
}
});
} | java | public Observable<TaskInner> beginCreateAsync(String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
return beginCreateWithServiceResponseAsync(resourceGroupName, registryName, taskName, taskCreateParameters).map(new Func1<ServiceResponse<TaskInner>, TaskInner>() {
@Override
public TaskInner call(ServiceResponse<TaskInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"TaskInner",
">",
"beginCreateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"taskName",
",",
"TaskInner",
"taskCreateParameters",
")",
"{",
"return",
"beginCreateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"taskName",
",",
"taskCreateParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"TaskInner",
">",
",",
"TaskInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"TaskInner",
"call",
"(",
"ServiceResponse",
"<",
"TaskInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a task for a container registry with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param taskName The name of the container registry task.
@param taskCreateParameters The parameters for creating a task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the TaskInner object | [
"Creates",
"a",
"task",
"for",
"a",
"container",
"registry",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/containerregistry/v2018_09_01/implementation/TasksInner.java#L444-L451 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/entity/message/MessageImpl.java | MessageImpl.addReaction | public void addReaction(Emoji emoji, boolean you) {
"""
Adds an emoji to the list of reactions.
@param emoji The emoji.
@param you Whether this reaction is used by you or not.
"""
Optional<Reaction> reaction = reactions.stream().filter(r -> emoji.equalsEmoji(r.getEmoji())).findAny();
reaction.ifPresent(r -> ((ReactionImpl) r).incrementCount(you));
if (!reaction.isPresent()) {
reactions.add(new ReactionImpl(this, emoji, 1, you));
}
} | java | public void addReaction(Emoji emoji, boolean you) {
Optional<Reaction> reaction = reactions.stream().filter(r -> emoji.equalsEmoji(r.getEmoji())).findAny();
reaction.ifPresent(r -> ((ReactionImpl) r).incrementCount(you));
if (!reaction.isPresent()) {
reactions.add(new ReactionImpl(this, emoji, 1, you));
}
} | [
"public",
"void",
"addReaction",
"(",
"Emoji",
"emoji",
",",
"boolean",
"you",
")",
"{",
"Optional",
"<",
"Reaction",
">",
"reaction",
"=",
"reactions",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"r",
"->",
"emoji",
".",
"equalsEmoji",
"(",
"r",
".",
"getEmoji",
"(",
")",
")",
")",
".",
"findAny",
"(",
")",
";",
"reaction",
".",
"ifPresent",
"(",
"r",
"->",
"(",
"(",
"ReactionImpl",
")",
"r",
")",
".",
"incrementCount",
"(",
"you",
")",
")",
";",
"if",
"(",
"!",
"reaction",
".",
"isPresent",
"(",
")",
")",
"{",
"reactions",
".",
"add",
"(",
"new",
"ReactionImpl",
"(",
"this",
",",
"emoji",
",",
"1",
",",
"you",
")",
")",
";",
"}",
"}"
] | Adds an emoji to the list of reactions.
@param emoji The emoji.
@param you Whether this reaction is used by you or not. | [
"Adds",
"an",
"emoji",
"to",
"the",
"list",
"of",
"reactions",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/entity/message/MessageImpl.java#L260-L266 |
js-lib-com/template.xhtml | src/main/java/js/template/xhtml/ValueOperator.java | ValueOperator.doExec | @Override
protected Object doExec(Element element, Object scope, String propertyPath, Object... arguments) throws TemplateException {
"""
Execute VALUE operator. Uses property path to extract content value, convert it to string and set element <em>value</em>
attribute.
@param element context element, unused,
@param scope scope object,
@param propertyPath property path,
@param arguments optional arguments, {@link Format} instance in this case.
@return always returns null for void.
@throws TemplateException if requested content value is undefined.
"""
if (!propertyPath.equals(".") && ConverterRegistry.hasType(scope.getClass())) {
throw new TemplateException("Operand is property path but scope is not an object.");
}
String value = null;
Format format = (Format) arguments[0];
if (format != null) {
value = this.content.getString(scope, propertyPath, format);
} else {
Object object = this.content.getObject(scope, propertyPath);
if (object != null) {
if (!ConverterRegistry.hasType(object.getClass())) {
throw new TemplateException("Invalid element |%s|. Operand for VALUE operator without formatter should be convertible to string.", element);
}
value = ConverterRegistry.getConverter().asString(object);
}
}
if (value == null) {
return null;
}
return new AttrImpl("value", value);
} | java | @Override
protected Object doExec(Element element, Object scope, String propertyPath, Object... arguments) throws TemplateException {
if (!propertyPath.equals(".") && ConverterRegistry.hasType(scope.getClass())) {
throw new TemplateException("Operand is property path but scope is not an object.");
}
String value = null;
Format format = (Format) arguments[0];
if (format != null) {
value = this.content.getString(scope, propertyPath, format);
} else {
Object object = this.content.getObject(scope, propertyPath);
if (object != null) {
if (!ConverterRegistry.hasType(object.getClass())) {
throw new TemplateException("Invalid element |%s|. Operand for VALUE operator without formatter should be convertible to string.", element);
}
value = ConverterRegistry.getConverter().asString(object);
}
}
if (value == null) {
return null;
}
return new AttrImpl("value", value);
} | [
"@",
"Override",
"protected",
"Object",
"doExec",
"(",
"Element",
"element",
",",
"Object",
"scope",
",",
"String",
"propertyPath",
",",
"Object",
"...",
"arguments",
")",
"throws",
"TemplateException",
"{",
"if",
"(",
"!",
"propertyPath",
".",
"equals",
"(",
"\".\"",
")",
"&&",
"ConverterRegistry",
".",
"hasType",
"(",
"scope",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"TemplateException",
"(",
"\"Operand is property path but scope is not an object.\"",
")",
";",
"}",
"String",
"value",
"=",
"null",
";",
"Format",
"format",
"=",
"(",
"Format",
")",
"arguments",
"[",
"0",
"]",
";",
"if",
"(",
"format",
"!=",
"null",
")",
"{",
"value",
"=",
"this",
".",
"content",
".",
"getString",
"(",
"scope",
",",
"propertyPath",
",",
"format",
")",
";",
"}",
"else",
"{",
"Object",
"object",
"=",
"this",
".",
"content",
".",
"getObject",
"(",
"scope",
",",
"propertyPath",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"ConverterRegistry",
".",
"hasType",
"(",
"object",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"TemplateException",
"(",
"\"Invalid element |%s|. Operand for VALUE operator without formatter should be convertible to string.\"",
",",
"element",
")",
";",
"}",
"value",
"=",
"ConverterRegistry",
".",
"getConverter",
"(",
")",
".",
"asString",
"(",
"object",
")",
";",
"}",
"}",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"AttrImpl",
"(",
"\"value\"",
",",
"value",
")",
";",
"}"
] | Execute VALUE operator. Uses property path to extract content value, convert it to string and set element <em>value</em>
attribute.
@param element context element, unused,
@param scope scope object,
@param propertyPath property path,
@param arguments optional arguments, {@link Format} instance in this case.
@return always returns null for void.
@throws TemplateException if requested content value is undefined. | [
"Execute",
"VALUE",
"operator",
".",
"Uses",
"property",
"path",
"to",
"extract",
"content",
"value",
"convert",
"it",
"to",
"string",
"and",
"set",
"element",
"<em",
">",
"value<",
"/",
"em",
">",
"attribute",
"."
] | train | https://github.com/js-lib-com/template.xhtml/blob/d50cec08aca9ab9680baebe2a26a341c096564fb/src/main/java/js/template/xhtml/ValueOperator.java#L46-L70 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.